]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/window.cpp
Removed #pragma implementation "appbase.h" which caused duplicate symbols
[wxWidgets.git] / src / gtk / window.cpp
index 7e235b0c06335305cd875a287ecbb6cc38bbbe66..e1172d0fdce89848642b98db22aaa8a172a94c98 100644 (file)
@@ -57,6 +57,8 @@
    some more information about what the wxWindow, which is the base class
    for all other window classes, does seems required as well.
 
+   I)
+
    What does wxWindow do? It contains the common interface for the following
    jobs of its descendants:
 
@@ -82,6 +84,8 @@
    5) A multitude of helper or extra methods for special purposes, such as
    Drag'n'Drop, managing validators etc.
 
+   6) Display a border (sunken, raised, simple or none).
+
    Normally one might expect, that one wxWindows window would always correspond
    to one GTK widget. Under GTK, there is no such allround widget that has all
    the functionality. Moreover, the GTK defines a client area as a different
    If the m_wxwindow field is set, then all input to this widget is inter-
    cepted and sent to the wxWindows class. If not, all input to the widget
    that gets pointed to by m_widget gets intercepted and sent to the class.
+   
+   II)
+   
+   The design of scrolling in wxWindows is markedly different from that offered
+   by the GTK itself and therefore we cannot simply take it as it is. In GTK,
+   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
+   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.
+   
+   III) 
+   
+   Singularily the most broken code in GTK is the code that is supposes to
+   inform subwindows (child windows) about new positions. Very often, duplicate
+   events are sent without changes in size or position, equally often no
+   events are sent at all (All this is due to a bug in the GtkContainer code
+   which got fixed in GTK 1.2.6). For that reason, wxGTK completely ignores
+   GTK's own system and it simply waits for size events for toplevel windows
+   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
+   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
+   GTK).
+
+   IV)
+   
+   If someone at some point of time feels the immense desire to have a look at,
+   change or attempt to optimse the Refresh() logic, this person will need an
+   intimate understanding of what a "draw" and what an "expose" events are and
+   what there are used for, in particular when used in connection with GTK's
+   own windowless widgets. Beware.
+   
+   V)
+   
+   Cursors, too, have been a constant source of pleasure. The main difficulty
+   is that a GdkWindow inherits a cursor if the programmer sets a new cursor
+   for the parent. To prevent this from doing too much harm, I use idle time
+   to set the cursor over and over again, starting from the toplevel windows
+   and ending with the youngest generation (speaking of parent and child windows).
+   Also don't forget that cursors (like much else) are connected to GdkWindows,
+   not GtkWidgets and that the "window" field of a GtkWidget might very well
+   point to the GdkWindow of the parent widget (-> "window less widget") and 
+   that the two obviously have very different meanings.
 
 */
 
@@ -694,6 +747,10 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp
                                 (int)gdk_event->area.height );
 */
 
+    wxEraseEvent eevent( win->GetId() );
+    eevent.SetEventObject( win );
+    win->GetEventHandler()->ProcessEvent(eevent);
+    
     wxPaintEvent event( win->GetId() );
     event.SetEventObject( win );
     win->GetEventHandler()->ProcessEvent( event );
@@ -726,6 +783,10 @@ static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxW
                                 (int)rect->height );
 */
                                
+    wxEraseEvent eevent( win->GetId() );
+    eevent.SetEventObject( win );
+    win->GetEventHandler()->ProcessEvent(eevent);
+    
     wxPaintEvent event( win->GetId() );
     event.SetEventObject( win );
     win->GetEventHandler()->ProcessEvent( event );
@@ -1768,7 +1829,8 @@ void wxWindow::Init()
     m_isBeingDeleted = FALSE;
     
     m_noExpose = FALSE;
-
+    m_nativeSizeEvent = FALSE;
+    
     m_hasScrolling = FALSE;
     m_isScrolling = FALSE;
 
@@ -1784,6 +1846,7 @@ void wxWindow::Init()
 
     m_isStaticBox = FALSE;
     m_isRadioButton = FALSE;
