From: Vadim Zeitlin Date: Fri, 31 May 2002 14:00:01 +0000 (+0000) Subject: replaced wxWindowGTK::m_isListBox with a virtual function X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/3ae4c570c40df9eb79312e5cdd274f24add0c0e3 replaced wxWindowGTK::m_isListBox with a virtual function git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15715 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/gtk/listbox.h b/include/wx/gtk/listbox.h index f45f92ac42..1ea85d5567 100644 --- a/include/wx/gtk/listbox.h +++ b/include/wx/gtk/listbox.h @@ -97,6 +97,8 @@ public: int m_prevSelection; bool m_blockEvent; + virtual void FixUpMouseEvent(GtkWidget *widget, wxCoord& x, wxCoord& y); + protected: virtual wxSize DoGetBestSize() const; diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 104ed4e920..723a4a8ab5 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -172,6 +172,11 @@ public: // (i.e. in idle time, implemented in OnInternalIdle() ). void GtkUpdateSize() { m_sizeSet = FALSE; } + // fix up the mouse event coords, used by wxListBox only so far + virtual void FixUpMouseEvent(GtkWidget * WXUNUSED(widget), + wxCoord& WXUNUSED(x), + wxCoord& WXUNUSED(y)) { } + // position and size of the window int m_x, m_y; int m_width, m_height; @@ -252,7 +257,8 @@ public: virtual void DoSetToolTip( wxToolTip *tip ); #endif // wxUSE_TOOLTIPS - // common part of all ctors (can't be virtual because called from ctor) +protected: + // common part of all ctors (not virtual because called from ctor) void Init(); private: diff --git a/include/wx/gtk1/listbox.h b/include/wx/gtk1/listbox.h index f45f92ac42..1ea85d5567 100644 --- a/include/wx/gtk1/listbox.h +++ b/include/wx/gtk1/listbox.h @@ -97,6 +97,8 @@ public: int m_prevSelection; bool m_blockEvent; + virtual void FixUpMouseEvent(GtkWidget *widget, wxCoord& x, wxCoord& y); + protected: virtual wxSize DoGetBestSize() const; diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index 104ed4e920..723a4a8ab5 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -172,6 +172,11 @@ public: // (i.e. in idle time, implemented in OnInternalIdle() ). void GtkUpdateSize() { m_sizeSet = FALSE; } + // fix up the mouse event coords, used by wxListBox only so far + virtual void FixUpMouseEvent(GtkWidget * WXUNUSED(widget), + wxCoord& WXUNUSED(x), + wxCoord& WXUNUSED(y)) { } + // position and size of the window int m_x, m_y; int m_width, m_height; @@ -252,7 +257,8 @@ public: virtual void DoSetToolTip( wxToolTip *tip ); #endif // wxUSE_TOOLTIPS - // common part of all ctors (can't be virtual because called from ctor) +protected: + // common part of all ctors (not virtual because called from ctor) void Init(); private: diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index 4eefc235d3..2f909c4a88 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -1064,4 +1064,13 @@ wxSize wxListBox::DoGetBestSize() const return wxSize(lbWidth, lbHeight); } -#endif +void wxListBox::FixUpMouseEvent(GtkWidget *widget, wxCoord& x, wxCoord& y) +{ + // the mouse event coords are relative to the listbox items, we need to + // translate them to the normal client coords + x += widget->allocation.x; + y += widget->allocation.y; +} + +#endif // wxUSE_LISTBOX + diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index eb2f76b4c6..287bf987f6 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1361,13 +1361,9 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton AdjustEventButtonState(event); - // wxListBox actually get mouse events from the item - - if (win->m_isListBox) - { - event.m_x += widget->allocation.x; - event.m_y += widget->allocation.y; - } + // wxListBox actually get mouse events from the item, so we need to give it + // a chance to correct this + win->FixUpMouseEvent(widget, event.m_x, event.m_y); // Some control don't have their own X window and thus cannot get // any events. @@ -1492,13 +1488,8 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto AdjustEventButtonState(event); - // wxListBox actually get mouse events from the item - - if (win->m_isListBox) - { - event.m_x += widget->allocation.x; - event.m_y += widget->allocation.y; - } + // same wxListBox hack as above + win->FixUpMouseEvent(widget, event.m_x, event.m_y); // Some control don't have their own X window and thus cannot get // any events. @@ -2387,7 +2378,6 @@ void wxWindowGTK::Init() m_isStaticBox = FALSE; m_isRadioButton = FALSE; - m_isListBox = FALSE; m_isFrame = FALSE; m_acceptsFocus = FALSE; m_hasFocus = FALSE; diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index 4eefc235d3..2f909c4a88 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -1064,4 +1064,13 @@ wxSize wxListBox::DoGetBestSize() const return wxSize(lbWidth, lbHeight); } -#endif +void wxListBox::FixUpMouseEvent(GtkWidget *widget, wxCoord& x, wxCoord& y) +{ + // the mouse event coords are relative to the listbox items, we need to + // translate them to the normal client coords + x += widget->allocation.x; + y += widget->allocation.y; +} + +#endif // wxUSE_LISTBOX + diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index eb2f76b4c6..287bf987f6 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -1361,13 +1361,9 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton AdjustEventButtonState(event); - // wxListBox actually get mouse events from the item - - if (win->m_isListBox) - { - event.m_x += widget->allocation.x; - event.m_y += widget->allocation.y; - } + // wxListBox actually get mouse events from the item, so we need to give it + // a chance to correct this + win->FixUpMouseEvent(widget, event.m_x, event.m_y); // Some control don't have their own X window and thus cannot get // any events. @@ -1492,13 +1488,8 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto AdjustEventButtonState(event); - // wxListBox actually get mouse events from the item - - if (win->m_isListBox) - { - event.m_x += widget->allocation.x; - event.m_y += widget->allocation.y; - } + // same wxListBox hack as above + win->FixUpMouseEvent(widget, event.m_x, event.m_y); // Some control don't have their own X window and thus cannot get // any events. @@ -2387,7 +2378,6 @@ void wxWindowGTK::Init() m_isStaticBox = FALSE; m_isRadioButton = FALSE; - m_isListBox = FALSE; m_isFrame = FALSE; m_acceptsFocus = FALSE; m_hasFocus = FALSE;