X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7c0ea335c7b1aa4ebd8b3a79dfb4be9fb20eefdb..b420fb6a37c3aa1c268983925280da7b4d7a2ee7:/src/gtk/frame.cpp diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 751e7631cb..c20496ef80 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -32,12 +32,13 @@ #endif #include "wx/dcclient.h" -#include "glib.h" -#include "gdk/gdk.h" -#include "gtk/gtk.h" +#include +#include +#include +#include +#include + #include "wx/gtk/win_gtk.h" -#include "gdk/gdkkeysyms.h" -#include "gdk/gdkx.h" // ---------------------------------------------------------------------------- // constants @@ -125,7 +126,7 @@ static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* win->m_width = alloc->width; win->m_height = alloc->height; - win->UpdateSize(); + win->GtkUpdateSize(); } } @@ -138,7 +139,7 @@ static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WX if (g_isIdle) wxapp_install_idle_handler(); - if (g_openDialogs == 0) + if ((g_openDialogs == 0) && (win->IsEnabled())) win->Close(); return TRUE; @@ -153,7 +154,7 @@ static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget * if (!win->m_hasVMT) return; win->m_menuBarDetached = FALSE; - win->UpdateSize(); + win->GtkUpdateSize(); } //----------------------------------------------------------------------------- @@ -165,7 +166,7 @@ static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget * if (!win->m_hasVMT) return; win->m_menuBarDetached = TRUE; - win->UpdateSize(); + win->GtkUpdateSize(); } #if wxUSE_TOOLBAR @@ -179,7 +180,7 @@ static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidge win->m_toolBarDetached = FALSE; - win->UpdateSize(); + win->GtkUpdateSize(); } //----------------------------------------------------------------------------- @@ -194,7 +195,7 @@ static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidge if (!win->m_hasVMT) return; win->m_toolBarDetached = TRUE; - win->UpdateSize(); + win->GtkUpdateSize(); } #endif // wxUSE_TOOLBAR @@ -356,7 +357,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) child->m_width, child->m_height ); -#if wxUSE_TOOLBAR +#if wxUSE_TOOLBAR_NATIVE /* we connect to these events for recalculating the client area space when the toolbar is floating */ if (wxIS_KIND_OF(child,wxToolBar)) @@ -385,7 +386,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) } /* resize on OnInternalIdle */ - parent->UpdateSize(); + parent->GtkUpdateSize(); } // ---------------------------------------------------------------------------- @@ -503,8 +504,11 @@ wxFrame::~wxFrame() if (wxTheApp->GetTopWindow() == this) wxTheApp->SetTopWindow( (wxWindow*) NULL ); - if (wxTopLevelWindows.Number() == 0) + if ((wxTopLevelWindows.Number() == 0) && + (wxTheApp->GetExitOnFrameDelete())) + { wxTheApp->ExitMainLoop(); + } } // ---------------------------------------------------------------------------- @@ -528,6 +532,11 @@ bool wxFrame::Show( bool show ) return wxWindow::Show( show ); } +void wxFrame::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) ) +{ + wxFAIL_MSG( wxT("DoMoveWindow called for wxFrame") ); +} + void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); @@ -616,29 +625,38 @@ void wxFrame::DoGetClientSize( int *width, int *height ) const #if wxUSE_STATUSBAR /* status bar */ if (m_frameStatusBar) (*height) -= wxSTATUS_HEIGHT; -#endif +#endif // wxUSE_STATUSBAR #if wxUSE_TOOLBAR /* tool bar */ if (m_frameToolBar) { - if (!m_toolBarDetached) + if (m_toolBarDetached) { - int y = 0; - m_frameToolBar->GetSize( (int *) NULL, &y ); - (*height) -= y; + *height -= wxPLACE_HOLDER; } else - (*height) -= wxPLACE_HOLDER; + { + int x, y; + m_frameToolBar->GetSize( &x, &y ); + if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL ) + { + *width -= x; + } + else + { + *height -= y; + } + } } -#endif +#endif // wxUSE_TOOLBAR /* mini edge */ - (*height) -= m_miniEdge*2 + m_miniTitle; + *height -= m_miniEdge*2 + m_miniTitle; } if (width) { - (*width) -= m_miniEdge*2; + *width -= m_miniEdge*2; } } @@ -664,14 +682,23 @@ void wxFrame::DoSetClientSize( int width, int height ) /* tool bar */ if (m_frameToolBar) { - if (!m_toolBarDetached) + if (m_toolBarDetached) { - int y = 0; - m_frameToolBar->GetSize( (int *) NULL, &y ); - height += y; + height += wxPLACE_HOLDER; } else - height += wxPLACE_HOLDER; + { + int x, y; + m_frameToolBar->GetSize( &x, &y ); + if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL ) + { + width += x; + } + else + { + height += y; + } + } } #endif @@ -696,7 +723,8 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), m_height = height; /* space occupied by m_frameToolBar and m_frameMenuBar */ - int client_area_y_offset = 0; + int client_area_x_offset = 0, + client_area_y_offset = 0; /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses wxWindow::Create to create it's GTK equivalent. m_mainWidget is only @@ -749,23 +777,38 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), 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; don't change the toolbar's reported size - m_frameToolBar->m_width = ww; */ + + /* don't change the toolbar's reported height/width */ + int ww, hh; + if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL ) + { + ww = m_toolBarDetached ? wxPLACE_HOLDER + : m_frameToolBar->m_width; + hh = m_height - 2*m_miniEdge; + + client_area_x_offset += ww; + } + else + { + ww = m_width - 2*m_miniEdge; + hh = m_toolBarDetached ? wxPLACE_HOLDER + : m_frameToolBar->m_height; + + client_area_y_offset += hh; + } + gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), m_frameToolBar->m_widget, xx, yy, ww, hh ); - client_area_y_offset += hh; } -#endif +#endif // wxUSE_TOOLBAR - int client_x = m_miniEdge; + int client_x = client_area_x_offset + m_miniEdge; int client_y = client_area_y_offset + m_miniEdge + m_miniTitle; - int client_w = m_width - 2*m_miniEdge; + int client_w = m_width - client_area_x_offset - 2*m_miniEdge; int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle; gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), m_wxwindow, @@ -791,6 +834,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), gtk_pizza_set_size( GTK_PIZZA(m_wxwindow), m_frameStatusBar->m_widget, xx, yy, ww, hh ); + gtk_widget_draw( m_frameStatusBar->m_widget, (GdkRectangle*) NULL ); } #endif @@ -855,33 +899,51 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar ) wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") ); + if (menuBar == m_frameMenuBar) + return; + + if (m_frameMenuBar) + { + m_frameMenuBar->UnsetInvokingWindow( this ); + + if (m_frameMenuBar->GetWindowStyle() & wxMB_DOCKABLE) + { + gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar->m_widget), + GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this ); + + gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar->m_widget), + GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this ); + } + + gtk_container_remove( GTK_CONTAINER(m_mainWidget), m_frameMenuBar->m_widget ); + gtk_widget_ref( m_frameMenuBar->m_widget ); + gtk_widget_unparent( m_frameMenuBar->m_widget ); + } + m_frameMenuBar = menuBar; if (m_frameMenuBar) { m_frameMenuBar->SetInvokingWindow( this ); - if (m_frameMenuBar->GetParent() != this) - { - m_frameMenuBar->SetParent(this); - gtk_pizza_put( GTK_PIZZA(m_mainWidget), + m_frameMenuBar->SetParent(this); + gtk_pizza_put( GTK_PIZZA(m_mainWidget), m_frameMenuBar->m_widget, m_frameMenuBar->m_x, m_frameMenuBar->m_y, m_frameMenuBar->m_width, m_frameMenuBar->m_height ); - if (menuBar->GetWindowStyle() & wxMB_DOCKABLE) - { - gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_attached", - GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached", - GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this ); - } + if (menuBar->GetWindowStyle() & wxMB_DOCKABLE) + { + gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_attached", + GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this ); - m_frameMenuBar->Show( TRUE ); + gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached", + GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this ); } + + m_frameMenuBar->Show( TRUE ); } /* resize window in OnInternalIdle */ @@ -920,7 +982,7 @@ void wxFrame::SetToolBar(wxToolBar *toolbar) GetChildren().DeleteObject( m_frameToolBar ); gtk_widget_reparent( m_frameToolBar->m_widget, m_mainWidget ); - UpdateSize(); + GtkUpdateSize(); } } } @@ -942,6 +1004,13 @@ wxStatusBar* wxFrame::CreateStatusBar(int number, return wxFrameBase::CreateStatusBar( number, style, id, name ); } +void wxFrame::PositionStatusBar() +{ + if ( !m_frameStatusBar ) + return; + + m_sizeSet = FALSE; +} #endif // wxUSE_STATUSBAR // ----------------------------------------------------------------------------