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
)
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
);
57 virtual void SetPrintMode(int mode
) { m_printMode
= mode
; }
58 virtual int GetPrintMode() const { return m_printMode
; }
60 // implementation only
61 void OnIdle(wxIdleEvent
& event
);
62 void OnEndSession(wxCloseEvent
& event
);
63 void OnQueryEndSession(wxCloseEvent
& event
);
65 // Send idle event to all top-level windows.
66 // Returns TRUE if more idle time is requested.
67 bool SendIdleEvents();
69 // Send idle event to window and all subwindows
70 // Returns TRUE if more idle time is requested.
71 bool SendIdleEvents(wxWindowMac
* win
);
73 // Windows only, but for compatibility...
74 inline void SetAuto3D(bool flag
) { m_auto3D
= flag
; }
75 inline bool GetAuto3D() const { return m_auto3D
; }
79 int m_printMode
; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
80 bool m_auto3D
; // Always use 3D controls, except
85 static bool Initialize();
86 static void CleanUp();
88 void DeletePendingObjects();
90 bool IsExiting() { return !m_keepGoing
; }
93 static long sm_lastMessageTime
;
94 static wxWindow
* s_captureWindow
;
95 static int s_lastMouseDown
; // 0 = none , 1 = left , 2 = right
96 static WXHRGN s_macCursorRgn
;
97 WXEVENTREF m_macCurrentEvent
;
107 static bool s_macDefaultEncodingIsPC
;
108 static bool s_macSupportPCMenuShortcuts
;
109 static long s_macAboutMenuItemId
;
110 static wxString s_macHelpMenuTitleName
;
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
;
123 WXHRGN m_macCursorRgn
;
124 WXHRGN m_macSleepRgn
;
125 WXHRGN m_macHelpRgn
;
127 virtual void MacSuspend( bool convertClipboard
) ;
128 virtual void MacResume( bool convertClipboard
) ;
130 virtual void MacConvertPrivateToPublicScrap() ;
131 virtual void MacConvertPublicToPrivateScrap() ;
133 // event main methods
135 void MacDoOneEvent() ;
136 void MacHandleOneEvent( WXEVENTREF ev
) ;
137 WXEVENTREF
MacGetCurrentEvent() { return m_macCurrentEvent
; }
141 virtual void MacHandleMouseDownEvent( WXEVENTREF ev
) ;
142 virtual void MacHandleMouseUpEvent( WXEVENTREF ev
) ;
143 virtual void MacHandleActivateEvent( WXEVENTREF ev
) ;
144 virtual void MacHandleUpdateEvent( WXEVENTREF ev
) ;
145 virtual void MacHandleKeyDownEvent( WXEVENTREF ev
) ;
146 virtual void MacHandleKeyUpEvent( WXEVENTREF ev
) ;
147 virtual void MacHandleDiskEvent( WXEVENTREF ev
) ;
148 virtual void MacHandleOSEvent( WXEVENTREF ev
) ;
149 virtual void MacHandleHighLevelEvent( WXEVENTREF ev
) ;
150 virtual void MacHandleMenuSelect( int menuid
, int menuitem
) ;
152 virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
153 virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
154 virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
155 virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
157 DECLARE_EVENT_TABLE()
160 class WXDLLEXPORT wxStAppResource
166 // opaque pointer for CFragInitBlock
167 static void OpenSharedLibraryResource(const void *) ;
168 static void CloseSharedLibraryResource() ;
171 short m_currentRefNum
;
174 // TODO: add platform-specific arguments
175 int WXDLLEXPORT
wxEntry( int argc
, char *argv
[] , bool enterLoop
= TRUE
);
177 void wxMacConvertFromPCForControls( char * p
) ;
179 void wxMacConvertToPC( const char *from
, char *to
, int len
) ;
180 void wxMacConvertFromPC( const char *from
, char *to
, int len
) ;
181 void wxMacConvertToPC( const char *from
, char *to
, int len
) ;
182 void wxMacConvertFromPC( char * p
) ;
183 void wxMacConvertFromPC( unsigned char *p
) ;
184 wxString
wxMacMakeMacStringFromPC( const char * p
) ;
185 void wxMacConvertToPC( char * p
) ;
186 void wxMacConvertToPC( unsigned char *p
) ;
187 wxString
wxMacMakePCStringFromMac( const char * p
) ;
189 // converts this string into a pascal with optional pc 2 mac encoding
190 void wxMacStringToPascal( const char * from
, unsigned char* to
, bool pc2macEncoding
) ;
192 // converts this string into a pascal with pc 2 mac encoding if s_macDefaultEncodingIsPC
193 inline void wxMacStringToPascal( const char * from
, unsigned char* to
)
194 { wxMacStringToPascal( from
, to
, wxApp::s_macDefaultEncodingIsPC
) ; }
196 // converts this string into a pascal with optional mac 2 pc encoding
197 wxString
wxMacMakeStringFromPascal( unsigned char* from
, bool mac2pcEncoding
) ;
199 // converts this pascal string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
200 inline wxString
wxMacMakeStringFromPascal( unsigned char* from
)
201 { return wxMacMakeStringFromPascal( from
, wxApp::s_macDefaultEncodingIsPC
) ; }
203 // converts this c string into a wxString with optional mac 2 pc encoding
204 wxString
wxMacMakeStringFromMacString( const char* from
, bool mac2pcEncoding
) ;
206 // converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
207 inline wxString
wxMacMakeStringFromMacString( const char* from
)
208 { return wxMacMakeStringFromMacString( from
, wxApp::s_macDefaultEncodingIsPC
) ; }