1. added wxNcPaintEvent and generate it under GTK/use under wxUniv

2. minor fixes to wxCheck/Radio/wxCheckList/Box appearance - now seems fine


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8368 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-09-15 14:35:31 +00:00
parent 07e9834fca
commit ebd161b6c8
12 changed files with 71 additions and 10 deletions

3
TODO
View File

@@ -7,4 +7,5 @@ MSW
GTK GTK
* check/radio box remains pressed * check/radio box remains pressed in win32 mode
* wxCheckListBox::HitTest doesn't work (clicking the check)

View File

@@ -900,6 +900,15 @@ public:
#endif // debug #endif // debug
}; };
class WXDLLEXPORT wxNcPaintEvent : public wxEvent
{
public:
wxNcPaintEvent(int id = 0) : wxEvent(id) { SetEventType(wxEVT_NC_PAINT); }
private:
DECLARE_DYNAMIC_CLASS(wxNcPaintEvent)
};
// Erase background event class // Erase background event class
/* /*
wxEVT_ERASE_BACKGROUND wxEVT_ERASE_BACKGROUND
@@ -1639,6 +1648,7 @@ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \
#define EVT_END_SESSION(func) { wxEVT_END_SESSION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL }, #define EVT_END_SESSION(func) { wxEVT_END_SESSION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL },
#define EVT_QUERY_END_SESSION(func) { wxEVT_QUERY_END_SESSION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL }, #define EVT_QUERY_END_SESSION(func) { wxEVT_QUERY_END_SESSION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL },
#define EVT_PAINT(func) { wxEVT_PAINT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxPaintEventFunction) & func, (wxObject *) NULL }, #define EVT_PAINT(func) { wxEVT_PAINT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxPaintEventFunction) & func, (wxObject *) NULL },
#define EVT_NC_PAINT(func) { wxEVT_NC_PAINT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxPaintEventFunction) & func, (wxObject *) NULL },
#define EVT_ERASE_BACKGROUND(func) { wxEVT_ERASE_BACKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxEraseEventFunction) & func, (wxObject *) NULL }, #define EVT_ERASE_BACKGROUND(func) { wxEVT_ERASE_BACKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxEraseEventFunction) & func, (wxObject *) NULL },
#define EVT_CHAR(func) { wxEVT_CHAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL }, #define EVT_CHAR(func) { wxEVT_CHAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL },
#define EVT_KEY_DOWN(func) { wxEVT_KEY_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL }, #define EVT_KEY_DOWN(func) { wxEVT_KEY_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL },

View File

@@ -223,6 +223,7 @@ public:
// get the size of a checkbox/radio button bitmap // get the size of a checkbox/radio button bitmap
virtual wxSize GetCheckBitmapSize() const = 0; virtual wxSize GetCheckBitmapSize() const = 0;
virtual wxSize GetRadioBitmapSize() const = 0; virtual wxSize GetRadioBitmapSize() const = 0;
virtual wxCoord GetCheckItemMargin() const = 0;
// virtual dtor for any base class // virtual dtor for any base class
virtual ~wxRenderer(); virtual ~wxRenderer();
@@ -390,6 +391,8 @@ public:
{ return m_renderer->GetCheckBitmapSize(); } { return m_renderer->GetCheckBitmapSize(); }
virtual wxSize GetRadioBitmapSize() const virtual wxSize GetRadioBitmapSize() const
{ return m_renderer->GetRadioBitmapSize(); } { return m_renderer->GetRadioBitmapSize(); }
virtual wxCoord GetCheckItemMargin() const
{ return m_renderer->GetCheckItemMargin(); }
protected: protected:
wxRenderer *m_renderer; wxRenderer *m_renderer;

View File

@@ -170,6 +170,7 @@ protected:
// event handlers // event handlers
void OnSize(wxSizeEvent& event); void OnSize(wxSizeEvent& event);
void OnNcPaint(wxPaintEvent& event);
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
void OnErase(wxEraseEvent& event); void OnErase(wxEraseEvent& event);

View File

@@ -63,6 +63,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent, wxEvent)
IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent, wxEvent)
IMPLEMENT_DYNAMIC_CLASS(wxSizeEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxSizeEvent, wxEvent)
IMPLEMENT_DYNAMIC_CLASS(wxPaintEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxPaintEvent, wxEvent)
IMPLEMENT_DYNAMIC_CLASS(wxNcPaintEvent, wxEvent)
IMPLEMENT_DYNAMIC_CLASS(wxEraseEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxEraseEvent, wxEvent)
IMPLEMENT_DYNAMIC_CLASS(wxMoveEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxMoveEvent, wxEvent)
IMPLEMENT_DYNAMIC_CLASS(wxFocusEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxFocusEvent, wxEvent)

View File

@@ -702,6 +702,10 @@ static int gtk_window_expose_callback( GtkWidget *widget,
eevent.SetEventObject( win ); eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent); win->GetEventHandler()->ProcessEvent(eevent);
wxNcPaintEvent eventNc( win->GetId() );
eventNc.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( eventNc );
wxPaintEvent event( win->GetId() ); wxPaintEvent event( win->GetId() );
event.SetEventObject( win ); event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event ); win->GetEventHandler()->ProcessEvent( event );
@@ -810,6 +814,10 @@ static void gtk_window_draw_callback( GtkWidget *widget,
eevent.SetEventObject( win ); eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent); win->GetEventHandler()->ProcessEvent(eevent);
wxNcPaintEvent eventNc( win->GetId() );
eventNc.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( eventNc );
wxPaintEvent event( win->GetId() ); wxPaintEvent event( win->GetId() );
event.SetEventObject( win ); event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event ); win->GetEventHandler()->ProcessEvent( event );

View File

@@ -702,6 +702,10 @@ static int gtk_window_expose_callback( GtkWidget *widget,
eevent.SetEventObject( win ); eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent); win->GetEventHandler()->ProcessEvent(eevent);
wxNcPaintEvent eventNc( win->GetId() );
eventNc.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( eventNc );
wxPaintEvent event( win->GetId() ); wxPaintEvent event( win->GetId() );
event.SetEventObject( win ); event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event ); win->GetEventHandler()->ProcessEvent( event );
@@ -810,6 +814,10 @@ static void gtk_window_draw_callback( GtkWidget *widget,
eevent.SetEventObject( win ); eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent); win->GetEventHandler()->ProcessEvent(eevent);
wxNcPaintEvent eventNc( win->GetId() );
eventNc.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( eventNc );
wxPaintEvent event( win->GetId() ); wxPaintEvent event( win->GetId() );
event.SetEventObject( win ); event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event ); win->GetEventHandler()->ProcessEvent( event );

View File

@@ -206,9 +206,9 @@ void wxCheckBox::Release()
void wxCheckBox::Toggle() void wxCheckBox::Toggle()
{ {
ChangeValue(!GetValue());
m_isPressed = FALSE; m_isPressed = FALSE;
ChangeValue(!GetValue());
} }
void wxCheckBox::ChangeValue(bool value) void wxCheckBox::ChangeValue(bool value)

View File

@@ -217,9 +217,13 @@ bool wxStdCheckListboxInputHandler::HandleMouse(wxControl *control,
const wxPoint& pt = event.GetPosition(); const wxPoint& pt = event.GetPosition();
lbox->CalcUnscrolledPosition(pt.x, pt.y, &x, &y); lbox->CalcUnscrolledPosition(pt.x, pt.y, &x, &y);
wxRenderer *renderer = lbox->GetRenderer();
x -= renderer->GetCheckItemMargin();
int item = y / lbox->GetLineHeight(); int item = y / lbox->GetLineHeight();
if ( x >= 0 && if ( x >= 0 &&
x < lbox->GetRenderer()->GetCheckBitmapSize().x && x < renderer->GetCheckBitmapSize().x &&
item >= 0 && item >= 0 &&
item < lbox->GetCount() ) item < lbox->GetCount() )
{ {

View File

@@ -150,6 +150,8 @@ public:
{ return wxSize(10, 10); } { return wxSize(10, 10); }
virtual wxSize GetRadioBitmapSize() const virtual wxSize GetRadioBitmapSize() const
{ return wxSize(11, 11); } { return wxSize(11, 11); }
virtual wxCoord GetCheckItemMargin() const
{ return 2; }
// helpers for "wxBitmap wxColourScheme::Get()" // helpers for "wxBitmap wxColourScheme::Get()"
void DrawCheckBitmap(wxDC& dc, const wxRect& rect); void DrawCheckBitmap(wxDC& dc, const wxRect& rect);
@@ -954,7 +956,17 @@ void wxGTKRenderer::DrawCheckItem(wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags) int flags)
{ {
DrawCheckButton(dc, label, bitmap, rect, flags); wxRect rectBitmap = rect;
rectBitmap.x -= 1;
rectBitmap.width = GetCheckBitmapSize().x;
// never draw the focus rect around the check indicators here
DrawCheckButton(dc, _T(""), bitmap, rectBitmap, flags & ~wxCONTROL_FOCUSED);
wxRect rectLabel = rect;
wxCoord shift = rectBitmap.width + 2*GetCheckItemMargin();
rectLabel.x += shift;
rectLabel.width -= shift;
DrawItem(dc, label, rectLabel, flags);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -165,6 +165,8 @@ public:
{ return wxSize(13, 13); } { return wxSize(13, 13); }
virtual wxSize GetRadioBitmapSize() const virtual wxSize GetRadioBitmapSize() const
{ return wxSize(13, 13); } { return wxSize(13, 13); }
virtual wxCoord GetCheckItemMargin() const
{ return 0; }
protected: protected:
// common part of DrawLabel() and DrawItem() // common part of DrawLabel() and DrawItem()

View File

@@ -59,6 +59,7 @@ BEGIN_EVENT_TABLE(wxWindow, wxWindowNative)
EVT_SIZE(wxWindow::OnSize) EVT_SIZE(wxWindow::OnSize)
EVT_PAINT(wxWindow::OnPaint) EVT_PAINT(wxWindow::OnPaint)
EVT_NC_PAINT(wxWindow::OnNcPaint)
EVT_ERASE_BACKGROUND(wxWindow::OnErase) EVT_ERASE_BACKGROUND(wxWindow::OnErase)
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -168,7 +169,20 @@ void wxWindow::OnErase(wxEraseEvent& event)
} }
} }
// the event handler executed when the window must be repainted // the event handlers executed when the window must be repainted
void wxWindow::OnNcPaint(wxPaintEvent& event)
{
if ( m_renderer )
{
// get the DC to use and create renderer on it
wxWindowDC dc(this);
wxControlRenderer renderer(this, dc, m_renderer);
// draw the border
DoDrawBorder(&renderer);
}
}
void wxWindow::OnPaint(wxPaintEvent& event) void wxWindow::OnPaint(wxPaintEvent& event)
{ {
if ( !m_renderer ) if ( !m_renderer )
@@ -182,10 +196,7 @@ void wxWindow::OnPaint(wxPaintEvent& event)
wxPaintDC dc(this); wxPaintDC dc(this);
wxControlRenderer renderer(this, dc, m_renderer); wxControlRenderer renderer(this, dc, m_renderer);
// first, draw the border // draw the control
DoDrawBorder(&renderer);
// and then draw the control
DoDraw(&renderer); DoDraw(&renderer);
} }
} }