From: <arn...@us...> - 2008-03-29 07:13:45
|
Revision: 1077 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=1077&view=rev Author: arnetheduck Date: 2008-03-29 00:13:41 -0700 (Sat, 29 Mar 2008) Log Message: ----------- Detempletize common dialogs Modified Paths: -------------- dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h dcplusplus/trunk/smartwin/include/smartwin/WidgetFactoryPlatformSmartWinDesktop.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectFileFilter.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseColor.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseFolder.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseFont.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetLoadFile.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetMessageBox.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetSaveFile.h dcplusplus/trunk/smartwin/source/LibraryLoader.cpp dcplusplus/trunk/smartwin/source/widgets/WidgetTreeView.cpp dcplusplus/trunk/win32/WinUtil.cpp Property Changed: ---------------- dcplusplus/trunk/ Property changes on: dcplusplus/trunk ___________________________________________________________________ Name: bzr:revision-info - timestamp: 2008-03-27 09:21:21.841000080 +0100 committer: arn...@gm... properties: branch-nick: dcplusplus + timestamp: 2008-03-27 13:06:39.479000092 +0100 committer: Jacek Sieka <arn...@gm...> properties: branch-nick: dcplusplus Name: bzr:revision-id:v3-trunk1 - 1027 arn...@gm...-20080323183926-schknwnkgeo7ivdn 1028 zouzou123gen-20080323220411-r8usuc3qxwuh7zsn 1029 zouzou123gen-20080323221249-0su72zaj13e706mk 1030 arn...@gm...-20080324140623-muba1dl46m000o8c 1031 zouzou123gen-20080324141933-qbgr93ugpe0297m6 1032 arn...@gm...-20080324153706-siidja05n84i00b1 1033 arn...@gm...-20080324153823-lhn3awurnu77riln 1034 arn...@gm...-20080324165650-zapppziji67yf5a2 1035 zouzou123gen-20080324175936-4mqc2kh0lo5wtdu2 1036 zouzou123gen-20080325004602-6wdsoym95mjuhwd3 1037 arn...@gm...-20080325100659-8fqy6q65itmghlep 1038 zouzou123gen-20080325175216-s297sdiucukfvijh 1039 arn...@gm...-20080325210137-3dfqyoi8ykosy087 1040 arn...@gm...-20080325211747-nwwy1eb33r071sca 1041 arn...@gm...-20080326084110-qbselrjckku275xi 1042 zouzou123gen-20080326123631-35642mgbk2i4ty32 1043 zouzou123gen-20080326124345-f4xwn2d3ty8ubd6r 1044 arn...@gm...-20080326162031-il0nyms30w0mky43 1045 arn...@gm...-20080326164801-8dru8mjc06xgzjpv 1046 arn...@gm...-20080326170438-uzl2rx8fqnohak7g 1047 zouzou123gen-20080326172821-d6uqcbmfb0c6rwlv 1048 arn...@gm...-20080326213257-qlgdh7m2712p2l0q 1049 arn...@gm...-20080326214313-ktnoekgk3s0wmatz 1050 arn...@gm...-20080326215256-0j1iqrf286b9g7zf 1051 arn...@gm...-20080327082121-hoi22wh1gwjdfbyd + 1027 arn...@gm...-20080323183926-schknwnkgeo7ivdn 1028 zouzou123gen-20080323220411-r8usuc3qxwuh7zsn 1029 zouzou123gen-20080323221249-0su72zaj13e706mk 1030 arn...@gm...-20080324140623-muba1dl46m000o8c 1031 zouzou123gen-20080324141933-qbgr93ugpe0297m6 1032 arn...@gm...-20080324153706-siidja05n84i00b1 1033 arn...@gm...-20080324153823-lhn3awurnu77riln 1034 arn...@gm...-20080324165650-zapppziji67yf5a2 1035 zouzou123gen-20080324175936-4mqc2kh0lo5wtdu2 1036 zouzou123gen-20080325004602-6wdsoym95mjuhwd3 1037 arn...@gm...-20080325100659-8fqy6q65itmghlep 1038 zouzou123gen-20080325175216-s297sdiucukfvijh 1039 arn...@gm...-20080325210137-3dfqyoi8ykosy087 1040 arn...@gm...-20080325211747-nwwy1eb33r071sca 1041 arn...@gm...-20080326084110-qbselrjckku275xi 1042 zouzou123gen-20080326123631-35642mgbk2i4ty32 1043 zouzou123gen-20080326124345-f4xwn2d3ty8ubd6r 1044 arn...@gm...-20080326162031-il0nyms30w0mky43 1045 arn...@gm...-20080326164801-8dru8mjc06xgzjpv 1046 arn...@gm...-20080326170438-uzl2rx8fqnohak7g 1047 zouzou123gen-20080326172821-d6uqcbmfb0c6rwlv 1048 arn...@gm...-20080326213257-qlgdh7m2712p2l0q 1049 arn...@gm...-20080326214313-ktnoekgk3s0wmatz 1050 arn...@gm...-20080326215256-0j1iqrf286b9g7zf 1051 arn...@gm...-20080327082121-hoi22wh1gwjdfbyd 1052 arn...@gm...-20080327120639-um3tukdt374rwvgm Modified: dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h 2008-03-29 07:12:57 UTC (rev 1076) +++ dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h 2008-03-29 07:13:41 UTC (rev 1077) @@ -178,16 +178,16 @@ typedef typename WidgetRadioButton::ObjectType WidgetRadioButtonPtr; /// WidgetChooseFolder class type. - typedef SmartWin::WidgetChooseFolder< SmartWin::Widget > WidgetChooseFolder; + typedef SmartWin::WidgetChooseFolder WidgetChooseFolder; /// LoadFileDialog class type. - typedef SmartWin::WidgetLoadFile< SmartWin::Widget > WidgetLoadFile; + typedef SmartWin::WidgetLoadFile WidgetLoadFile; /// SaveFileDialog class and object type. - typedef SmartWin::WidgetSaveFile< SmartWin::Widget > WidgetSaveFile; + typedef SmartWin::WidgetSaveFile WidgetSaveFile; /// WidgetChooseColor class and object type. - typedef SmartWin::WidgetChooseColor< SmartWin::Widget > WidgetChooseColor; + typedef SmartWin::WidgetChooseColor WidgetChooseColor; /// ComboBox class type. typedef SmartWin::WidgetComboBox WidgetComboBox; Modified: dcplusplus/trunk/smartwin/include/smartwin/WidgetFactoryPlatformSmartWinDesktop.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/WidgetFactoryPlatformSmartWinDesktop.h 2008-03-29 07:12:57 UTC (rev 1076) +++ dcplusplus/trunk/smartwin/include/smartwin/WidgetFactoryPlatformSmartWinDesktop.h 2008-03-29 07:13:41 UTC (rev 1077) @@ -63,7 +63,7 @@ typedef typename WidgetMenu::ObjectType WidgetMenuPtr; /// ChooseFont class and object type. - typedef SmartWin::WidgetChooseFont< SmartWin::Widget > WidgetChooseFont; + typedef SmartWin::WidgetChooseFont WidgetChooseFont; /// Toolbar class type. typedef SmartWin::WidgetToolbar WidgetToolbar; Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectFileFilter.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectFileFilter.h 2008-03-29 07:12:57 UTC (rev 1076) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectFileFilter.h 2008-03-29 07:13:41 UTC (rev 1077) @@ -37,12 +37,6 @@ { // begin namespace SmartWin -// DEVELOPERS RENOTE! -// This class is INTENTIONALLY inlined since some users might want to include this -// class without including the whole library! This way you can use the -// WidgetLoadFile && the WidgetSaveFile dialogs WITHOUT being forced to link -// against the COMPLETE library!! DON'T put this class into a library .cpp file!!! - /// Class for adding a filter to e.g. a WidgetLoadFile dialog. /** \ingroup AspectClasses * Class is an Aspect class which should be realized into classes that needs it. @@ -90,29 +84,6 @@ return itsActiveFilter + 1; } -protected: - AspectFileFilter() - : itsActiveFilter( 0 ) - {} - - SmartUtil::tstring filter() const - { - SmartUtil::tstring filter( itsFilter.begin(), itsFilter.end() ); - return filter; - } - -private: - std::vector< TCHAR > itsFilter; - unsigned int itsActiveFilter; -}; - -// Class that contains common things between the different WidgetXXXXFile classes. -// Among other things we have specializations that have lots of commonalities. -/// Class containing commonalities between WidgetLoadFile and WidgetSaveFile Widgets. -class WidgetFileCommon - : public virtual AspectFileFilter -{ -public: /// Sets the starting directory of the WidgetLoadFile or WidgetSaveFile Widget /** If given your dialog will try to start in the given directory, otherwise it * will use the working directory of the process. @@ -155,7 +126,12 @@ #endif } + protected: + AspectFileFilter() + : itsActiveFilter( 0 ) + {} + static const int PATH_BUFFER_SIZE = 32768; //really arbitrary, but 32K sounds reasonable. size in number of TCHARS! // Fills out the common members of the OPENFILENAME struct. @@ -170,7 +146,6 @@ ofn.hInstance = ::GetModuleHandle( 0 ); ofn.nMaxFile = PATH_BUFFER_SIZE; - itsFilter = this->filter(); // Remember that the filter needs to be accessible _after_ we return from this function... ofn.lpstrFilter = itsFilter.c_str(); ofn.nFilterIndex = this->getActiveFilter(); ofn.lpstrFileTitle = NULL; @@ -179,7 +154,9 @@ ofn.Flags = flags; // OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; } + private: + unsigned int itsActiveFilter; SmartUtil::tstring itsStartDir; SmartUtil::tstring itsFilter; }; Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseColor.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseColor.h 2008-03-29 07:12:57 UTC (rev 1076) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseColor.h 2008-03-29 07:13:41 UTC (rev 1077) @@ -28,9 +28,7 @@ #ifndef WidgetChooseColor_h #define WidgetChooseColor_h -#include "../WindowsHeaders.h" -#include "../FreeCommonDialog.h" -#include <memory> +#include "../Widget.h" namespace SmartWin { @@ -49,12 +47,11 @@ * This is one of few Widgets in SmartWin++ which can be used without linking in the * actual library! */ -template< class Parent > class WidgetChooseColor { public: /// Class type - typedef WidgetChooseColor< Parent > ThisType; + typedef WidgetChooseColor ThisType; /// Object type /** Note, not a pointer!!!! @@ -67,7 +64,7 @@ */ class ColorParams { - friend class WidgetChooseColor< Parent >; + friend class WidgetChooseColor; COLORREF itsColor; COLORREF itsCustomColors[16]; bool itsUserPressedOk; @@ -129,34 +126,23 @@ ColorParams showDialog( const ColorParams & colorParams, bool basic = true, bool allowFullOpen = true ); /// Expicit constructor taking pointer to parent - explicit WidgetChooseColor( Parent * parent = 0 ); + explicit WidgetChooseColor( Widget * parent = 0 ); virtual ~WidgetChooseColor() {} private: - Parent * itsParent; - - // Note! - // This one is STATIC which normally would be potentially dangerous in e.g. - // Multi Threaded environments, but since ColorParams is immutable in addition - // to that two different threads should never be allowed to manipulate GUI in - // Windows API this isn't dangerous after all... - static ColorParams itsColorParams; + ColorParams itsColorParams; + Widget* itsParent; + + HWND getParentHandle() { return itsParent ? itsParent->handle() : NULL; } }; -template< class Parent > -typename WidgetChooseColor< Parent >::ColorParams WidgetChooseColor< Parent >::itsColorParams; - -/// \ingroup GlobalStuff -/// A Free WidgetChooseColor dialog is a dialog which isn't "owned" by another Widget -typedef WidgetChooseColor< FreeCommonDialog > WidgetChooseColorFree; - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Implementation of class /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -template< class Parent > -WidgetChooseColor< Parent >::ColorParams::ColorParams() +inline +WidgetChooseColor::ColorParams::ColorParams() : itsColor( 0x0000FFFF ) , itsUserPressedOk( false ) { @@ -178,8 +164,7 @@ itsCustomColors[15] = 0x00997755; } -template< class Parent > -WidgetChooseColor< Parent >::ColorParams::ColorParams( COLORREF defaultColor ) +inline WidgetChooseColor::ColorParams::ColorParams( COLORREF defaultColor ) : itsColor( defaultColor ) , itsUserPressedOk( false ) { @@ -201,32 +186,28 @@ itsCustomColors[15] = 0x00997755; } -template< class Parent > -COLORREF WidgetChooseColor< Parent >::ColorParams::getColor() const +inline COLORREF WidgetChooseColor::ColorParams::getColor() const { return itsColor; } -template< class Parent > -WidgetChooseColor< Parent >::ColorParams::ColorParams( COLORREF defaultColor, COLORREF customColors[16] ) +inline WidgetChooseColor::ColorParams::ColorParams( COLORREF defaultColor, COLORREF customColors[16] ) : itsColor( defaultColor ) , itsUserPressedOk( false ) { - itsCustomColors = customColors; + memcpy(itsCustomColors, customColors, sizeof(itsCustomColors)); } -template< class Parent > -bool WidgetChooseColor< Parent >::ColorParams::userPressedOk() const +inline bool WidgetChooseColor::ColorParams::userPressedOk() const { return itsUserPressedOk; } -template< class Parent > -typename WidgetChooseColor< Parent >::ColorParams WidgetChooseColor< Parent >::showDialog( bool basic, bool allowFullOpen ) +inline WidgetChooseColor::ColorParams WidgetChooseColor::showDialog( bool basic, bool allowFullOpen ) { CHOOSECOLOR cc; cc.lStructSize = ( DWORD ) sizeof( CHOOSECOLOR ); - cc.hwndOwner = itsParent->handle(); + cc.hwndOwner = getParentHandle(); cc.hInstance = NULL; cc.rgbResult = itsColorParams.itsColor; cc.lpCustColors = itsColorParams.itsCustomColors; @@ -247,12 +228,10 @@ return itsColorParams; } -template< class Parent > -typename WidgetChooseColor< Parent >::ColorParams WidgetChooseColor< Parent >::showDialog( const ColorParams & colorParams, bool basic, bool allowFullOpen ) -{ +inline WidgetChooseColor::ColorParams WidgetChooseColor::showDialog( const ColorParams & colorParams, bool basic, bool allowFullOpen ){ CHOOSECOLOR cc; cc.lStructSize = ( DWORD ) sizeof( CHOOSECOLOR ); - cc.hwndOwner = itsParent->handle(); + cc.hwndOwner = getParentHandle(); cc.hInstance = NULL; cc.rgbResult = colorParams.itsColor; cc.lpCustColors = itsColorParams.itsCustomColors; @@ -273,8 +252,7 @@ return itsColorParams; } -template< class Parent > -WidgetChooseColor< Parent >::WidgetChooseColor( Parent * parent ) +inline WidgetChooseColor::WidgetChooseColor( Widget * parent ) : itsParent( parent ) { } Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseFolder.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseFolder.h 2008-03-29 07:12:57 UTC (rev 1076) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseFolder.h 2008-03-29 07:13:41 UTC (rev 1077) @@ -28,9 +28,8 @@ #ifndef WidgetChooseFolder_h #define WidgetChooseFolder_h -#include "../WindowsHeaders.h" +#include "../Widget.h" #include "../../SmartUtil.h" -#include "../FreeCommonDialog.h" #include <shlobj.h> namespace SmartWin @@ -48,12 +47,11 @@ * and HWND in the Parent template parameter. <br> * the complete signature of the function will then be "HWND parent()" */ -template< class Parent > class WidgetChooseFolder { public: /// Class type - typedef WidgetChooseFolder< Parent > ThisType; + typedef WidgetChooseFolder ThisType; /// Object type /** Note, not a pointer!!!! @@ -71,7 +69,7 @@ SmartUtil::tstring showDialog(); // Constructor Taking pointer to parent - explicit WidgetChooseFolder( Parent * parent = 0 ); + explicit WidgetChooseFolder( Widget * parent = 0 ); /// Sets the root directory in the WidgetChooseFolder Widget /** If given your dialog will try to start with the given directory as root, otherwise it @@ -102,60 +100,46 @@ itsStartDir = startDir; } - virtual ~WidgetChooseFolder() + ~WidgetChooseFolder() { + ::CoTaskMemFree(itsPidlRoot); } private: static int CALLBACK browseCallbackProc( HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData ) { - switch( uMsg ) - { - case BFFM_INITIALIZED: - ThisType* p = (ThisType*) lpData; - if( p->itsStartDir.size() > 0 ) - SendMessage( hwnd, BFFM_SETSELECTION, TRUE, (LPARAM) p->itsStartDir.c_str() ); - break; + if(lpData && uMsg == BFFM_INITIALIZED) { + ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData); } return 0; } - Parent * itsParent; + Widget* itsParent; SmartUtil::tstring itsTitleText; LPITEMIDLIST itsPidlRoot; SmartUtil::tstring itsStartDir; + + HWND getParentHandle() { return itsParent ? itsParent->handle() : NULL; } + }; -typedef WidgetChooseFolder< FreeCommonDialog > WidgetChooseFolderFree; - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Implementation of class /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -template< class Parent > -SmartUtil::tstring WidgetChooseFolder< Parent >::showDialog() +inline SmartUtil::tstring WidgetChooseFolder::showDialog() { - // WARNING! - // If you ONLY include THIS file then you must explicitly link to comctl32.lib - // since you won't get the default linking inclusion by the whole library!! - CoInitialize( 0 ); SmartUtil::tstring retVal = _T( "" ); - BROWSEINFO bws; - ZeroMemory( & bws, sizeof( bws ) ); + BROWSEINFO bws = { 0 }; bws.hwndOwner = itsParent->handle(); bws.pidlRoot = itsPidlRoot; bws.pszDisplayName = NULL; bws.lpszTitle = itsTitleText.c_str(); -#ifdef __WINE__ - bws.ulFlags = 0; // Wine 0.9.10 does not support the BIF_USENEWUI flag yet. -#else bws.ulFlags = BIF_USENEWUI; -#endif bws.lpfn = NULL; - bws.lParam = (LPARAM) this; + bws.lParam = !itsStartDir.empty() ? reinterpret_cast<LPARAM>(itsStartDir.c_str()) : 0; bws.lpfn = &browseCallbackProc; - LPITEMIDLIST lpIDL = NULL; - lpIDL = SHBrowseForFolder( & bws ); + LPITEMIDLIST lpIDL = SHBrowseForFolder( & bws ); if ( lpIDL ) { TCHAR temp_path[MAX_PATH + 1]; @@ -165,24 +149,14 @@ else retVal = temp_path; - LPMALLOC mal = NULL; - if ( SHGetMalloc( & mal ) == E_FAIL || !mal ) - free( lpIDL ); - else - { - mal->Free( lpIDL ); - mal->Release(); - } + ::CoTaskMemFree(lpIDL); } return retVal; } -template< class Parent > -WidgetChooseFolder< Parent >::WidgetChooseFolder( Parent * parent ) - : itsParent( parent ) +inline WidgetChooseFolder::WidgetChooseFolder( Widget * parent ) + : itsParent( parent ), itsPidlRoot(NULL) { - itsTitleText = _T( "" ); - itsPidlRoot = NULL; } // end namespace SmartWin Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseFont.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseFont.h 2008-03-29 07:12:57 UTC (rev 1076) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseFont.h 2008-03-29 07:13:41 UTC (rev 1077) @@ -29,10 +29,8 @@ #ifndef WidgetChooseFont_h #define WidgetChooseFont_h -#include "../WindowsHeaders.h" +#include "../Widget.h" #include "../resources/Font.h" -#include "../FreeCommonDialog.h" -#include <memory> namespace SmartWin { @@ -49,12 +47,11 @@ * an HWND on the template parameter class. <br> * the complete signature of the function will then be "HWND parent()" */ -template< class Parent > class WidgetChooseFont { public: /// Class type - typedef WidgetChooseFont< Parent > ThisType; + typedef WidgetChooseFont ThisType; /// Object type /** Note, not a pointer!!!! @@ -65,31 +62,26 @@ bool showDialog(DWORD dwFlags, LPLOGFONT lplf, DWORD& rgbColors); /// Constructor Taking pointer to parent - explicit WidgetChooseFont( Parent * parent = 0 ); + explicit WidgetChooseFont( Widget* parent = 0 ); virtual ~WidgetChooseFont() {} private: - Parent * itsParent; + Widget* itsParent; + + HWND getParentHandle() { return itsParent ? itsParent->handle() : NULL; } }; -/// \ingroup GlobalStuff -/// A Free WidgetChooseFont dialog is a dialog which isn't "owned" by another Widget -typedef WidgetChooseFont< FreeCommonDialog > WidgetChooseFontFree; - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Implementation of class /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -template< class Parent > -bool WidgetChooseFont< Parent >::showDialog(DWORD dwFlags, LPLOGFONT lplf, DWORD& rgbColors) +inline bool WidgetChooseFont::showDialog(DWORD dwFlags, LPLOGFONT lplf, DWORD& rgbColors) { - CHOOSEFONT cf; + CHOOSEFONT cf = { sizeof(CHOOSEFONT) }; // Initialize CHOOSEFONT - ZeroMemory( & cf, sizeof( CHOOSEFONT ) ); - cf.lStructSize = sizeof( CHOOSEFONT ); - cf.hwndOwner = itsParent->handle(); + cf.hwndOwner = getParentHandle(); cf.Flags = dwFlags | CF_INITTOLOGFONTSTRUCT; cf.lpLogFont = lplf; cf.rgbColors = rgbColors; @@ -103,8 +95,7 @@ return false; } -template< class Parent > -WidgetChooseFont< Parent >::WidgetChooseFont( Parent * parent ) +inline WidgetChooseFont::WidgetChooseFont( Widget * parent ) : itsParent( parent ) { } Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetLoadFile.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetLoadFile.h 2008-03-29 07:12:57 UTC (rev 1076) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetLoadFile.h 2008-03-29 07:13:41 UTC (rev 1077) @@ -28,9 +28,8 @@ #ifndef WidgetLoadFile_h #define WidgetLoadFile_h -#include "../WindowsHeaders.h" +#include "../Widget.h" #include "../../SmartUtil.h" -#include "../FreeCommonDialog.h" #include "../aspects/AspectFileFilter.h" #include <vector> @@ -55,14 +54,12 @@ * and HWND in the Parent template parameter. <br> * the complete signature of the function will then be "HWND parent()" */ -template< class Parent > class WidgetLoadFile - : public virtual AspectFileFilter, - public WidgetFileCommon + : public AspectFileFilter { public: /// Class type - typedef WidgetLoadFile< Parent > ThisType; + typedef WidgetLoadFile ThisType; /// Object type /** Note, not a pointer!!!! @@ -90,23 +87,18 @@ std::vector<SmartUtil::tstring> showDialogMultiSelect(); // Constructor Taking pointer to parent - explicit WidgetLoadFile( Parent * parent = 0 ); + explicit WidgetLoadFile( Widget * parent = 0 ); - virtual ~WidgetLoadFile() - {} + virtual ~WidgetLoadFile() { } private: - Parent * itsParent; + Widget * itsParent; + HWND getParentHandle() { return itsParent ? itsParent->handle() : NULL; } }; -/// \ingroup GlobalStuff -/// A Free WidgetLoadFile dialog is a dialog which isn't "owned" by another Widget -typedef WidgetLoadFile< FreeCommonDialog > WidgetLoadFileFree; - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Implementation of class /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -template< class Parent > -SmartUtil::tstring WidgetLoadFile< Parent >::showDialog() +inline SmartUtil::tstring WidgetLoadFile::showDialog() { TCHAR szFile[PATH_BUFFER_SIZE]; // buffer for file name szFile[0] = '\0'; @@ -117,7 +109,7 @@ // function... You MUST supply a parent with a function "handle()" which // returns a HWND! All the Widgetxxx classes (except LoadFile, SaveFile and // MessageBox) have the "handle()" function... - fillOutCommonStructure( ofn, itsParent->handle(), OFN_FILEMUSTEXIST ); + fillOutCommonStructure( ofn, getParentHandle(), OFN_FILEMUSTEXIST ); ofn.lpstrFile = szFile; ofn.Flags |= OFN_FILEMUSTEXIST; @@ -130,8 +122,7 @@ return retVal; } -template< class Parent > -std::vector<SmartUtil::tstring> WidgetLoadFile<Parent>::showDialogMultiSelect() +inline std::vector<SmartUtil::tstring> WidgetLoadFile::showDialogMultiSelect() { TCHAR szFile[PATH_BUFFER_SIZE]; // buffer for file name szFile[0] = '\0'; @@ -141,7 +132,7 @@ // If this one fizzles you have NOT supplied a parent with a "handle()" function... // You MUST supply a parent with a function "handle()" which returns a HWND! // All the Widgetxxx classes (except LoadFile, SaveFile and MessageBox) have the "handle()" function... - fillOutCommonStructure( ofn, itsParent->handle(), OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER ); + fillOutCommonStructure( ofn, getParentHandle(), OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER ); ofn.lpstrFile = szFile; std::vector<SmartUtil::tstring> retVal; if( ::GetOpenFileName(&ofn) ) @@ -174,8 +165,7 @@ return retVal; } -template< class Parent > -WidgetLoadFile< Parent >::WidgetLoadFile( Parent * parent ) +inline WidgetLoadFile::WidgetLoadFile( Widget * parent ) : itsParent( parent ) {} Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetMessageBox.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetMessageBox.h 2008-03-29 07:12:57 UTC (rev 1076) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetMessageBox.h 2008-03-29 07:13:41 UTC (rev 1077) @@ -117,7 +117,7 @@ * in the upper left corner ) */ RetVal show( const SmartUtil::tstring & body, - const SmartUtil::tstring & header = _T( "SmartWinMessageBox" ), + const SmartUtil::tstring & header = _T( "Message" ), Buttons buttons = BOX_OK, Icon icon = BOX_ICONINFORMATION ); Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetSaveFile.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetSaveFile.h 2008-03-29 07:12:57 UTC (rev 1076) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetSaveFile.h 2008-03-29 07:13:41 UTC (rev 1077) @@ -28,9 +28,8 @@ #ifndef WidgetSaveFile_h #define WidgetSaveFile_h -#include "../WindowsHeaders.h" +#include "../Widget.h" #include "../../SmartUtil.h" -#include "../FreeCommonDialog.h" #include "../aspects/AspectFileFilter.h" namespace SmartWin @@ -54,14 +53,12 @@ * arguments returning an HWND. <br> * the complete signature of the function will then be "HWND parent();" */ -template< class Parent > class WidgetSaveFile - : public virtual AspectFileFilter, - public WidgetFileCommon + : public AspectFileFilter { public: /// Class type - typedef WidgetSaveFile< Parent > ThisType; + typedef WidgetSaveFile ThisType; /// Object type /** Note, not a pointer!!!! @@ -75,24 +72,20 @@ SmartUtil::tstring showDialog(); /// Constructor Taking pointer to parent - explicit WidgetSaveFile( Parent * parent = 0 ); + explicit WidgetSaveFile( Widget * parent = 0 ); virtual ~WidgetSaveFile() {} private: - Parent * itsParent; + Widget * itsParent; + HWND getParentHandle() { return itsParent ? itsParent->handle() : NULL; } }; -/// \ingroup GlobalStuff -/// A Free WidgetSaveFile dialog is a dialog which isn't "owned" by another Widget -typedef WidgetSaveFile< FreeCommonDialog > WidgetSaveFileFree; - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Implementation of class /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -template< class Parent > -SmartUtil::tstring WidgetSaveFile< Parent >::showDialog() +inline SmartUtil::tstring WidgetSaveFile::showDialog() { TCHAR szFile[MAX_PATH + 1]; // buffer for file name szFile[0] = '\0'; @@ -103,7 +96,7 @@ // function... You MUST supply a parent with a function "handle()" which // returns a HWND! All the Widgetxxx classes (except LoadFile, SaveFile and // MessageBox) have the "handle()" function... - fillOutCommonStructure( ofn, itsParent->handle(), 0 ); // OFN_PATHMUSTEXIST ? + fillOutCommonStructure( ofn, getParentHandle(), 0 ); // OFN_PATHMUSTEXIST ? ofn.lpstrFile = szFile; SmartUtil::tstring retVal; @@ -115,8 +108,7 @@ return retVal; } -template< class Parent > -WidgetSaveFile< Parent >::WidgetSaveFile( Parent * parent ) +inline WidgetSaveFile::WidgetSaveFile( Widget * parent ) : itsParent( parent ) { } Modified: dcplusplus/trunk/smartwin/source/LibraryLoader.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/LibraryLoader.cpp 2008-03-29 07:12:57 UTC (rev 1076) +++ dcplusplus/trunk/smartwin/source/LibraryLoader.cpp 2008-03-29 07:13:41 UTC (rev 1077) @@ -120,9 +120,7 @@ LibraryLoader lib(_T("comctl32.dll")); DLLGETVERSIONPROC pDllGetVersion = (DLLGETVERSIONPROC)lib.getProcAddress(_T("DllGetVersion")); if(pDllGetVersion) { - DLLVERSIONINFO dvi; - ZeroMemory(&dvi, sizeof(dvi)); - dvi.cbSize = sizeof(dvi); + DLLVERSIONINFO dvi = { sizeof(dvi) }; if(SUCCEEDED((*pDllGetVersion)(&dvi))) return PACK_COMCTL_VERSION(dvi.dwMajorVersion, dvi.dwMinorVersion); } Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetTreeView.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetTreeView.cpp 2008-03-29 07:12:57 UTC (rev 1076) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetTreeView.cpp 2008-03-29 07:13:41 UTC (rev 1077) @@ -22,8 +22,7 @@ tv.hParent = parent; tv.hInsertAfter = TVI_LAST; - TVITEMEX t; - ZeroMemory( & t, sizeof( TVITEM ) ); + TVITEMEX t = { 0 }; t.mask = TVIF_TEXT; if ( param != 0 ) { Modified: dcplusplus/trunk/win32/WinUtil.cpp =================================================================== --- dcplusplus/trunk/win32/WinUtil.cpp 2008-03-29 07:12:57 UTC (rev 1076) +++ dcplusplus/trunk/win32/WinUtil.cpp 2008-03-29 07:13:41 UTC (rev 1077) @@ -413,10 +413,9 @@ bool WinUtil::browseDirectory(tstring& target, HWND owner /* = NULL */) { TCHAR buf[MAX_PATH]; - BROWSEINFO bi; LPMALLOC ma; - ZeroMemory(&bi, sizeof(bi)); + BROWSEINFO bi = { 0 }; bi.hwndOwner = owner; bi.pszDisplayName = buf; @@ -433,10 +432,8 @@ if(target.size() > 0 && target[target.size()-1] != _T('\\')) target+=_T('\\'); - if(::SHGetMalloc(&ma) != E_FAIL) { - ma->Free(pidl); - ma->Release(); - } + ::CoTaskMemFree(pidl); + return true; } return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |