]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/app.h
Added in-place editiging in wxListCtrl
[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
22 class WXDLLEXPORT wxFrame;
23 class WXDLLEXPORT wxWindow;
24 class WXDLLEXPORT wxApp ;
25 class WXDLLEXPORT wxKeyEvent;
26 class WXDLLEXPORT wxLog;
27
28 #define wxPRINT_WINDOWS 1
29 #define wxPRINT_POSTSCRIPT 2
30
31 WXDLLEXPORT_DATA(extern wxApp*) wxTheApp;
32
33 void WXDLLEXPORT wxCleanUp();
34 void WXDLLEXPORT wxCommonCleanUp(); // Call this from the platform's wxCleanUp()
35 void WXDLLEXPORT wxCommonInit(); // Call this from the platform's initialization
36
37 // Force an exit from main loop
38 void WXDLLEXPORT wxExit();
39
40 // Yield to other apps/messages
41 bool WXDLLEXPORT wxYield();
42
43 // Represents the application. Derive OnInit and declare
44 // a new App object to start application
45 class WXDLLEXPORT wxApp: public wxEvtHandler
46 {
47 DECLARE_DYNAMIC_CLASS(wxApp)
48 wxApp();
49 inline ~wxApp() {}
50
51 static void SetInitializerFunction(wxAppInitializerFunction fn) { m_appInitFn = fn; }
52 static wxAppInitializerFunction GetInitializerFunction() { return m_appInitFn; }
53
54 virtual int MainLoop();
55 void ExitMainLoop();
56 bool Initialized();
57 virtual bool Pending() ;
58 virtual void Dispatch() ;
59
60 virtual void OnIdle(wxIdleEvent& 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
72 inline void SetPrintMode(int mode) { m_printMode = mode; }
73 inline int GetPrintMode() const { return m_printMode; }
74
75 inline void SetExitOnFrameDelete(bool flag) { m_exitOnFrameDelete = flag; }
76 inline bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete; }
77
78 inline wxString GetAppName() const {
79 if (m_appName != "")
80 return m_appName;
81 else return m_className;
82 }
83
84 inline void SetAppName(const wxString& name) { m_appName = name; };
85 inline wxString GetClassName() const { return m_className; }
86 inline void SetClassName(const wxString& name) { m_className = name; }
87
88 void SetVendorName(const wxString& vendorName) { m_vendorName = vendorName; }
89 const wxString& GetVendorName() const { return m_vendorName; }
90
91 wxWindow *GetTopWindow() const ;
92 inline void SetTopWindow(wxWindow *win) { m_topWindow = win; }
93
94 inline void SetWantDebugOutput(bool flag) { m_wantDebugOutput = flag; }
95 inline bool GetWantDebugOutput() { return m_wantDebugOutput; }
96
97 // Send idle event to all top-level windows.
98 // Returns TRUE if more idle time is requested.
99 bool SendIdleEvents();
100
101 // Send idle event to window and all subwindows
102 // Returns TRUE if more idle time is requested.
103 bool SendIdleEvents(wxWindow* win);
104
105 inline void SetAuto3D(bool flag) { m_auto3D = flag; }
106 inline bool GetAuto3D() const { return m_auto3D; }
107
108 // Creates a log object
109 virtual wxLog* CreateLogTarget();
110
111 public:
112 // void (*work_proc)(wxApp*app); // work procedure;
113 int argc;
114 char ** argv;
115
116 protected:
117 bool m_wantDebugOutput ;
118 wxString m_className;
119 wxString m_appName,
120 m_vendorName;
121 wxWindow * m_topWindow;
122 bool m_exitOnFrameDelete;
123 bool m_showOnInit;
124 int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
125 bool m_auto3D ; // Always use 3D controls, except
126 // where overriden
127 static wxAppInitializerFunction m_appInitFn;
128
129 /* Windows-specific wxApp definitions */
130
131 public:
132
133 // Implementation
134 static bool Initialize(WXHINSTANCE instance);
135 static void CommonInit();
136 static bool RegisterWindowClasses();
137 static void CleanUp();
138 static void CommonCleanUp();
139 virtual bool DoMessage();
140 virtual bool ProcessMessage(WXMSG* pMsg);
141 void DeletePendingObjects();
142 bool ProcessIdle();
143 int GetComCtl32Version() const;
144
145 public:
146 static long sm_lastMessageTime;
147 int m_nCmdShow;
148
149 protected:
150 bool m_keepGoing ;
151 // bool m_resourceCollection;
152 // bool m_pendingCleanup; // TRUE if we need to check the GDI object lists for cleanup
153
154 DECLARE_EVENT_TABLE()
155 };
156
157 #if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
158 int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance, WXHINSTANCE hPrevInstance, char *lpszCmdLine,
159 int nCmdShow, bool enterLoop = TRUE);
160 #else
161 int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance);
162 #endif
163
164 #endif
165 // _WX_APP_H_
166