]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/app.h
got rid of wxEvtHandler::m_isWindow, use virtual functions (overridden in wxWindow...
[wxWidgets.git] / include / wx / mac / app.h
CommitLineData
0dbd6262
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: app.h
3// Purpose: wxApp class
a31a5f85 4// Author: Stefan Csomor
0dbd6262 5// Modified by:
a31a5f85 6// Created: 1998-01-01
0dbd6262 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
0dbd6262
SC
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_APP_H_
13#define _WX_APP_H_
14
af49c4b8 15#if defined(__GNUG__) && !defined(__APPLE__)
0dbd6262
SC
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
24class WXDLLEXPORT wxFrame;
e766c8a9 25class WXDLLEXPORT wxWindowMac;
0dbd6262
SC
26class WXDLLEXPORT wxApp ;
27class WXDLLEXPORT wxKeyEvent;
28class WXDLLEXPORT wxLog;
29
30#define wxPRINT_WINDOWS 1
31#define wxPRINT_POSTSCRIPT 2
32
33WXDLLEXPORT_DATA(extern wxApp*) wxTheApp;
34
35// Force an exit from main loop
36void WXDLLEXPORT wxExit();
37
38// Yield to other apps/messages
39bool WXDLLEXPORT wxYield();
40
41// Represents the application. Derive OnInit and declare
42// a new App object to start application
05adb9d2 43class WXDLLEXPORT wxApp: public wxAppBase
0dbd6262 44{
fbbdb7cd
GD
45 DECLARE_DYNAMIC_CLASS(wxApp)
46
47 wxApp();
48 virtual ~wxApp() {}
49
50 virtual int MainLoop();
51 virtual void ExitMainLoop();
52 virtual bool Initialized();
53 virtual bool Pending() ;
54 virtual void Dispatch() ;
e2478fde
VZ
55
56 virtual void Exit();
57
fbbdb7cd 58 virtual bool Yield(bool onlyIfNeeded = FALSE);
90a1a975 59 virtual bool ProcessIdle();
e2478fde 60 virtual void WakeUpIdle();
fbbdb7cd
GD
61
62 virtual void SetPrintMode(int mode) { m_printMode = mode; }
63 virtual int GetPrintMode() const { return m_printMode; }
64
cbf8aca6
SC
65#if wxUSE_GUI
66 // setting up all MacOS Specific Event-Handlers etc
67 virtual bool OnInitGui();
68#endif // wxUSE_GUI
fbbdb7cd
GD
69 // implementation only
70 void OnIdle(wxIdleEvent& event);
71 void OnEndSession(wxCloseEvent& event);
72 void OnQueryEndSession(wxCloseEvent& event);
73
74 // Send idle event to all top-level windows.
75 // Returns TRUE if more idle time is requested.
76 bool SendIdleEvents();
77
78 // Send idle event to window and all subwindows
79 // Returns TRUE if more idle time is requested.
80 bool SendIdleEvents(wxWindowMac* win);
81
82 // Windows only, but for compatibility...
83 inline void SetAuto3D(bool flag) { m_auto3D = flag; }
84 inline bool GetAuto3D() const { return m_auto3D; }
85
0dbd6262 86protected:
fbbdb7cd
GD
87 bool m_showOnInit;
88 int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
89 bool m_auto3D ; // Always use 3D controls, except
90 // where overriden
0dbd6262
SC
91public:
92
fbbdb7cd
GD
93 // Implementation
94 static bool Initialize();
95 static void CleanUp();
96
97 void DeletePendingObjects();
fbbdb7cd 98 bool IsExiting() { return !m_keepGoing ; }
cbf8aca6 99#if TARGET_CARBON
d921af51
JS
100 WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; }
101 WXEVENTHANDLERREF MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef ; }
cbf8aca6
SC
102#endif
103
0dbd6262 104public:
fbbdb7cd
GD
105 static long sm_lastMessageTime;
106 static wxWindow* s_captureWindow ;
107 static int s_lastMouseDown ; // 0 = none , 1 = left , 2 = right
108 static WXHRGN s_macCursorRgn ;
41d368a4 109 static long s_lastModifiers ;
fbbdb7cd
GD
110
111 int m_nCmdShow;
112
cd28bcad 113private:
fbbdb7cd 114 bool m_keepGoing ;
519cb848 115
fbbdb7cd 116 // mac specifics
cbf8aca6 117#if TARGET_CARBON
d921af51
JS
118 WXEVENTHANDLERREF m_macEventHandler ;
119 WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef ;
cbf8aca6 120#endif
cd28bcad
SC
121 WXEVENTREF m_macCurrentEvent ;
122
123public:
fbbdb7cd
GD
124 static bool s_macDefaultEncodingIsPC ;
125 static bool s_macSupportPCMenuShortcuts ;
126 static long s_macAboutMenuItemId ;
2b5f62a0
VZ
127 static long s_macPreferencesMenuItemId ;
128 static long s_macExitMenuItemId ;
fbbdb7cd
GD
129 static wxString s_macHelpMenuTitleName ;
130
131 static bool s_macHasAppearance ;
132 static long s_macAppearanceVersion ;
133 static bool s_macHasNavigation ;
134 static bool s_macNavigationVersion ;
135 static bool s_macHasWindowManager ;
136 static long s_macWindowManagerVersion ;
137 static bool s_macHasMenuManager ;
138 static long s_macMenuManagerVersion ;
139 static bool s_macHasDialogManager ;
140 static long s_macDialogManagerVersion ;
141
142 WXHRGN m_macCursorRgn ;
143 WXHRGN m_macSleepRgn ;
144 WXHRGN m_macHelpRgn ;
145
146 virtual void MacSuspend( bool convertClipboard ) ;
147 virtual void MacResume( bool convertClipboard ) ;
fbbdb7cd
GD
148 virtual void MacConvertPrivateToPublicScrap() ;
149 virtual void MacConvertPublicToPrivateScrap() ;
cbf8aca6 150
cd28bcad
SC
151 void MacDoOneEvent() ;
152 WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
153 void MacHandleOneEvent( WXEVENTREF ev ) ;
cbf8aca6
SC
154#if !TARGET_CARBON
155 virtual void MacHandleMenuSelect( int menuid , int menuitem ) ;
156 virtual void MacHandleMouseUpEvent( WXEVENTREF ev ) ;
157 virtual void MacHandleOSEvent( WXEVENTREF ev ) ;
158 virtual void MacHandleDiskEvent( WXEVENTREF ev ) ;
159 virtual void MacHandleActivateEvent( WXEVENTREF ev ) ;
160 virtual void MacHandleUpdateEvent( WXEVENTREF ev ) ;
cbf8aca6 161 virtual void MacHandleMouseDownEvent( WXEVENTREF ev ) ;
fbbdb7cd 162
41d368a4 163 void MacHandleModifierEvents( WXEVENTREF ev ) ;
cd28bcad 164
fbbdb7cd
GD
165 virtual void MacHandleKeyDownEvent( WXEVENTREF ev ) ;
166 virtual void MacHandleKeyUpEvent( WXEVENTREF ev ) ;
fbbdb7cd 167 virtual void MacHandleHighLevelEvent( WXEVENTREF ev ) ;
fbbdb7cd 168
cd28bcad
SC
169#endif
170
d921af51
JS
171 void MacHandleMenuCommand( wxUint32 command ) ;
172 bool MacSendKeyDownEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ;
173 bool MacSendKeyUpEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ;
174
fbbdb7cd
GD
175 virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
176 virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
177 virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
178 virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
179
2072fbbb 180 // in response of an open-document apple event
d921af51 181 virtual void MacOpenFile(const wxString &fileName) ;
2072fbbb 182 // in response of a print-document apple event
d921af51 183 virtual void MacPrintFile(const wxString &fileName) ;
2072fbbb 184 // in response of a open-application apple event
d921af51 185 virtual void MacNewFile() ;
2072fbbb 186
fbbdb7cd 187 DECLARE_EVENT_TABLE()
0dbd6262
SC
188};
189
fa15551c
SC
190class WXDLLEXPORT wxStAppResource
191{
fbbdb7cd 192public:
fa15551c
SC
193 wxStAppResource() ;
194 ~wxStAppResource() ;
fbbdb7cd
GD
195
196 // opaque pointer for CFragInitBlock
197 static void OpenSharedLibraryResource(const void *) ;
198 static void CloseSharedLibraryResource() ;
199
200private:
201 short m_currentRefNum ;
fa15551c
SC
202} ;
203
0dbd6262
SC
204#endif
205 // _WX_APP_H_
206