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:
parent
433f5675a9
commit
e2478fde62
@ -120,7 +120,8 @@ treectlg.cpp Generic
|
||||
wizard.cpp Generic
|
||||
|
||||
accesscmn.cpp Common
|
||||
appcmn.cpp Common Base
|
||||
appbase.cpp Common Base
|
||||
appcmn.cpp Common
|
||||
artprov.cpp Common
|
||||
artstd.cpp Common
|
||||
bmpbase.cpp Common NotGTK,NotOS2,NotMSW,NotMicro
|
||||
@ -165,8 +166,9 @@ filefn.cpp Common Base
|
||||
filename.cpp Common Base
|
||||
filesys.cpp Common Base
|
||||
fldlgcmn.cpp Common
|
||||
fmapbase.cpp Common Base
|
||||
fontcmn.cpp Common
|
||||
fontmap.cpp Common Base
|
||||
fontmap.cpp Common
|
||||
framecmn.cpp Common
|
||||
toplvcmn.cpp Common
|
||||
fs_inet.cpp Common Base
|
||||
@ -228,6 +230,7 @@ settcmn.cpp Common
|
||||
sizer.cpp Common
|
||||
socket.cpp Common Socket,Base
|
||||
statbar.cpp Common
|
||||
stopwatch.cpp Common Base
|
||||
strconv.cpp Common Base
|
||||
stream.cpp Common Base
|
||||
string.cpp Common Base
|
||||
@ -237,7 +240,7 @@ tbarbase.cpp Common
|
||||
textbuf.cpp Common Base
|
||||
textcmn.cpp Common
|
||||
textfile.cpp Common Base
|
||||
timercmn.cpp Common Base
|
||||
timercmn.cpp Common
|
||||
tokenzr.cpp Common Base
|
||||
treebase.cpp Common
|
||||
txtstrm.cpp Common Base
|
||||
@ -262,6 +265,7 @@ accel.cpp MSW
|
||||
access.cpp MSW OLE
|
||||
app.cpp MSW LowLevel
|
||||
automtn.cpp MSW OLE,LowLevel
|
||||
basemsw.cpp MSW Base
|
||||
bitmap.cpp MSW LowLevel
|
||||
bmpbuttn.cpp MSW
|
||||
brush.cpp MSW LowLevel
|
||||
@ -366,12 +370,14 @@ toplevel.cpp MSW LowLevel
|
||||
treectrl.cpp MSW Win32Only
|
||||
utils.cpp MSW Base,LowLevel
|
||||
utilsexc.cpp MSW Base,LowLevel
|
||||
utilsgui.cpp MSW LowLevel
|
||||
uuid.cpp MSW OLE,LowLevel
|
||||
uxtheme.cpp MSW
|
||||
volume.cpp MSW Base
|
||||
wave.cpp MSW LowLevel
|
||||
window.cpp MSW LowLevel
|
||||
|
||||
baseunix.cpp Unix Base
|
||||
dialup.cpp Unix NotMac
|
||||
dir.cpp Unix Base,NotMac
|
||||
fontenum.cpp Unix NotCocoa,NotMac,NotMGL,NotMicro
|
||||
@ -381,6 +387,8 @@ mimetype.cpp Unix Base,NotMac,NotMicro
|
||||
snglinst.cpp Unix Base
|
||||
taskbarx11.cpp Unix NotCocoa,NotMac,NotMGL,NotMicro
|
||||
threadpsx.cpp Unix Base,NotMac
|
||||
# not yet
|
||||
# utilsgui.cpp Unix
|
||||
utilsunx.cpp Unix Base
|
||||
utilsx11.cpp Unix NotMac,NotMGL,NotMicro
|
||||
|
||||
@ -809,6 +817,7 @@ access.h WXH
|
||||
accel.h WXH
|
||||
access.h WXH
|
||||
app.h WXH Base
|
||||
apptrait.h WXH Base
|
||||
artprov.h WXH
|
||||
bitmap.h WXH
|
||||
bmpbuttn.h WXH
|
||||
@ -881,6 +890,7 @@ filedlg.h WXH
|
||||
filefn.h WXH Base
|
||||
filename.h WXH Base
|
||||
filesys.h WXH Base
|
||||
fmappriv.h WXH Base
|
||||
font.h WXH
|
||||
fontdlg.h WXH
|
||||
fontenc.h WXH Base
|
||||
@ -950,7 +960,7 @@ minifram.h WXH
|
||||
module.h WXH Base
|
||||
msgdlg.h WXH
|
||||
msgout.h WXH Base
|
||||
mslu.cpp MSW
|
||||
mslu.cpp MSW Base
|
||||
mstream.h WXH Base
|
||||
notebook.h WXH
|
||||
object.h WXH Base
|
||||
@ -1350,6 +1360,8 @@ window.h MGLH
|
||||
access.h MSWH
|
||||
accel.h MSWH
|
||||
app.h MSWH
|
||||
apptbase.h MSWH Base
|
||||
apptrait.h MSWH Base
|
||||
bitmap.h MSWH
|
||||
bmpbuttn.h MSWH
|
||||
brush.h MSWH
|
||||
@ -1547,10 +1559,13 @@ pnghand.h OS2H
|
||||
statbox.h OS2H
|
||||
toplevel.h OS2H
|
||||
|
||||
apptbase.h UnixH Base
|
||||
apptrait.h UnixH Base
|
||||
execute.h UnixH
|
||||
fontutil.h UnixH
|
||||
gsockunx.h UnixH Base
|
||||
mimetype.h UnixH Base
|
||||
pipe.h UnixH Base
|
||||
taskbarx11.h UnixH
|
||||
utilsx11.h UnixH
|
||||
|
||||
|
@ -121,7 +121,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXWINDLL_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswdllu" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswdllu" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
@ -147,7 +147,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MDd /W4 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXWINDLL_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswdllud" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "_DEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswdllud" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "_DEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
@ -172,7 +172,7 @@ LINK32=link.exe
|
||||
# PROP Intermediate_Dir "../ReleaseUnicode"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswu" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "_UNICODE" /D "UNICODE" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswu" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "_UNICODE" /D "UNICODE" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD BASE RSC /l 0x409
|
||||
# ADD RSC /l 0x409
|
||||
BSC32=bscmake.exe
|
||||
@ -195,7 +195,7 @@ LIB32=link.exe -lib
|
||||
# PROP Intermediate_Dir "../DebugUnicode"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswud" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "_DEBUG" /D "__WXDEBUG__" /D WINVER=0x0400 /D "STRICT" /D "_UNICODE" /D "UNICODE" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswud" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "_DEBUG" /D "__WXDEBUG__" /D WINVER=0x0400 /D "STRICT" /D "_UNICODE" /D "UNICODE" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD BASE RSC /l 0x409
|
||||
# ADD RSC /l 0x409
|
||||
BSC32=bscmake.exe
|
||||
@ -219,7 +219,7 @@ LIB32=link.exe -lib
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXWINDLL_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswdll" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswdll" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
@ -245,7 +245,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MDd /W4 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXWINDLL_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswdlld" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "_DEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswdlld" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "_DEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
@ -270,7 +270,7 @@ LINK32=link.exe
|
||||
# PROP Intermediate_Dir "../Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /O2 /I "../lib/msw" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /O2 /I "../lib/msw" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD BASE RSC /l 0x409
|
||||
# ADD RSC /l 0x409
|
||||
BSC32=bscmake.exe
|
||||
@ -293,7 +293,7 @@ LIB32=link.exe -lib
|
||||
# PROP Intermediate_Dir "../Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswd" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "_DEBUG" /D "__WXDEBUG__" /D WINVER=0x0400 /D "STRICT" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswd" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "_DEBUG" /D "__WXDEBUG__" /D WINVER=0x0400 /D "STRICT" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD BASE RSC /l 0x409
|
||||
# ADD RSC /l 0x409
|
||||
BSC32=bscmake.exe
|
||||
|
@ -7,7 +7,7 @@ by category (and sorted by alphabetical order inside each category).
|
||||
|
||||
\begin{twocollist}\itemsep=0pt
|
||||
\twocolitem{\_\_WINDOWS\_\_}{any Windows, yom may also use \_\_WXMSW\_\_}
|
||||
\twocolitem{\_\_WIN16\_\_}{Win16 API}
|
||||
\twocolitem{\_\_WIN16\_\_}{Win16 API (not supported since wxWindows 2.6)}
|
||||
\twocolitem{\_\_WIN32\_\_}{Win32 API}
|
||||
\twocolitem{\_\_WIN95\_\_}{Windows 95 or NT 4.0 and above system (not NT 3.5x)}
|
||||
\twocolitem{\_\_WXGTK\_\_}{GTK}
|
||||
@ -15,7 +15,8 @@ by category (and sorted by alphabetical order inside each category).
|
||||
\twocolitem{\_\_WXGTK20\_\_}{GTK 2.0 or higher}
|
||||
\twocolitem{\_\_WXMOTIF\_\_}{Motif}
|
||||
\twocolitem{\_\_WXMOTIF20\_\_}{Motif 2.0 or higher}
|
||||
\twocolitem{\_\_WXMAC\_\_}{Mac OS whether Classic (Mac OS 8/9 TARGET\_CARBON == 0) or Carbon (including Mac OS X TARGET\_CARBON == 1)}
|
||||
\twocolitem{\_\_WXMAC\_\_}{Mac OS whether Classic (Mac OS 8/9 TARGET\_CARBON
|
||||
== 0) or Carbon (including Mac OS X TARGET\_CARBON == 1)}
|
||||
\twocolitem{\_\_WXMGL\_\_}{SciTech Soft MGL (\_\_WXUNIVERSAL\_\_ will be also
|
||||
defined)}
|
||||
\twocolitem{\_\_WXMSW\_\_}{Any Windows}
|
||||
@ -31,9 +32,8 @@ to one of the symbols above so this should be tested first.}
|
||||
\twocolitem{\_\_X\_\_}{any X11-based GUI toolkit except GTK+}
|
||||
\end{twocollist}
|
||||
|
||||
In fact, they should better all start with \_\_WX instead of \_\_ only. The
|
||||
only GUIs implemented for 2.0 are \_\_WXGTK\_\_, \_\_WXMSW\_\_ and
|
||||
\_\_WXMOTIF\_\_ yet. Any new ones, please start the define with \_\_WX.
|
||||
In fact, they should better all start with \_\_WX instead of \_\_ only,
|
||||
so please start any new defines with \_\_WX.
|
||||
|
||||
\subsection{Operating systems}
|
||||
|
||||
@ -47,6 +47,7 @@ only GUIs implemented for 2.0 are \_\_WXGTK\_\_, \_\_WXMSW\_\_ and
|
||||
\twocolitem{\_\_DOS\_GENERAL\_\_}{DOS (used with wxMGL only)}
|
||||
\twocolitem{\_\_FREEBSD\_\_}{FreeBSD}
|
||||
\twocolitem{\_\_HPUX\_\_}{HP-UX (Unix)}
|
||||
\twocolitem{\_\_GNU\_\_}{GNU Hurd}
|
||||
\twocolitem{\_\_LINUX\_\_}{Linux}
|
||||
\twocolitem{\_\_MACH\_\_}{Mach-O Architecture (Mac OS X only builds)}
|
||||
\twocolitem{\_\_OSF\_\_}{OSF/1}
|
||||
@ -99,6 +100,11 @@ the compiler version, $1100$ is $11.0$ and $1200$ is OpenWatcom.}
|
||||
\subsection{Miscellaneous}
|
||||
|
||||
\begin{twocollist}\itemsep=0pt
|
||||
\twocolitem{\_\_WXWINDOWS\_\_}{always defined in wxWindows applications, see
|
||||
also \helpref{wxCHECK\_VERSION}{wxcheckversion}}
|
||||
\twocolitem{\_\_WXBASE\_\_}{only used by wxWindows internally (defined when
|
||||
building wxBase code, either as a standalone library or as part of the
|
||||
monolithis wxWindows library, not defined when building GUI library only)}
|
||||
\twocolitem{\_\_WXDEBUG\_\_}{defined in debug mode, undefined in release mode}
|
||||
\twocolitem{wxUSE\_XXX}{if defined as $1$, feature XXX is active
|
||||
(the symbols of this form are always defined, use \#if and not \#ifdef to test
|
||||
|
440
include/wx/app.h
440
include/wx/app.h
@ -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ç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
172
include/wx/apptrait.h
Normal 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_
|
||||
|
@ -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_
|
||||
|
@ -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);
|
||||
|
@ -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
74
include/wx/fmappriv.h
Normal 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_
|
||||
|
@ -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_
|
||||
|
||||
|
@ -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_
|
||||
|
||||
|
@ -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 );
|
||||
|
@ -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 );
|
||||
|
@ -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; }
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -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
46
include/wx/msw/apptbase.h
Normal 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
44
include/wx/msw/apptrait.h
Normal 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_
|
||||
|
@ -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
|
||||
|
@ -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; }
|
||||
|
63
include/wx/unix/apptbase.h
Normal file
63
include/wx/unix/apptbase.h
Normal 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_
|
||||
|
46
include/wx/unix/apptrait.h
Normal file
46
include/wx/unix/apptrait.h
Normal 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_
|
||||
|
@ -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
95
include/wx/unix/pipe.h
Normal 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_
|
||||
|
@ -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_
|
||||
|
@ -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();
|
||||
|
||||
|
@ -205,20 +205,11 @@ int wxEntry( int argc, char *argv[])
|
||||
return retValue;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// other functions
|
||||
// ----------------------------------------------------------------------------
|
||||
void wxWakeUpIdle()
|
||||
void wxApp::Exit()
|
||||
{
|
||||
wxTheApp->CocoaRequestIdle();
|
||||
}
|
||||
|
||||
void wxExit()
|
||||
{
|
||||
wxLogError(_("Fatal error: exiting"));
|
||||
|
||||
wxApp::CleanUp();
|
||||
exit(1);
|
||||
|
||||
wxAppConsole::Exit();
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
735
src/common/appbase.cpp
Normal file
735
src/common/appbase.cpp
Normal file
@ -0,0 +1,735 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: common/base/appbase.cpp
|
||||
// Purpose: implements wxAppConsole class
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 19.06.2003 (extracted from common/appcmn.cpp)
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
|
||||
// License: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// for compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#if wxUSE_LOG
|
||||
#include "wx/log.h"
|
||||
#endif // wxUSE_LOG
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#include "wx/apptrait.h"
|
||||
#include "wx/cmdline.h"
|
||||
#include "wx/confbase.h"
|
||||
#if wxUSE_FONTMAP
|
||||
#include "wx/fontmap.h"
|
||||
#endif // wxUSE_FONTMAP
|
||||
#include "wx/msgout.h"
|
||||
#include "wx/tokenzr.h"
|
||||
|
||||
#if !defined(__WXMSW__) || defined(__WXMICROWIN__)
|
||||
#include <signal.h> // for SIGTRAP used by wxTrap()
|
||||
#endif //Win/Unix
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/private.h" // includes windows.h for MessageBox()
|
||||
#endif
|
||||
|
||||
#if defined(__WXMAC__)
|
||||
#include "wx/mac/private.h" // includes mac headers
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// private functions prototypes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
// really just show the assert dialog
|
||||
static bool DoShowAssertDialog(const wxString& msg);
|
||||
|
||||
// prepare for showing the assert dialog, use the given traits or
|
||||
// DoShowAssertDialog() as last fallback to really show it
|
||||
static
|
||||
void ShowAssertDialog(const wxChar *szFile,
|
||||
int nLine,
|
||||
const wxChar *szCond,
|
||||
const wxChar *szMsg,
|
||||
wxAppTraits *traits = NULL);
|
||||
|
||||
// turn on the trace masks specified in the env variable WXTRACE
|
||||
static void LINKAGEMODE SetTraceMasks();
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global vars
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxApp *wxTheApp = NULL;
|
||||
|
||||
wxAppInitializerFunction wxAppConsole::ms_appInitFn = NULL;
|
||||
|
||||
// ============================================================================
|
||||
// wxAppConsole implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ctor/dtor
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxAppConsole::wxAppConsole()
|
||||
{
|
||||
m_traits = NULL;
|
||||
|
||||
wxTheApp = (wxApp *)this;
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
SetTraceMasks();
|
||||
#endif
|
||||
}
|
||||
|
||||
wxAppConsole::~wxAppConsole()
|
||||
{
|
||||
delete m_traits;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// OnXXX() callbacks
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxAppConsole::OnInit()
|
||||
{
|
||||
#if wxUSE_CMDLINE_PARSER
|
||||
wxCmdLineParser parser(argc, argv);
|
||||
|
||||
OnInitCmdLine(parser);
|
||||
|
||||
bool cont;
|
||||
switch ( parser.Parse(FALSE /* don't show usage */) )
|
||||
{
|
||||
case -1:
|
||||
cont = OnCmdLineHelp(parser);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
cont = OnCmdLineParsed(parser);
|
||||
break;
|
||||
|
||||
default:
|
||||
cont = OnCmdLineError(parser);
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !cont )
|
||||
return FALSE;
|
||||
#endif // wxUSE_CMDLINE_PARSER
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int wxAppConsole::OnExit()
|
||||
{
|
||||
#if wxUSE_CONFIG
|
||||
// delete the config object if any (don't use Get() here, but Set()
|
||||
// because Get() could create a new config object)
|
||||
delete wxConfigBase::Set((wxConfigBase *) NULL);
|
||||
#endif // wxUSE_CONFIG
|
||||
|
||||
#ifdef __WXUNIVERSAL__
|
||||
delete wxTheme::Set(NULL);
|
||||
#endif // __WXUNIVERSAL__
|
||||
|
||||
// use Set(NULL) and not Get() to avoid creating a message output object on
|
||||
// demand when we just want to delete it
|
||||
delete wxMessageOutput::Set(NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wxAppConsole::Exit()
|
||||
{
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// traits stuff
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxAppTraits *wxAppConsole::CreateTraits()
|
||||
{
|
||||
return wxAppTraits::CreateConsole();
|
||||
}
|
||||
|
||||
wxAppTraits *wxAppConsole::GetTraits()
|
||||
{
|
||||
// FIXME-MT: protect this with a CS?
|
||||
if ( !m_traits )
|
||||
{
|
||||
m_traits = CreateTraits();
|
||||
|
||||
wxASSERT_MSG( m_traits, _T("wxApp::CreateTraits() failed?") );
|
||||
}
|
||||
|
||||
return m_traits;
|
||||
}
|
||||
|
||||
// we must implement CreateXXX() in wxApp itself for backwards compatibility
|
||||
#if WXWIN_COMPATIBILITY_2_4
|
||||
|
||||
#if wxUSE_LOG
|
||||
|
||||
wxLog *wxAppConsole::CreateLogTarget()
|
||||
{
|
||||
wxAppTraits *traits = GetTraits();
|
||||
return traits ? traits->CreateLogTarget() : NULL;
|
||||
}
|
||||
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
wxMessageOutput *wxAppConsole::CreateMessageOutput()
|
||||
{
|
||||
wxAppTraits *traits = GetTraits();
|
||||
return traits ? traits->CreateMessageOutput() : NULL;
|
||||
}
|
||||
|
||||
#endif // WXWIN_COMPATIBILITY_2_4
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event processing
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxAppConsole::ProcessPendingEvents()
|
||||
{
|
||||
// ensure that we're the only thread to modify the pending events list
|
||||
wxENTER_CRIT_SECT( *wxPendingEventsLocker );
|
||||
|
||||
if ( !wxPendingEvents )
|
||||
{
|
||||
wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
|
||||
return;
|
||||
}
|
||||
|
||||
// iterate until the list becomes empty
|
||||
wxNode *node = wxPendingEvents->GetFirst();
|
||||
while (node)
|
||||
{
|
||||
wxEvtHandler *handler = (wxEvtHandler *)node->GetData();
|
||||
delete node;
|
||||
|
||||
// In ProcessPendingEvents(), new handlers might be add
|
||||
// and we can safely leave the critical section here.
|
||||
wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
|
||||
handler->ProcessPendingEvents();
|
||||
wxENTER_CRIT_SECT( *wxPendingEventsLocker );
|
||||
|
||||
node = wxPendingEvents->GetFirst();
|
||||
}
|
||||
|
||||
wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
|
||||
}
|
||||
|
||||
int wxAppConsole::FilterEvent(wxEvent& WXUNUSED(event))
|
||||
{
|
||||
// process the events normally by default
|
||||
return -1;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// cmd line parsing
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_CMDLINE_PARSER
|
||||
|
||||
#define OPTION_VERBOSE _T("verbose")
|
||||
#define OPTION_THEME _T("theme")
|
||||
#define OPTION_MODE _T("mode")
|
||||
|
||||
void wxAppConsole::OnInitCmdLine(wxCmdLineParser& parser)
|
||||
{
|
||||
// the standard command line options
|
||||
static const wxCmdLineEntryDesc cmdLineDesc[] =
|
||||
{
|
||||
{
|
||||
wxCMD_LINE_SWITCH,
|
||||
_T("h"),
|
||||
_T("help"),
|
||||
gettext_noop("show this help message"),
|
||||
wxCMD_LINE_VAL_NONE,
|
||||
wxCMD_LINE_OPTION_HELP
|
||||
},
|
||||
|
||||
#if wxUSE_LOG
|
||||
{
|
||||
wxCMD_LINE_SWITCH,
|
||||
_T(""),
|
||||
OPTION_VERBOSE,
|
||||
gettext_noop("generate verbose log messages"),
|
||||
wxCMD_LINE_VAL_NONE,
|
||||
0x0
|
||||
},
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
#ifdef __WXUNIVERSAL__
|
||||
{
|
||||
wxCMD_LINE_OPTION,
|
||||
_T(""),
|
||||
OPTION_THEME,
|
||||
gettext_noop("specify the theme to use"),
|
||||
wxCMD_LINE_VAL_STRING,
|
||||
0x0
|
||||
},
|
||||
#endif // __WXUNIVERSAL__
|
||||
|
||||
#if defined(__WXMGL__)
|
||||
// VS: this is not specific to wxMGL, all fullscreen (framebuffer) ports
|
||||
// should provide this option. That's why it is in common/appcmn.cpp
|
||||
// and not mgl/app.cpp
|
||||
{
|
||||
wxCMD_LINE_OPTION,
|
||||
_T(""),
|
||||
OPTION_MODE,
|
||||
gettext_noop("specify display mode to use (e.g. 640x480-16)"),
|
||||
wxCMD_LINE_VAL_STRING,
|
||||
0x0
|
||||
},
|
||||
#endif // __WXMGL__
|
||||
|
||||
// terminator
|
||||
{
|
||||
wxCMD_LINE_NONE,
|
||||
_T(""),
|
||||
_T(""),
|
||||
_T(""),
|
||||
wxCMD_LINE_VAL_NONE,
|
||||
0x0
|
||||
}
|
||||
};
|
||||
|
||||
parser.SetDesc(cmdLineDesc);
|
||||
}
|
||||
|
||||
bool wxAppConsole::OnCmdLineParsed(wxCmdLineParser& parser)
|
||||
{
|
||||
#if wxUSE_LOG
|
||||
if ( parser.Found(OPTION_VERBOSE) )
|
||||
{
|
||||
wxLog::SetVerbose(TRUE);
|
||||
}
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
#ifdef __WXUNIVERSAL__
|
||||
wxString themeName;
|
||||
if ( parser.Found(OPTION_THEME, &themeName) )
|
||||
{
|
||||
wxTheme *theme = wxTheme::Create(themeName);
|
||||
if ( !theme )
|
||||
{
|
||||
wxLogError(_("Unsupported theme '%s'."), themeName.c_str());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Delete the defaultly created theme and set the new theme.
|
||||
delete wxTheme::Get();
|
||||
wxTheme::Set(theme);
|
||||
}
|
||||
#endif // __WXUNIVERSAL__
|
||||
|
||||
#if defined(__WXMGL__)
|
||||
wxString modeDesc;
|
||||
if ( parser.Found(OPTION_MODE, &modeDesc) )
|
||||
{
|
||||
unsigned w, h, bpp;
|
||||
if ( wxSscanf(modeDesc.c_str(), _T("%ux%u-%u"), &w, &h, &bpp) != 3 )
|
||||
{
|
||||
wxLogError(_("Invalid display mode specification '%s'."), modeDesc.c_str());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !SetDisplayMode(wxDisplayModeInfo(w, h, bpp)) )
|
||||
return FALSE;
|
||||
}
|
||||
#endif // __WXMGL__
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxAppConsole::OnCmdLineHelp(wxCmdLineParser& parser)
|
||||
{
|
||||
parser.Usage();
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxAppConsole::OnCmdLineError(wxCmdLineParser& parser)
|
||||
{
|
||||
parser.Usage();
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif // wxUSE_CMDLINE_PARSER
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// debugging support
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/* static */
|
||||
bool wxAppConsole::CheckBuildOptions(const wxBuildOptions& opts)
|
||||
{
|
||||
#define wxCMP(what) (what == opts.m_ ## what)
|
||||
|
||||
bool
|
||||
#ifdef __WXDEBUG__
|
||||
isDebug = TRUE;
|
||||
#else
|
||||
isDebug = FALSE;
|
||||
#endif
|
||||
|
||||
int verMaj = wxMAJOR_VERSION,
|
||||
verMin = wxMINOR_VERSION;
|
||||
|
||||
if ( !(wxCMP(isDebug) && wxCMP(verMaj) && wxCMP(verMin)) )
|
||||
{
|
||||
wxString msg;
|
||||
wxString libDebug, progDebug;
|
||||
|
||||
if (isDebug)
|
||||
libDebug = wxT("debug");
|
||||
else
|
||||
libDebug = wxT("no debug");
|
||||
|
||||
if (opts.m_isDebug)
|
||||
progDebug = wxT("debug");
|
||||
else
|
||||
progDebug = wxT("no debug");
|
||||
|
||||
msg.Printf(_T("Mismatch between the program and library build versions detected.\nThe library used %d.%d (%s), and your program used %d.%d (%s)."),
|
||||
verMaj, verMin, libDebug.c_str(), opts.m_verMaj, opts.m_verMin, progDebug.c_str());
|
||||
|
||||
wxLogFatalError(msg);
|
||||
|
||||
// normally wxLogFatalError doesn't return
|
||||
return FALSE;
|
||||
}
|
||||
#undef wxCMP
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
|
||||
void wxAppConsole::OnAssert(const wxChar *file,
|
||||
int line,
|
||||
const wxChar *cond,
|
||||
const wxChar *msg)
|
||||
{
|
||||
ShowAssertDialog(file, line, cond, msg, m_traits);
|
||||
}
|
||||
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
// ============================================================================
|
||||
// other classes implementations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxConsoleAppTraitsBase
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_LOG
|
||||
|
||||
wxLog *wxConsoleAppTraitsBase::CreateLogTarget()
|
||||
{
|
||||
return new wxLogStderr;
|
||||
}
|
||||
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
wxMessageOutput *wxConsoleAppTraitsBase::CreateMessageOutput()
|
||||
{
|
||||
return new wxMessageOutputStderr;
|
||||
}
|
||||
|
||||
#if wxUSE_FONTMAP
|
||||
|
||||
wxFontMapper *wxConsoleAppTraitsBase::CreateFontMapper()
|
||||
{
|
||||
return (wxFontMapper *)new wxFontMapperBase;
|
||||
}
|
||||
|
||||
#endif // wxUSE_FONTMAP
|
||||
|
||||
bool wxConsoleAppTraitsBase::ShowAssertDialog(const wxString& msg)
|
||||
{
|
||||
return wxAppTraitsBase::ShowAssertDialog(msg);
|
||||
}
|
||||
|
||||
bool wxConsoleAppTraitsBase::HasStderr()
|
||||
{
|
||||
// console applications always have stderr, even under Mac/Windows
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxConsoleAppTraitsBase::ScheduleForDestroy(wxObject *object)
|
||||
{
|
||||
delete object;
|
||||
}
|
||||
|
||||
void wxConsoleAppTraitsBase::RemoveFromPendingDelete(wxObject * WXUNUSED(object))
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxAppTraits
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
|
||||
bool wxAppTraitsBase::ShowAssertDialog(const wxString& msg)
|
||||
{
|
||||
return DoShowAssertDialog(msg);
|
||||
}
|
||||
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
wxAppTraits *wxAppTraitsBase::CreateConsole()
|
||||
{
|
||||
return new wxConsoleAppTraits;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// global functions implementation
|
||||
// ============================================================================
|
||||
|
||||
void wxExit()
|
||||
{
|
||||
if ( wxTheApp )
|
||||
{
|
||||
wxTheApp->Exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
// what else can we do?
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
void wxWakeUpIdle()
|
||||
{
|
||||
if ( wxTheApp )
|
||||
{
|
||||
wxTheApp->WakeUpIdle();
|
||||
}
|
||||
//else: do nothing, what can we do?
|
||||
}
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
|
||||
// wxASSERT() helper
|
||||
bool wxAssertIsEqual(int x, int y)
|
||||
{
|
||||
return x == y;
|
||||
}
|
||||
|
||||
// break into the debugger
|
||||
void wxTrap()
|
||||
{
|
||||
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
|
||||
DebugBreak();
|
||||
#elif defined(__WXMAC__) && !defined(__DARWIN__)
|
||||
#if __powerc
|
||||
Debugger();
|
||||
#else
|
||||
SysBreak();
|
||||
#endif
|
||||
#elif defined(__UNIX__)
|
||||
raise(SIGTRAP);
|
||||
#else
|
||||
// TODO
|
||||
#endif // Win/Unix
|
||||
}
|
||||
|
||||
void wxAssert(int cond,
|
||||
const wxChar *szFile,
|
||||
int nLine,
|
||||
const wxChar *szCond,
|
||||
const wxChar *szMsg)
|
||||
{
|
||||
if ( !cond )
|
||||
wxOnAssert(szFile, nLine, szCond, szMsg);
|
||||
}
|
||||
|
||||
// this function is called when an assert fails
|
||||
void wxOnAssert(const wxChar *szFile,
|
||||
int nLine,
|
||||
const wxChar *szCond,
|
||||
const wxChar *szMsg)
|
||||
{
|
||||
// FIXME MT-unsafe
|
||||
static bool s_bInAssert = FALSE;
|
||||
|
||||
if ( s_bInAssert )
|
||||
{
|
||||
// He-e-e-e-elp!! we're trapped in endless loop
|
||||
wxTrap();
|
||||
|
||||
s_bInAssert = FALSE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
s_bInAssert = TRUE;
|
||||
|
||||
if ( !wxTheApp )
|
||||
{
|
||||
// by default, show the assert dialog box -- we can't customize this
|
||||
// behaviour
|
||||
ShowAssertDialog(szFile, nLine, szCond, szMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
// let the app process it as it wants
|
||||
wxTheApp->OnAssert(szFile, nLine, szCond, szMsg);
|
||||
}
|
||||
|
||||
s_bInAssert = FALSE;
|
||||
}
|
||||
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
// ============================================================================
|
||||
// private functions implementation
|
||||
// ============================================================================
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
|
||||
static void LINKAGEMODE SetTraceMasks()
|
||||
{
|
||||
#if wxUSE_LOG
|
||||
wxString mask;
|
||||
if ( wxGetEnv(wxT("WXTRACE"), &mask) )
|
||||
{
|
||||
wxStringTokenizer tkn(mask, wxT(",;:"));
|
||||
while ( tkn.HasMoreTokens() )
|
||||
wxLog::AddTraceMask(tkn.GetNextToken());
|
||||
}
|
||||
#endif // wxUSE_LOG
|
||||
}
|
||||
|
||||
bool DoShowAssertDialog(const wxString& msg)
|
||||
{
|
||||
// under MSW we can show the dialog even in the console mode
|
||||
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
|
||||
wxString msgDlg(msg);
|
||||
|
||||
// this message is intentionally not translated -- it is for
|
||||
// developpers only
|
||||
msgDlg += wxT("\nDo you want to stop the program?\n")
|
||||
wxT("You can also choose [Cancel] to suppress ")
|
||||
wxT("further warnings.");
|
||||
|
||||
switch ( ::MessageBox(NULL, msgDlg, _T("wxWindows Debug Alert"),
|
||||
MB_YESNOCANCEL | MB_ICONSTOP ) )
|
||||
{
|
||||
case IDYES:
|
||||
wxTrap();
|
||||
break;
|
||||
|
||||
case IDCANCEL:
|
||||
// stop the asserts
|
||||
return true;
|
||||
|
||||
//case IDNO: nothing to do
|
||||
}
|
||||
#else // !__WXMSW__
|
||||
wxFprintf(stderr, wxT("%s\n"), msg.c_str());
|
||||
fflush(stderr);
|
||||
|
||||
// TODO: ask the user to enter "Y" or "N" on the console?
|
||||
wxTrap();
|
||||
#endif // __WXMSW__/!__WXMSW__
|
||||
|
||||
// continue with the asserts
|
||||
return false;
|
||||
}
|
||||
|
||||
// show the assert modal dialog
|
||||
static
|
||||
void ShowAssertDialog(const wxChar *szFile,
|
||||
int nLine,
|
||||
const wxChar *szCond,
|
||||
const wxChar *szMsg,
|
||||
wxAppTraits *traits)
|
||||
{
|
||||
// this variable can be set to true to suppress "assert failure" messages
|
||||
static bool s_bNoAsserts = FALSE;
|
||||
|
||||
wxString msg;
|
||||
msg.reserve(2048);
|
||||
|
||||
// make life easier for people using VC++ IDE by using this format: like
|
||||
// this, clicking on the message will take us immediately to the place of
|
||||
// the failed assert
|
||||
msg.Printf(wxT("%s(%d): assert \"%s\" failed"), szFile, nLine, szCond);
|
||||
|
||||
if ( szMsg )
|
||||
{
|
||||
msg << _T(": ") << szMsg;
|
||||
}
|
||||
else // no message given
|
||||
{
|
||||
msg << _T('.');
|
||||
}
|
||||
|
||||
#if wxUSE_THREADS
|
||||
// if we are not in the main thread, output the assert directly and trap
|
||||
// since dialogs cannot be displayed
|
||||
if ( !wxThread::IsMain() )
|
||||
{
|
||||
msg += wxT(" [in child thread]");
|
||||
|
||||
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
|
||||
msg << wxT("\r\n");
|
||||
OutputDebugString(msg );
|
||||
#else
|
||||
// send to stderr
|
||||
wxFprintf(stderr, wxT("%s\n"), msg.c_str());
|
||||
fflush(stderr);
|
||||
#endif
|
||||
// He-e-e-e-elp!! we're asserting in a child thread
|
||||
wxTrap();
|
||||
}
|
||||
#endif // wxUSE_THREADS
|
||||
|
||||
if ( !s_bNoAsserts )
|
||||
{
|
||||
// send it to the normal log destination
|
||||
wxLogDebug(_T("%s"), msg);
|
||||
|
||||
if ( traits )
|
||||
{
|
||||
// delegate showing assert dialog (if possible) to that class
|
||||
s_bNoAsserts = traits->ShowAssertDialog(msg);
|
||||
}
|
||||
else // no traits object
|
||||
{
|
||||
// fall back to the function of last resort
|
||||
s_bNoAsserts = DoShowAssertDialog(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __WXDEBUG__
|
||||
|
@ -1,6 +1,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: common/appcmn.cpp
|
||||
// Purpose: wxAppBase methods common to all platforms
|
||||
// Purpose: wxAppConsole and wxAppBase methods common to all platforms
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 18.10.99
|
||||
@ -32,45 +32,20 @@
|
||||
#include "wx/app.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/list.h"
|
||||
#if wxUSE_LOG
|
||||
#include "wx/log.h"
|
||||
#endif // wxUSE_LOG
|
||||
#if wxUSE_GUI
|
||||
#include "wx/msgdlg.h"
|
||||
#endif // wxUSE_GUI
|
||||
#include "wx/msgdlg.h"
|
||||
#endif
|
||||
|
||||
#include "wx/cmdline.h"
|
||||
#include "wx/thread.h"
|
||||
#include "wx/confbase.h"
|
||||
#include "wx/tokenzr.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/apptrait.h"
|
||||
#if wxUSE_FONTMAP
|
||||
#include "wx/fontmap.h"
|
||||
#endif // wxUSE_FONTMAP
|
||||
#include "wx/msgout.h"
|
||||
#include "wx/thread.h"
|
||||
#include "wx/utils.h"
|
||||
|
||||
#if wxUSE_GUI
|
||||
#include "wx/artprov.h"
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
#if !defined(__WXMSW__) || defined(__WXMICROWIN__)
|
||||
#include <signal.h> // for SIGTRAP used by wxTrap()
|
||||
#endif //Win/Unix
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/private.h" // includes windows.h for MessageBox()
|
||||
#endif
|
||||
|
||||
#if defined(__WXMAC__)
|
||||
#include "wx/mac/private.h" // includes mac headers
|
||||
#endif
|
||||
|
||||
// private functions prototypes
|
||||
#ifdef __WXDEBUG__
|
||||
static void LINKAGEMODE SetTraceMasks();
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
// ===========================================================================
|
||||
// implementation
|
||||
// ===========================================================================
|
||||
// ============================================================================
|
||||
// wxAppBase implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// initialization and termination
|
||||
@ -78,13 +53,6 @@
|
||||
|
||||
wxAppBase::wxAppBase()
|
||||
{
|
||||
wxTheApp = (wxApp *)this;
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_2
|
||||
m_wantDebugOutput = FALSE;
|
||||
#endif // WXWIN_COMPATIBILITY_2_2
|
||||
|
||||
#if wxUSE_GUI
|
||||
m_topWindow = (wxWindow *)NULL;
|
||||
m_useBestVisual = FALSE;
|
||||
m_isActive = TRUE;
|
||||
@ -102,11 +70,6 @@ wxAppBase::wxAppBase()
|
||||
// safely (i.e. without losing the effect of the users SetExitOnFrameDelete
|
||||
// call) overwrite in OnRun()
|
||||
m_exitOnFrameDelete = Later;
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
SetTraceMasks();
|
||||
#endif
|
||||
}
|
||||
|
||||
wxAppBase::~wxAppBase()
|
||||
@ -114,8 +77,6 @@ wxAppBase::~wxAppBase()
|
||||
// this destructor is required for Darwin
|
||||
}
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
bool wxAppBase::OnInitGui()
|
||||
{
|
||||
#ifdef __WXUNIVERSAL__
|
||||
@ -139,103 +100,20 @@ int wxAppBase::OnRun()
|
||||
return MainLoop();
|
||||
}
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
int wxAppBase::OnExit()
|
||||
void wxAppBase::Exit()
|
||||
{
|
||||
#if wxUSE_CONFIG
|
||||
// delete the config object if any (don't use Get() here, but Set()
|
||||
// because Get() could create a new config object)
|
||||
delete wxConfigBase::Set((wxConfigBase *) NULL);
|
||||
#endif // wxUSE_CONFIG
|
||||
|
||||
#ifdef __WXUNIVERSAL__
|
||||
delete wxTheme::Set(NULL);
|
||||
#endif // __WXUNIVERSAL__
|
||||
|
||||
// use Set(NULL) and not Get() to avoid creating a message output object on
|
||||
// demand when we just want to delete it
|
||||
delete wxMessageOutput::Set(NULL);
|
||||
|
||||
return 0;
|
||||
ExitMainLoop();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// customization hooks
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_LOG
|
||||
|
||||
wxLog *wxAppBase::CreateLogTarget()
|
||||
wxAppTraits *wxAppBase::CreateTraits()
|
||||
{
|
||||
#if wxUSE_GUI && wxUSE_LOGGUI && !defined(__WXMICROWIN__)
|
||||
return new wxLogGui;
|
||||
#else // !GUI
|
||||
return new wxLogStderr;
|
||||
#endif // wxUSE_GUI
|
||||
}
|
||||
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
wxMessageOutput *wxAppBase::CreateMessageOutput()
|
||||
{
|
||||
// The standard way of printing help on command line arguments (app --help)
|
||||
// is (according to common practice):
|
||||
// - console apps: to stderr (on any platform)
|
||||
// - GUI apps: stderr on Unix platforms (!)
|
||||
// message box under Windows and others
|
||||
#if wxUSE_GUI && !defined(__UNIX__)
|
||||
// wxMessageOutputMessageBox doesn't work under Motif
|
||||
#ifdef __WXMOTIF__
|
||||
return new wxMessageOutputLog;
|
||||
#else
|
||||
return new wxMessageOutputMessageBox;
|
||||
#endif
|
||||
#else // !wxUSE_GUI || __UNIX__
|
||||
return new wxMessageOutputStderr;
|
||||
#endif
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxAppBase
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxAppBase::ProcessPendingEvents()
|
||||
{
|
||||
// ensure that we're the only thread to modify the pending events list
|
||||
wxENTER_CRIT_SECT( *wxPendingEventsLocker );
|
||||
|
||||
if ( !wxPendingEvents )
|
||||
{
|
||||
wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
|
||||
return;
|
||||
}
|
||||
|
||||
// iterate until the list becomes empty
|
||||
wxNode *node = wxPendingEvents->GetFirst();
|
||||
while (node)
|
||||
{
|
||||
wxEvtHandler *handler = (wxEvtHandler *)node->GetData();
|
||||
delete node;
|
||||
|
||||
// In ProcessPendingEvents(), new handlers might be add
|
||||
// and we can safely leave the critical section here.
|
||||
wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
|
||||
handler->ProcessPendingEvents();
|
||||
wxENTER_CRIT_SECT( *wxPendingEventsLocker );
|
||||
|
||||
node = wxPendingEvents->GetFirst();
|
||||
}
|
||||
|
||||
wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
|
||||
return wxAppTraits::CreateGUI();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// misc
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
void wxAppBase::SetActive(bool active, wxWindow * WXUNUSED(lastFocus))
|
||||
{
|
||||
if ( active == m_isActive )
|
||||
@ -249,414 +127,112 @@ void wxAppBase::SetActive(bool active, wxWindow * WXUNUSED(lastFocus))
|
||||
(void)ProcessEvent(event);
|
||||
}
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
int wxAppBase::FilterEvent(wxEvent& WXUNUSED(event))
|
||||
{
|
||||
// process the events normally by default
|
||||
return -1;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// cmd line parsing
|
||||
// wxGUIAppTraitsBase
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxAppBase::OnInit()
|
||||
{
|
||||
#if wxUSE_CMDLINE_PARSER
|
||||
wxCmdLineParser parser(argc, argv);
|
||||
|
||||
OnInitCmdLine(parser);
|
||||
|
||||
bool cont;
|
||||
switch ( parser.Parse(FALSE /* don't show usage */) )
|
||||
{
|
||||
case -1:
|
||||
cont = OnCmdLineHelp(parser);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
cont = OnCmdLineParsed(parser);
|
||||
break;
|
||||
|
||||
default:
|
||||
cont = OnCmdLineError(parser);
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !cont )
|
||||
return FALSE;
|
||||
#endif // wxUSE_CMDLINE_PARSER
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if wxUSE_CMDLINE_PARSER
|
||||
|
||||
#define OPTION_VERBOSE _T("verbose")
|
||||
#define OPTION_THEME _T("theme")
|
||||
#define OPTION_MODE _T("mode")
|
||||
|
||||
void wxAppBase::OnInitCmdLine(wxCmdLineParser& parser)
|
||||
{
|
||||
// the standard command line options
|
||||
static const wxCmdLineEntryDesc cmdLineDesc[] =
|
||||
{
|
||||
{
|
||||
wxCMD_LINE_SWITCH,
|
||||
_T("h"),
|
||||
_T("help"),
|
||||
gettext_noop("show this help message"),
|
||||
wxCMD_LINE_VAL_NONE,
|
||||
wxCMD_LINE_OPTION_HELP
|
||||
},
|
||||
|
||||
#if wxUSE_LOG
|
||||
{
|
||||
wxCMD_LINE_SWITCH,
|
||||
_T(""),
|
||||
OPTION_VERBOSE,
|
||||
gettext_noop("generate verbose log messages"),
|
||||
wxCMD_LINE_VAL_NONE,
|
||||
0x0
|
||||
},
|
||||
|
||||
wxLog *wxGUIAppTraitsBase::CreateLogTarget()
|
||||
{
|
||||
return new wxLogGui;
|
||||
}
|
||||
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
#ifdef __WXUNIVERSAL__
|
||||
{
|
||||
wxCMD_LINE_OPTION,
|
||||
_T(""),
|
||||
OPTION_THEME,
|
||||
gettext_noop("specify the theme to use"),
|
||||
wxCMD_LINE_VAL_STRING,
|
||||
0x0
|
||||
},
|
||||
#endif // __WXUNIVERSAL__
|
||||
|
||||
#if defined(__WXMGL__)
|
||||
// VS: this is not specific to wxMGL, all fullscreen (framebuffer) ports
|
||||
// should provide this option. That's why it is in common/appcmn.cpp
|
||||
// and not mgl/app.cpp
|
||||
{
|
||||
wxCMD_LINE_OPTION,
|
||||
_T(""),
|
||||
OPTION_MODE,
|
||||
gettext_noop("specify display mode to use (e.g. 640x480-16)"),
|
||||
wxCMD_LINE_VAL_STRING,
|
||||
0x0
|
||||
},
|
||||
#endif // __WXMGL__
|
||||
|
||||
// terminator
|
||||
{
|
||||
wxCMD_LINE_NONE,
|
||||
_T(""),
|
||||
_T(""),
|
||||
_T(""),
|
||||
wxCMD_LINE_VAL_NONE,
|
||||
0x0
|
||||
}
|
||||
};
|
||||
|
||||
parser.SetDesc(cmdLineDesc);
|
||||
wxMessageOutput *wxGUIAppTraitsBase::CreateMessageOutput()
|
||||
{
|
||||
// The standard way of printing help on command line arguments (app --help)
|
||||
// is (according to common practice):
|
||||
// - console apps: to stderr (on any platform)
|
||||
// - GUI apps: stderr on Unix platforms (!)
|
||||
// message box under Windows and others
|
||||
#ifdef __UNIX__
|
||||
return new wxMessageOutputStderr;
|
||||
#else // !__UNIX__
|
||||
// wxMessageOutputMessageBox doesn't work under Motif
|
||||
#ifdef __WXMOTIF__
|
||||
return new wxMessageOutputLog;
|
||||
#else
|
||||
return new wxMessageOutputMessageBox;
|
||||
#endif
|
||||
#endif // __UNIX__/!__UNIX__
|
||||
}
|
||||
|
||||
bool wxAppBase::OnCmdLineParsed(wxCmdLineParser& parser)
|
||||
#if wxUSE_FONTMAP
|
||||
|
||||
wxFontMapper *wxGUIAppTraitsBase::CreateFontMapper()
|
||||
{
|
||||
#if wxUSE_LOG
|
||||
if ( parser.Found(OPTION_VERBOSE) )
|
||||
{
|
||||
wxLog::SetVerbose(TRUE);
|
||||
}
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
#ifdef __WXUNIVERSAL__
|
||||
wxString themeName;
|
||||
if ( parser.Found(OPTION_THEME, &themeName) )
|
||||
{
|
||||
wxTheme *theme = wxTheme::Create(themeName);
|
||||
if ( !theme )
|
||||
{
|
||||
wxLogError(_("Unsupported theme '%s'."), themeName.c_str());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Delete the defaultly created theme and set the new theme.
|
||||
delete wxTheme::Get();
|
||||
wxTheme::Set(theme);
|
||||
}
|
||||
#endif // __WXUNIVERSAL__
|
||||
|
||||
#if defined(__WXMGL__)
|
||||
wxString modeDesc;
|
||||
if ( parser.Found(OPTION_MODE, &modeDesc) )
|
||||
{
|
||||
unsigned w, h, bpp;
|
||||
if ( wxSscanf(modeDesc.c_str(), _T("%ux%u-%u"), &w, &h, &bpp) != 3 )
|
||||
{
|
||||
wxLogError(_("Invalid display mode specification '%s'."), modeDesc.c_str());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !SetDisplayMode(wxDisplayModeInfo(w, h, bpp)) )
|
||||
return FALSE;
|
||||
}
|
||||
#endif // __WXMGL__
|
||||
|
||||
return TRUE;
|
||||
return new wxFontMapper;
|
||||
}
|
||||
|
||||
bool wxAppBase::OnCmdLineHelp(wxCmdLineParser& parser)
|
||||
{
|
||||
parser.Usage();
|
||||
#endif // wxUSE_FONTMAP
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxAppBase::OnCmdLineError(wxCmdLineParser& parser)
|
||||
{
|
||||
parser.Usage();
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif // wxUSE_CMDLINE_PARSER
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// debugging support
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/* static */
|
||||
bool wxAppBase::CheckBuildOptions(const wxBuildOptions& opts)
|
||||
{
|
||||
#define wxCMP(what) (what == opts.m_ ## what)
|
||||
|
||||
bool
|
||||
#ifdef __WXDEBUG__
|
||||
isDebug = TRUE;
|
||||
|
||||
bool wxGUIAppTraitsBase::ShowAssertDialog(const wxString& msg)
|
||||
{
|
||||
// under MSW we prefer to use the base class version using ::MessageBox()
|
||||
// even if wxMessageBox() is available because it has less chances to
|
||||
// double fault our app than our wxMessageBox()
|
||||
#if defined(__WXMSW__) || !wxUSE_MSGDLG
|
||||
return wxAppTraitsBase::ShowAssertDialog(msg);
|
||||
#else // wxUSE_MSGDLG
|
||||
// this message is intentionally not translated -- it is for
|
||||
// developpers only
|
||||
wxString msgDlg(msg);
|
||||
msgDlg += wxT("\nDo you want to stop the program?\n")
|
||||
wxT("You can also choose [Cancel] to suppress ")
|
||||
wxT("further warnings.");
|
||||
|
||||
switch ( wxMessageBox(msgDlg, wxT("wxWindows Debug Alert"),
|
||||
wxYES_NO | wxCANCEL | wxICON_STOP ) )
|
||||
{
|
||||
case wxYES:
|
||||
wxTrap();
|
||||
break;
|
||||
|
||||
case wxCANCEL:
|
||||
// no more asserts
|
||||
return true;
|
||||
|
||||
//case wxNO: nothing to do
|
||||
}
|
||||
|
||||
return false;
|
||||
#endif // !wxUSE_MSGDLG/wxUSE_MSGDLG
|
||||
}
|
||||
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
bool wxGUIAppTraitsBase::HasStderr()
|
||||
{
|
||||
// we consider that under Unix stderr always goes somewhere, even if the
|
||||
// user doesn't always see it under GUI desktops
|
||||
#ifdef __UNIX__
|
||||
return true;
|
||||
#else
|
||||
isDebug = FALSE;
|
||||
return false;
|
||||
#endif
|
||||
|
||||
int verMaj = wxMAJOR_VERSION,
|
||||
verMin = wxMINOR_VERSION;
|
||||
|
||||
if ( !(wxCMP(isDebug) && wxCMP(verMaj) && wxCMP(verMin)) )
|
||||
{
|
||||
wxString msg;
|
||||
wxString libDebug, progDebug;
|
||||
|
||||
if (isDebug)
|
||||
libDebug = wxT("debug");
|
||||
else
|
||||
libDebug = wxT("no debug");
|
||||
|
||||
if (opts.m_isDebug)
|
||||
progDebug = wxT("debug");
|
||||
else
|
||||
progDebug = wxT("no debug");
|
||||
|
||||
msg.Printf(_T("Mismatch between the program and library build versions detected.\nThe library used %d.%d (%s), and your program used %d.%d (%s)."),
|
||||
verMaj, verMin, libDebug.c_str(), opts.m_verMaj, opts.m_verMin, progDebug.c_str());
|
||||
|
||||
wxLogFatalError(msg);
|
||||
|
||||
// normally wxLogFatalError doesn't return
|
||||
return FALSE;
|
||||
}
|
||||
#undef wxCMP
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
|
||||
static void LINKAGEMODE SetTraceMasks()
|
||||
void wxGUIAppTraitsBase::ScheduleForDestroy(wxObject *object)
|
||||
{
|
||||
#if wxUSE_LOG
|
||||
wxString mask;
|
||||
if ( wxGetEnv(wxT("WXTRACE"), &mask) )
|
||||
{
|
||||
wxStringTokenizer tkn(mask, wxT(","));
|
||||
while ( tkn.HasMoreTokens() )
|
||||
wxLog::AddTraceMask(tkn.GetNextToken());
|
||||
}
|
||||
#endif // wxUSE_LOG
|
||||
if ( !wxPendingDelete.Member(object) )
|
||||
wxPendingDelete.Append(object);
|
||||
}
|
||||
|
||||
// wxASSERT() helper
|
||||
bool wxAssertIsEqual(int x, int y)
|
||||
void wxGUIAppTraitsBase::RemoveFromPendingDelete(wxObject *object)
|
||||
{
|
||||
return x == y;
|
||||
wxPendingDelete.DeleteObject(object);
|
||||
}
|
||||
|
||||
// break into the debugger
|
||||
void wxTrap()
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxAppTraits
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxAppTraits *wxAppTraitsBase::CreateGUI()
|
||||
{
|
||||
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
|
||||
DebugBreak();
|
||||
#elif defined(__WXMAC__) && !defined(__DARWIN__)
|
||||
#if __powerc
|
||||
Debugger();
|
||||
#else
|
||||
SysBreak();
|
||||
#endif
|
||||
#elif defined(__UNIX__)
|
||||
raise(SIGTRAP);
|
||||
#else
|
||||
// TODO
|
||||
#endif // Win/Unix
|
||||
return new wxGUIAppTraits;
|
||||
}
|
||||
|
||||
|
||||
void wxAssert(int cond,
|
||||
const wxChar *szFile,
|
||||
int nLine,
|
||||
const wxChar *szCond,
|
||||
const wxChar *szMsg)
|
||||
{
|
||||
if ( !cond )
|
||||
wxOnAssert(szFile, nLine, szCond, szMsg);
|
||||
}
|
||||
|
||||
// show the assert modal dialog
|
||||
static
|
||||
void ShowAssertDialog(const wxChar *szFile,
|
||||
int nLine,
|
||||
const wxChar *szCond,
|
||||
const wxChar *szMsg)
|
||||
{
|
||||
// this variable can be set to true to suppress "assert failure" messages
|
||||
static bool s_bNoAsserts = FALSE;
|
||||
|
||||
wxChar szBuf[4096];
|
||||
|
||||
// make life easier for people using VC++ IDE by using this format: like
|
||||
// this, clicking on the message will take us immediately to the place of
|
||||
// the failed assert
|
||||
wxSnprintf(szBuf, WXSIZEOF(szBuf),
|
||||
wxT("%s(%d): assert \"%s\" failed"),
|
||||
szFile, nLine, szCond);
|
||||
|
||||
if ( szMsg != NULL )
|
||||
{
|
||||
wxStrcat(szBuf, wxT(": "));
|
||||
wxStrcat(szBuf, szMsg);
|
||||
}
|
||||
else // no message given
|
||||
{
|
||||
wxStrcat(szBuf, wxT("."));
|
||||
}
|
||||
|
||||
#if wxUSE_THREADS
|
||||
// if we are not in the main thread,
|
||||
// output the assert directly and trap since dialogs cannot be displayed
|
||||
if (!wxThread::IsMain()) {
|
||||
wxStrcat(szBuf, wxT(" [in child thread]"));
|
||||
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
|
||||
wxStrcat(szBuf, wxT("\r\n"));
|
||||
OutputDebugString(szBuf);
|
||||
#else
|
||||
// send to stderr
|
||||
wxFprintf(stderr, wxT("%s\n"), szBuf);
|
||||
fflush(stderr);
|
||||
#endif
|
||||
// He-e-e-e-elp!! we're asserting in a child thread
|
||||
wxTrap();
|
||||
}
|
||||
#endif // wxUSE_THREADS
|
||||
|
||||
if ( !s_bNoAsserts )
|
||||
{
|
||||
// send it to the normal log destination
|
||||
wxLogDebug(szBuf);
|
||||
|
||||
#if (wxUSE_GUI && wxUSE_MSGDLG) || defined(__WXMSW__)
|
||||
// this message is intentionally not translated - it is for
|
||||
// developpers only
|
||||
wxStrcat(szBuf, wxT("\nDo you want to stop the program?\nYou can also choose [Cancel] to suppress further warnings."));
|
||||
|
||||
// use the native message box if available: this is more robust than
|
||||
// using our own
|
||||
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
|
||||
switch ( ::MessageBox(NULL, szBuf, _T("Debug"),
|
||||
MB_YESNOCANCEL | MB_ICONSTOP ) )
|
||||
{
|
||||
case IDYES:
|
||||
wxTrap();
|
||||
break;
|
||||
|
||||
case IDCANCEL:
|
||||
s_bNoAsserts = TRUE;
|
||||
break;
|
||||
|
||||
//case IDNO: nothing to do
|
||||
}
|
||||
#else // !MSW
|
||||
switch ( wxMessageBox(szBuf, wxT("Debug"),
|
||||
wxYES_NO | wxCANCEL | wxICON_STOP ) )
|
||||
{
|
||||
case wxYES:
|
||||
wxTrap();
|
||||
break;
|
||||
|
||||
case wxCANCEL:
|
||||
s_bNoAsserts = TRUE;
|
||||
break;
|
||||
|
||||
//case wxNO: nothing to do
|
||||
}
|
||||
#endif // GUI or MSW
|
||||
|
||||
#else // !GUI
|
||||
wxTrap();
|
||||
#endif // GUI/!GUI
|
||||
}
|
||||
}
|
||||
|
||||
// this function is called when an assert fails
|
||||
void wxOnAssert(const wxChar *szFile,
|
||||
int nLine,
|
||||
const wxChar *szCond,
|
||||
const wxChar *szMsg)
|
||||
{
|
||||
// FIXME MT-unsafe
|
||||
static bool s_bInAssert = FALSE;
|
||||
|
||||
if ( s_bInAssert )
|
||||
{
|
||||
// He-e-e-e-elp!! we're trapped in endless loop
|
||||
wxTrap();
|
||||
|
||||
s_bInAssert = FALSE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
s_bInAssert = TRUE;
|
||||
|
||||
if ( !wxTheApp )
|
||||
{
|
||||
// by default, show the assert dialog box - we can't customize this
|
||||
// behaviour
|
||||
ShowAssertDialog(szFile, nLine, szCond, szMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
// let the app process it as it wants
|
||||
wxTheApp->OnAssert(szFile, nLine, szCond, szMsg);
|
||||
}
|
||||
|
||||
s_bInAssert = FALSE;
|
||||
}
|
||||
|
||||
void wxAppBase::OnAssert(const wxChar *file,
|
||||
int line,
|
||||
const wxChar *cond,
|
||||
const wxChar *msg)
|
||||
{
|
||||
ShowAssertDialog(file, line, cond, msg);
|
||||
}
|
||||
|
||||
#endif //WXDEBUG
|
||||
|
||||
|
@ -50,23 +50,6 @@ protected:
|
||||
#define ART(artId, xpmRc) \
|
||||
if ( id == artId ) return wxBitmap(xpmRc##_xpm);
|
||||
|
||||
// Compatibility hack to use wxApp::GetStdIcon of overriden by the user
|
||||
#if WXWIN_COMPATIBILITY_2_2
|
||||
#define GET_STD_ICON_FROM_APP(iconId) \
|
||||
if ( client == wxART_MESSAGE_BOX ) \
|
||||
{ \
|
||||
wxIcon icon = wxTheApp->GetStdIcon(iconId); \
|
||||
if ( icon.Ok() ) \
|
||||
{ \
|
||||
wxBitmap bmp; \
|
||||
bmp.CopyFromIcon(icon); \
|
||||
return bmp; \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define GET_STD_ICON_FROM_APP(iconId)
|
||||
#endif
|
||||
|
||||
// There are two ways of getting the standard icon: either via XPMs or via
|
||||
// wxIcon ctor. This depends on the platform:
|
||||
#if defined(__WXUNIVERSAL__)
|
||||
@ -87,7 +70,6 @@ protected:
|
||||
#define ART_MSGBOX(artId, iconId, xpmRc) \
|
||||
if ( id == artId ) \
|
||||
{ \
|
||||
GET_STD_ICON_FROM_APP(iconId) \
|
||||
CREATE_STD_ICON(#iconId, xpmRc) \
|
||||
}
|
||||
|
||||
|
642
src/common/fmapbase.cpp
Normal file
642
src/common/fmapbase.cpp
Normal file
@ -0,0 +1,642 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: common/fmapbase.cpp
|
||||
// Purpose: wxFontMapperBase class implementation
|
||||
// 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>
|
||||
// License: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// for compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_FONTMAP
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/intl.h"
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#include "wx/fontmap.h"
|
||||
#include "wx/fmappriv.h"
|
||||
|
||||
#include "wx/apptrait.h"
|
||||
#include "wx/module.h"
|
||||
|
||||
#if wxUSE_CONFIG
|
||||
#include "wx/config.h"
|
||||
#include "wx/memconf.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// encodings supported by GetEncodingDescription
|
||||
static wxFontEncoding gs_encodings[] =
|
||||
{
|
||||
wxFONTENCODING_ISO8859_1,
|
||||
wxFONTENCODING_ISO8859_2,
|
||||
wxFONTENCODING_ISO8859_3,
|
||||
wxFONTENCODING_ISO8859_4,
|
||||
wxFONTENCODING_ISO8859_5,
|
||||
wxFONTENCODING_ISO8859_6,
|
||||
wxFONTENCODING_ISO8859_7,
|
||||
wxFONTENCODING_ISO8859_8,
|
||||
wxFONTENCODING_ISO8859_9,
|
||||
wxFONTENCODING_ISO8859_10,
|
||||
wxFONTENCODING_ISO8859_11,
|
||||
wxFONTENCODING_ISO8859_12,
|
||||
wxFONTENCODING_ISO8859_13,
|
||||
wxFONTENCODING_ISO8859_14,
|
||||
wxFONTENCODING_ISO8859_15,
|
||||
wxFONTENCODING_KOI8,
|
||||
wxFONTENCODING_CP932,
|
||||
wxFONTENCODING_CP936,
|
||||
wxFONTENCODING_CP949,
|
||||
wxFONTENCODING_CP950,
|
||||
wxFONTENCODING_CP1250,
|
||||
wxFONTENCODING_CP1251,
|
||||
wxFONTENCODING_CP1252,
|
||||
wxFONTENCODING_CP1253,
|
||||
wxFONTENCODING_CP1254,
|
||||
wxFONTENCODING_CP1255,
|
||||
wxFONTENCODING_CP1256,
|
||||
wxFONTENCODING_CP1257,
|
||||
wxFONTENCODING_CP437,
|
||||
wxFONTENCODING_UTF7,
|
||||
wxFONTENCODING_UTF8,
|
||||
wxFONTENCODING_EUC_JP,
|
||||
};
|
||||
|
||||
// the descriptions for them
|
||||
static const wxChar* gs_encodingDescs[] =
|
||||
{
|
||||
wxTRANSLATE( "Western European (ISO-8859-1)" ),
|
||||
wxTRANSLATE( "Central European (ISO-8859-2)" ),
|
||||
wxTRANSLATE( "Esperanto (ISO-8859-3)" ),
|
||||
wxTRANSLATE( "Baltic (old) (ISO-8859-4)" ),
|
||||
wxTRANSLATE( "Cyrillic (ISO-8859-5)" ),
|
||||
wxTRANSLATE( "Arabic (ISO-8859-6)" ),
|
||||
wxTRANSLATE( "Greek (ISO-8859-7)" ),
|
||||
wxTRANSLATE( "Hebrew (ISO-8859-8)" ),
|
||||
wxTRANSLATE( "Turkish (ISO-8859-9)" ),
|
||||
wxTRANSLATE( "Nordic (ISO-8859-10)" ),
|
||||
wxTRANSLATE( "Thai (ISO-8859-11)" ),
|
||||
wxTRANSLATE( "Indian (ISO-8859-12)" ),
|
||||
wxTRANSLATE( "Baltic (ISO-8859-13)" ),
|
||||
wxTRANSLATE( "Celtic (ISO-8859-14)" ),
|
||||
wxTRANSLATE( "Western European with Euro (ISO-8859-15)" ),
|
||||
wxTRANSLATE( "KOI8-R" ),
|
||||
wxTRANSLATE( "Windows Japanese (CP 932)" ),
|
||||
wxTRANSLATE( "Windows Chinese Simplified (CP 936)" ),
|
||||
wxTRANSLATE( "Windows Korean (CP 949)" ),
|
||||
wxTRANSLATE( "Windows Chinese Traditional (CP 950)" ),
|
||||
wxTRANSLATE( "Windows Central European (CP 1250)" ),
|
||||
wxTRANSLATE( "Windows Cyrillic (CP 1251)" ),
|
||||
wxTRANSLATE( "Windows Western European (CP 1252)" ),
|
||||
wxTRANSLATE( "Windows Greek (CP 1253)" ),
|
||||
wxTRANSLATE( "Windows Turkish (CP 1254)" ),
|
||||
wxTRANSLATE( "Windows Hebrew (CP 1255)" ),
|
||||
wxTRANSLATE( "Windows Arabic (CP 1256)" ),
|
||||
wxTRANSLATE( "Windows Baltic (CP 1257)" ),
|
||||
wxTRANSLATE( "Windows/DOS OEM (CP 437)" ),
|
||||
wxTRANSLATE( "Unicode 7 bit (UTF-7)" ),
|
||||
wxTRANSLATE( "Unicode 8 bit (UTF-8)" ),
|
||||
wxTRANSLATE( "Extended Unix Codepage for Japanese (EUC-JP)" ),
|
||||
};
|
||||
|
||||
// and the internal names (these are not translated on purpose!)
|
||||
static const wxChar* gs_encodingNames[] =
|
||||
{
|
||||
wxT( "iso-8859-1" ),
|
||||
wxT( "iso-8859-2" ),
|
||||
wxT( "iso-8859-3" ),
|
||||
wxT( "iso-8859-4" ),
|
||||
wxT( "iso-8859-5" ),
|
||||
wxT( "iso-8859-6" ),
|
||||
wxT( "iso-8859-7" ),
|
||||
wxT( "iso-8859-8" ),
|
||||
wxT( "iso-8859-9" ),
|
||||
wxT( "iso-8859-10" ),
|
||||
wxT( "iso-8859-11" ),
|
||||
wxT( "iso-8859-12" ),
|
||||
wxT( "iso-8859-13" ),
|
||||
wxT( "iso-8859-14" ),
|
||||
wxT( "iso-8859-15" ),
|
||||
wxT( "koi8-r" ),
|
||||
wxT( "windows-932" ),
|
||||
wxT( "windows-936" ),
|
||||
wxT( "windows-949" ),
|
||||
wxT( "windows-950" ),
|
||||
wxT( "windows-1250" ),
|
||||
wxT( "windows-1251" ),
|
||||
wxT( "windows-1252" ),
|
||||
wxT( "windows-1253" ),
|
||||
wxT( "windows-1254" ),
|
||||
wxT( "windows-1255" ),
|
||||
wxT( "windows-1256" ),
|
||||
wxT( "windows-1257" ),
|
||||
wxT( "windows-437" ),
|
||||
wxT( "utf-7" ),
|
||||
wxT( "utf-8" ),
|
||||
wxT( "euc-jp" ),
|
||||
};
|
||||
|
||||
wxCOMPILE_TIME_ASSERT( WXSIZEOF(gs_encodingDescs) == WXSIZEOF(gs_encodings) &&
|
||||
WXSIZEOF(gs_encodingNames) == WXSIZEOF(gs_encodings),
|
||||
EncodingsArraysNotInSync );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// private classes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// clean up the font mapper object
|
||||
class wxFontMapperModule : public wxModule
|
||||
{
|
||||
public:
|
||||
wxFontMapperModule() : wxModule() { }
|
||||
virtual bool OnInit() { return TRUE; }
|
||||
virtual void OnExit() { delete wxFontMapper::Set(NULL); }
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxFontMapperModule)
|
||||
};
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFontMapperModule, wxModule)
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// wxFontMapperBase implementation
|
||||
// ============================================================================
|
||||
|
||||
wxFontMapper *wxFontMapperBase::sm_instance = NULL;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ctor and dtor
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxFontMapperBase::wxFontMapperBase()
|
||||
{
|
||||
#if wxUSE_CONFIG
|
||||
m_config = NULL;
|
||||
m_configIsDummy = FALSE;
|
||||
#endif // wxUSE_CONFIG
|
||||
}
|
||||
|
||||
wxFontMapperBase::~wxFontMapperBase()
|
||||
{
|
||||
#if wxUSE_CONFIG
|
||||
if ( m_configIsDummy )
|
||||
delete m_config;
|
||||
#endif // wxUSE_CONFIG
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxFontMapper *wxFontMapperBase::Get()
|
||||
{
|
||||
if ( !sm_instance )
|
||||
{
|
||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||
if ( traits )
|
||||
{
|
||||
sm_instance = traits->CreateFontMapper();
|
||||
|
||||
wxASSERT_MSG( sm_instance,
|
||||
_T("wxAppTraits::CreateFontMapper() failed") );
|
||||
}
|
||||
|
||||
if ( !sm_instance )
|
||||
{
|
||||
// last resort: we must create something because the existing code
|
||||
// relies on always having a valid font mapper object
|
||||
sm_instance = (wxFontMapper *)new wxFontMapperBase;
|
||||
}
|
||||
}
|
||||
|
||||
return sm_instance;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxFontMapper *wxFontMapperBase::Set(wxFontMapper *mapper)
|
||||
{
|
||||
wxFontMapper *old = sm_instance;
|
||||
sm_instance = mapper;
|
||||
return old;
|
||||
}
|
||||
|
||||
#if wxUSE_CONFIG
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// config usage customisation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/* static */
|
||||
const wxChar *wxFontMapperBase::GetDefaultConfigPath()
|
||||
{
|
||||
return FONTMAPPER_ROOT_PATH;
|
||||
}
|
||||
|
||||
void wxFontMapperBase::SetConfigPath(const wxString& prefix)
|
||||
{
|
||||
wxCHECK_RET( !prefix.IsEmpty() && prefix[0] == wxCONFIG_PATH_SEPARATOR,
|
||||
wxT("an absolute path should be given to wxFontMapper::SetConfigPath()") );
|
||||
|
||||
m_configRootPath = prefix;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// get config object and path for it
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxConfigBase *wxFontMapperBase::GetConfig()
|
||||
{
|
||||
if ( !m_config )
|
||||
{
|
||||
// try the default
|
||||
m_config = wxConfig::Get(FALSE /*don't create on demand*/ );
|
||||
|
||||
if ( !m_config )
|
||||
{
|
||||
// we still want to have a config object because otherwise we would
|
||||
// keep asking the user the same questions in the interactive mode,
|
||||
// so create a dummy config which won't write to any files/registry
|
||||
// but will allow us to remember the results of the questions at
|
||||
// least during this run
|
||||
m_config = new wxMemoryConfig;
|
||||
m_configIsDummy = TRUE;
|
||||
// VS: we can't call wxConfig::Set(m_config) here because that would
|
||||
// disable automatic wxConfig instance creation if this code was
|
||||
// called before wxApp::OnInit (this happens in wxGTK -- it sets
|
||||
// default wxFont encoding in wxApp::Initialize())
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_configIsDummy && wxConfig::Get(FALSE) != NULL )
|
||||
{
|
||||
// VS: in case we created dummy m_config (see above), we want to switch back
|
||||
// to the real one as soon as one becomes available.
|
||||
delete m_config;
|
||||
m_config = wxConfig::Get(FALSE);
|
||||
m_configIsDummy = FALSE;
|
||||
// FIXME: ideally, we should add keys from dummy config to the real one now,
|
||||
// but it is a low-priority task because typical wxWin application
|
||||
// either doesn't use wxConfig at all or creates wxConfig object in
|
||||
// wxApp::OnInit(), before any real interaction with the user takes
|
||||
// place...
|
||||
}
|
||||
|
||||
return m_config;
|
||||
}
|
||||
|
||||
const wxString& wxFontMapperBase::GetConfigPath()
|
||||
{
|
||||
if ( !m_configRootPath )
|
||||
{
|
||||
// use the default
|
||||
m_configRootPath = GetDefaultConfigPath();
|
||||
}
|
||||
|
||||
return m_configRootPath;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// config helpers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxFontMapperBase::ChangePath(const wxString& pathNew, wxString *pathOld)
|
||||
{
|
||||
wxConfigBase *config = GetConfig();
|
||||
if ( !config )
|
||||
return FALSE;
|
||||
|
||||
*pathOld = config->GetPath();
|
||||
|
||||
wxString path = GetConfigPath();
|
||||
if ( path.IsEmpty() || path.Last() != wxCONFIG_PATH_SEPARATOR )
|
||||
{
|
||||
path += wxCONFIG_PATH_SEPARATOR;
|
||||
}
|
||||
|
||||
wxASSERT_MSG( !pathNew || (pathNew[0] != wxCONFIG_PATH_SEPARATOR),
|
||||
wxT("should be a relative path") );
|
||||
|
||||
path += pathNew;
|
||||
|
||||
config->SetPath(path);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxFontMapperBase::RestorePath(const wxString& pathOld)
|
||||
{
|
||||
GetConfig()->SetPath(pathOld);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// charset/encoding correspondence
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxFontEncoding
|
||||
wxFontMapperBase::CharsetToEncoding(const wxString& charset,
|
||||
bool WXUNUSED(interactive))
|
||||
{
|
||||
wxFontEncoding encoding = wxFONTENCODING_SYSTEM;
|
||||
|
||||
// we're going to modify it, make a copy
|
||||
wxString cs = charset;
|
||||
|
||||
#if wxUSE_CONFIG
|
||||
// first try the user-defined settings
|
||||
wxFontMapperPathChanger path(this, FONTMAPPER_CHARSET_PATH);
|
||||
if ( path.IsOk() )
|
||||
{
|
||||
wxConfigBase *config = GetConfig();
|
||||
|
||||
// do we have an encoding for this charset?
|
||||
long value = config->Read(charset, -1l);
|
||||
if ( value != -1 )
|
||||
{
|
||||
if ( value == wxFONTENCODING_UNKNOWN )
|
||||
{
|
||||
// don't try to find it, in particular don't ask the user
|
||||
return wxFONTENCODING_SYSTEM;
|
||||
}
|
||||
|
||||
if ( value >= 0 && value <= wxFONTENCODING_MAX )
|
||||
{
|
||||
encoding = (wxFontEncoding)value;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogDebug(wxT("corrupted config data: invalid encoding %ld for charset '%s' ignored"),
|
||||
value, charset.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if ( encoding == wxFONTENCODING_SYSTEM )
|
||||
{
|
||||
// may be we have an alias?
|
||||
config->SetPath(FONTMAPPER_CHARSET_ALIAS_PATH);
|
||||
|
||||
wxString alias = config->Read(charset);
|
||||
if ( !!alias )
|
||||
{
|
||||
// yes, we do - use it instead
|
||||
cs = alias;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // wxUSE_CONFIG
|
||||
|
||||
// if didn't find it there, try to recognize it ourselves
|
||||
if ( encoding == wxFONTENCODING_SYSTEM )
|
||||
{
|
||||
// trim any spaces
|
||||
cs.Trim(true);
|
||||
cs.Trim(false);
|
||||
|
||||
// discard the optional quotes
|
||||
if ( !cs.empty() )
|
||||
{
|
||||
if ( cs[0u] == _T('"') && cs.Last() == _T('"') )
|
||||
{
|
||||
cs = wxString(cs.c_str(), cs.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
cs.MakeUpper();
|
||||
|
||||
if ( cs.empty() || cs == _T("US-ASCII") )
|
||||
{
|
||||
encoding = wxFONTENCODING_DEFAULT;
|
||||
}
|
||||
else if ( cs == wxT("UTF-7") )
|
||||
{
|
||||
encoding = wxFONTENCODING_UTF7;
|
||||
}
|
||||
else if ( cs == wxT("UTF-8") )
|
||||
{
|
||||
encoding = wxFONTENCODING_UTF8;
|
||||
}
|
||||
else if ( cs == wxT("GB2312") )
|
||||
{
|
||||
encoding = wxFONTENCODING_GB2312;
|
||||
}
|
||||
else if ( cs == wxT("BIG5") )
|
||||
{
|
||||
encoding = wxFONTENCODING_BIG5;
|
||||
}
|
||||
else if ( cs == wxT("SJIS") ||
|
||||
cs == wxT("SHIFT_JIS") ||
|
||||
cs == wxT("SHIFT-JIS") )
|
||||
{
|
||||
encoding = wxFONTENCODING_SHIFT_JIS;
|
||||
}
|
||||
else if ( cs == wxT("EUC-JP") ||
|
||||
cs == wxT("EUC_JP") )
|
||||
{
|
||||
encoding = wxFONTENCODING_EUC_JP;
|
||||
}
|
||||
else if ( cs == wxT("KOI8-R") ||
|
||||
cs == wxT("KOI8-U") ||
|
||||
cs == wxT("KOI8-RU") )
|
||||
{
|
||||
// although koi8-ru is not strictly speaking the same as koi8-r,
|
||||
// they are similar enough to make mapping it to koi8 better than
|
||||
// not reckognizing it at all
|
||||
encoding = wxFONTENCODING_KOI8;
|
||||
}
|
||||
else if ( cs.Left(3) == wxT("ISO") )
|
||||
{
|
||||
// the dash is optional (or, to be exact, it is not, but
|
||||
// several brokenmails "forget" it)
|
||||
const wxChar *p = cs.c_str() + 3;
|
||||
if ( *p == wxT('-') )
|
||||
p++;
|
||||
|
||||
// printf( "iso %s\n", (const char*) cs.ToAscii() );
|
||||
|
||||
unsigned int value;
|
||||
if ( wxSscanf(p, wxT("8859-%u"), &value) == 1 )
|
||||
{
|
||||
// printf( "value %d\n", (int)value );
|
||||
|
||||
// make it 0 based and check that it is strictly positive in
|
||||
// the process (no such thing as iso8859-0 encoding)
|
||||
if ( (value-- > 0) &&
|
||||
(value < wxFONTENCODING_ISO8859_MAX -
|
||||
wxFONTENCODING_ISO8859_1) )
|
||||
{
|
||||
// it's a valid ISO8859 encoding
|
||||
value += wxFONTENCODING_ISO8859_1;
|
||||
encoding = (wxFontEncoding)value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( cs.Left(4) == wxT("8859") )
|
||||
{
|
||||
const wxChar *p = cs.c_str();
|
||||
|
||||
unsigned int value;
|
||||
if ( wxSscanf(p, wxT("8859-%u"), &value) == 1 )
|
||||
{
|
||||
// printf( "value %d\n", (int)value );
|
||||
|
||||
// make it 0 based and check that it is strictly positive in
|
||||
// the process (no such thing as iso8859-0 encoding)
|
||||
if ( (value-- > 0) &&
|
||||
(value < wxFONTENCODING_ISO8859_MAX -
|
||||
wxFONTENCODING_ISO8859_1) )
|
||||
{
|
||||
// it's a valid ISO8859 encoding
|
||||
value += wxFONTENCODING_ISO8859_1;
|
||||
encoding = (wxFontEncoding)value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // check for Windows charsets
|
||||
{
|
||||
size_t len;
|
||||
if ( cs.Left(7) == wxT("WINDOWS") )
|
||||
{
|
||||
len = 7;
|
||||
}
|
||||
else if ( cs.Left(2) == wxT("CP") )
|
||||
{
|
||||
len = 2;
|
||||
}
|
||||
else // not a Windows encoding
|
||||
{
|
||||
len = 0;
|
||||
}
|
||||
|
||||
if ( len )
|
||||
{
|
||||
const wxChar *p = cs.c_str() + len;
|
||||
if ( *p == wxT('-') )
|
||||
p++;
|
||||
|
||||
int value;
|
||||
if ( wxSscanf(p, wxT("%u"), &value) == 1 )
|
||||
{
|
||||
if ( value >= 1250 )
|
||||
{
|
||||
value -= 1250;
|
||||
if ( value < wxFONTENCODING_CP12_MAX -
|
||||
wxFONTENCODING_CP1250 )
|
||||
{
|
||||
// a valid Windows code page
|
||||
value += wxFONTENCODING_CP1250;
|
||||
encoding = (wxFontEncoding)value;
|
||||
}
|
||||
}
|
||||
|
||||
switch ( value )
|
||||
{
|
||||
case 932:
|
||||
encoding = wxFONTENCODING_CP932;
|
||||
break;
|
||||
|
||||
case 936:
|
||||
encoding = wxFONTENCODING_CP936;
|
||||
break;
|
||||
|
||||
case 949:
|
||||
encoding = wxFONTENCODING_CP949;
|
||||
break;
|
||||
|
||||
case 950:
|
||||
encoding = wxFONTENCODING_CP950;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//else: unknown
|
||||
}
|
||||
|
||||
return encoding;
|
||||
}
|
||||
|
||||
/* static */
|
||||
size_t wxFontMapperBase::GetSupportedEncodingsCount()
|
||||
{
|
||||
return WXSIZEOF(gs_encodings);
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxFontEncoding wxFontMapperBase::GetEncoding(size_t n)
|
||||
{
|
||||
wxCHECK_MSG( n < WXSIZEOF(gs_encodings), wxFONTENCODING_SYSTEM,
|
||||
_T("wxFontMapper::GetEncoding(): invalid index") );
|
||||
|
||||
return gs_encodings[n];
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxString wxFontMapperBase::GetEncodingDescription(wxFontEncoding encoding)
|
||||
{
|
||||
if ( encoding == wxFONTENCODING_DEFAULT )
|
||||
{
|
||||
return _("Default encoding");
|
||||
}
|
||||
|
||||
const size_t count = WXSIZEOF(gs_encodingDescs);
|
||||
|
||||
for ( size_t i = 0; i < count; i++ )
|
||||
{
|
||||
if ( gs_encodings[i] == encoding )
|
||||
{
|
||||
return wxGetTranslation(gs_encodingDescs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
wxString str;
|
||||
str.Printf(_("Unknown encoding (%d)"), encoding);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxString wxFontMapperBase::GetEncodingName(wxFontEncoding encoding)
|
||||
{
|
||||
if ( encoding == wxFONTENCODING_DEFAULT )
|
||||
{
|
||||
return _("default");
|
||||
}
|
||||
|
||||
const size_t count = WXSIZEOF(gs_encodingNames);
|
||||
|
||||
for ( size_t i = 0; i < count; i++ )
|
||||
{
|
||||
if ( gs_encodings[i] == encoding )
|
||||
{
|
||||
return gs_encodingNames[i];
|
||||
}
|
||||
}
|
||||
|
||||
wxString str;
|
||||
str.Printf(_("unknown-%d"), encoding);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
#endif // wxUSE_CONFIG
|
||||
|
||||
#endif // wxUSE_FONTMAP
|
||||
|
@ -5,7 +5,7 @@
|
||||
// Modified by:
|
||||
// Created: 04.11.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Vadim Zeitlin
|
||||
// Copyright: (c) 1999-2003 Vadim Zeitlin <vadim@wxwindows.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -36,20 +36,17 @@
|
||||
#include "wx/intl.h"
|
||||
#endif // PCH
|
||||
|
||||
#include "wx/module.h"
|
||||
#include "wx/fontmap.h"
|
||||
#include "wx/fmappriv.h"
|
||||
|
||||
#if wxUSE_CONFIG
|
||||
#include "wx/config.h"
|
||||
#include "wx/memconf.h"
|
||||
#endif
|
||||
#endif // wxUSE_CONFIG
|
||||
|
||||
#if wxUSE_GUI
|
||||
#include "wx/fontutil.h"
|
||||
#include "wx/msgdlg.h"
|
||||
#include "wx/fontdlg.h"
|
||||
#include "wx/choicdlg.h"
|
||||
#endif // wxUSE_GUI
|
||||
#include "wx/fontutil.h"
|
||||
#include "wx/msgdlg.h"
|
||||
#include "wx/fontdlg.h"
|
||||
#include "wx/choicdlg.h"
|
||||
|
||||
#include "wx/encconv.h"
|
||||
|
||||
@ -59,160 +56,31 @@
|
||||
|
||||
// the config paths we use
|
||||
#if wxUSE_CONFIG
|
||||
static const wxChar* FONTMAPPER_ROOT_PATH = wxT("/wxWindows/FontMapper");
|
||||
static const wxChar* FONTMAPPER_CHARSET_PATH = wxT("Charsets");
|
||||
static const wxChar* FONTMAPPER_CHARSET_ALIAS_PATH = wxT("Aliases");
|
||||
|
||||
// we only ask questions in GUI mode
|
||||
#if wxUSE_GUI
|
||||
static const wxChar* FONTMAPPER_FONT_FROM_ENCODING_PATH = wxT("Encodings");
|
||||
static const wxChar* FONTMAPPER_FONT_DONT_ASK = wxT("none");
|
||||
#endif // wxUSE_GUI
|
||||
static const wxChar* FONTMAPPER_FONT_FROM_ENCODING_PATH = wxT("Encodings");
|
||||
static const wxChar* FONTMAPPER_FONT_DONT_ASK = wxT("none");
|
||||
|
||||
#endif // wxUSE_CONFIG
|
||||
|
||||
// encodings supported by GetEncodingDescription
|
||||
static wxFontEncoding gs_encodings[] =
|
||||
{
|
||||
wxFONTENCODING_ISO8859_1,
|
||||
wxFONTENCODING_ISO8859_2,
|
||||
wxFONTENCODING_ISO8859_3,
|
||||
wxFONTENCODING_ISO8859_4,
|
||||
wxFONTENCODING_ISO8859_5,
|
||||
wxFONTENCODING_ISO8859_6,
|
||||
wxFONTENCODING_ISO8859_7,
|
||||
wxFONTENCODING_ISO8859_8,
|
||||
wxFONTENCODING_ISO8859_9,
|
||||
wxFONTENCODING_ISO8859_10,
|
||||
wxFONTENCODING_ISO8859_11,
|
||||
wxFONTENCODING_ISO8859_12,
|
||||
wxFONTENCODING_ISO8859_13,
|
||||
wxFONTENCODING_ISO8859_14,
|
||||
wxFONTENCODING_ISO8859_15,
|
||||
wxFONTENCODING_KOI8,
|
||||
wxFONTENCODING_CP932,
|
||||
wxFONTENCODING_CP936,
|
||||
wxFONTENCODING_CP949,
|
||||
wxFONTENCODING_CP950,
|
||||
wxFONTENCODING_CP1250,
|
||||
wxFONTENCODING_CP1251,
|
||||
wxFONTENCODING_CP1252,
|
||||
wxFONTENCODING_CP1253,
|
||||
wxFONTENCODING_CP1254,
|
||||
wxFONTENCODING_CP1255,
|
||||
wxFONTENCODING_CP1256,
|
||||
wxFONTENCODING_CP1257,
|
||||
wxFONTENCODING_CP437,
|
||||
wxFONTENCODING_UTF7,
|
||||
wxFONTENCODING_UTF8,
|
||||
wxFONTENCODING_EUC_JP,
|
||||
};
|
||||
|
||||
// the descriptions for them
|
||||
static const wxChar* gs_encodingDescs[] =
|
||||
{
|
||||
wxTRANSLATE( "Western European (ISO-8859-1)" ),
|
||||
wxTRANSLATE( "Central European (ISO-8859-2)" ),
|
||||
wxTRANSLATE( "Esperanto (ISO-8859-3)" ),
|
||||
wxTRANSLATE( "Baltic (old) (ISO-8859-4)" ),
|
||||
wxTRANSLATE( "Cyrillic (ISO-8859-5)" ),
|
||||
wxTRANSLATE( "Arabic (ISO-8859-6)" ),
|
||||
wxTRANSLATE( "Greek (ISO-8859-7)" ),
|
||||
wxTRANSLATE( "Hebrew (ISO-8859-8)" ),
|
||||
wxTRANSLATE( "Turkish (ISO-8859-9)" ),
|
||||
wxTRANSLATE( "Nordic (ISO-8859-10)" ),
|
||||
wxTRANSLATE( "Thai (ISO-8859-11)" ),
|
||||
wxTRANSLATE( "Indian (ISO-8859-12)" ),
|
||||
wxTRANSLATE( "Baltic (ISO-8859-13)" ),
|
||||
wxTRANSLATE( "Celtic (ISO-8859-14)" ),
|
||||
wxTRANSLATE( "Western European with Euro (ISO-8859-15)" ),
|
||||
wxTRANSLATE( "KOI8-R" ),
|
||||
wxTRANSLATE( "Windows Japanese (CP 932)" ),
|
||||
wxTRANSLATE( "Windows Chinese Simplified (CP 936)" ),
|
||||
wxTRANSLATE( "Windows Korean (CP 949)" ),
|
||||
wxTRANSLATE( "Windows Chinese Traditional (CP 950)" ),
|
||||
wxTRANSLATE( "Windows Central European (CP 1250)" ),
|
||||
wxTRANSLATE( "Windows Cyrillic (CP 1251)" ),
|
||||
wxTRANSLATE( "Windows Western European (CP 1252)" ),
|
||||
wxTRANSLATE( "Windows Greek (CP 1253)" ),
|
||||
wxTRANSLATE( "Windows Turkish (CP 1254)" ),
|
||||
wxTRANSLATE( "Windows Hebrew (CP 1255)" ),
|
||||
wxTRANSLATE( "Windows Arabic (CP 1256)" ),
|
||||
wxTRANSLATE( "Windows Baltic (CP 1257)" ),
|
||||
wxTRANSLATE( "Windows/DOS OEM (CP 437)" ),
|
||||
wxTRANSLATE( "Unicode 7 bit (UTF-7)" ),
|
||||
wxTRANSLATE( "Unicode 8 bit (UTF-8)" ),
|
||||
wxTRANSLATE( "Extended Unix Codepage for Japanese (EUC-JP)" ),
|
||||
};
|
||||
|
||||
// and the internal names (these are not translated on purpose!)
|
||||
static const wxChar* gs_encodingNames[] =
|
||||
{
|
||||
wxT( "iso-8859-1" ),
|
||||
wxT( "iso-8859-2" ),
|
||||
wxT( "iso-8859-3" ),
|
||||
wxT( "iso-8859-4" ),
|
||||
wxT( "iso-8859-5" ),
|
||||
wxT( "iso-8859-6" ),
|
||||
wxT( "iso-8859-7" ),
|
||||
wxT( "iso-8859-8" ),
|
||||
wxT( "iso-8859-9" ),
|
||||
wxT( "iso-8859-10" ),
|
||||
wxT( "iso-8859-11" ),
|
||||
wxT( "iso-8859-12" ),
|
||||
wxT( "iso-8859-13" ),
|
||||
wxT( "iso-8859-14" ),
|
||||
wxT( "iso-8859-15" ),
|
||||
wxT( "koi8-r" ),
|
||||
wxT( "windows-932" ),
|
||||
wxT( "windows-936" ),
|
||||
wxT( "windows-949" ),
|
||||
wxT( "windows-950" ),
|
||||
wxT( "windows-1250" ),
|
||||
wxT( "windows-1251" ),
|
||||
wxT( "windows-1252" ),
|
||||
wxT( "windows-1253" ),
|
||||
wxT( "windows-1254" ),
|
||||
wxT( "windows-1255" ),
|
||||
wxT( "windows-1256" ),
|
||||
wxT( "windows-1257" ),
|
||||
wxT( "windows-437" ),
|
||||
wxT( "utf-7" ),
|
||||
wxT( "utf-8" ),
|
||||
wxT( "euc-jp" ),
|
||||
};
|
||||
|
||||
wxCOMPILE_TIME_ASSERT( WXSIZEOF(gs_encodingDescs) == WXSIZEOF(gs_encodings) &&
|
||||
WXSIZEOF(gs_encodingNames) == WXSIZEOF(gs_encodings),
|
||||
EncodingsArraysNotInSync );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// private classes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// change the config path during the lifetime of this object
|
||||
class wxFontMapperPathChanger
|
||||
// it may happen that while we're showing a dialog asking the user about
|
||||
// something, another request for an encoding mapping arrives: in this case it
|
||||
// is best to not do anything because otherwise we risk to enter an infinite
|
||||
// loop so we create an object of this class on stack to test for this in all
|
||||
// interactive functions
|
||||
class ReentrancyBlocker
|
||||
{
|
||||
public:
|
||||
wxFontMapperPathChanger(wxFontMapper *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);
|
||||
}
|
||||
ReentrancyBlocker(bool& flag) : m_flagOld(flag), m_flag(flag)
|
||||
{ m_flag = true; }
|
||||
~ReentrancyBlocker() { m_flag = m_flagOld; }
|
||||
|
||||
private:
|
||||
wxFontMapper *m_fontMapper;
|
||||
bool m_ok;
|
||||
wxString m_pathOld;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxFontMapperPathChanger)
|
||||
bool m_flagOld;
|
||||
bool& m_flag;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
@ -225,443 +93,21 @@ private:
|
||||
|
||||
wxFontMapper::wxFontMapper()
|
||||
{
|
||||
#if wxUSE_CONFIG
|
||||
m_config = NULL;
|
||||
m_configIsDummy = FALSE;
|
||||
#endif // wxUSE_CONFIG
|
||||
|
||||
#if wxUSE_GUI
|
||||
m_windowParent = NULL;
|
||||
#endif // wxUSE_GUI
|
||||
}
|
||||
|
||||
wxFontMapper::~wxFontMapper()
|
||||
{
|
||||
#if wxUSE_CONFIG
|
||||
if ( m_configIsDummy )
|
||||
delete m_config;
|
||||
#endif // wxUSE_CONFIG
|
||||
}
|
||||
|
||||
wxFontMapper *wxFontMapper::sm_instance = NULL;
|
||||
|
||||
/*static*/ wxFontMapper *wxFontMapper::Get()
|
||||
wxFontEncoding
|
||||
wxFontMapper::CharsetToEncoding(const wxString& charset, bool interactive)
|
||||
{
|
||||
if ( !sm_instance )
|
||||
sm_instance = new wxFontMapper;
|
||||
return sm_instance;
|
||||
}
|
||||
// try the ways not needing the users intervention first
|
||||
wxFontEncoding
|
||||
encoding = wxFontMapperBase::CharsetToEncoding(charset, interactive);
|
||||
|
||||
/*static*/ wxFontMapper *wxFontMapper::Set(wxFontMapper *mapper)
|
||||
{
|
||||
wxFontMapper *old = sm_instance;
|
||||
sm_instance = mapper;
|
||||
return old;
|
||||
}
|
||||
|
||||
class wxFontMapperModule: public wxModule
|
||||
{
|
||||
public:
|
||||
wxFontMapperModule() : wxModule() {}
|
||||
virtual bool OnInit() { return TRUE; }
|
||||
virtual void OnExit() { delete wxFontMapper::Set(NULL); }
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxFontMapperModule)
|
||||
};
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFontMapperModule, wxModule)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// customisation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_CONFIG
|
||||
|
||||
/* static */ const wxChar *wxFontMapper::GetDefaultConfigPath()
|
||||
{
|
||||
return FONTMAPPER_ROOT_PATH;
|
||||
}
|
||||
|
||||
void wxFontMapper::SetConfigPath(const wxString& prefix)
|
||||
{
|
||||
wxCHECK_RET( !prefix.IsEmpty() && prefix[0] == wxCONFIG_PATH_SEPARATOR,
|
||||
wxT("an absolute path should be given to wxFontMapper::SetConfigPath()") );
|
||||
|
||||
m_configRootPath = prefix;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// get config object and path for it
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxConfigBase *wxFontMapper::GetConfig()
|
||||
{
|
||||
if ( !m_config )
|
||||
{
|
||||
// try the default
|
||||
m_config = wxConfig::Get(FALSE /*don't create on demand*/ );
|
||||
|
||||
if ( !m_config )
|
||||
{
|
||||
// we still want to have a config object because otherwise we would
|
||||
// keep asking the user the same questions in the interactive mode,
|
||||
// so create a dummy config which won't write to any files/registry
|
||||
// but will allow us to remember the results of the questions at
|
||||
// least during this run
|
||||
m_config = new wxMemoryConfig;
|
||||
m_configIsDummy = TRUE;
|
||||
// VS: we can't call wxConfig::Set(m_config) here because that would
|
||||
// disable automatic wxConfig instance creation if this code was
|
||||
// called before wxApp::OnInit (this happens in wxGTK -- it sets
|
||||
// default wxFont encoding in wxApp::Initialize())
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_configIsDummy && wxConfig::Get(FALSE) != NULL )
|
||||
{
|
||||
// VS: in case we created dummy m_config (see above), we want to switch back
|
||||
// to the real one as soon as one becomes available.
|
||||
delete m_config;
|
||||
m_config = wxConfig::Get(FALSE);
|
||||
m_configIsDummy = FALSE;
|
||||
// FIXME: ideally, we should add keys from dummy config to the real one now,
|
||||
// but it is a low-priority task because typical wxWin application
|
||||
// either doesn't use wxConfig at all or creates wxConfig object in
|
||||
// wxApp::OnInit(), before any real interaction with the user takes
|
||||
// place...
|
||||
}
|
||||
|
||||
return m_config;
|
||||
}
|
||||
|
||||
const wxString& wxFontMapper::GetConfigPath()
|
||||
{
|
||||
if ( !m_configRootPath )
|
||||
{
|
||||
// use the default
|
||||
m_configRootPath = GetDefaultConfigPath();
|
||||
}
|
||||
|
||||
return m_configRootPath;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool wxFontMapper::ChangePath(const wxString& pathNew, wxString *pathOld)
|
||||
{
|
||||
#if wxUSE_CONFIG
|
||||
wxConfigBase *config = GetConfig();
|
||||
if ( !config )
|
||||
return FALSE;
|
||||
|
||||
*pathOld = config->GetPath();
|
||||
|
||||
wxString path = GetConfigPath();
|
||||
if ( path.IsEmpty() || path.Last() != wxCONFIG_PATH_SEPARATOR )
|
||||
{
|
||||
path += wxCONFIG_PATH_SEPARATOR;
|
||||
}
|
||||
|
||||
wxASSERT_MSG( !pathNew || (pathNew[0] != wxCONFIG_PATH_SEPARATOR),
|
||||
wxT("should be a relative path") );
|
||||
|
||||
path += pathNew;
|
||||
|
||||
config->SetPath(path);
|
||||
|
||||
return TRUE;
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxFontMapper::RestorePath(const wxString& pathOld)
|
||||
{
|
||||
#if wxUSE_CONFIG
|
||||
GetConfig()->SetPath(pathOld);
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// charset/encoding correspondence
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/* static */
|
||||
wxString wxFontMapper::GetEncodingDescription(wxFontEncoding encoding)
|
||||
{
|
||||
if ( encoding == wxFONTENCODING_DEFAULT )
|
||||
{
|
||||
return _("Default encoding");
|
||||
}
|
||||
|
||||
const size_t count = WXSIZEOF(gs_encodingDescs);
|
||||
|
||||
for ( size_t i = 0; i < count; i++ )
|
||||
{
|
||||
if ( gs_encodings[i] == encoding )
|
||||
{
|
||||
return wxGetTranslation(gs_encodingDescs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
wxString str;
|
||||
str.Printf(_("Unknown encoding (%d)"), encoding);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxString wxFontMapper::GetEncodingName(wxFontEncoding encoding)
|
||||
{
|
||||
if ( encoding == wxFONTENCODING_DEFAULT )
|
||||
{
|
||||
return _("default");
|
||||
}
|
||||
|
||||
const size_t count = WXSIZEOF(gs_encodingNames);
|
||||
|
||||
for ( size_t i = 0; i < count; i++ )
|
||||
{
|
||||
if ( gs_encodings[i] == encoding )
|
||||
{
|
||||
return gs_encodingNames[i];
|
||||
}
|
||||
}
|
||||
|
||||
wxString str;
|
||||
str.Printf(_("unknown-%d"), encoding);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
wxFontEncoding wxFontMapper::CharsetToEncoding(const wxString& charset,
|
||||
bool interactive)
|
||||
{
|
||||
// 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 fot
|
||||
static const int wxFONTENCODING_UNKNOWN = -2;
|
||||
|
||||
wxFontEncoding encoding = wxFONTENCODING_SYSTEM;
|
||||
|
||||
// we're going to modify it, make a copy
|
||||
wxString cs = charset;
|
||||
|
||||
#if wxUSE_CONFIG
|
||||
// first try the user-defined settings
|
||||
wxString pathOld;
|
||||
if ( ChangePath(FONTMAPPER_CHARSET_PATH, &pathOld) )
|
||||
{
|
||||
wxConfigBase *config = GetConfig();
|
||||
|
||||
// do we have an encoding for this charset?
|
||||
long value = config->Read(charset, -1l);
|
||||
if ( value != -1 )
|
||||
{
|
||||
if ( value == wxFONTENCODING_UNKNOWN )
|
||||
{
|
||||
// don't try to find it, in particular don't ask the user
|
||||
return wxFONTENCODING_SYSTEM;
|
||||
}
|
||||
|
||||
if ( value >= 0 && value <= wxFONTENCODING_MAX )
|
||||
{
|
||||
encoding = (wxFontEncoding)value;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogDebug(wxT("corrupted config data: invalid encoding %ld for charset '%s' ignored"),
|
||||
value, charset.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if ( encoding == wxFONTENCODING_SYSTEM )
|
||||
{
|
||||
// may be we have an alias?
|
||||
config->SetPath(FONTMAPPER_CHARSET_ALIAS_PATH);
|
||||
|
||||
wxString alias = config->Read(charset);
|
||||
if ( !!alias )
|
||||
{
|
||||
// yes, we do - use it instead
|
||||
cs = alias;
|
||||
}
|
||||
}
|
||||
|
||||
RestorePath(pathOld);
|
||||
}
|
||||
#endif // wxUSE_CONFIG
|
||||
|
||||
// if didn't find it there, try to recognize it ourselves
|
||||
if ( encoding == wxFONTENCODING_SYSTEM )
|
||||
{
|
||||
// trim any spaces
|
||||
cs.Trim(TRUE);
|
||||
cs.Trim(FALSE);
|
||||
|
||||
// discard the optional quotes
|
||||
if ( !cs.empty() )
|
||||
{
|
||||
if ( cs[0u] == _T('"') && cs.Last() == _T('"') )
|
||||
{
|
||||
cs = wxString(cs.c_str(), cs.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
cs.MakeUpper();
|
||||
|
||||
if ( cs.empty() || cs == _T("US-ASCII") )
|
||||
{
|
||||
encoding = wxFONTENCODING_DEFAULT;
|
||||
}
|
||||
else if ( cs == wxT("UTF-7") )
|
||||
{
|
||||
encoding = wxFONTENCODING_UTF7;
|
||||
}
|
||||
else if ( cs == wxT("UTF-8") )
|
||||
{
|
||||
encoding = wxFONTENCODING_UTF8;
|
||||
}
|
||||
else if ( cs == wxT("GB2312") )
|
||||
{
|
||||
encoding = wxFONTENCODING_GB2312;
|
||||
}
|
||||
else if ( cs == wxT("BIG5") )
|
||||
{
|
||||
encoding = wxFONTENCODING_BIG5;
|
||||
}
|
||||
else if ( cs == wxT("SJIS") ||
|
||||
cs == wxT("SHIFT_JIS") ||
|
||||
cs == wxT("SHIFT-JIS") )
|
||||
{
|
||||
encoding = wxFONTENCODING_SHIFT_JIS;
|
||||
}
|
||||
else if ( cs == wxT("EUC-JP") ||
|
||||
cs == wxT("EUC_JP") )
|
||||
{
|
||||
encoding = wxFONTENCODING_EUC_JP;
|
||||
}
|
||||
else if ( cs == wxT("KOI8-R") ||
|
||||
cs == wxT("KOI8-U") ||
|
||||
cs == wxT("KOI8-RU") )
|
||||
{
|
||||
// although koi8-ru is not strictly speaking the same as koi8-r,
|
||||
// they are similar enough to make mapping it to koi8 better than
|
||||
// not reckognizing it at all
|
||||
encoding = wxFONTENCODING_KOI8;
|
||||
}
|
||||
else if ( cs.Left(3) == wxT("ISO") )
|
||||
{
|
||||
// the dash is optional (or, to be exact, it is not, but
|
||||
// several brokenmails "forget" it)
|
||||
const wxChar *p = cs.c_str() + 3;
|
||||
if ( *p == wxT('-') )
|
||||
p++;
|
||||
|
||||
// printf( "iso %s\n", (const char*) cs.ToAscii() );
|
||||
|
||||
unsigned int value;
|
||||
if ( wxSscanf(p, wxT("8859-%u"), &value) == 1 )
|
||||
{
|
||||
// printf( "value %d\n", (int)value );
|
||||
|
||||
// make it 0 based and check that it is strictly positive in
|
||||
// the process (no such thing as iso8859-0 encoding)
|
||||
if ( (value-- > 0) &&
|
||||
(value < wxFONTENCODING_ISO8859_MAX -
|
||||
wxFONTENCODING_ISO8859_1) )
|
||||
{
|
||||
// it's a valid ISO8859 encoding
|
||||
value += wxFONTENCODING_ISO8859_1;
|
||||
encoding = (wxFontEncoding)value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( cs.Left(4) == wxT("8859") )
|
||||
{
|
||||
const wxChar *p = cs.c_str();
|
||||
|
||||
unsigned int value;
|
||||
if ( wxSscanf(p, wxT("8859-%u"), &value) == 1 )
|
||||
{
|
||||
// printf( "value %d\n", (int)value );
|
||||
|
||||
// make it 0 based and check that it is strictly positive in
|
||||
// the process (no such thing as iso8859-0 encoding)
|
||||
if ( (value-- > 0) &&
|
||||
(value < wxFONTENCODING_ISO8859_MAX -
|
||||
wxFONTENCODING_ISO8859_1) )
|
||||
{
|
||||
// it's a valid ISO8859 encoding
|
||||
value += wxFONTENCODING_ISO8859_1;
|
||||
encoding = (wxFontEncoding)value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // check for Windows charsets
|
||||
{
|
||||
size_t len;
|
||||
if ( cs.Left(7) == wxT("WINDOWS") )
|
||||
{
|
||||
len = 7;
|
||||
}
|
||||
else if ( cs.Left(2) == wxT("CP") )
|
||||
{
|
||||
len = 2;
|
||||
}
|
||||
else // not a Windows encoding
|
||||
{
|
||||
len = 0;
|
||||
}
|
||||
|
||||
if ( len )
|
||||
{
|
||||
const wxChar *p = cs.c_str() + len;
|
||||
if ( *p == wxT('-') )
|
||||
p++;
|
||||
|
||||
int value;
|
||||
if ( wxSscanf(p, wxT("%u"), &value) == 1 )
|
||||
{
|
||||
if ( value >= 1250 )
|
||||
{
|
||||
value -= 1250;
|
||||
if ( value < wxFONTENCODING_CP12_MAX -
|
||||
wxFONTENCODING_CP1250 )
|
||||
{
|
||||
// a valid Windows code page
|
||||
value += wxFONTENCODING_CP1250;
|
||||
encoding = (wxFontEncoding)value;
|
||||
}
|
||||
}
|
||||
|
||||
switch ( value )
|
||||
{
|
||||
case 932:
|
||||
encoding = wxFONTENCODING_CP932;
|
||||
break;
|
||||
|
||||
case 936:
|
||||
encoding = wxFONTENCODING_CP936;
|
||||
break;
|
||||
|
||||
case 949:
|
||||
encoding = wxFONTENCODING_CP949;
|
||||
break;
|
||||
|
||||
case 950:
|
||||
encoding = wxFONTENCODING_CP950;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//else: unknown
|
||||
}
|
||||
|
||||
#if wxUSE_GUI
|
||||
// if still no luck, ask the user - unless disabled
|
||||
// if we failed to find the encoding, ask the user -- unless disabled
|
||||
if ( (encoding == wxFONTENCODING_SYSTEM) && interactive )
|
||||
{
|
||||
// prepare the dialog data
|
||||
@ -676,13 +122,13 @@ wxFontEncoding wxFontMapper::CharsetToEncoding(const wxString& charset,
|
||||
msg.Printf(_("The charset '%s' is unknown. You may select\nanother charset to replace it with or choose\n[Cancel] if it cannot be replaced"), charset.c_str());
|
||||
|
||||
// the list of choices
|
||||
const size_t count = WXSIZEOF(gs_encodingDescs);
|
||||
const size_t count = GetSupportedEncodingsCount();
|
||||
|
||||
wxString *encodingNamesTranslated = new wxString[count];
|
||||
|
||||
for ( size_t i = 0; i < count; i++ )
|
||||
{
|
||||
encodingNamesTranslated[i] = wxGetTranslation(gs_encodingDescs[i]);
|
||||
encodingNamesTranslated[i] = GetEncodingDescription(GetEncoding(i));
|
||||
}
|
||||
|
||||
// the parent window
|
||||
@ -700,28 +146,26 @@ wxFontEncoding wxFontMapper::CharsetToEncoding(const wxString& charset,
|
||||
|
||||
if ( n != -1 )
|
||||
{
|
||||
encoding = gs_encodings[n];
|
||||
encoding = GetEncoding(n);
|
||||
}
|
||||
|
||||
#if wxUSE_CONFIG
|
||||
// save the result in the config now
|
||||
if ( ChangePath(FONTMAPPER_CHARSET_PATH, &pathOld) )
|
||||
wxFontMapperPathChanger path(this, FONTMAPPER_CHARSET_PATH);
|
||||
if ( path.IsOk() )
|
||||
{
|
||||
wxConfigBase *config = GetConfig();
|
||||
|
||||
// remember the alt encoding for this charset - or remember that
|
||||
// remember the alt encoding for this charset -- or remember that
|
||||
// we don't know it
|
||||
long value = n == -1 ? wxFONTENCODING_UNKNOWN : (long)encoding;
|
||||
if ( !config->Write(charset, value) )
|
||||
{
|
||||
wxLogError(_("Failed to remember the encoding for the charset '%s'."), charset.c_str());
|
||||
}
|
||||
|
||||
RestorePath(pathOld);
|
||||
}
|
||||
#endif // wxUSE_CONFIG
|
||||
}
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
return encoding;
|
||||
}
|
||||
@ -732,8 +176,6 @@ wxFontEncoding wxFontMapper::CharsetToEncoding(const wxString& charset,
|
||||
// correspond to which is used by GetFontForEncoding() function
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
bool wxFontMapper::TestAltEncoding(const wxString& configEntry,
|
||||
wxFontEncoding encReplacement,
|
||||
wxNativeEncodingInfo *info)
|
||||
@ -750,26 +192,12 @@ bool wxFontMapper::TestAltEncoding(const wxString& configEntry,
|
||||
GetConfig()->Write(configEntry, info->ToString());
|
||||
}
|
||||
#endif // wxUSE_CONFIG
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
#if wxUSE_GUI
|
||||
class ReentrancyBlocker
|
||||
{
|
||||
public:
|
||||
ReentrancyBlocker(bool& flag) : m_flagOld(flag), m_flag(flag)
|
||||
{ m_flag = TRUE; }
|
||||
~ReentrancyBlocker() { m_flag = m_flagOld; }
|
||||
|
||||
private:
|
||||
bool m_flagOld;
|
||||
bool& m_flag;
|
||||
};
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
|
||||
wxNativeEncodingInfo *info,
|
||||
const wxString& facename,
|
||||
@ -780,20 +208,20 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
|
||||
// example, when GetAltForEncoding() is called from an OnPaint() handler:
|
||||
// in this case, wxYield() which is called from wxMessageBox() we use here
|
||||
// will lead to another call of OnPaint() and hence to another call of
|
||||
// GetAltForEncoding() - and it is impossible to catch this from the user
|
||||
// GetAltForEncoding() -- and it is impossible to catch this from the user
|
||||
// code because we are called from wxFont ctor implicitly.
|
||||
|
||||
// assume we're always called from the main thread, so that it is safe to
|
||||
// use a static var
|
||||
static bool s_inGetAltForEncoding = FALSE;
|
||||
static bool s_inGetAltForEncoding = false;
|
||||
|
||||
if ( interactive && s_inGetAltForEncoding )
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
ReentrancyBlocker blocker(s_inGetAltForEncoding);
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
wxCHECK_MSG( info, FALSE, wxT("bad pointer in GetAltForEncoding") );
|
||||
wxCHECK_MSG( info, false, wxT("bad pointer in GetAltForEncoding") );
|
||||
|
||||
info->facename = facename;
|
||||
|
||||
@ -803,7 +231,7 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
|
||||
}
|
||||
|
||||
// if we failed to load the system default encoding, something is really
|
||||
// wrong and we'd better stop now - otherwise we will go into endless
|
||||
// wrong and we'd better stop now -- otherwise we will go into endless
|
||||
// recursion trying to create the font in the msg box with the error
|
||||
// message
|
||||
if ( encoding == wxFONTENCODING_SYSTEM )
|
||||
@ -823,50 +251,47 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
|
||||
|
||||
#if wxUSE_CONFIG
|
||||
// do we have a font spec for this encoding?
|
||||
wxString pathOld;
|
||||
if ( ChangePath(FONTMAPPER_FONT_FROM_ENCODING_PATH, &pathOld) )
|
||||
wxString fontinfo;
|
||||
wxFontMapperPathChanger path(this, FONTMAPPER_FONT_FROM_ENCODING_PATH);
|
||||
if ( path.IsOk() )
|
||||
{
|
||||
wxConfigBase *config = GetConfig();
|
||||
fontinfo = GetConfig()->Read(configEntry);
|
||||
}
|
||||
|
||||
wxString fontinfo = config->Read(configEntry);
|
||||
|
||||
RestorePath(pathOld);
|
||||
|
||||
// this special value means that we don't know of fonts for this
|
||||
// encoding but, moreover, have already asked the user as well and he
|
||||
// didn't specify any font neither
|
||||
if ( fontinfo == FONTMAPPER_FONT_DONT_ASK )
|
||||
// this special value means that we don't know of fonts for this
|
||||
// encoding but, moreover, have already asked the user as well and he
|
||||
// didn't specify any font neither
|
||||
if ( fontinfo == FONTMAPPER_FONT_DONT_ASK )
|
||||
{
|
||||
interactive = false;
|
||||
}
|
||||
else // use the info entered the last time
|
||||
{
|
||||
if ( !!fontinfo && !!facename )
|
||||
{
|
||||
interactive = FALSE;
|
||||
// we tried to find a match with facename -- now try without it
|
||||
fontinfo = GetConfig()->Read(encName);
|
||||
}
|
||||
else // use the info entered the last time
|
||||
{
|
||||
if ( !!fontinfo && !!facename )
|
||||
{
|
||||
// we tried to find a match with facename - now try without it
|
||||
fontinfo = config->Read(encName);
|
||||
}
|
||||
|
||||
if ( !!fontinfo )
|
||||
if ( !!fontinfo )
|
||||
{
|
||||
if ( info->FromString(fontinfo) )
|
||||
{
|
||||
if ( info->FromString(fontinfo) )
|
||||
if ( wxTestFontEncoding(*info) )
|
||||
{
|
||||
if ( wxTestFontEncoding(*info) )
|
||||
{
|
||||
// ok, got something
|
||||
return TRUE;
|
||||
}
|
||||
//else: no such fonts, look for something else
|
||||
// (should we erase the outdated value?)
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogDebug(wxT("corrupted config data: string '%s' is not a valid font encoding info"),
|
||||
fontinfo.c_str());
|
||||
// ok, got something
|
||||
return true;
|
||||
}
|
||||
//else: no such fonts, look for something else
|
||||
// (should we erase the outdated value?)
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogDebug(wxT("corrupted config data: string '%s' is not a valid font encoding info"),
|
||||
fontinfo.c_str());
|
||||
}
|
||||
//else: there is no information in config about this encoding
|
||||
}
|
||||
//else: there is no information in config about this encoding
|
||||
}
|
||||
#endif // wxUSE_CONFIG
|
||||
|
||||
@ -874,7 +299,7 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
|
||||
// system
|
||||
wxFontEncodingArray equiv = wxEncodingConverter::GetAllEquivalents(encoding);
|
||||
size_t count = equiv.GetCount();
|
||||
bool foundEquivEncoding = FALSE;
|
||||
bool foundEquivEncoding = false;
|
||||
wxFontEncoding equivEncoding = wxFONTENCODING_SYSTEM;
|
||||
if ( count )
|
||||
{
|
||||
@ -888,7 +313,7 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
|
||||
{
|
||||
equivEncoding = equiv[i];
|
||||
|
||||
foundEquivEncoding = TRUE;
|
||||
foundEquivEncoding = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -938,15 +363,15 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
|
||||
|
||||
#if wxUSE_CONFIG
|
||||
// remember this in the config
|
||||
if ( ChangePath(FONTMAPPER_FONT_FROM_ENCODING_PATH, &pathOld) )
|
||||
wxFontMapperPathChanger path(this,
|
||||
FONTMAPPER_FONT_FROM_ENCODING_PATH);
|
||||
if ( path.IsOk() )
|
||||
{
|
||||
GetConfig()->Write(configEntry, info->ToString());
|
||||
|
||||
RestorePath(pathOld);
|
||||
}
|
||||
#endif // wxUSE_CONFIG
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
//else: the user canceled the font selection dialog
|
||||
}
|
||||
@ -957,7 +382,9 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
|
||||
//
|
||||
// remember it to avoid asking the same question again later
|
||||
#if wxUSE_CONFIG
|
||||
if ( ChangePath(FONTMAPPER_FONT_FROM_ENCODING_PATH, &pathOld) )
|
||||
wxFontMapperPathChanger path(this,
|
||||
FONTMAPPER_FONT_FROM_ENCODING_PATH);
|
||||
if ( path.IsOk() )
|
||||
{
|
||||
GetConfig()->Write
|
||||
(
|
||||
@ -965,8 +392,6 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
|
||||
foundEquivEncoding ? info->ToString().c_str()
|
||||
: FONTMAPPER_FONT_DONT_ASK
|
||||
);
|
||||
|
||||
RestorePath(pathOld);
|
||||
}
|
||||
#endif // wxUSE_CONFIG
|
||||
}
|
||||
@ -978,14 +403,20 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
|
||||
}
|
||||
|
||||
bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
|
||||
wxFontEncoding *alt_encoding,
|
||||
wxFontEncoding *encodingAlt,
|
||||
const wxString& facename,
|
||||
bool interactive)
|
||||
{
|
||||
wxNativeEncodingInfo info;
|
||||
bool r = GetAltForEncoding(encoding, &info, facename, interactive);
|
||||
*alt_encoding = info.encoding;
|
||||
return r;
|
||||
if ( !GetAltForEncoding(encoding, &info, facename, interactive) )
|
||||
return false;
|
||||
|
||||
wxCHECK_MSG( encodingAlt, false,
|
||||
_T("wxFontEncoding::GetAltForEncoding(): NULL pointer") );
|
||||
|
||||
*encodingAlt = info.encoding;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxFontMapper::IsEncodingAvailable(wxFontEncoding encoding,
|
||||
@ -993,15 +424,11 @@ bool wxFontMapper::IsEncodingAvailable(wxFontEncoding encoding,
|
||||
{
|
||||
wxNativeEncodingInfo info;
|
||||
|
||||
if (wxGetNativeFontEncoding(encoding, &info))
|
||||
{
|
||||
info.facename = facename;
|
||||
return wxTestFontEncoding(info);
|
||||
}
|
||||
if ( !wxGetNativeFontEncoding(encoding, &info) )
|
||||
return false;
|
||||
|
||||
return FALSE;
|
||||
info.facename = facename;
|
||||
return wxTestFontEncoding(info);
|
||||
}
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
#endif // wxUSE_FONTMAP
|
||||
|
@ -19,14 +19,18 @@
|
||||
|
||||
#if wxUSE_FILESYSTEM && wxUSE_STREAMS
|
||||
|
||||
#include "wx/image.h"
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/fs_mem.h"
|
||||
|
||||
#ifdef __WXBASE__
|
||||
|
||||
#ifndef WXPRECOMP
|
||||
#include "wx/intl.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/hash.h"
|
||||
#endif
|
||||
|
||||
#include "wx/filesys.h"
|
||||
#include "wx/fs_mem.h"
|
||||
#include "wx/mstream.h"
|
||||
|
||||
class MemFSHashObj : public wxObject
|
||||
@ -77,28 +81,31 @@ class MemFSHashObj : public wxObject
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
wxHashTable *wxMemoryFSHandler::m_Hash = NULL;
|
||||
wxHashTable *wxMemoryFSHandlerBase::m_Hash = NULL;
|
||||
|
||||
|
||||
wxMemoryFSHandler::wxMemoryFSHandler() : wxFileSystemHandler()
|
||||
wxMemoryFSHandlerBase::wxMemoryFSHandlerBase() : wxFileSystemHandler()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
wxMemoryFSHandler::~wxMemoryFSHandler()
|
||||
wxMemoryFSHandlerBase::~wxMemoryFSHandlerBase()
|
||||
{
|
||||
// as only one copy of FS handler is supposed to exist, we may silently
|
||||
// delete static data here. (There is no way how to remove FS handler from
|
||||
// wxFileSystem other than releasing _all_ handlers.)
|
||||
|
||||
if (m_Hash) delete m_Hash;
|
||||
m_Hash = NULL;
|
||||
if (m_Hash)
|
||||
{
|
||||
delete m_Hash;
|
||||
m_Hash = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool wxMemoryFSHandler::CanOpen(const wxString& location)
|
||||
bool wxMemoryFSHandlerBase::CanOpen(const wxString& location)
|
||||
{
|
||||
wxString p = GetProtocol(location);
|
||||
return (p == wxT("memory"));
|
||||
@ -107,7 +114,7 @@ bool wxMemoryFSHandler::CanOpen(const wxString& location)
|
||||
|
||||
|
||||
|
||||
wxFSFile* wxMemoryFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString& location)
|
||||
wxFSFile* wxMemoryFSHandlerBase::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString& location)
|
||||
{
|
||||
if (m_Hash)
|
||||
{
|
||||
@ -127,25 +134,25 @@ wxFSFile* wxMemoryFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString
|
||||
|
||||
|
||||
|
||||
wxString wxMemoryFSHandler::FindFirst(const wxString& WXUNUSED(spec),
|
||||
wxString wxMemoryFSHandlerBase::FindFirst(const wxString& WXUNUSED(spec),
|
||||
int WXUNUSED(flags))
|
||||
{
|
||||
wxFAIL_MSG(wxT("wxMemoryFSHandler::FindFirst not implemented"));
|
||||
wxFAIL_MSG(wxT("wxMemoryFSHandlerBase::FindFirst not implemented"));
|
||||
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
|
||||
|
||||
wxString wxMemoryFSHandler::FindNext()
|
||||
wxString wxMemoryFSHandlerBase::FindNext()
|
||||
{
|
||||
wxFAIL_MSG(wxT("wxMemoryFSHandler::FindNext not implemented"));
|
||||
wxFAIL_MSG(wxT("wxMemoryFSHandlerBase::FindNext not implemented"));
|
||||
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
|
||||
bool wxMemoryFSHandler::CheckHash(const wxString& filename)
|
||||
bool wxMemoryFSHandlerBase::CheckHash(const wxString& filename)
|
||||
{
|
||||
if (m_Hash == NULL)
|
||||
{
|
||||
@ -166,9 +173,8 @@ bool wxMemoryFSHandler::CheckHash(const wxString& filename)
|
||||
|
||||
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
/*static*/ void wxMemoryFSHandler::AddFile(const wxString& filename, wxImage& image, long type)
|
||||
/*static*/ void
|
||||
wxMemoryFSHandlerBase::AddFile(const wxString& filename, wxImage& image, long type)
|
||||
{
|
||||
if (!CheckHash(filename)) return;
|
||||
|
||||
@ -186,21 +192,13 @@ bool wxMemoryFSHandler::CheckHash(const wxString& filename)
|
||||
}
|
||||
|
||||
|
||||
/*static*/ void wxMemoryFSHandler::AddFile(const wxString& filename, const wxBitmap& bitmap, long type)
|
||||
{
|
||||
wxImage img = bitmap.ConvertToImage();
|
||||
AddFile(filename, img, type);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*static*/ void wxMemoryFSHandler::AddFile(const wxString& filename, const wxString& textdata)
|
||||
/*static*/ void wxMemoryFSHandlerBase::AddFile(const wxString& filename, const wxString& textdata)
|
||||
{
|
||||
AddFile(filename, (const void*) textdata.mb_str(), textdata.Length());
|
||||
}
|
||||
|
||||
|
||||
/*static*/ void wxMemoryFSHandler::AddFile(const wxString& filename, const void *binarydata, size_t size)
|
||||
/*static*/ void wxMemoryFSHandlerBase::AddFile(const wxString& filename, const void *binarydata, size_t size)
|
||||
{
|
||||
if (!CheckHash(filename)) return;
|
||||
m_Hash -> Put(filename, new MemFSHashObj(binarydata, size));
|
||||
@ -208,7 +206,7 @@ bool wxMemoryFSHandler::CheckHash(const wxString& filename)
|
||||
|
||||
|
||||
|
||||
/*static*/ void wxMemoryFSHandler::RemoveFile(const wxString& filename)
|
||||
/*static*/ void wxMemoryFSHandlerBase::RemoveFile(const wxString& filename)
|
||||
{
|
||||
if (m_Hash == NULL ||
|
||||
m_Hash -> Get(filename) == NULL)
|
||||
@ -222,6 +220,18 @@ bool wxMemoryFSHandler::CheckHash(const wxString& filename)
|
||||
delete m_Hash -> Delete(filename);
|
||||
}
|
||||
|
||||
#endif // __WXBASE__
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
/*static*/ void wxMemoryFSHandler::AddFile(const wxString& filename, const wxBitmap& bitmap, long type)
|
||||
{
|
||||
wxImage img = bitmap.ConvertToImage();
|
||||
AddFile(filename, img, type);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // wxUSE_FILESYSTEM && wxUSE_FS_ZIP
|
||||
|
||||
|
@ -32,23 +32,15 @@
|
||||
|
||||
#include "wx/module.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global vars
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
WXDLLEXPORT wxApp *wxTheApp = NULL;
|
||||
|
||||
wxAppInitializerFunction
|
||||
wxAppBase::m_appInitFn = (wxAppInitializerFunction)NULL;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// private classes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class /* no WXDLLEXPORT */ wxConsoleApp : public wxApp
|
||||
// we need a dummy app object if the user doesn't want to create a real one
|
||||
class wxDummyConsoleApp : public wxApp
|
||||
{
|
||||
public:
|
||||
virtual int OnRun() { wxFAIL_MSG(wxT("unreachable")); return 0; }
|
||||
virtual int OnRun() { wxFAIL_MSG( _T("unreachable code") ); return 0; }
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -68,21 +60,6 @@ static size_t gs_nInitCount = 0;
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// stubs for some GUI functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void WXDLLEXPORT wxExit()
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
||||
// Yield to other apps/messages
|
||||
void WXDLLEXPORT wxWakeUpIdle()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxBase-specific functions
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -103,7 +80,7 @@ bool WXDLLEXPORT wxInitialize()
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
wxTheApp = new wxConsoleApp;
|
||||
wxTheApp = new wxDummyConsoleApp;
|
||||
|
||||
if ( !wxTheApp )
|
||||
{
|
||||
|
@ -18,57 +18,38 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "log.h"
|
||||
#pragma implementation "log.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
// wxWindows
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/string.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/app.h"
|
||||
|
||||
#if wxUSE_GUI
|
||||
#include "wx/window.h"
|
||||
#include "wx/msgdlg.h"
|
||||
#ifdef __WXMSW__
|
||||
#include "wx/msw/private.h"
|
||||
#endif
|
||||
#endif
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#include "wx/file.h"
|
||||
#include "wx/textfile.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/wxchar.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/thread.h"
|
||||
|
||||
#if wxUSE_LOG
|
||||
|
||||
// wxWindows
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/string.h"
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#include "wx/apptrait.h"
|
||||
#include "wx/file.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/msgout.h"
|
||||
#include "wx/textfile.h"
|
||||
#include "wx/thread.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/wxchar.h"
|
||||
|
||||
// other standard headers
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/private.h" // includes windows.h for OutputDebugString
|
||||
#endif
|
||||
|
||||
#if defined(__WXMAC__)
|
||||
#include "wx/mac/private.h" // includes mac headers
|
||||
#endif
|
||||
|
||||
#if defined(__MWERKS__) && wxUSE_UNICODE
|
||||
#include <wtime.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// non member functions
|
||||
@ -524,192 +505,6 @@ wxLogStderr::wxLogStderr(FILE *fp)
|
||||
m_fp = fp;
|
||||
}
|
||||
|
||||
#if defined(__WXMAC__) && !defined(__DARWIN__) && defined(__MWERKS__) && (__MWERKS__ >= 0x2400)
|
||||
|
||||
// MetroNub stuff doesn't seem to work in CodeWarrior 5.3 Carbon builds...
|
||||
|
||||
#ifndef __MetroNubUtils__
|
||||
#include "MetroNubUtils.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __GESTALT__
|
||||
#include <Gestalt.h>
|
||||
#endif
|
||||
|
||||
#ifndef true
|
||||
#define true 1
|
||||
#endif
|
||||
|
||||
#ifndef false
|
||||
#define false 0
|
||||
#endif
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
|
||||
#include <CodeFragments.h>
|
||||
|
||||
EXTERN_API_C( long )
|
||||
CallUniversalProc(UniversalProcPtr theProcPtr, ProcInfoType procInfo, ...);
|
||||
|
||||
ProcPtr gCallUniversalProc_Proc = NULL;
|
||||
|
||||
#endif
|
||||
|
||||
static MetroNubUserEntryBlock* gMetroNubEntry = NULL;
|
||||
|
||||
static long fRunOnce = false;
|
||||
|
||||
Boolean IsCompatibleVersion(short inVersion);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
IsCompatibleVersion
|
||||
--------------------------------------------------------------------------- */
|
||||
|
||||
Boolean IsCompatibleVersion(short inVersion)
|
||||
{
|
||||
Boolean result = false;
|
||||
|
||||
if (fRunOnce)
|
||||
{
|
||||
MetroNubUserEntryBlock* block = (MetroNubUserEntryBlock *)result;
|
||||
|
||||
result = (inVersion <= block->apiHiVersion);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
IsMetroNubInstalled
|
||||
--------------------------------------------------------------------------- */
|
||||
|
||||
Boolean IsMetroNubInstalled()
|
||||
{
|
||||
if (!fRunOnce)
|
||||
{
|
||||
long result, value;
|
||||
|
||||
fRunOnce = true;
|
||||
gMetroNubEntry = NULL;
|
||||
|
||||
if (Gestalt(gestaltSystemVersion, &value) == noErr && value < 0x1000)
|
||||
{
|
||||
/* look for MetroNub's Gestalt selector */
|
||||
if (Gestalt(kMetroNubUserSignature, &result) == noErr)
|
||||
{
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
if (gCallUniversalProc_Proc == NULL)
|
||||
{
|
||||
CFragConnectionID connectionID;
|
||||
Ptr mainAddress;
|
||||
Str255 errorString;
|
||||
ProcPtr symbolAddress;
|
||||
OSErr err;
|
||||
CFragSymbolClass symbolClass;
|
||||
|
||||
symbolAddress = NULL;
|
||||
err = GetSharedLibrary("\pInterfaceLib", kPowerPCCFragArch, kFindCFrag,
|
||||
&connectionID, &mainAddress, errorString);
|
||||
|
||||
if (err != noErr)
|
||||
{
|
||||
gCallUniversalProc_Proc = NULL;
|
||||
goto end;
|
||||
}
|
||||
|
||||
err = FindSymbol(connectionID, "\pCallUniversalProc",
|
||||
(Ptr *) &gCallUniversalProc_Proc, &symbolClass);
|
||||
|
||||
if (err != noErr)
|
||||
{
|
||||
gCallUniversalProc_Proc = NULL;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
MetroNubUserEntryBlock* block = (MetroNubUserEntryBlock *)result;
|
||||
|
||||
/* make sure the version of the API is compatible */
|
||||
if (block->apiLowVersion <= kMetroNubUserAPIVersion &&
|
||||
kMetroNubUserAPIVersion <= block->apiHiVersion)
|
||||
gMetroNubEntry = block; /* success! */
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
return (gMetroNubEntry != NULL && gCallUniversalProc_Proc != NULL);
|
||||
#else
|
||||
return (gMetroNubEntry != NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
IsMWDebuggerRunning [v1 API]
|
||||
--------------------------------------------------------------------------- */
|
||||
|
||||
Boolean IsMWDebuggerRunning()
|
||||
{
|
||||
if (IsMetroNubInstalled())
|
||||
return CallIsDebuggerRunningProc(gMetroNubEntry->isDebuggerRunning);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
AmIBeingMWDebugged [v1 API]
|
||||
--------------------------------------------------------------------------- */
|
||||
|
||||
Boolean AmIBeingMWDebugged()
|
||||
{
|
||||
if (IsMetroNubInstalled())
|
||||
return CallAmIBeingDebuggedProc(gMetroNubEntry->amIBeingDebugged);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
UserSetWatchPoint [v2 API]
|
||||
--------------------------------------------------------------------------- */
|
||||
|
||||
OSErr UserSetWatchPoint (Ptr address, long length, WatchPointIDT* watchPointID)
|
||||
{
|
||||
if (IsMetroNubInstalled() && IsCompatibleVersion(kMetroNubUserAPIVersion))
|
||||
return CallUserSetWatchPointProc(gMetroNubEntry->userSetWatchPoint,
|
||||
address, length, watchPointID);
|
||||
else
|
||||
return errProcessIsNotClient;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
ClearWatchPoint [v2 API]
|
||||
--------------------------------------------------------------------------- */
|
||||
|
||||
OSErr ClearWatchPoint (WatchPointIDT watchPointID)
|
||||
{
|
||||
if (IsMetroNubInstalled() && IsCompatibleVersion(kMetroNubUserAPIVersion))
|
||||
return CallClearWatchPointProc(gMetroNubEntry->clearWatchPoint, watchPointID);
|
||||
else
|
||||
return errProcessIsNotClient;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ >= 0x2400)
|
||||
|
||||
void wxLogStderr::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
|
||||
{
|
||||
wxString str;
|
||||
@ -720,43 +515,18 @@ void wxLogStderr::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
|
||||
fputc(_T('\n'), m_fp);
|
||||
fflush(m_fp);
|
||||
|
||||
// under Windows, programs usually don't have stderr at all, so show the
|
||||
// messages also under debugger (unless it's a console program which does
|
||||
// have stderr or unless this is a file logger which doesn't use stderr at
|
||||
// all)
|
||||
#if defined(__WXMSW__) && wxUSE_GUI && !defined(__WXMICROWIN__)
|
||||
// under GUI systems such as Windows or Mac, programs usually don't have
|
||||
// stderr at all, so show the messages also somewhere else, typically in
|
||||
// the debugger window so that they go at least somewhere instead of being
|
||||
// simply lost
|
||||
if ( m_fp == stderr )
|
||||
{
|
||||
str += wxT("\r\n") ;
|
||||
OutputDebugString(str.c_str());
|
||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||
if ( traits && !traits->HasStderr() )
|
||||
{
|
||||
wxMessageOutputDebug().Printf(_T("%s"), str.c_str());
|
||||
}
|
||||
}
|
||||
#endif // MSW
|
||||
|
||||
#if defined(__WXMAC__) && !defined(__DARWIN__) && wxUSE_GUI
|
||||
Str255 pstr ;
|
||||
wxString output = str + wxT(";g") ;
|
||||
wxMacStringToPascal( output.c_str() , pstr ) ;
|
||||
|
||||
Boolean running = false ;
|
||||
|
||||
#if defined(__MWERKS__) && (__MWERKS__ >= 0x2400)
|
||||
|
||||
if ( IsMWDebuggerRunning() && AmIBeingMWDebugged() )
|
||||
{
|
||||
running = true ;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (running)
|
||||
{
|
||||
#ifdef __powerc
|
||||
DebugStr(pstr);
|
||||
#else
|
||||
SysBreakStr(pstr);
|
||||
#endif
|
||||
}
|
||||
#endif // Mac
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -870,11 +640,7 @@ wxLogLevel wxLog::ms_logLevel = wxLOG_Max; // log everything by defaul
|
||||
|
||||
size_t wxLog::ms_suspendCount = 0;
|
||||
|
||||
#if wxUSE_GUI
|
||||
const wxChar *wxLog::ms_timestamp = wxT("%X"); // time only, no date
|
||||
#else
|
||||
const wxChar *wxLog::ms_timestamp = NULL; // save space
|
||||
#endif
|
||||
const wxChar *wxLog::ms_timestamp = wxT("%X"); // time only, no date
|
||||
|
||||
wxTraceMask wxLog::ms_ulTraceMask = (wxTraceMask)0;
|
||||
wxArrayString wxLog::ms_aTraceMasks;
|
||||
@ -989,6 +755,5 @@ const wxChar *wxSysErrorMsg(unsigned long nErrCode)
|
||||
#endif // Win/Unix
|
||||
}
|
||||
|
||||
#endif //wxUSE_LOG
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
// vi:sts=4:sw=4:et
|
||||
|
@ -48,6 +48,12 @@
|
||||
// implementation
|
||||
// ===========================================================================
|
||||
|
||||
#ifdef __WXBASE__
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMessageOutput
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxMessageOutput* wxMessageOutput::ms_msgOut = 0;
|
||||
|
||||
wxMessageOutput* wxMessageOutput::Get()
|
||||
@ -83,6 +89,64 @@ void wxMessageOutputStderr::Printf(const wxChar* format, ...)
|
||||
fprintf(stderr, "%s", (const char*) out.mb_str());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMessageOutputDebug
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxMessageOutputDebug::Printf(const wxChar* format, ...)
|
||||
{
|
||||
wxString out;
|
||||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
out.PrintfV(format, args);
|
||||
va_end(args);
|
||||
|
||||
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
|
||||
out.Replace(wxT("\t"), wxT(" "));
|
||||
out += _T("\r\n");
|
||||
::OutputDebugString(out);
|
||||
#elif defined(__WXMAC__) && !defined(__DARWIN__)
|
||||
if ( wxIsDebuggerRunning() )
|
||||
{
|
||||
Str255 pstr;
|
||||
wxString output = str + wxT(";g") ;
|
||||
wxMacStringToPascal(output.c_str(), pstr);
|
||||
|
||||
#ifdef __powerc
|
||||
DebugStr(pstr);
|
||||
#else
|
||||
SysBreakStr(pstr);
|
||||
#endif
|
||||
}
|
||||
#else // !MSW, !Mac
|
||||
wxFputs(out, stderr);
|
||||
fflush(stderr);
|
||||
#endif // platform
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMessageOutputLog
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxMessageOutputLog::Printf(const wxChar* format, ...)
|
||||
{
|
||||
wxString out;
|
||||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
out.PrintfV(format, args);
|
||||
va_end(args);
|
||||
|
||||
out.Replace(wxT("\t"), wxT(" "));
|
||||
|
||||
::wxLogMessage(wxT("%s"), out.c_str());
|
||||
}
|
||||
|
||||
#endif // __WXBASE__
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMessageOutputMessageBox
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -112,21 +176,3 @@ void wxMessageOutputMessageBox::Printf(const wxChar* format, ...)
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMessageOutputLog
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxMessageOutputLog::Printf(const wxChar* format, ...)
|
||||
{
|
||||
wxString out;
|
||||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
out.PrintfV(format, args);
|
||||
va_end(args);
|
||||
|
||||
out.Replace(wxT("\t"), wxT(" "));
|
||||
|
||||
::wxLogMessage(wxT("%s"), out.c_str());
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#if wxUSE_SOCKETS
|
||||
|
||||
#include "wx/app.h"
|
||||
#include "wx/apptrait.h"
|
||||
#include "wx/defs.h"
|
||||
#include "wx/object.h"
|
||||
#include "wx/string.h"
|
||||
@ -37,10 +38,6 @@
|
||||
#include "wx/intl.h"
|
||||
#include "wx/event.h"
|
||||
|
||||
#if wxUSE_GUI
|
||||
#include "wx/gdicmn.h" // for wxPendingDelete
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
#include "wx/sckaddr.h"
|
||||
#include "wx/socket.h"
|
||||
|
||||
@ -51,30 +48,24 @@
|
||||
// discard buffer
|
||||
#define MAX_DISCARD_SIZE (10 * 1024)
|
||||
|
||||
// what to do within waits: in wxBase we don't do anything as we don't have
|
||||
// the event loop anyhow (for now). In GUI apps we have 2 cases: from the main
|
||||
// thread itself we have to call wxYield() to let the events (including the
|
||||
// GUI events and the low-level (not wxWindows) events from GSocket) be
|
||||
// processed. From another thread it is enough to just call wxThread::Yield()
|
||||
// which will give away the rest of our time slice: the explanation is that
|
||||
// the events will be processed by the main thread anyhow, without calling
|
||||
// wxYield(), but we don't want to eat the CPU time uselessly while sitting
|
||||
// in the loop waiting for the data
|
||||
#if wxUSE_GUI
|
||||
#if wxUSE_THREADS
|
||||
#define PROCESS_EVENTS() \
|
||||
{ \
|
||||
if ( wxThread::IsMain() ) \
|
||||
wxYield(); \
|
||||
else \
|
||||
wxThread::Yield(); \
|
||||
}
|
||||
#else // !wxUSE_THREADS
|
||||
#define PROCESS_EVENTS() wxYield()
|
||||
#endif // wxUSE_THREADS/!wxUSE_THREADS
|
||||
#else // !wxUSE_GUI
|
||||
#define PROCESS_EVENTS()
|
||||
#endif // wxUSE_GUI/!wxUSE_GUI
|
||||
// what to do within waits: we have 2 cases: from the main thread itself we
|
||||
// have to call wxYield() to let the events (including the GUI events and the
|
||||
// low-level (not wxWindows) events from GSocket) be processed. From another
|
||||
// thread it is enough to just call wxThread::Yield() which will give away the
|
||||
// rest of our time slice: the explanation is that the events will be processed
|
||||
// by the main thread anyhow, without calling wxYield(), but we don't want to
|
||||
// eat the CPU time uselessly while sitting in the loop waiting for the data
|
||||
#if wxUSE_THREADS
|
||||
#define PROCESS_EVENTS() \
|
||||
{ \
|
||||
if ( wxThread::IsMain() ) \
|
||||
wxYield(); \
|
||||
else \
|
||||
wxThread::Yield(); \
|
||||
}
|
||||
#else // !wxUSE_THREADS
|
||||
#define PROCESS_EVENTS() wxYield()
|
||||
#endif // wxUSE_THREADS/!wxUSE_THREADS
|
||||
|
||||
#define wxTRACE_Socket _T("wxSocket")
|
||||
|
||||
@ -213,9 +204,9 @@ wxSocketBase::~wxSocketBase()
|
||||
{
|
||||
// Just in case the app called Destroy() *and* then deleted
|
||||
// the socket immediately: don't leave dangling pointers.
|
||||
#if wxUSE_GUI
|
||||
wxPendingDelete.DeleteObject(this);
|
||||
#endif
|
||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||
if ( traits )
|
||||
traits->RemoveFromPendingDelete(this);
|
||||
|
||||
// Shutdown and close the socket
|
||||
if (!m_beingDeleted)
|
||||
@ -243,12 +234,18 @@ bool wxSocketBase::Destroy()
|
||||
// Supress events from now on
|
||||
Notify(FALSE);
|
||||
|
||||
#if wxUSE_GUI
|
||||
if ( !wxPendingDelete.Member(this) )
|
||||
wxPendingDelete.Append(this);
|
||||
#else
|
||||
delete this;
|
||||
#endif
|
||||
// schedule this object for deletion
|
||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||
if ( traits )
|
||||
{
|
||||
// let the traits object decide what to do with us
|
||||
traits->ScheduleForDestroy(this);
|
||||
}
|
||||
else // no app or no traits
|
||||
{
|
||||
// in wxBase we might have no app object at all, don't leak memory
|
||||
delete this;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
344
src/common/stopwatch.cpp
Normal file
344
src/common/stopwatch.cpp
Normal file
@ -0,0 +1,344 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: common/stopwatch.cpp
|
||||
// Purpose: wxStopWatch and other non-GUI stuff from wx/timer.h
|
||||
// Author:
|
||||
// Original version by Julian Smart
|
||||
// Vadim Zeitlin got rid of all ifdefs (11.12.99)
|
||||
// Sylvain Bougnoux added wxStopWatch class
|
||||
// Guillermo Rodriguez <guille@iies.es> rewrote from scratch (Dic/99)
|
||||
// Modified by:
|
||||
// Created: 20.06.2003 (extracted from common/timercmn.cpp)
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998-2003 wxWindows Team
|
||||
// License: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// for compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#include "wx/timer.h"
|
||||
#include "wx/longlong.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// System headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(__WIN32__) && !defined(HAVE_FTIME) && !defined(__MWERKS__)
|
||||
#define HAVE_FTIME
|
||||
#endif
|
||||
|
||||
#if defined(__VISAGECPP__) && !defined(HAVE_FTIME)
|
||||
#define HAVE_FTIME
|
||||
# if __IBMCPP__ >= 400
|
||||
# define ftime(x) _ftime(x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__MWERKS__) && defined(__WXMSW__)
|
||||
# undef HAVE_FTIME
|
||||
# undef HAVE_GETTIMEOFDAY
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
#ifndef __WXMAC__
|
||||
#include <sys/types.h> // for time_t
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_GETTIMEOFDAY)
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#elif defined(HAVE_FTIME)
|
||||
#include <sys/timeb.h>
|
||||
#endif
|
||||
|
||||
#ifdef __WXMAC__
|
||||
#include <Timer.h>
|
||||
#include <DriverServices.h>
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// macros
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// on some really old systems gettimeofday() doesn't have the second argument,
|
||||
// define wxGetTimeOfDay() to hide this difference
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
#ifdef WX_GETTIMEOFDAY_NO_TZ
|
||||
struct timezone;
|
||||
#define wxGetTimeOfDay(tv, tz) gettimeofday(tv)
|
||||
#else
|
||||
#define wxGetTimeOfDay(tv, tz) gettimeofday((tv), (tz))
|
||||
#endif
|
||||
#endif // HAVE_GETTIMEOFDAY
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStopWatch
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_STOPWATCH
|
||||
|
||||
void wxStopWatch::Start(long t)
|
||||
{
|
||||
m_t0 = wxGetLocalTimeMillis() - t;
|
||||
m_pause = 0;
|
||||
m_pauseCount = 0;
|
||||
}
|
||||
|
||||
long wxStopWatch::GetElapsedTime() const
|
||||
{
|
||||
return (wxGetLocalTimeMillis() - m_t0).GetLo();
|
||||
}
|
||||
|
||||
long wxStopWatch::Time() const
|
||||
{
|
||||
return m_pauseCount ? m_pause : GetElapsedTime();
|
||||
}
|
||||
|
||||
#endif // wxUSE_STOPWATCH
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// old timer functions superceded by wxStopWatch
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_LONGLONG
|
||||
|
||||
static wxLongLong wxStartTime = 0l;
|
||||
|
||||
// starts the global timer
|
||||
void wxStartTimer()
|
||||
{
|
||||
wxStartTime = wxGetLocalTimeMillis();
|
||||
}
|
||||
|
||||
// Returns elapsed time in milliseconds
|
||||
long wxGetElapsedTime(bool resetTimer)
|
||||
{
|
||||
wxLongLong oldTime = wxStartTime;
|
||||
wxLongLong newTime = wxGetLocalTimeMillis();
|
||||
|
||||
if ( resetTimer )
|
||||
wxStartTime = newTime;
|
||||
|
||||
return (newTime - oldTime).GetLo();
|
||||
}
|
||||
|
||||
#endif // wxUSE_LONGLONG
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// the functions to get the current time and timezone info
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Get local time as seconds since 00:00:00, Jan 1st 1970
|
||||
long wxGetLocalTime()
|
||||
{
|
||||
struct tm tm;
|
||||
time_t t0, t1;
|
||||
|
||||
// This cannot be made static because mktime can overwrite it.
|
||||
//
|
||||
memset(&tm, 0, sizeof(tm));
|
||||
tm.tm_year = 70;
|
||||
tm.tm_mon = 0;
|
||||
tm.tm_mday = 5; // not Jan 1st 1970 due to mktime 'feature'
|
||||
tm.tm_hour = 0;
|
||||
tm.tm_min = 0;
|
||||
tm.tm_sec = 0;
|
||||
tm.tm_isdst = -1; // let mktime guess
|
||||
|
||||
// Note that mktime assumes that the struct tm contains local time.
|
||||
//
|
||||
t1 = time(&t1); // now
|
||||
t0 = mktime(&tm); // origin
|
||||
|
||||
// Return the difference in seconds.
|
||||
//
|
||||
if (( t0 != (time_t)-1 ) && ( t1 != (time_t)-1 ))
|
||||
return (long)difftime(t1, t0) + (60 * 60 * 24 * 4);
|
||||
|
||||
wxLogSysError(_("Failed to get the local system time"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get UTC time as seconds since 00:00:00, Jan 1st 1970
|
||||
long wxGetUTCTime()
|
||||
{
|
||||
struct tm tm;
|
||||
struct tm *ptm;
|
||||
time_t t0, t1;
|
||||
|
||||
// This cannot be made static because mktime can overwrite it
|
||||
//
|
||||
memset(&tm, 0, sizeof(tm));
|
||||
tm.tm_year = 70;
|
||||
tm.tm_mon = 0;
|
||||
tm.tm_mday = 5; // not Jan 1st 1970 due to mktime 'feature'
|
||||
tm.tm_hour = 0;
|
||||
tm.tm_min = 0;
|
||||
tm.tm_sec = 0;
|
||||
tm.tm_isdst = -1; // let mktime guess
|
||||
|
||||
// Note that mktime assumes that the struct tm contains local time.
|
||||
//
|
||||
t1 = time(&t1); // now
|
||||
t0 = mktime(&tm); // origin in localtime
|
||||
|
||||
if (( t0 != (time_t)-1 ) && ( t1 != (time_t)-1 ))
|
||||
{
|
||||
// To get t0 as GMT we convert to a struct tm with gmtime,
|
||||
// and then back again.
|
||||
//
|
||||
ptm = gmtime(&t0);
|
||||
|
||||
if (ptm)
|
||||
{
|
||||
memcpy(&tm, ptm, sizeof(tm));
|
||||
t0 = mktime(&tm);
|
||||
|
||||
if (t0 != (time_t)-1 )
|
||||
return (long)difftime(t1, t0) + (60 * 60 * 24 * 4);
|
||||
wxLogSysError(_("mktime() failed"));
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogSysError(_("gmtime() failed"));
|
||||
}
|
||||
}
|
||||
|
||||
wxLogError(_("Failed to get the UTC system time."));
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if wxUSE_LONGLONG
|
||||
|
||||
// Get local time as milliseconds since 00:00:00, Jan 1st 1970
|
||||
wxLongLong wxGetLocalTimeMillis()
|
||||
{
|
||||
wxLongLong val = 1000l;
|
||||
|
||||
// If possible, use a function which avoids conversions from
|
||||
// broken-up time structures to milliseconds
|
||||
|
||||
#if defined(__WXMSW__) && defined(__MWERKS__)
|
||||
// This should probably be the way all WXMSW compilers should do it
|
||||
// Go direct to the OS for time
|
||||
|
||||
SYSTEMTIME thenst = { 1970, 1, 4, 1, 0, 0, 0, 0 }; // 00:00:00 Jan 1st 1970
|
||||
FILETIME thenft;
|
||||
SystemTimeToFileTime( &thenst, &thenft );
|
||||
wxLongLong then( thenft.dwHighDateTime, thenft.dwLowDateTime ); // time in 100 nanoseconds
|
||||
|
||||
SYSTEMTIME nowst;
|
||||
GetLocalTime( &nowst );
|
||||
FILETIME nowft;
|
||||
SystemTimeToFileTime( &nowst, &nowft );
|
||||
wxLongLong now( nowft.dwHighDateTime, nowft.dwLowDateTime ); // time in 100 nanoseconds
|
||||
|
||||
return ( now - then ) / 10000.0; // time from 00:00:00 Jan 1st 1970 to now in milliseconds
|
||||
|
||||
#elif defined(HAVE_GETTIMEOFDAY)
|
||||
struct timeval tp;
|
||||
if ( wxGetTimeOfDay(&tp, (struct timezone *)NULL) != -1 )
|
||||
{
|
||||
val *= tp.tv_sec;
|
||||
return (val + (tp.tv_usec / 1000));
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogError(_("wxGetTimeOfDay failed."));
|
||||
return 0;
|
||||
}
|
||||
#elif defined(HAVE_FTIME)
|
||||
struct timeb tp;
|
||||
|
||||
// ftime() is void and not int in some mingw32 headers, so don't
|
||||
// test the return code (well, it shouldn't fail anyhow...)
|
||||
(void)ftime(&tp);
|
||||
val *= tp.time;
|
||||
return (val + tp.millitm);
|
||||
#elif defined(__WXMAC__)
|
||||
|
||||
static UInt64 gMilliAtStart = 0;
|
||||
|
||||
Nanoseconds upTime = AbsoluteToNanoseconds( UpTime() );
|
||||
|
||||
if ( gMilliAtStart == 0 )
|
||||
{
|
||||
time_t start = time(NULL);
|
||||
gMilliAtStart = ((UInt64) start) * 1000000L;
|
||||
gMilliAtStart -= upTime.lo / 1000 ;
|
||||
gMilliAtStart -= ( ( (UInt64) upTime.hi ) << 32 ) / (1000 * 1000);
|
||||
}
|
||||
|
||||
UInt64 millival = gMilliAtStart;
|
||||
millival += upTime.lo / (1000 * 1000);
|
||||
millival += ( ( (UInt64) upTime.hi ) << 32 ) / (1000 * 1000);
|
||||
val = millival;
|
||||
|
||||
return val;
|
||||
#else // no gettimeofday() nor ftime()
|
||||
// We use wxGetLocalTime() to get the seconds since
|
||||
// 00:00:00 Jan 1st 1970 and then whatever is available
|
||||
// to get millisecond resolution.
|
||||
//
|
||||
// NOTE that this might lead to a problem if the clocks
|
||||
// use different sources, so this approach should be
|
||||
// avoided where possible.
|
||||
|
||||
val *= wxGetLocalTime();
|
||||
|
||||
// GRG: This will go soon as all WIN32 seem to have ftime
|
||||
#if defined (__WIN32__)
|
||||
// If your platform/compiler needs to use two different functions
|
||||
// to get ms resolution, please do NOT just shut off these warnings,
|
||||
// drop me a line instead at <guille@iies.es>
|
||||
#warning "Possible clock skew bug in wxGetLocalTimeMillis()!"
|
||||
|
||||
SYSTEMTIME st;
|
||||
::GetLocalTime(&st);
|
||||
val += st.wMilliseconds;
|
||||
#else // !Win32
|
||||
// If your platform/compiler does not support ms resolution please
|
||||
// do NOT just shut off these warnings, drop me a line instead at
|
||||
// <guille@iies.es>
|
||||
|
||||
#if defined(__VISUALC__) || defined (__WATCOMC__)
|
||||
#pragma message("wxStopWatch will be up to second resolution!")
|
||||
#elif defined(__BORLANDC__)
|
||||
#pragma message "wxStopWatch will be up to second resolution!"
|
||||
#else
|
||||
#warning "wxStopWatch will be up to second resolution!"
|
||||
#endif // compiler
|
||||
#endif
|
||||
|
||||
return val;
|
||||
|
||||
#endif // time functions
|
||||
}
|
||||
|
||||
#endif // wxUSE_LONGLONG
|
||||
|
||||
|
@ -1,12 +1,8 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: common/timercmn.cpp
|
||||
// Purpose: Common timer implementation
|
||||
// Author:
|
||||
// Original version by Julian Smart
|
||||
// Vadim Zeitlin got rid of all ifdefs (11.12.99)
|
||||
// Sylvain Bougnoux added wxStopWatch class
|
||||
// Guillermo Rodriguez <guille@iies.es> rewrote from scratch (Dic/99)
|
||||
// Modified by:
|
||||
// Purpose: wxTimerBase implementation
|
||||
// Author: Julian Smart, Guillermo Rodriguez, Vadim Zeitlin
|
||||
// Modified by: VZ: extracted all non-wxTimer stuff in stopwatch.cpp (20.06.03)
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
@ -33,88 +29,21 @@
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_TIMER
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/intl.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/thread.h"
|
||||
#endif
|
||||
|
||||
#include "wx/timer.h"
|
||||
#include "wx/longlong.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// System headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(__WIN32__) && !defined(HAVE_FTIME) && !defined(__MWERKS__)
|
||||
#define HAVE_FTIME
|
||||
#endif
|
||||
|
||||
#if defined(__VISAGECPP__) && !defined(HAVE_FTIME)
|
||||
#define HAVE_FTIME
|
||||
# if __IBMCPP__ >= 400
|
||||
# define ftime(x) _ftime(x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__MWERKS__) && defined(__WXMSW__)
|
||||
# undef HAVE_FTIME
|
||||
# undef HAVE_GETTIMEOFDAY
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
#ifndef __WXMAC__
|
||||
#include <sys/types.h> // for time_t
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_GETTIMEOFDAY)
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#elif defined(HAVE_FTIME)
|
||||
#include <sys/timeb.h>
|
||||
#endif
|
||||
|
||||
#ifdef __WXMAC__
|
||||
#include <Timer.h>
|
||||
#include <DriverServices.h>
|
||||
#endif
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxWin macros
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_GUI && wxUSE_TIMER
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTimerEvent, wxEvent)
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// macros
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// on some really old systems gettimeofday() doesn't have the second argument,
|
||||
// define wxGetTimeOfDay() to hide this difference
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
#ifdef WX_GETTIMEOFDAY_NO_TZ
|
||||
struct timezone;
|
||||
#define wxGetTimeOfDay(tv, tz) gettimeofday(tv)
|
||||
#else
|
||||
#define wxGetTimeOfDay(tv, tz) gettimeofday((tv), (tz))
|
||||
#endif
|
||||
#endif // HAVE_GETTIMEOFDAY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTimerEvent, wxEvent)
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// wxTimerBase implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTimerBase
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_GUI && wxUSE_TIMER
|
||||
|
||||
wxTimerBase::~wxTimerBase()
|
||||
{
|
||||
// this destructor is required for Darwin
|
||||
@ -157,252 +86,5 @@ bool wxTimerBase::Start(int milliseconds, bool oneShot)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStopWatch
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_STOPWATCH && wxUSE_LONGLONG
|
||||
|
||||
void wxStopWatch::Start(long t)
|
||||
{
|
||||
m_t0 = wxGetLocalTimeMillis() - t;
|
||||
m_pause = 0;
|
||||
m_pauseCount = 0;
|
||||
}
|
||||
|
||||
long wxStopWatch::GetElapsedTime() const
|
||||
{
|
||||
return (wxGetLocalTimeMillis() - m_t0).GetLo();
|
||||
}
|
||||
|
||||
long wxStopWatch::Time() const
|
||||
{
|
||||
return m_pauseCount ? m_pause : GetElapsedTime();
|
||||
}
|
||||
|
||||
#endif // wxUSE_LONGLONG
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// old timer functions superceded by wxStopWatch
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_LONGLONG
|
||||
|
||||
static wxLongLong wxStartTime = 0l;
|
||||
|
||||
// starts the global timer
|
||||
void wxStartTimer()
|
||||
{
|
||||
wxStartTime = wxGetLocalTimeMillis();
|
||||
}
|
||||
|
||||
// Returns elapsed time in milliseconds
|
||||
long wxGetElapsedTime(bool resetTimer)
|
||||
{
|
||||
wxLongLong oldTime = wxStartTime;
|
||||
wxLongLong newTime = wxGetLocalTimeMillis();
|
||||
|
||||
if ( resetTimer )
|
||||
wxStartTime = newTime;
|
||||
|
||||
return (newTime - oldTime).GetLo();
|
||||
}
|
||||
|
||||
#endif // wxUSE_LONGLONG
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// the functions to get the current time and timezone info
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Get local time as seconds since 00:00:00, Jan 1st 1970
|
||||
long wxGetLocalTime()
|
||||
{
|
||||
struct tm tm;
|
||||
time_t t0, t1;
|
||||
|
||||
// This cannot be made static because mktime can overwrite it.
|
||||
//
|
||||
memset(&tm, 0, sizeof(tm));
|
||||
tm.tm_year = 70;
|
||||
tm.tm_mon = 0;
|
||||
tm.tm_mday = 5; // not Jan 1st 1970 due to mktime 'feature'
|
||||
tm.tm_hour = 0;
|
||||
tm.tm_min = 0;
|
||||
tm.tm_sec = 0;
|
||||
tm.tm_isdst = -1; // let mktime guess
|
||||
|
||||
// Note that mktime assumes that the struct tm contains local time.
|
||||
//
|
||||
t1 = time(&t1); // now
|
||||
t0 = mktime(&tm); // origin
|
||||
|
||||
// Return the difference in seconds.
|
||||
//
|
||||
if (( t0 != (time_t)-1 ) && ( t1 != (time_t)-1 ))
|
||||
return (long)difftime(t1, t0) + (60 * 60 * 24 * 4);
|
||||
|
||||
wxLogSysError(_("Failed to get the local system time"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get UTC time as seconds since 00:00:00, Jan 1st 1970
|
||||
long wxGetUTCTime()
|
||||
{
|
||||
struct tm tm;
|
||||
struct tm *ptm;
|
||||
time_t t0, t1;
|
||||
|
||||
// This cannot be made static because mktime can overwrite it
|
||||
//
|
||||
memset(&tm, 0, sizeof(tm));
|
||||
tm.tm_year = 70;
|
||||
tm.tm_mon = 0;
|
||||
tm.tm_mday = 5; // not Jan 1st 1970 due to mktime 'feature'
|
||||
tm.tm_hour = 0;
|
||||
tm.tm_min = 0;
|
||||
tm.tm_sec = 0;
|
||||
tm.tm_isdst = -1; // let mktime guess
|
||||
|
||||
// Note that mktime assumes that the struct tm contains local time.
|
||||
//
|
||||
t1 = time(&t1); // now
|
||||
t0 = mktime(&tm); // origin in localtime
|
||||
|
||||
if (( t0 != (time_t)-1 ) && ( t1 != (time_t)-1 ))
|
||||
{
|
||||
// To get t0 as GMT we convert to a struct tm with gmtime,
|
||||
// and then back again.
|
||||
//
|
||||
ptm = gmtime(&t0);
|
||||
|
||||
if (ptm)
|
||||
{
|
||||
memcpy(&tm, ptm, sizeof(tm));
|
||||
t0 = mktime(&tm);
|
||||
|
||||
if (t0 != (time_t)-1 )
|
||||
return (long)difftime(t1, t0) + (60 * 60 * 24 * 4);
|
||||
wxLogSysError(_("mktime() failed"));
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogSysError(_("gmtime() failed"));
|
||||
}
|
||||
}
|
||||
|
||||
wxLogError(_("Failed to get the UTC system time."));
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if wxUSE_LONGLONG
|
||||
|
||||
// Get local time as milliseconds since 00:00:00, Jan 1st 1970
|
||||
wxLongLong wxGetLocalTimeMillis()
|
||||
{
|
||||
wxLongLong val = 1000l;
|
||||
|
||||
// If possible, use a function which avoids conversions from
|
||||
// broken-up time structures to milliseconds
|
||||
|
||||
#if defined(__WXMSW__) && defined(__MWERKS__)
|
||||
// This should probably be the way all WXMSW compilers should do it
|
||||
// Go direct to the OS for time
|
||||
|
||||
SYSTEMTIME thenst = { 1970, 1, 4, 1, 0, 0, 0, 0 }; // 00:00:00 Jan 1st 1970
|
||||
FILETIME thenft;
|
||||
SystemTimeToFileTime( &thenst, &thenft );
|
||||
wxLongLong then( thenft.dwHighDateTime, thenft.dwLowDateTime ); // time in 100 nanoseconds
|
||||
|
||||
SYSTEMTIME nowst;
|
||||
GetLocalTime( &nowst );
|
||||
FILETIME nowft;
|
||||
SystemTimeToFileTime( &nowst, &nowft );
|
||||
wxLongLong now( nowft.dwHighDateTime, nowft.dwLowDateTime ); // time in 100 nanoseconds
|
||||
|
||||
return ( now - then ) / 10000.0; // time from 00:00:00 Jan 1st 1970 to now in milliseconds
|
||||
|
||||
#elif defined(HAVE_GETTIMEOFDAY)
|
||||
struct timeval tp;
|
||||
if ( wxGetTimeOfDay(&tp, (struct timezone *)NULL) != -1 )
|
||||
{
|
||||
val *= tp.tv_sec;
|
||||
return (val + (tp.tv_usec / 1000));
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogError(_("wxGetTimeOfDay failed."));
|
||||
return 0;
|
||||
}
|
||||
#elif defined(HAVE_FTIME)
|
||||
struct timeb tp;
|
||||
|
||||
// ftime() is void and not int in some mingw32 headers, so don't
|
||||
// test the return code (well, it shouldn't fail anyhow...)
|
||||
(void)ftime(&tp);
|
||||
val *= tp.time;
|
||||
return (val + tp.millitm);
|
||||
#elif defined(__WXMAC__)
|
||||
|
||||
static UInt64 gMilliAtStart = 0;
|
||||
|
||||
Nanoseconds upTime = AbsoluteToNanoseconds( UpTime() );
|
||||
|
||||
if ( gMilliAtStart == 0 )
|
||||
{
|
||||
time_t start = time(NULL);
|
||||
gMilliAtStart = ((UInt64) start) * 1000000L;
|
||||
gMilliAtStart -= upTime.lo / 1000 ;
|
||||
gMilliAtStart -= ( ( (UInt64) upTime.hi ) << 32 ) / (1000 * 1000);
|
||||
}
|
||||
|
||||
UInt64 millival = gMilliAtStart;
|
||||
millival += upTime.lo / (1000 * 1000);
|
||||
millival += ( ( (UInt64) upTime.hi ) << 32 ) / (1000 * 1000);
|
||||
val = millival;
|
||||
|
||||
return val;
|
||||
#else // no gettimeofday() nor ftime()
|
||||
// We use wxGetLocalTime() to get the seconds since
|
||||
// 00:00:00 Jan 1st 1970 and then whatever is available
|
||||
// to get millisecond resolution.
|
||||
//
|
||||
// NOTE that this might lead to a problem if the clocks
|
||||
// use different sources, so this approach should be
|
||||
// avoided where possible.
|
||||
|
||||
val *= wxGetLocalTime();
|
||||
|
||||
// GRG: This will go soon as all WIN32 seem to have ftime
|
||||
#if defined (__WIN32__)
|
||||
// If your platform/compiler needs to use two different functions
|
||||
// to get ms resolution, please do NOT just shut off these warnings,
|
||||
// drop me a line instead at <guille@iies.es>
|
||||
#warning "Possible clock skew bug in wxGetLocalTimeMillis()!"
|
||||
|
||||
SYSTEMTIME st;
|
||||
::GetLocalTime(&st);
|
||||
val += st.wMilliseconds;
|
||||
#else // !Win32
|
||||
// If your platform/compiler does not support ms resolution please
|
||||
// do NOT just shut off these warnings, drop me a line instead at
|
||||
// <guille@iies.es>
|
||||
|
||||
#if defined(__VISUALC__) || defined (__WATCOMC__)
|
||||
#pragma message("wxStopWatch will be up to second resolution!")
|
||||
#elif defined(__BORLANDC__)
|
||||
#pragma message "wxStopWatch will be up to second resolution!"
|
||||
#else
|
||||
#warning "wxStopWatch will be up to second resolution!"
|
||||
#endif // compiler
|
||||
#endif
|
||||
|
||||
return val;
|
||||
|
||||
#endif // time functions
|
||||
}
|
||||
|
||||
#endif // #if wxUSE_STOPWATCH && wxUSE_LONGLONG
|
||||
#endif // wxUSE_TIMER
|
||||
|
||||
|
@ -92,15 +92,6 @@ extern bool g_isIdle;
|
||||
|
||||
void wxapp_install_idle_handler();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxExit
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void wxExit()
|
||||
{
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxYield
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -168,20 +159,15 @@ bool wxApp::Yield(bool onlyIfNeeded)
|
||||
// wxWakeUpIdle
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static bool gs_WakeUpIdle = false;
|
||||
|
||||
void wxWakeUpIdle()
|
||||
void wxApp::WakeUpIdle()
|
||||
{
|
||||
#if wxUSE_THREADS
|
||||
if (!wxThread::IsMain())
|
||||
wxMutexGuiEnter();
|
||||
#endif
|
||||
|
||||
if (g_isIdle) {
|
||||
gs_WakeUpIdle = true;
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
gs_WakeUpIdle = false;
|
||||
}
|
||||
|
||||
#if wxUSE_THREADS
|
||||
if (!wxThread::IsMain())
|
||||
@ -660,6 +646,13 @@ int wxApp::MainLoop()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wxApp::Exit()
|
||||
{
|
||||
// VZ: no idea why is it different from ExitMainLoop() but this is what
|
||||
// wxExit() used to do
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
void wxApp::ExitMainLoop()
|
||||
{
|
||||
if (gtk_main_level() > 0)
|
||||
|
@ -92,15 +92,6 @@ extern bool g_isIdle;
|
||||
|
||||
void wxapp_install_idle_handler();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxExit
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void wxExit()
|
||||
{
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxYield
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -168,20 +159,15 @@ bool wxApp::Yield(bool onlyIfNeeded)
|
||||
// wxWakeUpIdle
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static bool gs_WakeUpIdle = false;
|
||||
|
||||
void wxWakeUpIdle()
|
||||
void wxApp::WakeUpIdle()
|
||||
{
|
||||
#if wxUSE_THREADS
|
||||
if (!wxThread::IsMain())
|
||||
wxMutexGuiEnter();
|
||||
#endif
|
||||
|
||||
if (g_isIdle) {
|
||||
gs_WakeUpIdle = true;
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
gs_WakeUpIdle = false;
|
||||
}
|
||||
|
||||
#if wxUSE_THREADS
|
||||
if (!wxThread::IsMain())
|
||||
@ -660,6 +646,13 @@ int wxApp::MainLoop()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wxApp::Exit()
|
||||
{
|
||||
// VZ: no idea why is it different from ExitMainLoop() but this is what
|
||||
// wxExit() used to do
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
void wxApp::ExitMainLoop()
|
||||
{
|
||||
if (gtk_main_level() > 0)
|
||||
|
@ -1226,7 +1226,7 @@ void wxApp::OnIdle(wxIdleEvent& event)
|
||||
wxMenuBar::MacGetCommonMenuBar()->MacInstallMenuBar();
|
||||
}
|
||||
|
||||
void wxWakeUpIdle()
|
||||
void wxApp::WakeUpIdle()
|
||||
{
|
||||
wxMacWakeUp() ;
|
||||
}
|
||||
@ -1289,10 +1289,8 @@ void wxApp::DeletePendingObjects()
|
||||
}
|
||||
}
|
||||
|
||||
void wxExit()
|
||||
void wxApp::Exit()
|
||||
{
|
||||
wxLogError(_("Fatal error: exiting"));
|
||||
|
||||
wxApp::CleanUp();
|
||||
::ExitToShell() ;
|
||||
}
|
||||
|
@ -1226,7 +1226,7 @@ void wxApp::OnIdle(wxIdleEvent& event)
|
||||
wxMenuBar::MacGetCommonMenuBar()->MacInstallMenuBar();
|
||||
}
|
||||
|
||||
void wxWakeUpIdle()
|
||||
void wxApp::WakeUpIdle()
|
||||
{
|
||||
wxMacWakeUp() ;
|
||||
}
|
||||
@ -1289,10 +1289,8 @@ void wxApp::DeletePendingObjects()
|
||||
}
|
||||
}
|
||||
|
||||
void wxExit()
|
||||
void wxApp::Exit()
|
||||
{
|
||||
wxLogError(_("Fatal error: exiting"));
|
||||
|
||||
wxApp::CleanUp();
|
||||
::ExitToShell() ;
|
||||
}
|
||||
|
@ -45,11 +45,7 @@ wxApp *wxTheApp = NULL;
|
||||
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxExit
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void wxExit()
|
||||
void wxApp::Exit()
|
||||
{
|
||||
MGL_exit();
|
||||
exit(0);
|
||||
@ -108,14 +104,15 @@ bool wxApp::Yield(bool onlyIfNeeded)
|
||||
// wxWakeUpIdle
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void wxWakeUpIdle()
|
||||
void wxApp::WakeUpIdle()
|
||||
{
|
||||
#if wxUSE_THREADS
|
||||
if (!wxThread::IsMain())
|
||||
wxMutexGuiEnter();
|
||||
#endif
|
||||
|
||||
while (wxTheApp->ProcessIdle()) {}
|
||||
while (wxTheApp->ProcessIdle())
|
||||
;
|
||||
|
||||
#if wxUSE_THREADS
|
||||
if (!wxThread::IsMain())
|
||||
|
@ -161,6 +161,13 @@ void wxApp::CleanUp()
|
||||
delete wxLog::SetActiveTarget(NULL);
|
||||
}
|
||||
|
||||
void wxApp::Exit()
|
||||
{
|
||||
wxApp::CleanUp();
|
||||
|
||||
wxAppConsole::Exit();
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// wxEntry*
|
||||
// ============================================================================
|
||||
@ -593,21 +600,6 @@ void wxApp::SetTopLevelWidget(WXDisplay* display, WXWidget widget)
|
||||
(*m_perDisplayData)[display].m_topLevelWidget = (Widget)widget;
|
||||
}
|
||||
|
||||
void wxExit()
|
||||
{
|
||||
int retValue = 0;
|
||||
if (wxTheApp)
|
||||
retValue = wxTheApp->OnExit();
|
||||
|
||||
wxApp::CleanUp();
|
||||
/*
|
||||
* Exit in some platform-specific way.
|
||||
* Not recommended that the app calls this:
|
||||
* only for emergencies.
|
||||
*/
|
||||
exit(retValue);
|
||||
}
|
||||
|
||||
// Yield to other processes
|
||||
|
||||
bool wxApp::Yield(bool onlyIfNeeded)
|
||||
|
@ -463,7 +463,7 @@ static void wxBreakDispatch()
|
||||
write( idleFds[1], &dummy, 1 );
|
||||
}
|
||||
|
||||
void wxWakeUpIdle()
|
||||
void wxApp::WakeUpIdle()
|
||||
{
|
||||
::wxBreakDispatch();
|
||||
}
|
||||
|
140
src/msw/app.cpp
140
src/msw/app.cpp
@ -48,6 +48,7 @@
|
||||
#include "wx/log.h"
|
||||
#endif
|
||||
|
||||
#include "wx/apptrait.h"
|
||||
#include "wx/cmdline.h"
|
||||
#include "wx/filename.h"
|
||||
#include "wx/module.h"
|
||||
@ -130,7 +131,6 @@ extern void wxSetKeyboardHook(bool doIt);
|
||||
#endif
|
||||
|
||||
MSG s_currentMsg;
|
||||
wxApp *wxTheApp = NULL;
|
||||
|
||||
// NB: all "NoRedraw" classes must have the same names as the "normal" classes
|
||||
// with NR suffix - wxWindow::MSWCreate() supposes this
|
||||
@ -168,11 +168,92 @@ LRESULT WXDLLEXPORT APIENTRY wxWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
#endif
|
||||
|
||||
// ===========================================================================
|
||||
// implementation
|
||||
// wxGUIAppTraits implementation
|
||||
// ===========================================================================
|
||||
|
||||
// private class which we use to pass parameters from BeforeChildWaitLoop() to
|
||||
// AfterChildWaitLoop()
|
||||
struct ChildWaitLoopData
|
||||
{
|
||||
ChildWaitLoopData(wxWindowDisabler *wd_, wxWindow *winActive_)
|
||||
{
|
||||
wd = wd_;
|
||||
winActive = winActive_;
|
||||
}
|
||||
|
||||
wxWindowDisabler *wd;
|
||||
wxWindow *winActive;
|
||||
};
|
||||
|
||||
void *wxGUIAppTraits::BeforeChildWaitLoop()
|
||||
{
|
||||
/*
|
||||
We use a dirty hack here to disable all application windows (which we
|
||||
must do because otherwise the calls to wxYield() could lead to some very
|
||||
unexpected reentrancies in the users code) but to avoid losing
|
||||
focus/activation entirely when the child process terminates which would
|
||||
happen if we simply disabled everything using wxWindowDisabler. Indeed,
|
||||
remember that Windows will never activate a disabled window and when the
|
||||
last childs window is closed and Windows looks for a window to activate
|
||||
all our windows are still disabled. There is no way to enable them in
|
||||
time because we don't know when the childs windows are going to be
|
||||
closed, so the solution we use here is to keep one special tiny frame
|
||||
enabled all the time. Then when the child terminates it will get
|
||||
activated and when we close it below -- after reenabling all the other
|
||||
windows! -- the previously active window becomes activated again and
|
||||
everything is ok.
|
||||
*/
|
||||
wxBeginBusyCursor();
|
||||
|
||||
// first disable all existing windows
|
||||
wxWindowDisabler *wd = new wxWindowDisabler;
|
||||
|
||||
// then create an "invisible" frame: it has minimal size, is positioned
|
||||
// (hopefully) outside the screen and doesn't appear on the taskbar
|
||||
wxWindow *winActive = new wxFrame
|
||||
(
|
||||
wxTheApp->GetTopWindow(),
|
||||
-1,
|
||||
_T(""),
|
||||
wxPoint(32600, 32600),
|
||||
wxSize(1, 1),
|
||||
wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR
|
||||
);
|
||||
winActive->Show();
|
||||
|
||||
return new ChildWaitLoopData(wd, winActive);
|
||||
}
|
||||
|
||||
void wxGUIAppTraits::AlwaysYield()
|
||||
{
|
||||
wxYield();
|
||||
}
|
||||
|
||||
void wxGUIAppTraits::AfterChildWaitLoop(void *dataOrig)
|
||||
{
|
||||
wxEndBusyCursor();
|
||||
|
||||
const ChildWaitLoopData * const data = (ChildWaitLoopData *)dataOrig;
|
||||
|
||||
delete data->wd;
|
||||
|
||||
// finally delete the dummy frame and, as wd has been already destroyed and
|
||||
// the other windows reenabled, the activation is going to return to the
|
||||
// window which had had it before
|
||||
data->winActive->Destroy();
|
||||
}
|
||||
|
||||
bool wxGUIAppTraits::DoMessageFromThreadWait()
|
||||
{
|
||||
return !wxTheApp || wxTheApp->DoMessage();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// wxApp implementation
|
||||
// ===========================================================================
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxApp
|
||||
// wxWin macros
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
|
||||
@ -799,8 +880,6 @@ int wxEntry(WXHINSTANCE hInstance)
|
||||
|
||||
//// Static member initialization
|
||||
|
||||
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
|
||||
|
||||
wxApp::wxApp()
|
||||
{
|
||||
argc = 0;
|
||||
@ -1146,6 +1225,23 @@ bool wxApp::SendIdleEvents(wxWindow* win)
|
||||
return needMore;
|
||||
}
|
||||
|
||||
void wxApp::WakeUpIdle()
|
||||
{
|
||||
// Send the top window a dummy message so idle handler processing will
|
||||
// start up again. Doing it this way ensures that the idle handler
|
||||
// wakes up in the right thread (see also wxWakeUpMainThread() which does
|
||||
// the same for the main app thread only)
|
||||
wxWindow *topWindow = wxTheApp->GetTopWindow();
|
||||
if ( topWindow )
|
||||
{
|
||||
if ( !::PostMessage(GetHwndOf(topWindow), WM_NULL, 0, 0) )
|
||||
{
|
||||
// should never happen
|
||||
wxLogLastError(wxT("PostMessage(WM_NULL)"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wxApp::DeletePendingObjects()
|
||||
{
|
||||
wxNode *node = wxPendingDelete.GetFirst();
|
||||
@ -1295,19 +1391,6 @@ int wxApp::GetComCtl32Version()
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxExit()
|
||||
{
|
||||
if ( wxTheApp )
|
||||
{
|
||||
wxTheApp->ExitMainLoop();
|
||||
}
|
||||
else
|
||||
{
|
||||
// what else can we do?
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
// Yield to incoming messages
|
||||
|
||||
bool wxApp::Yield(bool onlyIfNeeded)
|
||||
@ -1375,27 +1458,6 @@ bool wxHandleFatalExceptions(bool doit)
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxWakeUpIdle
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void wxWakeUpIdle()
|
||||
{
|
||||
// Send the top window a dummy message so idle handler processing will
|
||||
// start up again. Doing it this way ensures that the idle handler
|
||||
// wakes up in the right thread (see also wxWakeUpMainThread() which does
|
||||
// the same for the main app thread only)
|
||||
wxWindow *topWindow = wxTheApp->GetTopWindow();
|
||||
if ( topWindow )
|
||||
{
|
||||
if ( !::PostMessage(GetHwndOf(topWindow), WM_NULL, 0, 0) )
|
||||
{
|
||||
// should never happen
|
||||
wxLogLastError(wxT("PostMessage(WM_NULL)"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// For some reason, with MSVC++ 1.5, WinMain isn't linked in properly
|
||||
|
61
src/msw/basemsw.cpp
Normal file
61
src/msw/basemsw.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: msw/basemsw.cpp
|
||||
// Purpose: misc stuff only used in console applications under MSW
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 22.06.2003
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
|
||||
// License: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// for compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#include "wx/apptrait.h"
|
||||
|
||||
#include "wx/msw/private.h"
|
||||
|
||||
// ============================================================================
|
||||
// wxConsoleAppTraits implementation
|
||||
// ============================================================================
|
||||
|
||||
void wxConsoleAppTraits::AlwaysYield()
|
||||
{
|
||||
MSG msg;
|
||||
while ( ::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )
|
||||
;
|
||||
}
|
||||
|
||||
void *wxConsoleAppTraits::BeforeChildWaitLoop()
|
||||
{
|
||||
// nothing to do here
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void wxConsoleAppTraits::AfterChildWaitLoop(void * WXUNUSED(data))
|
||||
{
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
bool wxConsoleAppTraits::DoMessageFromThreadWait()
|
||||
{
|
||||
// nothing to process here
|
||||
return true;
|
||||
}
|
||||
|
@ -118,83 +118,10 @@ bool wxGetNativeFontEncoding(wxFontEncoding encoding,
|
||||
encoding = wxFont::GetDefaultEncoding();
|
||||
}
|
||||
|
||||
switch ( encoding )
|
||||
{
|
||||
// although this function is supposed to return an exact match, do do
|
||||
// some mappings here for the most common case of "standard" encoding
|
||||
case wxFONTENCODING_SYSTEM:
|
||||
info->charset = DEFAULT_CHARSET;
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_ISO8859_1:
|
||||
case wxFONTENCODING_ISO8859_15:
|
||||
case wxFONTENCODING_CP1252:
|
||||
info->charset = ANSI_CHARSET;
|
||||
break;
|
||||
|
||||
#if !defined(__WIN16__) && !defined(__WXMICROWIN__)
|
||||
|
||||
// The following four fonts are multi-byte charsets
|
||||
case wxFONTENCODING_CP932:
|
||||
info->charset = SHIFTJIS_CHARSET;
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_CP936:
|
||||
info->charset = GB2312_CHARSET;
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_CP949:
|
||||
info->charset = HANGUL_CHARSET;
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_CP950:
|
||||
info->charset = CHINESEBIG5_CHARSET;
|
||||
break;
|
||||
|
||||
// The rest are single byte encodings
|
||||
case wxFONTENCODING_CP1250:
|
||||
info->charset = EASTEUROPE_CHARSET;
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_CP1251:
|
||||
info->charset = RUSSIAN_CHARSET;
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_CP1253:
|
||||
info->charset = GREEK_CHARSET;
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_CP1254:
|
||||
info->charset = TURKISH_CHARSET;
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_CP1255:
|
||||
info->charset = HEBREW_CHARSET;
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_CP1256:
|
||||
info->charset = ARABIC_CHARSET;
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_CP1257:
|
||||
info->charset = BALTIC_CHARSET;
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_CP874:
|
||||
info->charset = THAI_CHARSET;
|
||||
break;
|
||||
|
||||
|
||||
#endif // !Win16
|
||||
|
||||
case wxFONTENCODING_CP437:
|
||||
info->charset = OEM_CHARSET;
|
||||
break;
|
||||
|
||||
default:
|
||||
// no way to translate this encoding into a Windows charset
|
||||
return FALSE;
|
||||
}
|
||||
extern long wxEncodingToCharset(wxFontEncoding encoding);
|
||||
info->charset = wxEncodingToCharset(encoding);
|
||||
if ( info->charset == -1 )
|
||||
return FALSE;
|
||||
|
||||
info->encoding = encoding;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: msw/main.cpp
|
||||
// Purpose: Main/DllMain
|
||||
// Purpose: WinMain/DllMain
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 04/01/98
|
||||
@ -33,85 +33,74 @@
|
||||
|
||||
#include "wx/msw/private.h"
|
||||
|
||||
// Don't implement WinMain if we're building an MFC/wxWindows
|
||||
// hybrid app.
|
||||
// Don't implement WinMain if we're building an MFC/wxWindows hybrid app.
|
||||
#if wxUSE_MFC && !defined(NOMAIN)
|
||||
#define NOMAIN 1
|
||||
#define NOMAIN 1
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
// BC++ has to be special: its run-time expects the DLL entry point to be
|
||||
// named DllEntryPoint instead of the (more) standard DllMain
|
||||
#define DllMain DllEntryPoint
|
||||
#endif
|
||||
|
||||
#if defined(__WXMICROWIN__)
|
||||
#define HINSTANCE HANDLE
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// function prototypes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// from src/msw/app.cpp
|
||||
extern void WXDLLEXPORT wxEntryCleanup();
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// globals
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
HINSTANCE wxhInstance = 0;
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// implementation: various entry points
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// various entry points
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// May wish not to have a DllMain or WinMain, e.g. if we're programming
|
||||
// a Netscape plugin or if we're writing a console application
|
||||
#if wxUSE_GUI && !defined(NOMAIN)
|
||||
|
||||
// NT defines APIENTRY, 3.x not
|
||||
#if !defined(APIENTRY)
|
||||
#define APIENTRY FAR PASCAL
|
||||
#endif
|
||||
extern "C"
|
||||
{
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// ----------------------------------------------------------------------------
|
||||
// WinMain
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Note that WinMain is also defined in dummy.obj, which is linked to
|
||||
// an application that is using the DLL version of wxWindows.
|
||||
|
||||
#if !defined(_WINDLL)
|
||||
|
||||
#if defined(__WXMICROWIN__)
|
||||
#define HINSTANCE HANDLE
|
||||
|
||||
extern "C"
|
||||
#endif
|
||||
|
||||
int PASCAL WinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance,
|
||||
lpCmdLine, nCmdShow);
|
||||
return wxEntry((WXHINSTANCE) hInstance,
|
||||
(WXHINSTANCE) hPrevInstance,
|
||||
lpCmdLine,
|
||||
nCmdShow);
|
||||
}
|
||||
|
||||
#endif // !defined(_WINDLL)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// DllMain
|
||||
|
||||
#if defined(_WINDLL)
|
||||
#else // _WINDLL
|
||||
|
||||
// DLL entry point
|
||||
|
||||
extern "C"
|
||||
#ifdef __BORLANDC__
|
||||
// SCD: I don't know why, but also OWL uses this function
|
||||
BOOL WINAPI DllEntryPoint (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
|
||||
#else
|
||||
BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
|
||||
#endif
|
||||
BOOL WINAPI
|
||||
DllMain(HANDLE hModule, DWORD fdwReason, LPVOID WXUNUSED(lpReserved))
|
||||
{
|
||||
// Only call wxEntry if the application itself is part of the DLL.
|
||||
// If only the wxWindows library is in the DLL, then the
|
||||
// initialisation will be called when the application implicitly
|
||||
// calls WinMain.
|
||||
#ifndef WXMAKINGDLL
|
||||
switch (fdwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
// Only call wxEntry if the application itself is part of the DLL.
|
||||
// If only the wxWindows library is in the DLL, then the
|
||||
// initialisation will be called when the application implicitly
|
||||
// calls WinMain.
|
||||
return wxEntry((WXHINSTANCE) hModule);
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
@ -124,18 +113,24 @@ BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
|
||||
(void)hModule;
|
||||
(void)fdwReason;
|
||||
#endif // !WXMAKINGDLL
|
||||
(void)lpReserved;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif // _WINDLL
|
||||
#endif // _WINDLL/!_WINDLL
|
||||
|
||||
} // extern "C"
|
||||
|
||||
#endif // !NOMAIN
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global functions
|
||||
// global HINSTANCE
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __WXBASE__
|
||||
|
||||
HINSTANCE wxhInstance = 0;
|
||||
|
||||
HINSTANCE wxGetInstance()
|
||||
{
|
||||
return wxhInstance;
|
||||
@ -146,3 +141,5 @@ void wxSetInstance(HINSTANCE hInst)
|
||||
wxhInstance = hInst;
|
||||
}
|
||||
|
||||
#endif // __WXBASE__
|
||||
|
||||
|
@ -131,6 +131,8 @@ WXDLLEXPORT int wxMSLU_GetSaveFileNameW(void *ofn)
|
||||
// Missing libc file manipulation functions in Win9x
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#ifdef __WXBASE__
|
||||
|
||||
WXDLLEXPORT int wxMSLU__trename(const wxChar *oldname, const wxChar *newname)
|
||||
{
|
||||
if ( wxUsingUnicowsDll() )
|
||||
@ -196,6 +198,8 @@ WXDLLEXPORT int wxMSLU__wstat(const wxChar *name, struct _stat *buffer)
|
||||
return _wstat(name, buffer);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // compilers having wopen() &c
|
||||
|
||||
#endif // __WXBASE__
|
||||
|
||||
#endif // wxUSE_UNICODE_MSLU
|
||||
|
@ -26,11 +26,12 @@
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
# include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#if wxUSE_THREADS
|
||||
|
||||
#include "wx/apptrait.h"
|
||||
|
||||
#include "wx/msw/private.h"
|
||||
#include "wx/msw/missing.h"
|
||||
|
||||
@ -1000,10 +1001,11 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
|
||||
m_internal->Cancel();
|
||||
}
|
||||
|
||||
#if wxUSE_GUI
|
||||
// we can't just wait for the thread to terminate because it might be
|
||||
// calling some GUI functions and so it will never terminate before we
|
||||
// process the Windows messages that result from these functions
|
||||
// (note that even in console applications we might have to process
|
||||
// messages if we use wxExecute() or timers or ...)
|
||||
DWORD result = 0; // suppress warnings from broken compilers
|
||||
do
|
||||
{
|
||||
@ -1041,12 +1043,17 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
|
||||
|
||||
case WAIT_OBJECT_0 + 1:
|
||||
// new message arrived, process it
|
||||
if ( !wxTheApp->DoMessage() )
|
||||
{
|
||||
// WM_QUIT received: kill the thread
|
||||
Kill();
|
||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits()
|
||||
: NULL;
|
||||
|
||||
return wxTHREAD_KILLED;
|
||||
if ( traits && !traits->DoMessageFromThreadWait() )
|
||||
{
|
||||
// WM_QUIT received: kill the thread
|
||||
Kill();
|
||||
|
||||
return wxTHREAD_KILLED;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1054,16 +1061,6 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
|
||||
wxFAIL_MSG(wxT("unexpected result of MsgWaitForMultipleObject"));
|
||||
}
|
||||
} while ( result != WAIT_OBJECT_0 );
|
||||
#else // !wxUSE_GUI
|
||||
// simply wait for the thread to terminate
|
||||
//
|
||||
// OTOH, even console apps create windows (in wxExecute, for WinSock
|
||||
// &c), so may be use MsgWaitForMultipleObject() too here?
|
||||
if ( WaitForSingleObject(hThread, INFINITE) != WAIT_OBJECT_0 )
|
||||
{
|
||||
wxFAIL_MSG(wxT("unexpected result of WaitForSingleObject"));
|
||||
}
|
||||
#endif // wxUSE_GUI/!wxUSE_GUI
|
||||
|
||||
if ( IsMain() )
|
||||
{
|
||||
|
@ -17,10 +17,6 @@
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma implementation "utils.h" // Note: this is done in utilscmn.cpp now.
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
@ -33,9 +29,6 @@
|
||||
#include "wx/app.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/log.h"
|
||||
#if wxUSE_GUI
|
||||
#include "wx/cursor.h"
|
||||
#endif
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#include "wx/msw/private.h" // includes <windows.h>
|
||||
@ -94,32 +87,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//// BEGIN for console support: VC++ only
|
||||
#ifdef __VISUALC__
|
||||
|
||||
#include "wx/msw/msvcrt.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "wx/ioswrap.h"
|
||||
|
||||
/* Need to undef new if including crtdbg.h */
|
||||
# ifdef new
|
||||
# undef new
|
||||
# endif
|
||||
|
||||
#ifndef __WIN16__
|
||||
# include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
# if defined(__WXDEBUG__) && wxUSE_GLOBAL_MEMORY_OPERATORS && wxUSE_DEBUG_NEW_ALWAYS
|
||||
# define new new(__TFILE__,__LINE__)
|
||||
# endif
|
||||
|
||||
#endif
|
||||
// __VISUALC__
|
||||
/// END for console support
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -134,8 +101,6 @@ static const wxChar eHOSTNAME[] = wxT("HostName");
|
||||
static const wxChar eUSERID[] = wxT("UserId");
|
||||
#endif // !Win32
|
||||
|
||||
#ifndef __WXMICROWIN__
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
@ -1073,77 +1038,6 @@ int wxGetOsVersion(int *majorVsn, int *minorVsn)
|
||||
// sleep functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
#if wxUSE_TIMER
|
||||
|
||||
// Sleep for nSecs seconds. Attempt a Windows implementation using timers.
|
||||
static bool gs_inTimer = FALSE;
|
||||
|
||||
class wxSleepTimer : public wxTimer
|
||||
{
|
||||
public:
|
||||
virtual void Notify()
|
||||
{
|
||||
gs_inTimer = FALSE;
|
||||
Stop();
|
||||
}
|
||||
};
|
||||
|
||||
static wxTimer *wxTheSleepTimer = NULL;
|
||||
|
||||
void wxUsleep(unsigned long milliseconds)
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
::Sleep(milliseconds);
|
||||
#else // !Win32
|
||||
if (gs_inTimer)
|
||||
return;
|
||||
if (miliseconds <= 0)
|
||||
return;
|
||||
|
||||
wxTheSleepTimer = new wxSleepTimer;
|
||||
gs_inTimer = TRUE;
|
||||
wxTheSleepTimer->Start(milliseconds);
|
||||
while (gs_inTimer)
|
||||
{
|
||||
if (wxTheApp->Pending())
|
||||
wxTheApp->Dispatch();
|
||||
}
|
||||
delete wxTheSleepTimer;
|
||||
wxTheSleepTimer = NULL;
|
||||
#endif // Win32/!Win32
|
||||
}
|
||||
|
||||
void wxSleep(int nSecs)
|
||||
{
|
||||
if (gs_inTimer)
|
||||
return;
|
||||
if (nSecs <= 0)
|
||||
return;
|
||||
|
||||
wxTheSleepTimer = new wxSleepTimer;
|
||||
gs_inTimer = TRUE;
|
||||
wxTheSleepTimer->Start(nSecs*1000);
|
||||
while (gs_inTimer)
|
||||
{
|
||||
if (wxTheApp->Pending())
|
||||
wxTheApp->Dispatch();
|
||||
}
|
||||
delete wxTheSleepTimer;
|
||||
wxTheSleepTimer = NULL;
|
||||
}
|
||||
|
||||
// Consume all events until no more left
|
||||
void wxFlushEvents()
|
||||
{
|
||||
// wxYield();
|
||||
}
|
||||
|
||||
#endif // wxUSE_TIMER
|
||||
|
||||
#elif defined(__WIN32__) // wxUSE_GUI
|
||||
|
||||
void wxUsleep(unsigned long milliseconds)
|
||||
{
|
||||
::Sleep(milliseconds);
|
||||
@ -1154,497 +1048,90 @@ void wxSleep(int nSecs)
|
||||
wxUsleep(1000*nSecs);
|
||||
}
|
||||
|
||||
#endif // wxUSE_GUI/!wxUSE_GUI
|
||||
#endif // __WXMICROWIN__
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// deprecated (in favour of wxLog) log functions
|
||||
// font encoding <-> Win32 codepage conversion functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_2
|
||||
|
||||
// Output a debug mess., in a system dependent fashion.
|
||||
#ifndef __WXMICROWIN__
|
||||
void wxDebugMsg(const wxChar *fmt ...)
|
||||
extern long wxEncodingToCharset(wxFontEncoding encoding)
|
||||
{
|
||||
va_list ap;
|
||||
static wxChar buffer[512];
|
||||
|
||||
if (!wxTheApp->GetWantDebugOutput())
|
||||
return;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
||||
wvsprintf(buffer,fmt,ap);
|
||||
OutputDebugString((LPCTSTR)buffer);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
// Non-fatal error: pop up message box and (possibly) continue
|
||||
void wxError(const wxString& msg, const wxString& title)
|
||||
{
|
||||
wxSprintf(wxBuffer, wxT("%s\nContinue?"), WXSTRINGCAST msg);
|
||||
if (MessageBox(NULL, (LPCTSTR)wxBuffer, (LPCTSTR)WXSTRINGCAST title,
|
||||
MB_ICONSTOP | MB_YESNO) == IDNO)
|
||||
wxExit();
|
||||
}
|
||||
|
||||
// Fatal error: pop up message box and abort
|
||||
void wxFatalError(const wxString& msg, const wxString& title)
|
||||
{
|
||||
wxSprintf(wxBuffer, wxT("%s: %s"), WXSTRINGCAST title, WXSTRINGCAST msg);
|
||||
FatalAppExit(0, (LPCTSTR)wxBuffer);
|
||||
}
|
||||
#endif // __WXMICROWIN__
|
||||
|
||||
#endif // WXWIN_COMPATIBILITY_2_2
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// functions to work with .INI files
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Reading and writing resources (eg WIN.INI, .Xdefaults)
|
||||
#if wxUSE_RESOURCES
|
||||
bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
|
||||
{
|
||||
if (file != wxT(""))
|
||||
// Don't know what the correct cast should be, but it doesn't
|
||||
// compile in BC++/16-bit without this cast.
|
||||
#if !defined(__WIN32__)
|
||||
return (WritePrivateProfileString((const char*) section, (const char*) entry, (const char*) value, (const char*) file) != 0);
|
||||
#else
|
||||
return (WritePrivateProfileString((LPCTSTR)WXSTRINGCAST section, (LPCTSTR)WXSTRINGCAST entry, (LPCTSTR)value, (LPCTSTR)WXSTRINGCAST file) != 0);
|
||||
#endif
|
||||
else
|
||||
return (WriteProfileString((LPCTSTR)WXSTRINGCAST section, (LPCTSTR)WXSTRINGCAST entry, (LPCTSTR)WXSTRINGCAST value) != 0);
|
||||
}
|
||||
|
||||
bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file)
|
||||
{
|
||||
wxString buf;
|
||||
buf.Printf(wxT("%.4f"), value);
|
||||
|
||||
return wxWriteResource(section, entry, buf, file);
|
||||
}
|
||||
|
||||
bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file)
|
||||
{
|
||||
wxString buf;
|
||||
buf.Printf(wxT("%ld"), value);
|
||||
|
||||
return wxWriteResource(section, entry, buf, file);
|
||||
}
|
||||
|
||||
bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file)
|
||||
{
|
||||
wxString buf;
|
||||
buf.Printf(wxT("%d"), value);
|
||||
|
||||
return wxWriteResource(section, entry, buf, file);
|
||||
}
|
||||
|
||||
bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file)
|
||||
{
|
||||
static const wxChar defunkt[] = wxT("$$default");
|
||||
if (file != wxT(""))
|
||||
switch ( encoding )
|
||||
{
|
||||
int n = GetPrivateProfileString((LPCTSTR)WXSTRINGCAST section, (LPCTSTR)WXSTRINGCAST entry, (LPCTSTR)defunkt,
|
||||
(LPTSTR)wxBuffer, 1000, (LPCTSTR)WXSTRINGCAST file);
|
||||
if (n == 0 || wxStrcmp(wxBuffer, defunkt) == 0)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
int n = GetProfileString((LPCTSTR)WXSTRINGCAST section, (LPCTSTR)WXSTRINGCAST entry, (LPCTSTR)defunkt,
|
||||
(LPTSTR)wxBuffer, 1000);
|
||||
if (n == 0 || wxStrcmp(wxBuffer, defunkt) == 0)
|
||||
return FALSE;
|
||||
}
|
||||
if (*value) delete[] (*value);
|
||||
*value = copystring(wxBuffer);
|
||||
return TRUE;
|
||||
}
|
||||
// although this function is supposed to return an exact match, do do
|
||||
// some mappings here for the most common case of "standard" encoding
|
||||
case wxFONTENCODING_SYSTEM:
|
||||
return DEFAULT_CHARSET;
|
||||
|
||||
bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file)
|
||||
{
|
||||
wxChar *s = NULL;
|
||||
bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
|
||||
if (succ)
|
||||
{
|
||||
*value = (float)wxStrtod(s, NULL);
|
||||
delete[] s;
|
||||
return TRUE;
|
||||
}
|
||||
else return FALSE;
|
||||
}
|
||||
case wxFONTENCODING_ISO8859_1:
|
||||
case wxFONTENCODING_ISO8859_15:
|
||||
case wxFONTENCODING_CP1252:
|
||||
return ANSI_CHARSET;
|
||||
|
||||
bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file)
|
||||
{
|
||||
wxChar *s = NULL;
|
||||
bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
|
||||
if (succ)
|
||||
{
|
||||
*value = wxStrtol(s, NULL, 10);
|
||||
delete[] s;
|
||||
return TRUE;
|
||||
}
|
||||
else return FALSE;
|
||||
}
|
||||
#if !defined(__WXMICROWIN__)
|
||||
// The following four fonts are multi-byte charsets
|
||||
case wxFONTENCODING_CP932:
|
||||
return SHIFTJIS_CHARSET;
|
||||
|
||||
bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file)
|
||||
{
|
||||
wxChar *s = NULL;
|
||||
bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
|
||||
if (succ)
|
||||
{
|
||||
*value = (int)wxStrtol(s, NULL, 10);
|
||||
delete[] s;
|
||||
return TRUE;
|
||||
}
|
||||
else return FALSE;
|
||||
}
|
||||
#endif // wxUSE_RESOURCES
|
||||
case wxFONTENCODING_CP936:
|
||||
return GB2312_CHARSET;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// helper functions for showing a "busy" cursor
|
||||
// ---------------------------------------------------------------------------
|
||||
case wxFONTENCODING_CP949:
|
||||
return HANGUL_CHARSET;
|
||||
|
||||
static HCURSOR gs_wxBusyCursor = 0; // new, busy cursor
|
||||
static HCURSOR gs_wxBusyCursorOld = 0; // old cursor
|
||||
static int gs_wxBusyCursorCount = 0;
|
||||
case wxFONTENCODING_CP950:
|
||||
return CHINESEBIG5_CHARSET;
|
||||
|
||||
extern HCURSOR wxGetCurrentBusyCursor()
|
||||
{
|
||||
return gs_wxBusyCursor;
|
||||
}
|
||||
// The rest are single byte encodings
|
||||
case wxFONTENCODING_CP1250:
|
||||
return EASTEUROPE_CHARSET;
|
||||
|
||||
// Set the cursor to the busy cursor for all windows
|
||||
void wxBeginBusyCursor(wxCursor *cursor)
|
||||
{
|
||||
if ( gs_wxBusyCursorCount++ == 0 )
|
||||
{
|
||||
gs_wxBusyCursor = (HCURSOR)cursor->GetHCURSOR();
|
||||
#ifndef __WXMICROWIN__
|
||||
gs_wxBusyCursorOld = ::SetCursor(gs_wxBusyCursor);
|
||||
#endif
|
||||
}
|
||||
//else: nothing to do, already set
|
||||
}
|
||||
case wxFONTENCODING_CP1251:
|
||||
return RUSSIAN_CHARSET;
|
||||
|
||||
// Restore cursor to normal
|
||||
void wxEndBusyCursor()
|
||||
{
|
||||
wxCHECK_RET( gs_wxBusyCursorCount > 0,
|
||||
wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") );
|
||||
case wxFONTENCODING_CP1253:
|
||||
return GREEK_CHARSET;
|
||||
|
||||
if ( --gs_wxBusyCursorCount == 0 )
|
||||
{
|
||||
#ifndef __WXMICROWIN__
|
||||
::SetCursor(gs_wxBusyCursorOld);
|
||||
#endif
|
||||
gs_wxBusyCursorOld = 0;
|
||||
}
|
||||
}
|
||||
case wxFONTENCODING_CP1254:
|
||||
return TURKISH_CHARSET;
|
||||
|
||||
// TRUE if we're between the above two calls
|
||||
bool wxIsBusy()
|
||||
{
|
||||
return gs_wxBusyCursorCount > 0;
|
||||
}
|
||||
case wxFONTENCODING_CP1255:
|
||||
return HEBREW_CHARSET;
|
||||
|
||||
// Check whether this window wants to process messages, e.g. Stop button
|
||||
// in long calculations.
|
||||
bool wxCheckForInterrupt(wxWindow *wnd)
|
||||
{
|
||||
wxCHECK( wnd, FALSE );
|
||||
case wxFONTENCODING_CP1256:
|
||||
return ARABIC_CHARSET;
|
||||
|
||||
MSG msg;
|
||||
while ( ::PeekMessage(&msg, GetHwndOf(wnd), 0, 0, PM_REMOVE) )
|
||||
{
|
||||
::TranslateMessage(&msg);
|
||||
::DispatchMessage(&msg);
|
||||
}
|
||||
case wxFONTENCODING_CP1257:
|
||||
return BALTIC_CHARSET;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// MSW only: get user-defined resource from the .res file.
|
||||
// Returns NULL or newly-allocated memory, so use delete[] to clean up.
|
||||
|
||||
#ifndef __WXMICROWIN__
|
||||
wxChar *wxLoadUserResource(const wxString& resourceName, const wxString& resourceType)
|
||||
{
|
||||
HRSRC hResource = ::FindResource(wxGetInstance(), resourceName, resourceType);
|
||||
if ( hResource == 0 )
|
||||
return NULL;
|
||||
|
||||
HGLOBAL hData = ::LoadResource(wxGetInstance(), hResource);
|
||||
if ( hData == 0 )
|
||||
return NULL;
|
||||
|
||||
wxChar *theText = (wxChar *)::LockResource(hData);
|
||||
if ( !theText )
|
||||
return NULL;
|
||||
|
||||
// Not all compilers put a zero at the end of the resource (e.g. BC++ doesn't).
|
||||
// so we need to find the length of the resource.
|
||||
int len = ::SizeofResource(wxGetInstance(), hResource);
|
||||
wxChar *s = new wxChar[len+1];
|
||||
wxStrncpy(s,theText,len);
|
||||
s[len]=0;
|
||||
|
||||
// wxChar *s = copystring(theText);
|
||||
|
||||
// Obsolete in WIN32
|
||||
#ifndef __WIN32__
|
||||
UnlockResource(hData);
|
||||
#endif
|
||||
|
||||
// No need??
|
||||
// GlobalFree(hData);
|
||||
|
||||
return s;
|
||||
}
|
||||
#endif // __WXMICROWIN__
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// get display info
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// See also the wxGetMousePosition in window.cpp
|
||||
// Deprecated: use wxPoint wxGetMousePosition() instead
|
||||
void wxGetMousePosition( int* x, int* y )
|
||||
{
|
||||
POINT pt;
|
||||
GetCursorPos( & pt );
|
||||
if ( x ) *x = pt.x;
|
||||
if ( y ) *y = pt.y;
|
||||
};
|
||||
|
||||
// Return TRUE if we have a colour display
|
||||
bool wxColourDisplay()
|
||||
{
|
||||
#ifdef __WXMICROWIN__
|
||||
// MICROWIN_TODO
|
||||
return TRUE;
|
||||
#else
|
||||
// this function is called from wxDC ctor so it is called a *lot* of times
|
||||
// hence we optimize it a bit but doign the check only once
|
||||
//
|
||||
// this should be MT safe as only the GUI thread (holding the GUI mutex)
|
||||
// can call us
|
||||
static int s_isColour = -1;
|
||||
|
||||
if ( s_isColour == -1 )
|
||||
{
|
||||
ScreenHDC dc;
|
||||
int noCols = ::GetDeviceCaps(dc, NUMCOLORS);
|
||||
|
||||
s_isColour = (noCols == -1) || (noCols > 2);
|
||||
}
|
||||
|
||||
return s_isColour != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Returns depth of screen
|
||||
int wxDisplayDepth()
|
||||
{
|
||||
ScreenHDC dc;
|
||||
return GetDeviceCaps(dc, PLANES) * GetDeviceCaps(dc, BITSPIXEL);
|
||||
}
|
||||
|
||||
// Get size of display
|
||||
void wxDisplaySize(int *width, int *height)
|
||||
{
|
||||
#ifdef __WXMICROWIN__
|
||||
RECT rect;
|
||||
HWND hWnd = GetDesktopWindow();
|
||||
::GetWindowRect(hWnd, & rect);
|
||||
|
||||
if ( width )
|
||||
*width = rect.right - rect.left;
|
||||
if ( height )
|
||||
*height = rect.bottom - rect.top;
|
||||
#else // !__WXMICROWIN__
|
||||
ScreenHDC dc;
|
||||
|
||||
if ( width )
|
||||
*width = ::GetDeviceCaps(dc, HORZRES);
|
||||
if ( height )
|
||||
*height = ::GetDeviceCaps(dc, VERTRES);
|
||||
#endif // __WXMICROWIN__/!__WXMICROWIN__
|
||||
}
|
||||
|
||||
void wxDisplaySizeMM(int *width, int *height)
|
||||
{
|
||||
#ifdef __WXMICROWIN__
|
||||
// MICROWIN_TODO
|
||||
if ( width )
|
||||
*width = 0;
|
||||
if ( height )
|
||||
*height = 0;
|
||||
#else
|
||||
ScreenHDC dc;
|
||||
|
||||
if ( width )
|
||||
*width = ::GetDeviceCaps(dc, HORZSIZE);
|
||||
if ( height )
|
||||
*height = ::GetDeviceCaps(dc, VERTSIZE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxClientDisplayRect(int *x, int *y, int *width, int *height)
|
||||
{
|
||||
#if defined(__WIN16__) || defined(__WXMICROWIN__)
|
||||
*x = 0; *y = 0;
|
||||
wxDisplaySize(width, height);
|
||||
#else
|
||||
// Determine the desktop dimensions minus the taskbar and any other
|
||||
// special decorations...
|
||||
RECT r;
|
||||
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
|
||||
if (x) *x = r.left;
|
||||
if (y) *y = r.top;
|
||||
if (width) *width = r.right - r.left;
|
||||
if (height) *height = r.bottom - r.top;
|
||||
#endif
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// window information functions
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd)
|
||||
{
|
||||
wxString str;
|
||||
|
||||
if ( hWnd )
|
||||
{
|
||||
int len = GetWindowTextLength((HWND)hWnd) + 1;
|
||||
::GetWindowText((HWND)hWnd, str.GetWriteBuf(len), len);
|
||||
str.UngetWriteBuf();
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
wxString WXDLLEXPORT wxGetWindowClass(WXHWND hWnd)
|
||||
{
|
||||
wxString str;
|
||||
|
||||
// MICROWIN_TODO
|
||||
#ifndef __WXMICROWIN__
|
||||
if ( hWnd )
|
||||
{
|
||||
int len = 256; // some starting value
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
int count = ::GetClassName((HWND)hWnd, str.GetWriteBuf(len), len);
|
||||
|
||||
str.UngetWriteBuf();
|
||||
if ( count == len )
|
||||
{
|
||||
// the class name might have been truncated, retry with larger
|
||||
// buffer
|
||||
len *= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
case wxFONTENCODING_CP874:
|
||||
return THAI_CHARSET;
|
||||
#endif // !__WXMICROWIN__
|
||||
|
||||
return str;
|
||||
case wxFONTENCODING_CP437:
|
||||
return OEM_CHARSET;
|
||||
}
|
||||
|
||||
// no way to translate this encoding into a Windows charset
|
||||
return -1;
|
||||
}
|
||||
|
||||
WXWORD WXDLLEXPORT wxGetWindowId(WXHWND hWnd)
|
||||
{
|
||||
#ifndef __WIN32__
|
||||
return (WXWORD)GetWindowWord((HWND)hWnd, GWW_ID);
|
||||
#else // Win32
|
||||
return (WXWORD)GetWindowLong((HWND)hWnd, GWL_ID);
|
||||
#endif // Win16/32
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Metafile helpers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern void PixelToHIMETRIC(LONG *x, LONG *y)
|
||||
{
|
||||
ScreenHDC hdcRef;
|
||||
|
||||
int iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE),
|
||||
iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE),
|
||||
iWidthPels = GetDeviceCaps(hdcRef, HORZRES),
|
||||
iHeightPels = GetDeviceCaps(hdcRef, VERTRES);
|
||||
|
||||
*x *= (iWidthMM * 100);
|
||||
*x /= iWidthPels;
|
||||
*y *= (iHeightMM * 100);
|
||||
*y /= iHeightPels;
|
||||
}
|
||||
|
||||
extern void HIMETRICToPixel(LONG *x, LONG *y)
|
||||
{
|
||||
ScreenHDC hdcRef;
|
||||
|
||||
int iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE),
|
||||
iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE),
|
||||
iWidthPels = GetDeviceCaps(hdcRef, HORZRES),
|
||||
iHeightPels = GetDeviceCaps(hdcRef, VERTRES);
|
||||
|
||||
*x *= iWidthPels;
|
||||
*x /= (iWidthMM * 100);
|
||||
*y *= iHeightPels;
|
||||
*y /= (iHeightMM * 100);
|
||||
}
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
#ifdef __WXMICROWIN__
|
||||
int wxGetOsVersion(int *majorVsn, int *minorVsn)
|
||||
{
|
||||
// MICROWIN_TODO
|
||||
if (majorVsn) *majorVsn = 0;
|
||||
if (minorVsn) *minorVsn = 0;
|
||||
return wxUNIX;
|
||||
}
|
||||
#endif // __WXMICROWIN__
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Win32 codepage conversion functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__WIN32__) && !defined(__WXMICROWIN__)
|
||||
|
||||
// wxGetNativeFontEncoding() doesn't exist neither in wxBase nor in wxUniv
|
||||
#if wxUSE_GUI && !defined(__WXUNIVERSAL__)
|
||||
// we have 2 versions of wxCharsetToCodepage(): the old one which directly
|
||||
// looks up the vlaues in the registry and the new one which is more
|
||||
// politically correct and has more chances to work on other Windows versions
|
||||
// as well but the old version is still needed for !wxUSE_FONTMAP case
|
||||
#if wxUSE_FONTMAP
|
||||
|
||||
#include "wx/fontmap.h"
|
||||
|
||||
// VZ: the new version of wxCharsetToCodepage() is more politically correct
|
||||
// and should work on other Windows versions as well but the old version is
|
||||
// still needed for !wxUSE_FONTMAP || !wxUSE_GUI case
|
||||
|
||||
extern long wxEncodingToCodepage(wxFontEncoding encoding)
|
||||
{
|
||||
// translate encoding into the Windows CHARSET
|
||||
wxNativeEncodingInfo natveEncInfo;
|
||||
if ( !wxGetNativeFontEncoding(encoding, &natveEncInfo) )
|
||||
long charset = wxEncodingToCharset(encoding);
|
||||
if ( charset == -1 )
|
||||
return -1;
|
||||
|
||||
// translate CHARSET to code page
|
||||
CHARSETINFO csetInfo;
|
||||
if ( !::TranslateCharsetInfo((DWORD *)(DWORD)natveEncInfo.charset,
|
||||
if ( !::TranslateCharsetInfo((DWORD *)(DWORD)charset,
|
||||
&csetInfo,
|
||||
TCI_SRCCHARSET) )
|
||||
{
|
||||
@ -1656,8 +1143,6 @@ extern long wxEncodingToCodepage(wxFontEncoding encoding)
|
||||
return csetInfo.ciACP;
|
||||
}
|
||||
|
||||
#if wxUSE_FONTMAP
|
||||
|
||||
extern long wxCharsetToCodepage(const wxChar *name)
|
||||
{
|
||||
// first get the font encoding for this charset
|
||||
@ -1672,12 +1157,7 @@ extern long wxCharsetToCodepage(const wxChar *name)
|
||||
return wxEncodingToCodepage(enc);
|
||||
}
|
||||
|
||||
#endif // wxUSE_FONTMAP
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
// include old wxCharsetToCodepage() by OK if needed
|
||||
#if !wxUSE_GUI || !wxUSE_FONTMAP
|
||||
#else // !wxUSE_FONTMAP
|
||||
|
||||
#include "wx/msw/registry.h"
|
||||
|
||||
@ -1687,15 +1167,18 @@ extern long wxCharsetToCodepage(const wxChar *name)
|
||||
if (!name)
|
||||
return GetACP();
|
||||
|
||||
long CP=-1;
|
||||
long CP = -1;
|
||||
|
||||
wxString path(wxT("MIME\\Database\\Charset\\"));
|
||||
wxString cn(name);
|
||||
do {
|
||||
wxString path(wxT("MIME\\Database\\Charset\\"));
|
||||
path += cn;
|
||||
wxRegKey key(wxRegKey::HKCR, path);
|
||||
|
||||
if (!key.Exists()) break;
|
||||
// follow the alias loop
|
||||
for ( ;; )
|
||||
{
|
||||
wxRegKey key(wxRegKey::HKCR, path + cn);
|
||||
|
||||
if (!key.Exists())
|
||||
break;
|
||||
|
||||
// two cases: either there's an AliasForCharset string,
|
||||
// or there are Codepage and InternetEncoding dwords.
|
||||
@ -1703,17 +1186,17 @@ extern long wxCharsetToCodepage(const wxChar *name)
|
||||
// the Codepage just says which Windows character set to
|
||||
// use when displaying the data.
|
||||
if (key.HasValue(wxT("InternetEncoding")) &&
|
||||
key.QueryValue(wxT("InternetEncoding"), &CP)) break;
|
||||
key.QueryValue(wxT("InternetEncoding"), &CP))
|
||||
break;
|
||||
|
||||
// no encoding, see if it's an alias
|
||||
if (!key.HasValue(wxT("AliasForCharset")) ||
|
||||
!key.QueryValue(wxT("AliasForCharset"), cn)) break;
|
||||
} while (1);
|
||||
!key.QueryValue(wxT("AliasForCharset"), cn))
|
||||
break;
|
||||
}
|
||||
|
||||
return CP;
|
||||
}
|
||||
|
||||
#endif // !wxUSE_GUI || !wxUSE_FONTMAP
|
||||
|
||||
#endif // Win32
|
||||
#endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
|
||||
|
||||
|
@ -33,9 +33,6 @@
|
||||
#include "wx/app.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/log.h"
|
||||
#if wxUSE_GUI // See 'dirty hack' below.
|
||||
#include "wx/frame.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __WIN32__
|
||||
@ -43,6 +40,8 @@
|
||||
#include "wx/process.h"
|
||||
#endif
|
||||
|
||||
#include "wx/apptrait.h"
|
||||
|
||||
#include "wx/msw/private.h"
|
||||
|
||||
#include <ctype.h>
|
||||
@ -594,8 +593,6 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler)
|
||||
command = cmd;
|
||||
}
|
||||
|
||||
#if defined(__WIN32__)
|
||||
|
||||
// the IO redirection is only supported with wxUSE_STREAMS
|
||||
BOOL redirect = FALSE;
|
||||
|
||||
@ -854,100 +851,35 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler)
|
||||
return pi.dwProcessId;
|
||||
}
|
||||
|
||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||
wxCHECK_MSG( traits, -1, _T("no wxAppTraits in wxExecute()?") );
|
||||
|
||||
// disable all app windows while waiting for the child process to finish
|
||||
#if wxUSE_GUI
|
||||
void *cookie = traits->BeforeChildWaitLoop();
|
||||
|
||||
/*
|
||||
We use a dirty hack here to disable all application windows (which we
|
||||
must do because otherwise the calls to wxYield() could lead to some very
|
||||
unexpected reentrancies in the users code) but to avoid losing
|
||||
focus/activation entirely when the child process terminates which would
|
||||
happen if we simply disabled everything using wxWindowDisabler. Indeed,
|
||||
remember that Windows will never activate a disabled window and when the
|
||||
last childs window is closed and Windows looks for a window to activate
|
||||
all our windows are still disabled. There is no way to enable them in
|
||||
time because we don't know when the childs windows are going to be
|
||||
closed, so the solution we use here is to keep one special tiny frame
|
||||
enabled all the time. Then when the child terminates it will get
|
||||
activated and when we close it below -- after reenabling all the other
|
||||
windows! -- the previously active window becomes activated again and
|
||||
everything is ok.
|
||||
*/
|
||||
wxWindow *winActive;
|
||||
// wait until the child process terminates
|
||||
while ( data->state )
|
||||
{
|
||||
wxBusyCursor bc;
|
||||
|
||||
// first disable all existing windows
|
||||
wxWindowDisabler wd;
|
||||
|
||||
// then create an "invisible" frame: it has minimal size, is positioned
|
||||
// (hopefully) outside the screen and doesn't appear on the taskbar
|
||||
winActive = new wxFrame
|
||||
(
|
||||
wxTheApp->GetTopWindow(),
|
||||
-1,
|
||||
_T(""),
|
||||
wxPoint(32600, 32600),
|
||||
wxSize(1, 1),
|
||||
wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR
|
||||
);
|
||||
winActive->Show();
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
// wait until the child process terminates
|
||||
while ( data->state )
|
||||
{
|
||||
#if wxUSE_STREAMS
|
||||
bufOut.Update();
|
||||
bufErr.Update();
|
||||
bufOut.Update();
|
||||
bufErr.Update();
|
||||
#endif // wxUSE_STREAMS
|
||||
|
||||
// don't eat 100% of the CPU -- ugly but anything else requires
|
||||
// real async IO which we don't have for the moment
|
||||
::Sleep(50);
|
||||
// don't eat 100% of the CPU -- ugly but anything else requires
|
||||
// real async IO which we don't have for the moment
|
||||
::Sleep(50);
|
||||
|
||||
#if wxUSE_GUI
|
||||
// repaint the GUI
|
||||
wxYield();
|
||||
#else // !GUI
|
||||
// dispatch the messages to the hidden window so that it could
|
||||
// process the wxWM_PROC_TERMINATED notification
|
||||
MSG msg;
|
||||
::PeekMessage(&msg, hwnd, 0, 0, PM_REMOVE);
|
||||
#endif // GUI/!GUI
|
||||
}
|
||||
|
||||
#if wxUSE_GUI
|
||||
// we must process messages or we'd never get wxWM_PROC_TERMINATED
|
||||
traits->AlwaysYield();
|
||||
}
|
||||
|
||||
// finally delete the dummy frame and, as wd has been already destroyed and
|
||||
// the other windows reenabled, the activation is going to return to the
|
||||
// window which had it before
|
||||
winActive->Destroy();
|
||||
#endif // wxUSE_GUI
|
||||
traits->AfterChildWaitLoop(cookie);
|
||||
|
||||
DWORD dwExitCode = data->dwExitCode;
|
||||
delete data;
|
||||
|
||||
// return the exit code
|
||||
return dwExitCode;
|
||||
#else // Win16
|
||||
long instanceID = WinExec((LPCSTR) WXSTRINGCAST command, SW_SHOW);
|
||||
if (instanceID < 32)
|
||||
return flags & wxEXEC_SYNC ? -1 : 0;
|
||||
|
||||
if ( flags & wxEXEC_SYNC )
|
||||
{
|
||||
int running;
|
||||
do
|
||||
{
|
||||
wxYield();
|
||||
running = GetModuleUsage((HINSTANCE)instanceID);
|
||||
} while (running);
|
||||
}
|
||||
|
||||
return instanceID;
|
||||
#endif // Win16/32
|
||||
}
|
||||
|
||||
long wxExecute(wxChar **argv, int flags, wxProcess *handler)
|
||||
|
444
src/msw/utilsgui.cpp
Normal file
444
src/msw/utilsgui.cpp
Normal file
@ -0,0 +1,444 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: msw/utilsgui.cpp
|
||||
// Purpose: Various utility functions only available in GUI
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 21.06.2003 (extracted from msw/utils.cpp)
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// License: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// for compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/cursor.h"
|
||||
#include "wx/utils.h"
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#include "wx/msw/private.h" // includes <windows.h>
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// functions to work with .INI files
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Reading and writing resources (eg WIN.INI, .Xdefaults)
|
||||
#if wxUSE_RESOURCES
|
||||
bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
|
||||
{
|
||||
if (file != wxT(""))
|
||||
// Don't know what the correct cast should be, but it doesn't
|
||||
// compile in BC++/16-bit without this cast.
|
||||
#if !defined(__WIN32__)
|
||||
return (WritePrivateProfileString((const char*) section, (const char*) entry, (const char*) value, (const char*) file) != 0);
|
||||
#else
|
||||
return (WritePrivateProfileString((LPCTSTR)WXSTRINGCAST section, (LPCTSTR)WXSTRINGCAST entry, (LPCTSTR)value, (LPCTSTR)WXSTRINGCAST file) != 0);
|
||||
#endif
|
||||
else
|
||||
return (WriteProfileString((LPCTSTR)WXSTRINGCAST section, (LPCTSTR)WXSTRINGCAST entry, (LPCTSTR)WXSTRINGCAST value) != 0);
|
||||
}
|
||||
|
||||
bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file)
|
||||
{
|
||||
wxString buf;
|
||||
buf.Printf(wxT("%.4f"), value);
|
||||
|
||||
return wxWriteResource(section, entry, buf, file);
|
||||
}
|
||||
|
||||
bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file)
|
||||
{
|
||||
wxString buf;
|
||||
buf.Printf(wxT("%ld"), value);
|
||||
|
||||
return wxWriteResource(section, entry, buf, file);
|
||||
}
|
||||
|
||||
bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file)
|
||||
{
|
||||
wxString buf;
|
||||
buf.Printf(wxT("%d"), value);
|
||||
|
||||
return wxWriteResource(section, entry, buf, file);
|
||||
}
|
||||
|
||||
bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file)
|
||||
{
|
||||
static const wxChar defunkt[] = wxT("$$default");
|
||||
if (file != wxT(""))
|
||||
{
|
||||
int n = GetPrivateProfileString((LPCTSTR)WXSTRINGCAST section, (LPCTSTR)WXSTRINGCAST entry, (LPCTSTR)defunkt,
|
||||
(LPTSTR)wxBuffer, 1000, (LPCTSTR)WXSTRINGCAST file);
|
||||
if (n == 0 || wxStrcmp(wxBuffer, defunkt) == 0)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
int n = GetProfileString((LPCTSTR)WXSTRINGCAST section, (LPCTSTR)WXSTRINGCAST entry, (LPCTSTR)defunkt,
|
||||
(LPTSTR)wxBuffer, 1000);
|
||||
if (n == 0 || wxStrcmp(wxBuffer, defunkt) == 0)
|
||||
return FALSE;
|
||||
}
|
||||
if (*value) delete[] (*value);
|
||||
*value = copystring(wxBuffer);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file)
|
||||
{
|
||||
wxChar *s = NULL;
|
||||
bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
|
||||
if (succ)
|
||||
{
|
||||
*value = (float)wxStrtod(s, NULL);
|
||||
delete[] s;
|
||||
return TRUE;
|
||||
}
|
||||
else return FALSE;
|
||||
}
|
||||
|
||||
bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file)
|
||||
{
|
||||
wxChar *s = NULL;
|
||||
bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
|
||||
if (succ)
|
||||
{
|
||||
*value = wxStrtol(s, NULL, 10);
|
||||
delete[] s;
|
||||
return TRUE;
|
||||
}
|
||||
else return FALSE;
|
||||
}
|
||||
|
||||
bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file)
|
||||
{
|
||||
wxChar *s = NULL;
|
||||
bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
|
||||
if (succ)
|
||||
{
|
||||
*value = (int)wxStrtol(s, NULL, 10);
|
||||
delete[] s;
|
||||
return TRUE;
|
||||
}
|
||||
else return FALSE;
|
||||
}
|
||||
#endif // wxUSE_RESOURCES
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// helper functions for showing a "busy" cursor
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static HCURSOR gs_wxBusyCursor = 0; // new, busy cursor
|
||||
static HCURSOR gs_wxBusyCursorOld = 0; // old cursor
|
||||
static int gs_wxBusyCursorCount = 0;
|
||||
|
||||
extern HCURSOR wxGetCurrentBusyCursor()
|
||||
{
|
||||
return gs_wxBusyCursor;
|
||||
}
|
||||
|
||||
// Set the cursor to the busy cursor for all windows
|
||||
void wxBeginBusyCursor(wxCursor *cursor)
|
||||
{
|
||||
if ( gs_wxBusyCursorCount++ == 0 )
|
||||
{
|
||||
gs_wxBusyCursor = (HCURSOR)cursor->GetHCURSOR();
|
||||
#ifndef __WXMICROWIN__
|
||||
gs_wxBusyCursorOld = ::SetCursor(gs_wxBusyCursor);
|
||||
#endif
|
||||
}
|
||||
//else: nothing to do, already set
|
||||
}
|
||||
|
||||
// Restore cursor to normal
|
||||
void wxEndBusyCursor()
|
||||
{
|
||||
wxCHECK_RET( gs_wxBusyCursorCount > 0,
|
||||
wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") );
|
||||
|
||||
if ( --gs_wxBusyCursorCount == 0 )
|
||||
{
|
||||
#ifndef __WXMICROWIN__
|
||||
::SetCursor(gs_wxBusyCursorOld);
|
||||
#endif
|
||||
gs_wxBusyCursorOld = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// TRUE if we're between the above two calls
|
||||
bool wxIsBusy()
|
||||
{
|
||||
return gs_wxBusyCursorCount > 0;
|
||||
}
|
||||
|
||||
// Check whether this window wants to process messages, e.g. Stop button
|
||||
// in long calculations.
|
||||
bool wxCheckForInterrupt(wxWindow *wnd)
|
||||
{
|
||||
wxCHECK( wnd, FALSE );
|
||||
|
||||
MSG msg;
|
||||
while ( ::PeekMessage(&msg, GetHwndOf(wnd), 0, 0, PM_REMOVE) )
|
||||
{
|
||||
::TranslateMessage(&msg);
|
||||
::DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// MSW only: get user-defined resource from the .res file.
|
||||
// Returns NULL or newly-allocated memory, so use delete[] to clean up.
|
||||
|
||||
#ifndef __WXMICROWIN__
|
||||
wxChar *wxLoadUserResource(const wxString& resourceName, const wxString& resourceType)
|
||||
{
|
||||
HRSRC hResource = ::FindResource(wxGetInstance(), resourceName, resourceType);
|
||||
if ( hResource == 0 )
|
||||
return NULL;
|
||||
|
||||
HGLOBAL hData = ::LoadResource(wxGetInstance(), hResource);
|
||||
if ( hData == 0 )
|
||||
return NULL;
|
||||
|
||||
wxChar *theText = (wxChar *)::LockResource(hData);
|
||||
if ( !theText )
|
||||
return NULL;
|
||||
|
||||
// Not all compilers put a zero at the end of the resource (e.g. BC++ doesn't).
|
||||
// so we need to find the length of the resource.
|
||||
int len = ::SizeofResource(wxGetInstance(), hResource);
|
||||
wxChar *s = new wxChar[len+1];
|
||||
wxStrncpy(s,theText,len);
|
||||
s[len]=0;
|
||||
|
||||
// wxChar *s = copystring(theText);
|
||||
|
||||
// Obsolete in WIN32
|
||||
#ifndef __WIN32__
|
||||
UnlockResource(hData);
|
||||
#endif
|
||||
|
||||
// No need??
|
||||
// GlobalFree(hData);
|
||||
|
||||
return s;
|
||||
}
|
||||
#endif // __WXMICROWIN__
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// get display info
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// See also the wxGetMousePosition in window.cpp
|
||||
// Deprecated: use wxPoint wxGetMousePosition() instead
|
||||
void wxGetMousePosition( int* x, int* y )
|
||||
{
|
||||
POINT pt;
|
||||
GetCursorPos( & pt );
|
||||
if ( x ) *x = pt.x;
|
||||
if ( y ) *y = pt.y;
|
||||
};
|
||||
|
||||
// Return TRUE if we have a colour display
|
||||
bool wxColourDisplay()
|
||||
{
|
||||
#ifdef __WXMICROWIN__
|
||||
// MICROWIN_TODO
|
||||
return TRUE;
|
||||
#else
|
||||
// this function is called from wxDC ctor so it is called a *lot* of times
|
||||
// hence we optimize it a bit but doign the check only once
|
||||
//
|
||||
// this should be MT safe as only the GUI thread (holding the GUI mutex)
|
||||
// can call us
|
||||
static int s_isColour = -1;
|
||||
|
||||
if ( s_isColour == -1 )
|
||||
{
|
||||
ScreenHDC dc;
|
||||
int noCols = ::GetDeviceCaps(dc, NUMCOLORS);
|
||||
|
||||
s_isColour = (noCols == -1) || (noCols > 2);
|
||||
}
|
||||
|
||||
return s_isColour != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Returns depth of screen
|
||||
int wxDisplayDepth()
|
||||
{
|
||||
ScreenHDC dc;
|
||||
return GetDeviceCaps(dc, PLANES) * GetDeviceCaps(dc, BITSPIXEL);
|
||||
}
|
||||
|
||||
// Get size of display
|
||||
void wxDisplaySize(int *width, int *height)
|
||||
{
|
||||
#ifdef __WXMICROWIN__
|
||||
RECT rect;
|
||||
HWND hWnd = GetDesktopWindow();
|
||||
::GetWindowRect(hWnd, & rect);
|
||||
|
||||
if ( width )
|
||||
*width = rect.right - rect.left;
|
||||
if ( height )
|
||||
*height = rect.bottom - rect.top;
|
||||
#else // !__WXMICROWIN__
|
||||
ScreenHDC dc;
|
||||
|
||||
if ( width )
|
||||
*width = ::GetDeviceCaps(dc, HORZRES);
|
||||
if ( height )
|
||||
*height = ::GetDeviceCaps(dc, VERTRES);
|
||||
#endif // __WXMICROWIN__/!__WXMICROWIN__
|
||||
}
|
||||
|
||||
void wxDisplaySizeMM(int *width, int *height)
|
||||
{
|
||||
#ifdef __WXMICROWIN__
|
||||
// MICROWIN_TODO
|
||||
if ( width )
|
||||
*width = 0;
|
||||
if ( height )
|
||||
*height = 0;
|
||||
#else
|
||||
ScreenHDC dc;
|
||||
|
||||
if ( width )
|
||||
*width = ::GetDeviceCaps(dc, HORZSIZE);
|
||||
if ( height )
|
||||
*height = ::GetDeviceCaps(dc, VERTSIZE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxClientDisplayRect(int *x, int *y, int *width, int *height)
|
||||
{
|
||||
#if defined(__WIN16__) || defined(__WXMICROWIN__)
|
||||
*x = 0; *y = 0;
|
||||
wxDisplaySize(width, height);
|
||||
#else
|
||||
// Determine the desktop dimensions minus the taskbar and any other
|
||||
// special decorations...
|
||||
RECT r;
|
||||
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
|
||||
if (x) *x = r.left;
|
||||
if (y) *y = r.top;
|
||||
if (width) *width = r.right - r.left;
|
||||
if (height) *height = r.bottom - r.top;
|
||||
#endif
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// window information functions
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd)
|
||||
{
|
||||
wxString str;
|
||||
|
||||
if ( hWnd )
|
||||
{
|
||||
int len = GetWindowTextLength((HWND)hWnd) + 1;
|
||||
::GetWindowText((HWND)hWnd, str.GetWriteBuf(len), len);
|
||||
str.UngetWriteBuf();
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
wxString WXDLLEXPORT wxGetWindowClass(WXHWND hWnd)
|
||||
{
|
||||
wxString str;
|
||||
|
||||
// MICROWIN_TODO
|
||||
#ifndef __WXMICROWIN__
|
||||
if ( hWnd )
|
||||
{
|
||||
int len = 256; // some starting value
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
int count = ::GetClassName((HWND)hWnd, str.GetWriteBuf(len), len);
|
||||
|
||||
str.UngetWriteBuf();
|
||||
if ( count == len )
|
||||
{
|
||||
// the class name might have been truncated, retry with larger
|
||||
// buffer
|
||||
len *= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !__WXMICROWIN__
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
WXWORD WXDLLEXPORT wxGetWindowId(WXHWND hWnd)
|
||||
{
|
||||
#ifndef __WIN32__
|
||||
return (WXWORD)GetWindowWord((HWND)hWnd, GWW_ID);
|
||||
#else // Win32
|
||||
return (WXWORD)GetWindowLong((HWND)hWnd, GWL_ID);
|
||||
#endif // Win16/32
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Metafile helpers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern void PixelToHIMETRIC(LONG *x, LONG *y)
|
||||
{
|
||||
ScreenHDC hdcRef;
|
||||
|
||||
int iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE),
|
||||
iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE),
|
||||
iWidthPels = GetDeviceCaps(hdcRef, HORZRES),
|
||||
iHeightPels = GetDeviceCaps(hdcRef, VERTRES);
|
||||
|
||||
*x *= (iWidthMM * 100);
|
||||
*x /= iWidthPels;
|
||||
*y *= (iHeightMM * 100);
|
||||
*y /= iHeightPels;
|
||||
}
|
||||
|
||||
extern void HIMETRICToPixel(LONG *x, LONG *y)
|
||||
{
|
||||
ScreenHDC hdcRef;
|
||||
|
||||
int iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE),
|
||||
iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE),
|
||||
iWidthPels = GetDeviceCaps(hdcRef, HORZRES),
|
||||
iHeightPels = GetDeviceCaps(hdcRef, VERTRES);
|
||||
|
||||
*x *= iWidthPels;
|
||||
*x /= (iWidthMM * 100);
|
||||
*y *= iHeightPels;
|
||||
*y /= (iHeightMM * 100);
|
||||
}
|
||||
|
||||
|
@ -42,46 +42,9 @@
|
||||
#include "wx/volume.h"
|
||||
|
||||
#include <shellapi.h>
|
||||
#include "wx/msw/missing.h"
|
||||
|
||||
#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
|
||||
#ifdef __WXBASE__
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// Dynamic library function defs.
|
||||
@ -128,14 +91,6 @@ static FileInfoMap& GetFileInfoMap()
|
||||
}
|
||||
#define s_fileInfo (GetFileInfoMap())
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// Other initialization.
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
#if wxUSE_GUI
|
||||
// already in wx/iconbndl.h
|
||||
// WX_DEFINE_OBJARRAY(wxIconArray);
|
||||
#endif
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// Local helper functions.
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@ -421,7 +376,7 @@ static bool BuildRemoteList(wxArrayString& list, NETRESOURCE* pResSrc,
|
||||
// Purpose: Generate and return a list of all volumes (drives) available.
|
||||
// Notes:
|
||||
//=============================================================================
|
||||
wxArrayString wxFSVolume::GetVolumes(int flagsSet, int flagsUnset)
|
||||
wxArrayString wxFSVolumeBase::GetVolumes(int flagsSet, int flagsUnset)
|
||||
{
|
||||
InterlockedExchange(&s_cancelSearch, FALSE); // reset
|
||||
|
||||
@ -490,7 +445,7 @@ wxArrayString wxFSVolume::GetVolumes(int flagsSet, int flagsUnset)
|
||||
// performing the search. This is the only thread-safe function
|
||||
// provided by the class.
|
||||
//=============================================================================
|
||||
void wxFSVolume::CancelSearch()
|
||||
void wxFSVolumeBase::CancelSearch()
|
||||
{
|
||||
InterlockedExchange(&s_cancelSearch, TRUE);
|
||||
} // CancelSearch
|
||||
@ -499,7 +454,7 @@ void wxFSVolume::CancelSearch()
|
||||
// Function: constructor
|
||||
// Purpose: default constructor
|
||||
//=============================================================================
|
||||
wxFSVolume::wxFSVolume()
|
||||
wxFSVolumeBase::wxFSVolumeBase()
|
||||
{
|
||||
m_isOk = FALSE;
|
||||
} // wxVolume
|
||||
@ -508,7 +463,7 @@ wxFSVolume::wxFSVolume()
|
||||
// Function: constructor
|
||||
// Purpose: constructor that calls Create
|
||||
//=============================================================================
|
||||
wxFSVolume::wxFSVolume(const wxString& name)
|
||||
wxFSVolumeBase::wxFSVolumeBase(const wxString& name)
|
||||
{
|
||||
Create(name);
|
||||
} // wxVolume
|
||||
@ -517,7 +472,7 @@ wxFSVolume::wxFSVolume(const wxString& name)
|
||||
// Function: Create
|
||||
// Purpose: Finds, logs in, etc. to the request volume.
|
||||
//=============================================================================
|
||||
bool wxFSVolume::Create(const wxString& name)
|
||||
bool wxFSVolumeBase::Create(const wxString& name)
|
||||
{
|
||||
// assume fail.
|
||||
m_isOk = FALSE;
|
||||
@ -535,16 +490,6 @@ bool wxFSVolume::Create(const wxString& name)
|
||||
}
|
||||
m_dispName = fi.szDisplayName;
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
m_icons.Alloc(wxFS_VOL_ICO_MAX);
|
||||
int idx;
|
||||
wxIcon null;
|
||||
for (idx = 0; idx < wxFS_VOL_ICO_MAX; idx++)
|
||||
m_icons.Add(null);
|
||||
|
||||
#endif
|
||||
|
||||
// all tests passed.
|
||||
return m_isOk = TRUE;
|
||||
} // Create
|
||||
@ -555,7 +500,7 @@ bool wxFSVolume::Create(const wxString& name)
|
||||
// Notes: For fixed disks, it must exist. For removable disks, it must also
|
||||
// be present. For Network Shares, it must also be logged in, etc.
|
||||
//=============================================================================
|
||||
bool wxFSVolume::IsOk() const
|
||||
bool wxFSVolumeBase::IsOk() const
|
||||
{
|
||||
return m_isOk;
|
||||
} // IsOk
|
||||
@ -564,7 +509,7 @@ bool wxFSVolume::IsOk() const
|
||||
// Function: GetKind
|
||||
// Purpose: Return the type of the volume.
|
||||
//=============================================================================
|
||||
wxFSVolumeKind wxFSVolume::GetKind() const
|
||||
wxFSVolumeKind wxFSVolumeBase::GetKind() const
|
||||
{
|
||||
if (!m_isOk)
|
||||
return wxFS_VOL_OTHER;
|
||||
@ -581,7 +526,7 @@ wxFSVolumeKind wxFSVolume::GetKind() const
|
||||
// Purpose: Return the caches flags for this volume.
|
||||
// Notes: - Returns -1 if no flags were cached.
|
||||
//=============================================================================
|
||||
int wxFSVolume::GetFlags() const
|
||||
int wxFSVolumeBase::GetFlags() const
|
||||
{
|
||||
if (!m_isOk)
|
||||
return -1;
|
||||
@ -593,40 +538,52 @@ int wxFSVolume::GetFlags() const
|
||||
return itr->second.m_flags;
|
||||
} // GetFlags
|
||||
|
||||
#endif // __WXBASE__
|
||||
|
||||
// ============================================================================
|
||||
// wxFSVolume
|
||||
// ============================================================================
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
void wxFSVolume::InitIcons()
|
||||
{
|
||||
m_icons.Alloc(wxFS_VOL_ICO_MAX);
|
||||
wxIcon null;
|
||||
for (int idx = 0; idx < wxFS_VOL_ICO_MAX; idx++)
|
||||
m_icons.Add(null);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// Function: GetIcon
|
||||
// Purpose: return the requested icon.
|
||||
//=============================================================================
|
||||
|
||||
wxIcon wxFSVolume::GetIcon(wxFSIconType type) const
|
||||
{
|
||||
wxCHECK_MSG(type < (int)m_icons.GetCount(), wxNullIcon,
|
||||
_T("Invalid request for icon type!"));
|
||||
wxCHECK_MSG( type >= 0 && (size_t)type < m_icons.GetCount(),
|
||||
wxIcon(),
|
||||
_T("invalid icon index") );
|
||||
wxCHECK_MSG( type >= 0 && (size_t)type < m_icons.GetCount(), wxNullIcon,
|
||||
_T("wxFSIconType::GetIcon(): invalid icon index") );
|
||||
|
||||
// Load on demand.
|
||||
if (m_icons[type].IsNull())
|
||||
{
|
||||
unsigned flags = 0;
|
||||
UINT flags = SHGFI_ICON;
|
||||
switch (type)
|
||||
{
|
||||
case wxFS_VOL_ICO_SMALL:
|
||||
flags = SHGFI_ICON | SHGFI_SMALLICON;
|
||||
flags |= SHGFI_SMALLICON;
|
||||
break;
|
||||
|
||||
case wxFS_VOL_ICO_LARGE:
|
||||
flags = SHGFI_ICON | SHGFI_SHELLICONSIZE;
|
||||
flags |= SHGFI_SHELLICONSIZE;
|
||||
break;
|
||||
|
||||
case wxFS_VOL_ICO_SEL_SMALL:
|
||||
flags = SHGFI_ICON | SHGFI_SMALLICON | SHGFI_OPENICON;
|
||||
flags |= SHGFI_SMALLICON | SHGFI_OPENICON;
|
||||
break;
|
||||
|
||||
case wxFS_VOL_ICO_SEL_LARGE:
|
||||
flags = SHGFI_ICON | SHGFI_SHELLICONSIZE | SHGFI_OPENICON;
|
||||
flags |= SHGFI_SHELLICONSIZE | SHGFI_OPENICON;
|
||||
break;
|
||||
|
||||
case wxFS_VOL_ICO_MAX:
|
||||
|
@ -1100,11 +1100,12 @@ void wxApp::OnQueryEndSession(
|
||||
}
|
||||
} // end of wxApp::OnQueryEndSession
|
||||
|
||||
void wxExit()
|
||||
void wxApp::Exit()
|
||||
{
|
||||
wxLogError(_("Fatal error: exiting"));
|
||||
|
||||
wxApp::CleanUp();
|
||||
|
||||
// VZ: must really exit somehow, insert appropriate OS/2 syscall (FIXME)
|
||||
wxAppConsole::Exit();
|
||||
} // end of wxExit
|
||||
|
||||
//
|
||||
@ -1213,7 +1214,7 @@ void wxApp::RemoveSocketHandler(int handle)
|
||||
// wxWakeUpIdle
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void wxWakeUpIdle()
|
||||
void wxApp::WakeUpIdle()
|
||||
{
|
||||
//
|
||||
// Send the top window a dummy message so idle handler processing will
|
||||
|
108
src/unix/baseunix.cpp
Normal file
108
src/unix/baseunix.cpp
Normal file
@ -0,0 +1,108 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: unix/baseunix.cpp
|
||||
// Purpose: misc stuff only used in console applications under Unix
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 23.06.2003
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
|
||||
// License: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// for compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#include "wx/apptrait.h"
|
||||
|
||||
// for waitpid()
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
// ============================================================================
|
||||
// wxConsoleAppTraits implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxExecute support
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxConsoleAppTraits::CreateEndProcessPipe(wxExecuteData& WXUNUSED(data))
|
||||
{
|
||||
// nothing to do, so always ok
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
wxConsoleAppTraits::IsWriteFDOfEndProcessPipe(wxExecuteData& WXUNUSED(data),
|
||||
int WXUNUSED(fd))
|
||||
{
|
||||
// we don't have any pipe
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
wxConsoleAppTraits::DetachWriteFDOfEndProcessPipe(wxExecuteData& WXUNUSED(data))
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
wxConsoleAppTraits::WaitForChild(wxExecuteData& execData)
|
||||
{
|
||||
wxASSERT_MSG( execData.flags & wxEXEC_SYNC,
|
||||
wxT("async execution not supported yet") );
|
||||
|
||||
int exitcode = 0;
|
||||
if ( waitpid(execData.pid, &exitcode, 0) == -1 || !WIFEXITED(exitcode) )
|
||||
{
|
||||
wxLogSysError(_("Waiting for subprocess termination failed"));
|
||||
}
|
||||
|
||||
return exitcode;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// misc other stuff
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// WXWIN_OS_DESCRIPTION is normally defined by configure
|
||||
#if defined( __MWERKS__ ) && defined(__MACH__)
|
||||
#define WXWIN_OS_DESCRIPTION "MacOS X"
|
||||
#endif
|
||||
|
||||
int wxConsoleAppTraits::GetOSVersion(int *verMaj, int *verMin)
|
||||
{
|
||||
int major, minor;
|
||||
char name[256];
|
||||
|
||||
if ( sscanf(WXWIN_OS_DESCRIPTION, "%s %d.%d", name, &major, &minor) != 3 )
|
||||
{
|
||||
// unreckognized uname string format
|
||||
major =
|
||||
minor = -1;
|
||||
}
|
||||
|
||||
if ( majorVsn )
|
||||
*majorVsn = major;
|
||||
if ( minorVsn )
|
||||
*minorVsn = minor;
|
||||
|
||||
return wxUNIX;
|
||||
}
|
||||
|
@ -28,6 +28,10 @@
|
||||
|
||||
#include "wx/wfstream.h"
|
||||
|
||||
#include "wx/unix/execute.h"
|
||||
|
||||
#ifdef __WXBASE__
|
||||
|
||||
#if defined( __MWERKS__ ) && defined(__MACH__)
|
||||
#define WXWIN_OS_DESCRIPTION "MacOS X"
|
||||
#define HAVE_NANOSLEEP
|
||||
@ -60,10 +64,6 @@
|
||||
#define wxStatfs_t WX_STATFS_T
|
||||
#endif
|
||||
|
||||
#if wxUSE_GUI
|
||||
#include "wx/unix/execute.h"
|
||||
#endif
|
||||
|
||||
// SGI signal.h defines signal handler arguments differently depending on
|
||||
// whether _LANGUAGE_C_PLUS_PLUS is set or not - do set it
|
||||
#if defined(__SGI__) && !defined(_LANGUAGE_C_PLUS_PLUS)
|
||||
@ -75,8 +75,8 @@
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
@ -340,30 +340,6 @@ bool wxShutdown(wxShutdownFlags wFlags)
|
||||
}
|
||||
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
void wxHandleProcessTermination(wxEndProcessData *proc_data)
|
||||
{
|
||||
// notify user about termination if required
|
||||
if ( proc_data->process )
|
||||
{
|
||||
proc_data->process->OnTerminate(proc_data->pid, proc_data->exitcode);
|
||||
}
|
||||
|
||||
// clean up
|
||||
if ( proc_data->pid > 0 )
|
||||
{
|
||||
delete proc_data;
|
||||
}
|
||||
else
|
||||
{
|
||||
// let wxExecute() know that the process has terminated
|
||||
proc_data->pid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStream classes to support IO redirection in wxExecute
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -428,83 +404,6 @@ bool wxPipeInputStream::CanRead() const
|
||||
|
||||
#endif // wxUSE_STREAMS
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxPipe: this 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];
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxExecute: the real worker function
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -549,10 +448,21 @@ long wxExecute(wxChar **argv,
|
||||
wxChar **mb_argv = argv;
|
||||
#endif // Unicode/ANSI
|
||||
|
||||
#if wxUSE_GUI && !(defined(__DARWIN__) && defined(__WXMAC__))
|
||||
// we want this function to work even if there is no wxApp so ensure that
|
||||
// we have a valid traits pointer
|
||||
wxConsoleAppTraits traitsConsole;
|
||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||
if ( !traits )
|
||||
traits = &traitsConsole;
|
||||
|
||||
// this struct contains all information which we pass to and from
|
||||
// wxAppTraits methods
|
||||
wxExecuteData execData;
|
||||
execData.flags = flags;
|
||||
execData.process = process;
|
||||
|
||||
// create pipes
|
||||
wxPipe pipeEndProcDetect;
|
||||
if ( !pipeEndProcDetect.Create() )
|
||||
if ( !traits->CreateEndProcessPipe(execData) )
|
||||
{
|
||||
wxLogError( _("Failed to execute '%s'\n"), *argv );
|
||||
|
||||
@ -560,7 +470,6 @@ long wxExecute(wxChar **argv,
|
||||
|
||||
return ERROR_RETURN_CODE;
|
||||
}
|
||||
#endif // wxUSE_GUI && !(defined(__DARWIN__) && defined(__WXMAC__))
|
||||
|
||||
// pipes for inter process communication
|
||||
wxPipe pipeIn, // stdin
|
||||
@ -611,10 +520,7 @@ long wxExecute(wxChar **argv,
|
||||
if ( fd == pipeIn[wxPipe::Read]
|
||||
|| fd == pipeOut[wxPipe::Write]
|
||||
|| fd == pipeErr[wxPipe::Write]
|
||||
#if wxUSE_GUI && !(defined(__DARWIN__) && defined(__WXMAC__))
|
||||
|| fd == pipeEndProcDetect[wxPipe::Write]
|
||||
#endif // wxUSE_GUI && !(defined(__DARWIN__) && defined(__WXMAC__))
|
||||
)
|
||||
|| traits->IsWriteFDOfEndProcessPipe(execData, fd) )
|
||||
{
|
||||
// don't close this one, we still need it
|
||||
continue;
|
||||
@ -635,12 +541,9 @@ long wxExecute(wxChar **argv,
|
||||
}
|
||||
#endif // !__VMS
|
||||
|
||||
#if wxUSE_GUI && !(defined(__DARWIN__) && defined(__WXMAC__))
|
||||
// reading side can be safely closed but we should keep the write one
|
||||
// opened
|
||||
pipeEndProcDetect.Detach(wxPipe::Write);
|
||||
pipeEndProcDetect.Close();
|
||||
#endif // wxUSE_GUI && !(defined(__DARWIN__) && defined(__WXMAC__))
|
||||
traits->DetachWriteFDOfEndProcessPipe(execData);
|
||||
|
||||
// redirect stdin, stdout and stderr
|
||||
if ( pipeIn.IsOk() )
|
||||
@ -707,6 +610,9 @@ long wxExecute(wxChar **argv,
|
||||
|
||||
bufOut.Init(outStream);
|
||||
bufErr.Init(errStream);
|
||||
|
||||
execData.bufOut = &bufOut;
|
||||
execData.bufErr = &bufErr;
|
||||
#endif // wxUSE_STREAMS
|
||||
}
|
||||
|
||||
@ -717,85 +623,7 @@ long wxExecute(wxChar **argv,
|
||||
pipeErr.Close();
|
||||
}
|
||||
|
||||
#if wxUSE_GUI && !defined(__WXMICROWIN__)
|
||||
wxEndProcessData *data = new wxEndProcessData;
|
||||
|
||||
// wxAddProcessCallback is now (with DARWIN) allowed to call the
|
||||
// callback function directly if the process terminates before
|
||||
// the callback can be added to the run loop. Set up the data.
|
||||
if ( flags & wxEXEC_SYNC )
|
||||
{
|
||||
// we may have process for capturing the program output, but it's
|
||||
// not used in wxEndProcessData in the case of sync execution
|
||||
data->process = NULL;
|
||||
|
||||
// sync execution: indicate it by negating the pid
|
||||
data->pid = -pid;
|
||||
}
|
||||
else
|
||||
{
|
||||
// async execution, nothing special to do - caller will be
|
||||
// notified about the process termination if process != NULL, data
|
||||
// will be deleted in GTK_EndProcessDetector
|
||||
data->process = process;
|
||||
data->pid = pid;
|
||||
}
|
||||
|
||||
|
||||
#if defined(__DARWIN__) && defined(__WXMAC__)
|
||||
data->tag = wxAddProcessCallbackForPid(data,pid);
|
||||
#else
|
||||
data->tag = wxAddProcessCallback
|
||||
(
|
||||
data,
|
||||
pipeEndProcDetect.Detach(wxPipe::Read)
|
||||
);
|
||||
|
||||
pipeEndProcDetect.Close();
|
||||
#endif // defined(__DARWIN__) && defined(__WXMAC__)
|
||||
|
||||
if ( flags & wxEXEC_SYNC )
|
||||
{
|
||||
wxBusyCursor bc;
|
||||
wxWindowDisabler wd;
|
||||
|
||||
// data->pid will be set to 0 from GTK_EndProcessDetector when the
|
||||
// process terminates
|
||||
while ( data->pid != 0 )
|
||||
{
|
||||
#if wxUSE_STREAMS
|
||||
bufOut.Update();
|
||||
bufErr.Update();
|
||||
#endif // wxUSE_STREAMS
|
||||
|
||||
// give GTK+ a chance to call GTK_EndProcessDetector here and
|
||||
// also repaint the GUI
|
||||
wxYield();
|
||||
}
|
||||
|
||||
int exitcode = data->exitcode;
|
||||
|
||||
delete data;
|
||||
|
||||
return exitcode;
|
||||
}
|
||||
else // async execution
|
||||
{
|
||||
return pid;
|
||||
}
|
||||
#else // !wxUSE_GUI
|
||||
|
||||
wxASSERT_MSG( flags & wxEXEC_SYNC,
|
||||
wxT("async execution not supported yet") );
|
||||
|
||||
int exitcode = 0;
|
||||
if ( waitpid(pid, &exitcode, 0) == -1 || !WIFEXITED(exitcode) )
|
||||
{
|
||||
wxLogSysError(_("Waiting for subprocess termination failed"));
|
||||
}
|
||||
|
||||
return exitcode;
|
||||
#endif // wxUSE_GUI
|
||||
return traits->WaitForChild(execData);
|
||||
}
|
||||
|
||||
return ERROR_RETURN_CODE;
|
||||
@ -986,7 +814,9 @@ bool wxGetUserName(wxChar *buf, int sz)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// this function is in mac/utils.cpp for wxMac
|
||||
#ifndef __WXMAC__
|
||||
|
||||
wxString wxGetOsDescription()
|
||||
{
|
||||
#ifndef WXWIN_OS_DESCRIPTION
|
||||
@ -995,33 +825,20 @@ wxString wxGetOsDescription()
|
||||
return wxString::FromAscii( WXWIN_OS_DESCRIPTION );
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
// this function returns the GUI toolkit version in GUI programs, but OS
|
||||
// version in non-GUI ones
|
||||
#if !wxUSE_GUI
|
||||
#endif // !__WXMAC__
|
||||
|
||||
int wxGetOsVersion(int *majorVsn, int *minorVsn)
|
||||
int wxGetOsVersion(int *verMaj, int *verMin)
|
||||
{
|
||||
int major, minor;
|
||||
char name[256];
|
||||
// we want this function to work even if there is no wxApp
|
||||
wxConsoleAppTraits traitsConsole;
|
||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||
if ( ! traits )
|
||||
traits = &traitsConsole;
|
||||
|
||||
if ( sscanf(WXWIN_OS_DESCRIPTION, "%s %d.%d", name, &major, &minor) != 3 )
|
||||
{
|
||||
// unreckognized uname string format
|
||||
major = minor = -1;
|
||||
}
|
||||
|
||||
if ( majorVsn )
|
||||
*majorVsn = major;
|
||||
if ( minorVsn )
|
||||
*minorVsn = minor;
|
||||
|
||||
return wxUNIX;
|
||||
return traits->GetOSVersion(verMaj, verMin);
|
||||
}
|
||||
|
||||
#endif // !wxUSE_GUI
|
||||
|
||||
unsigned long wxGetProcessId()
|
||||
{
|
||||
return (unsigned long)getpid();
|
||||
@ -1243,3 +1060,147 @@ void wxFatalError( const wxString &msg, const wxString &title )
|
||||
|
||||
#endif // WXWIN_COMPATIBILITY_2_2
|
||||
|
||||
#endif // __WXBASE__
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxExecute support
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Darwin doesn't use the same process end detection mechanisms so we don't
|
||||
// need wxExecute-related helpers for it
|
||||
#if !(defined(__DARWIN__) && defined(__WXMAC__))
|
||||
|
||||
bool wxGUIAppTraits::CreateEndProcessPipe(wxExecuteData& execData)
|
||||
{
|
||||
return execData.pipeEndProcDetect.Create();
|
||||
}
|
||||
|
||||
bool wxGUIAppTraits::IsWriteFDOfEndProcessPipe(wxExecuteData& execData, int fd)
|
||||
{
|
||||
return fd == execData.pipeEndProcDetect[wxPipe::Write]
|
||||
}
|
||||
|
||||
void wxGUIAppTraits::DetachWriteFDOfEndProcessPipe(wxExecuteData& execData)
|
||||
{
|
||||
execData.pipeEndProcDetect.Detach(wxPipe::Write);
|
||||
execData.pipeEndProcDetect.Close();
|
||||
}
|
||||
|
||||
#else // !Darwin
|
||||
|
||||
bool wxGUIAppTraits::CreateEndProcessPipe(wxExecuteData& WXUNUSED(execData))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
wxGUIAppTraits::IsWriteFDOfEndProcessPipe(wxExecuteData& WXUNUSED(execData),
|
||||
int WXUNUSED(fd))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
wxGUIAppTraits::DetachWriteFDOfEndProcessPipe(wxExecuteData& WXUNUSED(execData))
|
||||
{
|
||||
// nothing to do here, we don't use the pipe
|
||||
}
|
||||
|
||||
#endif // !Darwin/Darwin
|
||||
|
||||
int wxGUIAppTraits::WaitForChild(wxExecuteData& execData)
|
||||
{
|
||||
wxEndProcessData *endProcData = new wxEndProcessData;
|
||||
|
||||
// wxAddProcessCallback is now (with DARWIN) allowed to call the
|
||||
// callback function directly if the process terminates before
|
||||
// the callback can be added to the run loop. Set up the endProcData.
|
||||
if ( execData.flags & wxEXEC_SYNC )
|
||||
{
|
||||
// we may have process for capturing the program output, but it's
|
||||
// not used in wxEndProcessData in the case of sync execution
|
||||
endProcData->process = NULL;
|
||||
|
||||
// sync execution: indicate it by negating the pid
|
||||
endProcData->pid = -execData.pid;
|
||||
}
|
||||
else
|
||||
{
|
||||
// async execution, nothing special to do -- caller will be
|
||||
// notified about the process termination if process != NULL, endProcData
|
||||
// will be deleted in GTK_EndProcessDetector
|
||||
endProcData->process = execData.process;
|
||||
endProcData->pid = execData.pid;
|
||||
}
|
||||
|
||||
|
||||
#if defined(__DARWIN__) && defined(__WXMAC__)
|
||||
endProcData->tag = wxAddProcessCallbackForPid(endProcData, execData.pid);
|
||||
#else
|
||||
endProcData->tag = wxAddProcessCallback
|
||||
(
|
||||
endProcData,
|
||||
execData.pipeEndProcDetect.Detach(wxPipe::Read)
|
||||
);
|
||||
|
||||
execData.pipeEndProcDetect.Close();
|
||||
#endif // defined(__DARWIN__) && defined(__WXMAC__)
|
||||
|
||||
if ( execData.flags & wxEXEC_SYNC )
|
||||
{
|
||||
wxBusyCursor bc;
|
||||
wxWindowDisabler wd;
|
||||
|
||||
// endProcData->pid will be set to 0 from GTK_EndProcessDetector when the
|
||||
// process terminates
|
||||
while ( endProcData->pid != 0 )
|
||||
{
|
||||
#if wxUSE_STREAMS
|
||||
if ( execData.bufOut )
|
||||
execData.bufOut->Update();
|
||||
|
||||
if ( execData.bufErr )
|
||||
execData.bufErr->Update();
|
||||
#endif // wxUSE_STREAMS
|
||||
|
||||
// give GTK+ a chance to call GTK_EndProcessDetector here and
|
||||
// also repaint the GUI
|
||||
wxYield();
|
||||
}
|
||||
|
||||
int exitcode = endProcData->exitcode;
|
||||
|
||||
delete endProcData;
|
||||
|
||||
return exitcode;
|
||||
}
|
||||
else // async execution
|
||||
{
|
||||
return execData.pid;
|
||||
}
|
||||
}
|
||||
|
||||
void wxHandleProcessTermination(wxEndProcessData *proc_data)
|
||||
{
|
||||
// notify user about termination if required
|
||||
if ( proc_data->process )
|
||||
{
|
||||
proc_data->process->OnTerminate(proc_data->pid, proc_data->exitcode);
|
||||
}
|
||||
|
||||
// clean up
|
||||
if ( proc_data->pid > 0 )
|
||||
{
|
||||
delete proc_data;
|
||||
}
|
||||
else
|
||||
{
|
||||
// let wxExecute() know that the process has terminated
|
||||
proc_data->pid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
|
@ -248,7 +248,7 @@ LIB32=link.exe -lib
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\appcmn.cpp
|
||||
SOURCE=.\common\appbase.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@ -328,7 +328,7 @@ SOURCE=.\common\filesys.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\fontmap.cpp
|
||||
SOURCE=.\common\fmapbase.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@ -436,6 +436,10 @@ SOURCE=.\common\socket.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\stopwatch.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\strconv.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -460,10 +464,6 @@ SOURCE=.\common\textfile.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\timercmn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\tokenzr.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -525,6 +525,10 @@ SOURCE=.\msw\dummy.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\console.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\dde.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -541,6 +545,10 @@ SOURCE=.\msw\mimetype.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\mslu.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\regconf.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -664,6 +672,10 @@ SOURCE=..\include\wx\app.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\wx\apptrait.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\wx\buffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -780,6 +792,10 @@ SOURCE=..\include\wx\filesys.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\wx\fmappriv.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\wx\fontenc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -1013,6 +1029,14 @@ SOURCE=..\include\wx\zstream.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\wx\msw\apptbase.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\wx\msw\apptrait.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\wx\msw\dde.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
2805
src/wxMSW.dsp
Normal file
2805
src/wxMSW.dsp
Normal file
File diff suppressed because it is too large
Load Diff
@ -2,8 +2,8 @@
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=wxWindows - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
@ -32,8 +32,6 @@ CFG=wxWindows - Win32 Debug
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "wxWindows - Win32 Release Unicode DLL"
|
||||
|
||||
@ -48,10 +46,13 @@ RSC=rc.exe
|
||||
# PROP Intermediate_Dir "../ReleaseUnicodeDll"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /MD /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXWINDLL_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswdllu" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswdllu" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "NDEBUG" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
|
||||
MTL=midl.exe
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /i "../include" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@ -74,17 +75,20 @@ LINK32=link.exe
|
||||
# PROP Intermediate_Dir "../DebugUnicodeDll"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /MDd /W4 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXWINDLL_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswdllud" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "_DEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswdllud" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "_DEBUG" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
|
||||
MTL=midl.exe
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /i "../include" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /dll /debug /machine:I386 /pdbtype:sept /out:"../lib/wxmsw250ud.dll"
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /dll /debug /machine:I386 /out:"../lib/wxmsw250ud.dll" /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib odbc32.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxmsw250ud.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "wxWindows - Win32 Release Unicode"
|
||||
@ -99,8 +103,10 @@ LINK32=link.exe
|
||||
# PROP Output_Dir "../lib"
|
||||
# PROP Intermediate_Dir "../ReleaseUnicode"
|
||||
# PROP Target_Dir ""
|
||||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswu" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "_UNICODE" /D "UNICODE" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswu" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x409
|
||||
# ADD RSC /l 0x409
|
||||
BSC32=bscmake.exe
|
||||
@ -122,8 +128,10 @@ LIB32=link.exe -lib
|
||||
# PROP Output_Dir "../lib"
|
||||
# PROP Intermediate_Dir "../DebugUnicode"
|
||||
# PROP Target_Dir ""
|
||||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswud" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "_DEBUG" /D "__WXDEBUG__" /D WINVER=0x0400 /D "STRICT" /D "_UNICODE" /D "UNICODE" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswud" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_DEBUG" /D "__WXDEBUG__" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x409
|
||||
# ADD RSC /l 0x409
|
||||
BSC32=bscmake.exe
|
||||
@ -146,10 +154,13 @@ LIB32=link.exe -lib
|
||||
# PROP Intermediate_Dir "../ReleaseDll"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /MD /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXWINDLL_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswdll" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswdll" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "NDEBUG" /D "WXMAKINGDLL" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
|
||||
MTL=midl.exe
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /i "../include" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@ -172,17 +183,20 @@ LINK32=link.exe
|
||||
# PROP Intermediate_Dir "../DebugDll"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /MDd /W4 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXWINDLL_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswdlld" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "_DEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswdlld" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "_DEBUG" /D "WXMAKINGDLL" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
|
||||
MTL=midl.exe
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /i "../include" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /dll /debug /machine:I386 /pdbtype:sept /out:"../lib/wxmsw250d.dll"
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /dll /debug /machine:I386 /out:"../lib/wxmsw250d.dll" /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib odbc32.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxmsw250d.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "wxWindows - Win32 Release"
|
||||
@ -197,8 +211,10 @@ LINK32=link.exe
|
||||
# PROP Output_Dir "../lib"
|
||||
# PROP Intermediate_Dir "../Release"
|
||||
# PROP Target_Dir ""
|
||||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /O2 /I "../lib/msw" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /O2 /I "../lib/msw" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "NDEBUG" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x409
|
||||
# ADD RSC /l 0x409
|
||||
BSC32=bscmake.exe
|
||||
@ -220,8 +236,10 @@ LIB32=link.exe -lib
|
||||
# PROP Output_Dir "../lib"
|
||||
# PROP Intermediate_Dir "../Debug"
|
||||
# PROP Target_Dir ""
|
||||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswd" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "_DEBUG" /D "__WXDEBUG__" /D WINVER=0x0400 /D "STRICT" /Yu"wx/wxprec.h" /FD /c
|
||||
# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswd" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_DEBUG" /D "__WXDEBUG__" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x409
|
||||
# ADD RSC /l 0x409
|
||||
BSC32=bscmake.exe
|
||||
@ -252,6 +270,10 @@ SOURCE=.\common\accesscmn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\appbase.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\appcmn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -392,6 +414,11 @@ SOURCE=.\common\event.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\extended.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\fddlgcmn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -424,6 +451,10 @@ SOURCE=.\common\fldlgcmn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\fmapbase.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\fontcmn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -668,6 +699,10 @@ SOURCE=.\common\statbar.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\stopwatch.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\strconv.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -724,6 +759,11 @@ SOURCE=.\common\txtstrm.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\unzip.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\url.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -770,18 +810,6 @@ SOURCE=.\common\zipstrm.cpp
|
||||
|
||||
SOURCE=.\common\zstream.cpp
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\extended.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\unzip.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
|
||||
# End Group
|
||||
# Begin Group "Generic Files"
|
||||
|
||||
@ -898,7 +926,6 @@ SOURCE=.\generic\treectlg.cpp
|
||||
|
||||
SOURCE=.\generic\wizard.cpp
|
||||
# End Source File
|
||||
|
||||
# End Group
|
||||
# Begin Group "wxHTML Files"
|
||||
|
||||
@ -983,18 +1010,44 @@ SOURCE=.\html\m_tables.cpp
|
||||
|
||||
SOURCE=.\html\winpars.cpp
|
||||
# End Source File
|
||||
|
||||
# End Group
|
||||
# Begin Group "MSW Files"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Group "OLE Files"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\dummy.cpp
|
||||
# ADD CPP /Yc"wx/wxprec.h"
|
||||
SOURCE=.\msw\ole\access.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\ole\automtn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\ole\dataobj.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\ole\dropsrc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\ole\droptgt.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\ole\oleutils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\ole\uuid.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\accel.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -1003,6 +1056,10 @@ SOURCE=.\msw\app.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\basemsw.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\bitmap.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -1115,6 +1172,11 @@ SOURCE=.\msw\dragimag.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\dummy.cpp
|
||||
# ADD CPP /Yc"wx/wxprec.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\enhmeta.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -1167,6 +1229,16 @@ SOURCE=.\msw\glcanvas.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\gsocket.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\gsockmsw.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\helpbest.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -1387,6 +1459,10 @@ SOURCE=.\msw\utilsexc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\utilsgui.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\uxtheme.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -1401,51 +1477,6 @@ SOURCE=.\msw\wave.cpp
|
||||
|
||||
SOURCE=.\msw\window.cpp
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\gsocket.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\gsockmsw.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
|
||||
# Begin Group "OLE Files"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\ole\access.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\ole\automtn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\ole\dataobj.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\ole\dropsrc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\ole\droptgt.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\ole\oleutils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msw\ole\uuid.cpp
|
||||
# End Source File
|
||||
|
||||
# End Group
|
||||
# End Group
|
||||
# Begin Group "Headers"
|
||||
|
||||
@ -1456,7 +1487,9 @@ SOURCE=.\msw\ole\uuid.cpp
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\wx\msw\setup.h
|
||||
|
||||
!IF "$(CFG)" == "wxWindows - Win32 Release Unicode DLL"
|
||||
|
||||
# Begin Custom Build - Creating ..\lib\mswdllu\wx\setup.h from $(InputPath)
|
||||
InputPath=..\include\wx\msw\setup.h
|
||||
|
||||
@ -1464,7 +1497,9 @@ InputPath=..\include\wx\msw\setup.h
|
||||
copy "$(InputPath)" ..\lib\mswdllu\wx\setup.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "wxWindows - Win32 Debug Unicode DLL"
|
||||
|
||||
# Begin Custom Build - Creating ..\lib\mswdllud\wx\setup.h from $(InputPath)
|
||||
InputPath=..\include\wx\msw\setup.h
|
||||
|
||||
@ -1472,7 +1507,9 @@ InputPath=..\include\wx\msw\setup.h
|
||||
copy "$(InputPath)" ..\lib\mswdllud\wx\setup.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "wxWindows - Win32 Release Unicode"
|
||||
|
||||
# Begin Custom Build - Creating ..\lib\mswu\wx\setup.h from $(InputPath)
|
||||
InputPath=..\include\wx\msw\setup.h
|
||||
|
||||
@ -1480,7 +1517,9 @@ InputPath=..\include\wx\msw\setup.h
|
||||
copy "$(InputPath)" ..\lib\mswu\wx\setup.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "wxWindows - Win32 Debug Unicode"
|
||||
|
||||
# Begin Custom Build - Creating ..\lib\mswud\wx\setup.h from $(InputPath)
|
||||
InputPath=..\include\wx\msw\setup.h
|
||||
|
||||
@ -1488,7 +1527,9 @@ InputPath=..\include\wx\msw\setup.h
|
||||
copy "$(InputPath)" ..\lib\mswud\wx\setup.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "wxWindows - Win32 Release DLL"
|
||||
|
||||
# Begin Custom Build - Creating ..\lib\mswdll\wx\setup.h from $(InputPath)
|
||||
InputPath=..\include\wx\msw\setup.h
|
||||
|
||||
@ -1496,7 +1537,9 @@ InputPath=..\include\wx\msw\setup.h
|
||||
copy "$(InputPath)" ..\lib\mswdll\wx\setup.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "wxWindows - Win32 Debug DLL"
|
||||
|
||||
# Begin Custom Build - Creating ..\lib\mswdlld\wx\setup.h from $(InputPath)
|
||||
InputPath=..\include\wx\msw\setup.h
|
||||
|
||||
@ -1504,7 +1547,9 @@ InputPath=..\include\wx\msw\setup.h
|
||||
copy "$(InputPath)" ..\lib\mswdlld\wx\setup.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "wxWindows - Win32 Release"
|
||||
|
||||
# Begin Custom Build - Creating ..\lib\msw\wx\setup.h from $(InputPath)
|
||||
InputPath=..\include\wx\msw\setup.h
|
||||
|
||||
@ -1512,7 +1557,9 @@ InputPath=..\include\wx\msw\setup.h
|
||||
copy "$(InputPath)" ..\lib\msw\wx\setup.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "wxWindows - Win32 Debug"
|
||||
|
||||
# Begin Custom Build - Creating ..\lib\mswd\wx\setup.h from $(InputPath)
|
||||
InputPath=..\include\wx\msw\setup.h
|
||||
|
||||
@ -1520,7 +1567,9 @@ InputPath=..\include\wx\msw\setup.h
|
||||
copy "$(InputPath)" ..\lib\mswd\wx\setup.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
@ -1540,6 +1589,10 @@ SOURCE=..\include\wx\app.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\wx\apptrait.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\wx\artprov.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -1832,6 +1885,10 @@ SOURCE=..\include\wx\filesys.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\wx\fmappriv.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\wx\font.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -2462,7 +2519,6 @@ SOURCE=..\include\wx\zipstrm.h
|
||||
|
||||
SOURCE=..\include\wx\zstream.h
|
||||
# End Source File
|
||||
|
||||
# End Group
|
||||
# Begin Group "MSW"
|
||||
|
||||
@ -2481,6 +2537,14 @@ SOURCE=..\include\wx\msw\app.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\wx\msw\apptbase.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\wx\msw\apptrait.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\wx\msw\bitmap.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -2831,7 +2895,6 @@ SOURCE=..\include\wx\msw\window.h
|
||||
|
||||
SOURCE=..\include\wx\msw\winundef.h
|
||||
# End Source File
|
||||
|
||||
# End Group
|
||||
# Begin Group "Generic"
|
||||
|
||||
@ -2992,7 +3055,6 @@ SOURCE=..\include\wx\generic\treectlg.h
|
||||
|
||||
SOURCE=..\include\wx\generic\wizard.h
|
||||
# End Source File
|
||||
|
||||
# End Group
|
||||
# Begin Group "HTML"
|
||||
|
||||
@ -3049,7 +3111,6 @@ SOURCE=..\include\wx\html\m_templ.h
|
||||
|
||||
SOURCE=..\include\wx\html\winpars.h
|
||||
# End Source File
|
||||
|
||||
# End Group
|
||||
# End Group
|
||||
# End Target
|
||||
|
@ -887,9 +887,10 @@ void wxApp::OnIdle(wxIdleEvent& event)
|
||||
s_inOnIdle = FALSE;
|
||||
}
|
||||
|
||||
void wxWakeUpIdle()
|
||||
void wxApp::WakeUpIdle()
|
||||
{
|
||||
// **** please implement me! ****
|
||||
// TODO: use wxMotif implementation?
|
||||
|
||||
// Wake up the idle handler processor, even if it is in another thread...
|
||||
}
|
||||
|
||||
@ -1061,18 +1062,11 @@ Window wxGetWindowParent(Window window)
|
||||
return (Window) 0;
|
||||
}
|
||||
|
||||
void wxExit()
|
||||
void wxApp::Exit()
|
||||
{
|
||||
int retValue = 0;
|
||||
if (wxTheApp)
|
||||
retValue = wxTheApp->OnExit();
|
||||
|
||||
wxApp::CleanUp();
|
||||
/*
|
||||
* Exit in some platform-specific way. Not recommended that the app calls this:
|
||||
* only for emergencies.
|
||||
*/
|
||||
exit(retValue);
|
||||
|
||||
wxAppConsole::Exit();
|
||||
}
|
||||
|
||||
// Yield to other processes
|
||||
|
Loading…
Reference in New Issue
Block a user