1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxApp class
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "app.h"
20 #include "wx/object.h"
21 #include "wx/gdicmn.h"
24 class WXDLLEXPORT wxFrame
;
25 class WXDLLEXPORT wxWindow
;
26 class WXDLLEXPORT wxApp
;
27 class WXDLLEXPORT wxKeyEvent
;
28 class WXDLLEXPORT wxLog
;
30 #define wxPRINT_WINDOWS 1
31 #define 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
);
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 /** Returns the standard icons for the msg dialogs, implemented in
71 src/generic/msgdlgg.cpp and src/gtk/app.cpp. */
72 virtual wxIcon
GetStdIcon(int which
) const;
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 // Windows only, but for compatibility...
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 // Will always be set to the appropriate, main-style values.
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
;
135 static bool Initialize();
136 static void CleanUp();
138 void DeletePendingObjects();
142 static long sm_lastMessageTime
;
148 DECLARE_EVENT_TABLE()
151 // TODO: add platform-specific arguments
152 int WXDLLEXPORT
wxEntry( int argc
, char *argv
[] );