wxBase/GUI separation: 1st step, wxMSW should build, all the rest is broken

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21342 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-06-24 00:56:19 +00:00
parent 433f5675a9
commit e2478fde62
64 changed files with 7364 additions and 3583 deletions

View File

@@ -27,13 +27,10 @@
#include "wx/window.h" // for wxTopLevelWindows
#endif // wxUSE_GUI
#if WXWIN_COMPATIBILITY_2_2
#include "wx/icon.h"
#endif
#include "wx/build.h"
class WXDLLEXPORT wxApp;
class WXDLLEXPORT wxAppTraits;
class WXDLLEXPORT wxCmdLineParser;
class WXDLLEXPORT wxLog;
class WXDLLEXPORT wxMessageOutput;
@@ -49,8 +46,11 @@ typedef wxApp* (*wxAppInitializerFunction)();
// constants
// ----------------------------------------------------------------------------
static const int wxPRINT_WINDOWS = 1;
static const int wxPRINT_POSTSCRIPT = 2;
enum
{
wxPRINT_WINDOWS = 1,
wxPRINT_POSTSCRIPT = 2
};
// ----------------------------------------------------------------------------
// support for framebuffer ports
@@ -76,16 +76,222 @@ private:
unsigned m_width, m_height, m_depth;
bool m_ok;
};
#endif
#endif // wxUSE_GUI
// ----------------------------------------------------------------------------
// the common part of wxApp implementations for all platforms
// wxAppConsole: wxApp for non-GUI applications
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxAppBase : public wxEvtHandler
class WXDLLEXPORT wxAppConsole : public wxEvtHandler
{
DECLARE_NO_COPY_CLASS(wxAppBase)
public:
// ctor and dtor
wxAppConsole();
virtual ~wxAppConsole();
// the virtual functions which may/must be overridden in the derived class
// -----------------------------------------------------------------------
// Called before OnRun(), this is a good place to do initialization -- if
// anything fails, return false from here to prevent the program from
// continuing. The command line is normally parsed here, call the base
// class OnInit() to do it.
virtual bool OnInit();
// This is the replacement for the normal main(): all program work should
// be done here. When OnRun() returns, the programs starts shutting down.
virtual int OnRun() = 0;
// This is only called if OnInit() returned true so it's a good place to do
// any cleanup matching the initializations done there.
virtual int OnExit();
// Called when a fatal exception occurs, this function should take care not
// to do anything which might provoke a nested exception! It may be
// overridden if you wish to react somehow in non-default way (core dump
// under Unix, application crash under Windows) to fatal program errors,
// however extreme care should be taken if you don't want this function to
// crash.
virtual void OnFatalException() { }
// Called from wxExit() function, should terminate the application a.s.a.p.
virtual void Exit();
// application info: name, description, vendor
// -------------------------------------------
// NB: all these should be set by the application itself, there are no
// reasonable default except for the application name which is taken to
// be argv[0]
// set/get the application name
wxString GetAppName() const
{
return m_appName.empty() ? m_className : m_appName;
}
void SetAppName(const wxString& name) { m_appName = name; }
// set/get the app class name
wxString GetClassName() const { return m_className; }
void SetClassName(const wxString& name) { m_className = name; }
// set/get the vendor name
const wxString& GetVendorName() const { return m_vendorName; }
void SetVendorName(const wxString& name) { m_vendorName = name; }
// cmd line parsing stuff
// ----------------------
// all of these methods may be overridden in the derived class to
// customize the command line parsing (by default only a few standard
// options are handled)
//
// you also need to call wxApp::OnInit() from YourApp::OnInit() for all
// this to work
#if wxUSE_CMDLINE_PARSER
// this one is called from OnInit() to add all supported options
// to the given parser
virtual void OnInitCmdLine(wxCmdLineParser& parser);
// called after successfully parsing the command line, return TRUE
// to continue and FALSE to exit
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
// called if "--help" option was specified, return TRUE to continue
// and FALSE to exit
virtual bool OnCmdLineHelp(wxCmdLineParser& parser);
// called if incorrect command line options were given, return
// FALSE to abort and TRUE to continue
virtual bool OnCmdLineError(wxCmdLineParser& parser);
#endif // wxUSE_CMDLINE_PARSER
// miscellaneous customization functions
// -------------------------------------
// create the app traits object to which we delegate for everything which
// either should be configurable by the user (then he can change the
// default behaviour simply by overriding CreateTraits() and returning his
// own traits object) or which is GUI/console dependent as then wxAppTraits
// allows us to abstract the differences behind the common fa<66>ade
wxAppTraits *GetTraits();
// the functions below shouldn't be used now that we have wxAppTraits
#if WXWIN_COMPATIBILITY_2_4
#if wxUSE_LOG
// override this function to create default log target of arbitrary
// user-defined class (default implementation creates a wxLogGui
// object) -- this log object is used by default by all wxLogXXX()
// functions.
virtual wxLog *CreateLogTarget();
#endif // wxUSE_LOG
// similar to CreateLogTarget() but for the global wxMessageOutput
// object
virtual wxMessageOutput *CreateMessageOutput();
#endif // WXWIN_COMPATIBILITY_2_4
// event processing functions
// --------------------------
// this method allows to filter all the events processed by the program, so
// you should try to return quickly from it to avoid slowing down the
// program to the crawl
//
// return value should be -1 to continue with the normal event processing,
// or TRUE or FALSE to stop further processing and pretend that the event
// had been already processed or won't be processed at all, respectively
virtual int FilterEvent(wxEvent& event);
// process all events in the wxPendingEvents list -- it is necessary to
// call this function to process posted events. This happens during each
// event loop iteration in GUI mode but if there is no main loop, it may be
// also called directly.
virtual void ProcessPendingEvents();
// doesn't do anything in this class, just a hook for GUI wxApp
virtual bool Yield(bool WXUNUSED(onlyIfNeeded) = false) { return true; }
// make sure that idle events are sent again
virtual void WakeUpIdle() { }
// debugging support
// -----------------
// this function is called when an assert failure occurs, the base class
// version does the normal processing (i.e. shows the usual assert failure
// dialog box)
//
// the arguments are the place where the assert occured, the text of the
// assert itself and the user-specified message
#ifdef __WXDEBUG__
virtual void OnAssert(const wxChar *file,
int line,
const wxChar *cond,
const wxChar *msg);
#endif // __WXDEBUG__
// check that the wxBuildOptions object (constructed in the application
// itself, usually the one from IMPLEMENT_APP() macro) matches the build
// options of the library and abort if it doesn't
static bool CheckBuildOptions(const wxBuildOptions& buildOptions);
// implementation only from now on
// -------------------------------
// helpers for dynamic wxApp construction
static void SetInitializerFunction(wxAppInitializerFunction fn)
{ ms_appInitFn = fn; }
static wxAppInitializerFunction GetInitializerFunction()
{ return ms_appInitFn; }
// command line arguments (public for backwards compatibility)
int argc;
wxChar **argv;
protected:
// the function which creates the traits object when GetTraits() needs it
// for the first time
virtual wxAppTraits *CreateTraits();
// function used for dynamic wxApp creation
static wxAppInitializerFunction ms_appInitFn;
// application info (must be set from the user code)
wxString m_vendorName, // vendor name (ACME Inc)
m_appName, // app name
m_className; // class name
// the class defining the application behaviour, NULL initially and created
// by GetTraits() when first needed
wxAppTraits *m_traits;
// the application object is a singleton anyhow, there is no sense in
// copying it
DECLARE_NO_COPY_CLASS(wxAppConsole)
};
// ----------------------------------------------------------------------------
// wxAppBase: the common part of wxApp implementations for all platforms
// ----------------------------------------------------------------------------
#if wxUSE_GUI
class WXDLLEXPORT wxAppBase : public wxAppConsole
{
public:
wxAppBase();
virtual ~wxAppBase();
@@ -93,20 +299,11 @@ public:
// the virtual functions which may/must be overridden in the derived class
// -----------------------------------------------------------------------
// called during the program initialization, returning FALSE from here
// prevents the program from continuing - it's a good place to create
// the top level program window and return TRUE.
//
// Override: always in GUI application, rarely in console ones.
virtual bool OnInit();
#if wxUSE_GUI
// a platform-dependent version of OnInit(): the code here is likely to
// depend on the toolkit. default version does nothing.
//
// Override: rarely.
virtual bool OnInitGui();
#endif // wxUSE_GUI
// called to start program execution - the default version just enters
// the main GUI loop in which events are received and processed until
@@ -115,34 +312,15 @@ public:
// of the program really starts here
//
// Override: rarely in GUI applications, always in console ones.
#if wxUSE_GUI
virtual int OnRun();
#else // !GUI
virtual int OnRun() = 0;
#endif // wxUSE_GUI
// called after the main loop termination. This is a good place for
// cleaning up (it may be too late in dtor) and is also useful if you
// want to return some non-default exit code - this is just the return
// value of this method.
//
// Override: often.
virtual int OnExit();
// exit the main loop thus terminating the application
virtual void Exit();
// called when a fatal exception occurs, this function should take care
// not to do anything which might provoke a nested exception! It may be
// overridden if you wish to react somehow in non-default way (core
// dump under Unix, application crash under Windows) to fatal program
// errors, however extreme care should be taken if you don't want this
// function to crash.
//
// Override: rarely.
virtual void OnFatalException() { }
// the worker functions - usually not used directly by the user code
// -----------------------------------------------------------------
#if wxUSE_GUI
// execute the main GUI loop, the function returns when the loop ends
virtual int MainLoop() = 0;
@@ -177,34 +355,8 @@ public:
//
// it should return TRUE if more idle events are needed, FALSE if not
virtual bool ProcessIdle() = 0;
#endif // wxUSE_GUI
// application info: name, description, vendor
// -------------------------------------------
// NB: all these should be set by the application itself, there are no
// reasonable default except for the application name which is taken to
// be argv[0]
// set/get the application name
wxString GetAppName() const
{
if ( !m_appName )
return m_className;
else
return m_appName;
}
void SetAppName(const wxString& name) { m_appName = name; }
// set/get the app class name
wxString GetClassName() const { return m_className; }
void SetClassName(const wxString& name) { m_className = name; }
// set/get the vendor name
const wxString& GetVendorName() const { return m_vendorName; }
void SetVendorName(const wxString& name) { m_vendorName = name; }
#if wxUSE_GUI
// top level window functions
// --------------------------
@@ -237,65 +389,16 @@ public:
bool GetExitOnFrameDelete() const
{ return m_exitOnFrameDelete == Yes; }
#endif // wxUSE_GUI
// cmd line parsing stuff
// ----------------------
// display mode, visual, printing mode, ...
// ------------------------------------------------------------------------
// all of these methods may be overridden in the derived class to
// customize the command line parsing (by default only a few standard
// options are handled)
//
// you also need to call wxApp::OnInit() from YourApp::OnInit() for all
// this to work
#if wxUSE_CMDLINE_PARSER
// this one is called from OnInit() to add all supported options
// to the given parser
virtual void OnInitCmdLine(wxCmdLineParser& parser);
// called after successfully parsing the command line, return TRUE
// to continue and FALSE to exit
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
// called if "--help" option was specified, return TRUE to continue
// and FALSE to exit
virtual bool OnCmdLineHelp(wxCmdLineParser& parser);
// called if incorrect command line options were given, return
// FALSE to abort and TRUE to continue
virtual bool OnCmdLineError(wxCmdLineParser& parser);
#endif // wxUSE_CMDLINE_PARSER
// miscellaneous customization functions
// -------------------------------------
#if wxUSE_LOG
// override this function to create default log target of arbitrary
// user-defined class (default implementation creates a wxLogGui
// object) - this log object is used by default by all wxLogXXX()
// functions.
virtual wxLog *CreateLogTarget();
#endif // wxUSE_LOG
// similar to CreateLogTarget() but for the global wxMessageOutput
// object
virtual wxMessageOutput *CreateMessageOutput();
#if wxUSE_GUI
#if WXWIN_COMPATIBILITY_2_2
// get the standard icon used by wxWin dialogs - this allows the user
// to customize the standard dialogs. The 'which' parameter is one of
// wxICON_XXX values
virtual wxIcon GetStdIcon(int WXUNUSED(which)) const { return wxNullIcon; }
#endif
// Get display mode that is used use. This is only used in framebuffer wxWin ports
// (such as wxMGL).
// Get display mode that is used use. This is only used in framebuffer
// wxWin ports (such as wxMGL).
virtual wxDisplayModeInfo GetDisplayMode() const { return wxDisplayModeInfo(); }
// Set display mode to use. This is only used in framebuffer wxWin ports
// (such as wxMGL). This method should be called from wxApp:OnInitGui
// Set display mode to use. This is only used in framebuffer wxWin
// ports (such as wxMGL). This method should be called from
// wxApp::OnInitGui
virtual bool SetDisplayMode(const wxDisplayModeInfo& WXUNUSED(info)) { return TRUE; }
// set use of best visual flag (see below)
@@ -309,81 +412,22 @@ public:
virtual void SetPrintMode(int WXUNUSED(mode)) { }
int GetPrintMode() const { return wxPRINT_POSTSCRIPT; }
// miscellaneous other stuff
// ------------------------------------------------------------------------
// called by toolkit-specific code to set the app status: active (we have
// focus) or not and also the last window which had focus before we were
// deactivated
virtual void SetActive(bool isActive, wxWindow *lastFocus);
#endif // wxUSE_GUI
// this method allows to filter all the events processed by the program, so
// you should try to return quickly from it to avoid slowing down the
// program to the crawl
//
// return value should be -1 to continue with the normal event processing,
// or TRUE or FALSE to stop further processing and pretend that the event
// had been already processed or won't be processed at all, respectively
virtual int FilterEvent(wxEvent& event);
// debugging support
// -----------------
// this function is called when an assert failure occurs, the base class
// version does the normal processing (i.e. shows the usual assert failure
// dialog box)
//
// the arguments are the place where the assert occured, the text of the
// assert itself and the user-specified message
#ifdef __WXDEBUG__
virtual void OnAssert(const wxChar *file,
int line,
const wxChar *cond,
const wxChar *msg);
#endif // __WXDEBUG__
// check that the wxBuildOptions object (constructed in the application
// itself, usually the one from IMPLEMENT_APP() macro) matches the build
// options of the library and abort if it doesn't
static bool CheckBuildOptions(const wxBuildOptions& buildOptions);
// deprecated functions, please updae your code to not use them!
// -------------------------------------------------------------
#if WXWIN_COMPATIBILITY_2_2
// used by obsolete wxDebugMsg only
void SetWantDebugOutput( bool flag ) { m_wantDebugOutput = flag; }
bool GetWantDebugOutput() const { return m_wantDebugOutput; }
// TRUE if the application wants to get debug output
bool m_wantDebugOutput;
#endif // WXWIN_COMPATIBILITY_2_2
// implementation only from now on
// -------------------------------
// helpers for dynamic wxApp construction
static void SetInitializerFunction(wxAppInitializerFunction fn)
{ m_appInitFn = fn; }
static wxAppInitializerFunction GetInitializerFunction()
{ return m_appInitFn; }
// process all events in the wxPendingEvents list
virtual void ProcessPendingEvents();
// access to the command line arguments
int argc;
wxChar **argv;
protected:
// function used for dynamic wxApp creation
static wxAppInitializerFunction m_appInitFn;
// override base class method to use GUI traits
virtual wxAppTraits *CreateTraits();
// application info (must be set from the user code)
wxString m_vendorName, // vendor name (ACME Inc)
m_appName, // app name
m_className; // class name
#if wxUSE_GUI
// the main top level window - may be NULL
// the main top level window (may be NULL)
wxWindow *m_topWindow;
// if Yes, exit the main loop when the last top level window is deleted, if
@@ -403,9 +447,13 @@ protected:
// does any of our windows has focus?
bool m_isActive;
#endif // wxUSE_GUI
DECLARE_NO_COPY_CLASS(wxAppBase)
};
#endif // wxUSE_GUI
// ----------------------------------------------------------------------------
// now include the declaration of the real class
// ----------------------------------------------------------------------------
@@ -430,7 +478,7 @@ protected:
#endif
#else // !GUI
// can't use typedef because wxApp forward declared as a class
class WXDLLEXPORT wxApp : public wxAppBase
class WXDLLEXPORT wxApp : public wxAppConsole
{
};
#endif // GUI/!GUI
@@ -461,18 +509,6 @@ extern bool WXDLLEXPORT wxYield();
// Yield to other apps/messages
extern void WXDLLEXPORT wxWakeUpIdle();
// Post a message to the given eventhandler which will be processed during the
// next event loop iteration
inline void wxPostEvent(wxEvtHandler *dest, wxEvent& event)
{
wxCHECK_RET( dest, wxT("need an object to post event to in wxPostEvent") );
#if wxUSE_GUI
dest->AddPendingEvent(event);
#else
dest->ProcessEvent(event);
#endif // wxUSE_GUI
}
// console applications may avoid using DECLARE_APP and IMPLEMENT_APP macros
// and call these functions instead at the program startup and termination

