]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/window.cpp
don't draw with NULL font
[wxWidgets.git] / src / gtk1 / window.cpp
index fb798b8e5c500dd8729b8795bb1d02b9cce0ecc6..1e1dcdc207a5546e34370b5f116cb31801cf2af5 100644 (file)
@@ -303,7 +303,7 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g
 }
 
 //-----------------------------------------------------------------------------
-// "draw" of m_wxwindow
+// "draw" of m_widget
 //-----------------------------------------------------------------------------
 
 static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxWindow *win )
@@ -313,6 +313,39 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU
 
 #endif // GTK_MINOR_VERSION > 0
 
+
+//-----------------------------------------------------------------------------
+// "size_allocate"
+//-----------------------------------------------------------------------------
+
+static void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
+{
+    if (g_isIdle)
+        wxapp_install_idle_handler();
+
+    if (!win->m_hasVMT) 
+        return;
+
+    if (win->m_sizeSet)
+        return;
+       
+    win->m_sizeSet = TRUE;
+    
+/*
+    wxPrintf( "OnSize from " );
+    if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
+        wxPrintf( win->GetClassInfo()->GetClassName() );
+    wxPrintf( " %d %d %d %d\n", (int)alloc->x,
+                                (int)alloc->y,
+                                (int)alloc->width,
+                                (int)alloc->height );
+*/
+
+    wxSizeEvent event( win->GetSize(), win->GetId() );
+    event.SetEventObject( win );
+    win->GetEventHandler()->ProcessEvent( event );
+}
+
 //-----------------------------------------------------------------------------
 // key event conversion routines
 //-----------------------------------------------------------------------------
@@ -694,6 +727,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 +763,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 );
@@ -1766,6 +1807,8 @@ void wxWindow::Init()
     m_hasVMT = FALSE;
     m_needParent = TRUE;
     m_isBeingDeleted = FALSE;
+    
+    m_noExpose = FALSE;
 
     m_hasScrolling = FALSE;
     m_isScrolling = FALSE;
@@ -1776,13 +1819,13 @@ void wxWindow::Init()
     m_oldVerticalPos = 0.0;
 
     m_resizing = FALSE;
-    m_scrollGC = (GdkGC*) NULL;
     m_widgetStyle = (GtkStyle*) NULL;
 
     m_insertCallback = (wxInsertChildFunction) NULL;
 
     m_isStaticBox = FALSE;
     m_isRadioButton = FALSE;
+    m_isFrame = FALSE;
     m_acceptsFocus = FALSE;
     
     m_cursor = *wxSTANDARD_CURSOR;
@@ -1977,12 +2020,6 @@ wxWindow::~wxWindow()
         m_widgetStyle = (GtkStyle*) NULL;
     }
 
-    if (m_scrollGC)
-    {
-        gdk_gc_unref( m_scrollGC );
-        m_scrollGC = (GdkGC*) NULL;
-    }
-
     if (m_wxwindow)
     {
         gtk_widget_destroy( m_wxwindow );
@@ -2032,14 +2069,24 @@ void wxWindow::PostCreation()
 {
     wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
 
+    if (!m_isFrame)
+    {
+        /* frames have their own callback */
+        gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
+            GTK_SIGNAL_FUNC(gtk_window_size_callback), (gpointer)this );
+    }
+
     if (m_wxwindow)
     {
-        /* these get reported to wxWindows -> wxPaintEvent */
-        gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
-          GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
+        if (!m_noExpose)
+       {
+            /* these get reported to wxWindows -> wxPaintEvent */
+            gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
+                GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
 
-       gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
-          GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
+            gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
+                GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
+       }
          
 #if (GTK_MINOR_VERSION > 0)
         /* these are called when the "sunken" or "raised" borders are drawn */
@@ -2117,9 +2164,14 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
         m_y = y;
         m_width = width;
         m_height = height;
+
+        m_sizeSet = FALSE;
     }
     else
     {
+        int old_width = m_width;
+       int old_height = m_height;
+       
         GtkMyFixed *myfixed = GTK_MYFIXED(m_parent->m_wxwindow);
        
         if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
@@ -2168,14 +2220,19 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
                               m_y-border,
                               m_width+2*border,
                               m_height+border+bottom_border );
-    }
 
-    m_sizeSet = TRUE;
+        if ((old_width != m_width) ||
+           (old_height != m_height))
+       {
+           m_sizeSet = FALSE;
+       }
+    }
 
+/*
     wxSizeEvent event( wxSize(m_width,m_height), GetId() );
     event.SetEventObject( this );
     GetEventHandler()->ProcessEvent( event );
-
+*/
     m_resizing = FALSE;
 }
 
@@ -2665,50 +2722,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 );
-       }
     }
 }
 
@@ -2937,7 +2988,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)