]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/window.cpp
wxDataObejct and related changes (won't compile right now)
[wxWidgets.git] / src / gtk1 / window.cpp
index e1172d0fdce89848642b98db22aaa8a172a94c98..bc543f7d514f1cca6f656aa7a926297caef2118d 100644 (file)
    clicking on a scrollbar belonging to scrolled window will inevitably move
    the window. In wxWindows, the scrollbar will only emit an event, send this
    to (normally) a wxScrolledWindow and that class will call ScrollWindow()
-   which actually move the window and its subchildren. Note that GtkMyFixed
+   which actually moves the window and its subchildren. Note that GtkMyFixed
    memorizes how much it has been scrolled but that wxWindows forgets this
    so that the two coordinates systems have to be kept in synch. This is done
    in various places using the myfixed->xoffset and myfixed->yoffset values.
    and then iterates down the respective size events to all window. This has
    the disadvantage, that windows might get size events before the GTK widget
    actually has the reported size. This doesn't normally pose any problem, but
-   the OpenGl drawing routines rely in correct behaviour. Therefore, I have
+   the OpenGl drawing routines rely on correct behaviour. Therefore, I have
    added the m_nativeSizeEvents flag, which is true only for the OpenGL canvas,
    i.e. the wxGLCanvas will emit a size event, when (and not before) the X11
    window that is used for OpenGl output really has that size (as reported by
@@ -823,13 +823,12 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
     GdkModifierType state;
     if (gdk_event->window) gdk_window_get_pointer(gdk_event->window, &x, &y, &state);
 
+    bool ret = FALSE;
+    
     long key_code = map_to_unmodified_wx_keysym( gdk_event->keyval );
-
     /* sending unknown key events doesn't really make sense */
     if (key_code == 0) return FALSE;
 
-    bool ret = FALSE;
-
     wxKeyEvent event( wxEVT_KEY_DOWN );
     event.SetTimestamp( gdk_event->time );
     event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
@@ -843,8 +842,6 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
     event.SetEventObject( win );
     ret = win->GetEventHandler()->ProcessEvent( event );
 
-    key_code = map_to_wx_keysym( gdk_event->keyval );
-
 #if wxUSE_ACCEL
     if (!ret)
     {
@@ -862,10 +859,14 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
         }
     }
 #endif // wxUSE_ACCEL
+
     /* wxMSW doesn't send char events with Alt pressed */
     /* Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x
-       will only be sent if it is not a menu accelerator. */
-    if ((key_code != 0) && ! ret )
+       will only be sent if it is not in an accelerator table. */
+    key_code = map_to_wx_keysym( gdk_event->keyval );
+    
+    if ( (!ret) &&
+         (key_code != 0))
     {
         wxKeyEvent event2( wxEVT_CHAR );
         event2.SetTimestamp( gdk_event->time );
@@ -878,7 +879,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
         event2.m_x = x;
         event2.m_y = y;
         event2.SetEventObject( win );
-        ret = (ret || win->GetEventHandler()->ProcessEvent( event2 ));
+        ret = win->GetEventHandler()->ProcessEvent( event2 );
     }
 
     /* win is a control: tab can be propagated up */
@@ -906,6 +907,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
 
 #if (GTK_MINOR_VERSION > 0)
     /* pressing F10 will activate the menu bar of the top frame */
+/*
     if ( (!ret) &&
          (gdk_event->keyval == GDK_F10) )
     {
@@ -921,10 +923,9 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
                     wxNode *node = menubar->GetMenus().First();
                     if (node)
                     {
-                        // doesn't work correctly
-            // wxMenu *firstMenu = (wxMenu*) node->Data();
-                        // gtk_menu_item_select( GTK_MENU_ITEM(firstMenu->m_owner) );
-                        // ret = TRUE;
+                        wxMenu *firstMenu = (wxMenu*) node->Data();
+                        gtk_menu_item_select( GTK_MENU_ITEM(firstMenu->m_owner) );
+                        ret = TRUE;
                         break;
                     }
                 }
@@ -932,6 +933,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
             ancestor = ancestor->GetParent();
         }
     }
+*/
 #endif
 
 /*
@@ -1059,13 +1061,6 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
         }
     }
 
-/*
-    wxPrintf( wxT("2) OnButtonPress from ") );
-    if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
-        wxPrintf( win->GetClassInfo()->GetClassName() );
-    wxPrintf( wxT(".\n") );
-*/
-
     wxEventType event_type = wxEVT_LEFT_DOWN;
 
     if (gdk_event->button == 1)
@@ -1114,6 +1109,15 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
 
     if (!g_captureWindow)
     {
+        int x = event.m_x;
+        int y = event.m_y;
+        if (win->m_wxwindow)
+        {
+            GtkMyFixed *myfixed = GTK_MYFIXED(win->m_wxwindow);
+           x += myfixed->xoffset;
+           y += myfixed->yoffset;
+        }
+
         wxNode *node = win->GetChildren().First();
         while (node)
         {
@@ -1122,8 +1126,6 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
             if (child->m_isStaticBox)
             {
                 // wxStaticBox is transparent in the box itself
-                int x = event.m_x;
-                int y = event.m_y;
                 int xx1 = child->m_x;
                 int yy1 = child->m_y;
                 int xx2 = child->m_x + child->m_width;
@@ -1148,10 +1150,10 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
             else
             {
                 if ((child->m_wxwindow == (GtkWidget*) NULL) &&
-                    (child->m_x <= event.m_x) &&
-                    (child->m_y <= event.m_y) &&
-                    (child->m_x+child->m_width  >= event.m_x) &&
-                    (child->m_y+child->m_height >= event.m_y))
+                    (child->m_x <= x) &&
+                    (child->m_y <= y) &&
+                    (child->m_x+child->m_width  >= x) &&
+                    (child->m_y+child->m_height >= y))
                 {
                     win = child;
                     event.m_x -= child->m_x;
@@ -1167,6 +1169,13 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
 
     gs_timeLastClick = gdk_event->time;
 
+/*
+    wxPrintf( wxT("2) OnButtonPress from ") );
+    if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
+        wxPrintf( win->GetClassInfo()->GetClassName() );
+    wxPrintf( wxT(".\n") );
+*/
+
     if (win->GetEventHandler()->ProcessEvent( event ))
     {
         gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" );
@@ -1224,6 +1233,15 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
 
     if (!g_captureWindow)
     {
+        int x = event.m_x;
+        int y = event.m_y;
+        if (win->m_wxwindow)
+        {
+            GtkMyFixed *myfixed = GTK_MYFIXED(win->m_wxwindow);
+           x += myfixed->xoffset;
+           y += myfixed->yoffset;
+        }
+
         wxNode *node = win->GetChildren().First();
         while (node)
         {
@@ -1232,8 +1250,6 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
             if (child->m_isStaticBox)
             {
                 // wxStaticBox is transparent in the box itself
-                int x = event.m_x;
-                int y = event.m_y;
                 int xx1 = child->m_x;
                 int yy1 = child->m_y;
                 int xx2 = child->m_x + child->m_width;
@@ -1258,10 +1274,10 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
             else
             {
                 if ((child->m_wxwindow == (GtkWidget*) NULL) &&
-                    (child->m_x <= event.m_x) &&
-                    (child->m_y <= event.m_y) &&
-                    (child->m_x+child->m_width  >= event.m_x) &&
-                    (child->m_y+child->m_height >= event.m_y))
+                    (child->m_x <= x) &&
+                    (child->m_y <= y) &&
+                    (child->m_x+child->m_width  >= x) &&
+                    (child->m_y+child->m_height >= y))
                 {
                     win = child;
                     event.m_x -= child->m_x;
@@ -1334,6 +1350,15 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
 
     if (!g_captureWindow)
     {
+        int x = event.m_x;
+        int y = event.m_y;
+        if (win->m_wxwindow)
+        {
+            GtkMyFixed *myfixed = GTK_MYFIXED(win->m_wxwindow);
+           x += myfixed->xoffset;
+           y += myfixed->yoffset;
+        }
+
         wxNode *node = win->GetChildren().First();
         while (node)
         {
@@ -1342,8 +1367,6 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
             if (child->m_isStaticBox)
             {
                 // wxStaticBox is transparent in the box itself
-                int x = event.m_x;
-                int y = event.m_y;
                 int xx1 = child->m_x;
                 int yy1 = child->m_y;
                 int xx2 = child->m_x + child->m_width;
@@ -1368,10 +1391,10 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
             else
             {
                 if ((child->m_wxwindow == (GtkWidget*) NULL) &&
-                    (child->m_x <= event.m_x) &&
-                    (child->m_y <= event.m_y) &&
-                    (child->m_x+child->m_width  >= event.m_x) &&
-                    (child->m_y+child->m_height >= event.m_y))
+                    (child->m_x <= x) &&
+                    (child->m_y <= y) &&
+                    (child->m_x+child->m_width  >= x) &&
+                    (child->m_y+child->m_height >= y))
                 {
                     win = child;
                     event.m_x -= child->m_x;
@@ -2255,7 +2278,7 @@ void wxWindow::OnInternalIdle()
 
     if (cursor.Ok())
     {
-        /* I now set the cursor the anew in every OnInternalIdle call
+        /* I now set the cursor anew in every OnInternalIdle call
           as setting the cursor in a parent window also effects the
           windows above so that checking for the current cursor is
           not possible. */
@@ -2640,7 +2663,7 @@ bool wxWindow::Reparent( wxWindowBase *newParentBase )
 
     if (oldParent)
     {
-        gtk_container_remove( GTK_CONTAINER(oldParent->m_wxwindow), m_widget );
+        gtk_container_remove( GTK_CONTAINER(m_widget->parent), m_widget );
     }
 
     wxASSERT( GTK_IS_WIDGET(m_widget) );