172
include/wx/apptrait.h Normal file
View File

@@ -0,0 +1,172 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/apptrait.h
// Purpose: declaration of wxAppTraits and derived classes
// Author: Vadim Zeitlin
// Modified by:
// Created: 19.06.2003
// RCS-ID: $Id$
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_APPTRAIT_H_
#define _WX_APPTRAIT_H_
class WXDLLEXPORT wxAppTraits;
#if wxUSE_FONTMAP
class WXDLLEXPORT wxFontMapper;
#endif // wxUSE_FONTMAP
class WXDLLEXPORT wxLog;
class WXDLLEXPORT wxMessageOutput;
// ----------------------------------------------------------------------------
// wxAppTraits: this class defines various configurable aspects of wxApp
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxAppTraitsBase
{
public:
// wxAppTraits is an ABC, but we also provide 2 standard implementations of
// it, one for the console apps and the other for the GUI ones
static wxAppTraits *CreateConsole();
#if wxUSE_GUI
static wxAppTraits *CreateGUI();
#endif // wxUSE_GUI
// hooks for creating the global objects, may be overridden by the user
// ------------------------------------------------------------------------
#if wxUSE_LOG
// create the default log target
virtual wxLog *CreateLogTarget() = 0;
#endif // wxUSE_LOG
// create the global object used for printing out messages
virtual wxMessageOutput *CreateMessageOutput() = 0;
#if wxUSE_FONTMAP
// create the global font mapper object used for encodings/charset mapping
virtual wxFontMapper *CreateFontMapper() = 0;
#endif // wxUSE_FONTMAP
// functions abstracting differences between GUI and console modes
// ------------------------------------------------------------------------
#ifdef __WXDEBUG__
// show the assert dialog with the specified message in GUI or just print
// the string to stderr in console mode
//
// base class version has an implementation (in spite of being pure
// virtual) in base/appbase.cpp which can be called as last resort.
//
// return true to suppress subsequent asserts, false to continue as before
virtual bool ShowAssertDialog(const wxString& msg) = 0;
#endif // __WXDEBUG__
// return true if fprintf(stderr) goes somewhere, false otherwise
virtual bool HasStderr() = 0;
// managing "pending delete" list: in GUI mode we can't immediately delete
// some objects because there may be unprocessed events for them and so we
// only do it during the next idle loop iteration while this is, of course,
// unnecessary in wxBase, so we have a few functions to abstract these
// operations
// add the object to the pending delete list in GUI, delete it immediately
// in wxBase
virtual void ScheduleForDestroy(wxObject *object) = 0;
// remove this object from the pending delete list in GUI, do nothing in
// wxBase
virtual void RemoveFromPendingDelete(wxObject *object) = 0;
};
// ----------------------------------------------------------------------------
// include the platform-specific version of the class
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/apptbase.h"
#else
typedef
// wxAppTraits must be a class because it was forward declared as class
class WXDLLEXPORT wxAppTraits : public wxAppTraitsBase
{
};
#endif // platform
// ============================================================================
// standard traits for console and GUI applications
// ============================================================================
// ----------------------------------------------------------------------------
// wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
// ----------------------------------------------------------------------------
class wxConsoleAppTraitsBase : public wxAppTraits
{
public:
#if wxUSE_LOG
virtual wxLog *CreateLogTarget();
#endif // wxUSE_LOG
virtual wxMessageOutput *CreateMessageOutput();
#if wxUSE_FONTMAP
virtual wxFontMapper *CreateFontMapper();
#endif // wxUSE_FONTMAP
#ifdef __WXDEBUG__
virtual bool ShowAssertDialog(const wxString& msg);
#endif // __WXDEBUG__
virtual bool HasStderr();
virtual void ScheduleForDestroy(wxObject *object);
virtual void RemoveFromPendingDelete(wxObject *object);
};
// ----------------------------------------------------------------------------
// wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
// ----------------------------------------------------------------------------
#if wxUSE_GUI
class wxGUIAppTraitsBase : public wxAppTraits
{
public:
#if wxUSE_LOG
virtual wxLog *CreateLogTarget();
#endif // wxUSE_LOG
virtual wxMessageOutput *CreateMessageOutput();
#if wxUSE_FONTMAP
virtual wxFontMapper *CreateFontMapper();
#endif // wxUSE_FONTMAP
#ifdef __WXDEBUG__
virtual bool ShowAssertDialog(const wxString& msg);
#endif // __WXDEBUG__
virtual bool HasStderr();
virtual void ScheduleForDestroy(wxObject *object);
virtual void RemoveFromPendingDelete(wxObject *object);
};
#endif // wxUSE_GUI
// ----------------------------------------------------------------------------
// include the platform-specific version of the classes above
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/apptrait.h"
#elif defined(__UNIX__)
#include "wx/unix/apptrait.h"
#else // no platform-specific methods to add to wxAppTraits
#if wxUSE_GUI
typedef wxGUIAppTraitsBase wxGUIAppTraits;
#endif // wxUSE_GUI
typedef wxConsoleAppTraitsBase wxConsoleAppTraits;
#endif // platform
#endif // _WX_APPTRAIT_H_

