]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/app.h
expat define MACOS_CLASSIC added
[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);
e2478fde 59 virtual void WakeUpIdle();
fbbdb7cd
GD
60
61 virtual void SetPrintMode(int mode) { m_printMode = mode; }
62 virtual int GetPrintMode() const { return m_printMode; }
63
cbf8aca6
SC
64#if wxUSE_GUI
65 // setting up all MacOS Specific Event-Handlers etc
66 virtual bool OnInitGui();
67#endif // wxUSE_GUI
fbbdb7cd
GD
68 // implementation only
69 void OnIdle(wxIdleEvent& event);
70 void OnEndSession(wxCloseEvent& event);
71 void OnQueryEndSession(wxCloseEvent& event);
72
fbbdb7cd
GD
73 // Windows only, but for compatibility...
74 inline void SetAuto3D(bool flag) { m_auto3D = flag; }
75 inline bool GetAuto3D() const { return m_auto3D; }
76
0dbd6262 77protected:
fbbdb7cd
GD
78 bool m_showOnInit;
79 int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
80 bool m_auto3D ; // Always use 3D controls, except
81 // where overriden
0dbd6262
SC
82public:
83
fbbdb7cd 84 // Implementation
05e2b077 85 virtual bool Initialize(int& argc, wxChar **argv);
94826170 86 virtual void CleanUp();
fbbdb7cd 87
fbbdb7cd 88 bool IsExiting() { return !m_keepGoing ; }
cbf8aca6 89#if TARGET_CARBON
d921af51
JS
90 WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; }
91 WXEVENTHANDLERREF MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef ; }
cbf8aca6
SC
92#endif
93
0dbd6262 94public:
fbbdb7cd
GD
95 static long sm_lastMessageTime;
96 static wxWindow* s_captureWindow ;
97 static int s_lastMouseDown ; // 0 = none , 1 = left , 2 = right
98 static WXHRGN s_macCursorRgn ;
41d368a4 99 static long s_lastModifiers ;
fbbdb7cd
GD
100
101 int m_nCmdShow;
102
cd28bcad 103private:
fbbdb7cd 104 bool m_keepGoing ;
519cb848 105
fbbdb7cd 106 // mac specifics
cbf8aca6 107#if TARGET_CARBON
d921af51
JS
108 WXEVENTHANDLERREF m_macEventHandler ;
109 WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef ;
cbf8aca6 110#endif
cd28bcad
SC
111 WXEVENTREF m_macCurrentEvent ;
112
113public:
fbbdb7cd
GD
114 static bool s_macDefaultEncodingIsPC ;
115 static bool s_macSupportPCMenuShortcuts ;
116 static long s_macAboutMenuItemId ;
2b5f62a0
VZ
117 static long s_macPreferencesMenuItemId ;
118 static long s_macExitMenuItemId ;
fbbdb7cd
GD
119 static wxString s_macHelpMenuTitleName ;
120
121 static bool s_macHasAppearance ;
122 static long s_macAppearanceVersion ;
123 static bool s_macHasNavigation ;
124 static bool s_macNavigationVersion ;
125 static bool s_macHasWindowManager ;
126 static long s_macWindowManagerVersion ;
127 static bool s_macHasMenuManager ;
128 static long s_macMenuManagerVersion ;
129 static bool s_macHasDialogManager ;
130 static long s_macDialogManagerVersion ;
131
132 WXHRGN m_macCursorRgn ;
133 WXHRGN m_macSleepRgn ;
134 WXHRGN m_macHelpRgn ;
135
136 virtual void MacSuspend( bool convertClipboard ) ;
137 virtual void MacResume( bool convertClipboard ) ;
fbbdb7cd
GD
138 virtual void MacConvertPrivateToPublicScrap() ;
139 virtual void MacConvertPublicToPrivateScrap() ;
cbf8aca6 140
cd28bcad
SC
141 void MacDoOneEvent() ;
142 WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
143 void MacHandleOneEvent( WXEVENTREF ev ) ;
cbf8aca6
SC
144#if !TARGET_CARBON
145 virtual void MacHandleMenuSelect( int menuid , int menuitem ) ;
146 virtual void MacHandleMouseUpEvent( WXEVENTREF ev ) ;
147 virtual void MacHandleOSEvent( WXEVENTREF ev ) ;
148 virtual void MacHandleDiskEvent( WXEVENTREF ev ) ;
149 virtual void MacHandleActivateEvent( WXEVENTREF ev ) ;
150 virtual void MacHandleUpdateEvent( WXEVENTREF ev ) ;
cbf8aca6 151 virtual void MacHandleMouseDownEvent( WXEVENTREF ev ) ;
fbbdb7cd 152
41d368a4 153 void MacHandleModifierEvents( WXEVENTREF ev ) ;
cd28bcad 154
fbbdb7cd
GD
155 virtual void MacHandleKeyDownEvent( WXEVENTREF ev ) ;
156 virtual void MacHandleKeyUpEvent( WXEVENTREF ev ) ;
fbbdb7cd 157 virtual void MacHandleHighLevelEvent( WXEVENTREF ev ) ;
fbbdb7cd 158
cd28bcad
SC
159#endif
160
d921af51
JS
161 void MacHandleMenuCommand( wxUint32 command ) ;
162 bool MacSendKeyDownEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ;
163 bool MacSendKeyUpEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ;
164
fbbdb7cd
GD
165 virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
166 virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
167 virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
168 virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
169
2072fbbb 170 // in response of an open-document apple event
d921af51 171 virtual void MacOpenFile(const wxString &fileName) ;
2072fbbb 172 // in response of a print-document apple event
d921af51 173 virtual void MacPrintFile(const wxString &fileName) ;
2072fbbb 174 // in response of a open-application apple event
d921af51 175 virtual void MacNewFile() ;
2072fbbb 176
fbbdb7cd 177 DECLARE_EVENT_TABLE()
0dbd6262
SC
178};
179
fa15551c
SC
180class WXDLLEXPORT wxStAppResource
181{
fbbdb7cd 182public:
fa15551c
SC
183 wxStAppResource() ;
184 ~wxStAppResource() ;
fbbdb7cd
GD
185
186 // opaque pointer for CFragInitBlock
187 static void OpenSharedLibraryResource(const void *) ;
188 static void CloseSharedLibraryResource() ;
189
190private:
191 short m_currentRefNum ;
fa15551c
SC
192} ;
193
0dbd6262
SC
194#endif
195 // _WX_APP_H_
196