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

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

View File

@@ -120,7 +120,8 @@ treectlg.cpp Generic
wizard.cpp Generic wizard.cpp Generic
accesscmn.cpp Common accesscmn.cpp Common
appcmn.cpp Common Base appbase.cpp Common Base
appcmn.cpp Common
artprov.cpp Common artprov.cpp Common
artstd.cpp Common artstd.cpp Common
bmpbase.cpp Common NotGTK,NotOS2,NotMSW,NotMicro bmpbase.cpp Common NotGTK,NotOS2,NotMSW,NotMicro
@@ -165,8 +166,9 @@ filefn.cpp Common Base
filename.cpp Common Base filename.cpp Common Base
filesys.cpp Common Base filesys.cpp Common Base
fldlgcmn.cpp Common fldlgcmn.cpp Common
fmapbase.cpp Common Base
fontcmn.cpp Common fontcmn.cpp Common
fontmap.cpp Common Base fontmap.cpp Common
framecmn.cpp Common framecmn.cpp Common
toplvcmn.cpp Common toplvcmn.cpp Common
fs_inet.cpp Common Base fs_inet.cpp Common Base
@@ -228,6 +230,7 @@ settcmn.cpp Common
sizer.cpp Common sizer.cpp Common
socket.cpp Common Socket,Base socket.cpp Common Socket,Base
statbar.cpp Common statbar.cpp Common
stopwatch.cpp Common Base
strconv.cpp Common Base strconv.cpp Common Base
stream.cpp Common Base stream.cpp Common Base
string.cpp Common Base string.cpp Common Base
@@ -237,7 +240,7 @@ tbarbase.cpp Common
textbuf.cpp Common Base textbuf.cpp Common Base
textcmn.cpp Common textcmn.cpp Common
textfile.cpp Common Base textfile.cpp Common Base
timercmn.cpp Common Base timercmn.cpp Common
tokenzr.cpp Common Base tokenzr.cpp Common Base
treebase.cpp Common treebase.cpp Common
txtstrm.cpp Common Base txtstrm.cpp Common Base
@@ -262,6 +265,7 @@ accel.cpp MSW
access.cpp MSW OLE access.cpp MSW OLE
app.cpp MSW LowLevel app.cpp MSW LowLevel
automtn.cpp MSW OLE,LowLevel automtn.cpp MSW OLE,LowLevel
basemsw.cpp MSW Base
bitmap.cpp MSW LowLevel bitmap.cpp MSW LowLevel
bmpbuttn.cpp MSW bmpbuttn.cpp MSW
brush.cpp MSW LowLevel brush.cpp MSW LowLevel
@@ -366,12 +370,14 @@ toplevel.cpp MSW LowLevel
treectrl.cpp MSW Win32Only treectrl.cpp MSW Win32Only
utils.cpp MSW Base,LowLevel utils.cpp MSW Base,LowLevel
utilsexc.cpp MSW Base,LowLevel utilsexc.cpp MSW Base,LowLevel
utilsgui.cpp MSW LowLevel
uuid.cpp MSW OLE,LowLevel uuid.cpp MSW OLE,LowLevel
uxtheme.cpp MSW uxtheme.cpp MSW
volume.cpp MSW Base volume.cpp MSW Base
wave.cpp MSW LowLevel wave.cpp MSW LowLevel
window.cpp MSW LowLevel window.cpp MSW LowLevel
baseunix.cpp Unix Base
dialup.cpp Unix NotMac dialup.cpp Unix NotMac
dir.cpp Unix Base,NotMac dir.cpp Unix Base,NotMac
fontenum.cpp Unix NotCocoa,NotMac,NotMGL,NotMicro fontenum.cpp Unix NotCocoa,NotMac,NotMGL,NotMicro
@@ -381,6 +387,8 @@ mimetype.cpp Unix Base,NotMac,NotMicro
snglinst.cpp Unix Base snglinst.cpp Unix Base
taskbarx11.cpp Unix NotCocoa,NotMac,NotMGL,NotMicro taskbarx11.cpp Unix NotCocoa,NotMac,NotMGL,NotMicro
threadpsx.cpp Unix Base,NotMac threadpsx.cpp Unix Base,NotMac
# not yet
# utilsgui.cpp Unix
utilsunx.cpp Unix Base utilsunx.cpp Unix Base
utilsx11.cpp Unix NotMac,NotMGL,NotMicro utilsx11.cpp Unix NotMac,NotMGL,NotMicro
@@ -809,6 +817,7 @@ access.h WXH
accel.h WXH accel.h WXH
access.h WXH access.h WXH
app.h WXH Base app.h WXH Base
apptrait.h WXH Base
artprov.h WXH artprov.h WXH
bitmap.h WXH bitmap.h WXH
bmpbuttn.h WXH bmpbuttn.h WXH
@@ -881,6 +890,7 @@ filedlg.h WXH
filefn.h WXH Base filefn.h WXH Base
filename.h WXH Base filename.h WXH Base
filesys.h WXH Base filesys.h WXH Base
fmappriv.h WXH Base
font.h WXH font.h WXH
fontdlg.h WXH fontdlg.h WXH
fontenc.h WXH Base fontenc.h WXH Base
@@ -950,7 +960,7 @@ minifram.h WXH
module.h WXH Base module.h WXH Base
msgdlg.h WXH msgdlg.h WXH
msgout.h WXH Base msgout.h WXH Base
mslu.cpp MSW mslu.cpp MSW Base
mstream.h WXH Base mstream.h WXH Base
notebook.h WXH notebook.h WXH
object.h WXH Base object.h WXH Base
@@ -1350,6 +1360,8 @@ window.h MGLH
access.h MSWH access.h MSWH
accel.h MSWH accel.h MSWH
app.h MSWH app.h MSWH
apptbase.h MSWH Base
apptrait.h MSWH Base
bitmap.h MSWH bitmap.h MSWH
bmpbuttn.h MSWH bmpbuttn.h MSWH
brush.h MSWH brush.h MSWH
@@ -1547,10 +1559,13 @@ pnghand.h OS2H
statbox.h OS2H statbox.h OS2H
toplevel.h OS2H toplevel.h OS2H
apptbase.h UnixH Base
apptrait.h UnixH Base
execute.h UnixH execute.h UnixH
fontutil.h UnixH fontutil.h UnixH
gsockunx.h UnixH Base gsockunx.h UnixH Base
mimetype.h UnixH Base mimetype.h UnixH Base
pipe.h UnixH Base
taskbarx11.h UnixH taskbarx11.h UnixH
utilsx11.h UnixH utilsx11.h UnixH

View File

@@ -121,7 +121,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # 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 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 BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
@@ -147,7 +147,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # 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 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 BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
@@ -172,7 +172,7 @@ LINK32=link.exe
# PROP Intermediate_Dir "../ReleaseUnicode" # PROP Intermediate_Dir "../ReleaseUnicode"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c # 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 BASE RSC /l 0x409
# ADD RSC /l 0x409 # ADD RSC /l 0x409
BSC32=bscmake.exe BSC32=bscmake.exe
@@ -195,7 +195,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "../DebugUnicode" # PROP Intermediate_Dir "../DebugUnicode"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c # 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 BASE RSC /l 0x409
# ADD RSC /l 0x409 # ADD RSC /l 0x409
BSC32=bscmake.exe BSC32=bscmake.exe
@@ -219,7 +219,7 @@ LIB32=link.exe -lib
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # 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 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 BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
@@ -245,7 +245,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # 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 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 BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
@@ -270,7 +270,7 @@ LINK32=link.exe
# PROP Intermediate_Dir "../Release" # PROP Intermediate_Dir "../Release"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c # 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 BASE RSC /l 0x409
# ADD RSC /l 0x409 # ADD RSC /l 0x409
BSC32=bscmake.exe BSC32=bscmake.exe
@@ -293,7 +293,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "../Debug" # PROP Intermediate_Dir "../Debug"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c # 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 BASE RSC /l 0x409
# ADD RSC /l 0x409 # ADD RSC /l 0x409
BSC32=bscmake.exe BSC32=bscmake.exe

View File

