]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/frame.cpp
wxGetUserHome() returns "const wxMB2WXbuf" for Unix in Unicode build.
[wxWidgets.git] / src / gtk1 / frame.cpp
index 48c3b8f13254f0bb32354f7c819dbc66002c549a..40fd6651829385baf6361d9d23a93932cca37a53 100644 (file)
@@ -31,6 +31,7 @@
 
 const int wxMENU_HEIGHT    = 27;
 const int wxSTATUS_HEIGHT  = 25;
+const int wxPLACE_HOLDER   = 0;
 
 //-----------------------------------------------------------------------------
 // data
@@ -167,6 +168,21 @@ static void wxInsertChildInFrame( wxWindow* parent, wxWindow* child )
                          GTK_WIDGET(child->m_widget),
                          child->m_x,
                          child->m_y );
+                        
+       /* we connect to these events for recalculating the client area
+          space when the toolbar is floating */
+       if (wxIS_KIND_OF(child,wxToolBar))
+       {
+           wxToolBar *toolBar = (wxToolBar*) child;
+           if (toolBar->m_windowStyle & wxTB_DOCKABLE)
+           {
+                gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_attached",
+                    GTK_SIGNAL_FUNC(gtk_toolbar_attached_callback), (gpointer)parent );
+                   
+                gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_detached",
+                    GTK_SIGNAL_FUNC(gtk_toolbar_detached_callback), (gpointer)parent );
+           }
+       }
     }
     else
     {
@@ -252,7 +268,7 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
 
     m_widget = gtk_window_new( win_type );
 
-    gtk_window_set_title( GTK_WINDOW(m_widget), title );
+    gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
     GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
 
     /* needed ? */
@@ -336,7 +352,7 @@ wxFrame::~wxFrame()
 
 bool wxFrame::Show( bool show )
 {
-    wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+    wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
 
     if (show && !m_sizeSet)
     {
@@ -353,7 +369,7 @@ bool wxFrame::Show( bool show )
 
 bool wxFrame::Destroy()
 {
-    wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+    wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
 
     if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
 
@@ -362,10 +378,10 @@ bool wxFrame::Destroy()
 
 void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags )
 {
-    wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+    wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
 
     /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
-    wxASSERT_MSG( (m_wxwindow != NULL), "invalid frame" );
+    wxASSERT_MSG( (m_wxwindow != NULL), _T("invalid frame") );
     
     /* avoid recursions */
     if (m_resizing) return; 
@@ -428,7 +444,7 @@ void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags )
 
 void wxFrame::Centre( int direction )
 {
-    wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+    wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
 
     int x = 0;
     int y = 0;
@@ -441,19 +457,37 @@ void wxFrame::Centre( int direction )
 
 void wxFrame::GetClientSize( int *width, int *height ) const
 {
-    wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+    wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
 
     wxWindow::GetClientSize( width, height );
     if (height)
     {
-        if (m_frameMenuBar && !m_menuBarDetached) (*height) -= wxMENU_HEIGHT;
+        /* menu bar */
+        if (m_frameMenuBar)
+       {
+           if (!m_menuBarDetached) 
+               (*height) -= wxMENU_HEIGHT;
+           else
+               (*height) -= wxPLACE_HOLDER;
+       }
+       
+       /* status bar */
         if (m_frameStatusBar) (*height) -= wxSTATUS_HEIGHT;
+       
+       /* tool bar */
         if (m_frameToolBar)
         {
-            int y = 0;
-            m_frameToolBar->GetSize( (int *) NULL, &y );
-            (*height) -= y;
+           if (!m_toolBarDetached)
+           {
+                int y = 0;
+                m_frameToolBar->GetSize( (int *) NULL, &y );
+                (*height) -= y;
+           }
+           else
+                (*height) -= wxPLACE_HOLDER;
         }
+       
+       /* mini edge */
         (*height) -= m_miniEdge*2 + m_miniTitle;
     }
     if (width)
@@ -464,18 +498,34 @@ void wxFrame::GetClientSize( int *width, int *height ) const
 
 void wxFrame::DoSetClientSize( int width, int height )
 {
-    wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+    wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
 
-    int h = height;
-    if (m_frameMenuBar && !m_menuBarDetached) h += wxMENU_HEIGHT;
-    if (m_frameStatusBar) h += wxSTATUS_HEIGHT;
-    if (m_frameToolBar)
-    {
-        int y = 0;
-        m_frameToolBar->GetSize( (int *) NULL, &y );
-        h += y;
-    }
-    wxWindow::DoSetClientSize( width + m_miniEdge*2, h  + m_miniEdge*2 + m_miniTitle );
+        /* menu bar */
+        if (m_frameMenuBar)
+       {
+           if (!m_menuBarDetached) 
+               height += wxMENU_HEIGHT;
+           else
+               height += wxPLACE_HOLDER;
+       }
+       
+       /* status bar */
+        if (m_frameStatusBar) height += wxSTATUS_HEIGHT;
+       
+       /* tool bar */
+        if (m_frameToolBar)
+        {
+           if (!m_toolBarDetached)
+           {
+                int y = 0;
+                m_frameToolBar->GetSize( (int *) NULL, &y );
+                height += y;
+           }
+           else
+                height += wxPLACE_HOLDER;
+        }
+       
+    wxWindow::DoSetClientSize( width + m_miniEdge*2, height  + m_miniEdge*2 + m_miniTitle );
 }
 
 void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height )
@@ -489,7 +539,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
     m_resizing = TRUE;
 
     /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
-    wxASSERT_MSG( (m_wxwindow != NULL), "invalid frame" );
+    wxASSERT_MSG( (m_wxwindow != NULL), _T("invalid frame") );
     
     m_width = width;
     m_height = height;
@@ -523,8 +573,8 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
             int xx = m_miniEdge;
             int yy = m_miniEdge + m_miniTitle;
             int ww = m_width  - 2*m_miniEdge;
-            int hh = 0;
-           if (!m_menuBarDetached) hh = wxMENU_HEIGHT;
+            int hh = wxMENU_HEIGHT;
+           if (m_menuBarDetached) hh = wxPLACE_HOLDER;
             m_frameMenuBar->m_x = xx;
             m_frameMenuBar->m_y = yy;
             m_frameMenuBar->m_width = ww;
@@ -540,13 +590,19 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
         {
             int xx = m_miniEdge;
             int yy = m_miniEdge + m_miniTitle;
-            if (m_frameMenuBar && !m_menuBarDetached) yy += wxMENU_HEIGHT;
+            if (m_frameMenuBar)
+           {
+               if (!m_menuBarDetached) 
+                   yy += wxMENU_HEIGHT; 
+               else 
+                   yy += wxPLACE_HOLDER;
+           }
             int ww = m_width - 2*m_miniEdge;
             int hh = m_frameToolBar->m_height;
-
+           if (m_toolBarDetached) hh = wxPLACE_HOLDER; 
             m_frameToolBar->m_x = xx;
             m_frameToolBar->m_y = yy;
-            m_frameToolBar->m_height = hh;
+            /* m_frameToolBar->m_height = hh;   don't change the toolbar's height */
             m_frameToolBar->m_width = ww;
 
             gtk_myfixed_move( GTK_MYFIXED(m_mainWidget), m_frameToolBar->m_widget, xx, yy );
@@ -621,7 +677,7 @@ void wxFrame::OnCloseWindow( wxCloseEvent& event )
 
 void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
 {
-    wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+    wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
 
     if (GetAutoLayout())
     {
@@ -672,8 +728,8 @@ static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
 
 void wxFrame::SetMenuBar( wxMenuBar *menuBar )
 {
-    wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
-    wxASSERT_MSG( (m_wxwindow != NULL), "invalid frame" );
+    wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
+    wxASSERT_MSG( (m_wxwindow != NULL), _T("invalid frame") );
 
     m_frameMenuBar = menuBar;
 
@@ -735,9 +791,9 @@ void wxFrame::OnMenuHighlight(wxMenuEvent& event)
 
 wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
 {
-    wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+    wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
 
-    wxCHECK_MSG( m_frameToolBar == NULL, FALSE, "recreating toolbar in wxFrame" );
+    wxCHECK_MSG( m_frameToolBar == NULL, FALSE, _T("recreating toolbar in wxFrame") );
 
     m_frameToolBar = OnCreateToolBar( style, id, name );
 
@@ -760,9 +816,9 @@ wxToolBar *wxFrame::GetToolBar() const
 
 wxStatusBar* wxFrame::CreateStatusBar( int number, long style, wxWindowID id, const wxString& name )
 {
-    wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+    wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
 
-    wxCHECK_MSG( m_frameStatusBar == NULL, FALSE, "recreating status bar in wxFrame" );
+    wxCHECK_MSG( m_frameStatusBar == NULL, FALSE, _T("recreating status bar in wxFrame") );
 
     m_frameStatusBar = OnCreateStatusBar( number, style, id, name );
 
@@ -814,18 +870,18 @@ void wxFrame::Command( int id )
 
 void wxFrame::SetStatusText(const wxString& text, int number)
 {
-    wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+    wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
 
-    wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set text for" );
+    wxCHECK_RET( m_frameStatusBar != NULL, _T("no statusbar to set text for") );
 
     m_frameStatusBar->SetStatusText(text, number);
 }
 
 void wxFrame::SetStatusWidths(int n, const int widths_field[] )
 {
-    wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+    wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
 
-    wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set widths for" );
+    wxCHECK_RET( m_frameStatusBar != NULL, _T("no statusbar to set widths for") );
 
     m_frameStatusBar->SetStatusWidths(n, widths_field);
 }
@@ -837,16 +893,16 @@ wxStatusBar *wxFrame::GetStatusBar() const
 
 void wxFrame::SetTitle( const wxString &title )
 {
-    wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+    wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
 
     m_title = title;
-    if (m_title.IsNull()) m_title = "";
-    gtk_window_set_title( GTK_WINDOW(m_widget), title );
+    if (m_title.IsNull()) m_title = _T("");
+    gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
 }
 
 void wxFrame::SetIcon( const wxIcon &icon )
 {
-    wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+    wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
 
     m_icon = icon;
     if (!icon.Ok()) return;