// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "app.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
- EVT_IDLE(wxApp::OnIdle)
+ EVT_IDLE(wxAppBase::OnIdle)
END_EVENT_TABLE()
bool wxApp::Initialize(int& argc, wxChar **argv)
gs_pfnXErrorHandler = XSetErrorHandler( wxXErrorHandler );
#endif // __WXDEBUG__
- char *displayName = NULL;
+ wxString displayName;
bool syncDisplay = FALSE;
int argcOrig = argc;
if (wxSscanf(argv[i], _T("%dx%d"), &w, &h) != 2)
{
wxLogError( _("Invalid geometry specification '%s'"),
- wxString::FromAscii(argv[i]).c_str() );
+ wxString(argv[i]).c_str() );
}
else
{
}
// X11 display stuff
- Display *xdisplay = XOpenDisplay( displayName );
+ Display *xdisplay;
+ if ( displayName.empty() )
+ xdisplay = XOpenDisplay( NULL );
+ else
+ xdisplay = XOpenDisplay( displayName.ToAscii() );
if (!xdisplay)
{
wxLogError( _("wxWindows could not open display. Exiting.") );
return FALSE;
}
-// Returns TRUE if more time is needed.
-// Note that this duplicates wxEventLoopImpl::SendIdleEvent
-// but ProcessIdle may be needed by apps, so is kept.
-bool wxApp::ProcessIdle()
-{
- wxIdleEvent event;
- event.SetEventObject(this);
- ProcessEvent(event);
-
- return event.MoreRequested();
-}
-
void wxApp::ExitMainLoop()
{
if (m_mainLoop)
return FALSE;
}
-void wxApp::OnIdle(wxIdleEvent& event)
-{
- static bool s_inOnIdle = FALSE;
-
- // Avoid recursion (via ProcessEvent default case)
- if (s_inOnIdle)
- return;
-
- s_inOnIdle = TRUE;
-
- // Resend in the main thread events which have been prepared in other
- // threads
- ProcessPendingEvents();
-
- // 'Garbage' collection of windows deleted with Close()
- DeletePendingObjects();
-
- // Send OnIdle events to all windows
- bool needMore = SendIdleEvents();
-
- if (needMore)
- event.RequestMore(TRUE);
-
- s_inOnIdle = FALSE;
-}
-
void wxApp::WakeUpIdle()
{
// TODO: use wxMotif implementation?
}
-// Send idle event to all top-level windows
-bool wxApp::SendIdleEvents()
-{
- bool needMore = FALSE;
-
- wxWindowList::Node* node = wxTopLevelWindows.GetFirst();
- while (node)
- {
- wxWindow* win = node->GetData();
- if (SendIdleEvents(win))
- needMore = TRUE;
- node = node->GetNext();
- }
-
- return needMore;
-}
-
-// Send idle event to window and all subwindows
-bool wxApp::SendIdleEvents(wxWindow* win)
-{
- bool needMore = FALSE;
-
- wxIdleEvent event;
- event.SetEventObject(win);
-
- win->GetEventHandler()->ProcessEvent(event);
-
- if (event.MoreRequested())
- needMore = TRUE;
-
- wxWindowListNode* node = win->GetChildren().GetFirst();
- while (node)
- {
- wxWindow* win = (wxWindow*) node->GetData();
- if (SendIdleEvents(win))
- needMore = TRUE;
-
- node = node->GetNext();
- }
-
- win->OnInternalIdle();
-
- return needMore;
-}
-
// Create display, and other initialization
bool wxApp::OnInitGui()
{
Window wxGetWindowParent(Window window)
{
- wxASSERT_MSG( window, "invalid window" );
+ wxASSERT_MSG( window, _T("invalid window") );
return (Window) 0;