minor Configure / makefiles updates
[wxWidgets.git] / include / wx / gtk / app.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: app.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef __GTKAPPH__
11 #define __GTKAPPH__
12
13 #ifdef __GNUG__
14 #pragma interface
15 #endif
16
17 #include "wx/defs.h"
18 #include "wx/window.h"
19 #include "wx/frame.h"
20
21 //-----------------------------------------------------------------------------
22 // classes
23 //-----------------------------------------------------------------------------
24
25 class wxApp;
26 class wxLog;
27
28 //-----------------------------------------------------------------------------
29 // global data
30 //-----------------------------------------------------------------------------
31
32 extern wxApp *wxTheApp;
33
34 extern GdkVisual *wxVisualSetByExternal;
35 extern GdkColormap *wxColormapSetByExternal;
36
37 //-----------------------------------------------------------------------------
38 // global functions
39 //-----------------------------------------------------------------------------
40
41 void wxExit(void);
42 bool wxYield(void);
43
44 //-----------------------------------------------------------------------------
45 // constants
46 //-----------------------------------------------------------------------------
47
48 #define wxPRINT_WINDOWS 1
49 #define wxPRINT_POSTSCRIPT 2
50
51 //-----------------------------------------------------------------------------
52 // wxApp
53 //-----------------------------------------------------------------------------
54
55 class wxApp: public wxEvtHandler
56 {
57 DECLARE_DYNAMIC_CLASS(wxApp)
58
59 public:
60
61 wxApp();
62 ~wxApp();
63
64 static void SetInitializerFunction(wxAppInitializerFunction fn) { m_appInitFn = fn; }
65 static wxAppInitializerFunction GetInitializerFunction() { return m_appInitFn; }
66
67 /* this may have to be overwritten when special, non-default visuals have
68 to be set. it is also platform dependent as only X knows about displays
69 and visuals. by standard, this routine looks at wxVisualSetByExternal
70 which might have been set in the wxModule code of the OpenGL canvas */
71 virtual bool InitVisual();
72
73 virtual bool OnInit();
74 virtual bool OnInitGui();
75 virtual int OnRun();
76 virtual int OnExit();
77
78 wxWindow *GetTopWindow();
79 void SetTopWindow( wxWindow *win );
80 virtual int MainLoop();
81 void ExitMainLoop();
82 bool Initialized();
83 virtual bool Pending();
84 virtual void Dispatch();
85
86 inline void SetWantDebugOutput(bool flag) { m_wantDebugOutput = flag; }
87 inline bool GetWantDebugOutput() { return m_wantDebugOutput; }
88
89 void OnIdle( wxIdleEvent &event );
90 bool SendIdleEvents();
91 bool SendIdleEvents( wxWindow* win );
92
93 inline wxString GetAppName() const
94 {
95 if (m_appName != "")
96 return m_appName;
97 else return m_className;
98 }
99
100 inline void SetAppName(const wxString& name) { m_appName = name; };
101 inline wxString GetClassName() const { return m_className; }
102 inline void SetClassName(const wxString& name) { m_className = name; }
103 const wxString& GetVendorName() const { return m_vendorName; }
104 void SetVendorName(const wxString& name) { m_vendorName = name; }
105
106 inline void SetExitOnFrameDelete(bool flag) { m_exitOnFrameDelete = flag; }
107 inline bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete; }
108
109 void SetPrintMode(int WXUNUSED(mode) ) {};
110 int GetPrintMode() const { return wxPRINT_POSTSCRIPT; };
111
112 // override this function to create default log target of arbitrary
113 // user-defined classv (default implementation creates a wxLogGui object)
114 virtual wxLog *CreateLogTarget();
115
116 // GTK implementation
117
118 static void CommonInit();
119 static void CommonCleanUp();
120
121 bool ProcessIdle();
122 void DeletePendingObjects();
123
124 bool m_initialized;
125 bool m_exitOnFrameDelete;
126 bool m_wantDebugOutput;
127 wxWindow *m_topWindow;
128
129 gint m_idleTag;
130
131 int argc;
132 char **argv;
133
134 static wxAppInitializerFunction m_appInitFn;
135
136 private:
137 wxString m_vendorName,
138 m_appName,
139 m_className;
140
141 DECLARE_EVENT_TABLE()
142 };
143
144 #endif // __GTKAPPH__