@@ -7,7 +7,7 @@ by category (and sorted by alphabetical order inside each category).
\begin{twocollist}\itemsep=0pt \begin{twocollist}\itemsep=0pt
\twocolitem{\_\_WINDOWS\_\_}{any Windows, yom may also use \_\_WXMSW\_\_} \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{\_\_WIN32\_\_}{Win32 API}
\twocolitem{\_\_WIN95\_\_}{Windows 95 or NT 4.0 and above system (not NT 3.5x)} \twocolitem{\_\_WIN95\_\_}{Windows 95 or NT 4.0 and above system (not NT 3.5x)}
\twocolitem{\_\_WXGTK\_\_}{GTK} \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{\_\_WXGTK20\_\_}{GTK 2.0 or higher}
\twocolitem{\_\_WXMOTIF\_\_}{Motif} \twocolitem{\_\_WXMOTIF\_\_}{Motif}
\twocolitem{\_\_WXMOTIF20\_\_}{Motif 2.0 or higher} \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 \twocolitem{\_\_WXMGL\_\_}{SciTech Soft MGL (\_\_WXUNIVERSAL\_\_ will be also
defined)} defined)}
\twocolitem{\_\_WXMSW\_\_}{Any Windows} \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+} \twocolitem{\_\_X\_\_}{any X11-based GUI toolkit except GTK+}
\end{twocollist} \end{twocollist}
In fact, they should better all start with \_\_WX instead of \_\_ only. The In fact, they should better all start with \_\_WX instead of \_\_ only,
only GUIs implemented for 2.0 are \_\_WXGTK\_\_, \_\_WXMSW\_\_ and so please start any new defines with \_\_WX.
\_\_WXMOTIF\_\_ yet. Any new ones, please start the define with \_\_WX.
\subsection{Operating systems} \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{\_\_DOS\_GENERAL\_\_}{DOS (used with wxMGL only)}
\twocolitem{\_\_FREEBSD\_\_}{FreeBSD} \twocolitem{\_\_FREEBSD\_\_}{FreeBSD}
\twocolitem{\_\_HPUX\_\_}{HP-UX (Unix)} \twocolitem{\_\_HPUX\_\_}{HP-UX (Unix)}
\twocolitem{\_\_GNU\_\_}{GNU Hurd}
\twocolitem{\_\_LINUX\_\_}{Linux} \twocolitem{\_\_LINUX\_\_}{Linux}
\twocolitem{\_\_MACH\_\_}{Mach-O Architecture (Mac OS X only builds)} \twocolitem{\_\_MACH\_\_}{Mach-O Architecture (Mac OS X only builds)}
\twocolitem{\_\_OSF\_\_}{OSF/1} \twocolitem{\_\_OSF\_\_}{OSF/1}
@@ -99,6 +100,11 @@ the compiler version, $1100$ is $11.0$ and $1200$ is OpenWatcom.}
\subsection{Miscellaneous} \subsection{Miscellaneous}
\begin{twocollist}\itemsep=0pt \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{\_\_WXDEBUG\_\_}{defined in debug mode, undefined in release mode}
\twocolitem{wxUSE\_XXX}{if defined as $1$, feature XXX is active \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 (the symbols of this form are always defined, use \#if and not \#ifdef to test

View File

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

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

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

View File

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

View File

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

View File

@@ -2145,6 +2145,15 @@ private:
DECLARE_DYNAMIC_CLASS(wxEvtHandler) 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&); typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
#if wxUSE_GUI #if wxUSE_GUI
typedef void (wxEvtHandler::*wxCommandEventFunction)(wxCommandEvent&); typedef void (wxEvtHandler::*wxCommandEventFunction)(wxCommandEvent&);

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

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

View File

@@ -32,68 +32,64 @@
class WXDLLEXPORT wxConfigBase; class WXDLLEXPORT wxConfigBase;
#endif // wxUSE_CONFIG #endif // wxUSE_CONFIG
class WXDLLEXPORT wxFontMapper;
#if wxUSE_GUI #if wxUSE_GUI
class WXDLLEXPORT wxWindow; class WXDLLEXPORT wxWindow;
#endif // wxUSE_GUI #endif // wxUSE_GUI
// ---------------------------------------------------------------------------- // ============================================================================
// wxFontMapper manages user-definable correspondence between logical font // wxFontMapper manages user-definable correspondence between wxWindows font
// names and the fonts present on the machine. // encodings and the fonts present on the machine.
// //
// The default implementations of all functions will ask the user if they are // This is a singleton class, font mapper objects can only be accessed using
// not capable of finding the answer themselves and store the answer in a // wxFontMapper::Get().
// 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 // wxFontMapperBase: this is a non-interactive class which just uses its built
// disable this - which shouldn't be ever needed because if "interactive" was // in knowledge of the encodings equivalence
// never TRUE, the config file is never created anyhow.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLEXPORT wxFontMapper class WXDLLEXPORT wxFontMapperBase
{ {
public: public:
// default ctor // constructtor and such
wxFontMapper(); // ---------------------
// virtual dtor for a base class // default ctor
virtual ~wxFontMapper(); wxFontMapperBase();
// virtual dtor for any base class
virtual ~wxFontMapperBase();
// return instance of the wxFontMapper singleton // return instance of the wxFontMapper singleton
static wxFontMapper *Get(); static wxFontMapper *Get();
// set the sigleton to 'mapper' instance and return previous one // set the sigleton to 'mapper' instance and return previous one
static wxFontMapper *Set(wxFontMapper *mapper); 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 // translates charset strings to encoding
// 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
// returns the encoding for the given charset (in the form of RFC 2046) or // returns the encoding for the given charset (in the form of RFC 2046) or
// wxFONTENCODING_SYSTEM if couldn't decode it // 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, 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 // return internal string identifier for the encoding (see also
// GetEncodingDescription()) // GetEncodingDescription())
@@ -104,16 +100,6 @@ public:
// NB: hard-coded now, but might change later (read it from config?) // NB: hard-coded now, but might change later (read it from config?)
static wxString GetEncodingDescription(wxFontEncoding encoding); 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, // functions which allow to configure the config object used: by default,
// the global one (from wxConfigBase::Get() will be used) and the default // the global one (from wxConfigBase::Get() will be used) and the default
@@ -130,22 +116,21 @@ public:
// return default config path // return default config path
static const wxChar *GetDefaultConfigPath(); static const wxChar *GetDefaultConfigPath();
#endif #endif // wxUSE_CONFIG
protected: protected:
#if wxUSE_CONFIG #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 // function will use wxConfig::Get() to get the global one
wxConfigBase *GetConfig(); 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() // GetDefaultConfigPath()
const wxString& GetConfigPath(); const wxString& GetConfigPath();
#endif
// change to the given (relative) path in the config, return TRUE if ok // change to the given (relative) path in the config, return true if ok
// (then GetConfig() will return something !NULL), FALSE if no config // (then GetConfig() will return something !NULL), false if no config
// object // object
// //
// caller should provide a pointer to the string variable which should be // caller should provide a pointer to the string variable which should be
@@ -155,7 +140,87 @@ protected:
// restore the config path after use // restore the config path after use
void RestorePath(const wxString& pathOld); 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 #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 // GetAltForEncoding() helper: tests for the existence of the given
// encoding and saves the result in config if ok - this results in the // encoding and saves the result in config if ok - this results in the
// following (desired) behaviour: when an unknown/unavailable encoding is // following (desired) behaviour: when an unknown/unavailable encoding is
@@ -166,38 +231,31 @@ protected:
bool TestAltEncoding(const wxString& configEntry, bool TestAltEncoding(const wxString& configEntry,
wxFontEncoding encReplacement, wxFontEncoding encReplacement,
wxNativeEncodingInfo *info); 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 // the title for our dialogs
wxString m_titleDialog; wxString m_titleDialog;
// the parent window for our dialogs // the parent window for our dialogs
wxWindow *m_windowParent; wxWindow *m_windowParent;
#endif // wxUSE_GUI
friend class wxFontMapperPathChanger;
private: private:
static wxFontMapper *sm_instance;
DECLARE_NO_COPY_CLASS(wxFontMapper) DECLARE_NO_COPY_CLASS(wxFontMapper)
}; };
#else // !wxUSE_GUI
class WXDLLEXPORT wxFontMapper : public wxFontMapperBase
{
};
#endif // wxUSE_GUI/!wxUSE_GUI
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// global variables // global variables
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// the default font mapper for wxWindows programs // the default font mapper for wxWindows programs do NOT use! This is for
// do NOT use! This is for backward compatibility, use wxFontMapper::Get() instead // backward compatibility, use wxFontMapper::Get() instead
#define wxTheFontMapper (wxFontMapper::Get()) #define wxTheFontMapper (wxFontMapper::Get())
#else // !wxUSE_FONTMAP #else // !wxUSE_FONTMAP
@@ -210,3 +268,4 @@ private:
#endif // wxUSE_FONTMAP/!wxUSE_FONTMAP #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
#endif // _WX_FONTMAPPER_H_ #endif // _WX_FONTMAPPER_H_

View File

@@ -23,27 +23,23 @@
#include "wx/filesys.h" #include "wx/filesys.h"
#if wxUSE_GUI class WXDLLEXPORT wxBitmap;
#include "wx/image.h" class WXDLLEXPORT wxImage;
#include "wx/bitmap.h"
#endif
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// wxMemoryFSHandler // wxMemoryFSHandler
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
class WXDLLEXPORT wxMemoryFSHandler : public wxFileSystemHandler class WXDLLEXPORT wxMemoryFSHandlerBase : public wxFileSystemHandler
{ {
public: public:
wxMemoryFSHandler(); wxMemoryFSHandlerBase();
~wxMemoryFSHandler(); ~wxMemoryFSHandlerBase();
// Add file to list of files stored in memory. Stored data (bitmap, text or raw data) // Add file to list of files stored in memory. Stored data (bitmap, text or
// will be copied into private memory stream and available under name "memory:" + filename // raw data) will be copied into private memory stream and available under
#if wxUSE_GUI // name "memory:" + filename
static void AddFile(const wxString& filename, wxImage& image, long type); 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 wxString& textdata);
static void AddFile(const wxString& filename, const void *binarydata, size_t size); static void AddFile(const wxString& filename, const void *binarydata, size_t size);
@@ -61,9 +57,15 @@ class WXDLLEXPORT wxMemoryFSHandler : public wxFileSystemHandler
static bool CheckHash(const wxString& filename); static bool CheckHash(const wxString& filename);
}; };
#endif class wxMemoryFSHandler : public wxMemoryFSHandlerBase
// wxUSE_FILESYSTEM {
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_ #endif // _WX_FS_MEM_H_

View File

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

View File

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

View File

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

View File

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

View File

@@ -74,6 +74,18 @@ public:
#endif // wxUSE_GUI #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) // implementation using wxLog (mainly for backwards compatibility)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

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

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

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

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

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

View File

@@ -240,6 +240,50 @@ struct HH_AKLINK
BOOL fIndexOnFail; 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 // Rich text control
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -319,7 +363,7 @@ typedef struct _paraformat2 {
#endif #endif
#endif #endif // wxUSE_RICHEDIT
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Misc stuff // Misc stuff

View File

@@ -76,8 +76,12 @@ public:
virtual bool Initialized(void); virtual bool Initialized(void);
virtual bool Pending(void) ; virtual bool Pending(void) ;
virtual void Dispatch(void); virtual void Dispatch(void);
virtual void Exit();
virtual bool Yield(bool onlyIfNeeded = FALSE); 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 void SetPrintMode(int mode) { m_nPrintMode = mode; }
virtual int GetPrintMode(void) const { return m_nPrintMode; } virtual int GetPrintMode(void) const { return m_nPrintMode; }

View File

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

View File

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

View File

@@ -10,6 +10,11 @@
#ifndef _WX_UNIX_EXECUTE_H #ifndef _WX_UNIX_EXECUTE_H
#define _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 // 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 // executed when the process terminates, if pid < 0, the execution is
// synchronous and the caller (wxExecute) frees the data // synchronous and the caller (wxExecute) frees the data
@@ -21,6 +26,43 @@ struct wxEndProcessData
int exitcode; // the exit code 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 // this function is called when the process terminates from port specific
// callback function and is common to all ports (src/unix/utilsunx.cpp) // callback function and is common to all ports (src/unix/utilsunx.cpp)
extern void wxHandleProcessTermination(wxEndProcessData *proc_data); 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 // this function is called to associate the port-specific callback with the
// child process. The return valus is port-specific. // child process. The return valus is port-specific.
extern int wxAddProcessCallback(wxEndProcessData *proc_data, int fd); extern int wxAddProcessCallback(wxEndProcessData *proc_data, int fd);
// For ports (e.g. DARWIN) which can add callbacks based on the pid // For ports (e.g. DARWIN) which can add callbacks based on the pid
extern int wxAddProcessCallbackForPid(wxEndProcessData *proc_data, int pid); extern int wxAddProcessCallbackForPid(wxEndProcessData *proc_data, int pid);

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

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

View File

@@ -24,10 +24,6 @@
#if wxUSE_FSVOLUME #if wxUSE_FSVOLUME
#if wxUSE_GUI
#include "wx/iconbndl.h" // for wxIconArray
#endif // wxUSE_GUI
// the volume flags // the volume flags
enum enum
{ {
@@ -56,22 +52,7 @@ enum wxFSVolumeKind
wxFS_VOL_MAX wxFS_VOL_MAX
}; };
#if wxUSE_GUI class WXDLLEXPORT wxFSVolumeBase
#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
{ {
public: public:
// return the array containing the names of the volumes // 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 // create the volume object with this name (should be one of those returned
// by GetVolumes()). // by GetVolumes()).
wxFSVolume(); wxFSVolumeBase();
wxFSVolume(const wxString& name); wxFSVolumeBase(const wxString& name);
bool Create(const wxString& name); bool Create(const wxString& name);
// accessors // accessors
@@ -112,22 +93,61 @@ public:
wxString GetName() const { return m_volName; } wxString GetName() const { return m_volName; }
wxString GetDisplayName() const { return m_dispName; } wxString GetDisplayName() const { return m_dispName; }
#if wxUSE_GUI
wxIcon GetIcon(wxFSIconType type) const;
#endif
// TODO: operatios (Mount(), Unmount(), Eject(), ...)? // TODO: operatios (Mount(), Unmount(), Eject(), ...)?
private: protected:
// the internal volume name
wxString m_volName; 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 // wxUSE_FSVOLUME
#endif // _WX_FSVOLUME_H_ #endif // _WX_FSVOLUME_H_

View File

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

View File

@@ -205,20 +205,11 @@ int wxEntry( int argc, char *argv[])
return retValue; return retValue;
} }
// ---------------------------------------------------------------------------- void wxApp::Exit()
// other functions
// ----------------------------------------------------------------------------
void wxWakeUpIdle()
{ {
wxTheApp->CocoaRequestIdle();
}
void wxExit()
{
wxLogError(_("Fatal error: exiting"));
wxApp::CleanUp(); wxApp::CleanUp();
exit(1);
wxAppConsole::Exit();
} }
// ============================================================================ // ============================================================================

735
src/common/appbase.cpp Normal file
View 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__

View File

@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: common/appcmn.cpp // Name: common/appcmn.cpp
// Purpose: wxAppBase methods common to all platforms // Purpose: wxAppConsole and wxAppBase methods common to all platforms
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 18.10.99 // Created: 18.10.99
@@ -32,45 +32,20 @@
#include "wx/app.h" #include "wx/app.h"
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/list.h" #include "wx/list.h"
#if wxUSE_LOG
#include "wx/log.h"
#endif // wxUSE_LOG
#if wxUSE_GUI
#include "wx/msgdlg.h" #include "wx/msgdlg.h"
#endif // wxUSE_GUI
#endif #endif
#include "wx/cmdline.h" #include "wx/apptrait.h"
#include "wx/thread.h" #if wxUSE_FONTMAP
#include "wx/confbase.h" #include "wx/fontmap.h"
#include "wx/tokenzr.h" #endif // wxUSE_FONTMAP
#include "wx/utils.h"
#include "wx/msgout.h" #include "wx/msgout.h"
#include "wx/thread.h"
#include "wx/utils.h"
#if wxUSE_GUI // ============================================================================
#include "wx/artprov.h" // wxAppBase implementation
#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
// ===========================================================================
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// initialization and termination // initialization and termination
@@ -78,13 +53,6 @@
wxAppBase::wxAppBase() 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_topWindow = (wxWindow *)NULL;
m_useBestVisual = FALSE; m_useBestVisual = FALSE;
m_isActive = TRUE; m_isActive = TRUE;
@@ -102,11 +70,6 @@ wxAppBase::wxAppBase()
// safely (i.e. without losing the effect of the users SetExitOnFrameDelete // safely (i.e. without losing the effect of the users SetExitOnFrameDelete
// call) overwrite in OnRun() // call) overwrite in OnRun()
m_exitOnFrameDelete = Later; m_exitOnFrameDelete = Later;
#endif // wxUSE_GUI
#ifdef __WXDEBUG__
SetTraceMasks();
#endif
} }
wxAppBase::~wxAppBase() wxAppBase::~wxAppBase()
@@ -114,8 +77,6 @@ wxAppBase::~wxAppBase()
// this destructor is required for Darwin // this destructor is required for Darwin
} }
#if wxUSE_GUI
bool wxAppBase::OnInitGui() bool wxAppBase::OnInitGui()
{ {
#ifdef __WXUNIVERSAL__ #ifdef __WXUNIVERSAL__
@@ -139,103 +100,20 @@ int wxAppBase::OnRun()
return MainLoop(); return MainLoop();
} }
#endif // wxUSE_GUI void wxAppBase::Exit()
int wxAppBase::OnExit()
{ {
#if wxUSE_CONFIG ExitMainLoop();
// 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;
} }
// ---------------------------------------------------------------------------- wxAppTraits *wxAppBase::CreateTraits()
// customization hooks
// ----------------------------------------------------------------------------
#if wxUSE_LOG
wxLog *wxAppBase::CreateLogTarget()
{ {
#if wxUSE_GUI && wxUSE_LOGGUI && !defined(__WXMICROWIN__) return wxAppTraits::CreateGUI();
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 );
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// misc // misc
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if wxUSE_GUI
void wxAppBase::SetActive(bool active, wxWindow * WXUNUSED(lastFocus)) void wxAppBase::SetActive(bool active, wxWindow * WXUNUSED(lastFocus))
{ {
if ( active == m_isActive ) if ( active == m_isActive )
@@ -249,351 +127,65 @@ void wxAppBase::SetActive(bool active, wxWindow * WXUNUSED(lastFocus))
(void)ProcessEvent(event); (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 #if wxUSE_LOG
wxLog *wxGUIAppTraitsBase::CreateLogTarget()
{ {
wxCMD_LINE_SWITCH, return new wxLogGui;
_T(""), }
OPTION_VERBOSE,
gettext_noop("generate verbose log messages"),
wxCMD_LINE_VAL_NONE,
0x0
},
#endif // wxUSE_LOG #endif // wxUSE_LOG
#ifdef __WXUNIVERSAL__ wxMessageOutput *wxGUIAppTraitsBase::CreateMessageOutput()
{ {
wxCMD_LINE_OPTION, // The standard way of printing help on command line arguments (app --help)
_T(""), // is (according to common practice):
OPTION_THEME, // - console apps: to stderr (on any platform)
gettext_noop("specify the theme to use"), // - GUI apps: stderr on Unix platforms (!)
wxCMD_LINE_VAL_STRING, // message box under Windows and others
0x0 #ifdef __UNIX__
}, return new wxMessageOutputStderr;
#endif // __WXUNIVERSAL__ #else // !__UNIX__
// wxMessageOutputMessageBox doesn't work under Motif
#if defined(__WXMGL__) #ifdef __WXMOTIF__
// VS: this is not specific to wxMGL, all fullscreen (framebuffer) ports return new wxMessageOutputLog;
// 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 wxAppBase::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 wxAppBase::OnCmdLineHelp(wxCmdLineParser& parser)
{
parser.Usage();
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;
#else #else
isDebug = FALSE; return new wxMessageOutputMessageBox;
#endif #endif
#endif // __UNIX__/!__UNIX__
}
int verMaj = wxMAJOR_VERSION, #if wxUSE_FONTMAP
verMin = wxMINOR_VERSION;
if ( !(wxCMP(isDebug) && wxCMP(verMaj) && wxCMP(verMin)) ) wxFontMapper *wxGUIAppTraitsBase::CreateFontMapper()
{ {
wxString msg; return new wxFontMapper;
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; #endif // wxUSE_FONTMAP
}
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
static void LINKAGEMODE SetTraceMasks() bool wxGUIAppTraitsBase::ShowAssertDialog(const wxString& msg)
{ {
#if wxUSE_LOG // under MSW we prefer to use the base class version using ::MessageBox()
wxString mask; // even if wxMessageBox() is available because it has less chances to
if ( wxGetEnv(wxT("WXTRACE"), &mask) ) // double fault our app than our wxMessageBox()
{ #if defined(__WXMSW__) || !wxUSE_MSGDLG
wxStringTokenizer tkn(mask, wxT(",")); return wxAppTraitsBase::ShowAssertDialog(msg);
while ( tkn.HasMoreTokens() ) #else // wxUSE_MSGDLG
wxLog::AddTraceMask(tkn.GetNextToken()); // this message is intentionally not translated -- it is for
}
#endif // wxUSE_LOG
}
// 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);
}
// 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 // developpers only
wxStrcat(szBuf, wxT("\nDo you want to stop the program?\nYou can also choose [Cancel] to suppress further warnings.")); wxString msgDlg(msg);
msgDlg += wxT("\nDo you want to stop the program?\n")
wxT("You can also choose [Cancel] to suppress ")
wxT("further warnings.");
// use the native message box if available: this is more robust than switch ( wxMessageBox(msgDlg, wxT("wxWindows Debug Alert"),
// 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 ) ) wxYES_NO | wxCANCEL | wxICON_STOP ) )
{ {
case wxYES: case wxYES:
@@ -601,62 +193,46 @@ void ShowAssertDialog(const wxChar *szFile,
break; break;
case wxCANCEL: case wxCANCEL:
s_bNoAsserts = TRUE; // no more asserts
break; return true;
//case wxNO: nothing to do //case wxNO: nothing to do
} }
#endif // GUI or MSW
#else // !GUI return false;
wxTrap(); #endif // !wxUSE_MSGDLG/wxUSE_MSGDLG
#endif // GUI/!GUI
}
} }
// this function is called when an assert fails #endif // __WXDEBUG__
void wxOnAssert(const wxChar *szFile,
int nLine, bool wxGUIAppTraitsBase::HasStderr()
const wxChar *szCond,
const wxChar *szMsg)
{ {
// FIXME MT-unsafe // we consider that under Unix stderr always goes somewhere, even if the
static bool s_bInAssert = FALSE; // user doesn't always see it under GUI desktops
#ifdef __UNIX__
return true;
#else
return false;
#endif
}
if ( s_bInAssert ) void wxGUIAppTraitsBase::ScheduleForDestroy(wxObject *object)
{ {
// He-e-e-e-elp!! we're trapped in endless loop if ( !wxPendingDelete.Member(object) )
wxTrap(); wxPendingDelete.Append(object);
s_bInAssert = FALSE;
return;
} }
s_bInAssert = TRUE; void wxGUIAppTraitsBase::RemoveFromPendingDelete(wxObject *object)
if ( !wxTheApp )
{ {
// by default, show the assert dialog box - we can't customize this wxPendingDelete.DeleteObject(object);
// behaviour
ShowAssertDialog(szFile, nLine, szCond, szMsg);
} }
else
// ----------------------------------------------------------------------------
// wxAppTraits
// ----------------------------------------------------------------------------
wxAppTraits *wxAppTraitsBase::CreateGUI()
{ {
// let the app process it as it wants return new wxGUIAppTraits;
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

View File

@@ -50,23 +50,6 @@ protected:
#define ART(artId, xpmRc) \ #define ART(artId, xpmRc) \
if ( id == artId ) return wxBitmap(xpmRc##_xpm); 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 // There are two ways of getting the standard icon: either via XPMs or via
// wxIcon ctor. This depends on the platform: // wxIcon ctor. This depends on the platform:
#if defined(__WXUNIVERSAL__) #if defined(__WXUNIVERSAL__)
@@ -87,7 +70,6 @@ protected:
#define ART_MSGBOX(artId, iconId, xpmRc) \ #define ART_MSGBOX(artId, iconId, xpmRc) \
if ( id == artId ) \ if ( id == artId ) \
{ \ { \
GET_STD_ICON_FROM_APP(iconId) \
CREATE_STD_ICON(#iconId, xpmRc) \ CREATE_STD_ICON(#iconId, xpmRc) \
} }

642
src/common/fmapbase.cpp Normal file
View 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

View File

@@ -5,7 +5,7 @@
// Modified by: // Modified by:
// Created: 04.11.99 // Created: 04.11.99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Vadim Zeitlin // Copyright: (c) 1999-2003 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -36,20 +36,17 @@
#include "wx/intl.h" #include "wx/intl.h"
#endif // PCH #endif // PCH
#include "wx/module.h"
#include "wx/fontmap.h" #include "wx/fontmap.h"
#include "wx/fmappriv.h"
#if wxUSE_CONFIG #if wxUSE_CONFIG
#include "wx/config.h" #include "wx/config.h"
#include "wx/memconf.h" #endif // wxUSE_CONFIG
#endif
#if wxUSE_GUI
#include "wx/fontutil.h" #include "wx/fontutil.h"
#include "wx/msgdlg.h" #include "wx/msgdlg.h"
#include "wx/fontdlg.h" #include "wx/fontdlg.h"
#include "wx/choicdlg.h" #include "wx/choicdlg.h"
#endif // wxUSE_GUI
#include "wx/encconv.h" #include "wx/encconv.h"
@@ -59,160 +56,31 @@
// the config paths we use // the config paths we use
#if wxUSE_CONFIG #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_FROM_ENCODING_PATH = wxT("Encodings");
static const wxChar* FONTMAPPER_FONT_DONT_ASK = wxT("none"); static const wxChar* FONTMAPPER_FONT_DONT_ASK = wxT("none");
#endif // wxUSE_GUI
#endif // wxUSE_CONFIG #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 // private classes
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// change the config path during the lifetime of this object // it may happen that while we're showing a dialog asking the user about
class wxFontMapperPathChanger // 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: public:
wxFontMapperPathChanger(wxFontMapper *fontMapper, const wxString& path) ReentrancyBlocker(bool& flag) : m_flagOld(flag), m_flag(flag)
{ { m_flag = true; }
m_fontMapper = fontMapper; ~ReentrancyBlocker() { m_flag = m_flagOld; }
m_ok = m_fontMapper->ChangePath(path, &m_pathOld);
}
bool IsOk() const { return m_ok; }
~wxFontMapperPathChanger()
{
if ( IsOk() )
m_fontMapper->RestorePath(m_pathOld);
}
private: private:
wxFontMapper *m_fontMapper; bool m_flagOld;
bool m_ok; bool& m_flag;
wxString m_pathOld;
DECLARE_NO_COPY_CLASS(wxFontMapperPathChanger)
}; };
// ============================================================================ // ============================================================================
@@ -225,443 +93,21 @@ private:
wxFontMapper::wxFontMapper() wxFontMapper::wxFontMapper()
{ {
#if wxUSE_CONFIG
m_config = NULL;
m_configIsDummy = FALSE;
#endif // wxUSE_CONFIG
#if wxUSE_GUI
m_windowParent = NULL; m_windowParent = NULL;
#endif // wxUSE_GUI
} }
wxFontMapper::~wxFontMapper() wxFontMapper::~wxFontMapper()
{ {
#if wxUSE_CONFIG
if ( m_configIsDummy )
delete m_config;
#endif // wxUSE_CONFIG
} }
wxFontMapper *wxFontMapper::sm_instance = NULL; wxFontEncoding
wxFontMapper::CharsetToEncoding(const wxString& charset, bool interactive)
/*static*/ wxFontMapper *wxFontMapper::Get()
{ {
if ( !sm_instance ) // try the ways not needing the users intervention first
sm_instance = new wxFontMapper; wxFontEncoding
return sm_instance; encoding = wxFontMapperBase::CharsetToEncoding(charset, interactive);
}
/*static*/ wxFontMapper *wxFontMapper::Set(wxFontMapper *mapper) // if we failed to find the encoding, ask the user -- unless disabled
{
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 ( (encoding == wxFONTENCODING_SYSTEM) && interactive ) if ( (encoding == wxFONTENCODING_SYSTEM) && interactive )
{ {
// prepare the dialog data // 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()); 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 // the list of choices
const size_t count = WXSIZEOF(gs_encodingDescs); const size_t count = GetSupportedEncodingsCount();
wxString *encodingNamesTranslated = new wxString[count]; wxString *encodingNamesTranslated = new wxString[count];
for ( size_t i = 0; i < count; i++ ) for ( size_t i = 0; i < count; i++ )
{ {
encodingNamesTranslated[i] = wxGetTranslation(gs_encodingDescs[i]); encodingNamesTranslated[i] = GetEncodingDescription(GetEncoding(i));
} }
// the parent window // the parent window
@@ -700,28 +146,26 @@ wxFontEncoding wxFontMapper::CharsetToEncoding(const wxString& charset,
if ( n != -1 ) if ( n != -1 )
{ {
encoding = gs_encodings[n]; encoding = GetEncoding(n);
} }
#if wxUSE_CONFIG #if wxUSE_CONFIG
// save the result in the config now // 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(); 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 // we don't know it
long value = n == -1 ? wxFONTENCODING_UNKNOWN : (long)encoding; long value = n == -1 ? wxFONTENCODING_UNKNOWN : (long)encoding;
if ( !config->Write(charset, value) ) if ( !config->Write(charset, value) )
{ {
wxLogError(_("Failed to remember the encoding for the charset '%s'."), charset.c_str()); wxLogError(_("Failed to remember the encoding for the charset '%s'."), charset.c_str());
} }
RestorePath(pathOld);
} }
#endif // wxUSE_CONFIG #endif // wxUSE_CONFIG
} }
#endif // wxUSE_GUI
return encoding; return encoding;
} }
@@ -732,8 +176,6 @@ wxFontEncoding wxFontMapper::CharsetToEncoding(const wxString& charset,
// correspond to which is used by GetFontForEncoding() function // correspond to which is used by GetFontForEncoding() function
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if wxUSE_GUI
bool wxFontMapper::TestAltEncoding(const wxString& configEntry, bool wxFontMapper::TestAltEncoding(const wxString& configEntry,
wxFontEncoding encReplacement, wxFontEncoding encReplacement,
wxNativeEncodingInfo *info) wxNativeEncodingInfo *info)
@@ -750,26 +192,12 @@ bool wxFontMapper::TestAltEncoding(const wxString& configEntry,
GetConfig()->Write(configEntry, info->ToString()); GetConfig()->Write(configEntry, info->ToString());
} }
#endif // wxUSE_CONFIG #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, bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
wxNativeEncodingInfo *info, wxNativeEncodingInfo *info,
const wxString& facename, const wxString& facename,
@@ -780,20 +208,20 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
// example, when GetAltForEncoding() is called from an OnPaint() handler: // example, when GetAltForEncoding() is called from an OnPaint() handler:
// in this case, wxYield() which is called from wxMessageBox() we use here // 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 // 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. // code because we are called from wxFont ctor implicitly.
// assume we're always called from the main thread, so that it is safe to // assume we're always called from the main thread, so that it is safe to
// use a static var // use a static var
static bool s_inGetAltForEncoding = FALSE; static bool s_inGetAltForEncoding = false;
if ( interactive && s_inGetAltForEncoding ) if ( interactive && s_inGetAltForEncoding )
return FALSE; return false;
ReentrancyBlocker blocker(s_inGetAltForEncoding); ReentrancyBlocker blocker(s_inGetAltForEncoding);
#endif // wxUSE_GUI #endif // wxUSE_GUI
wxCHECK_MSG( info, FALSE, wxT("bad pointer in GetAltForEncoding") ); wxCHECK_MSG( info, false, wxT("bad pointer in GetAltForEncoding") );
info->facename = facename; info->facename = facename;
@@ -803,7 +231,7 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
} }
// if we failed to load the system default encoding, something is really // 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 // recursion trying to create the font in the msg box with the error
// message // message
if ( encoding == wxFONTENCODING_SYSTEM ) if ( encoding == wxFONTENCODING_SYSTEM )
@@ -823,28 +251,26 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
#if wxUSE_CONFIG #if wxUSE_CONFIG
// do we have a font spec for this encoding? // do we have a font spec for this encoding?
wxString pathOld; wxString fontinfo;
if ( ChangePath(FONTMAPPER_FONT_FROM_ENCODING_PATH, &pathOld) ) 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 // 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 // encoding but, moreover, have already asked the user as well and he
// didn't specify any font neither // didn't specify any font neither
if ( fontinfo == FONTMAPPER_FONT_DONT_ASK ) if ( fontinfo == FONTMAPPER_FONT_DONT_ASK )
{ {
interactive = FALSE; interactive = false;
} }
else // use the info entered the last time else // use the info entered the last time
{ {
if ( !!fontinfo && !!facename ) if ( !!fontinfo && !!facename )
{ {
// we tried to find a match with facename - now try without it // we tried to find a match with facename -- now try without it
fontinfo = config->Read(encName); fontinfo = GetConfig()->Read(encName);
} }
if ( !!fontinfo ) if ( !!fontinfo )
@@ -854,7 +280,7 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
if ( wxTestFontEncoding(*info) ) if ( wxTestFontEncoding(*info) )
{ {
// ok, got something // ok, got something
return TRUE; return true;
} }
//else: no such fonts, look for something else //else: no such fonts, look for something else
// (should we erase the outdated value?) // (should we erase the outdated value?)
@@ -867,14 +293,13 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
} }
//else: there is no information in config about this encoding //else: there is no information in config about this encoding
} }
}
#endif // wxUSE_CONFIG #endif // wxUSE_CONFIG
// now try to map this encoding to a compatible one which we have on this // now try to map this encoding to a compatible one which we have on this
// system // system
wxFontEncodingArray equiv = wxEncodingConverter::GetAllEquivalents(encoding); wxFontEncodingArray equiv = wxEncodingConverter::GetAllEquivalents(encoding);
size_t count = equiv.GetCount(); size_t count = equiv.GetCount();
bool foundEquivEncoding = FALSE; bool foundEquivEncoding = false;
wxFontEncoding equivEncoding = wxFONTENCODING_SYSTEM; wxFontEncoding equivEncoding = wxFONTENCODING_SYSTEM;
if ( count ) if ( count )
{ {
@@ -888,7 +313,7 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
{ {
equivEncoding = equiv[i]; equivEncoding = equiv[i];
foundEquivEncoding = TRUE; foundEquivEncoding = true;
} }
} }
} }
@@ -938,15 +363,15 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
#if wxUSE_CONFIG #if wxUSE_CONFIG
// remember this in the 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()); GetConfig()->Write(configEntry, info->ToString());
RestorePath(pathOld);
} }
#endif // wxUSE_CONFIG #endif // wxUSE_CONFIG
return TRUE; return true;
} }
//else: the user canceled the font selection dialog //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 // remember it to avoid asking the same question again later
#if wxUSE_CONFIG #if wxUSE_CONFIG
if ( ChangePath(FONTMAPPER_FONT_FROM_ENCODING_PATH, &pathOld) ) wxFontMapperPathChanger path(this,
FONTMAPPER_FONT_FROM_ENCODING_PATH);
if ( path.IsOk() )
{ {
GetConfig()->Write GetConfig()->Write
( (
@@ -965,8 +392,6 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
foundEquivEncoding ? info->ToString().c_str() foundEquivEncoding ? info->ToString().c_str()
: FONTMAPPER_FONT_DONT_ASK : FONTMAPPER_FONT_DONT_ASK
); );
RestorePath(pathOld);
} }
#endif // wxUSE_CONFIG #endif // wxUSE_CONFIG
} }
@@ -978,14 +403,20 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
} }
bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding, bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
wxFontEncoding *alt_encoding, wxFontEncoding *encodingAlt,
const wxString& facename, const wxString& facename,
bool interactive) bool interactive)
{ {
wxNativeEncodingInfo info; wxNativeEncodingInfo info;
bool r = GetAltForEncoding(encoding, &info, facename, interactive); if ( !GetAltForEncoding(encoding, &info, facename, interactive) )
*alt_encoding = info.encoding; return false;
return r;
wxCHECK_MSG( encodingAlt, false,
_T("wxFontEncoding::GetAltForEncoding(): NULL pointer") );
*encodingAlt = info.encoding;
return true;
} }
bool wxFontMapper::IsEncodingAvailable(wxFontEncoding encoding, bool wxFontMapper::IsEncodingAvailable(wxFontEncoding encoding,
@@ -993,15 +424,11 @@ bool wxFontMapper::IsEncodingAvailable(wxFontEncoding encoding,
{ {
wxNativeEncodingInfo info; wxNativeEncodingInfo info;
if (wxGetNativeFontEncoding(encoding, &info)) if ( !wxGetNativeFontEncoding(encoding, &info) )
{ return false;
info.facename = facename; info.facename = facename;
return wxTestFontEncoding(info); return wxTestFontEncoding(info);
} }
return FALSE;
}
#endif // wxUSE_GUI
#endif // wxUSE_FONTMAP #endif // wxUSE_FONTMAP

View File

@@ -19,14 +19,18 @@
#if wxUSE_FILESYSTEM && wxUSE_STREAMS #if wxUSE_FILESYSTEM && wxUSE_STREAMS
#include "wx/image.h"
#include "wx/bitmap.h"
#include "wx/fs_mem.h"
#ifdef __WXBASE__
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/log.h" #include "wx/log.h"
#include "wx/hash.h" #include "wx/hash.h"
#endif #endif
#include "wx/filesys.h"
#include "wx/fs_mem.h"
#include "wx/mstream.h" #include "wx/mstream.h"
class MemFSHashObj : public wxObject 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 // 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 // delete static data here. (There is no way how to remove FS handler from
// wxFileSystem other than releasing _all_ handlers.) // wxFileSystem other than releasing _all_ handlers.)
if (m_Hash) delete m_Hash; if (m_Hash)
{
delete m_Hash;
m_Hash = NULL; m_Hash = NULL;
} }
}
bool wxMemoryFSHandler::CanOpen(const wxString& location) bool wxMemoryFSHandlerBase::CanOpen(const wxString& location)
{ {
wxString p = GetProtocol(location); wxString p = GetProtocol(location);
return (p == wxT("memory")); 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) 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)) int WXUNUSED(flags))
{ {
wxFAIL_MSG(wxT("wxMemoryFSHandler::FindFirst not implemented")); wxFAIL_MSG(wxT("wxMemoryFSHandlerBase::FindFirst not implemented"));
return wxEmptyString; return wxEmptyString;
} }
wxString wxMemoryFSHandler::FindNext() wxString wxMemoryFSHandlerBase::FindNext()
{ {
wxFAIL_MSG(wxT("wxMemoryFSHandler::FindNext not implemented")); wxFAIL_MSG(wxT("wxMemoryFSHandlerBase::FindNext not implemented"));
return wxEmptyString; return wxEmptyString;
} }
bool wxMemoryFSHandler::CheckHash(const wxString& filename) bool wxMemoryFSHandlerBase::CheckHash(const wxString& filename)
{ {
if (m_Hash == NULL) if (m_Hash == NULL)
{ {
@@ -166,9 +173,8 @@ bool wxMemoryFSHandler::CheckHash(const wxString& filename)
#if wxUSE_GUI /*static*/ void
wxMemoryFSHandlerBase::AddFile(const wxString& filename, wxImage& image, long type)
/*static*/ void wxMemoryFSHandler::AddFile(const wxString& filename, wxImage& image, long type)
{ {
if (!CheckHash(filename)) return; 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) /*static*/ void wxMemoryFSHandlerBase::AddFile(const wxString& filename, const wxString& textdata)
{
wxImage img = bitmap.ConvertToImage();
AddFile(filename, img, type);
}
#endif
/*static*/ void wxMemoryFSHandler::AddFile(const wxString& filename, const wxString& textdata)
{ {
AddFile(filename, (const void*) textdata.mb_str(), textdata.Length()); 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; if (!CheckHash(filename)) return;
m_Hash -> Put(filename, new MemFSHashObj(binarydata, size)); 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 || if (m_Hash == NULL ||
m_Hash -> Get(filename) == NULL) m_Hash -> Get(filename) == NULL)
@@ -222,6 +220,18 @@ bool wxMemoryFSHandler::CheckHash(const wxString& filename)
delete m_Hash -> Delete(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 #endif // wxUSE_FILESYSTEM && wxUSE_FS_ZIP

View File

@@ -32,23 +32,15 @@
#include "wx/module.h" #include "wx/module.h"
// ----------------------------------------------------------------------------
// global vars
// ----------------------------------------------------------------------------
WXDLLEXPORT wxApp *wxTheApp = NULL;
wxAppInitializerFunction
wxAppBase::m_appInitFn = (wxAppInitializerFunction)NULL;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// private classes // 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: 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 // implementation
// ============================================================================ // ============================================================================
// ----------------------------------------------------------------------------
// stubs for some GUI functions
// ----------------------------------------------------------------------------
void WXDLLEXPORT wxExit()
{
abort();
}
// Yield to other apps/messages
void WXDLLEXPORT wxWakeUpIdle()
{
// do nothing
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxBase-specific functions // wxBase-specific functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -103,7 +80,7 @@ bool WXDLLEXPORT wxInitialize()
return FALSE; return FALSE;
} }
wxTheApp = new wxConsoleApp; wxTheApp = new wxDummyConsoleApp;
if ( !wxTheApp ) if ( !wxTheApp )
{ {

View File

@@ -28,48 +28,29 @@
#pragma hdrstop #pragma hdrstop
#endif #endif
#if wxUSE_LOG
// wxWindows // wxWindows
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/string.h"
#include "wx/intl.h"
#include "wx/app.h" #include "wx/app.h"
#include "wx/intl.h"
#if wxUSE_GUI #include "wx/string.h"
#include "wx/window.h"
#include "wx/msgdlg.h"
#ifdef __WXMSW__
#include "wx/msw/private.h"
#endif
#endif
#endif //WX_PRECOMP #endif //WX_PRECOMP
#include "wx/apptrait.h"
#include "wx/file.h" #include "wx/file.h"
#include "wx/log.h"
#include "wx/msgout.h"
#include "wx/textfile.h" #include "wx/textfile.h"
#include "wx/thread.h"
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/wxchar.h" #include "wx/wxchar.h"
#include "wx/log.h"
#include "wx/thread.h"
#if wxUSE_LOG
// other standard headers // other standard headers
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.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
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// non member functions // non member functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -524,192 +505,6 @@ wxLogStderr::wxLogStderr(FILE *fp)
m_fp = 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)) void wxLogStderr::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
{ {
wxString str; wxString str;
@@ -720,43 +515,18 @@ void wxLogStderr::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
fputc(_T('\n'), m_fp); fputc(_T('\n'), m_fp);
fflush(m_fp); fflush(m_fp);
// under Windows, programs usually don't have stderr at all, so show the // under GUI systems such as Windows or Mac, programs usually don't have
// messages also under debugger (unless it's a console program which does // stderr at all, so show the messages also somewhere else, typically in
// have stderr or unless this is a file logger which doesn't use stderr at // the debugger window so that they go at least somewhere instead of being
// all) // simply lost
#if defined(__WXMSW__) && wxUSE_GUI && !defined(__WXMICROWIN__)
if ( m_fp == stderr ) if ( m_fp == stderr )
{ {
str += wxT("\r\n") ; wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
OutputDebugString(str.c_str()); if ( traits && !traits->HasStderr() )
}
#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 ; wxMessageOutputDebug().Printf(_T("%s"), str.c_str());
} }
#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; size_t wxLog::ms_suspendCount = 0;
#if wxUSE_GUI
const wxChar *wxLog::ms_timestamp = wxT("%X"); // time only, no date const wxChar *wxLog::ms_timestamp = wxT("%X"); // time only, no date
#else
const wxChar *wxLog::ms_timestamp = NULL; // save space
#endif
wxTraceMask wxLog::ms_ulTraceMask = (wxTraceMask)0; wxTraceMask wxLog::ms_ulTraceMask = (wxTraceMask)0;
wxArrayString wxLog::ms_aTraceMasks; wxArrayString wxLog::ms_aTraceMasks;
@@ -991,4 +757,3 @@ const wxChar *wxSysErrorMsg(unsigned long nErrCode)
#endif // wxUSE_LOG #endif // wxUSE_LOG
// vi:sts=4:sw=4:et

View File

@@ -48,6 +48,12 @@
// implementation // implementation
// =========================================================================== // ===========================================================================
#ifdef __WXBASE__
// ----------------------------------------------------------------------------
// wxMessageOutput
// ----------------------------------------------------------------------------
wxMessageOutput* wxMessageOutput::ms_msgOut = 0; wxMessageOutput* wxMessageOutput::ms_msgOut = 0;
wxMessageOutput* wxMessageOutput::Get() wxMessageOutput* wxMessageOutput::Get()
@@ -83,6 +89,64 @@ void wxMessageOutputStderr::Printf(const wxChar* format, ...)
fprintf(stderr, "%s", (const char*) out.mb_str()); 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 // wxMessageOutputMessageBox
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -112,21 +176,3 @@ void wxMessageOutputMessageBox::Printf(const wxChar* format, ...)
#endif // wxUSE_GUI #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());
}

View File

@@ -27,6 +27,7 @@
#if wxUSE_SOCKETS #if wxUSE_SOCKETS
#include "wx/app.h" #include "wx/app.h"
#include "wx/apptrait.h"
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/object.h" #include "wx/object.h"
#include "wx/string.h" #include "wx/string.h"
@@ -37,10 +38,6 @@
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/event.h" #include "wx/event.h"
#if wxUSE_GUI
#include "wx/gdicmn.h" // for wxPendingDelete
#endif // wxUSE_GUI
#include "wx/sckaddr.h" #include "wx/sckaddr.h"
#include "wx/socket.h" #include "wx/socket.h"
@@ -51,16 +48,13 @@
// discard buffer // discard buffer
#define MAX_DISCARD_SIZE (10 * 1024) #define MAX_DISCARD_SIZE (10 * 1024)
// what to do within waits: in wxBase we don't do anything as we don't have // what to do within waits: we have 2 cases: from the main thread itself we
// the event loop anyhow (for now). In GUI apps we have 2 cases: from the main // have to call wxYield() to let the events (including the GUI events and the
// thread itself we have to call wxYield() to let the events (including the // low-level (not wxWindows) events from GSocket) be processed. From another
// GUI events and the low-level (not wxWindows) events from GSocket) be // thread it is enough to just call wxThread::Yield() which will give away the
// processed. From another thread it is enough to just call wxThread::Yield() // rest of our time slice: the explanation is that the events will be processed
// which will give away the rest of our time slice: the explanation is that // by the main thread anyhow, without calling wxYield(), but we don't want to
// the events will be processed by the main thread anyhow, without calling // eat the CPU time uselessly while sitting in the loop waiting for the data
// 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 #if wxUSE_THREADS
#define PROCESS_EVENTS() \ #define PROCESS_EVENTS() \
{ \ { \
@@ -72,9 +66,6 @@
#else // !wxUSE_THREADS #else // !wxUSE_THREADS
#define PROCESS_EVENTS() wxYield() #define PROCESS_EVENTS() wxYield()
#endif // wxUSE_THREADS/!wxUSE_THREADS #endif // wxUSE_THREADS/!wxUSE_THREADS
#else // !wxUSE_GUI
#define PROCESS_EVENTS()
#endif // wxUSE_GUI/!wxUSE_GUI
#define wxTRACE_Socket _T("wxSocket") #define wxTRACE_Socket _T("wxSocket")
@@ -213,9 +204,9 @@ wxSocketBase::~wxSocketBase()
{ {
// Just in case the app called Destroy() *and* then deleted // Just in case the app called Destroy() *and* then deleted
// the socket immediately: don't leave dangling pointers. // the socket immediately: don't leave dangling pointers.
#if wxUSE_GUI wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
wxPendingDelete.DeleteObject(this); if ( traits )
#endif traits->RemoveFromPendingDelete(this);
// Shutdown and close the socket // Shutdown and close the socket
if (!m_beingDeleted) if (!m_beingDeleted)
@@ -243,12 +234,18 @@ bool wxSocketBase::Destroy()
// Supress events from now on // Supress events from now on
Notify(FALSE); Notify(FALSE);
#if wxUSE_GUI // schedule this object for deletion
if ( !wxPendingDelete.Member(this) ) wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
wxPendingDelete.Append(this); if ( traits )
#else {
// 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; delete this;
#endif }
return TRUE; return TRUE;
} }

344
src/common/stopwatch.cpp Normal file
View 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

View File

@@ -1,12 +1,8 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: common/timercmn.cpp // Name: common/timercmn.cpp
// Purpose: Common timer implementation // Purpose: wxTimerBase implementation
// Author: // Author: Julian Smart, Guillermo Rodriguez, Vadim Zeitlin
// Original version by Julian Smart // Modified by: VZ: extracted all non-wxTimer stuff in stopwatch.cpp (20.06.03)
// 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: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
@@ -33,88 +29,21 @@
#pragma hdrstop #pragma hdrstop
#endif #endif
#if wxUSE_TIMER
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/intl.h"
#include "wx/log.h"
#include "wx/thread.h"
#endif #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 // wxWin macros
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if wxUSE_GUI && wxUSE_TIMER
IMPLEMENT_DYNAMIC_CLASS(wxTimerEvent, wxEvent) 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
// ============================================================================ // ============================================================================
// implementation // wxTimerBase implementation
// ============================================================================ // ============================================================================
// ----------------------------------------------------------------------------
// wxTimerBase
// ----------------------------------------------------------------------------
#if wxUSE_GUI && wxUSE_TIMER
wxTimerBase::~wxTimerBase() wxTimerBase::~wxTimerBase()
{ {
// this destructor is required for Darwin // this destructor is required for Darwin
@@ -157,252 +86,5 @@ bool wxTimerBase::Start(int milliseconds, bool oneShot)
return TRUE; return TRUE;
} }
#endif // wxUSE_GUI #endif // wxUSE_TIMER
// ----------------------------------------------------------------------------
// 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

View File

@@ -92,15 +92,6 @@ extern bool g_isIdle;
void wxapp_install_idle_handler(); void wxapp_install_idle_handler();
//-----------------------------------------------------------------------------
// wxExit
//-----------------------------------------------------------------------------
void wxExit()
{
gtk_main_quit();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxYield // wxYield
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -168,20 +159,15 @@ bool wxApp::Yield(bool onlyIfNeeded)
// wxWakeUpIdle // wxWakeUpIdle
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static bool gs_WakeUpIdle = false; void wxApp::WakeUpIdle()
void wxWakeUpIdle()
{ {
#if wxUSE_THREADS #if wxUSE_THREADS
if (!wxThread::IsMain()) if (!wxThread::IsMain())
wxMutexGuiEnter(); wxMutexGuiEnter();
#endif #endif
if (g_isIdle) { if (g_isIdle)
gs_WakeUpIdle = true;
wxapp_install_idle_handler(); wxapp_install_idle_handler();
gs_WakeUpIdle = false;
}
#if wxUSE_THREADS #if wxUSE_THREADS
if (!wxThread::IsMain()) if (!wxThread::IsMain())
@@ -660,6 +646,13 @@ int wxApp::MainLoop()
return 0; 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() void wxApp::ExitMainLoop()
{ {
if (gtk_main_level() > 0) if (gtk_main_level() > 0)

View File

@@ -92,15 +92,6 @@ extern bool g_isIdle;
void wxapp_install_idle_handler(); void wxapp_install_idle_handler();
//-----------------------------------------------------------------------------
// wxExit
//-----------------------------------------------------------------------------
void wxExit()
{
gtk_main_quit();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxYield // wxYield
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -168,20 +159,15 @@ bool wxApp::Yield(bool onlyIfNeeded)
// wxWakeUpIdle // wxWakeUpIdle
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static bool gs_WakeUpIdle = false; void wxApp::WakeUpIdle()
void wxWakeUpIdle()
{ {
#if wxUSE_THREADS #if wxUSE_THREADS
if (!wxThread::IsMain()) if (!wxThread::IsMain())
wxMutexGuiEnter(); wxMutexGuiEnter();
#endif #endif
if (g_isIdle) { if (g_isIdle)
gs_WakeUpIdle = true;
wxapp_install_idle_handler(); wxapp_install_idle_handler();
gs_WakeUpIdle = false;
}
#if wxUSE_THREADS #if wxUSE_THREADS
if (!wxThread::IsMain()) if (!wxThread::IsMain())
@@ -660,6 +646,13 @@ int wxApp::MainLoop()
return 0; 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() void wxApp::ExitMainLoop()
{ {
if (gtk_main_level() > 0) if (gtk_main_level() > 0)

View File

@@ -1226,7 +1226,7 @@ void wxApp::OnIdle(wxIdleEvent& event)
wxMenuBar::MacGetCommonMenuBar()->MacInstallMenuBar(); wxMenuBar::MacGetCommonMenuBar()->MacInstallMenuBar();
} }
void wxWakeUpIdle() void wxApp::WakeUpIdle()
{ {
wxMacWakeUp() ; wxMacWakeUp() ;
} }
@@ -1289,10 +1289,8 @@ void wxApp::DeletePendingObjects()
} }
} }
void wxExit() void wxApp::Exit()
{ {
wxLogError(_("Fatal error: exiting"));
wxApp::CleanUp(); wxApp::CleanUp();
::ExitToShell() ; ::ExitToShell() ;
} }

View File

@@ -1226,7 +1226,7 @@ void wxApp::OnIdle(wxIdleEvent& event)
wxMenuBar::MacGetCommonMenuBar()->MacInstallMenuBar(); wxMenuBar::MacGetCommonMenuBar()->MacInstallMenuBar();
} }
void wxWakeUpIdle() void wxApp::WakeUpIdle()
{ {
wxMacWakeUp() ; wxMacWakeUp() ;
} }
@@ -1289,10 +1289,8 @@ void wxApp::DeletePendingObjects()
} }
} }
void wxExit() void wxApp::Exit()
{ {
wxLogError(_("Fatal error: exiting"));
wxApp::CleanUp(); wxApp::CleanUp();
::ExitToShell() ; ::ExitToShell() ;
} }

View File

@@ -45,11 +45,7 @@ wxApp *wxTheApp = NULL;
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL; wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
//----------------------------------------------------------------------------- void wxApp::Exit()
// wxExit
//-----------------------------------------------------------------------------
void wxExit()
{ {
MGL_exit(); MGL_exit();
exit(0); exit(0);
@@ -108,14 +104,15 @@ bool wxApp::Yield(bool onlyIfNeeded)
// wxWakeUpIdle // wxWakeUpIdle
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void wxWakeUpIdle() void wxApp::WakeUpIdle()
{ {
#if wxUSE_THREADS #if wxUSE_THREADS
if (!wxThread::IsMain()) if (!wxThread::IsMain())
wxMutexGuiEnter(); wxMutexGuiEnter();
#endif #endif
while (wxTheApp->ProcessIdle()) {} while (wxTheApp->ProcessIdle())
;
#if wxUSE_THREADS #if wxUSE_THREADS
if (!wxThread::IsMain()) if (!wxThread::IsMain())

View File

@@ -161,6 +161,13 @@ void wxApp::CleanUp()
delete wxLog::SetActiveTarget(NULL); delete wxLog::SetActiveTarget(NULL);
} }
void wxApp::Exit()
{
wxApp::CleanUp();
wxAppConsole::Exit();
}
// ============================================================================ // ============================================================================
// wxEntry* // wxEntry*
// ============================================================================ // ============================================================================
@@ -593,21 +600,6 @@ void wxApp::SetTopLevelWidget(WXDisplay* display, WXWidget widget)
(*m_perDisplayData)[display].m_topLevelWidget = (Widget)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 // Yield to other processes
bool wxApp::Yield(bool onlyIfNeeded) bool wxApp::Yield(bool onlyIfNeeded)

View File

@@ -463,7 +463,7 @@ static void wxBreakDispatch()
write( idleFds[1], &dummy, 1 ); write( idleFds[1], &dummy, 1 );
} }
void wxWakeUpIdle() void wxApp::WakeUpIdle()
{ {
::wxBreakDispatch(); ::wxBreakDispatch();
} }

View File

@@ -48,6 +48,7 @@
#include "wx/log.h" #include "wx/log.h"
#endif #endif
#include "wx/apptrait.h"
#include "wx/cmdline.h" #include "wx/cmdline.h"
#include "wx/filename.h" #include "wx/filename.h"
#include "wx/module.h" #include "wx/module.h"
@@ -130,7 +131,6 @@ extern void wxSetKeyboardHook(bool doIt);
#endif #endif
MSG s_currentMsg; MSG s_currentMsg;
wxApp *wxTheApp = NULL;
// NB: all "NoRedraw" classes must have the same names as the "normal" classes // NB: all "NoRedraw" classes must have the same names as the "normal" classes
// with NR suffix - wxWindow::MSWCreate() supposes this // with NR suffix - wxWindow::MSWCreate() supposes this
@@ -168,11 +168,92 @@ LRESULT WXDLLEXPORT APIENTRY wxWndProc(HWND, UINT, WPARAM, LPARAM);
#endif #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) IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
@@ -799,8 +880,6 @@ int wxEntry(WXHINSTANCE hInstance)
//// Static member initialization //// Static member initialization
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
wxApp::wxApp() wxApp::wxApp()
{ {
argc = 0; argc = 0;
@@ -1146,6 +1225,23 @@ bool wxApp::SendIdleEvents(wxWindow* win)
return needMore; 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() void wxApp::DeletePendingObjects()
{ {
wxNode *node = wxPendingDelete.GetFirst(); wxNode *node = wxPendingDelete.GetFirst();
@@ -1295,19 +1391,6 @@ int wxApp::GetComCtl32Version()
#endif #endif
} }
void wxExit()
{
if ( wxTheApp )
{
wxTheApp->ExitMainLoop();
}
else
{
// what else can we do?
exit(-1);
}
}
// Yield to incoming messages // Yield to incoming messages
bool wxApp::Yield(bool onlyIfNeeded) bool wxApp::Yield(bool onlyIfNeeded)
@@ -1375,27 +1458,6 @@ bool wxHandleFatalExceptions(bool doit)
#endif #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 // For some reason, with MSVC++ 1.5, WinMain isn't linked in properly

61
src/msw/basemsw.cpp Normal file
View 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;
}

View File

@@ -118,83 +118,10 @@ bool wxGetNativeFontEncoding(wxFontEncoding encoding,
encoding = wxFont::GetDefaultEncoding(); encoding = wxFont::GetDefaultEncoding();
} }
switch ( encoding ) extern long wxEncodingToCharset(wxFontEncoding encoding);
{ info->charset = wxEncodingToCharset(encoding);
// although this function is supposed to return an exact match, do do if ( info->charset == -1 )
// 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; return FALSE;
}
info->encoding = encoding; info->encoding = encoding;

View File

@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: msw/main.cpp // Name: msw/main.cpp
// Purpose: Main/DllMain // Purpose: WinMain/DllMain
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
// Created: 04/01/98 // Created: 04/01/98
@@ -33,85 +33,74 @@
#include "wx/msw/private.h" #include "wx/msw/private.h"
// Don't implement WinMain if we're building an MFC/wxWindows // Don't implement WinMain if we're building an MFC/wxWindows hybrid app.
// hybrid app.
#if wxUSE_MFC && !defined(NOMAIN) #if wxUSE_MFC && !defined(NOMAIN)
#define NOMAIN 1 #define NOMAIN 1
#endif #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 // from src/msw/app.cpp
extern void WXDLLEXPORT wxEntryCleanup(); 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 // 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 // a Netscape plugin or if we're writing a console application
#if wxUSE_GUI && !defined(NOMAIN) #if wxUSE_GUI && !defined(NOMAIN)
// NT defines APIENTRY, 3.x not extern "C"
#if !defined(APIENTRY) {
#define APIENTRY FAR PASCAL
#endif
///////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------
// WinMain // WinMain
// ----------------------------------------------------------------------------
// Note that WinMain is also defined in dummy.obj, which is linked to // Note that WinMain is also defined in dummy.obj, which is linked to
// an application that is using the DLL version of wxWindows. // an application that is using the DLL version of wxWindows.
#if !defined(_WINDLL) #if !defined(_WINDLL)
#if defined(__WXMICROWIN__)
#define HINSTANCE HANDLE
extern "C"
#endif
int PASCAL WinMain(HINSTANCE hInstance, int PASCAL WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, LPSTR lpCmdLine,
int nCmdShow) int nCmdShow)
{ {
return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance, return wxEntry((WXHINSTANCE) hInstance,
lpCmdLine, nCmdShow); (WXHINSTANCE) hPrevInstance,
lpCmdLine,
nCmdShow);
} }
#endif // !defined(_WINDLL) #else // _WINDLL
/////////////////////////////////////////////////////////////////////////////////
// DllMain
#if defined(_WINDLL)
// DLL entry point // DLL entry point
extern "C" BOOL WINAPI
#ifdef __BORLANDC__ DllMain(HANDLE hModule, DWORD fdwReason, LPVOID WXUNUSED(lpReserved))
// 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
{ {
#ifndef WXMAKINGDLL
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// Only call wxEntry if the application itself is part of the DLL. // Only call wxEntry if the application itself is part of the DLL.
// If only the wxWindows library is in the DLL, then the // If only the wxWindows library is in the DLL, then the
// initialisation will be called when the application implicitly // initialisation will be called when the application implicitly
// calls WinMain. // calls WinMain.
#ifndef WXMAKINGDLL
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
return wxEntry((WXHINSTANCE) hModule); return wxEntry((WXHINSTANCE) hModule);
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
@@ -124,18 +113,24 @@ BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
(void)hModule; (void)hModule;
(void)fdwReason; (void)fdwReason;
#endif // !WXMAKINGDLL #endif // !WXMAKINGDLL
(void)lpReserved;
return TRUE; return TRUE;
} }
#endif // _WINDLL #endif // _WINDLL/!_WINDLL
} // extern "C"
#endif // !NOMAIN #endif // !NOMAIN
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// global functions // global HINSTANCE
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifdef __WXBASE__
HINSTANCE wxhInstance = 0;
HINSTANCE wxGetInstance() HINSTANCE wxGetInstance()
{ {
return wxhInstance; return wxhInstance;
@@ -146,3 +141,5 @@ void wxSetInstance(HINSTANCE hInst)
wxhInstance = hInst; wxhInstance = hInst;
} }
#endif // __WXBASE__

View File

@@ -131,6 +131,8 @@ WXDLLEXPORT int wxMSLU_GetSaveFileNameW(void *ofn)
// Missing libc file manipulation functions in Win9x // Missing libc file manipulation functions in Win9x
//------------------------------------------------------------------------ //------------------------------------------------------------------------
#ifdef __WXBASE__
WXDLLEXPORT int wxMSLU__trename(const wxChar *oldname, const wxChar *newname) WXDLLEXPORT int wxMSLU__trename(const wxChar *oldname, const wxChar *newname)
{ {
if ( wxUsingUnicowsDll() ) if ( wxUsingUnicowsDll() )
@@ -196,6 +198,8 @@ WXDLLEXPORT int wxMSLU__wstat(const wxChar *name, struct _stat *buffer)
return _wstat(name, buffer); return _wstat(name, buffer);
} }
#endif #endif // compilers having wopen() &c
#endif // __WXBASE__
#endif // wxUSE_UNICODE_MSLU #endif // wxUSE_UNICODE_MSLU

View File

@@ -26,11 +26,12 @@
#endif #endif
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
# include "wx/wx.h"
#endif #endif
#if wxUSE_THREADS #if wxUSE_THREADS
#include "wx/apptrait.h"
#include "wx/msw/private.h" #include "wx/msw/private.h"
#include "wx/msw/missing.h" #include "wx/msw/missing.h"
@@ -1000,10 +1001,11 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
m_internal->Cancel(); m_internal->Cancel();
} }
#if wxUSE_GUI
// we can't just wait for the thread to terminate because it might be // 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 // calling some GUI functions and so it will never terminate before we
// process the Windows messages that result from these functions // 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 DWORD result = 0; // suppress warnings from broken compilers
do do
{ {
@@ -1041,29 +1043,24 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
case WAIT_OBJECT_0 + 1: case WAIT_OBJECT_0 + 1:
// new message arrived, process it // new message arrived, process it
if ( !wxTheApp->DoMessage() ) {
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits()
: NULL;
if ( traits && !traits->DoMessageFromThreadWait() )
{ {
// WM_QUIT received: kill the thread // WM_QUIT received: kill the thread
Kill(); Kill();
return wxTHREAD_KILLED; return wxTHREAD_KILLED;
} }
}
break; break;
default: default:
wxFAIL_MSG(wxT("unexpected result of MsgWaitForMultipleObject")); wxFAIL_MSG(wxT("unexpected result of MsgWaitForMultipleObject"));
} }
} while ( result != WAIT_OBJECT_0 ); } 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() ) if ( IsMain() )
{ {

View File

@@ -17,10 +17,6 @@
// headers // headers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifdef __GNUG__
// #pragma implementation "utils.h" // Note: this is done in utilscmn.cpp now.
#endif
// For compilers that support precompilation, includes "wx.h". // For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h" #include "wx/wxprec.h"
@@ -33,9 +29,6 @@
#include "wx/app.h" #include "wx/app.h"
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/log.h" #include "wx/log.h"
#if wxUSE_GUI
#include "wx/cursor.h"
#endif
#endif //WX_PRECOMP #endif //WX_PRECOMP
#include "wx/msw/private.h" // includes <windows.h> #include "wx/msw/private.h" // includes <windows.h>
@@ -94,32 +87,6 @@
#endif #endif
#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 // constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -134,8 +101,6 @@ static const wxChar eHOSTNAME[] = wxT("HostName");
static const wxChar eUSERID[] = wxT("UserId"); static const wxChar eUSERID[] = wxT("UserId");
#endif // !Win32 #endif // !Win32
#ifndef __WXMICROWIN__
// ============================================================================ // ============================================================================
// implementation // implementation
// ============================================================================ // ============================================================================
@@ -1073,77 +1038,6 @@ int wxGetOsVersion(int *majorVsn, int *minorVsn)
// sleep functions // 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) void wxUsleep(unsigned long milliseconds)
{ {
::Sleep(milliseconds); ::Sleep(milliseconds);
@@ -1154,497 +1048,90 @@ void wxSleep(int nSecs)
wxUsleep(1000*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 extern long wxEncodingToCharset(wxFontEncoding encoding)
// Output a debug mess., in a system dependent fashion.
#ifndef __WXMICROWIN__
void wxDebugMsg(const wxChar *fmt ...)
{ {
va_list ap; switch ( encoding )
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); // although this function is supposed to return an exact match, do do
if (MessageBox(NULL, (LPCTSTR)wxBuffer, (LPCTSTR)WXSTRINGCAST title, // some mappings here for the most common case of "standard" encoding
MB_ICONSTOP | MB_YESNO) == IDNO) case wxFONTENCODING_SYSTEM:
wxExit(); return DEFAULT_CHARSET;
}
// Fatal error: pop up message box and abort case wxFONTENCODING_ISO8859_1:
void wxFatalError(const wxString& msg, const wxString& title) case wxFONTENCODING_ISO8859_15:
{ case wxFONTENCODING_CP1252:
wxSprintf(wxBuffer, wxT("%s: %s"), WXSTRINGCAST title, WXSTRINGCAST msg); return ANSI_CHARSET;
FatalAppExit(0, (LPCTSTR)wxBuffer);
}
#endif // __WXMICROWIN__
#endif // WXWIN_COMPATIBILITY_2_2 #if !defined(__WXMICROWIN__)
// The following four fonts are multi-byte charsets
case wxFONTENCODING_CP932:
return SHIFTJIS_CHARSET;
#if wxUSE_GUI case wxFONTENCODING_CP936:
return GB2312_CHARSET;
// ---------------------------------------------------------------------------- case wxFONTENCODING_CP949:
// functions to work with .INI files return HANGUL_CHARSET;
// ----------------------------------------------------------------------------
// Reading and writing resources (eg WIN.INI, .Xdefaults) case wxFONTENCODING_CP950:
#if wxUSE_RESOURCES return CHINESEBIG5_CHARSET;
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) // The rest are single byte encodings
{ case wxFONTENCODING_CP1250:
wxString buf; return EASTEUROPE_CHARSET;
buf.Printf(wxT("%.4f"), value);
return wxWriteResource(section, entry, buf, file); case wxFONTENCODING_CP1251:
} return RUSSIAN_CHARSET;
bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file) case wxFONTENCODING_CP1253:
{ return GREEK_CHARSET;
wxString buf;
buf.Printf(wxT("%ld"), value);
return wxWriteResource(section, entry, buf, file); case wxFONTENCODING_CP1254:
} return TURKISH_CHARSET;
bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file) case wxFONTENCODING_CP1255:
{ return HEBREW_CHARSET;
wxString buf;
buf.Printf(wxT("%d"), value);
return wxWriteResource(section, entry, buf, file); case wxFONTENCODING_CP1256:
} return ARABIC_CHARSET;
bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file) case wxFONTENCODING_CP1257:
{ return BALTIC_CHARSET;
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) case wxFONTENCODING_CP874:
{ return THAI_CHARSET;
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__ #endif // !__WXMICROWIN__
return str; case wxFONTENCODING_CP437:
return OEM_CHARSET;
} }
WXWORD WXDLLEXPORT wxGetWindowId(WXHWND hWnd) // no way to translate this encoding into a Windows charset
{ return -1;
#ifndef __WIN32__
return (WXWORD)GetWindowWord((HWND)hWnd, GWW_ID);
#else // Win32
return (WXWORD)GetWindowLong((HWND)hWnd, GWL_ID);
#endif // Win16/32
} }
// ---------------------------------------------------------------------------- // we have 2 versions of wxCharsetToCodepage(): the old one which directly
// Metafile helpers // 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
extern void PixelToHIMETRIC(LONG *x, LONG *y) #if wxUSE_FONTMAP
{
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__)
#include "wx/fontmap.h" #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) extern long wxEncodingToCodepage(wxFontEncoding encoding)
{ {
// translate encoding into the Windows CHARSET // translate encoding into the Windows CHARSET
wxNativeEncodingInfo natveEncInfo; long charset = wxEncodingToCharset(encoding);
if ( !wxGetNativeFontEncoding(encoding, &natveEncInfo) ) if ( charset == -1 )
return -1; return -1;
// translate CHARSET to code page // translate CHARSET to code page
CHARSETINFO csetInfo; CHARSETINFO csetInfo;
if ( !::TranslateCharsetInfo((DWORD *)(DWORD)natveEncInfo.charset, if ( !::TranslateCharsetInfo((DWORD *)(DWORD)charset,
&csetInfo, &csetInfo,
TCI_SRCCHARSET) ) TCI_SRCCHARSET) )
{ {
@@ -1656,8 +1143,6 @@ extern long wxEncodingToCodepage(wxFontEncoding encoding)
return csetInfo.ciACP; return csetInfo.ciACP;
} }
#if wxUSE_FONTMAP
extern long wxCharsetToCodepage(const wxChar *name) extern long wxCharsetToCodepage(const wxChar *name)
{ {
// first get the font encoding for this charset // first get the font encoding for this charset
@@ -1672,12 +1157,7 @@ extern long wxCharsetToCodepage(const wxChar *name)
return wxEncodingToCodepage(enc); return wxEncodingToCodepage(enc);
} }
#endif // wxUSE_FONTMAP #else // !wxUSE_FONTMAP
#endif // wxUSE_GUI
// include old wxCharsetToCodepage() by OK if needed
#if !wxUSE_GUI || !wxUSE_FONTMAP
#include "wx/msw/registry.h" #include "wx/msw/registry.h"
@@ -1689,13 +1169,16 @@ extern long wxCharsetToCodepage(const wxChar *name)
long CP = -1; long CP = -1;
wxString cn(name);
do {
wxString path(wxT("MIME\\Database\\Charset\\")); wxString path(wxT("MIME\\Database\\Charset\\"));
path += cn; wxString cn(name);
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, // two cases: either there's an AliasForCharset string,
// or there are Codepage and InternetEncoding dwords. // 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 // the Codepage just says which Windows character set to
// use when displaying the data. // use when displaying the data.
if (key.HasValue(wxT("InternetEncoding")) && 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 // no encoding, see if it's an alias
if (!key.HasValue(wxT("AliasForCharset")) || if (!key.HasValue(wxT("AliasForCharset")) ||
!key.QueryValue(wxT("AliasForCharset"), cn)) break; !key.QueryValue(wxT("AliasForCharset"), cn))
} while (1); break;
}
return CP; return CP;
} }
#endif // !wxUSE_GUI || !wxUSE_FONTMAP #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
#endif // Win32

