]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/app.h
added HasEntry/Group function to wxConfig, corrected entry/group deletion
[wxWidgets.git] / include / wx / msw / app.h
CommitLineData
2bda0e17
KB
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
4e066dd2
VZ
28#if USE_WXCONFIG
29 class WXDLLEXPORT wxConfig;
30#endif //USE_WXCONFIG
31
2bda0e17
KB
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
2bda0e17
KB
66// Generic
67 virtual bool OnInit(void) { return FALSE; };
68
69 // No specific tasks to do here.
70 virtual bool OnInitGui(void) { return TRUE; }
71
72 // Called to set off the main loop
73 virtual int OnRun(void) { return MainLoop(); };
74 virtual int OnExit(void) { return 0; };
75 inline void SetPrintMode(int mode) { m_printMode = mode; }
76 inline int GetPrintMode(void) const { return m_printMode; }
77
78 inline void SetExitOnFrameDelete(bool flag) { m_exitOnFrameDelete = flag; }
79 inline bool GetExitOnFrameDelete(void) const { return m_exitOnFrameDelete; }
80
81/*
82 inline void SetShowFrameOnInit(bool flag) { m_showOnInit = flag; }
83 inline bool GetShowFrameOnInit(void) const { return m_showOnInit; }
84*/
85
86 inline wxString GetAppName(void) const {
87 if (m_appName != "")
88 return m_appName;
89 else return m_className;
90 }
91
92 inline void SetAppName(const wxString& name) { m_appName = name; };
93 inline wxString GetClassName(void) const { return m_className; }
94 inline void SetClassName(const wxString& name) { m_className = name; }
95 wxWindow *GetTopWindow(void) const ;
96 inline void SetTopWindow(wxWindow *win) { m_topWindow = win; }
97
98 inline void SetWantDebugOutput(bool flag) { m_wantDebugOutput = flag; }
99 inline bool GetWantDebugOutput(void) { return m_wantDebugOutput; }
100
101 // Send idle event to all top-level windows.
102 // Returns TRUE if more idle time is requested.
103 bool SendIdleEvents(void);
104
105 // Send idle event to window and all subwindows
106 // Returns TRUE if more idle time is requested.
107 bool SendIdleEvents(wxWindow* win);
108
debe6624 109 inline void SetAuto3D(bool flag) { m_auto3D = flag; }
2bda0e17
KB
110 inline bool GetAuto3D(void) const { return m_auto3D; }
111
112 // Creates a log object
4e066dd2
VZ
113 virtual wxLog* CreateLogTarget();
114
115#if USE_WXCONFIG
116 // override this function to create a global wxConfig object of different
117 // than default type (right now the default implementation returns NULL)
118 virtual wxConfig* CreateConfig() { return NULL; }
119#endif //USE_WXCONFIG
2bda0e17
KB
120
121public:
122// void (*work_proc)(wxApp*app); // work procedure;
123 int argc;
124 char ** argv;
125
126protected:
127 bool m_wantDebugOutput ;
128 wxString m_className;
129 wxString m_appName;
130 wxWindow * m_topWindow;
131 bool m_exitOnFrameDelete;
132 bool m_showOnInit;
133 int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
134 bool m_auto3D ; // Always use 3D controls, except
135 // where overriden
136 static wxAppInitializerFunction m_appInitFn;
137
138/* Windows-specific wxApp definitions */
139
140public:
141
142 // Implementation
143 static bool Initialize(WXHINSTANCE instance);
144 static void CommonInit(void);
145 static bool RegisterWindowClasses(void);
146 static void CleanUp(void);
147 static void CommonCleanUp(void);
148 virtual bool DoMessage(void);
149 virtual bool ProcessMessage(WXMSG* pMsg);
150 void DeletePendingObjects(void);
151 bool ProcessIdle(void);
152
153/*
154 inline void SetPendingCleanup(bool flag) { m_pendingCleanup = flag; }
155 inline bool GetPendingCleanup(void) { return m_pendingCleanup; }
156
157 bool DoResourceCleanup(void);
158 // Set resource collection scheme on or off.
159 inline void SetResourceCollection(bool flag) { m_resourceCollection = flag; }
160 inline bool GetResourceCollection(void) { return m_resourceCollection; }
161*/
162
163public:
164 static long sm_lastMessageTime;
165 int m_nCmdShow;
166
167protected:
168 bool m_keepGoing ;
169// bool m_resourceCollection;
170// bool m_pendingCleanup; // TRUE if we need to check the GDI object lists for cleanup
171
172DECLARE_EVENT_TABLE()
173};
174
175#if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
176int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance, WXHINSTANCE hPrevInstance, char *lpszCmdLine,
177 int nCmdShow, bool enterLoop = TRUE);
178#else
179int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance);
180#endif
181
182#endif
183 // __APPH__
184