View File

@@ -14,6 +14,8 @@
#include "wx/version.h"
class WXDLLEXPORT wxAppConsole;
// ----------------------------------------------------------------------------
// wxBuildOptions
// ----------------------------------------------------------------------------
@@ -48,7 +50,7 @@ private:
bool m_isDebug;
// actually only CheckBuildOptions() should be our friend but well...
friend class wxAppBase;
friend class wxAppConsole;
};
#endif // _WX_BUILD_H_

View File

@@ -50,8 +50,12 @@ public:
virtual bool Initialized();
virtual bool Pending();
virtual void Dispatch();
virtual void Exit();
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual bool ProcessIdle();
virtual bool WakeUpIdle() { CocoaRequestIdle(); }
/* Idle Processing */
void OnIdle(wxIdleEvent& event);

View File

@@ -2145,6 +2145,15 @@ private:
DECLARE_DYNAMIC_CLASS(wxEvtHandler)
};
// Post a message to the given eventhandler which will be processed during the
// next event loop iteration
inline void wxPostEvent(wxEvtHandler *dest, wxEvent& event)
{
wxCHECK_RET( dest, wxT("need an object to post event to in wxPostEvent") );
dest->AddPendingEvent(event);
}
typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
#if wxUSE_GUI
typedef void (wxEvtHandler::*wxCommandEventFunction)(wxCommandEvent&);

