]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/app.h
* wxMemory*Stream link problem fix.
[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
bb6290e3
JS
37void WXDLLEXPORT wxCleanUp();
38void WXDLLEXPORT wxCommonCleanUp(); // Call this from the platform's wxCleanUp()
39void WXDLLEXPORT wxCommonInit(); // Call this from the platform's initialization
2bda0e17
KB
40
41// Force an exit from main loop
bb6290e3 42void WXDLLEXPORT wxExit();
2bda0e17
KB
43
44// Yield to other apps/messages
bb6290e3 45bool WXDLLEXPORT wxYield();
2bda0e17
KB
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)
bb6290e3
JS
52 wxApp();
53 inline ~wxApp() {}
2bda0e17
KB
54
55 static void SetInitializerFunction(wxAppInitializerFunction fn) { m_appInitFn = fn; }
bb6290e3 56 static wxAppInitializerFunction GetInitializerFunction() { return m_appInitFn; }
2bda0e17 57
bb6290e3
JS
58 virtual int MainLoop();
59 void ExitMainLoop();
60 bool Initialized();
61 virtual bool Pending() ;
62 virtual void Dispatch() ;
2bda0e17
KB
63
64 virtual void OnIdle(wxIdleEvent& event);
65
2bda0e17 66// Generic
bb6290e3 67 virtual bool OnInit() { return FALSE; };
2bda0e17
KB
68
69 // No specific tasks to do here.
bb6290e3 70 virtual bool OnInitGui() { return TRUE; }
2bda0e17
KB
71
72 // Called to set off the main loop
bb6290e3
JS
73 virtual int OnRun() { return MainLoop(); };
74 virtual int OnExit() { return 0; };
2bda0e17 75 inline void SetPrintMode(int mode) { m_printMode = mode; }
bb6290e3 76 inline int GetPrintMode() const { return m_printMode; }
2bda0e17 77
bb6290e3
JS
78 inline void SetExitOnFrameDelete(bool flag) { m_exitOnFrameDelete = flag; }
79 inline bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete; }
2bda0e17 80
bb6290e3 81 inline wxString GetAppName() const {
2bda0e17
KB
82 if (m_appName != "")
83 return m_appName;
84 else return m_className;
85 }
86
87 inline void SetAppName(const wxString& name) { m_appName = name; };
bb6290e3 88 inline wxString GetClassName() const { return m_className; }
2bda0e17 89 inline void SetClassName(const wxString& name) { m_className = name; }
bb6290e3 90 wxWindow *GetTopWindow() const ;
2bda0e17
KB
91 inline void SetTopWindow(wxWindow *win) { m_topWindow = win; }
92
93 inline void SetWantDebugOutput(bool flag) { m_wantDebugOutput = flag; }
bb6290e3 94 inline bool GetWantDebugOutput() { return m_wantDebugOutput; }
2bda0e17
KB
95
96 // Send idle event to all top-level windows.
97 // Returns TRUE if more idle time is requested.
bb6290e3 98 bool SendIdleEvents();
2bda0e17
KB
99
100 // Send idle event to window and all subwindows
101 // Returns TRUE if more idle time is requested.
102 bool SendIdleEvents(wxWindow* win);
103
debe6624 104 inline void SetAuto3D(bool flag) { m_auto3D = flag; }
bb6290e3 105 inline bool GetAuto3D() const { return m_auto3D; }
2bda0e17
KB
106
107 // Creates a log object
4e066dd2
VZ
108 virtual wxLog* CreateLogTarget();
109
110#if USE_WXCONFIG
111 // override this function to create a global wxConfig object of different
112 // than default type (right now the default implementation returns NULL)
113 virtual wxConfig* CreateConfig() { return NULL; }
114#endif //USE_WXCONFIG
2bda0e17
KB
115
116public:
117// void (*work_proc)(wxApp*app); // work procedure;
118 int argc;
119 char ** argv;
120
121protected:
122 bool m_wantDebugOutput ;
123 wxString m_className;
124 wxString m_appName;
125 wxWindow * m_topWindow;
126 bool m_exitOnFrameDelete;
127 bool m_showOnInit;
128 int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
129 bool m_auto3D ; // Always use 3D controls, except
130 // where overriden
131 static wxAppInitializerFunction m_appInitFn;
132
133/* Windows-specific wxApp definitions */
134
135public:
136
137 // Implementation
138 static bool Initialize(WXHINSTANCE instance);
bb6290e3
JS
139 static void CommonInit();
140 static bool RegisterWindowClasses();
141 static void CleanUp();
142 static void CommonCleanUp();
143 virtual bool DoMessage();
2bda0e17 144 virtual bool ProcessMessage(WXMSG* pMsg);
bb6290e3
JS
145 void DeletePendingObjects();
146 bool ProcessIdle();
147 int GetComCtl32Version() const;
2bda0e17
KB
148
149public:
150 static long sm_lastMessageTime;
151 int m_nCmdShow;
152
153protected:
154 bool m_keepGoing ;
155// bool m_resourceCollection;
156// bool m_pendingCleanup; // TRUE if we need to check the GDI object lists for cleanup
157
158DECLARE_EVENT_TABLE()
159};
160
161#if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
162int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance, WXHINSTANCE hPrevInstance, char *lpszCmdLine,
163 int nCmdShow, bool enterLoop = TRUE);
164#else
165int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance);
166#endif
167
168#endif
169 // __APPH__
170