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