74
include/wx/fmappriv.h Normal file
View File

@@ -0,0 +1,74 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/fmappriv.h
// Purpose: private wxFontMapper stuff, not to be used by the library users
// Author: Vadim Zeitlin
// Modified by:
// Created: 21.06.2003 (extracted from common/fontmap.cpp)
// RCS-ID: $Id$
// Copyright: (c) 1999-2003 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FMAPPRIV_H_
#define _WX_FMAPPRIV_H_
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// a special pseudo encoding which means "don't ask me about this charset
// any more" -- we need it to avoid driving the user crazy with asking him
// time after time about the same charset which he [presumably] doesn't
// have the fonts for
enum { wxFONTENCODING_UNKNOWN = -2 };
// the config paths we use
#if wxUSE_CONFIG
#define FONTMAPPER_ROOT_PATH wxT("/wxWindows/FontMapper")
#define FONTMAPPER_CHARSET_PATH wxT("Charsets")
#define FONTMAPPER_CHARSET_ALIAS_PATH wxT("Aliases")
#endif // wxUSE_CONFIG
// ----------------------------------------------------------------------------
// wxFontMapperPathChanger: change the config path during our lifetime
// ----------------------------------------------------------------------------
#if wxUSE_CONFIG
class wxFontMapperPathChanger
{
public:
wxFontMapperPathChanger(wxFontMapperBase *fontMapper, const wxString& path)
{
m_fontMapper = fontMapper;
m_ok = m_fontMapper->ChangePath(path, &m_pathOld);
}
bool IsOk() const { return m_ok; }
~wxFontMapperPathChanger()
{
if ( IsOk() )
m_fontMapper->RestorePath(m_pathOld);
}
private:
// the fontmapper object we're working with
wxFontMapperBase *m_fontMapper;
// the old path to be restored if m_ok
wxString m_pathOld;
// have we changed the path successfully?
bool m_ok;
DECLARE_NO_COPY_CLASS(wxFontMapperPathChanger)
};
#endif // wxUSE_CONFIG
#endif // _WX_FMAPPRIV_H_

View File

