const int wxMENU_HEIGHT = 27;
const int wxSTATUS_HEIGHT = 25;
+const int wxPLACE_HOLDER = 0;
//-----------------------------------------------------------------------------
// data
return TRUE;
}
+//-----------------------------------------------------------------------------
+// "child_attached" of menu bar
+//-----------------------------------------------------------------------------
+
+static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
+{
+ if (!win->HasVMT()) return;
+
+ win->m_menuBarDetached = FALSE;
+ win->m_sizeSet = FALSE;
+}
+
+//-----------------------------------------------------------------------------
+// "child_detached" of menu bar
+//-----------------------------------------------------------------------------
+
+static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
+{
+ if (!win->HasVMT()) return;
+
+ win->m_menuBarDetached = TRUE;
+ win->m_sizeSet = FALSE;
+}
+
+//-----------------------------------------------------------------------------
+// "child_attached" of tool bar
+//-----------------------------------------------------------------------------
+
+static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
+{
+ if (!win->HasVMT()) return;
+
+ win->m_toolBarDetached = FALSE;
+ win->m_sizeSet = FALSE;
+}
+
+//-----------------------------------------------------------------------------
+// "child_detached" of tool bar
+//-----------------------------------------------------------------------------
+
+static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
+{
+ if (!win->HasVMT()) return;
+
+ win->m_toolBarDetached = TRUE;
+ win->m_sizeSet = FALSE;
+}
+
//-----------------------------------------------------------------------------
// "configure_event"
//-----------------------------------------------------------------------------
{
if (wxIS_KIND_OF(child,wxToolBar) || wxIS_KIND_OF(child,wxMenuBar))
{
+ /* actually, menubars are never inserted here, but this
+ may change one day */
+
/* these are outside the client area */
wxFrame* frame = (wxFrame*) parent;
gtk_myfixed_put( GTK_MYFIXED(frame->m_mainWidget),
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
{
wxFrame::wxFrame()
{
m_frameMenuBar = (wxMenuBar *) NULL;
- m_mdiMenuBar = (wxMenuBar *) NULL;
m_frameStatusBar = (wxStatusBar *) NULL;
m_frameToolBar = (wxToolBar *) NULL;
m_sizeSet = FALSE;
m_miniEdge = 0;
m_miniTitle = 0;
m_mainWidget = (GtkWidget*) NULL;
+ m_menuBarDetached = FALSE;
+ m_toolBarDetached = FALSE;
}
wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title,
long style, const wxString &name )
{
m_frameMenuBar = (wxMenuBar *) NULL;
- m_mdiMenuBar = (wxMenuBar *) NULL;
m_frameStatusBar = (wxStatusBar *) NULL;
m_frameToolBar = (wxToolBar *) NULL;
m_sizeSet = FALSE;
m_miniEdge = 0;
m_miniTitle = 0;
m_mainWidget = (GtkWidget*) NULL;
+ m_menuBarDetached = FALSE;
+ m_toolBarDetached = FALSE;
Create( parent, id, title, pos, size, style, name );
}
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 ? */
recognized by other WM as well. not tested. */
long decor = (long) GDK_DECOR_ALL;
long func = (long) GDK_FUNC_ALL;
+
if ((m_windowStyle & wxCAPTION) == 0)
decor |= GDK_DECOR_TITLE;
-/*
- if ((m_windowStyle & wxMINIMIZE) == 0)
+/* if ((m_windowStyle & wxMINIMIZE) == 0)
func |= GDK_FUNC_MINIMIZE;
if ((m_windowStyle & wxMAXIMIZE) == 0)
- func |= GDK_FUNC_MAXIMIZE;
-*/
+ func |= GDK_FUNC_MAXIMIZE; */
if ((m_windowStyle & wxSYSTEM_MENU) == 0)
decor |= GDK_DECOR_MENU;
if ((m_windowStyle & wxMINIMIZE_BOX) == 0)
decor |= GDK_DECOR_MAXIMIZE;
if ((m_windowStyle & wxRESIZE_BORDER) == 0)
func |= GDK_FUNC_RESIZE;
+
gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor);
gdk_window_set_functions(m_widget->window, (GdkWMFunction)func);
wxTopLevelWindows.DeleteObject( this );
if (wxTheApp->GetTopWindow() == this)
- {
wxTheApp->SetTopWindow( (wxWindow*) NULL );
- }
if (wxTopLevelWindows.Number() == 0)
- {
wxTheApp->ExitMainLoop();
- }
}
bool wxFrame::Show( bool show )
{
- wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+ wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
if (show && !m_sizeSet)
{
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);
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;
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;
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) (*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)
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) 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 )
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;
int yy = m_miniEdge + m_miniTitle;
int ww = m_width - 2*m_miniEdge;
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;
{
int xx = m_miniEdge;
int yy = m_miniEdge + m_miniTitle;
- if ((m_frameMenuBar) || (m_mdiMenuBar)) 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 );
void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
{
- wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+ wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
if (GetAutoLayout())
{
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;
m_frameMenuBar->m_parent = this;
gtk_myfixed_put( GTK_MYFIXED(m_mainWidget),
m_frameMenuBar->m_widget, m_frameMenuBar->m_x, m_frameMenuBar->m_y );
-
- /* an mdi child menu bar might be underneath */
- if (m_mdiMenuBar)
- m_frameMenuBar->Show( FALSE );
+
+ if (menuBar->m_windowStyle & 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 );
+ }
}
}
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 );
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 );
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);
}
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;