1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxApp class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "app.h"
20 #include "wx/object.h"
24 class WXDLLEXPORT wxFrame
;
25 class WXDLLEXPORT wxWindow
;
26 class WXDLLEXPORT wxApp
;
27 class WXDLLEXPORT wxKeyEvent
;
28 class WXDLLEXPORT wxLog
;
30 static const int wxPRINT_WINDOWS
= 1;
31 static const int wxPRINT_POSTSCRIPT
= 2;
33 WXDLLEXPORT_DATA(extern wxApp
*) wxTheApp
;
35 // Force an exit from main loop
36 void WXDLLEXPORT
wxExit();
38 // Yield to other apps/messages
39 bool WXDLLEXPORT
wxYield();
41 // Represents the application. Derive OnInit and declare
42 // a new App object to start application
43 class WXDLLEXPORT wxApp
: public wxEvtHandler
45 DECLARE_DYNAMIC_CLASS(wxApp
)
49 static void SetInitializerFunction(wxAppInitializerFunction fn
) { m_appInitFn
= fn
; }
50 static wxAppInitializerFunction
GetInitializerFunction() { return m_appInitFn
; }
52 virtual int MainLoop();
55 virtual bool Pending() ;
56 virtual void Dispatch() ;
58 void OnIdle(wxIdleEvent
& event
);
59 void OnEndSession(wxCloseEvent
& event
);
60 void OnQueryEndSession(wxCloseEvent
& event
);
63 virtual bool OnInit() { return FALSE
; };
65 // No specific tasks to do here.
66 virtual bool OnInitGui() { return TRUE
; }
68 // Called to set off the main loop
69 virtual int OnRun() { return MainLoop(); };
70 virtual int OnExit() { return 0; }
71 /** Returns the standard icons for the msg dialogs, implemented in
72 src/generic/msgdlgg.cpp and src/gtk/app.cpp. */
73 virtual wxIcon
GetStdIcon(int which
) const;
75 // called when a fatal exception occurs, this function should take care not
76 // to do anything which might provoke a nested exception!
77 virtual void OnFatalException() { }
79 void SetPrintMode(int mode
) { m_printMode
= mode
; }
80 int GetPrintMode() const { return m_printMode
; }
82 void SetExitOnFrameDelete(bool flag
) { m_exitOnFrameDelete
= flag
; }
83 bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete
; }
85 const wxString
& GetAppName() const {
86 if (m_appName
!= _T(""))
88 else return m_className
;
91 void SetAppName(const wxString
& name
) { m_appName
= name
; };
92 wxString
GetClassName() const { return m_className
; }
93 void SetClassName(const wxString
& name
) { m_className
= name
; }
95 void SetVendorName(const wxString
& vendorName
) { m_vendorName
= vendorName
; }
96 const wxString
& GetVendorName() const { return m_vendorName
; }
98 wxWindow
*GetTopWindow() const ;
99 void SetTopWindow(wxWindow
*win
) { m_topWindow
= win
; }
101 void SetWantDebugOutput(bool flag
) { m_wantDebugOutput
= flag
; }
102 bool GetWantDebugOutput() { return m_wantDebugOutput
; }
104 // Send idle event to all top-level windows.
105 // Returns TRUE if more idle time is requested.
106 bool SendIdleEvents();
108 // Send idle event to window and all subwindows
109 // Returns TRUE if more idle time is requested.
110 bool SendIdleEvents(wxWindow
* win
);
112 void SetAuto3D(bool flag
) { m_auto3D
= flag
; }
113 bool GetAuto3D() const { return m_auto3D
; }
115 // Creates a log object
116 virtual wxLog
* CreateLogTarget();
123 bool m_wantDebugOutput
;
124 wxString m_className
;
127 wxWindow
* m_topWindow
;
128 bool m_exitOnFrameDelete
;
130 int m_printMode
; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
131 bool m_auto3D
; // Always use 3D controls, except
133 static wxAppInitializerFunction m_appInitFn
;
135 /* Windows-specific wxApp definitions */
140 static bool Initialize();
141 static void CleanUp();
143 static bool RegisterWindowClasses();
144 // Convert Windows to argc, argv style
145 void ConvertToStandardCommandArgs(char* p
);
146 virtual bool DoMessage();
147 virtual bool ProcessMessage(WXMSG
* pMsg
);
148 void DeletePendingObjects();
151 void ProcessPendingEvents();
153 int GetComCtl32Version() const;
161 DECLARE_EVENT_TABLE()
164 #if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
165 int WXDLLEXPORT
wxEntry(WXHINSTANCE hInstance
, WXHINSTANCE hPrevInstance
, char *lpszCmdLine
,
166 int nCmdShow
, bool enterLoop
= TRUE
);
168 int WXDLLEXPORT
wxEntry(WXHINSTANCE hInstance
);