View File

@@ -33,9 +33,6 @@
#include "wx/app.h" #include "wx/app.h"
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/log.h" #include "wx/log.h"
#if wxUSE_GUI // See 'dirty hack' below.
#include "wx/frame.h"
#endif
#endif #endif
#ifdef __WIN32__ #ifdef __WIN32__
@@ -43,6 +40,8 @@
#include "wx/process.h" #include "wx/process.h"
#endif #endif
#include "wx/apptrait.h"
#include "wx/msw/private.h" #include "wx/msw/private.h"
#include <ctype.h> #include <ctype.h>
@@ -594,8 +593,6 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler)
command = cmd; command = cmd;
} }
#if defined(__WIN32__)
// the IO redirection is only supported with wxUSE_STREAMS // the IO redirection is only supported with wxUSE_STREAMS
BOOL redirect = FALSE; BOOL redirect = FALSE;
@@ -854,45 +851,11 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler)
return pi.dwProcessId; 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 // 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;
{
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 // wait until the child process terminates
while ( data->state ) while ( data->state )
@@ -906,48 +869,17 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler)
// real async IO which we don't have for the moment // real async IO which we don't have for the moment
::Sleep(50); ::Sleep(50);
#if wxUSE_GUI // we must process messages or we'd never get wxWM_PROC_TERMINATED
// repaint the GUI traits->AlwaysYield();
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 traits->AfterChildWaitLoop(cookie);
}
// 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
DWORD dwExitCode = data->dwExitCode; DWORD dwExitCode = data->dwExitCode;
delete data; delete data;
// return the exit code // return the exit code
return dwExitCode; 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) long wxExecute(wxChar **argv, int flags, wxProcess *handler)

