1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxApp class
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "app.h"
20 #include "wx/object.h"
21 #include "wx/gdicmn.h"
24 class WXDLLEXPORT wxFrame
;
25 class WXDLLEXPORT wxWindowMac
;
26 class WXDLLEXPORT wxApp
;
27 class WXDLLEXPORT wxKeyEvent
;
28 class WXDLLEXPORT wxLog
;
30 #define wxPRINT_WINDOWS 1
31 #define wxPRINT_POSTSCRIPT 2
33 WXDLLEXPORT_DATA(extern wxApp
*) wxTheApp
;
35 // Force an exit from main loop
36 void WXDLLEXPORT
wxExit();
38 // Yield to other apps/messages
39 bool WXDLLEXPORT
wxYield();
41 // Represents the application. Derive OnInit and declare
42 // a new App object to start application
43 class WXDLLEXPORT wxApp
: public wxAppBase
45 DECLARE_DYNAMIC_CLASS(wxApp
)
49 virtual int MainLoop();
50 virtual void ExitMainLoop();
51 virtual bool Initialized();
52 virtual bool Pending() ;
53 virtual void Dispatch() ;
55 virtual wxIcon
GetStdIcon(int which
) const;
56 virtual void SetPrintMode(int mode
) { m_printMode
= mode
; }
57 virtual int GetPrintMode() const { return m_printMode
; }
59 // implementation only
60 void OnIdle(wxIdleEvent
& event
);
61 void OnEndSession(wxCloseEvent
& event
);
62 void OnQueryEndSession(wxCloseEvent
& event
);
64 // Send idle event to all top-level windows.
65 // Returns TRUE if more idle time is requested.
66 bool SendIdleEvents();
68 // Send idle event to window and all subwindows
69 // Returns TRUE if more idle time is requested.
70 bool SendIdleEvents(wxWindowMac
* win
);
72 // Windows only, but for compatibility...
73 inline void SetAuto3D(bool flag
) { m_auto3D
= flag
; }
74 inline bool GetAuto3D() const { return m_auto3D
; }
78 int m_printMode
; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
79 bool m_auto3D
; // Always use 3D controls, except
84 static bool Initialize();
85 static void CleanUp();
87 void DeletePendingObjects();
89 bool IsExiting() { return !m_keepGoing
; }
92 static long sm_lastMessageTime
;
93 static wxWindow
* s_captureWindow
;
94 static int s_lastMouseDown
; // 0 = none , 1 = left , 2 = right
95 static RgnHandle s_macCursorRgn
;
96 EventRecord
* m_macCurrentEvent
;
106 static bool s_macDefaultEncodingIsPC
;
107 static bool s_macSupportPCMenuShortcuts
;
108 static long s_macAboutMenuItemId
;
109 static wxString s_macHelpMenuTitleName
;
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
;
122 RgnHandle m_macCursorRgn
;
123 RgnHandle m_macSleepRgn
;
124 RgnHandle m_macHelpRgn
;
126 virtual void MacSuspend( bool convertClipboard
) ;
127 virtual void MacResume( bool convertClipboard
) ;
129 virtual void MacConvertPrivateToPublicScrap() ;
130 virtual void MacConvertPublicToPrivateScrap() ;
132 // event main methods
134 void MacDoOneEvent() ;
135 void MacHandleOneEvent( EventRecord
*ev
) ;
136 EventRecord
* MacGetCurrentEvent() { return m_macCurrentEvent
; }
139 virtual void MacHandleMouseDownEvent( EventRecord
*ev
) ;
140 virtual void MacHandleMouseUpEvent( EventRecord
*ev
) ;
141 virtual void MacHandleActivateEvent( EventRecord
*ev
) ;
142 virtual void MacHandleUpdateEvent( EventRecord
*ev
) ;
143 virtual void MacHandleKeyDownEvent( EventRecord
*ev
) ;
144 virtual void MacHandleKeyUpEvent( EventRecord
*ev
) ;
145 virtual void MacHandleDiskEvent( EventRecord
*ev
) ;
146 virtual void MacHandleOSEvent( EventRecord
*ev
) ;
147 virtual void MacHandleHighLevelEvent( EventRecord
*ev
) ;
148 virtual void MacHandleMenuSelect( int menuid
, int menuitem
) ;
150 virtual OSErr
MacHandleAEODoc(const AppleEvent
*event
, AppleEvent
*reply
) ;
151 virtual OSErr
MacHandleAEPDoc(const AppleEvent
*event
, AppleEvent
*reply
) ;
152 virtual OSErr
MacHandleAEOApp(const AppleEvent
*event
, AppleEvent
*reply
) ;
153 virtual OSErr
MacHandleAEQuit(const AppleEvent
*event
, AppleEvent
*reply
) ;
155 DECLARE_EVENT_TABLE()
158 // TODO: add platform-specific arguments
159 int WXDLLEXPORT
wxEntry( int argc
, char *argv
[] , bool enterLoop
= TRUE
);
161 void wxMacConvertFromPCForControls( char * p
) ;
163 void wxMacConvertToPC( const char *from
, char *to
, int len
) ;
164 void wxMacConvertFromPC( const char *from
, char *to
, int len
) ;
165 void wxMacConvertToPC( const char *from
, char *to
, int len
) ;
166 void wxMacConvertFromPC( char * p
) ;
167 void wxMacConvertFromPC( unsigned char *p
) ;
168 wxString
wxMacMakeMacStringFromPC( const char * p
) ;
169 void wxMacConvertToPC( char * p
) ;
170 void wxMacConvertToPC( unsigned char *p
) ;
171 wxString
wxMacMakePCStringFromMac( const char * p
) ;
173 // converts this string into a pascal with optional pc 2 mac encoding
174 void wxMacStringToPascal( const char * from
, StringPtr to
, bool pc2macEncoding
) ;
176 // converts this string into a pascal with pc 2 mac encoding if s_macDefaultEncodingIsPC
177 inline void wxMacStringToPascal( const char * from
, StringPtr to
)
178 { wxMacStringToPascal( from
, to
, wxApp::s_macDefaultEncodingIsPC
) ; }
180 // converts this string into a pascal with optional mac 2 pc encoding
181 wxString
wxMacMakeStringFromPascal( StringPtr from
, bool mac2pcEncoding
) ;
183 // converts this pascal string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
184 inline wxString
wxMacMakeStringFromPascal( StringPtr from
)
185 { return wxMacMakeStringFromPascal( from
, wxApp::s_macDefaultEncodingIsPC
) ; }
187 // converts this c string into a wxString with optional mac 2 pc encoding
188 wxString
wxMacMakeStringFromMacString( const char* from
, bool mac2pcEncoding
) ;
190 // converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
191 inline wxString
wxMacMakeStringFromMacString( const char* from
)
192 { return wxMacMakeStringFromMacString( from
, wxApp::s_macDefaultEncodingIsPC
) ; }