Made icons configurable via a wxMApp virtual function. Tested on wxGTK only,
[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 #include "wx/icon.h"
21
22 //-----------------------------------------------------------------------------
23 // classes
24 //-----------------------------------------------------------------------------
25
26 class wxApp;
27 class wxLog;
28
29 //-----------------------------------------------------------------------------
30 // global data
31 //-----------------------------------------------------------------------------
32
33 extern wxApp *wxTheApp;
34
35 //-----------------------------------------------------------------------------
36 // global functions
37 //-----------------------------------------------------------------------------
38
39 void wxExit(void);
40 bool wxYield(void);
41
42 //-----------------------------------------------------------------------------
43 // constants
44 //-----------------------------------------------------------------------------
45
46 #define wxPRINT_WINDOWS 1
47 #define wxPRINT_POSTSCRIPT 2
48
49 //-----------------------------------------------------------------------------
50 // wxApp
51 //-----------------------------------------------------------------------------
52
53 class wxApp: public wxEvtHandler
54 {
55 DECLARE_DYNAMIC_CLASS(wxApp)
56
57 public:
58
59 wxApp();
60 ~wxApp();
61
62 static void SetInitializerFunction(wxAppInitializerFunction fn) { m_appInitFn = fn; }
63 static wxAppInitializerFunction GetInitializerFunction() { return m_appInitFn; }
64
65 /* override for altering the way wxGTK intializes the GUI (palette/visual/colorcube).
66 * under wxMSW, OnInitGui() does nothing by default. when overriding this method,
67 * the code in it is likely to be platform dependent, otherwise use OnInit(). */
68 virtual bool OnInitGui();
69
70 /* override to create top level frame, display splash screen etc. */
71 virtual bool OnInit() { return FALSE; }
72
73 virtual int OnRun() { return MainLoop(); }
74 virtual int OnExit() { return 0; }
75
76 wxWindow *GetTopWindow();
77 void SetTopWindow( wxWindow *win );
78
79 virtual int MainLoop();
80 void ExitMainLoop();
81 bool Initialized();
82 virtual bool Pending();
83 virtual void Dispatch();
84
85 /** Returns the standard icons for the msg dialogs, implemented in
86 src/generic/msgdlgg.cpp and src/gtk/app.cpp. */
87 virtual wxIcon GetStdIcon(int which) const;
88 inline void SetWantDebugOutput( bool flag ) { m_wantDebugOutput = flag; }
89 inline bool GetWantDebugOutput() { return m_wantDebugOutput; }
90
91 void OnIdle( wxIdleEvent &event );
92 bool SendIdleEvents();
93 bool SendIdleEvents( wxWindow* win );
94
95 inline wxString GetAppName() const
96 { if (m_appName != "") return m_appName; else return m_className; }
97 inline void SetAppName( const wxString& name ) { m_appName = name; }
98
99 inline wxString GetClassName() const { return m_className; }
100 inline void SetClassName( const wxString& name ) { m_className = name; }
101
102 const wxString& GetVendorName() const { return m_vendorName; }
103 void SetVendorName( const wxString& name ) { m_vendorName = name; }
104
105 inline void SetExitOnFrameDelete( bool flag ) { m_exitOnFrameDelete = flag; }
106 inline bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete; }
107
108 void SetPrintMode( int WXUNUSED(mode) ) {}
109 int GetPrintMode() const { return wxPRINT_POSTSCRIPT; }
110
111 #if wxUSE_LOG
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 #endif // wxUSE_LOG
116
117 // implementation
118
119 static bool Initialize();
120 static bool InitialzeVisual();
121 static void CleanUp();
122
123 bool ProcessIdle();
124 #if wxUSE_THREADS
125 void ProcessPendingEvents();
126 #endif
127 void DeletePendingObjects();
128
129 /// This can be used to suppress the generation of Idle events.
130 inline void SuppressIdleEvents(bool arg = TRUE) { m_suppressIdleEvents = arg; }
131 inline bool GetSuppressIdleEvents() const { return m_suppressIdleEvents; }
132
133 bool m_initialized;
134 bool m_exitOnFrameDelete;
135 bool m_wantDebugOutput;
136 wxWindow *m_topWindow;
137
138 gint m_idleTag;
139 #if wxUSE_THREADS
140 gint m_wakeUpTimerTag;
141 #endif
142 unsigned char *m_colorCube;
143
144 int argc;
145 char **argv;
146
147 wxString m_vendorName;
148 wxString m_appName;
149 wxString m_className;
150
151 static wxAppInitializerFunction m_appInitFn;
152 private:
153 /// Set to TRUE while we are in wxYield().
154 bool m_suppressIdleEvents;
155 DECLARE_EVENT_TABLE()
156 };
157
158 #endif // __GTKAPPH__