]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/app.h
replacing old core graphics with new graphics context implementation
[wxWidgets.git] / include / wx / mac / carbon / app.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: app.h
3 // Purpose: wxApp class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_APP_H_
13 #define _WX_APP_H_
14
15 #include "wx/defs.h"
16 #include "wx/object.h"
17 #include "wx/gdicmn.h"
18 #include "wx/event.h"
19
20 #ifdef __WXMAC_OSX__
21 typedef struct __CFRunLoopSource * CFRunLoopSourceRef;
22 #endif
23
24 class WXDLLEXPORT wxFrame;
25 class WXDLLEXPORT wxWindowMac;
26 class WXDLLEXPORT wxApp ;
27 class WXDLLEXPORT wxKeyEvent;
28 class WXDLLEXPORT wxLog;
29
30 // Force an exit from main loop
31 void WXDLLEXPORT wxExit();
32
33 // Yield to other apps/messages
34 bool WXDLLEXPORT wxYield();
35
36 // Represents the application. Derive OnInit and declare
37 // a new App object to start application
38 class WXDLLEXPORT wxApp: public wxAppBase
39 {
40 DECLARE_DYNAMIC_CLASS(wxApp)
41
42 wxApp();
43 virtual ~wxApp() {}
44
45 virtual bool Yield(bool onlyIfNeeded = FALSE);
46 virtual void WakeUpIdle();
47
48 virtual void SetPrintMode(int mode) { m_printMode = mode; }
49 virtual int GetPrintMode() const { return m_printMode; }
50
51 #if wxUSE_GUI
52 // setting up all MacOS Specific Event-Handlers etc
53 virtual bool OnInitGui();
54 #endif // wxUSE_GUI
55 // implementation only
56 void OnIdle(wxIdleEvent& event);
57 void OnEndSession(wxCloseEvent& event);
58 void OnQueryEndSession(wxCloseEvent& event);
59
60 void MacDoOneEvent() ;
61
62 protected:
63 int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
64
65 public:
66
67 static bool sm_isEmbedded;
68 // Implementation
69 virtual bool Initialize(int& argc, wxChar **argv);
70 virtual void CleanUp();
71
72 // the installed application event handler
73 WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; }
74 WXEVENTHANDLERREF MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef ; }
75 void MacSetCurrentEvent( WXEVENTREF event , WXEVENTHANDLERCALLREF handler )
76 { m_macCurrentEvent = event ; m_macCurrentEventHandlerCallRef = handler ; }
77
78 public:
79 static wxWindow* s_captureWindow ;
80 static long s_lastModifiers ;
81
82 int m_nCmdShow;
83
84 private:
85 // mac specifics
86
87 WXEVENTHANDLERREF m_macEventHandler ;
88 WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef ;
89 WXEVENTREF m_macCurrentEvent ;
90 #ifdef __WXMAC_OSX__
91 CFRunLoopSourceRef m_macEventPosted ;
92 #endif
93
94 public:
95 static long s_macAboutMenuItemId ;
96 static long s_macPreferencesMenuItemId ;
97 static long s_macExitMenuItemId ;
98 static wxString s_macHelpMenuTitleName ;
99
100 WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
101 void MacHandleOneEvent( WXEVENTREF ev ) ;
102
103 // For embedded use. By default does nothing.
104 virtual void MacHandleUnhandledEvent( WXEVENTREF ev );
105
106 bool MacSendKeyDownEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey , wxChar uniChar ) ;
107 bool MacSendKeyUpEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey , wxChar uniChar ) ;
108 bool MacSendCharEvent( wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey , wxChar uniChar ) ;
109 void MacCreateKeyEvent( wxKeyEvent& event, wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey , wxChar uniChar ) ;
110 virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
111 virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
112 virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
113 virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
114 virtual short MacHandleAERApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
115
116 // in response of an open-document apple event
117 virtual void MacOpenFile(const wxString &fileName) ;
118 // in response of a print-document apple event
119 virtual void MacPrintFile(const wxString &fileName) ;
120 // in response of a open-application apple event
121 virtual void MacNewFile() ;
122 // in response of a reopen-application apple event
123 virtual void MacReopenApp() ;
124
125 DECLARE_EVENT_TABLE()
126 };
127
128 #endif
129 // _WX_APP_H_
130