appcmn.cpp
来自「A*算法 A*算法 A*算法 A*算法A*算法A*算法」· C++ 代码 · 共 613 行 · 第 1/2 页
CPP
613 行
wxEventLoop * const loop = wxEventLoop::GetActive();
return loop && loop->Dispatch();
#else // wxUSE_EVTLOOP_IN_APP
return true;
#endif // wxUSE_EVTLOOP_IN_APP/!wxUSE_EVTLOOP_IN_APP
}
// ----------------------------------------------------------------------------
// OnXXX() hooks
// ----------------------------------------------------------------------------
bool wxAppBase::OnInitGui()
{
#ifdef __WXUNIVERSAL__
if ( !wxTheme::Get() && !wxTheme::CreateDefault() )
return false;
#endif // __WXUNIVERSAL__
return true;
}
int wxAppBase::OnRun()
{
// see the comment in ctor: if the initial value hasn't been changed, use
// the default Yes from now on
if ( m_exitOnFrameDelete == Later )
{
m_exitOnFrameDelete = Yes;
}
//else: it has been changed, assume the user knows what he is doing
return MainLoop();
}
int wxAppBase::OnExit()
{
#ifdef __WXUNIVERSAL__
delete wxTheme::Set(NULL);
#endif // __WXUNIVERSAL__
return wxAppConsole::OnExit();
}
void wxAppBase::Exit()
{
ExitMainLoop();
}
wxAppTraits *wxAppBase::CreateTraits()
{
return new wxGUIAppTraits;
}
// ----------------------------------------------------------------------------
// misc
// ----------------------------------------------------------------------------
void wxAppBase::SetActive(bool active, wxWindow * WXUNUSED(lastFocus))
{
if ( active == m_isActive )
return;
m_isActive = active;
wxActivateEvent event(wxEVT_ACTIVATE_APP, active);
event.SetEventObject(this);
(void)ProcessEvent(event);
}
void wxAppBase::DeletePendingObjects()
{
wxList::compatibility_iterator node = wxPendingDelete.GetFirst();
while (node)
{
wxObject *obj = node->GetData();
delete obj;
if (wxPendingDelete.Member(obj))
wxPendingDelete.Erase(node);
// Deleting one object may have deleted other pending
// objects, so start from beginning of list again.
node = wxPendingDelete.GetFirst();
}
}
// Returns true if more time is needed.
bool wxAppBase::ProcessIdle()
{
wxIdleEvent event;
bool needMore = false;
wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
while (node)
{
wxWindow* win = node->GetData();
if (SendIdleEvents(win, event))
needMore = true;
node = node->GetNext();
}
event.SetEventObject(this);
(void) ProcessEvent(event);
if (event.MoreRequested())
needMore = true;
wxUpdateUIEvent::ResetUpdateTime();
return needMore;
}
// Send idle event to window and all subwindows
bool wxAppBase::SendIdleEvents(wxWindow* win, wxIdleEvent& event)
{
bool needMore = false;
win->OnInternalIdle();
if (wxIdleEvent::CanSend(win))
{
event.SetEventObject(win);
win->GetEventHandler()->ProcessEvent(event);
if (event.MoreRequested())
needMore = true;
}
wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst();
while ( node )
{
wxWindow *child = node->GetData();
if (SendIdleEvents(child, event))
needMore = true;
node = node->GetNext();
}
return needMore;
}
void wxAppBase::OnIdle(wxIdleEvent& WXUNUSED(event))
{
// If there are pending events, we must process them: pending events
// are either events to the threads other than main or events posted
// with wxPostEvent() functions
// GRG: I have moved this here so that all pending events are processed
// before starting to delete any objects. This behaves better (in
// particular, wrt wxPostEvent) and is coherent with wxGTK's current
// behaviour. Changed Feb/2000 before 2.1.14
ProcessPendingEvents();
// 'Garbage' collection of windows deleted with Close().
DeletePendingObjects();
#if wxUSE_LOG
// flush the logged messages if any
wxLog::FlushActive();
#endif // wxUSE_LOG
}
// ----------------------------------------------------------------------------
// wxGUIAppTraitsBase
// ----------------------------------------------------------------------------
#if wxUSE_LOG
wxLog *wxGUIAppTraitsBase::CreateLogTarget()
{
#if wxUSE_LOGGUI
return new wxLogGui;
#else
// we must have something!
return new wxLogStderr;
#endif
}
#endif // wxUSE_LOG
wxMessageOutput *wxGUIAppTraitsBase::CreateMessageOutput()
{
// The standard way of printing help on command line arguments (app --help)
// is (according to common practice):
// - console apps: to stderr (on any platform)
// - GUI apps: stderr on Unix platforms (!)
// message box under Windows and others
#ifdef __UNIX__
return new wxMessageOutputStderr;
#else // !__UNIX__
// wxMessageOutputMessageBox doesn't work under Motif
#ifdef __WXMOTIF__
return new wxMessageOutputLog;
#else
return new wxMessageOutputMessageBox;
#endif
#endif // __UNIX__/!__UNIX__
}
#if wxUSE_FONTMAP
wxFontMapper *wxGUIAppTraitsBase::CreateFontMapper()
{
return new wxFontMapper;
}
#endif // wxUSE_FONTMAP
wxRendererNative *wxGUIAppTraitsBase::CreateRenderer()
{
// use the default native renderer by default
return NULL;
}
#ifdef __WXDEBUG__
bool wxGUIAppTraitsBase::ShowAssertDialog(const wxString& msg)
{
// under MSW we prefer to use the base class version using ::MessageBox()
// even if wxMessageBox() is available because it has less chances to
// double fault our app than our wxMessageBox()
#if defined(__WXMSW__) || !wxUSE_MSGDLG
return wxAppTraitsBase::ShowAssertDialog(msg);
#else // wxUSE_MSGDLG
// this message is intentionally not translated -- it is for
// developpers only
wxString msgDlg(msg);
msgDlg += wxT("\nDo you want to stop the program?\n")
wxT("You can also choose [Cancel] to suppress ")
wxT("further warnings.");
switch ( wxMessageBox(msgDlg, wxT("wxWidgets Debug Alert"),
wxYES_NO | wxCANCEL | wxICON_STOP ) )
{
case wxYES:
wxTrap();
break;
case wxCANCEL:
// no more asserts
return true;
//case wxNO: nothing to do
}
return false;
#endif // !wxUSE_MSGDLG/wxUSE_MSGDLG
}
#endif // __WXDEBUG__
bool wxGUIAppTraitsBase::HasStderr()
{
// we consider that under Unix stderr always goes somewhere, even if the
// user doesn't always see it under GUI desktops
#ifdef __UNIX__
return true;
#else
return false;
#endif
}
void wxGUIAppTraitsBase::ScheduleForDestroy(wxObject *object)
{
if ( !wxPendingDelete.Member(object) )
wxPendingDelete.Append(object);
}
void wxGUIAppTraitsBase::RemoveFromPendingDelete(wxObject *object)
{
wxPendingDelete.DeleteObject(object);
}
#if wxUSE_SOCKETS
#if defined(__WINDOWS__)
#include "wx/msw/gsockmsw.h"
#elif defined(__UNIX__) || defined(__DARWIN__) || defined(__OS2__)
#include "wx/unix/gsockunx.h"
#elif defined(__WXMAC__)
#include <MacHeaders.c>
#define OTUNIXERRORS 1
#include <OpenTransport.h>
#include <OpenTransportProviders.h>
#include <OpenTptInternet.h>
#include "wx/mac/gsockmac.h"
#else
#error "Must include correct GSocket header here"
#endif
GSocketGUIFunctionsTable* wxGUIAppTraitsBase::GetSocketGUIFunctionsTable()
{
#if defined(__WXMAC__) && !defined(__DARWIN__)
// NB: wxMac CFM does not have any GUI-specific functions in gsocket.c and
// so it doesn't need this table at all
return NULL;
#else // !__WXMAC__ || __DARWIN__
static GSocketGUIFunctionsTableConcrete table;
return &table;
#endif // !__WXMAC__ || __DARWIN__
}
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?