]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/window.cpp
fix for AUI pane shrinking each time it is floated
[wxWidgets.git] / src / gtk / window.cpp
index 5b8290f3c88372e4065743214ac4a1ba7c6a3898..8f71b6e2eca09a81bb7cce98dc312b9783d014f0 100644 (file)
@@ -332,41 +332,12 @@ void wxgtk_window_size_request_callback(GtkWidget * WXUNUSED(widget),
 
 extern "C" {
 static gboolean
 
 extern "C" {
 static gboolean
-gtk_window_expose_callback( GtkWidget *widget,
+gtk_window_expose_callback( GtkWidget*,
                             GdkEventExpose *gdk_event,
                             wxWindow *win )
 {
     DEBUG_MAIN_THREAD
 
                             GdkEventExpose *gdk_event,
                             wxWindow *win )
 {
     DEBUG_MAIN_THREAD
 
-    wxPizza *pizza = WX_PIZZA(widget);
-    GdkWindow *backing_window = pizza->m_backing_window;
-
-    int w = widget->allocation.width;
-    int h = widget->allocation.height;
-    
-    // if this event is for the border-only GdkWindow
-    if (backing_window && gdk_event->window == pizza->m_backing_window)
-    {
-        if (win->HasFlag(wxBORDER_SIMPLE))
-        {
-            GdkGC* gc = gdk_gc_new(gdk_event->window);
-            gdk_gc_set_foreground(gc, &widget->style->black);
-            gdk_draw_rectangle(gdk_event->window, gc, false, 0, 0, w - 1, h - 1);
-            g_object_unref(gc);
-        }
-        else
-        {
-            GtkShadowType shadow = GTK_SHADOW_IN;
-            if (win->HasFlag(wxBORDER_RAISED))
-                shadow = GTK_SHADOW_OUT;
-            gtk_paint_shadow(
-                widget->style, gdk_event->window, GTK_STATE_NORMAL,
-                shadow, NULL, widget, "viewport", 0, 0, w, h);
-        }
-        
-        return TRUE;
-    }
-
 #if 0
     if (win->GetName())
     {
 #if 0
     if (win->GetName())
     {
@@ -397,7 +368,7 @@ gtk_window_expose_callback( GtkWidget *widget,
     win->GtkSendPaintEvents();
 
     // Let parent window draw window-less widgets
     win->GtkSendPaintEvents();
 
     // Let parent window draw window-less widgets
-    return TRUE;
+    return FALSE;
 }
 }
 
 }
 }
 
@@ -405,14 +376,16 @@ gtk_window_expose_callback( GtkWidget *widget,
 // "expose_event" from m_widget, for drawing border
 //-----------------------------------------------------------------------------
 
 // "expose_event" from m_widget, for drawing border
 //-----------------------------------------------------------------------------
 
-#if 0
-ndef __WXUNIVERSAL__
+#ifndef __WXUNIVERSAL__
+
+GtkWidget* GetEntryWidget();
+
 extern "C" {
 static gboolean
 extern "C" {
 static gboolean
-expose_event_border(GtkWidget* widget, GdkEventExpose* event, wxWindow* win)
+expose_event_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win)
 {
     // if this event is not for the GdkWindow the border is drawn on
 {
     // if this event is not for the GdkWindow the border is drawn on
-    if (win->m_wxwindow == win->m_widget && event->window == widget->window)
+    if (win->m_wxwindow == win->m_widget && gdk_event->window == widget->window)
         return false;
 
     int x = 0;
         return false;
 
     int x = 0;
@@ -427,10 +400,9 @@ expose_event_border(GtkWidget* widget, GdkEventExpose* event, wxWindow* win)
     int h = win->m_wxwindow->allocation.height;
     if (win->HasFlag(wxBORDER_SIMPLE))
     {
     int h = win->m_wxwindow->allocation.height;
     if (win->HasFlag(wxBORDER_SIMPLE))
     {
-        GdkGC* gc;
-        gc = gdk_gc_new(event->window);
+        GdkGC* gc = gdk_gc_new(gdk_event->window);
         gdk_gc_set_foreground(gc, &widget->style->black);
         gdk_gc_set_foreground(gc, &widget->style->black);
-        gdk_draw_rectangle(event->window, gc, false, x, y, w - 1, h - 1);
+        gdk_draw_rectangle(gdk_event->window, gc, false, x, y, w - 1, h - 1);
         g_object_unref(gc);
     }
     else
         g_object_unref(gc);
     }
     else
@@ -438,9 +410,20 @@ expose_event_border(GtkWidget* widget, GdkEventExpose* event, wxWindow* win)
         GtkShadowType shadow = GTK_SHADOW_IN;
         if (win->HasFlag(wxBORDER_RAISED))
             shadow = GTK_SHADOW_OUT;
         GtkShadowType shadow = GTK_SHADOW_IN;
         if (win->HasFlag(wxBORDER_RAISED))
             shadow = GTK_SHADOW_OUT;
+
+        // Style detail to use
+        const char* detail;
+        if (widget == win->m_wxwindow)
+            // for non-scrollable wxWindows
+            detail = "entry";
+        else
+            // for scrollable ones
+            detail = "viewport";
+
+        GtkWidget* styleWidget = GetEntryWidget();
         gtk_paint_shadow(
         gtk_paint_shadow(
-            widget->style, event->window, GTK_STATE_NORMAL,
-            shadow, &event->area, widget, "entry", x, y, w, h);
+           styleWidget->style, gdk_event->window, GTK_STATE_NORMAL,
+           shadow, NULL, styleWidget, detail, x, y, w, h);
     }
 
     // no further painting is needed for border-only GdkWindow
     }
 
     // no further painting is needed for border-only GdkWindow
@@ -2051,11 +2034,8 @@ void gtk_window_style_set_callback( GtkWidget *WXUNUSED(widget),
                                GtkStyle *previous_style,
                                wxWindow* win )
 {
                                GtkStyle *previous_style,
                                wxWindow* win )
 {
-    //wxLogDebug(wxT("gtk_window_style_set_callback"));
     if (win && previous_style)
     {
     if (win && previous_style)
     {
-        wxString name(win->GetName());
-        //wxLogDebug(wxT("gtk_window_style_set_callback %s"), name.c_str());
         wxSysColourChangedEvent event;
         event.SetEventObject(win);
 
         wxSysColourChangedEvent event;
         event.SetEventObject(win);
 
@@ -2065,40 +2045,28 @@ void gtk_window_style_set_callback( GtkWidget *WXUNUSED(widget),
 
 } // extern "C"
 
 
 } // extern "C"
 
-// Connect/disconnect style-set
-
-void wxConnectStyleSet(wxWindow* win)
-{
-    if (win->m_wxwindow)
-        g_signal_connect (win->m_wxwindow, "style_set",
-                              G_CALLBACK (gtk_window_style_set_callback), win);
-}
-
-void wxDisconnectStyleSet(wxWindow* win)
-{
-  if (win->m_wxwindow)
-      g_signal_handlers_disconnect_by_func (win->m_wxwindow,
-                                          (gpointer) gtk_window_style_set_callback,
-                                              win);
-}
-
 // Helper to suspend colour change event event processing while we change a widget's style
 class wxSuspendStyleEvents
 {
 public:
 // Helper to suspend colour change event event processing while we change a widget's style
 class wxSuspendStyleEvents
 {
 public:
-  wxSuspendStyleEvents(wxWindow* win)
-  {
-    m_win = win;
-    if (win->IsTopLevel())
-      wxDisconnectStyleSet(win);
-  }
-  ~wxSuspendStyleEvents()
-  {
-    if (m_win->IsTopLevel())
-      wxConnectStyleSet(m_win);
-  }
+    wxSuspendStyleEvents(wxWindow* win)
+    {
+        m_win = NULL;
+        if (win->m_wxwindow && win->IsTopLevel())
+        {
+            m_win = win;
+            g_signal_handlers_block_by_func(
+                m_win->m_wxwindow, (void*)gtk_window_style_set_callback, m_win);
+        }
+    }
+    ~wxSuspendStyleEvents()
+    {
+        if (m_win)
+            g_signal_handlers_unblock_by_func(
+                m_win->m_wxwindow, (void*)gtk_window_style_set_callback, m_win);
+    }
 
 
-  wxWindow* m_win;
+    wxWindow* m_win;
 };
 
 // ----------------------------------------------------------------------------
 };
 
 // ----------------------------------------------------------------------------
@@ -2258,6 +2226,11 @@ bool wxWindowGTK::Create( wxWindow *parent,
                           long style,
                           const wxString &name  )
 {
                           long style,
                           const wxString &name  )
 {
+    // Get default border
+    wxBorder border = GetBorder(style);
+    style &= ~wxBORDER_MASK;
+    style |= border;
+    
     if (!PreCreation( parent, pos, size ) ||
         !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
     {
     if (!PreCreation( parent, pos, size ) ||
         !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
     {
@@ -2265,6 +2238,7 @@ bool wxWindowGTK::Create( wxWindow *parent,
         return false;
     }
 
         return false;
     }
 
+
     m_wxwindow = wxPizza::New(m_windowStyle);
     if (!HasFlag(wxHSCROLL) && !HasFlag(wxVSCROLL))
         m_widget = m_wxwindow;
     m_wxwindow = wxPizza::New(m_windowStyle);
     if (!HasFlag(wxHSCROLL) && !HasFlag(wxVSCROLL))
         m_widget = m_wxwindow;
@@ -2439,9 +2413,8 @@ void wxWindowGTK::PostCreation()
                           G_CALLBACK (gtk_wxwindow_commit_cb), this);
 
         // border drawing
                           G_CALLBACK (gtk_wxwindow_commit_cb), this);
 
         // border drawing
-#if 0
-ndef __WXUNIVERSAL__
-        if (HasFlag(wxBORDER_SIMPLE | wxBORDER_RAISED | wxBORDER_SUNKEN))
+#ifndef __WXUNIVERSAL__
+        if (HasFlag(wxPizza::BORDER_STYLES))
         {
             g_signal_connect(m_widget, "expose_event",
                 G_CALLBACK(expose_event_border), this);
         {
             g_signal_connect(m_widget, "expose_event",
                 G_CALLBACK(expose_event_border), this);
@@ -3305,7 +3278,7 @@ wxWindowGTK::AdjustForLayoutDirection(wxCoord x,
     return x;
 }
 
     return x;
 }
 
-void wxWindowGTK::DoMoveInTabOrder(wxWindow *win, MoveKind move)
+void wxWindowGTK::DoMoveInTabOrder(wxWindow *win, WindowOrder move)
 {
     wxWindowBase::DoMoveInTabOrder(win, move);
     m_dirtyTabOrder = true;
 {
     wxWindowBase::DoMoveInTabOrder(win, move);
     m_dirtyTabOrder = true;
@@ -3649,7 +3622,6 @@ void wxWindowGTK::GtkSendPaintEvents()
         }
     }
 
         }
     }
 
-#if 0
     if (GetThemeEnabled() && (GetBackgroundStyle() == wxBG_STYLE_SYSTEM))
     {
         // find ancestor from which to steal background
     if (GetThemeEnabled() && (GetBackgroundStyle() == wxBG_STYLE_SYSTEM))
     {
         // find ancestor from which to steal background
@@ -3699,14 +3671,10 @@ void wxWindowGTK::GtkSendPaintEvents()
 
         GetEventHandler()->ProcessEvent(erase_event);
     }
 
         GetEventHandler()->ProcessEvent(erase_event);
     }
-    
+
     wxNcPaintEvent nc_paint_event( GetId() );
     nc_paint_event.SetEventObject( this );
     GetEventHandler()->ProcessEvent( nc_paint_event );
     wxNcPaintEvent nc_paint_event( GetId() );
     nc_paint_event.SetEventObject( this );
     GetEventHandler()->ProcessEvent( nc_paint_event );
-#endif
-    if (GetName() == "MyMiniControl")
-       wxPrintf( "MyMini paint\n" );
 
     wxPaintEvent paint_event( GetId() );
     paint_event.SetEventObject( this );
 
     wxPaintEvent paint_event( GetId() );
     paint_event.SetEventObject( this );