@@ -32,68 +32,64 @@
class WXDLLEXPORT wxConfigBase;
#endif // wxUSE_CONFIG
class WXDLLEXPORT wxFontMapper;
#if wxUSE_GUI
class WXDLLEXPORT wxWindow;
#endif // wxUSE_GUI
// ----------------------------------------------------------------------------
// wxFontMapper manages user-definable correspondence between logical font
// names and the fonts present on the machine.
// ============================================================================
// wxFontMapper manages user-definable correspondence between wxWindows font
// encodings and the fonts present on the machine.
//
// The default implementations of all functions will ask the user if they are
// not capable of finding the answer themselves and store the answer in a
// config file (configurable via SetConfigXXX functions). This behaviour may
// be disabled by giving the value of FALSE to "interactive" parameter.
// However, the functions will always consult the config file to allow the
// user-defined values override the default logic and there is no way to
// disable this - which shouldn't be ever needed because if "interactive" was
// never TRUE, the config file is never created anyhow.
// This is a singleton class, font mapper objects can only be accessed using
// wxFontMapper::Get().
// ============================================================================
// ----------------------------------------------------------------------------
// wxFontMapperBase: this is a non-interactive class which just uses its built
// in knowledge of the encodings equivalence
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxFontMapper
class WXDLLEXPORT wxFontMapperBase
{
public:
// default ctor
wxFontMapper();
// constructtor and such
// ---------------------
// virtual dtor for a base class
virtual ~wxFontMapper();
// default ctor
wxFontMapperBase();
// virtual dtor for any base class
virtual ~wxFontMapperBase();
// return instance of the wxFontMapper singleton
static wxFontMapper *Get();
// set the sigleton to 'mapper' instance and return previous one
static wxFontMapper *Set(wxFontMapper *mapper);
#if wxUSE_GUI
// find an alternative for the given encoding (which is supposed to not be
// available on this system). If successful, return TRUE and fill info
// structure with the parameters required to create the font, otherwise
// return FALSE
virtual bool GetAltForEncoding(wxFontEncoding encoding,
wxNativeEncodingInfo *info,
const wxString& facename = wxEmptyString,
bool interactive = TRUE);
// version better suitable for 'public' use. Returns wxFontEcoding
// that can be used it wxFont ctor
bool GetAltForEncoding(wxFontEncoding encoding,
wxFontEncoding *alt_encoding,
const wxString& facename = wxEmptyString,
bool interactive = TRUE);
// checks whether given encoding is available in given face or not.
// If no facename is given,
virtual bool IsEncodingAvailable(wxFontEncoding encoding,
const wxString& facename = wxEmptyString);
#endif // wxUSE_GUI
// translates charset strings to encoding
// --------------------------------------
// returns the encoding for the given charset (in the form of RFC 2046) or
// wxFONTENCODING_SYSTEM if couldn't decode it
//
// interactive parameter is ignored in the base class, we behave as if it
// were always false
virtual wxFontEncoding CharsetToEncoding(const wxString& charset,
bool interactive = TRUE);
bool interactive = true);
// encoding names
// --------------
// information about supported encodings
// -------------------------------------
// get the number of font encodings we know about
static size_t GetSupportedEncodingsCount();
// get the n-th supported encoding
static wxFontEncoding GetEncoding(size_t n);
// return internal string identifier for the encoding (see also
// GetEncodingDescription())
@@ -104,16 +100,6 @@ public:
// NB: hard-coded now, but might change later (read it from config?)
static wxString GetEncodingDescription(wxFontEncoding encoding);
// configure the appearance of the dialogs we may popup
// ----------------------------------------------------
#if wxUSE_GUI
// the parent window for modal dialogs
void SetDialogParent(wxWindow *parent) { m_windowParent = parent; }
// the title for the dialogs (note that default is quite reasonable)
void SetDialogTitle(const wxString& title) { m_titleDialog = title; }
#endif // wxUSE_GUI
// functions which allow to configure the config object used: by default,
// the global one (from wxConfigBase::Get() will be used) and the default
@@ -130,22 +116,21 @@ public:
// return default config path
static const wxChar *GetDefaultConfigPath();
#endif
#endif // wxUSE_CONFIG
protected:
#if wxUSE_CONFIG
// get the config object we're using - if it wasn't set explicitly, this
// get the config object we're using -- if it wasn't set explicitly, this
// function will use wxConfig::Get() to get the global one
wxConfigBase *GetConfig();
// gets the root path for our settings - if itwasn't set explicitly, use
// gets the root path for our settings -- if it wasn't set explicitly, use
// GetDefaultConfigPath()
const wxString& GetConfigPath();
#endif
// change to the given (relative) path in the config, return TRUE if ok
// (then GetConfig() will return something !NULL), FALSE if no config
// change to the given (relative) path in the config, return true if ok
// (then GetConfig() will return something !NULL), false if no config
// object
//
// caller should provide a pointer to the string variable which should be
@@ -155,7 +140,87 @@ protected:
// restore the config path after use
void RestorePath(const wxString& pathOld);
// config object and path (in it) to use
wxConfigBase *m_config;
bool m_configIsDummy;
wxString m_configRootPath;
#endif // wxUSE_CONFIG
private:
// the global fontmapper object or NULL
static wxFontMapper *sm_instance;
friend class wxFontMapperPathChanger;
DECLARE_NO_COPY_CLASS(wxFontMapperBase)
};
// ----------------------------------------------------------------------------
// wxFontMapper: interactive extension of wxFontMapperBase
//
// The default implementations of all functions will ask the user if they are
// not capable of finding the answer themselves and store the answer in a
// config file (configurable via SetConfigXXX functions). This behaviour may
// be disabled by giving the value of false to "interactive" parameter.
// However, the functions will always consult the config file to allow the
// user-defined values override the default logic and there is no way to
// disable this -- which shouldn't be ever needed because if "interactive" was
// never true, the config file is never created anyhow.
// ----------------------------------------------------------------------------
#if wxUSE_GUI
class WXDLLEXPORT wxFontMapper : public wxFontMapperBase
{
public:
// default ctor
wxFontMapper();
// virtual dtor for a base class
virtual ~wxFontMapper();
// working with the encodings
// --------------------------
// returns the encoding for the given charset (in the form of RFC 2046) or
// wxFONTENCODING_SYSTEM if couldn't decode it
virtual wxFontEncoding CharsetToEncoding(const wxString& charset,
bool interactive = true);
// find an alternative for the given encoding (which is supposed to not be
// available on this system). If successful, return true and fill info
// structure with the parameters required to create the font, otherwise
// return false
virtual bool GetAltForEncoding(wxFontEncoding encoding,
wxNativeEncodingInfo *info,
const wxString& facename = wxEmptyString,
bool interactive = true);
// version better suitable for 'public' use. Returns wxFontEcoding
// that can be used it wxFont ctor
bool GetAltForEncoding(wxFontEncoding encoding,
wxFontEncoding *alt_encoding,
const wxString& facename = wxEmptyString,
bool interactive = true);
// checks whether given encoding is available in given face or not.
// If no facename is given,
virtual bool IsEncodingAvailable(wxFontEncoding encoding,
const wxString& facename = wxEmptyString);
// configure the appearance of the dialogs we may popup
// ----------------------------------------------------
// the parent window for modal dialogs
void SetDialogParent(wxWindow *parent) { m_windowParent = parent; }
// the title for the dialogs (note that default is quite reasonable)
void SetDialogTitle(const wxString& title) { m_titleDialog = title; }
protected:
// GetAltForEncoding() helper: tests for the existence of the given
// encoding and saves the result in config if ok - this results in the
// following (desired) behaviour: when an unknown/unavailable encoding is
@@ -166,38 +231,31 @@ protected:
bool TestAltEncoding(const wxString& configEntry,
wxFontEncoding encReplacement,
wxNativeEncodingInfo *info);
#endif // wxUSE_GUI
#if wxUSE_CONFIG
// config object and path (in it) to use
wxConfigBase *m_config;
bool m_configIsDummy;
#endif
wxString m_configRootPath;
#if wxUSE_GUI
// the title for our dialogs
wxString m_titleDialog;
// the parent window for our dialogs
wxWindow *m_windowParent;
#endif // wxUSE_GUI
friend class wxFontMapperPathChanger;
private:
static wxFontMapper *sm_instance;
DECLARE_NO_COPY_CLASS(wxFontMapper)
};
#else // !wxUSE_GUI
class WXDLLEXPORT wxFontMapper : public wxFontMapperBase
{
};
#endif // wxUSE_GUI/!wxUSE_GUI
// ----------------------------------------------------------------------------
// global variables
// ----------------------------------------------------------------------------
// the default font mapper for wxWindows programs
// do NOT use! This is for backward compatibility, use wxFontMapper::Get() instead
// the default font mapper for wxWindows programs do NOT use! This is for
// backward compatibility, use wxFontMapper::Get() instead
#define wxTheFontMapper (wxFontMapper::Get())
#else // !wxUSE_FONTMAP
@@ -210,3 +268,4 @@ private:
#endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
#endif // _WX_FONTMAPPER_H_