444
src/msw/utilsgui.cpp Normal file
View 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);
}

View File

@@ -42,46 +42,9 @@
#include "wx/volume.h" #include "wx/volume.h"
#include <shellapi.h> #include <shellapi.h>
#include "wx/msw/missing.h"
#ifndef SHGetFileInfo #ifdef __WXBASE__
#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
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Dynamic library function defs. // Dynamic library function defs.
@@ -128,14 +91,6 @@ static FileInfoMap& GetFileInfoMap()
} }
#define s_fileInfo (GetFileInfoMap()) #define s_fileInfo (GetFileInfoMap())
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Other initialization.
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#if wxUSE_GUI
// already in wx/iconbndl.h
// WX_DEFINE_OBJARRAY(wxIconArray);
#endif
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Local helper functions. // 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. // Purpose: Generate and return a list of all volumes (drives) available.
// Notes: // Notes:
//============================================================================= //=============================================================================
wxArrayString wxFSVolume::GetVolumes(int flagsSet, int flagsUnset) wxArrayString wxFSVolumeBase::GetVolumes(int flagsSet, int flagsUnset)
{ {
InterlockedExchange(&s_cancelSearch, FALSE); // reset 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 // performing the search. This is the only thread-safe function
// provided by the class. // provided by the class.
//============================================================================= //=============================================================================
void wxFSVolume::CancelSearch() void wxFSVolumeBase::CancelSearch()
{ {
InterlockedExchange(&s_cancelSearch, TRUE); InterlockedExchange(&s_cancelSearch, TRUE);
} // CancelSearch } // CancelSearch
@@ -499,7 +454,7 @@ void wxFSVolume::CancelSearch()
// Function: constructor // Function: constructor
// Purpose: default constructor // Purpose: default constructor
//============================================================================= //=============================================================================
wxFSVolume::wxFSVolume() wxFSVolumeBase::wxFSVolumeBase()
{ {
m_isOk = FALSE; m_isOk = FALSE;
} // wxVolume } // wxVolume
@@ -508,7 +463,7 @@ wxFSVolume::wxFSVolume()
// Function: constructor // Function: constructor
// Purpose: constructor that calls Create // Purpose: constructor that calls Create
//============================================================================= //=============================================================================
wxFSVolume::wxFSVolume(const wxString& name) wxFSVolumeBase::wxFSVolumeBase(const wxString& name)
{ {
Create(name); Create(name);
} // wxVolume } // wxVolume
@@ -517,7 +472,7 @@ wxFSVolume::wxFSVolume(const wxString& name)
// Function: Create // Function: Create
// Purpose: Finds, logs in, etc. to the request volume. // Purpose: Finds, logs in, etc. to the request volume.
//============================================================================= //=============================================================================
bool wxFSVolume::Create(const wxString& name) bool wxFSVolumeBase::Create(const wxString& name)
{ {
// assume fail. // assume fail.
m_isOk = FALSE; m_isOk = FALSE;
@@ -535,16 +490,6 @@ bool wxFSVolume::Create(const wxString& name)
} }
m_dispName = fi.szDisplayName; 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. // all tests passed.
return m_isOk = TRUE; return m_isOk = TRUE;
} // Create } // Create
@@ -555,7 +500,7 @@ bool wxFSVolume::Create(const wxString& name)
// Notes: For fixed disks, it must exist. For removable disks, it must also // 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. // be present. For Network Shares, it must also be logged in, etc.
//============================================================================= //=============================================================================
bool wxFSVolume::IsOk() const bool wxFSVolumeBase::IsOk() const
{ {
return m_isOk; return m_isOk;
} // IsOk } // IsOk
@@ -564,7 +509,7 @@ bool wxFSVolume::IsOk() const
// Function: GetKind // Function: GetKind
// Purpose: Return the type of the volume. // Purpose: Return the type of the volume.
//============================================================================= //=============================================================================
wxFSVolumeKind wxFSVolume::GetKind() const wxFSVolumeKind wxFSVolumeBase::GetKind() const
{ {
if (!m_isOk) if (!m_isOk)
return wxFS_VOL_OTHER; return wxFS_VOL_OTHER;
@@ -581,7 +526,7 @@ wxFSVolumeKind wxFSVolume::GetKind() const
// Purpose: Return the caches flags for this volume. // Purpose: Return the caches flags for this volume.
// Notes: - Returns -1 if no flags were cached. // Notes: - Returns -1 if no flags were cached.
//============================================================================= //=============================================================================
int wxFSVolume::GetFlags() const int wxFSVolumeBase::GetFlags() const
{ {
if (!m_isOk) if (!m_isOk)
return -1; return -1;
@@ -593,40 +538,52 @@ int wxFSVolume::GetFlags() const
return itr->second.m_flags; return itr->second.m_flags;
} // GetFlags } // GetFlags
#endif // __WXBASE__
// ============================================================================
// wxFSVolume
// ============================================================================
#if wxUSE_GUI #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 // Function: GetIcon
// Purpose: return the requested icon. // Purpose: return the requested icon.
//============================================================================= //=============================================================================
wxIcon wxFSVolume::GetIcon(wxFSIconType type) const wxIcon wxFSVolume::GetIcon(wxFSIconType type) const
{ {
wxCHECK_MSG(type < (int)m_icons.GetCount(), wxNullIcon, wxCHECK_MSG( type >= 0 && (size_t)type < m_icons.GetCount(), wxNullIcon,
_T("Invalid request for icon type!")); _T("wxFSIconType::GetIcon(): invalid icon index") );
wxCHECK_MSG( type >= 0 && (size_t)type < m_icons.GetCount(),
wxIcon(),
_T("invalid icon index") );
// Load on demand. // Load on demand.
if (m_icons[type].IsNull()) if (m_icons[type].IsNull())
{ {
unsigned flags = 0; UINT flags = SHGFI_ICON;
switch (type) switch (type)
{ {
case wxFS_VOL_ICO_SMALL: case wxFS_VOL_ICO_SMALL:
flags = SHGFI_ICON | SHGFI_SMALLICON; flags |= SHGFI_SMALLICON;
break; break;
case wxFS_VOL_ICO_LARGE: case wxFS_VOL_ICO_LARGE:
flags = SHGFI_ICON | SHGFI_SHELLICONSIZE; flags |= SHGFI_SHELLICONSIZE;
break; break;
case wxFS_VOL_ICO_SEL_SMALL: case wxFS_VOL_ICO_SEL_SMALL:
flags = SHGFI_ICON | SHGFI_SMALLICON | SHGFI_OPENICON; flags |= SHGFI_SMALLICON | SHGFI_OPENICON;
break; break;
case wxFS_VOL_ICO_SEL_LARGE: case wxFS_VOL_ICO_SEL_LARGE:
flags = SHGFI_ICON | SHGFI_SHELLICONSIZE | SHGFI_OPENICON; flags |= SHGFI_SHELLICONSIZE | SHGFI_OPENICON;
break; break;
case wxFS_VOL_ICO_MAX: case wxFS_VOL_ICO_MAX:

View File

@@ -1100,11 +1100,12 @@ void wxApp::OnQueryEndSession(
} }
} // end of wxApp::OnQueryEndSession } // end of wxApp::OnQueryEndSession
void wxExit() void wxApp::Exit()
{ {
wxLogError(_("Fatal error: exiting"));
wxApp::CleanUp(); wxApp::CleanUp();
// VZ: must really exit somehow, insert appropriate OS/2 syscall (FIXME)
wxAppConsole::Exit();
} // end of wxExit } // end of wxExit
// //
@@ -1213,7 +1214,7 @@ void wxApp::RemoveSocketHandler(int handle)
// wxWakeUpIdle // wxWakeUpIdle
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void wxWakeUpIdle() void wxApp::WakeUpIdle()
{ {
// //
// Send the top window a dummy message so idle handler processing will // Send the top window a dummy message so idle handler processing will

108
src/unix/baseunix.cpp Normal file
View 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;
}

View File

@@ -28,6 +28,10 @@
#include "wx/wfstream.h" #include "wx/wfstream.h"
#include "wx/unix/execute.h"
#ifdef __WXBASE__
#if defined( __MWERKS__ ) && defined(__MACH__) #if defined( __MWERKS__ ) && defined(__MACH__)
#define WXWIN_OS_DESCRIPTION "MacOS X" #define WXWIN_OS_DESCRIPTION "MacOS X"
#define HAVE_NANOSLEEP #define HAVE_NANOSLEEP
@@ -60,10 +64,6 @@
#define wxStatfs_t WX_STATFS_T #define wxStatfs_t WX_STATFS_T
#endif #endif
#if wxUSE_GUI
#include "wx/unix/execute.h"
#endif
// SGI signal.h defines signal handler arguments differently depending on // SGI signal.h defines signal handler arguments differently depending on
// whether _LANGUAGE_C_PLUS_PLUS is set or not - do set it // whether _LANGUAGE_C_PLUS_PLUS is set or not - do set it
#if defined(__SGI__) && !defined(_LANGUAGE_C_PLUS_PLUS) #if defined(__SGI__) && !defined(_LANGUAGE_C_PLUS_PLUS)
@@ -75,8 +75,8 @@
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h>
#include <pwd.h> #include <pwd.h>
#include <errno.h> #include <errno.h>
#include <netdb.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 // wxStream classes to support IO redirection in wxExecute
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -428,83 +404,6 @@ bool wxPipeInputStream::CanRead() const
#endif // wxUSE_STREAMS #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 // wxExecute: the real worker function
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -549,10 +448,21 @@ long wxExecute(wxChar **argv,
wxChar **mb_argv = argv; wxChar **mb_argv = argv;
#endif // Unicode/ANSI #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 // create pipes
wxPipe pipeEndProcDetect; if ( !traits->CreateEndProcessPipe(execData) )
if ( !pipeEndProcDetect.Create() )
{ {
wxLogError( _("Failed to execute '%s'\n"), *argv ); wxLogError( _("Failed to execute '%s'\n"), *argv );
@@ -560,7 +470,6 @@ long wxExecute(wxChar **argv,
return ERROR_RETURN_CODE; return ERROR_RETURN_CODE;
} }
#endif // wxUSE_GUI && !(defined(__DARWIN__) && defined(__WXMAC__))
// pipes for inter process communication // pipes for inter process communication
wxPipe pipeIn, // stdin wxPipe pipeIn, // stdin
@@ -611,10 +520,7 @@ long wxExecute(wxChar **argv,
if ( fd == pipeIn[wxPipe::Read] if ( fd == pipeIn[wxPipe::Read]
|| fd == pipeOut[wxPipe::Write] || fd == pipeOut[wxPipe::Write]
|| fd == pipeErr[wxPipe::Write] || fd == pipeErr[wxPipe::Write]
#if wxUSE_GUI && !(defined(__DARWIN__) && defined(__WXMAC__)) || traits->IsWriteFDOfEndProcessPipe(execData, fd) )
|| fd == pipeEndProcDetect[wxPipe::Write]
#endif // wxUSE_GUI && !(defined(__DARWIN__) && defined(__WXMAC__))
)
{ {
// don't close this one, we still need it // don't close this one, we still need it
continue; continue;
@@ -635,12 +541,9 @@ long wxExecute(wxChar **argv,
} }
#endif // !__VMS #endif // !__VMS
#if wxUSE_GUI && !(defined(__DARWIN__) && defined(__WXMAC__))
// reading side can be safely closed but we should keep the write one // reading side can be safely closed but we should keep the write one
// opened // opened
pipeEndProcDetect.Detach(wxPipe::Write); traits->DetachWriteFDOfEndProcessPipe(execData);
pipeEndProcDetect.Close();
#endif // wxUSE_GUI && !(defined(__DARWIN__) && defined(__WXMAC__))
// redirect stdin, stdout and stderr // redirect stdin, stdout and stderr
if ( pipeIn.IsOk() ) if ( pipeIn.IsOk() )
@@ -707,6 +610,9 @@ long wxExecute(wxChar **argv,
bufOut.Init(outStream); bufOut.Init(outStream);
bufErr.Init(errStream); bufErr.Init(errStream);
execData.bufOut = &bufOut;
execData.bufErr = &bufErr;
#endif // wxUSE_STREAMS #endif // wxUSE_STREAMS
} }
@@ -717,85 +623,7 @@ long wxExecute(wxChar **argv,
pipeErr.Close(); pipeErr.Close();
} }
#if wxUSE_GUI && !defined(__WXMICROWIN__) return traits->WaitForChild(execData);
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 ERROR_RETURN_CODE; return ERROR_RETURN_CODE;
@@ -986,7 +814,9 @@ bool wxGetUserName(wxChar *buf, int sz)
return FALSE; return FALSE;
} }
// this function is in mac/utils.cpp for wxMac
#ifndef __WXMAC__ #ifndef __WXMAC__
wxString wxGetOsDescription() wxString wxGetOsDescription()
{ {
#ifndef WXWIN_OS_DESCRIPTION #ifndef WXWIN_OS_DESCRIPTION
@@ -995,33 +825,20 @@ wxString wxGetOsDescription()
return wxString::FromAscii( WXWIN_OS_DESCRIPTION ); return wxString::FromAscii( WXWIN_OS_DESCRIPTION );
#endif #endif
} }
#endif
// this function returns the GUI toolkit version in GUI programs, but OS #endif // !__WXMAC__
// version in non-GUI ones
#if !wxUSE_GUI
int wxGetOsVersion(int *majorVsn, int *minorVsn) int wxGetOsVersion(int *verMaj, int *verMin)
{ {
int major, minor; // we want this function to work even if there is no wxApp
char name[256]; wxConsoleAppTraits traitsConsole;
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
if ( ! traits )
traits = &traitsConsole;
if ( sscanf(WXWIN_OS_DESCRIPTION, "%s %d.%d", name, &major, &minor) != 3 ) return traits->GetOSVersion(verMaj, verMin);
{
// unreckognized uname string format
major = minor = -1;
} }
if ( majorVsn )
*majorVsn = major;
if ( minorVsn )
*minorVsn = minor;
return wxUNIX;
}
#endif // !wxUSE_GUI
unsigned long wxGetProcessId() unsigned long wxGetProcessId()
{ {
return (unsigned long)getpid(); return (unsigned long)getpid();
@@ -1243,3 +1060,147 @@ void wxFatalError( const wxString &msg, const wxString &title )
#endif // WXWIN_COMPATIBILITY_2_2 #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

View File

@@ -248,7 +248,7 @@ LIB32=link.exe -lib
# PROP Default_Filter "" # PROP Default_Filter ""
# Begin Source File # Begin Source File
SOURCE=.\common\appcmn.cpp SOURCE=.\common\appbase.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -328,7 +328,7 @@ SOURCE=.\common\filesys.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\common\fontmap.cpp SOURCE=.\common\fmapbase.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -436,6 +436,10 @@ SOURCE=.\common\socket.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\common\stopwatch.cpp
# End Source File
# Begin Source File
SOURCE=.\common\strconv.cpp SOURCE=.\common\strconv.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -460,10 +464,6 @@ SOURCE=.\common\textfile.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\common\timercmn.cpp
# End Source File
# Begin Source File
SOURCE=.\common\tokenzr.cpp SOURCE=.\common\tokenzr.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -525,6 +525,10 @@ SOURCE=.\msw\dummy.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\msw\console.cpp
# End Source File
# Begin Source File
SOURCE=.\msw\dde.cpp SOURCE=.\msw\dde.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -541,6 +545,10 @@ SOURCE=.\msw\mimetype.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\msw\mslu.cpp
# End Source File
# Begin Source File
SOURCE=.\msw\regconf.cpp SOURCE=.\msw\regconf.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -664,6 +672,10 @@ SOURCE=..\include\wx\app.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\include\wx\apptrait.h
# End Source File
# Begin Source File
SOURCE=..\include\wx\buffer.h SOURCE=..\include\wx\buffer.h
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -780,6 +792,10 @@ SOURCE=..\include\wx\filesys.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\include\wx\fmappriv.h
# End Source File
# Begin Source File
SOURCE=..\include\wx\fontenc.h SOURCE=..\include\wx\fontenc.h
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -1013,6 +1029,14 @@ SOURCE=..\include\wx\zstream.h
# PROP Default_Filter "" # PROP Default_Filter ""
# Begin 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\dde.h SOURCE=..\include\wx\msw\dde.h
# End Source File # End Source File
# Begin Source File # Begin Source File

2805
src/wxMSW.dsp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -2,8 +2,8 @@
# Microsoft Developer Studio Generated Build File, Format Version 6.00 # Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT ** # ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=wxWindows - Win32 Debug CFG=wxWindows - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE, !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 AllowPerConfigDependencies 0
# PROP Scc_ProjName "" # PROP Scc_ProjName ""
# PROP Scc_LocalPath "" # PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "wxWindows - Win32 Release Unicode DLL" !IF "$(CFG)" == "wxWindows - Win32 Release Unicode DLL"
@@ -48,10 +46,13 @@ RSC=rc.exe
# PROP Intermediate_Dir "../ReleaseUnicodeDll" # PROP Intermediate_Dir "../ReleaseUnicodeDll"
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # 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 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 BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /i "../include" /d "NDEBUG" # ADD RSC /l 0x409 /i "../include" /d "NDEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
@@ -74,17 +75,20 @@ LINK32=link.exe
# PROP Intermediate_Dir "../DebugUnicodeDll" # PROP Intermediate_Dir "../DebugUnicodeDll"
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # 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 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 BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /i "../include" /d "_DEBUG" # ADD RSC /l 0x409 /i "../include" /d "_DEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
# ADD BASE BSC32 /nologo # ADD BASE BSC32 /nologo
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe 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" # 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" !ELSEIF "$(CFG)" == "wxWindows - Win32 Release Unicode"
@@ -99,8 +103,10 @@ LINK32=link.exe
# PROP Output_Dir "../lib" # PROP Output_Dir "../lib"
# PROP Intermediate_Dir "../ReleaseUnicode" # PROP Intermediate_Dir "../ReleaseUnicode"
# PROP Target_Dir "" # PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c # 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 BASE RSC /l 0x409
# ADD RSC /l 0x409 # ADD RSC /l 0x409
BSC32=bscmake.exe BSC32=bscmake.exe
@@ -122,8 +128,10 @@ LIB32=link.exe -lib
# PROP Output_Dir "../lib" # PROP Output_Dir "../lib"
# PROP Intermediate_Dir "../DebugUnicode" # PROP Intermediate_Dir "../DebugUnicode"
# PROP Target_Dir "" # PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c # 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 BASE RSC /l 0x409
# ADD RSC /l 0x409 # ADD RSC /l 0x409
BSC32=bscmake.exe BSC32=bscmake.exe
@@ -146,10 +154,13 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "../ReleaseDll" # PROP Intermediate_Dir "../ReleaseDll"
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # 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 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 BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /i "../include" /d "NDEBUG" # ADD RSC /l 0x409 /i "../include" /d "NDEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
@@ -172,17 +183,20 @@ LINK32=link.exe
# PROP Intermediate_Dir "../DebugDll" # PROP Intermediate_Dir "../DebugDll"
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # 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 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 BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /i "../include" /d "_DEBUG" # ADD RSC /l 0x409 /i "../include" /d "_DEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
# ADD BASE BSC32 /nologo # ADD BASE BSC32 /nologo
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe 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" # 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" !ELSEIF "$(CFG)" == "wxWindows - Win32 Release"
@@ -197,8 +211,10 @@ LINK32=link.exe
# PROP Output_Dir "../lib" # PROP Output_Dir "../lib"
# PROP Intermediate_Dir "../Release" # PROP Intermediate_Dir "../Release"
# PROP Target_Dir "" # PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c # 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 BASE RSC /l 0x409
# ADD RSC /l 0x409 # ADD RSC /l 0x409
BSC32=bscmake.exe BSC32=bscmake.exe
@@ -220,8 +236,10 @@ LIB32=link.exe -lib
# PROP Output_Dir "../lib" # PROP Output_Dir "../lib"
# PROP Intermediate_Dir "../Debug" # PROP Intermediate_Dir "../Debug"
# PROP Target_Dir "" # PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c # 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 BASE RSC /l 0x409
# ADD RSC /l 0x409 # ADD RSC /l 0x409
BSC32=bscmake.exe BSC32=bscmake.exe
@@ -252,6 +270,10 @@ SOURCE=.\common\accesscmn.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\common\appbase.cpp
# End Source File
# Begin Source File
SOURCE=.\common\appcmn.cpp SOURCE=.\common\appcmn.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -392,6 +414,11 @@ SOURCE=.\common\event.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\common\extended.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=.\common\fddlgcmn.cpp SOURCE=.\common\fddlgcmn.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -424,6 +451,10 @@ SOURCE=.\common\fldlgcmn.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\common\fmapbase.cpp
# End Source File
# Begin Source File
SOURCE=.\common\fontcmn.cpp SOURCE=.\common\fontcmn.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -668,6 +699,10 @@ SOURCE=.\common\statbar.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\common\stopwatch.cpp
# End Source File
# Begin Source File
SOURCE=.\common\strconv.cpp SOURCE=.\common\strconv.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -724,6 +759,11 @@ SOURCE=.\common\txtstrm.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\common\unzip.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=.\common\url.cpp SOURCE=.\common\url.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -770,18 +810,6 @@ SOURCE=.\common\zipstrm.cpp
SOURCE=.\common\zstream.cpp SOURCE=.\common\zstream.cpp
# End Source File # 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 # End Group
# Begin Group "Generic Files" # Begin Group "Generic Files"
@@ -898,7 +926,6 @@ SOURCE=.\generic\treectlg.cpp
SOURCE=.\generic\wizard.cpp SOURCE=.\generic\wizard.cpp
# End Source File # End Source File
# End Group # End Group
# Begin Group "wxHTML Files" # Begin Group "wxHTML Files"
@@ -983,18 +1010,44 @@ SOURCE=.\html\m_tables.cpp
SOURCE=.\html\winpars.cpp SOURCE=.\html\winpars.cpp
# End Source File # End Source File
# End Group # End Group
# Begin Group "MSW Files" # Begin Group "MSW Files"
# PROP Default_Filter ""
# Begin Group "OLE Files"
# PROP Default_Filter "" # PROP Default_Filter ""
# Begin Source File # Begin Source File
SOURCE=.\msw\dummy.cpp SOURCE=.\msw\ole\access.cpp
# ADD CPP /Yc"wx/wxprec.h"
# End Source File # End Source File
# Begin 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 SOURCE=.\msw\accel.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -1003,6 +1056,10 @@ SOURCE=.\msw\app.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\msw\basemsw.cpp
# End Source File
# Begin Source File
SOURCE=.\msw\bitmap.cpp SOURCE=.\msw\bitmap.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -1115,6 +1172,11 @@ SOURCE=.\msw\dragimag.cpp
# End Source File # End Source File
# Begin 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 SOURCE=.\msw\enhmeta.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -1167,6 +1229,16 @@ SOURCE=.\msw\glcanvas.cpp
# End Source File # End Source File
# Begin 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 SOURCE=.\msw\helpbest.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -1387,6 +1459,10 @@ SOURCE=.\msw\utilsexc.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\msw\utilsgui.cpp
# End Source File
# Begin Source File
SOURCE=.\msw\uxtheme.cpp SOURCE=.\msw\uxtheme.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -1401,51 +1477,6 @@ SOURCE=.\msw\wave.cpp
SOURCE=.\msw\window.cpp SOURCE=.\msw\window.cpp
# End Source File # 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 # End Group
# Begin Group "Headers" # Begin Group "Headers"
@@ -1456,7 +1487,9 @@ SOURCE=.\msw\ole\uuid.cpp
# Begin Source File # Begin Source File
SOURCE=..\include\wx\msw\setup.h SOURCE=..\include\wx\msw\setup.h
!IF "$(CFG)" == "wxWindows - Win32 Release Unicode DLL" !IF "$(CFG)" == "wxWindows - Win32 Release Unicode DLL"
# Begin Custom Build - Creating ..\lib\mswdllu\wx\setup.h from $(InputPath) # Begin Custom Build - Creating ..\lib\mswdllu\wx\setup.h from $(InputPath)
InputPath=..\include\wx\msw\setup.h InputPath=..\include\wx\msw\setup.h
@@ -1464,7 +1497,9 @@ InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\mswdllu\wx\setup.h copy "$(InputPath)" ..\lib\mswdllu\wx\setup.h
# End Custom Build # End Custom Build
!ELSEIF "$(CFG)" == "wxWindows - Win32 Debug Unicode DLL" !ELSEIF "$(CFG)" == "wxWindows - Win32 Debug Unicode DLL"
# Begin Custom Build - Creating ..\lib\mswdllud\wx\setup.h from $(InputPath) # Begin Custom Build - Creating ..\lib\mswdllud\wx\setup.h from $(InputPath)
InputPath=..\include\wx\msw\setup.h InputPath=..\include\wx\msw\setup.h
@@ -1472,7 +1507,9 @@ InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\mswdllud\wx\setup.h copy "$(InputPath)" ..\lib\mswdllud\wx\setup.h
# End Custom Build # End Custom Build
!ELSEIF "$(CFG)" == "wxWindows - Win32 Release Unicode" !ELSEIF "$(CFG)" == "wxWindows - Win32 Release Unicode"
# Begin Custom Build - Creating ..\lib\mswu\wx\setup.h from $(InputPath) # Begin Custom Build - Creating ..\lib\mswu\wx\setup.h from $(InputPath)
InputPath=..\include\wx\msw\setup.h InputPath=..\include\wx\msw\setup.h
@@ -1480,7 +1517,9 @@ InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\mswu\wx\setup.h copy "$(InputPath)" ..\lib\mswu\wx\setup.h
# End Custom Build # End Custom Build
!ELSEIF "$(CFG)" == "wxWindows - Win32 Debug Unicode" !ELSEIF "$(CFG)" == "wxWindows - Win32 Debug Unicode"
# Begin Custom Build - Creating ..\lib\mswud\wx\setup.h from $(InputPath) # Begin Custom Build - Creating ..\lib\mswud\wx\setup.h from $(InputPath)
InputPath=..\include\wx\msw\setup.h InputPath=..\include\wx\msw\setup.h
@@ -1488,7 +1527,9 @@ InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\mswud\wx\setup.h copy "$(InputPath)" ..\lib\mswud\wx\setup.h
# End Custom Build # End Custom Build
!ELSEIF "$(CFG)" == "wxWindows - Win32 Release DLL" !ELSEIF "$(CFG)" == "wxWindows - Win32 Release DLL"
# Begin Custom Build - Creating ..\lib\mswdll\wx\setup.h from $(InputPath) # Begin Custom Build - Creating ..\lib\mswdll\wx\setup.h from $(InputPath)
InputPath=..\include\wx\msw\setup.h InputPath=..\include\wx\msw\setup.h
@@ -1496,7 +1537,9 @@ InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\mswdll\wx\setup.h copy "$(InputPath)" ..\lib\mswdll\wx\setup.h
# End Custom Build # End Custom Build
!ELSEIF "$(CFG)" == "wxWindows - Win32 Debug DLL" !ELSEIF "$(CFG)" == "wxWindows - Win32 Debug DLL"
# Begin Custom Build - Creating ..\lib\mswdlld\wx\setup.h from $(InputPath) # Begin Custom Build - Creating ..\lib\mswdlld\wx\setup.h from $(InputPath)
InputPath=..\include\wx\msw\setup.h InputPath=..\include\wx\msw\setup.h
@@ -1504,7 +1547,9 @@ InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\mswdlld\wx\setup.h copy "$(InputPath)" ..\lib\mswdlld\wx\setup.h
# End Custom Build # End Custom Build
!ELSEIF "$(CFG)" == "wxWindows - Win32 Release" !ELSEIF "$(CFG)" == "wxWindows - Win32 Release"
# Begin Custom Build - Creating ..\lib\msw\wx\setup.h from $(InputPath) # Begin Custom Build - Creating ..\lib\msw\wx\setup.h from $(InputPath)
InputPath=..\include\wx\msw\setup.h InputPath=..\include\wx\msw\setup.h
@@ -1512,7 +1557,9 @@ InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\msw\wx\setup.h copy "$(InputPath)" ..\lib\msw\wx\setup.h
# End Custom Build # End Custom Build
!ELSEIF "$(CFG)" == "wxWindows - Win32 Debug" !ELSEIF "$(CFG)" == "wxWindows - Win32 Debug"
# Begin Custom Build - Creating ..\lib\mswd\wx\setup.h from $(InputPath) # Begin Custom Build - Creating ..\lib\mswd\wx\setup.h from $(InputPath)
InputPath=..\include\wx\msw\setup.h InputPath=..\include\wx\msw\setup.h
@@ -1520,7 +1567,9 @@ InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\mswd\wx\setup.h copy "$(InputPath)" ..\lib\mswd\wx\setup.h
# End Custom Build # End Custom Build
!ENDIF !ENDIF
# End Source File # End Source File
# End Group # End Group
# Begin Group "Common" # Begin Group "Common"
@@ -1540,6 +1589,10 @@ SOURCE=..\include\wx\app.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\include\wx\apptrait.h
# End Source File
# Begin Source File
SOURCE=..\include\wx\artprov.h SOURCE=..\include\wx\artprov.h
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -1832,6 +1885,10 @@ SOURCE=..\include\wx\filesys.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\include\wx\fmappriv.h
# End Source File
# Begin Source File
SOURCE=..\include\wx\font.h SOURCE=..\include\wx\font.h
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -2462,7 +2519,6 @@ SOURCE=..\include\wx\zipstrm.h
SOURCE=..\include\wx\zstream.h SOURCE=..\include\wx\zstream.h
# End Source File # End Source File
# End Group # End Group
# Begin Group "MSW" # Begin Group "MSW"
@@ -2481,6 +2537,14 @@ SOURCE=..\include\wx\msw\app.h
# End Source File # End Source File
# Begin 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 SOURCE=..\include\wx\msw\bitmap.h
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -2831,7 +2895,6 @@ SOURCE=..\include\wx\msw\window.h
SOURCE=..\include\wx\msw\winundef.h SOURCE=..\include\wx\msw\winundef.h
# End Source File # End Source File
# End Group # End Group
# Begin Group "Generic" # Begin Group "Generic"
@@ -2992,7 +3055,6 @@ SOURCE=..\include\wx\generic\treectlg.h
SOURCE=..\include\wx\generic\wizard.h SOURCE=..\include\wx\generic\wizard.h
# End Source File # End Source File
# End Group # End Group
# Begin Group "HTML" # Begin Group "HTML"
@@ -3049,7 +3111,6 @@ SOURCE=..\include\wx\html\m_templ.h
SOURCE=..\include\wx\html\winpars.h SOURCE=..\include\wx\html\winpars.h
# End Source File # End Source File
# End Group # End Group
# End Group # End Group
# End Target # End Target

View File

@@ -887,9 +887,10 @@ void wxApp::OnIdle(wxIdleEvent& event)
s_inOnIdle = FALSE; 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... // Wake up the idle handler processor, even if it is in another thread...
} }
@@ -1061,18 +1062,11 @@ Window wxGetWindowParent(Window window)
return (Window) 0; return (Window) 0;
} }
void wxExit() void wxApp::Exit()
{ {
int retValue = 0;
if (wxTheApp)
retValue = wxTheApp->OnExit();
wxApp::CleanUp(); wxApp::CleanUp();
/*
* Exit in some platform-specific way. Not recommended that the app calls this: wxAppConsole::Exit();
* only for emergencies.
*/
exit(retValue);
} }
// Yield to other processes // Yield to other processes