+    m_isFrame = FALSE;
     m_acceptsFocus = FALSE;
     
     m_cursor = *wxSTANDARD_CURSOR;
@@ -2167,12 +2230,20 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
                               m_width+2*border,
                               m_height+border+bottom_border );
     }
+    
+/*
+    wxPrintf( "OnSize sent from " );
+    if (GetClassInfo() && GetClassInfo()->GetClassName())
+        wxPrintf( GetClassInfo()->GetClassName() );
+    wxPrintf( " %d %d %d %d\n", (int)m_x, (int)m_y, (int)m_width, (int)m_height );
+*/
 
-    m_sizeSet = TRUE;
-
-    wxSizeEvent event( wxSize(m_width,m_height), GetId() );
-    event.SetEventObject( this );
-    GetEventHandler()->ProcessEvent( event );
+    if (!m_nativeSizeEvent)
+    {
+        wxSizeEvent event( wxSize(m_width,m_height), GetId() );
+        event.SetEventObject( this );
+        GetEventHandler()->ProcessEvent( event );
+    }
 
     m_resizing = FALSE;
 }
@@ -2663,50 +2734,44 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
         }
     }
 
+    /* there is no GTK equivalent of "draw only, don't clear" so we
+       invent our own in the GtkMyFixed widget */
+
     if (!rect)
     {
         if (m_wxwindow)
        {
-           /* call the callback directly for preventing GTK from
-              clearing the background */
-           int w = 0;
-           int h = 0;
-           GetClientSize( &w, &h );
+           GtkMyFixed *myfixed = GTK_MYFIXED(m_wxwindow);
+           gboolean old_clear = myfixed->clear_on_draw;
+           gtk_my_fixed_set_clear( myfixed, FALSE );
+           
+            gtk_widget_draw( m_wxwindow, (GdkRectangle*) NULL );
            
-            GetUpdateRegion().Union( 0, 0, w, h );
-            wxPaintEvent event( GetId() );
-            event.SetEventObject( this );
-            GetEventHandler()->ProcessEvent( event );
-            GetUpdateRegion().Clear();
+           gtk_my_fixed_set_clear( myfixed, old_clear );
        }
         else
-       {
             gtk_widget_draw( m_widget, (GdkRectangle*) NULL );
-       }
     }
     else
     {
+        GdkRectangle gdk_rect;
+        gdk_rect.x = rect->x;
+        gdk_rect.y = rect->y;
+        gdk_rect.width = rect->width;
+        gdk_rect.height = rect->height;
 
         if (m_wxwindow)
        {
-           /* call the callback directly for preventing GTK from
-              clearing the background */
-            GetUpdateRegion().Union( rect->x, rect->y, rect->width, rect->height );
-            wxPaintEvent event( GetId() );
-            event.SetEventObject( this );
-            GetEventHandler()->ProcessEvent( event );
-            GetUpdateRegion().Clear();
+           GtkMyFixed *myfixed = GTK_MYFIXED(m_wxwindow);
+           gboolean old_clear = myfixed->clear_on_draw;
+           gtk_my_fixed_set_clear( myfixed, FALSE );
+           
+            gtk_widget_draw( m_wxwindow, &gdk_rect );
+           
+           gtk_my_fixed_set_clear( myfixed, old_clear );
        }
         else
-       {
-            GdkRectangle gdk_rect;
-            gdk_rect.x = rect->x;
-            gdk_rect.y = rect->y;
-            gdk_rect.width = rect->width;
-            gdk_rect.height = rect->height;
-           
             gtk_widget_draw( m_widget, &gdk_rect );
-       }
     }
 }
 
@@ -2935,7 +3000,7 @@ bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y )
                   (GtkMenuPositionFunc) pop_pos_callback,
                   (gpointer) this,             // client data
                   0,                           // button used to activate it
-                  0 //gs_timeLastClick         // the time of activation
+                  gs_timeLastClick             // the time of activation
                 );
                
     while (is_waiting)