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