]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/mac/app.h
disable use of #pragma interface under Mac OS X
[wxWidgets.git] / include / wx / mac / app.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: app.h
3// Purpose: wxApp class
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_APP_H_
13#define _WX_APP_H_
14
15#if defined(__GNUG__) && !defined(__APPLE__)
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;
25class WXDLLEXPORT wxWindowMac;
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
43class WXDLLEXPORT wxApp: public wxAppBase
44{
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() ;
55 virtual bool Yield(bool onlyIfNeeded = FALSE);
56 virtual bool ProcessIdle();
57
58 virtual void SetPrintMode(int mode) { m_printMode = mode; }
59 virtual int GetPrintMode() const { return m_printMode; }
60
61 // implementation only
62 void OnIdle(wxIdleEvent& event);
63 void OnEndSession(wxCloseEvent& event);
64 void OnQueryEndSession(wxCloseEvent& event);
65
66 // Send idle event to all top-level windows.
67 // Returns TRUE if more idle time is requested.
68 bool SendIdleEvents();
69
70 // Send idle event to window and all subwindows
71 // Returns TRUE if more idle time is requested.
72 bool SendIdleEvents(wxWindowMac* win);
73
74 // Windows only, but for compatibility...
75 inline void SetAuto3D(bool flag) { m_auto3D = flag; }
76 inline bool GetAuto3D() const { return m_auto3D; }
77
78protected:
79 bool m_showOnInit;
80 int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
81 bool m_auto3D ; // Always use 3D controls, except
82 // where overriden
83public:
84
85 // Implementation
86 static bool Initialize();
87 static void CleanUp();
88
89 virtual bool OnInit();
90 void DeletePendingObjects();
91 bool IsExiting() { return !m_keepGoing ; }
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 WXEVENTREF m_macCurrentEvent ;
100
101 int m_nCmdShow;
102
103protected:
104 bool m_keepGoing ;
105
106 // mac specifics
107
108public:
109 static bool s_macDefaultEncodingIsPC ;
110 static bool s_macSupportPCMenuShortcuts ;
111 static long s_macAboutMenuItemId ;
112 static wxString s_macHelpMenuTitleName ;
113
114 static bool s_macHasAppearance ;
115 static long s_macAppearanceVersion ;
116 static bool s_macHasNavigation ;
117 static bool s_macNavigationVersion ;
118 static bool s_macHasWindowManager ;
119 static long s_macWindowManagerVersion ;
120 static bool s_macHasMenuManager ;
121 static long s_macMenuManagerVersion ;
122 static bool s_macHasDialogManager ;
123 static long s_macDialogManagerVersion ;
124
125 WXHRGN m_macCursorRgn ;
126 WXHRGN m_macSleepRgn ;
127 WXHRGN m_macHelpRgn ;
128
129 virtual void MacSuspend( bool convertClipboard ) ;
130 virtual void MacResume( bool convertClipboard ) ;
131
132 virtual void MacConvertPrivateToPublicScrap() ;
133 virtual void MacConvertPublicToPrivateScrap() ;
134
135 // event main methods
136
137 void MacDoOneEvent() ;
138 void MacHandleOneEvent( WXEVENTREF ev ) ;
139 void MacHandleModifierEvents( WXEVENTREF ev ) ;
140 WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
141
142 // primary events
143
144 virtual void MacHandleMouseDownEvent( WXEVENTREF ev ) ;
145 virtual void MacHandleMouseUpEvent( WXEVENTREF ev ) ;
146 virtual void MacHandleActivateEvent( WXEVENTREF ev ) ;
147 virtual void MacHandleUpdateEvent( WXEVENTREF ev ) ;
148 virtual void MacHandleKeyDownEvent( WXEVENTREF ev ) ;
149 virtual void MacHandleKeyUpEvent( WXEVENTREF ev ) ;
150 virtual void MacHandleDiskEvent( WXEVENTREF ev ) ;
151 virtual void MacHandleOSEvent( WXEVENTREF ev ) ;
152 virtual void MacHandleHighLevelEvent( WXEVENTREF ev ) ;
153 virtual void MacHandleMenuSelect( int menuid , int menuitem ) ;
154
155 virtual bool MacSendKeyDownEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ;
156 virtual bool MacSendKeyUpEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ;
157
158 virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
159 virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
160 virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
161 virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
162
163 // in response of an open-document apple event
164 virtual void MacOpenFile(const wxString &fileName) ;
165 // in response of a print-document apple event
166 virtual void MacPrintFile(const wxString &fileName) ;
167 // in response of a open-application apple event
168 virtual void MacNewFile() ;
169
170 DECLARE_EVENT_TABLE()
171};
172
173class WXDLLEXPORT wxStAppResource
174{
175public:
176 wxStAppResource() ;
177 ~wxStAppResource() ;
178
179 // opaque pointer for CFragInitBlock
180 static void OpenSharedLibraryResource(const void *) ;
181 static void CloseSharedLibraryResource() ;
182
183private:
184 short m_currentRefNum ;
185} ;
186
187// TODO: add platform-specific arguments
188int WXDLLEXPORT wxEntry( int argc, char *argv[] , bool enterLoop = TRUE);
189
190void wxMacConvertFromPCForControls( char * p ) ;
191
192void wxMacConvertToPC( const char *from , char *to , int len ) ;
193void wxMacConvertFromPC( const char *from , char *to , int len ) ;
194void wxMacConvertToPC( const char *from , char *to , int len ) ;
195void wxMacConvertFromPC( char * p ) ;
196void wxMacConvertFromPC( unsigned char *p ) ;
197wxString wxMacMakeMacStringFromPC( const char * p ) ;
198void wxMacConvertToPC( char * p ) ;
199void wxMacConvertToPC( unsigned char *p ) ;
200wxString wxMacMakePCStringFromMac( const char * p ) ;
201
202// converts this string into a pascal with optional pc 2 mac encoding
203void wxMacStringToPascal( const char * from , unsigned char* to , bool pc2macEncoding ) ;
204
205// converts this string into a pascal with pc 2 mac encoding if s_macDefaultEncodingIsPC
206inline void wxMacStringToPascal( const char * from , unsigned char* to )
207 { wxMacStringToPascal( from , to , wxApp::s_macDefaultEncodingIsPC ) ; }
208
209// converts this string into a pascal with optional mac 2 pc encoding
210wxString wxMacMakeStringFromPascal( unsigned char* from , bool mac2pcEncoding ) ;
211
212// converts this pascal string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
213inline wxString wxMacMakeStringFromPascal( unsigned char* from )
214 { return wxMacMakeStringFromPascal( from , wxApp::s_macDefaultEncodingIsPC ) ; }
215
216// converts this c string into a wxString with optional mac 2 pc encoding
217wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) ;
218
219// converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
220inline wxString wxMacMakeStringFromMacString( const char* from )
221 { return wxMacMakeStringFromMacString( from , wxApp::s_macDefaultEncodingIsPC ) ; }
222
223#endif
224 // _WX_APP_H_
225