]> git.saurik.com Git - wxWidgets.git/commitdiff
replaced wxWindowGTK::m_isListBox with a virtual function
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 31 May 2002 14:00:01 +0000 (14:00 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 31 May 2002 14:00:01 +0000 (14:00 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15715 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/listbox.h
include/wx/gtk/window.h
include/wx/gtk1/listbox.h
include/wx/gtk1/window.h
src/gtk/listbox.cpp
src/gtk/window.cpp
src/gtk1/listbox.cpp
src/gtk1/window.cpp

index f45f92ac427d8a4a3bfc1998602db3441dc80121..1ea85d5567c81b10ef6afcf865e72ad31ccad866 100644 (file)
@@ -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;
 
index 104ed4e920daa141bc88262a0d441a3ecbb9296d..723a4a8ab56866680c9ba25b0c8adafc9ef62e93 100644 (file)
@@ -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:
index f45f92ac427d8a4a3bfc1998602db3441dc80121..1ea85d5567c81b10ef6afcf865e72ad31ccad866 100644 (file)
@@ -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;
 
index 104ed4e920daa141bc88262a0d441a3ecbb9296d..723a4a8ab56866680c9ba25b0c8adafc9ef62e93 100644 (file)
@@ -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:
index 4eefc235d3fd5ca07e2ea6b9705f2cf625f1d943..2f909c4a88fa911e34e15495c8315dc416a852c3 100644 (file)
@@ -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
+
index eb2f76b4c6a835e4901ed07c8d24d332d9c7de2c..287bf987f613fee0fc0fbe16bdc0f545bfe7bde0 100644 (file)
@@ -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;
index 4eefc235d3fd5ca07e2ea6b9705f2cf625f1d943..2f909c4a88fa911e34e15495c8315dc416a852c3 100644 (file)
@@ -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
+
index eb2f76b4c6a835e4901ed07c8d24d332d9c7de2c..287bf987f613fee0fc0fbe16bdc0f545bfe7bde0 100644 (file)
@@ -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;