X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a11672a469f036436838911c268cb2f8d5da5bf8..44ba8f0ea92f65d9893ce0780971745a5d8e80ea:/src/gtk1/app.cpp?ds=sidebyside diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index 6b0b5276df..08de37e9ae 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -24,6 +24,8 @@ #include "wx/font.h" #include "wx/settings.h" #include "wx/dialog.h" +#include "wx/msgdlg.h" +#include "wx/file.h" #if wxUSE_WX_RESOURCES #include "wx/resource.h" @@ -42,7 +44,9 @@ #endif #include -#ifdef __VMS +#if defined(__DARWIN__) +// FIXME: select must be used instead of poll (GD) +#elif defined(__VMS) # include #else # include @@ -85,12 +89,14 @@ void wxExit() // wxYield //----------------------------------------------------------------------------- +// not static because used by textctrl.cpp +// +// MT-FIXME +bool wxIsInsideYield = FALSE; + bool wxApp::Yield(bool onlyIfNeeded) { - // MT-FIXME - static bool s_inYield = FALSE; - - if ( s_inYield ) + if ( wxIsInsideYield ) { if ( !onlyIfNeeded ) { @@ -108,7 +114,7 @@ bool wxApp::Yield(bool onlyIfNeeded) } #endif // wxUSE_THREADS - s_inYield = TRUE; + wxIsInsideYield = TRUE; if (!g_isIdle) { @@ -128,7 +134,7 @@ bool wxApp::Yield(bool onlyIfNeeded) // It's necessary to call ProcessIdle() to update the frames sizes which // might have been changed (it also will update other things set from - // OnUpdateUI() which is a nice (and desired) side effect). But we + // OnUpdateUI() which is a nice (and desired) side effect). But we // call ProcessIdle() only once since this is not meant for longish // background jobs (controlled by wxIdleEvent::RequestMore() and the // return value of Processidle(). @@ -137,7 +143,7 @@ bool wxApp::Yield(bool onlyIfNeeded) // let the logs be flashed again wxLog::Resume(); - s_inYield = FALSE; + wxIsInsideYield = FALSE; return TRUE; } @@ -208,6 +214,13 @@ static gint wxapp_idle_callback( gpointer WXUNUSED(data) ) // from some safely-looking functions if ( wxTheApp->IsInAssert() ) { + // But repaint the assertion message if necessary + if (wxTopLevelWindows.GetCount() > 0) + { + wxWindow* win = (wxWindow*) wxTopLevelWindows.Last()->Data(); + if (win->IsKindOf(CLASSINFO(wxGenericMessageDialog))) + win->OnInternalIdle(); + } return TRUE; } #endif // __WXDEBUG__ @@ -245,7 +258,14 @@ static gint wxapp_poll_func( GPollFD *ufds, guint nfds, gint timeout ) wxMutexGuiLeave(); g_mainThreadLocked = TRUE; +#ifdef __DARWIN__ + // FIXME: poll is not available under Darwin/Mac OS X and this needs + // to be implemented using select instead (GD) + // what about other BSD derived systems? + res = -1; +#else res = poll( (struct pollfd*) ufds, nfds, timeout ); +#endif wxMutexGuiEnter(); g_mainThreadLocked = FALSE; @@ -315,7 +335,7 @@ wxApp::wxApp() #endif m_colorCube = (unsigned char*) NULL; - + // this is NULL for a "regular" wxApp, but is set (and freed) by a wxGLApp m_glVisualInfo = (void *) NULL; } @@ -342,7 +362,7 @@ bool wxApp::OnInitGui() // seems gtk_widget_set_default_visual no longer exists? GdkVisual* vis = gtk_widget_get_default_visual(); #else - GdkVisual* vis = gdkx_visual_get( + GdkVisual* vis = gdkx_visual_get( ((XVisualInfo *) m_glVisualInfo) ->visualid ); gtk_widget_set_default_visual( vis ); #endif @@ -352,7 +372,7 @@ bool wxApp::OnInitGui() visual = vis; } - + // On some machines, the default visual is just 256 colours, so // we make sure we get the best. This can sometimes be wasteful. @@ -430,14 +450,14 @@ bool wxApp::OnInitGui() GdkVisual *wxApp::GetGdkVisual() { GdkVisual *visual = NULL; - + if (m_glVisualInfo) visual = gdkx_visual_get( ((XVisualInfo *) m_glVisualInfo)->visualid ); else visual = gdk_window_get_visual( wxGetRootWindow()->window ); - + wxASSERT( visual ); - + return visual; } @@ -486,12 +506,37 @@ bool wxApp::SendIdleEvents() wxWindow* win = node->GetData(); if (SendIdleEvents(win)) needMore = TRUE; + node = node->GetNext(); } + node = wxTopLevelWindows.GetFirst(); + while (node) + { + wxWindow* win = node->GetData(); + CallInternalIdle( win ); + + node = node->GetNext(); + } return needMore; } +bool wxApp::CallInternalIdle( wxWindow* win ) +{ + win->OnInternalIdle(); + + wxNode* node = win->GetChildren().First(); + while (node) + { + wxWindow* win = (wxWindow*) node->Data(); + CallInternalIdle( win ); + + node = node->Next(); + } + + return TRUE; +} + bool wxApp::SendIdleEvents( wxWindow* win ) { bool needMore = FALSE; @@ -500,9 +545,7 @@ bool wxApp::SendIdleEvents( wxWindow* win ) event.SetEventObject(win); win->GetEventHandler()->ProcessEvent(event); - - win->OnInternalIdle(); - + if (event.MoreRequested()) needMore = TRUE; @@ -515,7 +558,8 @@ bool wxApp::SendIdleEvents( wxWindow* win ) node = node->Next(); } - return needMore ; + + return needMore; } int wxApp::MainLoop() @@ -563,8 +607,6 @@ void wxApp::DeletePendingObjects() bool wxApp::Initialize() { - wxBuffer = new wxChar[BUFSIZ + 512]; - wxClassInfo::InitializeClasses(); #if wxUSE_INTL @@ -612,9 +654,6 @@ void wxApp::CleanUp() delete wxTheApp; wxTheApp = (wxApp*) NULL; - delete[] wxBuffer; - wxBuffer = NULL; - wxClassInfo::CleanUpClasses(); #if wxUSE_THREADS @@ -788,33 +827,24 @@ int wxEntry( int argc, char *argv[] ) if ( retValue == 0 ) { - /* delete pending toplevel windows (typically a single - dialog) so that, if there isn't any left, we don't - call OnRun() */ + // Delete pending toplevel windows wxTheApp->DeletePendingObjects(); - wxTheApp->m_initialized = wxTopLevelWindows.GetCount() != 0; + // When is the app not initialized ? + wxTheApp->m_initialized = TRUE; if (wxTheApp->Initialized()) { wxTheApp->OnRun(); wxWindow *topWindow = wxTheApp->GetTopWindow(); + + // Delete all pending windows if any + wxTheApp->DeletePendingObjects(); + + // Reset top window if (topWindow) - { - /* 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 ); - } - } + wxTheApp->SetTopWindow( (wxWindow*) NULL ); retValue = wxTheApp->OnExit(); } @@ -825,54 +855,13 @@ int wxEntry( int argc, char *argv[] ) return retValue; } -#ifndef __WXUNIVERSAL__ - -// XPM hack: make the arrays const -#define static static const - -#include "wx/gtk/info.xpm" -#include "wx/gtk/error.xpm" -#include "wx/gtk/question.xpm" -#include "wx/gtk/warning.xpm" - -#undef static - -wxIcon wxApp::GetStdIcon(int which) const -{ - switch(which) - { - case wxICON_INFORMATION: - return wxIcon(info_xpm); - - case wxICON_QUESTION: - return wxIcon(question_xpm); - - case wxICON_EXCLAMATION: - return wxIcon(warning_xpm); - - default: - wxFAIL_MSG(wxT("requested non existent standard icon")); - // still fall through - - case wxICON_HAND: - return wxIcon(error_xpm); - } -} -#else -wxIcon wxApp::GetStdIcon(int which) const -{ - return wxTheme::Get()->GetRenderer()->GetStdIcon(which); -} -#endif // !__WXUNIVERSAL__ - - #ifdef __WXDEBUG__ -void wxApp::OnAssert(const wxChar *file, int line, const wxChar *msg) +void wxApp::OnAssert(const wxChar *file, int line, const wxChar* cond, const wxChar *msg) { m_isInAssert = TRUE; - wxAppBase::OnAssert(file, line, msg); + wxAppBase::OnAssert(file, line, cond, msg); m_isInAssert = FALSE; }