]> git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/app.h
Updated German and new Finnish translations.
[wxWidgets.git] / include / wx / motif / app.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: app.h
3 // Purpose: wxApp class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 17/09/98
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/gdicmn.h"
22 #include "wx/event.h"
23
24 class WXDLLEXPORT wxFrame;
25 class WXDLLEXPORT wxWindow;
26 class WXDLLEXPORT wxApp ;
27 class WXDLLEXPORT wxKeyEvent;
28 class WXDLLEXPORT wxLog;
29
30 #define wxPRINT_WINDOWS 1
31 #define 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 inline ~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
60 // Generic
61 virtual bool OnInit() { return FALSE; };
62
63 // Create an application context
64 virtual bool OnInitGui();
65
66 // Called to set off the main loop
67 virtual int OnRun() { return MainLoop(); };
68 virtual int OnExit() { return 0; }
69
70 /** Returns the standard icons for the msg dialogs, implemented in
71 src/generic/msgdlgg.cpp and src/gtk/app.cpp. */
72 virtual wxIcon GetStdIcon(int which) const;
73
74 inline void SetPrintMode(int mode) { m_printMode = mode; }
75 inline int GetPrintMode() const { return m_printMode; }
76
77 inline void SetExitOnFrameDelete(bool flag) { m_exitOnFrameDelete = flag; }
78 inline bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete; }
79
80 inline wxString GetAppName() const {
81 if (m_appName != "")
82 return m_appName;
83 else return m_className;
84 }
85
86 inline void SetAppName(const wxString& name) { m_appName = name; };
87 inline wxString GetClassName() const { return m_className; }
88 inline void SetClassName(const wxString& name) { m_className = name; }
89
90 void SetVendorName(const wxString& vendorName) { m_vendorName = vendorName; }
91 const wxString& GetVendorName() const { return m_vendorName; }
92
93 wxWindow *GetTopWindow() const ;
94 inline void SetTopWindow(wxWindow *win) { m_topWindow = win; }
95
96 inline void SetWantDebugOutput(bool flag) { m_wantDebugOutput = flag; }
97 inline bool GetWantDebugOutput() { return m_wantDebugOutput; }
98
99 // Send idle event to all top-level windows.
100 // Returns TRUE if more idle time is requested.
101 bool SendIdleEvents();
102
103 // Send idle event to window and all subwindows
104 // Returns TRUE if more idle time is requested.
105 bool SendIdleEvents(wxWindow* win);
106
107 // Windows only, but for compatibility...
108 inline void SetAuto3D(bool flag) { m_auto3D = flag; }
109 inline bool GetAuto3D() const { return m_auto3D; }
110
111 // Creates a log object
112 virtual wxLog* CreateLogTarget();
113
114 // Motif implementation.
115
116 // Processes an X event.
117 virtual void ProcessXEvent(WXEvent* event);
118
119 // Returns TRUE if an accelerator has been processed
120 virtual bool CheckForAccelerator(WXEvent* event);
121
122 public:
123 // Will always be set to the appropriate, main-style values.
124 int argc;
125 char ** argv;
126
127 protected:
128 bool m_wantDebugOutput ;
129 wxString m_className;
130 wxString m_appName,
131 m_vendorName;
132 wxWindow * m_topWindow;
133 bool m_exitOnFrameDelete;
134 bool m_showOnInit;
135 int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
136 bool m_auto3D ; // Always use 3D controls, except
137 // where overriden
138 static wxAppInitializerFunction m_appInitFn;
139
140 public:
141
142 // Implementation
143 static bool Initialize();
144 static void CleanUp();
145
146 void DeletePendingObjects();
147 bool ProcessIdle();
148 #if wxUSE_THREADS
149 void ProcessPendingEvents();
150 #endif
151
152 // Motif-specific
153 inline WXAppContext GetAppContext() const { return m_appContext; }
154 inline WXWidget GetTopLevelWidget() const { return m_topLevelWidget; }
155 WXColormap GetMainColormap(WXDisplay* display) ;
156 WXDisplay* GetInitialDisplay() const { return m_initialDisplay; }
157 inline long GetMaxRequestSize() const { return m_maxRequestSize; }
158
159 // This handler is called when a property change event occurs
160 virtual void HandlePropertyChange(WXEvent *event);
161
162 public:
163 static long sm_lastMessageTime;
164 int m_nCmdShow;
165
166 protected:
167 bool m_keepGoing ;
168
169 // Motif-specific
170 WXAppContext m_appContext;
171 WXWidget m_topLevelWidget;
172 WXColormap m_mainColormap;
173 WXDisplay* m_initialDisplay;
174 long m_maxRequestSize;
175
176 DECLARE_EVENT_TABLE()
177 };
178
179 int WXDLLEXPORT wxEntry( int argc, char *argv[] );
180
181 #endif
182 // _WX_APP_H_
183