]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/msw/app.h
Same as last one..
[wxWidgets.git] / include / wx / msw / app.h
... / ...
CommitLineData
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 and Markus Holzem
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __APPH__
13#define __APPH__
14
15#ifdef __GNUG__
16#pragma interface "app.h"
17#endif
18
19#include "wx/defs.h"
20#include "wx/object.h"
21
22class WXDLLEXPORT wxFrame;
23class WXDLLEXPORT wxWindow;
24class WXDLLEXPORT wxApp ;
25class WXDLLEXPORT wxKeyEvent;
26class WXDLLEXPORT wxLog;
27
28#if USE_WXCONFIG
29 class WXDLLEXPORT wxConfig;
30#endif //USE_WXCONFIG
31
32#define wxPRINT_WINDOWS 1
33#define wxPRINT_POSTSCRIPT 2
34
35WXDLLEXPORT_DATA(extern wxApp*) wxTheApp;
36
37void WXDLLEXPORT wxCleanUp(void);
38void WXDLLEXPORT wxCommonCleanUp(void); // Call this from the platform's wxCleanUp()
39void WXDLLEXPORT wxCommonInit(void); // Call this from the platform's initialization
40
41// Force an exit from main loop
42void WXDLLEXPORT wxExit(void);
43
44// Yield to other apps/messages
45bool WXDLLEXPORT wxYield(void);
46
47// Represents the application. Derive OnInit and declare
48// a new App object to start application
49class WXDLLEXPORT wxApp: public wxEvtHandler
50{
51 DECLARE_DYNAMIC_CLASS(wxApp)
52 wxApp(void);
53 inline ~wxApp(void) {}
54
55 static void SetInitializerFunction(wxAppInitializerFunction fn) { m_appInitFn = fn; }
56 static wxAppInitializerFunction GetInitializerFunction(void) { return m_appInitFn; }
57
58 virtual int MainLoop(void);
59 void ExitMainLoop(void);
60 bool Initialized(void);
61 virtual bool Pending(void) ;
62 virtual void Dispatch(void) ;
63
64 virtual void OnIdle(wxIdleEvent& event);
65
66 // Windows specific. Intercept keyboard input.
67#if WXWIN_COMPATIBILITY == 2
68 virtual bool OldOnCharHook(wxKeyEvent& event);
69#endif
70
71// Generic
72 virtual bool OnInit(void) { return FALSE; };
73
74 // No specific tasks to do here.
75 virtual bool OnInitGui(void) { return TRUE; }
76
77 // Called to set off the main loop
78 virtual int OnRun(void) { return MainLoop(); };
79 virtual int OnExit(void) { return 0; };
80 inline void SetPrintMode(int mode) { m_printMode = mode; }
81 inline int GetPrintMode(void) const { return m_printMode; }
82
83 inline void SetExitOnFrameDelete(bool flag) { m_exitOnFrameDelete = flag; }
84 inline bool GetExitOnFrameDelete(void) const { return m_exitOnFrameDelete; }
85
86/*
87 inline void SetShowFrameOnInit(bool flag) { m_showOnInit = flag; }
88 inline bool GetShowFrameOnInit(void) const { return m_showOnInit; }
89*/
90
91 inline wxString GetAppName(void) const {
92 if (m_appName != "")
93 return m_appName;
94 else return m_className;
95 }
96
97 inline void SetAppName(const wxString& name) { m_appName = name; };
98 inline wxString GetClassName(void) const { return m_className; }
99 inline void SetClassName(const wxString& name) { m_className = name; }
100 wxWindow *GetTopWindow(void) const ;
101 inline void SetTopWindow(wxWindow *win) { m_topWindow = win; }
102
103 inline void SetWantDebugOutput(bool flag) { m_wantDebugOutput = flag; }
104 inline bool GetWantDebugOutput(void) { return m_wantDebugOutput; }
105
106 // Send idle event to all top-level windows.
107 // Returns TRUE if more idle time is requested.
108 bool SendIdleEvents(void);
109
110 // Send idle event to window and all subwindows
111 // Returns TRUE if more idle time is requested.
112 bool SendIdleEvents(wxWindow* win);
113
114 inline void SetAuto3D(const bool flag) { m_auto3D = flag; }
115 inline bool GetAuto3D(void) const { return m_auto3D; }
116
117 // Creates a log object
118 virtual wxLog* CreateLogTarget();
119
120#if USE_WXCONFIG
121 // override this function to create a global wxConfig object of different
122 // than default type (right now the default implementation returns NULL)
123 virtual wxConfig* CreateConfig() { return NULL; }
124#endif //USE_WXCONFIG
125
126public:
127// void (*work_proc)(wxApp*app); // work procedure;
128 int argc;
129 char ** argv;
130
131protected:
132 bool m_wantDebugOutput ;
133 wxString m_className;
134 wxString m_appName;
135 wxWindow * m_topWindow;
136 bool m_exitOnFrameDelete;
137 bool m_showOnInit;
138 int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
139 bool m_auto3D ; // Always use 3D controls, except
140 // where overriden
141 static wxAppInitializerFunction m_appInitFn;
142
143/* Windows-specific wxApp definitions */
144
145public:
146
147 // Implementation
148 static bool Initialize(WXHINSTANCE instance);
149 static void CommonInit(void);
150 static bool RegisterWindowClasses(void);
151 static void CleanUp(void);
152 static void CommonCleanUp(void);
153 virtual bool DoMessage(void);
154 virtual bool ProcessMessage(WXMSG* pMsg);
155 void DeletePendingObjects(void);
156 bool ProcessIdle(void);
157
158/*
159 inline void SetPendingCleanup(bool flag) { m_pendingCleanup = flag; }
160 inline bool GetPendingCleanup(void) { return m_pendingCleanup; }
161
162 bool DoResourceCleanup(void);
163 // Set resource collection scheme on or off.
164 inline void SetResourceCollection(bool flag) { m_resourceCollection = flag; }
165 inline bool GetResourceCollection(void) { return m_resourceCollection; }
166*/
167
168public:
169 static long sm_lastMessageTime;
170 int m_nCmdShow;
171
172protected:
173 bool m_keepGoing ;
174// bool m_resourceCollection;
175// bool m_pendingCleanup; // TRUE if we need to check the GDI object lists for cleanup
176
177DECLARE_EVENT_TABLE()
178};
179
180#if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
181int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance, WXHINSTANCE hPrevInstance, char *lpszCmdLine,
182 int nCmdShow, bool enterLoop = TRUE);
183#else
184int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance);
185#endif
186
187#endif
188 // __APPH__
189