View File

@@ -23,47 +23,49 @@
#include "wx/filesys.h"
#if wxUSE_GUI
#include "wx/image.h"
#include "wx/bitmap.h"
#endif
class WXDLLEXPORT wxBitmap;
class WXDLLEXPORT wxImage;
//--------------------------------------------------------------------------------
// wxMemoryFSHandler
//--------------------------------------------------------------------------------
class WXDLLEXPORT wxMemoryFSHandler : public wxFileSystemHandler
class WXDLLEXPORT wxMemoryFSHandlerBase : public wxFileSystemHandler
{
public:
wxMemoryFSHandler();
~wxMemoryFSHandler();
public:
wxMemoryFSHandlerBase();
~wxMemoryFSHandlerBase();
// Add file to list of files stored in memory. Stored data (bitmap, text or raw data)
// will be copied into private memory stream and available under name "memory:" + filename
#if wxUSE_GUI
static void AddFile(const wxString& filename, wxImage& image, long type);
static void AddFile(const wxString& filename, const wxBitmap& bitmap, long type);
#endif
static void AddFile(const wxString& filename, const wxString& textdata);
static void AddFile(const wxString& filename, const void *binarydata, size_t size);
// Add file to list of files stored in memory. Stored data (bitmap, text or
// raw data) will be copied into private memory stream and available under
// name "memory:" + filename
static void AddFile(const wxString& filename, wxImage& image, long type);
static void AddFile(const wxString& filename, const wxString& textdata);
static void AddFile(const wxString& filename, const void *binarydata, size_t size);
// Remove file from memory FS and free occupied memory
static void RemoveFile(const wxString& filename);
// Remove file from memory FS and free occupied memory
static void RemoveFile(const wxString& filename);
virtual bool CanOpen(const wxString& location);
virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
virtual wxString FindFirst(const wxString& spec, int flags = 0);
virtual wxString FindNext();
virtual bool CanOpen(const wxString& location);
virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
virtual wxString FindFirst(const wxString& spec, int flags = 0);
virtual wxString FindNext();
private:
static wxHashTable *m_Hash;
private:
static wxHashTable *m_Hash;
static bool CheckHash(const wxString& filename);
static bool CheckHash(const wxString& filename);
};
#endif
// wxUSE_FILESYSTEM
class wxMemoryFSHandler : public wxMemoryFSHandlerBase
{
public:
#if wxUSE_GUI
static void AddFile(const wxString& filename, const wxBitmap& bitmap, long type);
#endif // wxUSE_GUI
};
#endif // wxUSE_FILESYSTEM
#endif // _WX_FS_MEM_H_

View File

@@ -46,8 +46,12 @@ public:
virtual bool Initialized();
virtual bool Pending();
virtual void Dispatch();
virtual void Exit();
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual bool ProcessIdle();
virtual void WakeUpIdle();
// implementation only from now on
void OnIdle( wxIdleEvent &event );

View File

@@ -46,8 +46,12 @@ public:
virtual bool Initialized();
virtual bool Pending();
virtual void Dispatch();
virtual void Exit();
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual bool ProcessIdle();
virtual void WakeUpIdle();
// implementation only from now on
void OnIdle( wxIdleEvent &event );

View File

@@ -52,8 +52,12 @@ class WXDLLEXPORT wxApp: public wxAppBase
virtual bool Initialized();
virtual bool Pending() ;
virtual void Dispatch() ;
virtual void Exit();
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual bool ProcessIdle();
virtual void WakeUpIdle();
virtual void SetPrintMode(int mode) { m_printMode = mode; }
virtual int GetPrintMode() const { return m_printMode; }

View File

@@ -55,8 +55,12 @@ public:
virtual bool Initialized();
virtual bool Pending();
virtual void Dispatch();
virtual void Exit();
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual bool ProcessIdle();
virtual void WakeUpIdle(); // implemented in motif/evtloop.cpp
virtual bool OnInitGui();

View File

@@ -74,6 +74,18 @@ public:
#endif // wxUSE_GUI
// ----------------------------------------------------------------------------
// implementation using the native way of outputting debug messages
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxMessageOutputDebug : public wxMessageOutput
{
public:
wxMessageOutputDebug() { }
virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2;
};
// ----------------------------------------------------------------------------
// implementation using wxLog (mainly for backwards compatibility)
// ----------------------------------------------------------------------------

View File

@@ -41,8 +41,10 @@ public:
virtual bool Initialized();
virtual bool Pending();
virtual void Dispatch();
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual bool ProcessIdle();
virtual void WakeUpIdle();
virtual void SetPrintMode(int mode) { m_printMode = mode; }
virtual int GetPrintMode() const { return m_printMode; }

46
include/wx/msw/apptbase.h Normal file
View File

@@ -0,0 +1,46 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/apptbase.h
// Purpose: declaration of wxAppTraits for MSW
// Author: Vadim Zeitlin
// Modified by:
// Created: 22.06.2003
// RCS-ID: $Id$
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_APPTBASE_H_
#define _WX_MSW_APPTBASE_H_
// ----------------------------------------------------------------------------
// wxAppTraits: the MSW version adds extra hooks needed by MSW-only code
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxAppTraits : public wxAppTraitsBase
{
public:
// wxExecute() support methods
// ---------------------------
// called before starting to wait for the child termination, may return
// some opaque data which will be passed later to AfterChildWaitLoop()
virtual void *BeforeChildWaitLoop() = 0;
// process pending Windows messages, even in console app
virtual void AlwaysYield() = 0;
// called after starting to wait for the child termination, the parameter
// is the return value of BeforeChildWaitLoop()
virtual void AfterChildWaitLoop(void *data) = 0;
// wxThread helpers
// ----------------
// process a message while waiting for a(nother) thread, should return
// false if and only if we have to exit the application
virtual bool DoMessageFromThreadWait() = 0;
};
#endif // _WX_MSW_APPTBASE_H_

44
include/wx/msw/apptrait.h Normal file
View File

