]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/app.h
0b79229f8b55cf256e54512a2c525df2851af238
[wxWidgets.git] / include / wx / msw / app.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: app.h
3 // Purpose: wxApp class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_APP_H_
13 #define _WX_APP_H_
14
15 #ifdef __GNUG__
16 #pragma interface "app.h"
17 #endif
18
19 #include "wx/defs.h"
20 #include "wx/object.h"
21 #include "wx/event.h"
22
23 class WXDLLEXPORT wxFrame;
24 class WXDLLEXPORT wxWindow;
25 class WXDLLEXPORT wxApp ;
26 class WXDLLEXPORT wxKeyEvent;
27 class WXDLLEXPORT wxLog;
28
29 static const int wxPRINT_WINDOWS = 1;
30 static const int wxPRINT_POSTSCRIPT = 2;
31
32 WXDLLEXPORT_DATA(extern wxApp*) wxTheApp;
33
34 // Force an exit from main loop
35 void WXDLLEXPORT wxExit();
36
37 // Yield to other apps/messages
38 bool WXDLLEXPORT wxYield();
39
40 // Represents the application. Derive OnInit and declare
41 // a new App object to start application
42 class WXDLLEXPORT wxApp: public wxEvtHandler
43 {
44 DECLARE_DYNAMIC_CLASS(wxApp)
45 wxApp();
46 ~wxApp();
47
48 static void SetInitializerFunction(wxAppInitializerFunction fn) { m_appInitFn = fn; }
49 static wxAppInitializerFunction GetInitializerFunction() { return m_appInitFn; }
50
51 virtual int MainLoop();
52 void ExitMainLoop();
53 bool Initialized();
54 virtual bool Pending() ;
55 virtual void Dispatch() ;
56
57 void OnIdle(wxIdleEvent& event);
58 void OnEndSession(wxCloseEvent& event);
59 void OnQueryEndSession(wxCloseEvent& event);
60
61 // Generic
62 virtual bool OnInit() { return FALSE; };
63
64 // No specific tasks to do here.
65 virtual bool OnInitGui() { return TRUE; }
66
67 // Called to set off the main loop
68 virtual int OnRun() { return MainLoop(); };
69 virtual int OnExit() { return 0; }
70
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() { }
74
75 void SetPrintMode(int mode) { m_printMode = mode; }
76 int GetPrintMode() const { return m_printMode; }
77
78 void SetExitOnFrameDelete(bool flag) { m_exitOnFrameDelete = flag; }
79 bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete; }
80
81 const wxString& GetAppName() const {
82 if (m_appName != _T(""))
83 return m_appName;
84 else return m_className;
85 }
86
87 void SetAppName(const wxString& name) { m_appName = name; };
88 wxString GetClassName() const { return m_className; }
89 void SetClassName(const wxString& name) { m_className = name; }
90
91 void SetVendorName(const wxString& vendorName) { m_vendorName = vendorName; }
92 const wxString& GetVendorName() const { return m_vendorName; }
93
94 wxWindow *GetTopWindow() const ;
95 void SetTopWindow(wxWindow *win) { m_topWindow = win; }
96
97 void SetWantDebugOutput(bool flag) { m_wantDebugOutput = flag; }
98 bool GetWantDebugOutput() { return m_wantDebugOutput; }
99
100 // Send idle event to all top-level windows.
101 // Returns TRUE if more idle time is requested.
102 bool SendIdleEvents();
103
104 // Send idle event to window and all subwindows
105 // Returns TRUE if more idle time is requested.
106 bool SendIdleEvents(wxWindow* win);
107
108 void SetAuto3D(bool flag) { m_auto3D = flag; }
109 bool GetAuto3D() const { return m_auto3D; }
110
111 // Creates a log object
112 virtual wxLog* CreateLogTarget();
113
114 public:
115 int argc;
116 wxChar ** argv;
117
118 protected:
119 bool m_wantDebugOutput ;
120 wxString m_className;
121 wxString m_appName,
122 m_vendorName;
123 wxWindow * m_topWindow;
124 bool m_exitOnFrameDelete;
125 bool m_showOnInit;
126 int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
127 bool m_auto3D ; // Always use 3D controls, except
128 // where overriden
129 static wxAppInitializerFunction m_appInitFn;
130
131 /* Windows-specific wxApp definitions */
132
133 public:
134
135 // Implementation
136 static bool Initialize();
137 static void CleanUp();
138
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();
145 bool ProcessIdle();
146 #if wxUSE_THREADS
147 void ProcessPendingEvents();
148 #endif
149 int GetComCtl32Version() const;
150
151 public:
152 int m_nCmdShow;
153
154 protected:
155 bool m_keepGoing ;
156
157 DECLARE_EVENT_TABLE()
158 };
159
160 #if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
161 int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance, WXHINSTANCE hPrevInstance, char *lpszCmdLine,
162 int nCmdShow, bool enterLoop = TRUE);
163 #else
164 int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance);
165 #endif
166
167 #endif
168 // _WX_APP_H_
169