]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/frame.cpp
Cleaned up paint DC cache in ~wxPaintDC to avoid spurious memory warning
[wxWidgets.git] / src / gtk / frame.cpp
index 3098d050c0f0a6adb57fdc5e2375286bbccbbf2b..2fc6814ccd352b57bd3dceebf67ec1bb9b5758bf 100644 (file)
@@ -202,11 +202,20 @@ gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *ev
    so we do this directly after realization */
 
 static gint
-gtk_frame_realized_callback( GtkWidget *WXUNUSED(widget), wxFrame *win )
+gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win )
 {
     if (g_isIdle)
         wxapp_install_idle_handler();
 
+    // FIXME I don't know when does it appear, but it's not in 1.2.2
+#if GTK_CHECK_VERSION(1, 2, 3)
+    /* I haven't been able to set the position of
+       the dialog before it is shown, so I set the
+       position in "realize" */
+    wxLogDebug( "%d %d\n", win->m_x, win->m_y );
+    gtk_window_reposition( GTK_WINDOW(widget), win->m_x, win->m_y );
+#endif // GTK > 1.2.2
+
     /* all this is for Motif Window Manager "hints" and is supposed to be
        recognized by other WM as well. not tested. */
     long decor = (long) GDK_DECOR_BORDER;
@@ -300,7 +309,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
     {
         /* these are outside the client area */
         wxFrame* frame = (wxFrame*) parent;
-        gtk_myfixed_put( GTK_MYFIXED(frame->m_mainWidget),
+        gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget),
                          GTK_WIDGET(child->m_widget),
                          child->m_x,
                          child->m_y,
@@ -327,7 +336,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
     else
     {
         /* these are inside the client area */
-        gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow),
+        gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
                          GTK_WIDGET(child->m_widget),
                          child->m_x,
                          child->m_y,
@@ -399,7 +408,7 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
 
     m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
 
-    GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
+    GtkWindowType win_type = GTK_WINDOW_DIALOG;  // this makes window placement work
     if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP;
 
     m_widget = gtk_window_new( win_type );
@@ -418,7 +427,7 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
         GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
 
     /* m_mainWidget holds the toolbar, the menubar and the client area */
-    m_mainWidget = gtk_myfixed_new();
+    m_mainWidget = gtk_pizza_new();
     gtk_widget_show( m_mainWidget );
     GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
     gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
@@ -428,7 +437,7 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
 #endif
 
     /* m_wxwindow only represents the client area without toolbar and menubar */
-    m_wxwindow = gtk_myfixed_new();
+    m_wxwindow = gtk_pizza_new();
     gtk_widget_show( m_wxwindow );
     gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow );
 
@@ -560,13 +569,16 @@ void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags )
     if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
     if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
 
+    // FIXME I don't know when does it appear, but it's not in 1.2.2
+#if GTK_CHECK_VERSION(1, 2, 3)
     if ((m_x != -1) || (m_y != -1))
     {
         if ((m_x != old_x) || (m_y != old_y))
         {
-            gtk_widget_set_uposition( m_widget, m_x, m_y );
+            gtk_window_reposition( GTK_WINDOW(m_widget), m_x, m_y );
         }
     }
+#endif // GTK > 1.2.2
 
     if ((m_width != old_width) || (m_height != old_height))
     {
@@ -726,7 +738,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
             m_frameMenuBar->m_y = yy;
             m_frameMenuBar->m_width = ww;
             m_frameMenuBar->m_height = hh;
-            gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
+            gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
                                   m_frameMenuBar->m_widget,
                                   xx, yy, ww, hh );
             client_area_y_offset += hh;
@@ -752,7 +764,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
             m_frameToolBar->m_y = yy;
             /* m_frameToolBar->m_height = hh;   don't change the toolbar's reported size
                m_frameToolBar->m_width = ww; */
-            gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
+            gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
                                   m_frameToolBar->m_widget,
                                   xx, yy, ww, hh );
             client_area_y_offset += hh;
@@ -763,7 +775,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
         int client_y = client_area_y_offset + m_miniEdge + m_miniTitle;
         int client_w = m_width - 2*m_miniEdge;
         int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle;
-        gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
+        gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
                               m_wxwindow,
                               client_x, client_y, client_w, client_h );
     }
@@ -784,7 +796,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
         m_frameStatusBar->m_y = yy;
         m_frameStatusBar->m_width = ww;
         m_frameStatusBar->m_height = hh;
-        gtk_myfixed_set_size( GTK_MYFIXED(m_wxwindow),
+        gtk_pizza_set_size( GTK_PIZZA(m_wxwindow),
                               m_frameStatusBar->m_widget,
                               xx, yy, ww, hh );
     }
@@ -902,7 +914,7 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar )
         if (m_frameMenuBar->GetParent() != this)
         {
             m_frameMenuBar->SetParent(this);
-            gtk_myfixed_put( GTK_MYFIXED(m_mainWidget),
+            gtk_pizza_put( GTK_PIZZA(m_mainWidget),
                 m_frameMenuBar->m_widget,
                 m_frameMenuBar->m_x,
                 m_frameMenuBar->m_y,
@@ -940,12 +952,16 @@ void wxFrame::OnMenuHighlight(wxMenuEvent& event)
         wxString helpString;
 
         int menuId = event.GetMenuId();
-        if ( menuId != -1 )
+        if ( menuId != wxID_SEPARATOR && menuId != -2 /* wxID_TITLE */ )
         {
             wxMenuBar *menuBar = GetMenuBar();
-            if (menuBar)
+            if ( menuBar )
             {
-                helpString = menuBar->GetHelpString(menuId);
+                // it's ok if we don't find the item because it might belong to
+                // the popup menu
+                wxMenuItem *item = menuBar->FindItem(menuId);
+                if ( item )
+                    helpString = item->GetHelp();
             }
         }
 
@@ -1070,10 +1086,10 @@ void wxFrame::Command( int id )
     wxMenuBar *bar = GetMenuBar();
     if (!bar) return;
 
-    wxMenuItem *item = bar->FindItemForId(id) ;
+    wxMenuItem *item = bar->FindItem(id) ;
     if (item && item->IsCheckable())
     {
-        bar->Check(id,!bar->Checked(id)) ;
+        bar->Check(id, !bar->IsChecked(id)) ;
     }
 
     wxEvtHandler* evtHandler = GetEventHandler();