From 7ba4fbebbc40bdf9c140f4c9ba9977fbf810527d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 9 Apr 2001 01:22:48 +0000 Subject: [PATCH] 1. fixes to wxDC deleting logic (should fix ~wxPrinterDC leak), some code reorganized/removed 2. applied (slightly modified) wxEnhMetaFileSimpleDataObject patch git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9687 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- distrib/msw/tmake/vc6.t | 15 +++- distrib/msw/tmake/vcapp.t | 81 +++++++++++++------- include/wx/debug.h | 137 ++++++++++++++++++---------------- include/wx/defs.h | 14 ++-- include/wx/msw/dc.h | 1 - include/wx/msw/dcclient.h | 21 ++++-- include/wx/msw/dcmemory.h | 16 ++-- include/wx/msw/dcprint.h | 12 +-- include/wx/msw/dcscreen.h | 29 ++++--- include/wx/msw/enhmeta.h | 36 ++++++++- samples/console/console.cpp | 23 +++++- samples/controls/controls.cpp | 4 +- samples/dialogs/dialogs.rc | 2 + src/msw/dc.cpp | 24 +++--- src/msw/dcclient.cpp | 82 ++++++++------------ src/msw/dcmemory.cpp | 50 ++++++++----- src/msw/dcprint.cpp | 102 ++++++++++++------------- src/msw/dcscreen.cpp | 24 ++---- src/msw/dialup.cpp | 7 +- src/msw/enhmeta.cpp | 44 ++++++++++- wxBase.dsp | 5 ++ 21 files changed, 432 insertions(+), 297 deletions(-) diff --git a/distrib/msw/tmake/vc6.t b/distrib/msw/tmake/vc6.t index 9359c9e654..3e0235c9ee 100644 --- a/distrib/msw/tmake/vc6.t +++ b/distrib/msw/tmake/vc6.t @@ -37,6 +37,14 @@ next if $wxHTML{$file} =~ /\b16\b/; $project{"WXHTMLSRCS"} .= $file . " " } + + if ( Config("wxnodir") ) { + $WXDIR = "."; + } + else { + if ( $ENV{'wx'} ) { $WXDIR = "\$(wx)"; } + else { $WXDIR = "\$(WXWIN)"; } + } #$} # Microsoft Developer Studio Project File - Name="wxWindows" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 @@ -81,7 +89,7 @@ RSC=rc.exe # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MT" /YX /FD /c -# ADD CPP /nologo /MD /W4 /Zi /O2 /I "$(wx)\include" /I "$(wx)\src\zlib" /I "$(wx)\src\jpeg" /I "$(wx)\src\png" /I "$(wx)\src\tiff" /D "NDEBUG" /D wxUSE_GUI=1 /D WIN95=1 /D "__WIN95__" /D "WIN32" /D "_WIN32" /D WINVER=0x400 /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN32__" /D "_MT" /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MD /W4 /Zi /O2 /I #$ $text = "\"$WXDIR\\include\" /I \"$WXDIR\\src\\zlib\" /I \"$WXDIR\\src\\jpeg\" /I \"$WXDIR\\src\\png\" /I \"$WXDIR\\src\\tiff\" /D \"NDEBUG\" /D wxUSE_GUI=1 /D WIN95=1 /D \"__WIN95__\" /D \"WIN32\" /D \"_WIN32\" /D WINVER=0x400 /D \"__WINDOWS__\" /D \"__WXMSW__\" /D \"__WIN32__\" /D \"_MT\" /Yu\"wx/wxprec.h\" /FD /c" # ADD BASE RSC /l 0x409 # ADD RSC /l 0x409 BSC32=bscmake.exe @@ -104,7 +112,7 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" -D "_MT" /YX /FD /c -# ADD CPP /nologo /MDd /W4 /Zi /Od /I "$(wx)\include" /I "$(wx)\src\zlib" /I "$(wx)\src\jpeg" /I "$(wx)\src\png" /I "$(wx)\src\tiff" /D "_DEBUG" /D DEBUG=1 /D WXDEBUG=1 /D "__WXDEBUG__" /D wxUSE_GUI=1 /D "__WIN95__" /D "WIN32" /D "_WIN32" /D WINVER=0x400 /D "__WINDOWS__" /D "__WIN32__" /D "__WXMSW__" /Fr /D "_MT" /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MDd /W4 /Zi /Od /I #$ $text = "\"$WXDIR\\include\" /I \"$WXDIR\\src\\zlib\" /I \"$WXDIR\\src\\jpeg\" /I \"$WXDIR\\src\\png\" /I \"$WXDIR\\src\\tiff\" /D \"_DEBUG\" /D DEBUG=1 /D WXDEBUG=1 /D \"__WXDEBUG__\" /D wxUSE_GUI=1 /D \"__WIN95__\" /D \"WIN32\" /D \"_WIN32\" /D WINVER=0x400 /D \"__WINDOWS__\" /D \"__WIN32__\" /D \"__WXMSW__\" /Fr /D \"_MT\" /Yu\"wx/wxprec.h\" /FD /c" # ADD BASE RSC /l 0x409 # ADD RSC /l 0x409 BSC32=bscmake.exe @@ -141,11 +149,12 @@ SOURCE=.\src\common\y_tab.c !IF "$(CFG)" == "wxWindows - Win32 Release" +# ADD CPP /W1 /D "USE_DEFINE" # SUBTRACT CPP /YX /Yc /Yu !ELSEIF "$(CFG)" == "wxWindows - Win32 Debug" -# ADD CPP /W1 +# ADD CPP /W1 /D "USE_DEFINE" # SUBTRACT CPP /YX /Yc /Yu !ENDIF diff --git a/distrib/msw/tmake/vcapp.t b/distrib/msw/tmake/vcapp.t index 2a0d20746c..e54adff94a 100644 --- a/distrib/msw/tmake/vcapp.t +++ b/distrib/msw/tmake/vcapp.t @@ -28,25 +28,47 @@ Project('CONFIG += wx'); } if ( Config("wx") ) { - #! VC 6.0 supports env vars in include path - #! $WXDIR = $ENV{'WX'}; - if ( $ENV{'wx'} ) { $WXDIR = "\$(wx)"; } - else { $WXDIR = "\$(WXWIN)"; } - $TMAKE_INCDIR_WX = $WXDIR . "\\include"; - AddIncludePath($TMAKE_INCDIR_WX); + if ( Config("wxnodir") ) { + $WXDIR = "..\\.."; + } + else { + #! VC 6.0 supports env vars in include path + #! $WXDIR = $ENV{'WX'}; + if ( $ENV{'wx'} ) { $WXDIR = "\$(wx)"; } + else { $WXDIR = "\$(WXWIN)"; } + } + + AddIncludePath($WXDIR . "\\include"); + } + + if ( Config("unicode") ) { + $UNICODE="Unicode"; + $UNICODE_SUFFIX="u"; + $UNICODE_FLAGS="/D _UNICODE /D UNICODE "; + + $project{"TARGET"} .= "Unicode"; + $project{"MAKEFILE"} .= "Unicode"; + } + else { + $UNICODE=""; + $UNICODE_SUFFIX=""; + $UNICODE_FLAGS=" "; } if ( Config("dll") ) { $DLL="Dll"; - $DLL_SUFFIX="d"; + $DEBUG_SUFFIX="d"; $DLL_OR_LIB=(Config("wxbase") ? "wxbase" : "wxmsw") . "221"; $DLL_FLAGS="/D WXUSINGDLL "; $EXTRA_LIBS=""; + + $project{"TARGET"} .= "Dll"; + $project{"MAKEFILE"} .= "Dll"; } else { $DLL=""; - $DLL_SUFFIX=""; - $DLL_OR_LIB="wxWindows"; + $DEBUG_SUFFIX=""; + $DLL_OR_LIB=Config("wxbase") ? "wxBase" : "wxWindows"; $DLL_FLAGS=" "; #! actually this depends on the contents of setup.h $EXTRA_LIBS=Config("wxbase") ? "" : "xpm zlib png jpeg tiff"; @@ -70,8 +92,8 @@ if ( Config("wx") ) { $vc_base_libs .= "comctl32.lib rpcrt4.lib wsock32.lib "; - $vc_link_release = "$WXDIR\\Release$DLL\\$DLL_OR_LIB.lib "; - $vc_link_debug = "$WXDIR\\Debug$DLL\\$DLL_OR_LIB$DLL_SUFFIX.lib "; + $vc_link_release = "$WXDIR\\Release$UNICODE$DLL\\$DLL_OR_LIB$UNICODE_SUFFIX.lib "; + $vc_link_debug = "$WXDIR\\Debug$UNICODE$DLL\\$DLL_OR_LIB$UNICODE_SUFFIX$DEBUG_SUFFIX.lib "; foreach ( split(/ /, $EXTRA_LIBS) ) { $vc_link_release .= "$WXDIR\\src\\$_\\Release\\$_.lib "; $vc_link_debug .= "$WXDIR\\src\\$_\\Debug\\$_.lib "; @@ -80,12 +102,7 @@ $vc_link_release .= '/nologo /subsystem:windows /machine:I386'; $vc_link_debug .= '/nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept'; - foreach ( split(/ /, Project('LIBPATH')) ) { - $vc_link_release .= " /libpath:$_\\Release"; - $vc_link_debug .= " /libpath:$_\\Debug"; - } - - $vc_cpp_def_common = '/D "WIN32" /D "_WINDOWS" ' . $DLL_FLAGS; + $vc_cpp_def_common = '/D "WIN32" /D "_WINDOWS" ' . $UNICODE_FLAGS . $DLL_FLAGS; $vc_cpp_def_release = '/D "NDEBUG" ' . $vc_cpp_def_common; $vc_cpp_def_debug = '/D "_DEBUG" ' . $vc_cpp_def_common; } else { @@ -94,16 +111,22 @@ $vc_base_libs = 'kernel32.lib user32.lib advapi32.lib '; if ( Config("wx") ) { $vc_base_libs .= 'wsock32.lib '; - $vc_link_release = "$WXDIR\\Base${DLL}Release\\$DLL_OR_LIB.lib "; - $vc_link_debug = "$WXDIR\\Base${DLL}Debug\\$DLL_OR_LIB" . "d.lib "; + $vc_link_release = "$WXDIR\\BaseRelease$UNICODE$DLL\\$DLL_OR_LIB$UNICODE_SUFFIX.lib "; + $vc_link_debug = "$WXDIR\\BaseDebug$UNICODE$DLL\\$DLL_OR_LIB$UNICODE_SUFFIX$DEBUG_SUFFIX.lib "; } $vc_link_release .= '/nologo /subsystem:console /machine:I386'; $vc_link_debug .= '/nologo /subsystem:console /debug /machine:I386 /pdbtype:sept'; - $vc_cpp_def_common = '/D "WIN32" /D "_CONSOLE" ' . $DLL_FLAGS; + $vc_cpp_def_common = '/D "WIN32" /D "_CONSOLE" ' . $UNICODE_FLAGS . $DLL_FLAGS; $vc_cpp_def_release = '/D "NDEBUG" ' . $vc_cpp_def_common; $vc_cpp_def_debug = '/D "_DEBUG" ' . $vc_cpp_def_common; } + + foreach ( split(/ /, Project('LIBPATH')) ) { + $vc_link_release .= " /libpath:$_\\Release"; + $vc_link_debug .= " /libpath:$_\\Debug"; + } + #! define wxWin debug flags in debug build if ( Config("wx") ) { $vc_cpp_def_debug .= '/MDd /D "__WXDEBUG__" /D "WXDEBUG=1" '; @@ -122,7 +145,7 @@ } #! else: disable C++ exception handling for wxWindows - $vc_cpp_opt_release = $vc_cpp_opt_common1 . '/O2 '; + $vc_cpp_opt_release = $vc_cpp_opt_common1 . '/O1 '; $vc_cpp_opt_debug = $vc_cpp_opt_common1 . '/Zi /Od '; $vc_cpp_opt_common = '/YX /FD /c'; $project{"VC_BASE_CPP_RELEASE"} = $vc_cpp_opt_release . $vc_cpp_def_release . $vc_cpp_opt_common; @@ -220,13 +243,13 @@ RSC=rc.exe # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release#$ $text = "$DLL" . '"' -# PROP BASE Intermediate_Dir "Release#$ $text = "$DLL" . '"' +# PROP BASE Output_Dir "Release#$ $text = "$UNICODE$DLL" . '"' +# PROP BASE Intermediate_Dir "Release#$ $text = "$UNICODE$DLL" . '"' # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release#$ $text = "$DLL" . '"' -# PROP Intermediate_Dir "Release#$ $text = "$DLL" . '"' +# PROP Output_Dir "Release#$ $text = "$UNICODE$DLL" . '"' +# PROP Intermediate_Dir "Release#$ $text = "$UNICODE$DLL" . '"' #$ Config("windows") && ($text='# PROP Ignore_Export_Lib 0'); # PROP Target_Dir "" # ADD BASE CPP #$ Expand("VC_BASE_CPP_RELEASE"); @@ -248,13 +271,13 @@ LINK32=link.exe # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug#$ $text = "$DLL" . '"' -# PROP BASE Intermediate_Dir "Debug#$ $text = "$DLL" . '"' +# PROP BASE Output_Dir "Debug#$ $text = "$UNICODE$DLL" . '"' +# PROP BASE Intermediate_Dir "Debug#$ $text = "$UNICODE$DLL" . '"' # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug#$ $text = "$DLL" . '"' -# PROP Intermediate_Dir "Debug#$ $text = "$DLL" . '"' +# PROP Output_Dir "Debug#$ $text = "$UNICODE$DLL" . '"' +# PROP Intermediate_Dir "Debug#$ $text = "$UNICODE$DLL" . '"' #$ Config("windows") && ($text='# PROP Ignore_Export_Lib 0'); # PROP Target_Dir "" # ADD BASE CPP #$ Expand("VC_BASE_CPP_DEBUG"); diff --git a/include/wx/debug.h b/include/wx/debug.h index 4cb9dd165d..4fd54e2d91 100644 --- a/include/wx/debug.h +++ b/include/wx/debug.h @@ -17,94 +17,101 @@ #include "wx/wxchar.h" // ---------------------------------------------------------------------------- -/** - @name Debugging macros - - All debugging macros rely on ASSERT() which in turn calls user-defined - OnAssert() function. To keep things simple, it's called even when the - expression is TRUE (i.e. everything is ok) and by default does nothing: just - returns the same value back. But if you redefine it to do something more sexy - (popping up a message box in your favourite GUI, sending you e-mail or - whatever) it will affect all ASSERTs, FAILs and CHECKs in your code. -
-
- Warning: if you don't like advices on programming style, don't read - further! ;-) -
-
- Extensive use of these macros is recommended! Remember that ASSERTs are - disabled in final (without __WXDEBUG__ defined) build, so they add strictly - nothing to your program's code. On the other hand, CHECK macros do stay - even in release builds, but in general are not much of a burden, while - a judicious use of them might increase your program's stability. - - @memo Debugging macros (replacement for standard assert()) and more. - */ +// Debugging macros +// +// All debugging macros rely on ASSERT() which in turn calls user-defined +// OnAssert() function. To keep things simple, it's called even when the +// expression is TRUE (i.e. everything is ok) and by default does nothing: just +// returns the same value back. But if you redefine it to do something more sexy +// (popping up a message box in your favourite GUI, sending you e-mail or +// whatever) it will affect all ASSERTs, FAILs and CHECKs in your code. +// +// Warning: if you don't like advices on programming style, don't read +// further! ;-) +// +// Extensive use of these macros is recommended! Remember that ASSERTs are +// disabled in final (without __WXDEBUG__ defined) build, so they add strictly +// nothing to your program's code. On the other hand, CHECK macros do stay +// even in release builds, but in general are not much of a burden, while +// a judicious use of them might increase your program's stability. // ---------------------------------------------------------------------------- -//@{ // Use of these suppresses compiler warnings about testing constant expression WXDLLEXPORT_DATA(extern const bool) wxTrue; WXDLLEXPORT_DATA(extern const bool) wxFalse; -/** @name Macros which are completely disabled in 'release' mode */ -//@{ +// Macros which are completely disabled in 'release' mode #ifdef __WXDEBUG__ - /** - this function may be redefined to do something non trivial and is called - whenever one of debugging macros fails (i.e. condition is false in an - assertion) - @param szFile and nLine - file name and line number of the ASSERT - szMsg - optional message explaining the reason + /* + this function may be redefined to do something non trivial and is called + whenever one of debugging macros fails (i.e. condition is false in an + assertion) + + parameters: + szFile and nLine - file name and line number of the ASSERT + szMsg - optional message explaining the reason */ void WXDLLEXPORT wxOnAssert(const wxChar *szFile, int nLine, const wxChar *szMsg = (const wxChar *) NULL); - /// generic assert macro - #define wxASSERT(cond) if ( !(cond) ) wxOnAssert(__TFILE__, __LINE__) + /* + notice the usage of else at the end of wxASSERT macro: this ensures that + the following code + + if ( ... ) + wxASSERT(...); + else + ... + + works like expected: if there were no "else", the one in the code above + would be matched with a wrong "if" + */ + + // generic assert macro + #define wxASSERT(cond) if ( !(cond) ) wxOnAssert(__TFILE__, __LINE__); else - /// assert with additional message explaining it's cause - #define wxASSERT_MSG(x, m) if ( !(x) ) wxOnAssert(__TFILE__, __LINE__, m) + // assert with additional message explaining it's cause + #define wxASSERT_MSG(cond, msg) \ + if ( !(cond) ) wxOnAssert(__TFILE__, __LINE__, msg); else #else // nothing to do in release modes (hopefully at this moment there are // no more bugs ;-) - #define wxASSERT(cond) - #define wxASSERT_MSG(x, m) + #define wxASSERT(cond) + #define wxASSERT_MSG(x, m) #endif //__WXDEBUG__ -/// special form of assert: always triggers it (in debug mode) -#define wxFAIL wxASSERT(wxFalse) +// special form of assert: always triggers it (in debug mode) +#define wxFAIL wxASSERT(wxFalse) -/// FAIL with some message -#define wxFAIL_MSG(msg) wxASSERT_MSG(wxFalse, msg) -//@} +// FAIL with some message +#define wxFAIL_MSG(msg) wxASSERT_MSG(wxFalse, msg) -// NB: these macros work also in release mode! +// NB: the following macros work also in release mode! -/** +/* These macros must be used only in invalid situation: for example, an invalid parameter (NULL pointer) is passed to a function. Instead of dereferencing it and causing core dump the function might try using CHECK( p != NULL ) or CHECK( p != NULL, return LogError("p is NULL!!") ) - - @name Macros which remain even in 'release' mode */ -//@{ - /// check that expression is true, "return" if not (also FAILs in debug mode) -#define wxCHECK(x, rc) if (!(x)) {wxFAIL; return rc; } - /// as wxCHECK but with a message explaining why we fail -#define wxCHECK_MSG(x, rc, msg) if (!(x)) {wxFAIL_MSG(msg); return rc; } - /// check that expression is true, perform op if not -#define wxCHECK2(x, op) if (!(x)) {wxFAIL; op; } - /// as wxCHECK2 but with a message explaining why we fail -#define wxCHECK2_MSG(x, op, msg) if (!(x)) {wxFAIL_MSG(msg); op; } - /// special form of wxCHECK2: as wxCHECK, but for use in void functions - // NB: there is only one form (with msg parameter) and it's intentional: - // there is no other way to tell the caller what exactly went wrong - // from the void function (of course, the function shouldn't be void - // to begin with...) -#define wxCHECK_RET(x, msg) if (!(x)) {wxFAIL_MSG(msg); return; } -//@} - -//@} + +// check that expression is true, "return" if not (also FAILs in debug mode) +#define wxCHECK(x, rc) if (!(x)) {wxFAIL; return rc; } + +// as wxCHECK but with a message explaining why we fail +#define wxCHECK_MSG(x, rc, msg) if (!(x)) {wxFAIL_MSG(msg); return rc; } + +// check that expression is true, perform op if not +#define wxCHECK2(x, op) if (!(x)) {wxFAIL; op; } + +// as wxCHECK2 but with a message explaining why we fail +#define wxCHECK2_MSG(x, op, msg) if (!(x)) {wxFAIL_MSG(msg); op; } + +// special form of wxCHECK2: as wxCHECK, but for use in void functions +// NB: there is only one form (with msg parameter) and it's intentional: +// there is no other way to tell the caller what exactly went wrong +// from the void function (of course, the function shouldn't be void +// to begin with...) +#define wxCHECK_RET(x, msg) if (!(x)) {wxFAIL_MSG(msg); return; } #endif // _WX_DEBUG_H_ + diff --git a/include/wx/defs.h b/include/wx/defs.h index b3893851f5..784b5b9e9d 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -53,21 +53,23 @@ #endif #if defined(__APPLE__) - // MacOS X + // MacOS X #ifndef __WXMAC__ #define __WXMAC__ #endif #ifndef __WXMAC_X__ #define __WXMAC_X__ #endif - + #define PM_USE_SESSION_APIS 0 #include #endif -#elif defined(applec) || defined(THINK_C) || (defined(__MWERKS__) && !defined(__INTEL__)) - // MacOS +#elif defined(applec) || \ + defined(THINK_C) || \ + (defined(__MWERKS__) && !defined(__INTEL__)) + // MacOS #elif defined(__WXMAC__) && defined(__APPLE__) - // MacOS X + // MacOS X #define __UNIX_LIKE__ #ifndef __WXMAC__ @@ -76,7 +78,7 @@ #ifndef __WXMAC_X__ #define __WXMAC_X__ #endif - + #define PM_USE_SESSION_APIS 0 #include #elif defined(__OS2__) diff --git a/include/wx/msw/dc.h b/include/wx/msw/dc.h index 6f31ec97b6..94605640ca 100644 --- a/include/wx/msw/dc.h +++ b/include/wx/msw/dc.h @@ -216,7 +216,6 @@ protected: // our HDC and its usage count: we only free it when the usage count drops // to 0 WXHDC m_hDC; - int m_hDCCount; // Store all old GDI objects when do a SelectObject, so we can select them // back in (this unselecting user's objects) so we can safely delete the diff --git a/include/wx/msw/dcclient.h b/include/wx/msw/dcclient.h index 5568f0a6a2..6e665dc436 100644 --- a/include/wx/msw/dcclient.h +++ b/include/wx/msw/dcclient.h @@ -38,34 +38,36 @@ WX_DECLARE_EXPORTED_OBJARRAY(wxPaintDCInfo, wxArrayDCInfo); class WXDLLEXPORT wxWindowDC : public wxDC { - DECLARE_DYNAMIC_CLASS(wxWindowDC) - public: + // default ctor wxWindowDC(); // Create a DC corresponding to the whole window wxWindowDC(wxWindow *win); - virtual ~wxWindowDC(); +protected: + // intiialize the newly created DC + void InitDC(); + +private: + DECLARE_DYNAMIC_CLASS(wxWindowDC) }; class WXDLLEXPORT wxClientDC : public wxWindowDC { - DECLARE_DYNAMIC_CLASS(wxClientDC) - public: + // default ctor wxClientDC(); // Create a DC corresponding to the client area of the window wxClientDC(wxWindow *win); - virtual ~wxClientDC(); +private: + DECLARE_DYNAMIC_CLASS(wxClientDC) }; class WXDLLEXPORT wxPaintDC : public wxWindowDC { - DECLARE_DYNAMIC_CLASS(wxPaintDC) - public: wxPaintDC(); @@ -82,6 +84,9 @@ protected: // find the entry for this DC in the cache (keyed by the window) wxPaintDCInfo *FindInCache(size_t *index = NULL) const; + +private: + DECLARE_DYNAMIC_CLASS(wxPaintDC) }; #endif diff --git a/include/wx/msw/dcmemory.h b/include/wx/msw/dcmemory.h index 85d83bd981..01f37663aa 100644 --- a/include/wx/msw/dcmemory.h +++ b/include/wx/msw/dcmemory.h @@ -1,12 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: dcmemory.h +// Name: wx/msw/dcmemory.h // Purpose: wxMemoryDC class // Author: Julian Smart // Modified by: // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_DCMEMORY_H_ @@ -24,13 +24,19 @@ public: wxMemoryDC(); wxMemoryDC(wxDC *dc); // Create compatible DC - ~wxMemoryDC(); - - virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); virtual void SelectObject(const wxBitmap& bitmap); +protected: + // override some base class virtuals + virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); virtual void DoGetSize(int* width, int* height) const; + // create DC compatible with the given one or screen if dc == NULL + bool CreateCompatible(wxDC *dc); + + // initialize the newly created DC + void Init(); + private: DECLARE_DYNAMIC_CLASS(wxMemoryDC) }; diff --git a/include/wx/msw/dcprint.h b/include/wx/msw/dcprint.h index 0c3b02d5ad..d9531b3f7d 100644 --- a/include/wx/msw/dcprint.h +++ b/include/wx/msw/dcprint.h @@ -21,11 +21,9 @@ #include "wx/dc.h" #include "wx/cmndata.h" -class WXDLLEXPORT wxPrinterDC: public wxDC +class WXDLLEXPORT wxPrinterDC : public wxDC { public: -DECLARE_CLASS(wxPrinterDC) - // Create a printer DC (obsolete function: use wxPrintData version now) wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output, bool interactive = TRUE, int orientation = wxPORTRAIT); @@ -34,8 +32,6 @@ DECLARE_CLASS(wxPrinterDC) wxPrinterDC(WXHDC theDC); - ~wxPrinterDC(void); - // override some base class virtuals virtual bool StartDoc(const wxString& message); virtual void EndDoc(); @@ -50,7 +46,13 @@ protected: wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop = wxCOPY, bool useMask = FALSE); + // init the dc + void Init(); + wxPrintData m_printData; + +private: + DECLARE_CLASS(wxPrinterDC) }; // Gets an HDC for the default printer configuration diff --git a/include/wx/msw/dcscreen.h b/include/wx/msw/dcscreen.h index 67a0cbd95e..f46d636481 100644 --- a/include/wx/msw/dcscreen.h +++ b/include/wx/msw/dcscreen.h @@ -1,12 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: dcscreen.h +// Name: wx/msw/dcscreen.h // Purpose: wxScreenDC class // Author: Julian Smart // Modified by: // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_DCSCREEN_H_ @@ -18,20 +18,19 @@ #include "wx/dcclient.h" -class WXDLLEXPORT wxScreenDC: public wxWindowDC +class WXDLLEXPORT wxScreenDC : public wxWindowDC { - DECLARE_DYNAMIC_CLASS(wxScreenDC) - - public: - // Create a DC representing the whole screen - wxScreenDC(void); - ~wxScreenDC(void); - - // Compatibility with X's requirements for - // drawing on top of all windows - static bool StartDrawingOnTop(wxWindow* WXUNUSED(window)) { return TRUE; } - static bool StartDrawingOnTop(wxRect* WXUNUSED(rect) = NULL) { return TRUE; } - static bool EndDrawingOnTop(void) { return TRUE; } +public: + // Create a DC representing the whole screen + wxScreenDC(); + + // Compatibility with X's requirements for drawing on top of all windows + static bool StartDrawingOnTop(wxWindow* WXUNUSED(window)) { return TRUE; } + static bool StartDrawingOnTop(wxRect* WXUNUSED(rect) = NULL) { return TRUE; } + static bool EndDrawingOnTop(void) { return TRUE; } + +private: + DECLARE_DYNAMIC_CLASS(wxScreenDC) }; #endif diff --git a/include/wx/msw/enhmeta.h b/include/wx/msw/enhmeta.h index 88f7cfa8a9..bf2574b935 100644 --- a/include/wx/msw/enhmeta.h +++ b/include/wx/msw/enhmeta.h @@ -94,12 +94,12 @@ private: DECLARE_DYNAMIC_CLASS(wxEnhMetaFileDC) }; +#if wxUSE_DRAG_AND_DROP + // ---------------------------------------------------------------------------- // wxEnhMetaFileDataObject is a specialization of wxDataObject for enh metafile // ---------------------------------------------------------------------------- -#if wxUSE_DRAG_AND_DROP - // notice that we want to support both CF_METAFILEPICT and CF_ENHMETAFILE and // so we derive from wxDataObject and not from wxDataObjectSimple class WXDLLEXPORT wxEnhMetaFileDataObject : public wxDataObject @@ -130,6 +130,38 @@ protected: wxEnhMetaFile m_metafile; }; + +// ---------------------------------------------------------------------------- +// wxEnhMetaFileSimpleDataObject does derive from wxDataObjectSimple which +// makes it more convenient to use (it can be used with wxDataObjectComposite) +// at the price of not supoprting any more CF_METAFILEPICT but only +// CF_ENHMETAFILE +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxEnhMetaFileSimpleDataObject : public wxDataObjectSimple +{ +public: + // ctors + wxEnhMetaFileSimpleDataObject() : wxDataObjectSimple(wxDF_ENHMETAFILE) { } + wxEnhMetaFileSimpleDataObject(const wxEnhMetaFile& metafile) + : wxDataObjectSimple(wxDF_ENHMETAFILE), m_metafile(metafile) { } + + // virtual functions which you may override if you want to provide data on + // demand only - otherwise, the trivial default versions will be used + virtual void SetEnhMetafile(const wxEnhMetaFile& metafile) + { m_metafile = metafile; } + virtual wxEnhMetaFile GetEnhMetafile() const + { return m_metafile; } + + // implement base class pure virtuals + virtual size_t GetDataSize() const; + virtual bool GetDataHere(void *buf) const; + virtual bool SetData(size_t len, const void *buf); + +protected: + wxEnhMetaFile m_metafile; +}; + #endif // wxUSE_DRAG_AND_DROP #endif // _WX_MSW_ENHMETA_H_ diff --git a/samples/console/console.cpp b/samples/console/console.cpp index f8995d43d9..242fa887a2 100644 --- a/samples/console/console.cpp +++ b/samples/console/console.cpp @@ -49,11 +49,12 @@ //#define TEST_HASH //#define TEST_INFO_FUNCTIONS //#define TEST_LIST -#define TEST_LOCALE +//#define TEST_LOCALE //#define TEST_LOG //#define TEST_LONGLONG //#define TEST_MIME //#define TEST_PATHLIST +#define TEST_REGCONF //#define TEST_REGISTRY //#define TEST_SOCKETS //#define TEST_STREAMS @@ -1599,14 +1600,28 @@ static void TestPathList() #endif // TEST_PATHLIST // ---------------------------------------------------------------------------- -// registry +// registry and related stuff // ---------------------------------------------------------------------------- // this is for MSW only #ifndef __WXMSW__ + #undef TEST_REGCONF #undef TEST_REGISTRY #endif +#ifdef TEST_REGCONF + +#include +#include + +static void TestRegConfWrite() +{ + wxRegConfig regconf(_T("console"), _T("wxwindows")); + regconf.Write(_T("Hello"), wxString(_T("world"))); +} + +#endif // TEST_REGCONF + #ifdef TEST_REGISTRY #include @@ -4680,6 +4695,10 @@ int main(int argc, char **argv) TestPathList(); #endif // TEST_PATHLIST +#ifdef TEST_REGCONF + TestRegConfWrite(); +#endif // TEST_REGCONF + #ifdef TEST_REGISTRY if ( 0 ) TestRegistryRead(); diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 13dca99061..d42475368c 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -701,7 +701,9 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) m_gaugeVert = new wxGauge( panel, -1, 100, wxPoint(195,35), wxSize(30, 90), wxGA_VERTICAL | wxGA_SMOOTH | wxNO_BORDER ); - m_slider = new wxSlider( panel, ID_SLIDER, 0, 0, 200, wxPoint(18,90), wxSize(155,-1), wxSL_LABELS ); + m_slider = new wxSlider( panel, ID_SLIDER, 0, 0, 200, wxPoint(18,90), wxSize(155,-1), + wxSL_AUTOTICKS | wxSL_LABELS ); + m_slider->SetTickFreq(40, 0); (void)new wxStaticBox( panel, -1, "&Explanation", wxPoint(230,10), wxSize(270,130) ); #ifdef __WXMOTIF__ // No wrapping text in wxStaticText yet :-( diff --git a/samples/dialogs/dialogs.rc b/samples/dialogs/dialogs.rc index 82bdf07561..3a98924530 100644 --- a/samples/dialogs/dialogs.rc +++ b/samples/dialogs/dialogs.rc @@ -1,2 +1,4 @@ +dialogs ICON "dialogs.ico" + #include "wx/msw/wx.rc" diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 90433d392f..0598c60773 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -183,23 +183,29 @@ wxDC::wxDC() m_windowExtX = VIEWPORT_EXTENT; m_windowExtY = VIEWPORT_EXTENT; - - m_hDCCount = 0; } wxDC::~wxDC() { - if ( m_hDC != 0 ) { + if ( m_hDC != 0 ) + { SelectOldObjects(m_hDC); - if ( m_bOwnsDC ) { - if ( m_canvas == NULL ) - ::DeleteDC(GetHdc()); - else - ::ReleaseDC((HWND)m_canvas->GetHWND(), GetHdc()); + + // if we own the HDC, we delete it, otherwise we just release it + + if ( m_bOwnsDC ) + { + ::DeleteDC(GetHdc()); } - } + else // we don't own our HDC + { + // this is not supposed to happen as we can't free the HDC then + wxCHECK_RET( m_canvas, _T("no canvas in not owning ~wxDC?") ); + ::ReleaseDC(GetHwndOf(m_canvas), GetHdc()); + } + } } // This will select current objects out of the DC, diff --git a/src/msw/dcclient.cpp b/src/msw/dcclient.cpp index 46642e078f..1cee9d8212 100644 --- a/src/msw/dcclient.cpp +++ b/src/msw/dcclient.cpp @@ -62,9 +62,9 @@ WX_DEFINE_OBJARRAY(wxArrayDCInfo); // macros // ---------------------------------------------------------------------------- - IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC) - IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC) - IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC) +IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC) +IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC) +IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC) // ---------------------------------------------------------------------------- // global variables @@ -90,33 +90,30 @@ static PAINTSTRUCT g_paintStruct; wxWindowDC::wxWindowDC() { - m_canvas = NULL; + m_canvas = NULL; } -wxWindowDC::wxWindowDC(wxWindow *the_canvas) +wxWindowDC::wxWindowDC(wxWindow *canvas) { - m_canvas = the_canvas; - m_hDC = (WXHDC) ::GetWindowDC(GetWinHwnd(the_canvas) ); - m_hDCCount++; + wxCHECK_RET( canvas, _T("invalid window in wxWindowDC") ); - SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID)); -} + m_canvas = canvas; + m_hDC = (WXHDC) ::GetWindowDC(GetHwndOf(m_canvas)); -wxWindowDC::~wxWindowDC() -{ - if (m_canvas && m_hDC) - { - SelectOldObjects(m_hDC); + // m_bOwnsDC was already set to false in the base class ctor, so the DC + // will be released (and not deleted) in ~wxDC - if ( !::ReleaseDC(GetWinHwnd(m_canvas), GetHdc()) ) - { - wxLogLastError(wxT("ReleaseDC")); - } + InitDC(); +} - m_hDC = 0; - } +void wxWindowDC::InitDC() +{ + // the background mode is only used for text background and is set in + // DrawText() to OPAQUE as required, otherwise always TRANSPARENT, + ::SetBkMode(GetHdc(), TRANSPARENT); - m_hDCCount--; + // default bg colour is pne of the window + SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID)); } // ---------------------------------------------------------------------------- @@ -125,31 +122,20 @@ wxWindowDC::~wxWindowDC() wxClientDC::wxClientDC() { - m_canvas = NULL; + m_canvas = NULL; } -wxClientDC::wxClientDC(wxWindow *the_canvas) +wxClientDC::wxClientDC(wxWindow *canvas) { - m_canvas = the_canvas; - m_hDC = (WXHDC) ::GetDC(GetWinHwnd(the_canvas)); + wxCHECK_RET( canvas, _T("invalid window in wxClientDC") ); - // the background mode is only used for text background - // and is set in DrawText() to OPAQUE as required, other- - // wise always TRANSPARENT, RR - ::SetBkMode( GetHdc(), TRANSPARENT ); - - SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID)); -} + m_canvas = canvas; + m_hDC = (WXHDC)::GetDC(GetHwndOf(m_canvas)); -wxClientDC::~wxClientDC() -{ - if ( m_canvas && GetHdc() ) - { - SelectOldObjects(m_hDC); + // m_bOwnsDC was already set to false in the base class ctor, so the DC + // will be released (and not deleted) in ~wxDC - ::ReleaseDC(GetWinHwnd(m_canvas), GetHdc()); - m_hDC = 0; - } + InitDC(); } // ---------------------------------------------------------------------------- @@ -157,7 +143,7 @@ wxClientDC::~wxClientDC() // ---------------------------------------------------------------------------- // VZ: initial implementation (by JACS) only remembered the last wxPaintDC -// created and tried to reuse - this was supposed to take care of a +// created and tried to reuse it - this was supposed to take care of a // situation when a derived class OnPaint() calls base class OnPaint() // because in this case ::BeginPaint() shouldn't be called second time. // @@ -177,7 +163,6 @@ wxArrayDCInfo wxPaintDC::ms_cache; wxPaintDC::wxPaintDC() { m_canvas = NULL; - m_hDC = 0; } wxPaintDC::wxPaintDC(wxWindow *canvas) @@ -204,16 +189,11 @@ wxPaintDC::wxPaintDC(wxWindow *canvas) } else // not in cache, create a new one { - m_hDC = (WXHDC)::BeginPaint(GetWinHwnd(m_canvas), &g_paintStruct); + m_hDC = (WXHDC)::BeginPaint(GetHwndOf(m_canvas), &g_paintStruct); ms_cache.Add(new wxPaintDCInfo(m_canvas, this)); } - // the background mode is only used for text background - // and is set in DrawText() to OPAQUE as required, other- - // wise always TRANSPARENT, RR - ::SetBkMode( GetHdc(), TRANSPARENT ); - - SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID)); + InitDC(); } wxPaintDC::~wxPaintDC() @@ -229,7 +209,7 @@ wxPaintDC::~wxPaintDC() if ( !--info->count ) { - ::EndPaint(GetWinHwnd(m_canvas), &g_paintStruct); + ::EndPaint(GetHwndOf(m_canvas), &g_paintStruct); ms_cache.Remove(index); diff --git a/src/msw/dcmemory.cpp b/src/msw/dcmemory.cpp index cb5a8a8abc..744f2ae65a 100644 --- a/src/msw/dcmemory.cpp +++ b/src/msw/dcmemory.cpp @@ -53,37 +53,47 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC) wxMemoryDC::wxMemoryDC() { - m_hDC = (WXHDC) ::CreateCompatibleDC((HDC) NULL); - m_ok = (m_hDC != 0); - m_bOwnsDC = TRUE; - - SetBrush(*wxWHITE_BRUSH); - SetPen(*wxBLACK_PEN); + CreateCompatible(NULL); - // the background mode is only used for text background and is set in - // DrawText() to OPAQUE as required, otherwise always TRANSPARENT - ::SetBkMode( GetHdc(), TRANSPARENT ); + Init(); } -wxMemoryDC::wxMemoryDC(wxDC *old_dc) +wxMemoryDC::wxMemoryDC(wxDC *dc) { - old_dc->BeginDrawing(); + wxCHECK_RET( dc, _T("NULL dc in wxMemoryDC ctor") ); + + dc->BeginDrawing(); - m_hDC = (WXHDC) ::CreateCompatibleDC(GetHdcOf(*old_dc)); - m_ok = (m_hDC != 0); + CreateCompatible(dc); - old_dc->EndDrawing(); + dc->EndDrawing(); - SetBrush(*wxWHITE_BRUSH); - SetPen(*wxBLACK_PEN); + Init(); +} + +void wxMemoryDC::Init() +{ + if ( m_ok ) + { + SetBrush(*wxWHITE_BRUSH); + SetPen(*wxBLACK_PEN); - // the background mode is only used for text background and is set in - // DrawText() to OPAQUE as required, otherwise always TRANSPARENT - ::SetBkMode( GetHdc(), TRANSPARENT ); + // the background mode is only used for text background and is set in + // DrawText() to OPAQUE as required, otherwise always TRANSPARENT + ::SetBkMode( GetHdc(), TRANSPARENT ); + } } -wxMemoryDC::~wxMemoryDC() +bool wxMemoryDC::CreateCompatible(wxDC *dc) { + m_hDC = (WXHDC)::CreateCompatibleDC(dc ? GetHdcOf(*dc) : NULL); + + // as we created the DC, we must delete it in the dtor + m_bOwnsDC = TRUE; + + m_ok = m_hDC != 0; + + return m_ok; } void wxMemoryDC::SelectObject(const wxBitmap& bitmap) diff --git a/src/msw/dcprint.cpp b/src/msw/dcprint.cpp index e8ccc8bac8..6ed8cdc9b1 100644 --- a/src/msw/dcprint.cpp +++ b/src/msw/dcprint.cpp @@ -70,68 +70,61 @@ IMPLEMENT_CLASS(wxPrinterDC, wxDC) // ---------------------------------------------------------------------------- // This form is deprecated -wxPrinterDC::wxPrinterDC(const wxString& driver_name, const wxString& device_name, const wxString& file, bool interactive, int orientation) +wxPrinterDC::wxPrinterDC(const wxString& driver_name, + const wxString& device_name, + const wxString& file, + bool interactive, + int orientation) { m_isInteractive = interactive; - if ( !!file ) + if ( !file.empty() ) m_printData.SetFilename(file); #if wxUSE_COMMON_DIALOGS - if (interactive) + if ( interactive ) { PRINTDLG pd; pd.lStructSize = sizeof( PRINTDLG ); - pd.hwndOwner=(HWND) NULL; - pd.hDevMode=(HANDLE)NULL; - pd.hDevNames=(HANDLE)NULL; - pd.Flags=PD_RETURNDC | PD_NOSELECTION | PD_NOPAGENUMS; - pd.nFromPage=0; - pd.nToPage=0; - pd.nMinPage=0; - pd.nMaxPage=0; - pd.nCopies=1; - pd.hInstance=(HINSTANCE)NULL; - - if ( PrintDlg( &pd ) != 0 ) + pd.hwndOwner = (HWND) NULL; + pd.hDevMode = (HANDLE)NULL; + pd.hDevNames = (HANDLE)NULL; + pd.Flags = PD_RETURNDC | PD_NOSELECTION | PD_NOPAGENUMS; + pd.nFromPage = 0; + pd.nToPage = 0; + pd.nMinPage = 0; + pd.nMaxPage = 0; + pd.nCopies = 1; + pd.hInstance = (HINSTANCE)NULL; + + m_ok = PrintDlg( &pd ) != 0; + if ( m_ok ) { m_hDC = (WXHDC) pd.hDC; - m_ok = TRUE; } - else - { - m_ok = FALSE; - return; - } - - // m_dontDelete = TRUE; } else #endif // wxUSE_COMMON_DIALOGS - if ((!driver_name.IsNull() && driver_name != wxT("")) && - (!device_name.IsNull() && device_name != wxT("")) && - (!file.IsNull() && file != wxT(""))) + { + if ( !driver_name.empty() && !device_name.empty() && !file.empty() ) { - m_hDC = (WXHDC) CreateDC(WXSTRINGCAST driver_name, WXSTRINGCAST device_name, WXSTRINGCAST file, NULL); - m_ok = m_hDC ? TRUE: FALSE; + m_hDC = (WXHDC) CreateDC(driver_name, device_name, file, NULL); } - else + else // we don't have all parameters, ask the user { wxPrintData printData; printData.SetOrientation(orientation); m_hDC = wxGetPrinterDC(printData); - m_ok = m_hDC ? TRUE: FALSE; } - if (m_hDC) - { - // int width = GetDeviceCaps(m_hDC, VERTRES); - // int height = GetDeviceCaps(m_hDC, HORZRES); - SetMapMode(wxMM_TEXT); - } - SetBrush(*wxBLACK_BRUSH); - SetPen(*wxBLACK_PEN); + m_ok = m_hDC ? TRUE: FALSE; + + // as we created it, we must delete it as well + m_bOwnsDC = TRUE; + } + + Init(); } wxPrinterDC::wxPrinterDC(const wxPrintData& printData) @@ -141,34 +134,33 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printData) m_isInteractive = FALSE; m_hDC = wxGetPrinterDC(printData); - m_ok = (m_hDC != 0); + m_ok = m_hDC != 0; + m_bOwnsDC = TRUE; - if (m_hDC) - SetMapMode(wxMM_TEXT); - - SetBrush(*wxBLACK_BRUSH); - SetPen(*wxBLACK_PEN); + Init(); } -wxPrinterDC::wxPrinterDC(WXHDC theDC) +wxPrinterDC::wxPrinterDC(WXHDC dc) { m_isInteractive = FALSE; - m_hDC = theDC; + m_hDC = dc; + m_bOwnsDC = TRUE; m_ok = TRUE; - if (m_hDC) +} + +void wxPrinterDC::Init() +{ + if ( m_hDC ) { // int width = GetDeviceCaps(m_hDC, VERTRES); // int height = GetDeviceCaps(m_hDC, HORZRES); SetMapMode(wxMM_TEXT); - } - SetBrush(*wxBLACK_BRUSH); - SetPen(*wxBLACK_PEN); -} -wxPrinterDC::~wxPrinterDC() -{ + SetBrush(*wxBLACK_BRUSH); + SetPen(*wxBLACK_PEN); + } } // ---------------------------------------------------------------------------- @@ -229,7 +221,7 @@ void wxPrinterDC::EndPage() // Returns default device and port names static bool wxGetDefaultDeviceName(wxString& deviceName, wxString& portName) { - deviceName = ""; + deviceName.clear(); LPDEVNAMES lpDevNames; LPSTR lpszDriverName; @@ -359,7 +351,7 @@ WXHDC wxGetPrinterDC(int orientation) } return (WXHDC) hDC; } -#endif +#endif // 0 // Gets an HDC for the specified printer configuration WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& printDataConst) diff --git a/src/msw/dcscreen.cpp b/src/msw/dcscreen.cpp index 511c3b25bc..b1d7d3deae 100644 --- a/src/msw/dcscreen.cpp +++ b/src/msw/dcscreen.cpp @@ -1,12 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: dcscreen.cpp +// Name: src/msw/dcscreen.cpp // Purpose: wxScreenDC class // Author: Julian Smart // Modified by: // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -33,22 +33,12 @@ IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC) // Create a DC representing the whole screen -wxScreenDC::wxScreenDC(void) +wxScreenDC::wxScreenDC() { - m_hDC = (WXHDC) ::GetDC((HWND) NULL); - m_hDCCount ++; + m_hDC = (WXHDC) ::GetDC((HWND) NULL); - // the background mode is only used for text background - // and is set in DrawText() to OPAQUE as required, other- - // wise always TRANSPARENT, RR - ::SetBkMode( GetHdc(), TRANSPARENT ); -} - -wxScreenDC::~wxScreenDC(void) -{ - SelectOldObjects(m_hDC); - ::ReleaseDC((HWND) NULL, (HDC) m_hDC); - m_hDC = 0; - m_hDCCount --; + // the background mode is only used for text background and is set in + // DrawText() to OPAQUE as required, otherwise always TRANSPARENT + ::SetBkMode( GetHdc(), TRANSPARENT ); } diff --git a/src/msw/dialup.cpp b/src/msw/dialup.cpp index bf03145dc5..8db47bdd84 100644 --- a/src/msw/dialup.cpp +++ b/src/msw/dialup.cpp @@ -56,7 +56,12 @@ DEFINE_EVENT_TYPE(wxEVT_DIALUP_CONNECTED) DEFINE_EVENT_TYPE(wxEVT_DIALUP_DISCONNECTED) // Doesn't yet compile under VC++ 4, BC++, Watcom C++: no wininet.h -#if !defined(__BORLANDC__) && !defined(__GNUWIN32_OLD__) && !( defined(__GNUWIN32__) && !wxCHECK_W32API_VERSION( 0, 5 ) ) && !defined(__WATCOMC__) && ! (defined(__VISUALC__) && (__VISUALC__ < 1020)) +#if !defined(__BORLANDC__) && \ + !defined(__GNUWIN32_OLD__) && \ + !defined(__WATCOMC__) && \ + (!defined(__VISUALC__) || (__VISUALC__ >= 1020)) + // FIXME: add this back as soon as wxCHECK_W32API_VERSION is chcked in + // (!defined(__GNUWIN32__) || wxCHECK_W32API_VERSION(0, 5)) && \ #include #include diff --git a/src/msw/enhmeta.cpp b/src/msw/enhmeta.cpp index 2f1661b329..f7ab6178fa 100644 --- a/src/msw/enhmeta.cpp +++ b/src/msw/enhmeta.cpp @@ -234,12 +234,12 @@ wxEnhMetaFileDC::~wxEnhMetaFileDC() m_hDC = 0; } +#if wxUSE_DRAG_AND_DROP + // ---------------------------------------------------------------------------- // wxEnhMetaFileDataObject // ---------------------------------------------------------------------------- -#if wxUSE_DRAG_AND_DROP - wxDataFormat wxEnhMetaFileDataObject::GetPreferredFormat(Direction WXUNUSED(dir)) const { @@ -391,6 +391,46 @@ bool wxEnhMetaFileDataObject::SetData(const wxDataFormat& format, return TRUE; } + +// ---------------------------------------------------------------------------- +// wxEnhMetaFileSimpleDataObject +// ---------------------------------------------------------------------------- + +size_t wxEnhMetaFileSimpleDataObject::GetDataSize() const +{ + // we pass data by handle and not HGLOBAL + return 0u; +} + +bool wxEnhMetaFileSimpleDataObject::GetDataHere(void *buf) const +{ + wxCHECK_MSG( m_metafile.Ok(), FALSE, _T("copying invalid enh metafile") ); + + HENHMETAFILE hEMF = (HENHMETAFILE)m_metafile.GetHENHMETAFILE(); + + HENHMETAFILE hEMFCopy = ::CopyEnhMetaFile(hEMF, NULL); + if ( !hEMFCopy ) + { + wxLogLastError(_T("CopyEnhMetaFile")); + + return FALSE; + } + + *(HENHMETAFILE *)buf = hEMFCopy; + return TRUE; +} + +bool wxEnhMetaFileSimpleDataObject::SetData(size_t WXUNUSED(len), + const void *buf) +{ + HENHMETAFILE hEMF = *(HENHMETAFILE *)buf; + + wxCHECK_MSG( hEMF, FALSE, _T("pasting invalid enh metafile") ); + m_metafile.SetHENHMETAFILE((WXHANDLE)hEMF); + + return TRUE; +} + #endif // wxUSE_DRAG_AND_DROP #endif // wxUSE_ENH_METAFILE diff --git a/wxBase.dsp b/wxBase.dsp index 267318398b..6c863ded43 100644 --- a/wxBase.dsp +++ b/wxBase.dsp @@ -117,6 +117,11 @@ SOURCE=.\src\common\dbtable.cpp # End Source File # Begin Source File +SOURCE=.\src\msw\dummy.cpp +# ADD CPP /Yc"wx/wxprec.h" +# End Source File +# Begin Source File + SOURCE=.\src\common\dynarray.cpp # End Source File # Begin Source File -- 2.45.2