1999-01-01 16:05:26 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: app.h
|
|
|
|
// Purpose: wxApp class
|
2003-02-28 21:54:04 +00:00
|
|
|
// Author: Stefan Csomor
|
1999-01-01 16:05:26 +00:00
|
|
|
// Modified by:
|
2003-02-28 21:54:04 +00:00
|
|
|
// Created: 1998-01-01
|
1999-01-01 16:05:26 +00:00
|
|
|
// RCS-ID: $Id$
|
2003-02-28 21:54:04 +00:00
|
|
|
// Copyright: (c) Stefan Csomor
|
1999-01-01 16:05:26 +00:00
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_APP_H_
|
|
|
|
#define _WX_APP_H_
|
|
|
|
|
2002-08-31 11:29:13 +00:00
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
1999-01-01 16:05:26 +00:00
|
|
|
#pragma interface "app.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/gdicmn.h"
|
|
|
|
#include "wx/event.h"
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxFrame;
|
2001-07-04 20:11:26 +00:00
|
|
|
class WXDLLEXPORT wxWindowMac;
|
1999-01-01 16:05:26 +00:00
|
|
|
class WXDLLEXPORT wxApp ;
|
|
|
|
class WXDLLEXPORT wxKeyEvent;
|
|
|
|
class WXDLLEXPORT wxLog;
|
|
|
|
|
|
|
|
#define wxPRINT_WINDOWS 1
|
|
|
|
#define wxPRINT_POSTSCRIPT 2
|
|
|
|
|
|
|
|
WXDLLEXPORT_DATA(extern wxApp*) wxTheApp;
|
|
|
|
|
|
|
|
// Force an exit from main loop
|
|
|
|
void WXDLLEXPORT wxExit();
|
|
|
|
|
|
|
|
// Yield to other apps/messages
|
|
|
|
bool WXDLLEXPORT wxYield();
|
|
|
|
|
|
|
|
// Represents the application. Derive OnInit and declare
|
|
|
|
// a new App object to start application
|
2000-08-09 11:02:59 +00:00
|
|
|
class WXDLLEXPORT wxApp: public wxAppBase
|
1999-01-01 16:05:26 +00:00
|
|
|
{
|
2002-05-05 16:09:21 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxApp)
|
|
|
|
|
|
|
|
wxApp();
|
|
|
|
virtual ~wxApp() {}
|
|
|
|
|
|
|
|
virtual int MainLoop();
|
|
|
|
virtual void ExitMainLoop();
|
|
|
|
virtual bool Initialized();
|
|
|
|
virtual bool Pending() ;
|
|
|
|
virtual void Dispatch() ;
|
|
|
|
virtual bool Yield(bool onlyIfNeeded = FALSE);
|
2002-08-01 19:54:55 +00:00
|
|
|
virtual bool ProcessIdle();
|
2002-05-05 16:09:21 +00:00
|
|
|
|
|
|
|
virtual void SetPrintMode(int mode) { m_printMode = mode; }
|
|
|
|
virtual int GetPrintMode() const { return m_printMode; }
|
|
|
|
|
2003-01-28 07:01:23 +00:00
|
|
|
#if wxUSE_GUI
|
|
|
|
// setting up all MacOS Specific Event-Handlers etc
|
|
|
|
virtual bool OnInitGui();
|
|
|
|
#endif // wxUSE_GUI
|
2002-05-05 16:09:21 +00:00
|
|
|
// implementation only
|
|
|
|
void OnIdle(wxIdleEvent& event);
|
|
|
|
void OnEndSession(wxCloseEvent& event);
|
|
|
|
void OnQueryEndSession(wxCloseEvent& event);
|
|
|
|
|
|
|
|
// Send idle event to all top-level windows.
|
|
|
|
// Returns TRUE if more idle time is requested.
|
|
|
|
bool SendIdleEvents();
|
|
|
|
|
|
|
|
// Send idle event to window and all subwindows
|
|
|
|
// Returns TRUE if more idle time is requested.
|
|
|
|
bool SendIdleEvents(wxWindowMac* win);
|
|
|
|
|
|
|
|
// Windows only, but for compatibility...
|
|
|
|
inline void SetAuto3D(bool flag) { m_auto3D = flag; }
|
|
|
|
inline bool GetAuto3D() const { return m_auto3D; }
|
|
|
|
|
1999-01-01 16:05:26 +00:00
|
|
|
protected:
|
2002-05-05 16:09:21 +00:00
|
|
|
bool m_showOnInit;
|
|
|
|
int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
|
|
|
|
bool m_auto3D ; // Always use 3D controls, except
|
|
|
|
// where overriden
|
1999-01-01 16:05:26 +00:00
|
|
|
public:
|
|
|
|
|
2002-05-05 16:09:21 +00:00
|
|
|
// Implementation
|
|
|
|
static bool Initialize();
|
|
|
|
static void CleanUp();
|
|
|
|
|
|
|
|
void DeletePendingObjects();
|
|
|
|
bool IsExiting() { return !m_keepGoing ; }
|
2003-01-28 07:01:23 +00:00
|
|
|
#if TARGET_CARBON
|
|
|
|
WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; }
|
2003-01-29 14:59:28 +00:00
|
|
|
WXEVENTHANDLERREF MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef ; }
|
2003-01-28 07:01:23 +00:00
|
|
|
#endif
|
|
|
|
|
1999-01-01 16:05:26 +00:00
|
|
|
public:
|
2002-05-05 16:09:21 +00:00
|
|
|
static long sm_lastMessageTime;
|
|
|
|
static wxWindow* s_captureWindow ;
|
|
|
|
static int s_lastMouseDown ; // 0 = none , 1 = left , 2 = right
|
|
|
|
static WXHRGN s_macCursorRgn ;
|
2002-08-14 17:09:20 +00:00
|
|
|
static long s_lastModifiers ;
|
2002-05-05 16:09:21 +00:00
|
|
|
|
|
|
|
int m_nCmdShow;
|
|
|
|
|
2003-01-29 14:59:28 +00:00
|
|
|
private:
|
2002-05-05 16:09:21 +00:00
|
|
|
bool m_keepGoing ;
|
1999-11-05 09:16:09 +00:00
|
|
|
|
2002-05-05 16:09:21 +00:00
|
|
|
// mac specifics
|
2003-01-28 07:01:23 +00:00
|
|
|
#if TARGET_CARBON
|
|
|
|
WXEVENTHANDLERREF m_macEventHandler ;
|
2003-01-29 14:59:28 +00:00
|
|
|
WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef ;
|
2003-01-28 07:01:23 +00:00
|
|
|
#endif
|
2003-01-29 14:59:28 +00:00
|
|
|
WXEVENTREF m_macCurrentEvent ;
|
|
|
|
|
|
|
|
public:
|
2002-05-05 16:09:21 +00:00
|
|
|
static bool s_macDefaultEncodingIsPC ;
|
|
|
|
static bool s_macSupportPCMenuShortcuts ;
|
|
|
|
static long s_macAboutMenuItemId ;
|
2002-12-04 14:11:26 +00:00
|
|
|
static long s_macPreferencesMenuItemId ;
|
|
|
|
static long s_macExitMenuItemId ;
|
2002-05-05 16:09:21 +00:00
|
|
|
static wxString s_macHelpMenuTitleName ;
|
|
|
|
|
|
|
|
static bool s_macHasAppearance ;
|
|
|
|
static long s_macAppearanceVersion ;
|
|
|
|
static bool s_macHasNavigation ;
|
|
|
|
static bool s_macNavigationVersion ;
|
|
|
|
static bool s_macHasWindowManager ;
|
|
|
|
static long s_macWindowManagerVersion ;
|
|
|
|
static bool s_macHasMenuManager ;
|
|
|
|
static long s_macMenuManagerVersion ;
|
|
|
|
static bool s_macHasDialogManager ;
|
|
|
|
static long s_macDialogManagerVersion ;
|
|
|
|
|
|
|
|
WXHRGN m_macCursorRgn ;
|
|
|
|
WXHRGN m_macSleepRgn ;
|
|
|
|
WXHRGN m_macHelpRgn ;
|
|
|
|
|
|
|
|
virtual void MacSuspend( bool convertClipboard ) ;
|
|
|
|
virtual void MacResume( bool convertClipboard ) ;
|
|
|
|
virtual void MacConvertPrivateToPublicScrap() ;
|
|
|
|
virtual void MacConvertPublicToPrivateScrap() ;
|
2003-01-28 07:01:23 +00:00
|
|
|
|
2003-01-29 14:59:28 +00:00
|
|
|
void MacDoOneEvent() ;
|
|
|
|
WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
|
|
|
|
void MacHandleOneEvent( WXEVENTREF ev ) ;
|
2003-01-28 07:01:23 +00:00
|
|
|
#if !TARGET_CARBON
|
|
|
|
virtual void MacHandleMenuSelect( int menuid , int menuitem ) ;
|
|
|
|
virtual void MacHandleMouseUpEvent( WXEVENTREF ev ) ;
|
|
|
|
virtual void MacHandleOSEvent( WXEVENTREF ev ) ;
|
|
|
|
virtual void MacHandleDiskEvent( WXEVENTREF ev ) ;
|
|
|
|
virtual void MacHandleActivateEvent( WXEVENTREF ev ) ;
|
|
|
|
virtual void MacHandleUpdateEvent( WXEVENTREF ev ) ;
|
|
|
|
virtual void MacHandleMouseDownEvent( WXEVENTREF ev ) ;
|
2002-05-05 16:09:21 +00:00
|
|
|
|
2002-08-14 17:09:20 +00:00
|
|
|
void MacHandleModifierEvents( WXEVENTREF ev ) ;
|
2003-01-29 14:59:28 +00:00
|
|
|
|
2002-05-05 16:09:21 +00:00
|
|
|
virtual void MacHandleKeyDownEvent( WXEVENTREF ev ) ;
|
|
|
|
virtual void MacHandleKeyUpEvent( WXEVENTREF ev ) ;
|
|
|
|
virtual void MacHandleHighLevelEvent( WXEVENTREF ev ) ;
|
|
|
|
|
2003-01-29 14:59:28 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void MacHandleMenuCommand( wxUint32 command ) ;
|
|
|
|
bool MacSendKeyDownEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ;
|
|
|
|
bool MacSendKeyUpEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ;
|
2002-06-21 16:01:18 +00:00
|
|
|
|
2002-05-05 16:09:21 +00:00
|
|
|
virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
|
|
|
|
virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
|
|
|
|
virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
|
|
|
|
virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
|
|
|
|
|
2002-08-24 22:04:04 +00:00
|
|
|
// in response of an open-document apple event
|
|
|
|
virtual void MacOpenFile(const wxString &fileName) ;
|
|
|
|
// in response of a print-document apple event
|
|
|
|
virtual void MacPrintFile(const wxString &fileName) ;
|
|
|
|
// in response of a open-application apple event
|
|
|
|
virtual void MacNewFile() ;
|
|
|
|
|
2002-05-05 16:09:21 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
1999-01-01 16:05:26 +00:00
|
|
|
};
|
|
|
|
|
2002-01-20 16:14:11 +00:00
|
|
|
class WXDLLEXPORT wxStAppResource
|
|
|
|
{
|
2002-05-05 16:09:21 +00:00
|
|
|
public:
|
2002-01-20 16:14:11 +00:00
|
|
|
wxStAppResource() ;
|
|
|
|
~wxStAppResource() ;
|
2002-05-05 16:09:21 +00:00
|
|
|
|
|
|
|
// opaque pointer for CFragInitBlock
|
|
|
|
static void OpenSharedLibraryResource(const void *) ;
|
|
|
|
static void CloseSharedLibraryResource() ;
|
|
|
|
|
|
|
|
private:
|
|
|
|
short m_currentRefNum ;
|
2002-01-20 16:14:11 +00:00
|
|
|
} ;
|
|
|
|
|
1999-01-01 16:05:26 +00:00
|
|
|
// TODO: add platform-specific arguments
|
2002-09-02 19:17:52 +00:00
|
|
|
#ifndef __DARWIN__
|
2000-08-09 11:02:59 +00:00
|
|
|
int WXDLLEXPORT wxEntry( int argc, char *argv[] , bool enterLoop = TRUE);
|
2002-09-02 19:17:52 +00:00
|
|
|
#endif
|
1999-01-01 16:05:26 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
// _WX_APP_H_
|
|
|
|
|