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