]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/app.h
compilation warning (and possible bug) fix
[wxWidgets.git] / include / wx / mac / app.h
CommitLineData
0dbd6262
SC
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#ifdef __GNUG__
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
SC
44{
45 DECLARE_DYNAMIC_CLASS(wxApp)
46 wxApp();
05adb9d2 47 virtual ~wxApp() {}
0dbd6262
SC
48
49 virtual int MainLoop();
05adb9d2
SC
50 virtual void ExitMainLoop();
51 virtual bool Initialized();
0dbd6262
SC
52 virtual bool Pending() ;
53 virtual void Dispatch() ;
8461e4c2 54 virtual bool Yield(bool onlyIfNeeded = FALSE);
0dbd6262 55
05adb9d2
SC
56 virtual wxIcon GetStdIcon(int which) const;
57 virtual void SetPrintMode(int mode) { m_printMode = mode; }
58 virtual int GetPrintMode() const { return m_printMode; }
0dbd6262 59
05adb9d2
SC
60 // implementation only
61 void OnIdle(wxIdleEvent& event);
62 void OnEndSession(wxCloseEvent& event);
63 void OnQueryEndSession(wxCloseEvent& event);
0dbd6262
SC
64
65 // Send idle event to all top-level windows.
66 // Returns TRUE if more idle time is requested.
67 bool SendIdleEvents();
68
69 // Send idle event to window and all subwindows
70 // Returns TRUE if more idle time is requested.
e766c8a9 71 bool SendIdleEvents(wxWindowMac* win);
0dbd6262
SC
72
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:
0dbd6262
SC
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
84 // Implementation
85 static bool Initialize();
86 static void CleanUp();
87
88 void DeletePendingObjects();
89 bool ProcessIdle();
05adb9d2 90 bool IsExiting() { return !m_keepGoing ; }
0dbd6262
SC
91
92public:
93 static long sm_lastMessageTime;
519cb848
SC
94 static wxWindow* s_captureWindow ;
95 static int s_lastMouseDown ; // 0 = none , 1 = left , 2 = right
96 static RgnHandle s_macCursorRgn ;
97 EventRecord* m_macCurrentEvent ;
98
0dbd6262
SC
99 int m_nCmdShow;
100
101protected:
102 bool m_keepGoing ;
103
8be97d65
SC
104// mac specifics
105
106public :
519cb848
SC
107 static bool s_macDefaultEncodingIsPC ;
108 static bool s_macSupportPCMenuShortcuts ;
109 static long s_macAboutMenuItemId ;
110 static wxString s_macHelpMenuTitleName ;
111
112 static bool s_macHasAppearance ;
113 static long s_macAppearanceVersion ;
114 static bool s_macHasNavigation ;
115 static bool s_macNavigationVersion ;
116 static bool s_macHasWindowManager ;
117 static long s_macWindowManagerVersion ;
118 static bool s_macHasMenuManager ;
119 static long s_macMenuManagerVersion ;
120 static bool s_macHasDialogManager ;
121 static long s_macDialogManagerVersion ;
122
123 RgnHandle m_macCursorRgn ;
124 RgnHandle m_macSleepRgn ;
125 RgnHandle m_macHelpRgn ;
8be97d65 126
519cb848
SC
127 virtual void MacSuspend( bool convertClipboard ) ;
128 virtual void MacResume( bool convertClipboard ) ;
8be97d65 129
519cb848
SC
130 virtual void MacConvertPrivateToPublicScrap() ;
131 virtual void MacConvertPublicToPrivateScrap() ;
132
133 // event main methods
134
135 void MacDoOneEvent() ;
136 void MacHandleOneEvent( EventRecord *ev ) ;
137 EventRecord* MacGetCurrentEvent() { return m_macCurrentEvent ; }
138 // primary events
8be97d65 139
519cb848
SC
140 virtual void MacHandleMouseDownEvent( EventRecord *ev ) ;
141 virtual void MacHandleMouseUpEvent( EventRecord *ev ) ;
142 virtual void MacHandleActivateEvent( EventRecord *ev ) ;
143 virtual void MacHandleUpdateEvent( EventRecord *ev ) ;
144 virtual void MacHandleKeyDownEvent( EventRecord *ev ) ;
145 virtual void MacHandleKeyUpEvent( EventRecord *ev ) ;
146 virtual void MacHandleDiskEvent( EventRecord *ev ) ;
147 virtual void MacHandleOSEvent( EventRecord *ev ) ;
148 virtual void MacHandleHighLevelEvent( EventRecord *ev ) ;
149 virtual void MacHandleMenuSelect( int menuid , int menuitem ) ;
150
5b781a67
SC
151 virtual OSErr MacHandleAEODoc(const AppleEvent *event , AppleEvent *reply) ;
152 virtual OSErr MacHandleAEPDoc(const AppleEvent *event , AppleEvent *reply) ;
153 virtual OSErr MacHandleAEOApp(const AppleEvent *event , AppleEvent *reply) ;
154 virtual OSErr MacHandleAEQuit(const AppleEvent *event , AppleEvent *reply) ;
8be97d65 155
0dbd6262
SC
156DECLARE_EVENT_TABLE()
157};
158
159// TODO: add platform-specific arguments
05adb9d2 160int WXDLLEXPORT wxEntry( int argc, char *argv[] , bool enterLoop = TRUE);
0dbd6262 161
519cb848
SC
162void wxMacConvertFromPCForControls( char * p ) ;
163
164void wxMacConvertToPC( const char *from , char *to , int len ) ;
165void wxMacConvertFromPC( const char *from , char *to , int len ) ;
166void wxMacConvertToPC( const char *from , char *to , int len ) ;
167void wxMacConvertFromPC( char * p ) ;
168void wxMacConvertFromPC( unsigned char *p ) ;
169wxString wxMacMakeMacStringFromPC( const char * p ) ;
170void wxMacConvertToPC( char * p ) ;
171void wxMacConvertToPC( unsigned char *p ) ;
172wxString wxMacMakePCStringFromMac( const char * p ) ;
173
3d2791f1
SC
174// converts this string into a pascal with optional pc 2 mac encoding
175void wxMacStringToPascal( const char * from , StringPtr to , bool pc2macEncoding ) ;
176
177// converts this string into a pascal with pc 2 mac encoding if s_macDefaultEncodingIsPC
178inline void wxMacStringToPascal( const char * from , StringPtr to )
179 { wxMacStringToPascal( from , to , wxApp::s_macDefaultEncodingIsPC ) ; }
180
181// converts this string into a pascal with optional mac 2 pc encoding
182wxString wxMacMakeStringFromPascal( StringPtr from , bool mac2pcEncoding ) ;
183
184// converts this pascal string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
185inline wxString wxMacMakeStringFromPascal( StringPtr from )
186 { return wxMacMakeStringFromPascal( from , wxApp::s_macDefaultEncodingIsPC ) ; }
187
188// converts this c string into a wxString with optional mac 2 pc encoding
189wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) ;
190
191// converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
192inline wxString wxMacMakeStringFromMacString( const char* from )
193 { return wxMacMakeStringFromMacString( from , wxApp::s_macDefaultEncodingIsPC ) ; }
194
0dbd6262
SC
195#endif
196 // _WX_APP_H_
197