@@ -0,0 +1,44 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/apptrait.h
// Purpose: class implementing wxAppTraits for MSW
// Author: Vadim Zeitlin
// Modified by:
// Created: 21.06.2003
// RCS-ID: $Id$
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_APPTRAIT_H_
#define _WX_MSW_APPTRAIT_H_
// ----------------------------------------------------------------------------
// wxGUI/ConsoleAppTraits: must derive from wxAppTraits, not wxAppTraitsBase
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxConsoleAppTraits : public wxConsoleAppTraitsBase
{
public:
virtual void *BeforeChildWaitLoop();
virtual void AlwaysYield();
virtual void AfterChildWaitLoop(void *data);
virtual bool DoMessageFromThreadWait();
};
#if wxUSE_GUI
class WXDLLEXPORT wxGUIAppTraits : public wxGUIAppTraitsBase
{
public:
virtual void *BeforeChildWaitLoop();
virtual void AlwaysYield();
virtual void AfterChildWaitLoop(void *data);
virtual bool DoMessageFromThreadWait();
};
#endif // wxUSE_GUI
#endif // _WX_MSW_APPTRAIT_H_

View File

@@ -240,6 +240,50 @@ struct HH_AKLINK
BOOL fIndexOnFail;
};
// ----------------------------------------------------------------------------
// SHGetFileInfo-related things
// ----------------------------------------------------------------------------
#ifndef SHGetFileInfo
#ifdef UNICODE
#define SHGetFileInfo SHGetFileInfoW
#else
#define SHGetFileInfo SHGetFileInfoA
#endif
#endif
#ifndef SHGFI_ATTRIBUTES
#define SHGFI_ATTRIBUTES 2048
#endif
#ifndef SFGAO_READONLY
#define SFGAO_READONLY 0x00040000L
#endif
#ifndef SFGAO_REMOVABLE
#define SFGAO_REMOVABLE 0x02000000L
#endif
#ifndef SHGFI_DISPLAYNAME
#define SHGFI_DISPLAYNAME 512
#endif
#ifndef SHGFI_ICON
#define SHGFI_ICON 256
#endif
#ifndef SHGFI_SMALLICON
#define SHGFI_SMALLICON 1
#endif
#ifndef SHGFI_SHELLICONSIZE
#define SHGFI_SHELLICONSIZE 4
#endif
#ifndef SHGFI_OPENICON
#define SHGFI_OPENICON 2
#endif
// ----------------------------------------------------------------------------
// Rich text control
// ----------------------------------------------------------------------------
@@ -319,7 +363,7 @@ typedef struct _paraformat2 {
#endif
#endif
#endif // wxUSE_RICHEDIT
// ----------------------------------------------------------------------------
// Misc stuff

View File

@@ -76,8 +76,12 @@ public:
virtual bool Initialized(void);
virtual bool Pending(void) ;
virtual void Dispatch(void);
virtual void Exit();
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual bool ProcessIdle(void);
virtual bool ProcessIdle(void);
virtual void WakeUpIdle(void);
virtual void SetPrintMode(int mode) { m_nPrintMode = mode; }
virtual int GetPrintMode(void) const { return m_nPrintMode; }

View File

@@ -0,0 +1,63 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/apptbase.h
// Purpose: declaration of wxAppTraits for Unix systems
// Author: Vadim Zeitlin
// Modified by:
// Created: 23.06.2003
// RCS-ID: $Id$
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_APPTBASE_H_
#define _WX_UNIX_APPTBASE_H_
class wxExecuteData;
class wxPipe;
// ----------------------------------------------------------------------------
// wxAppTraits: the Unix version adds extra hooks needed by Unix code
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxAppTraits : public wxAppTraitsBase
{
public:
// wxExecute() support methods
// ---------------------------
// called before starting the child process and creates the pipe used for
// detecting the process termination asynchronously in GUI, does nothing in
// wxBase
//
// if it returns false, we should return from wxExecute() with an error
virtual bool CreateEndProcessPipe(wxExecuteData& execData) = 0;
// test if the given descriptor is the end of the pipe create by the
// function above
virtual bool IsWriteFDOfEndProcessPipe(wxExecuteData& execData, int fd) = 0;
// ensure that the write end of the pipe is not closed by wxPipe dtor
virtual void DetachWriteFDOfEndProcessPipe(wxExecuteData& execData) = 0;
// wait for the process termination, return whatever wxExecute() must
// return
virtual int WaitForChild(wxExecuteData& execData) = 0;
// wxThread helpers
// ----------------
// TODO
// other miscellaneous helpers
// ---------------------------
// wxGetOsVersion() behaves differently in GUI and non-GUI builds udner
// Unix: in the former case it returns the information about the toolkit
// and in the latter -- about the OS, so we need to virtualize it
virtual int GetOSVersion(int *verMaj, int *verMin) = 0;
};
#endif // _WX_UNIX_APPTBASE_H_

View File

@@ -0,0 +1,46 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/apptrait.h
// Purpose: standard implementations of wxAppTraits for Unix
// Author: Vadim Zeitlin
// Modified by:
// Created: 23.06.2003
// RCS-ID: $Id$
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_APPTRAIT_H_
#define _WX_UNIX_APPTRAIT_H_
// ----------------------------------------------------------------------------
// wxGUI/ConsoleAppTraits: must derive from wxAppTraits, not wxAppTraitsBase
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxConsoleAppTraits : public wxConsoleAppTraitsBase
{
public:
virtual bool CreateEndProcessPipe();
virtual bool IsWriteFDOfEndProcessPipe(wxExecuteData& execData, int fd);
virtual void DetachWriteFDOfEndProcessPipe(wxExecuteData& execData);
virtual int WaitForChild(wxExecuteData& execData);
virtual int GetOSVersion(int *verMaj, int *verMin);
};
#if wxUSE_GUI
class WXDLLEXPORT wxGUIAppTraits : public wxGUIAppTraitsBase
{
public:
virtual bool CreateEndProcessPipe(wxExecuteData& execData);
virtual bool IsWriteFDOfEndProcessPipe(wxExecuteData& execData, int fd);
virtual void DetachWriteFDOfEndProcessPipe(wxExecuteData& execData);
virtual int WaitForChild(wxExecuteData& execData);
virtual int GetOSVersion(int *verMaj, int *verMin);
};
#endif // wxUSE_GUI
#endif // _WX_UNIX_APPTRAIT_H_

View File

@@ -10,6 +10,11 @@
#ifndef _WX_UNIX_EXECUTE_H
#define _WX_UNIX_EXECUTE_H
#include "wx/unix/pipe.h"
class wxProcess;
class wxStreamTempInputBuffer;
// if pid > 0, the execution is async and the data is freed in the callback
// executed when the process terminates, if pid < 0, the execution is
// synchronous and the caller (wxExecute) frees the data
@@ -21,6 +26,43 @@ struct wxEndProcessData
int exitcode; // the exit code
};
// struct in which information is passed from wxExecute() to wxAppTraits
// methods
struct wxExecuteData
{
wxExecuteData()
{
flags =
pid = 0;
process = NULL;
#if wxUSE_STREAMS
bufOut =
bufErr = NULL;
#endif // wxUSE_STREAMS
}
// wxExecute() flags
int flags;
// the pid of the child process
int pid;
// the associated process object or NULL
wxProcess *process;
// pipe used for end process detection
wxPipe pipeEndProcDetect;
#if wxUSE_STREAMS
// the input buffer bufOut is connected to stdout, this is why it is
// called bufOut and not bufIn
wxStreamTempInputBuffer *bufOut,
*bufErr;
#endif // wxUSE_STREAMS
};
// this function is called when the process terminates from port specific
// callback function and is common to all ports (src/unix/utilsunx.cpp)
extern void wxHandleProcessTermination(wxEndProcessData *proc_data);
@@ -28,6 +70,7 @@ extern void wxHandleProcessTermination(wxEndProcessData *proc_data);
// this function is called to associate the port-specific callback with the
// child process. The return valus is port-specific.
extern int wxAddProcessCallback(wxEndProcessData *proc_data, int fd);
// For ports (e.g. DARWIN) which can add callbacks based on the pid
extern int wxAddProcessCallbackForPid(wxEndProcessData *proc_data, int pid);

