]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/mac/app.h
Toolbar/tooltip udates
[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#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;
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
57 virtual void SetPrintMode(int mode) { m_printMode = mode; }
58 virtual int GetPrintMode() const { return m_printMode; }
59
60 // implementation only
61 void OnIdle(wxIdleEvent& event);
62 void OnEndSession(wxCloseEvent& event);
63 void OnQueryEndSession(wxCloseEvent& event);
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.
71 bool SendIdleEvents(wxWindowMac* win);
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
77protected:
78 bool m_showOnInit;
79 int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
80 bool m_auto3D ; // Always use 3D controls, except
81 // where overriden
82public:
83
84 // Implementation
85 static bool Initialize();
86 static void CleanUp();
87
88 virtual bool OnInit();
89 void DeletePendingObjects();
90 bool ProcessIdle();
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 WXEVENTREF m_macCurrentEvent ;
99
100 int m_nCmdShow;
101
102protected:
103 bool m_keepGoing ;
104
105 // mac specifics
106
107public:
108 static bool s_macDefaultEncodingIsPC ;
109 static bool s_macSupportPCMenuShortcuts ;
110 static long s_macAboutMenuItemId ;
111 static wxString s_macHelpMenuTitleName ;
112
113 static bool s_macHasAppearance ;
114 static long s_macAppearanceVersion ;
115 static bool s_macHasNavigation ;
116 static bool s_macNavigationVersion ;
117 static bool s_macHasWindowManager ;
118 static long s_macWindowManagerVersion ;
119 static bool s_macHasMenuManager ;
120 static long s_macMenuManagerVersion ;
121 static bool s_macHasDialogManager ;
122 static long s_macDialogManagerVersion ;
123
124 WXHRGN m_macCursorRgn ;
125 WXHRGN m_macSleepRgn ;
126 WXHRGN m_macHelpRgn ;
127
128 virtual void MacSuspend( bool convertClipboard ) ;
129 virtual void MacResume( bool convertClipboard ) ;
130
131 virtual void MacConvertPrivateToPublicScrap() ;
132 virtual void MacConvertPublicToPrivateScrap() ;
133
134 // event main methods
135
136 void MacDoOneEvent() ;
137 void MacHandleOneEvent( WXEVENTREF ev ) ;
138 WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
139
140 // primary events
141
142 virtual void MacHandleMouseDownEvent( WXEVENTREF ev ) ;
143 virtual void MacHandleMouseUpEvent( WXEVENTREF ev ) ;
144 virtual void MacHandleActivateEvent( WXEVENTREF ev ) ;
145 virtual void MacHandleUpdateEvent( WXEVENTREF ev ) ;
146 virtual void MacHandleKeyDownEvent( WXEVENTREF ev ) ;
147 virtual void MacHandleKeyUpEvent( WXEVENTREF ev ) ;
148 virtual void MacHandleDiskEvent( WXEVENTREF ev ) ;
149 virtual void MacHandleOSEvent( WXEVENTREF ev ) ;
150 virtual void MacHandleHighLevelEvent( WXEVENTREF ev ) ;
151 virtual void MacHandleMenuSelect( int menuid , int menuitem ) ;
152
153 virtual bool MacSendKeyDownEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ;
154 virtual bool MacSendKeyUpEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ;
155
156 virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
157 virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
158 virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
159 virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
160
161 DECLARE_EVENT_TABLE()
162};
163
164class WXDLLEXPORT wxStAppResource
165{
166public:
167 wxStAppResource() ;
168 ~wxStAppResource() ;
169
170 // opaque pointer for CFragInitBlock
171 static void OpenSharedLibraryResource(const void *) ;
172 static void CloseSharedLibraryResource() ;
173
174private:
175 short m_currentRefNum ;
176} ;
177
178// TODO: add platform-specific arguments
179int WXDLLEXPORT wxEntry( int argc, char *argv[] , bool enterLoop = TRUE);
180
181void wxMacConvertFromPCForControls( char * p ) ;
182
183void wxMacConvertToPC( const char *from , char *to , int len ) ;
184void wxMacConvertFromPC( const char *from , char *to , int len ) ;
185void wxMacConvertToPC( const char *from , char *to , int len ) ;
186void wxMacConvertFromPC( char * p ) ;
187void wxMacConvertFromPC( unsigned char *p ) ;
188wxString wxMacMakeMacStringFromPC( const char * p ) ;
189void wxMacConvertToPC( char * p ) ;
190void wxMacConvertToPC( unsigned char *p ) ;
191wxString wxMacMakePCStringFromMac( const char * p ) ;
192
193// converts this string into a pascal with optional pc 2 mac encoding
194void wxMacStringToPascal( const char * from , unsigned char* to , bool pc2macEncoding ) ;
195
196// converts this string into a pascal with pc 2 mac encoding if s_macDefaultEncodingIsPC
197inline void wxMacStringToPascal( const char * from , unsigned char* to )
198 { wxMacStringToPascal( from , to , wxApp::s_macDefaultEncodingIsPC ) ; }
199
200// converts this string into a pascal with optional mac 2 pc encoding
201wxString wxMacMakeStringFromPascal( unsigned char* from , bool mac2pcEncoding ) ;
202
203// converts this pascal string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
204inline wxString wxMacMakeStringFromPascal( unsigned char* from )
205 { return wxMacMakeStringFromPascal( from , wxApp::s_macDefaultEncodingIsPC ) ; }
206
207// converts this c string into a wxString with optional mac 2 pc encoding
208wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) ;
209
210// converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
211inline wxString wxMacMakeStringFromMacString( const char* from )
212 { return wxMacMakeStringFromMacString( from , wxApp::s_macDefaultEncodingIsPC ) ; }
213
214#endif
215 // _WX_APP_H_
216