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"
22 class WXDLLEXPORT wxFrame
;
23 class WXDLLEXPORT wxWindow
;
24 class WXDLLEXPORT wxApp
;
25 class WXDLLEXPORT wxKeyEvent
;
26 class WXDLLEXPORT wxLog
;
28 #define wxPRINT_WINDOWS 1
29 #define wxPRINT_POSTSCRIPT 2
31 WXDLLEXPORT_DATA(extern wxApp
*) wxTheApp
;
33 // Force an exit from main loop
34 void WXDLLEXPORT
wxExit();
36 // Yield to other apps/messages
37 bool WXDLLEXPORT
wxYield();
39 // Represents the application. Derive OnInit and declare
40 // a new App object to start application
41 class WXDLLEXPORT wxApp
: public wxEvtHandler
43 DECLARE_DYNAMIC_CLASS(wxApp
)
47 static void SetInitializerFunction(wxAppInitializerFunction fn
) { m_appInitFn
= fn
; }
48 static wxAppInitializerFunction
GetInitializerFunction() { return m_appInitFn
; }
50 virtual int MainLoop();
53 virtual bool Pending() ;
54 virtual void Dispatch() ;
56 void OnIdle(wxIdleEvent
& event
);
57 void OnEndSession(wxCloseEvent
& event
);
58 void OnQueryEndSession(wxCloseEvent
& event
);
61 virtual bool OnInit() { return FALSE
; };
63 // No specific tasks to do here.
64 virtual bool OnInitGui() { return TRUE
; }
66 // Called to set off the main loop
67 virtual int OnRun() { return MainLoop(); };
68 virtual int OnExit() { return 0; }
70 // called when a fatal exception occurs, this function should take care not
71 // to do anything which might provoke a nested exception!
72 virtual void OnFatalException() { }
74 inline void SetPrintMode(int mode
) { m_printMode
= mode
; }
75 inline int GetPrintMode() const { return m_printMode
; }
77 inline void SetExitOnFrameDelete(bool flag
) { m_exitOnFrameDelete
= flag
; }
78 inline bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete
; }
80 inline wxString
GetAppName() const {
83 else return m_className
;
86 inline void SetAppName(const wxString
& name
) { m_appName
= name
; };
87 inline wxString
GetClassName() const { return m_className
; }
88 inline void SetClassName(const wxString
& name
) { m_className
= name
; }
90 void SetVendorName(const wxString
& vendorName
) { m_vendorName
= vendorName
; }
91 const wxString
& GetVendorName() const { return m_vendorName
; }
93 wxWindow
*GetTopWindow() const ;
94 inline void SetTopWindow(wxWindow
*win
) { m_topWindow
= win
; }
96 inline void SetWantDebugOutput(bool flag
) { m_wantDebugOutput
= flag
; }
97 inline bool GetWantDebugOutput() { return m_wantDebugOutput
; }
99 // Send idle event to all top-level windows.
100 // Returns TRUE if more idle time is requested.
101 bool SendIdleEvents();
103 // Send idle event to window and all subwindows
104 // Returns TRUE if more idle time is requested.
105 bool SendIdleEvents(wxWindow
* win
);
107 inline void SetAuto3D(bool flag
) { m_auto3D
= flag
; }
108 inline bool GetAuto3D() const { return m_auto3D
; }
110 // Creates a log object
111 virtual wxLog
* CreateLogTarget();
114 // void (*work_proc)(wxApp*app); // work procedure;
119 bool m_wantDebugOutput
;
120 wxString m_className
;
123 wxWindow
* m_topWindow
;
124 bool m_exitOnFrameDelete
;
126 int m_printMode
; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
127 bool m_auto3D
; // Always use 3D controls, except
129 static wxAppInitializerFunction m_appInitFn
;
131 /* Windows-specific wxApp definitions */
136 static bool Initialize();
137 static void CleanUp();
139 static bool RegisterWindowClasses();
140 // Convert Windows to argc, argv style
141 void ConvertToStandardCommandArgs(char* p
);
142 virtual bool DoMessage();
143 virtual bool ProcessMessage(WXMSG
* pMsg
);
144 void DeletePendingObjects();
146 int GetComCtl32Version() const;
149 static long sm_lastMessageTime
;
155 DECLARE_EVENT_TABLE()
158 #if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
159 int WXDLLEXPORT
wxEntry(WXHINSTANCE hInstance
, WXHINSTANCE hPrevInstance
, char *lpszCmdLine
,
160 int nCmdShow
, bool enterLoop
= TRUE
);
162 int WXDLLEXPORT
wxEntry(WXHINSTANCE hInstance
);