95
include/wx/unix/pipe.h Normal file
View File

@@ -0,0 +1,95 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/pipe.h
// Purpose: wxPipe class
// Author: Vadim Zeitlin
// Modified by:
// Created: 24.06.2003 (extracted from src/unix/utilsunx.cpp)
// RCS-ID: $Id$
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_PIPE_H_
#define _WX_UNIX_PIPE_H_
#include <unistd.h>
// ----------------------------------------------------------------------------
// wxPipe: this class encapsulates pipe() system call
// ----------------------------------------------------------------------------
class wxPipe
{
public:
// the symbolic names for the pipe ends
enum Direction
{
Read,
Write
};
enum
{
INVALID_FD = -1
};
// default ctor doesn't do anything
wxPipe() { m_fds[Read] = m_fds[Write] = INVALID_FD; }
// create the pipe, return TRUE if ok, FALSE on error
bool Create()
{
if ( pipe(m_fds) == -1 )
{
wxLogSysError(_("Pipe creation failed"));
return FALSE;
}
return TRUE;
}
// return TRUE if we were created successfully
bool IsOk() const { return m_fds[Read] != INVALID_FD; }
// return the descriptor for one of the pipe ends
int operator[](Direction which) const
{
wxASSERT_MSG( which >= 0 && (size_t)which < WXSIZEOF(m_fds),
_T("invalid pipe index") );
return m_fds[which];
}
// detach a descriptor, meaning that the pipe dtor won't close it, and
// return it
int Detach(Direction which)
{
wxASSERT_MSG( which >= 0 && (size_t)which < WXSIZEOF(m_fds),
_T("invalid pipe index") );
int fd = m_fds[which];
m_fds[which] = INVALID_FD;
return fd;
}
// close the pipe descriptors
void Close()
{
for ( size_t n = 0; n < WXSIZEOF(m_fds); n++ )
{
if ( m_fds[n] != INVALID_FD )
close(m_fds[n]);
}
}
// dtor closes the pipe descriptors
~wxPipe() { Close(); }
private:
int m_fds[2];
};
#endif // _WX_UNIX_PIPE_H_

View File

@@ -24,10 +24,6 @@
#if wxUSE_FSVOLUME
#if wxUSE_GUI
#include "wx/iconbndl.h" // for wxIconArray
#endif // wxUSE_GUI
// the volume flags
enum
{
@@ -56,22 +52,7 @@ enum wxFSVolumeKind
wxFS_VOL_MAX
};
#if wxUSE_GUI
#include "wx/icon.h"
enum wxFSIconType
{
wxFS_VOL_ICO_SMALL = 0,
wxFS_VOL_ICO_LARGE,
wxFS_VOL_ICO_SEL_SMALL,
wxFS_VOL_ICO_SEL_LARGE,
wxFS_VOL_ICO_MAX
};
#endif // wxUSE_GUI
class WXDLLEXPORT wxFSVolume
class WXDLLEXPORT wxFSVolumeBase
{
public:
// return the array containing the names of the volumes
@@ -88,8 +69,8 @@ public:
// create the volume object with this name (should be one of those returned
// by GetVolumes()).
wxFSVolume();
wxFSVolume(const wxString& name);
wxFSVolumeBase();
wxFSVolumeBase(const wxString& name);
bool Create(const wxString& name);
// accessors
@@ -112,22 +93,61 @@ public:
wxString GetName() const { return m_volName; }
wxString GetDisplayName() const { return m_dispName; }
#if wxUSE_GUI
wxIcon GetIcon(wxFSIconType type) const;
#endif
// TODO: operatios (Mount(), Unmount(), Eject(), ...)?
private:
protected:
// the internal volume name
wxString m_volName;
wxString m_dispName;
#if wxUSE_GUI
wxIconArray m_icons;
#endif
bool m_isOk;
// the volume name as it is displayed to the user
wxString m_dispName;
// have we been initialized correctly?
bool m_isOk;
};
#if wxUSE_GUI
#include "wx/icon.h"
#include "wx/iconbndl.h" // only for wxIconArray
enum wxFSIconType
{
wxFS_VOL_ICO_SMALL = 0,
wxFS_VOL_ICO_LARGE,
wxFS_VOL_ICO_SEL_SMALL,
wxFS_VOL_ICO_SEL_LARGE,
wxFS_VOL_ICO_MAX
};
// wxFSVolume adds GetIcon() to wxFSVolumeBase
class wxFSVolume : public wxFSVolumeBase
{
public:
wxFSVolume() : wxFSVolumeBase() { InitIcons(); }
wxFSVolume(const wxString& name) : wxFSVolumeBase(name) { InitIcons(); }
wxIcon GetIcon(wxFSIconType type) const;
private:
void InitIcons();
// the different icons for this volume (created on demand)
wxIconArray m_icons;
};
#else // !wxUSE_GUI
// wxFSVolume is the same thing as wxFSVolume in wxBase
class wxFSVolume : public wxFSVolumeBase
{
public:
wxFSVolume() : wxFSVolumeBase() { }
wxFSVolume(const wxString& name) : wxFSVolumeBase(name) { }
};
#endif // wxUSE_GUI/!wxUSE_GUI
#endif // wxUSE_FSVOLUME
#endif // _WX_FSVOLUME_H_

View File

@@ -55,8 +55,12 @@ public:
virtual bool Initialized();
virtual bool Pending();
virtual void Dispatch();
virtual void Exit();
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual bool ProcessIdle();
virtual void WakeUpIdle();
virtual bool OnInitGui();