]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/frame.cpp
Commited slighly modified fix by David Parsons.
[wxWidgets.git] / src / gtk1 / frame.cpp
index acad4c3355008758d82b4433380af2b790a247c1..a53ad607c0bc764e24d05ca568129d47c0e25111 100644 (file)
 // headers
 // ----------------------------------------------------------------------------
 
 // headers
 // ----------------------------------------------------------------------------
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
     #pragma implementation "frame.h"
 #endif
 
     #pragma implementation "frame.h"
 #endif
 
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
 #include "wx/defs.h"
 
 #include "wx/dialog.h"
 #include "wx/defs.h"
 
 #include "wx/dialog.h"
@@ -45,7 +48,6 @@
 // constants
 // ----------------------------------------------------------------------------
 
 // constants
 // ----------------------------------------------------------------------------
 
-const int wxMENU_HEIGHT    = 27;
 const int wxSTATUS_HEIGHT  = 25;
 const int wxPLACE_HOLDER   = 0;
 
 const int wxSTATUS_HEIGHT  = 25;
 const int wxPLACE_HOLDER   = 0;
 
@@ -165,7 +167,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
                          child->m_y,
                          child->m_width,
                          child->m_height );
                          child->m_y,
                          child->m_width,
                          child->m_height );
-
+                         
 #if wxUSE_TOOLBAR_NATIVE
         // We connect to these events for recalculating the client area
         // space when the toolbar is floating
 #if wxUSE_TOOLBAR_NATIVE
         // We connect to these events for recalculating the client area
         // space when the toolbar is floating
@@ -193,7 +195,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
                          child->m_width,
                          child->m_height );
     }
                          child->m_width,
                          child->m_height );
     }
-
+    
     // Resize on OnInternalIdle
     parent->GtkUpdateSize();
 }
     // Resize on OnInternalIdle
     parent->GtkUpdateSize();
 }
@@ -206,6 +208,7 @@ void wxFrame::Init()
 {
     m_menuBarDetached = FALSE;
     m_toolBarDetached = FALSE;
 {
     m_menuBarDetached = FALSE;
     m_toolBarDetached = FALSE;
+    m_menuBarHeight = 2;
 }
 
 bool wxFrame::Create( wxWindow *parent,
 }
 
 bool wxFrame::Create( wxWindow *parent,
@@ -219,6 +222,7 @@ bool wxFrame::Create( wxWindow *parent,
     bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig,
                                        style, name);
     m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
     bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig,
                                        style, name);
     m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
+    
     return rt;
 }
 
     return rt;
 }
 
@@ -245,7 +249,7 @@ void wxFrame::DoGetClientSize( int *width, int *height ) const
         if (m_frameMenuBar)
         {
             if (!m_menuBarDetached)
         if (m_frameMenuBar)
         {
             if (!m_menuBarDetached)
-                (*height) -= wxMENU_HEIGHT;
+                (*height) -= m_menuBarHeight;
             else
                 (*height) -= wxPLACE_HOLDER;
         }
             else
                 (*height) -= wxPLACE_HOLDER;
         }
@@ -292,7 +296,7 @@ void wxFrame::DoSetClientSize( int width, int height )
         if (m_frameMenuBar)
         {
             if (!m_menuBarDetached)
         if (m_frameMenuBar)
         {
             if (!m_menuBarDetached)
-                height += wxMENU_HEIGHT;
+                height += m_menuBarHeight;
             else
                 height += wxPLACE_HOLDER;
         }
             else
                 height += wxPLACE_HOLDER;
         }
@@ -396,7 +400,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
             int xx = m_miniEdge;
             int yy = m_miniEdge + m_miniTitle;
             int ww = m_width  - 2*m_miniEdge;
             int xx = m_miniEdge;
             int yy = m_miniEdge + m_miniTitle;
             int ww = m_width  - 2*m_miniEdge;
-            int hh = wxMENU_HEIGHT;
+            int hh = m_menuBarHeight;
             if (m_menuBarDetached) hh = wxPLACE_HOLDER;
             m_frameMenuBar->m_x = xx;
             m_frameMenuBar->m_y = yy;
             if (m_menuBarDetached) hh = wxPLACE_HOLDER;
             m_frameMenuBar->m_x = xx;
             m_frameMenuBar->m_y = yy;
@@ -419,7 +423,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
             if (m_frameMenuBar)
             {
                 if (!m_menuBarDetached)
             if (m_frameMenuBar)
             {
                 if (!m_menuBarDetached)
-                    yy += wxMENU_HEIGHT;
+                    yy += m_menuBarHeight;
                 else
                     yy += wxPLACE_HOLDER;
             }
                 else
                     yy += wxPLACE_HOLDER;
             }
@@ -507,7 +511,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
 
 void wxFrame::OnInternalIdle()
 {
 
 void wxFrame::OnInternalIdle()
 {
-    wxTopLevelWindow::OnInternalIdle();
+    wxFrameBase::OnInternalIdle();
 
 #if wxUSE_MENUS_NATIVE
     if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle();
 
 #if wxUSE_MENUS_NATIVE
     if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle();
@@ -576,11 +580,34 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
             gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached",
                 GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this );
         }
             gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached",
                 GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this );
         }
+        
+        gtk_widget_show( m_frameMenuBar->m_widget );
 
 
-        m_frameMenuBar->Show( TRUE );
+        UpdateMenuBarSize();
     }
     }
+    else
+    {
+        m_menuBarHeight = 2;
+        GtkUpdateSize();        // resize window in OnInternalIdle
+    }
+}
+
+void wxFrame::UpdateMenuBarSize()
+{
+    wxASSERT_MSG( m_frameMenuBar, _T("Updating non existant menubar?") );
+
+    GtkRequisition  req;
+
+    req.width = 2;
+    req.height = 2;
+
+    (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_frameMenuBar->m_widget) )->size_request )
+        (m_frameMenuBar->m_widget, &req );
+
+    m_menuBarHeight = req.height;
+
+        // resize window in OnInternalIdle
 
 
-    // resize window in OnInternalIdle
     GtkUpdateSize();
 }
 
     GtkUpdateSize();
 }