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"
23 class WXDLLEXPORT wxFrame
;
24 class WXDLLEXPORT wxWindow
;
25 class WXDLLEXPORT wxApp
;
26 class WXDLLEXPORT wxKeyEvent
;
27 class WXDLLEXPORT wxLog
;
29 #define wxPRINT_WINDOWS 1
30 #define wxPRINT_POSTSCRIPT 2
32 WXDLLEXPORT_DATA(extern wxApp
*) wxTheApp
;
34 // Force an exit from main loop
35 void WXDLLEXPORT
wxExit();
37 // Yield to other apps/messages
38 bool WXDLLEXPORT
wxYield();
40 // Represents the application. Derive OnInit and declare
41 // a new App object to start application
42 class WXDLLEXPORT wxApp
: public wxEvtHandler
44 DECLARE_DYNAMIC_CLASS(wxApp
)
48 static void SetInitializerFunction(wxAppInitializerFunction fn
) { m_appInitFn
= fn
; }
49 static wxAppInitializerFunction
GetInitializerFunction() { return m_appInitFn
; }
51 virtual int MainLoop();
54 virtual bool Pending() ;
55 virtual void Dispatch() ;
57 void OnIdle(wxIdleEvent
& event
);
58 void OnEndSession(wxCloseEvent
& event
);
59 void OnQueryEndSession(wxCloseEvent
& event
);
62 virtual bool OnInit() { return FALSE
; };
64 // No specific tasks to do here.
65 virtual bool OnInitGui() { return TRUE
; }
67 // Called to set off the main loop
68 virtual int OnRun() { return MainLoop(); };
69 virtual int OnExit() { return 0; }
71 // called when a fatal exception occurs, this function should take care not
72 // to do anything which might provoke a nested exception!
73 virtual void OnFatalException() { }
75 inline void SetPrintMode(int mode
) { m_printMode
= mode
; }
76 inline int GetPrintMode() const { return m_printMode
; }
78 inline void SetExitOnFrameDelete(bool flag
) { m_exitOnFrameDelete
= flag
; }
79 inline bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete
; }
81 inline const wxString
& GetAppName() const {
82 if (m_appName
!= _T(""))
84 else return m_className
;
87 inline void SetAppName(const wxString
& name
) { m_appName
= name
; };
88 inline wxString
GetClassName() const { return m_className
; }
89 inline void SetClassName(const wxString
& name
) { m_className
= name
; }
91 void SetVendorName(const wxString
& vendorName
) { m_vendorName
= vendorName
; }
92 const wxString
& GetVendorName() const { return m_vendorName
; }
94 wxWindow
*GetTopWindow() const ;
95 inline void SetTopWindow(wxWindow
*win
) { m_topWindow
= win
; }
97 inline void SetWantDebugOutput(bool flag
) { m_wantDebugOutput
= flag
; }
98 inline bool GetWantDebugOutput() { return m_wantDebugOutput
; }
100 // Send idle event to all top-level windows.
101 // Returns TRUE if more idle time is requested.
102 bool SendIdleEvents();
104 // Send idle event to window and all subwindows
105 // Returns TRUE if more idle time is requested.
106 bool SendIdleEvents(wxWindow
* win
);
108 inline void SetAuto3D(bool flag
) { m_auto3D
= flag
; }
109 inline bool GetAuto3D() const { return m_auto3D
; }
111 // Creates a log object
112 virtual wxLog
* CreateLogTarget();
115 // void (*work_proc)(wxApp*app); // work procedure;
120 bool m_wantDebugOutput
;
121 wxString m_className
;
124 wxWindow
* m_topWindow
;
125 bool m_exitOnFrameDelete
;
127 int m_printMode
; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
128 bool m_auto3D
; // Always use 3D controls, except
130 static wxAppInitializerFunction m_appInitFn
;
132 /* Windows-specific wxApp definitions */
137 static bool Initialize();
138 static void CleanUp();
140 static bool RegisterWindowClasses();
141 // Convert Windows to argc, argv style
142 void ConvertToStandardCommandArgs(char* p
);
143 virtual bool DoMessage();
144 virtual bool ProcessMessage(WXMSG
* pMsg
);
145 void DeletePendingObjects();
148 void ProcessPendingEvents();
150 int GetComCtl32Version() const;
153 static long sm_lastMessageTime
;
159 DECLARE_EVENT_TABLE()
162 #if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
163 int WXDLLEXPORT
wxEntry(WXHINSTANCE hInstance
, WXHINSTANCE hPrevInstance
, char *lpszCmdLine
,
164 int nCmdShow
, bool enterLoop
= TRUE
);
166 int WXDLLEXPORT
wxEntry(WXHINSTANCE hInstance
);