]> git.saurik.com Git - wxWidgets.git/blame - include/wx/osx/app.h
Don't create multiple parent-less top level frames in layout sample.
[wxWidgets.git] / include / wx / osx / app.h
CommitLineData
6762286d 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: wx/osx/app.h
6762286d
SC
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
20class WXDLLIMPEXP_FWD_CORE wxFrame;
21class WXDLLIMPEXP_FWD_CORE wxWindowMac;
22class WXDLLIMPEXP_FWD_CORE wxApp ;
23class WXDLLIMPEXP_FWD_CORE wxKeyEvent;
24class WXDLLIMPEXP_FWD_BASE wxLog;
32e806fe 25class WXDLLIMPEXP_FWD_CORE wxMacAutoreleasePool;
6762286d
SC
26
27// Force an exit from main loop
28void WXDLLIMPEXP_CORE wxExit();
29
30// Yield to other apps/messages
31bool WXDLLIMPEXP_CORE wxYield();
32
33// Represents the application. Derive OnInit and declare
34// a new App object to start application
35class WXDLLIMPEXP_CORE wxApp: public wxAppBase
36{
37 DECLARE_DYNAMIC_CLASS(wxApp)
38
39 wxApp();
32e806fe 40 virtual ~wxApp();
6762286d 41
6762286d
SC
42 virtual void WakeUpIdle();
43
44 virtual void SetPrintMode(int mode) { m_printMode = mode; }
45 virtual int GetPrintMode() const { return m_printMode; }
46
47 // calling OnInit with an auto-release pool ready ...
48 virtual bool CallOnInit();
49#if wxUSE_GUI
50 // setting up all MacOS Specific Event-Handlers etc
51 virtual bool OnInitGui();
52#endif // wxUSE_GUI
53
cf4ce62c 54 virtual int OnRun();
cf4ce62c 55
6762286d
SC
56 virtual bool ProcessIdle();
57
58 // implementation only
59 void OnIdle(wxIdleEvent& event);
60 void OnEndSession(wxCloseEvent& event);
61 void OnQueryEndSession(wxCloseEvent& event);
62
63protected:
64 int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
32e806fe 65 wxMacAutoreleasePool* m_macPool;
6762286d
SC
66
67public:
68
69 static bool sm_isEmbedded;
70 // Implementation
71 virtual bool Initialize(int& argc, wxChar **argv);
72 virtual void CleanUp();
73
74 // the installed application event handler
75 WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; }
76 WXEVENTHANDLERREF MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef ; }
77 void MacSetCurrentEvent( WXEVENTREF event , WXEVENTHANDLERCALLREF handler )
78 { m_macCurrentEvent = event ; m_macCurrentEventHandlerCallRef = handler ; }
79
80 // adding a CFType object to be released only at the end of the current event cycle (increases the
81 // refcount of the object passed), needed in case we are in the middle of an event concering an object
82 // we want to delete and cannot do it immediately
83 // TODO change semantics to be in line with cocoa (make autrelease NOT increase the count)
84 void MacAddToAutorelease( void* cfrefobj );
32e806fe 85 void MacReleaseAutoreleasePool();
395506ea 86
6762286d
SC
87public:
88 static wxWindow* s_captureWindow ;
89 static long s_lastModifiers ;
90
91 int m_nCmdShow;
92
6762286d 93 // mac specifics
395506ea
SC
94protected:
95#if wxOSX_USE_COCOA
96 // override for support of custom app controllers
97 virtual WX_NSObject OSXCreateAppController();
98#endif
99
100private:
6762286d 101 virtual bool DoInitGui();
d48b06bd 102 virtual void DoCleanUp();
6762286d
SC
103
104 WXEVENTHANDLERREF m_macEventHandler ;
105 WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef ;
106 WXEVENTREF m_macCurrentEvent ;
6762286d
SC
107
108public:
109 static long s_macAboutMenuItemId ;
110 static long s_macPreferencesMenuItemId ;
111 static long s_macExitMenuItemId ;
112 static wxString s_macHelpMenuTitleName ;
113
114 WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
115
116 // For embedded use. By default does nothing.
117 virtual void MacHandleUnhandledEvent( WXEVENTREF ev );
118
2f7baaec
VZ
119 bool MacSendKeyDownEvent( wxWindow* focus , long keyval , long modifiers , long when , wxChar uniChar ) ;
120 bool MacSendKeyUpEvent( wxWindow* focus , long keyval , long modifiers , long when , wxChar uniChar ) ;
121 bool MacSendCharEvent( wxWindow* focus , long keymessage , long modifiers , long when , wxChar uniChar ) ;
122 void MacCreateKeyEvent( wxKeyEvent& event, wxWindow* focus , long keymessage , long modifiers , long when , wxChar uniChar ) ;
6762286d
SC
123#if wxOSX_USE_CARBON
124 // we only have applescript on these
125 virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
126 virtual short MacHandleAEGURL(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
127 virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
128 virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
129 virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
130 virtual short MacHandleAERApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
5c6eb3a8 131#endif
ee7553e9
DS
132 // in response of an openFiles message with Cocoa and an
133 // open-document apple event with Carbon
134 virtual void MacOpenFiles(const wxArrayString &fileNames) ;
135 // called by MacOpenFiles for each file.
6762286d
SC
136 virtual void MacOpenFile(const wxString &fileName) ;
137 // in response of a get-url apple event
138 virtual void MacOpenURL(const wxString &url) ;
139 // in response of a print-document apple event
140 virtual void MacPrintFile(const wxString &fileName) ;
141 // in response of a open-application apple event
142 virtual void MacNewFile() ;
143 // in response of a reopen-application apple event
144 virtual void MacReopenApp() ;
145
146 // Hide the application windows the same as the system hide command would do it.
147 void MacHideApp();
148
149 DECLARE_EVENT_TABLE()
150};
151
152#endif
153 // _WX_APP_H_
154