Made icons configurable via a wxMApp virtual function. Tested on wxGTK only,
[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 #include "wx/icon.h"
23
24 class WXDLLEXPORT wxFrame;
25 class WXDLLEXPORT wxWindow;
26 class WXDLLEXPORT wxApp ;
27 class WXDLLEXPORT wxKeyEvent;
28 class WXDLLEXPORT wxLog;
29
30 static const int wxPRINT_WINDOWS = 1;
31 static const int wxPRINT_POSTSCRIPT = 2;
32
33 WXDLLEXPORT_DATA(extern wxApp*) wxTheApp;
34
35 // Force an exit from main loop
36 void WXDLLEXPORT wxExit();
37
38 // Yield to other apps/messages
39 bool WXDLLEXPORT wxYield();
40
41 // Represents the application. Derive OnInit and declare
42 // a new App object to start application
43 class WXDLLEXPORT wxApp: public wxEvtHandler
44 {
45 DECLARE_DYNAMIC_CLASS(wxApp)
46 wxApp();
47 ~wxApp();
48
49 static void SetInitializerFunction(wxAppInitializerFunction fn) { m_appInitFn = fn; }
50 static wxAppInitializerFunction GetInitializerFunction() { return m_appInitFn; }
51
52 virtual int MainLoop();
53 void ExitMainLoop();
54 bool Initialized();
55 virtual bool Pending() ;
56 virtual void Dispatch() ;
57
58 void OnIdle(wxIdleEvent& event);
59 void OnEndSession(wxCloseEvent& event);
60 void OnQueryEndSession(wxCloseEvent& event);
61
62 // Generic
63 virtual bool OnInit() { return FALSE; };
64
65 // No specific tasks to do here.
66 virtual bool OnInitGui() { return TRUE; }
67
68 // Called to set off the main loop
69 virtual int OnRun() { return MainLoop(); };
70 virtual int OnExit() { return 0; }
71 /** Returns the standard icons for the msg dialogs, implemented in
72 src/generic/msgdlgg.cpp and src/gtk/app.cpp. */
73 virtual wxIcon GetStdIcon(int which) const;
74
75 // called when a fatal exception occurs, this function should take care not
76 // to do anything which might provoke a nested exception!
77 virtual void OnFatalException() { }
78
79 void SetPrintMode(int mode) { m_printMode = mode; }
80 int GetPrintMode() const { return m_printMode; }
81
82 void SetExitOnFrameDelete(bool flag) { m_exitOnFrameDelete = flag; }
83 bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete; }
84
85 const wxString& GetAppName() const {
86 if (m_appName != _T(""))
87 return m_appName;
88 else return m_className;
89 }
90
91 void SetAppName(const wxString& name) { m_appName = name; };
92 wxString GetClassName() const { return m_className; }
93 void SetClassName(const wxString& name) { m_className = name; }
94
95 void SetVendorName(const wxString& vendorName) { m_vendorName = vendorName; }
96 const wxString& GetVendorName() const { return m_vendorName; }
97
98 wxWindow *GetTopWindow() const ;
99 void SetTopWindow(wxWindow *win) { m_topWindow = win; }
100
101 void SetWantDebugOutput(bool flag) { m_wantDebugOutput = flag; }
102 bool GetWantDebugOutput() { return m_wantDebugOutput; }
103
104 // Send idle event to all top-level windows.
105 // Returns TRUE if more idle time is requested.
106 bool SendIdleEvents();
107
108 // Send idle event to window and all subwindows
109 // Returns TRUE if more idle time is requested.
110 bool SendIdleEvents(wxWindow* win);
111
112 void SetAuto3D(bool flag) { m_auto3D = flag; }
113 bool GetAuto3D() const { return m_auto3D; }
114
115 // Creates a log object
116 virtual wxLog* CreateLogTarget();
117
118 public:
119 int argc;
120 wxChar ** argv;
121
122 protected:
123 bool m_wantDebugOutput ;
124 wxString m_className;
125 wxString m_appName,
126 m_vendorName;
127 wxWindow * m_topWindow;
128 bool m_exitOnFrameDelete;
129 bool m_showOnInit;
130 int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
131 bool m_auto3D ; // Always use 3D controls, except
132 // where overriden
133 static wxAppInitializerFunction m_appInitFn;
134
135 /* Windows-specific wxApp definitions */
136
137 public:
138
139 // Implementation
140 static bool Initialize();
141 static void CleanUp();
142
143 static bool RegisterWindowClasses();
144 // Convert Windows to argc, argv style
145 void ConvertToStandardCommandArgs(char* p);
146 virtual bool DoMessage();
147 virtual bool ProcessMessage(WXMSG* pMsg);
148 void DeletePendingObjects();
149 bool ProcessIdle();
150 #if wxUSE_THREADS
151 void ProcessPendingEvents();
152 #endif
153 int GetComCtl32Version() const;
154
155 public:
156 int m_nCmdShow;
157
158 protected:
159 bool m_keepGoing ;
160
161 DECLARE_EVENT_TABLE()
162 };
163
164 #if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
165 int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance, WXHINSTANCE hPrevInstance, char *lpszCmdLine,
166 int nCmdShow, bool enterLoop = TRUE);
167 #else
168 int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance);
169 #endif
170
171 #endif
172 // _WX_APP_H_
173