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
);
59 virtual bool OnInit() { return FALSE
; };
61 // No specific tasks to do here.
62 virtual bool OnInitGui() { return TRUE
; }
64 // Called to set off the main loop
65 virtual int OnRun() { return MainLoop(); };
66 virtual int OnExit() { return 0; }
68 inline void SetPrintMode(int mode
) { m_printMode
= mode
; }
69 inline int GetPrintMode() const { return m_printMode
; }
71 inline void SetExitOnFrameDelete(bool flag
) { m_exitOnFrameDelete
= flag
; }
72 inline bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete
; }
74 inline wxString
GetAppName() const {
77 else return m_className
;
80 inline void SetAppName(const wxString
& name
) { m_appName
= name
; };
81 inline wxString
GetClassName() const { return m_className
; }
82 inline void SetClassName(const wxString
& name
) { m_className
= name
; }
84 void SetVendorName(const wxString
& vendorName
) { m_vendorName
= vendorName
; }
85 const wxString
& GetVendorName() const { return m_vendorName
; }
87 wxWindow
*GetTopWindow() const ;
88 inline void SetTopWindow(wxWindow
*win
) { m_topWindow
= win
; }
90 inline void SetWantDebugOutput(bool flag
) { m_wantDebugOutput
= flag
; }
91 inline bool GetWantDebugOutput() { return m_wantDebugOutput
; }
93 // Send idle event to all top-level windows.
94 // Returns TRUE if more idle time is requested.
95 bool SendIdleEvents();
97 // Send idle event to window and all subwindows
98 // Returns TRUE if more idle time is requested.
99 bool SendIdleEvents(wxWindow
* win
);
101 inline void SetAuto3D(bool flag
) { m_auto3D
= flag
; }
102 inline bool GetAuto3D() const { return m_auto3D
; }
104 // Creates a log object
105 virtual wxLog
* CreateLogTarget();
108 // void (*work_proc)(wxApp*app); // work procedure;
113 bool m_wantDebugOutput
;
114 wxString m_className
;
117 wxWindow
* m_topWindow
;
118 bool m_exitOnFrameDelete
;
120 int m_printMode
; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
121 bool m_auto3D
; // Always use 3D controls, except
123 static wxAppInitializerFunction m_appInitFn
;
125 /* Windows-specific wxApp definitions */
130 static bool Initialize();
131 static void CleanUp();
133 static bool RegisterWindowClasses();
134 // Convert Windows to argc, argv style
135 void ConvertToStandardCommandArgs(char* p
);
136 virtual bool DoMessage();
137 virtual bool ProcessMessage(WXMSG
* pMsg
);
138 void DeletePendingObjects();
140 int GetComCtl32Version() const;
143 static long sm_lastMessageTime
;
149 DECLARE_EVENT_TABLE()
152 #if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
153 int WXDLLEXPORT
wxEntry(WXHINSTANCE hInstance
, WXHINSTANCE hPrevInstance
, char *lpszCmdLine
,
154 int nCmdShow
, bool enterLoop
= TRUE
);
156 int WXDLLEXPORT
wxEntry(WXHINSTANCE hInstance
);