Made OnInit() and OnRun() logic like MSW when it

comes to quitting the app with no windows.
  Fixed overlapping windows when detaching the
    toolbar from the main frame.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15364 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-05-04 11:53:06 +00:00
parent 6d8b260cc3
commit 047ac72bbe
4 changed files with 84 additions and 86 deletions

View File

@@ -816,33 +816,24 @@ int wxEntry( int argc, char *argv[] )
if ( retValue == 0 ) if ( retValue == 0 )
{ {
/* delete pending toplevel windows (typically a single // Delete pending toplevel windows
dialog) so that, if there isn't any left, we don't
call OnRun() */
wxTheApp->DeletePendingObjects(); wxTheApp->DeletePendingObjects();
wxTheApp->m_initialized = wxTopLevelWindows.GetCount() != 0; // When is the app not initialized ?
wxTheApp->m_initialized = TRUE;
if (wxTheApp->Initialized()) if (wxTheApp->Initialized())
{ {
wxTheApp->OnRun(); wxTheApp->OnRun();
wxWindow *topWindow = wxTheApp->GetTopWindow(); wxWindow *topWindow = wxTheApp->GetTopWindow();
// Delete all pending windows if any
wxTheApp->DeletePendingObjects();
// Reset top window
if (topWindow) if (topWindow)
{ wxTheApp->SetTopWindow( (wxWindow*) NULL );
/* Forcibly delete the window. */
if (topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
topWindow->IsKindOf(CLASSINFO(wxDialog)) )
{
topWindow->Close( TRUE );
wxTheApp->DeletePendingObjects();
}
else
{
delete topWindow;
wxTheApp->SetTopWindow( (wxWindow*) NULL );
}
}
retValue = wxTheApp->OnExit(); retValue = wxTheApp->OnExit();
} }

View File

@@ -91,8 +91,14 @@ static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *
static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
{ {
if (g_isIdle)
wxapp_install_idle_handler();
if (!win->m_hasVMT) return; if (!win->m_hasVMT) return;
// Raise the client area area
gdk_window_raise( win->m_wxwindow->window );
win->m_menuBarDetached = TRUE; win->m_menuBarDetached = TRUE;
win->GtkUpdateSize(); win->GtkUpdateSize();
} }
@@ -109,7 +115,6 @@ static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
if (!win->m_hasVMT) return; if (!win->m_hasVMT) return;
win->m_toolBarDetached = FALSE; win->m_toolBarDetached = FALSE;
win->GtkUpdateSize(); win->GtkUpdateSize();
} }
@@ -124,6 +129,9 @@ static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
if (!win->m_hasVMT) return; if (!win->m_hasVMT) return;
// Raise the client area area
gdk_window_raise( win->m_wxwindow->window );
win->m_toolBarDetached = TRUE; win->m_toolBarDetached = TRUE;
win->GtkUpdateSize(); win->GtkUpdateSize();
} }
@@ -149,7 +157,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
if (!parent->m_insertInClientArea) if (!parent->m_insertInClientArea)
{ {
/* these are outside the client area */ // These are outside the client area
wxFrame* frame = (wxFrame*) parent; wxFrame* frame = (wxFrame*) parent;
gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget), gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget),
GTK_WIDGET(child->m_widget), GTK_WIDGET(child->m_widget),
@@ -159,8 +167,8 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
child->m_height ); child->m_height );
#if wxUSE_TOOLBAR_NATIVE #if wxUSE_TOOLBAR_NATIVE
/* we connect to these events for recalculating the client area // We connect to these events for recalculating the client area
space when the toolbar is floating */ // space when the toolbar is floating
if (wxIS_KIND_OF(child,wxToolBar)) if (wxIS_KIND_OF(child,wxToolBar))
{ {
wxToolBar *toolBar = (wxToolBar*) child; wxToolBar *toolBar = (wxToolBar*) child;
@@ -177,7 +185,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
} }
else else
{ {
/* these are inside the client area */ // These are inside the client area
gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow), gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
GTK_WIDGET(child->m_widget), GTK_WIDGET(child->m_widget),
child->m_x, child->m_x,
@@ -186,7 +194,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
child->m_height ); child->m_height );
} }
/* resize on OnInternalIdle */ // Resize on OnInternalIdle
parent->GtkUpdateSize(); parent->GtkUpdateSize();
} }
@@ -233,7 +241,7 @@ void wxFrame::DoGetClientSize( int *width, int *height ) const
if (height) if (height)
{ {
#if wxUSE_MENUS_NATIVE #if wxUSE_MENUS_NATIVE
/* menu bar */ // menu bar
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
if (!m_menuBarDetached) if (!m_menuBarDetached)
@@ -244,13 +252,13 @@ void wxFrame::DoGetClientSize( int *width, int *height ) const
#endif // wxUSE_MENUS_NATIVE #endif // wxUSE_MENUS_NATIVE
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
/* status bar */ // status bar
if (m_frameStatusBar && m_frameStatusBar->IsShown()) if (m_frameStatusBar && m_frameStatusBar->IsShown())
(*height) -= wxSTATUS_HEIGHT; (*height) -= wxSTATUS_HEIGHT;
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
/* tool bar */ // tool bar
if (m_frameToolBar && m_frameToolBar->IsShown()) if (m_frameToolBar && m_frameToolBar->IsShown())
{ {
if (m_toolBarDetached) if (m_toolBarDetached)
@@ -280,7 +288,7 @@ void wxFrame::DoSetClientSize( int width, int height )
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
#if wxUSE_MENUS_NATIVE #if wxUSE_MENUS_NATIVE
/* menu bar */ // menu bar
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
if (!m_menuBarDetached) if (!m_menuBarDetached)
@@ -291,12 +299,12 @@ void wxFrame::DoSetClientSize( int width, int height )
#endif // wxUSE_MENUS_NATIVE #endif // wxUSE_MENUS_NATIVE
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
/* status bar */ // status bar
if (m_frameStatusBar && m_frameStatusBar->IsShown()) height += wxSTATUS_HEIGHT; if (m_frameStatusBar && m_frameStatusBar->IsShown()) height += wxSTATUS_HEIGHT;
#endif #endif
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
/* tool bar */ // tool bar
if (m_frameToolBar && m_frameToolBar->IsShown()) if (m_frameToolBar && m_frameToolBar->IsShown())
{ {
if (m_toolBarDetached) if (m_toolBarDetached)
@@ -329,17 +337,17 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
// m_x = x; // m_x = x;
// m_y = y; // m_y = y;
/* avoid recursions */ // avoid recursions
if (m_resizing) return; if (m_resizing) return;
m_resizing = TRUE; m_resizing = TRUE;
/* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */ // this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow
wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") ); wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
m_width = width; m_width = width;
m_height = height; m_height = height;
/* space occupied by m_frameToolBar and m_frameMenuBar */ // space occupied by m_frameToolBar and m_frameMenuBar
int client_area_x_offset = 0, int client_area_x_offset = 0,
client_area_y_offset = 0; client_area_y_offset = 0;
@@ -362,7 +370,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
if (m_mainWidget) if (m_mainWidget)
{ {
/* set size hints */ // set size hints
gint flag = 0; // GDK_HINT_POS; gint flag = 0; // GDK_HINT_POS;
if ((minWidth != -1) || (minHeight != -1)) flag |= GDK_HINT_MIN_SIZE; if ((minWidth != -1) || (minHeight != -1)) flag |= GDK_HINT_MIN_SIZE;
if ((maxWidth != -1) || (maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE; if ((maxWidth != -1) || (maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE;
@@ -376,11 +384,11 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
&geom, &geom,
(GdkWindowHints) flag ); (GdkWindowHints) flag );
/* I revert back to wxGTK's original behaviour. m_mainWidget holds the // I revert back to wxGTK's original behaviour. m_mainWidget holds
* menubar, the toolbar and the client area, which is represented by // the menubar, the toolbar and the client area, which is represented
* m_wxwindow. // by m_wxwindow.
* this hurts in the eye, but I don't want to call SetSize() // This hurts in the eye, but I don't want to call SetSize()
* because I don't want to call any non-native functions here. */ // because I don't want to call any non-native functions here.
#if wxUSE_MENUS_NATIVE #if wxUSE_MENUS_NATIVE
if (m_frameMenuBar) if (m_frameMenuBar)
@@ -420,7 +428,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
m_frameToolBar->m_x = xx; m_frameToolBar->m_x = xx;
m_frameToolBar->m_y = yy; m_frameToolBar->m_y = yy;
/* don't change the toolbar's reported height/width */ // don't change the toolbar's reported height/width
int ww, hh; int ww, hh;
if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL ) if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL )
{ {
@@ -435,7 +443,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
ww = m_width - 2*m_miniEdge; ww = m_width - 2*m_miniEdge;
hh = m_toolBarDetached ? wxPLACE_HOLDER hh = m_toolBarDetached ? wxPLACE_HOLDER
: m_frameToolBar->m_height; : m_frameToolBar->m_height;
client_area_y_offset += hh; client_area_y_offset += hh;
} }
@@ -455,8 +463,8 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
} }
else else
{ {
/* if there is no m_mainWidget between m_widget and m_wxwindow there // If there is no m_mainWidget between m_widget and m_wxwindow there
is no need to set the size or position of m_wxwindow. */ // is no need to set the size or position of m_wxwindow.
} }
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR

View File

@@ -816,33 +816,24 @@ int wxEntry( int argc, char *argv[] )
if ( retValue == 0 ) if ( retValue == 0 )
{ {
/* delete pending toplevel windows (typically a single // Delete pending toplevel windows
dialog) so that, if there isn't any left, we don't
call OnRun() */
wxTheApp->DeletePendingObjects(); wxTheApp->DeletePendingObjects();
wxTheApp->m_initialized = wxTopLevelWindows.GetCount() != 0; // When is the app not initialized ?
wxTheApp->m_initialized = TRUE;
if (wxTheApp->Initialized()) if (wxTheApp->Initialized())
{ {
wxTheApp->OnRun(); wxTheApp->OnRun();
wxWindow *topWindow = wxTheApp->GetTopWindow(); wxWindow *topWindow = wxTheApp->GetTopWindow();
// Delete all pending windows if any
wxTheApp->DeletePendingObjects();
// Reset top window
if (topWindow) if (topWindow)
{ wxTheApp->SetTopWindow( (wxWindow*) NULL );
/* Forcibly delete the window. */
if (topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
topWindow->IsKindOf(CLASSINFO(wxDialog)) )
{
topWindow->Close( TRUE );
wxTheApp->DeletePendingObjects();
}
else
{
delete topWindow;
wxTheApp->SetTopWindow( (wxWindow*) NULL );
}
}
retValue = wxTheApp->OnExit(); retValue = wxTheApp->OnExit();
} }

View File

@@ -91,8 +91,14 @@ static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *
static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
{ {
if (g_isIdle)
wxapp_install_idle_handler();
if (!win->m_hasVMT) return; if (!win->m_hasVMT) return;
// Raise the client area area
gdk_window_raise( win->m_wxwindow->window );
win->m_menuBarDetached = TRUE; win->m_menuBarDetached = TRUE;
win->GtkUpdateSize(); win->GtkUpdateSize();
} }
@@ -109,7 +115,6 @@ static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
if (!win->m_hasVMT) return; if (!win->m_hasVMT) return;
win->m_toolBarDetached = FALSE; win->m_toolBarDetached = FALSE;
win->GtkUpdateSize(); win->GtkUpdateSize();
} }
@@ -124,6 +129,9 @@ static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
if (!win->m_hasVMT) return; if (!win->m_hasVMT) return;
// Raise the client area area
gdk_window_raise( win->m_wxwindow->window );
win->m_toolBarDetached = TRUE; win->m_toolBarDetached = TRUE;
win->GtkUpdateSize(); win->GtkUpdateSize();
} }
@@ -149,7 +157,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
if (!parent->m_insertInClientArea) if (!parent->m_insertInClientArea)
{ {
/* these are outside the client area */ // These are outside the client area
wxFrame* frame = (wxFrame*) parent; wxFrame* frame = (wxFrame*) parent;
gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget), gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget),
GTK_WIDGET(child->m_widget), GTK_WIDGET(child->m_widget),
@@ -159,8 +167,8 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
child->m_height ); child->m_height );
#if wxUSE_TOOLBAR_NATIVE #if wxUSE_TOOLBAR_NATIVE
/* we connect to these events for recalculating the client area // We connect to these events for recalculating the client area
space when the toolbar is floating */ // space when the toolbar is floating
if (wxIS_KIND_OF(child,wxToolBar)) if (wxIS_KIND_OF(child,wxToolBar))
{ {
wxToolBar *toolBar = (wxToolBar*) child; wxToolBar *toolBar = (wxToolBar*) child;
@@ -177,7 +185,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
} }
else else
{ {
/* these are inside the client area */ // These are inside the client area
gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow), gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
GTK_WIDGET(child->m_widget), GTK_WIDGET(child->m_widget),
child->m_x, child->m_x,
@@ -186,7 +194,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
child->m_height ); child->m_height );
} }
/* resize on OnInternalIdle */ // Resize on OnInternalIdle
parent->GtkUpdateSize(); parent->GtkUpdateSize();
} }
@@ -233,7 +241,7 @@ void wxFrame::DoGetClientSize( int *width, int *height ) const
if (height) if (height)
{ {
#if wxUSE_MENUS_NATIVE #if wxUSE_MENUS_NATIVE
/* menu bar */ // menu bar
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
if (!m_menuBarDetached) if (!m_menuBarDetached)
@@ -244,13 +252,13 @@ void wxFrame::DoGetClientSize( int *width, int *height ) const
#endif // wxUSE_MENUS_NATIVE #endif // wxUSE_MENUS_NATIVE
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
/* status bar */ // status bar
if (m_frameStatusBar && m_frameStatusBar->IsShown()) if (m_frameStatusBar && m_frameStatusBar->IsShown())
(*height) -= wxSTATUS_HEIGHT; (*height) -= wxSTATUS_HEIGHT;
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
/* tool bar */ // tool bar
if (m_frameToolBar && m_frameToolBar->IsShown()) if (m_frameToolBar && m_frameToolBar->IsShown())
{ {
if (m_toolBarDetached) if (m_toolBarDetached)
@@ -280,7 +288,7 @@ void wxFrame::DoSetClientSize( int width, int height )
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
#if wxUSE_MENUS_NATIVE #if wxUSE_MENUS_NATIVE
/* menu bar */ // menu bar
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
if (!m_menuBarDetached) if (!m_menuBarDetached)
@@ -291,12 +299,12 @@ void wxFrame::DoSetClientSize( int width, int height )
#endif // wxUSE_MENUS_NATIVE #endif // wxUSE_MENUS_NATIVE
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
/* status bar */ // status bar
if (m_frameStatusBar && m_frameStatusBar->IsShown()) height += wxSTATUS_HEIGHT; if (m_frameStatusBar && m_frameStatusBar->IsShown()) height += wxSTATUS_HEIGHT;
#endif #endif
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
/* tool bar */ // tool bar
if (m_frameToolBar && m_frameToolBar->IsShown()) if (m_frameToolBar && m_frameToolBar->IsShown())
{ {
if (m_toolBarDetached) if (m_toolBarDetached)
@@ -329,17 +337,17 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
// m_x = x; // m_x = x;
// m_y = y; // m_y = y;
/* avoid recursions */ // avoid recursions
if (m_resizing) return; if (m_resizing) return;
m_resizing = TRUE; m_resizing = TRUE;
/* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */ // this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow
wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") ); wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
m_width = width; m_width = width;
m_height = height; m_height = height;
/* space occupied by m_frameToolBar and m_frameMenuBar */ // space occupied by m_frameToolBar and m_frameMenuBar
int client_area_x_offset = 0, int client_area_x_offset = 0,
client_area_y_offset = 0; client_area_y_offset = 0;
@@ -362,7 +370,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
if (m_mainWidget) if (m_mainWidget)
{ {
/* set size hints */ // set size hints
gint flag = 0; // GDK_HINT_POS; gint flag = 0; // GDK_HINT_POS;
if ((minWidth != -1) || (minHeight != -1)) flag |= GDK_HINT_MIN_SIZE; if ((minWidth != -1) || (minHeight != -1)) flag |= GDK_HINT_MIN_SIZE;
if ((maxWidth != -1) || (maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE; if ((maxWidth != -1) || (maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE;
@@ -376,11 +384,11 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
&geom, &geom,
(GdkWindowHints) flag ); (GdkWindowHints) flag );
/* I revert back to wxGTK's original behaviour. m_mainWidget holds the // I revert back to wxGTK's original behaviour. m_mainWidget holds
* menubar, the toolbar and the client area, which is represented by // the menubar, the toolbar and the client area, which is represented
* m_wxwindow. // by m_wxwindow.
* this hurts in the eye, but I don't want to call SetSize() // This hurts in the eye, but I don't want to call SetSize()
* because I don't want to call any non-native functions here. */ // because I don't want to call any non-native functions here.
#if wxUSE_MENUS_NATIVE #if wxUSE_MENUS_NATIVE
if (m_frameMenuBar) if (m_frameMenuBar)
@@ -420,7 +428,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
m_frameToolBar->m_x = xx; m_frameToolBar->m_x = xx;
m_frameToolBar->m_y = yy; m_frameToolBar->m_y = yy;
/* don't change the toolbar's reported height/width */ // don't change the toolbar's reported height/width
int ww, hh; int ww, hh;
if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL ) if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL )
{ {
@@ -435,7 +443,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
ww = m_width - 2*m_miniEdge; ww = m_width - 2*m_miniEdge;
hh = m_toolBarDetached ? wxPLACE_HOLDER hh = m_toolBarDetached ? wxPLACE_HOLDER
: m_frameToolBar->m_height; : m_frameToolBar->m_height;
client_area_y_offset += hh; client_area_y_offset += hh;
} }
@@ -455,8 +463,8 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
} }
else else
{ {
/* if there is no m_mainWidget between m_widget and m_wxwindow there // If there is no m_mainWidget between m_widget and m_wxwindow there
is no need to set the size or position of m_wxwindow. */ // is no need to set the size or position of m_wxwindow.
} }
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR