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:
3
TODO
3
TODO
@@ -7,4 +7,5 @@ MSW
|
||||
|
||||
GTK
|
||||
|
||||
* check/radio box remains pressed
|
||||
* check/radio box remains pressed in win32 mode
|
||||
* wxCheckListBox::HitTest doesn't work (clicking the check)
|
||||
|
@@ -900,6 +900,15 @@ public:
|
||||
#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
|
||||
/*
|
||||
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_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_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_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 },
|
||||
|
@@ -223,6 +223,7 @@ public:
|
||||
// get the size of a checkbox/radio button bitmap
|
||||
virtual wxSize GetCheckBitmapSize() const = 0;
|
||||
virtual wxSize GetRadioBitmapSize() const = 0;
|
||||
virtual wxCoord GetCheckItemMargin() const = 0;
|
||||
|
||||
// virtual dtor for any base class
|
||||
virtual ~wxRenderer();
|
||||
@@ -390,6 +391,8 @@ public:
|
||||
{ return m_renderer->GetCheckBitmapSize(); }
|
||||
virtual wxSize GetRadioBitmapSize() const
|
||||
{ return m_renderer->GetRadioBitmapSize(); }
|
||||
virtual wxCoord GetCheckItemMargin() const
|
||||
{ return m_renderer->GetCheckItemMargin(); }
|
||||
|
||||
protected:
|
||||
wxRenderer *m_renderer;
|
||||
|
@@ -170,6 +170,7 @@ protected:
|
||||
|
||||
// event handlers
|
||||
void OnSize(wxSizeEvent& event);
|
||||
void OnNcPaint(wxPaintEvent& event);
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnErase(wxEraseEvent& event);
|
||||
|
||||
|
@@ -63,6 +63,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent, wxEvent)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent, wxEvent)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxSizeEvent, wxEvent)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxPaintEvent, wxEvent)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxNcPaintEvent, wxEvent)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxEraseEvent, wxEvent)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMoveEvent, wxEvent)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFocusEvent, wxEvent)
|
||||
|
@@ -702,6 +702,10 @@ static int gtk_window_expose_callback( GtkWidget *widget,
|
||||
eevent.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent(eevent);
|
||||
|
||||
wxNcPaintEvent eventNc( win->GetId() );
|
||||
eventNc.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent( eventNc );
|
||||
|
||||
wxPaintEvent event( win->GetId() );
|
||||
event.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent( event );
|
||||
@@ -810,6 +814,10 @@ static void gtk_window_draw_callback( GtkWidget *widget,
|
||||
eevent.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent(eevent);
|
||||
|
||||
wxNcPaintEvent eventNc( win->GetId() );
|
||||
eventNc.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent( eventNc );
|
||||
|
||||
wxPaintEvent event( win->GetId() );
|
||||
event.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent( event );
|
||||
|
@@ -702,6 +702,10 @@ static int gtk_window_expose_callback( GtkWidget *widget,
|
||||
eevent.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent(eevent);
|
||||
|
||||
wxNcPaintEvent eventNc( win->GetId() );
|
||||
eventNc.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent( eventNc );
|
||||
|
||||
wxPaintEvent event( win->GetId() );
|
||||
event.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent( event );
|
||||
@@ -810,6 +814,10 @@ static void gtk_window_draw_callback( GtkWidget *widget,
|
||||
eevent.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent(eevent);
|
||||
|
||||
wxNcPaintEvent eventNc( win->GetId() );
|
||||
eventNc.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent( eventNc );
|
||||
|
||||
wxPaintEvent event( win->GetId() );
|
||||
event.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent( event );
|
||||
|
@@ -206,9 +206,9 @@ void wxCheckBox::Release()
|
||||
|
||||
void wxCheckBox::Toggle()
|
||||
{
|
||||
ChangeValue(!GetValue());
|
||||
|
||||
m_isPressed = FALSE;
|
||||
|
||||
ChangeValue(!GetValue());
|
||||
}
|
||||
|
||||
void wxCheckBox::ChangeValue(bool value)
|
||||
|
@@ -217,9 +217,13 @@ bool wxStdCheckListboxInputHandler::HandleMouse(wxControl *control,
|
||||
|
||||
const wxPoint& pt = event.GetPosition();
|
||||
lbox->CalcUnscrolledPosition(pt.x, pt.y, &x, &y);
|
||||
|
||||
wxRenderer *renderer = lbox->GetRenderer();
|
||||
x -= renderer->GetCheckItemMargin();
|
||||
|
||||
int item = y / lbox->GetLineHeight();
|
||||
if ( x >= 0 &&
|
||||
x < lbox->GetRenderer()->GetCheckBitmapSize().x &&
|
||||
x < renderer->GetCheckBitmapSize().x &&
|
||||
item >= 0 &&
|
||||
item < lbox->GetCount() )
|
||||
{
|
||||
|
@@ -150,6 +150,8 @@ public:
|
||||
{ return wxSize(10, 10); }
|
||||
virtual wxSize GetRadioBitmapSize() const
|
||||
{ return wxSize(11, 11); }
|
||||
virtual wxCoord GetCheckItemMargin() const
|
||||
{ return 2; }
|
||||
|
||||
// helpers for "wxBitmap wxColourScheme::Get()"
|
||||
void DrawCheckBitmap(wxDC& dc, const wxRect& rect);
|
||||
@@ -954,7 +956,17 @@ void wxGTKRenderer::DrawCheckItem(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
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);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -165,6 +165,8 @@ public:
|
||||
{ return wxSize(13, 13); }
|
||||
virtual wxSize GetRadioBitmapSize() const
|
||||
{ return wxSize(13, 13); }
|
||||
virtual wxCoord GetCheckItemMargin() const
|
||||
{ return 0; }
|
||||
|
||||
protected:
|
||||
// common part of DrawLabel() and DrawItem()
|
||||
|
@@ -59,6 +59,7 @@ BEGIN_EVENT_TABLE(wxWindow, wxWindowNative)
|
||||
EVT_SIZE(wxWindow::OnSize)
|
||||
|
||||
EVT_PAINT(wxWindow::OnPaint)
|
||||
EVT_NC_PAINT(wxWindow::OnNcPaint)
|
||||
EVT_ERASE_BACKGROUND(wxWindow::OnErase)
|
||||
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)
|
||||
{
|
||||
if ( !m_renderer )
|
||||
@@ -182,10 +196,7 @@ void wxWindow::OnPaint(wxPaintEvent& event)
|
||||
wxPaintDC dc(this);
|
||||
wxControlRenderer renderer(this, dc, m_renderer);
|
||||
|
||||
// first, draw the border
|
||||
DoDrawBorder(&renderer);
|
||||
|
||||
// and then draw the control
|
||||
// draw the control
|
||||
DoDraw(&renderer);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user