]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/window.cpp
Fix stc doxygen warnings and regen stc files.
[wxWidgets.git] / src / gtk / window.cpp
index bedca9fba3915fe371b5bfaae09e7d0b0480679b..81b957556c9c765815c0629d75ff5a39727e760a 100644 (file)
@@ -2,7 +2,6 @@
 // Name:        src/gtk/window.cpp
 // Purpose:     wxWindowGTK implementation
 // Author:      Robert Roebling
-// Id:          $Id$
 // Copyright:   (c) 1998 Robert Roebling, Julian Smart
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -1694,13 +1693,29 @@ window_scroll_event(GtkWidget*, GdkEventScroll* gdk_event, wxWindow* win)
     if (win->GTKProcessEvent(event))
       return TRUE;
 
-    GtkRange *range = win->m_scrollBar[wxWindow::ScrollDir_Vert];
+    GtkRange *range;
+    switch (gdk_event->direction)
+    {
+        case GDK_SCROLL_UP:
+        case GDK_SCROLL_DOWN:
+            range = win->m_scrollBar[wxWindow::ScrollDir_Vert];
+            break;
+
+        case GDK_SCROLL_LEFT:
+        case GDK_SCROLL_RIGHT:
+            range = win->m_scrollBar[wxWindow::ScrollDir_Horz];
+            break;
+
+        default:
+            return false;
+    }
 
     if (range && gtk_widget_get_visible(GTK_WIDGET(range)))
     {
         GtkAdjustment* adj = gtk_range_get_adjustment(range);
         double delta = gtk_adjustment_get_step_increment(adj) * 3;
-        if (gdk_event->direction == GDK_SCROLL_UP)
+        if (gdk_event->direction == GDK_SCROLL_UP ||
+            gdk_event->direction == GDK_SCROLL_LEFT)
             delta = -delta;
 
         gtk_range_set_value(range, gtk_adjustment_get_value(adj) + delta);
@@ -1928,9 +1943,11 @@ size_allocate(GtkWidget*, GtkAllocation* alloc, wxWindow* win)
     GtkAllocation a;
     gtk_widget_get_allocation(win->m_widget, &a);
     // update position for widgets in native containers, such as wxToolBar
-    // (for widgets in a wxPizza, the values should already be the same)
-    win->m_x = a.x;
-    win->m_y = a.y;
+    if (!WX_IS_PIZZA(gtk_widget_get_parent(win->m_widget)))
+    {
+        win->m_x = a.x;
+        win->m_y = a.y;
+    }
     win->m_useCachedClientSize = true;
     if (win->m_clientWidth != w || win->m_clientHeight != h)
     {
@@ -2424,9 +2441,6 @@ wxWindowGTK::~wxWindowGTK()
     // destroy children before destroying this window itself
     DestroyChildren();
 
-    if (m_widget)
-        Show( false );
-
     // delete before the widgets to avoid a crash on solaris
     if ( m_imContext )
     {
@@ -3376,8 +3390,9 @@ void wxWindowGTK::SetFocus()
 
 void wxWindowGTK::SetCanFocus(bool canFocus)
 {
-    if ( m_widget )
-        gtk_widget_set_can_focus(m_widget, canFocus);
+    wxCHECK_RET(m_widget, "invalid window");
+
+    gtk_widget_set_can_focus(m_widget, canFocus);
 
     if ( m_wxwindow && (m_widget != m_wxwindow) )
     {
@@ -4368,6 +4383,13 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y )
                   gtk_get_current_event_time()
                 );
 
+    // it is possible for gtk_menu_popup() to fail
+    if (!gtk_widget_get_visible(GTK_WIDGET(menu->m_menu)))
+    {
+        menu->m_popupShown = false;
+        return false;
+    }
+
     while (menu->m_popupShown)
     {
         gtk_main_iteration();
@@ -4597,7 +4619,9 @@ int wxWindowGTK::GetScrollRange( int orient ) const
 //   difference due to possible inexactness in floating point arithmetic
 static inline bool IsScrollIncrement(double increment, double x)
 {
-    wxASSERT(increment > 0);
+    wxASSERT(increment >= 0);
+    if ( increment == 0. )
+        return false;
     const double tolerance = 1.0 / 1024;
     return fabs(increment - fabs(x)) < tolerance;
 }