From: <arn...@us...> - 2008-03-29 07:22:02
|
Revision: 1080 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=1080&view=rev Author: arnetheduck Date: 2008-03-29 00:22:00 -0700 (Sat, 29 Mar 2008) Log Message: ----------- Clean up color dialog some Modified Paths: -------------- dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h dcplusplus/trunk/win32/Appearance2Page.cpp Added Paths: ----------- dcplusplus/trunk/smartwin/include/smartwin/widgets/ColorDialog.h dcplusplus/trunk/smartwin/source/widgets/ColorDialog.cpp Removed Paths: ------------- dcplusplus/trunk/smartwin/include/smartwin/FreeCommonDialog.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseColor.h Property Changed: ---------------- dcplusplus/trunk/ Property changes on: dcplusplus/trunk ___________________________________________________________________ Name: bzr:revision-info - timestamp: 2008-03-27 22:58:31.127000093 +0100 committer: Jacek Sieka <arn...@gm...> properties: branch-nick: dcplusplus + timestamp: 2008-03-28 00:14:59.124000072 +0100 committer: Jacek Sieka <arn...@gm...> properties: branch-nick: dcplusplus Name: bzr:file-ids - smartwin/include/smartwin/widgets/FolderDialog.h 712@f586c4b0-9d0d-0410-bc51-f1fe239209fc:dcplusplus%2Ftrunk:smartwin%2Finclude%2Fsmartwin%2Fwidgets%2FWidgetChooseFolder.h smartwin/source/widgets/FolderDialog.cpp folderdialog.cpp-20080327215752-664xme4q5cf4ka0s-1 + smartwin/include/smartwin/widgets/ColorDialog.h 712@f586c4b0-9d0d-0410-bc51-f1fe239209fc:dcplusplus%2Ftrunk:smartwin%2Finclude%2Fsmartwin%2Fwidgets%2FWidgetChooseColor.h smartwin/source/widgets/ColorDialog.cpp colordialog.cpp-20080327231315-98woy23i6ubb6jui-4 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 1052 arn...@gm...-20080327120639-um3tukdt374rwvgm 1053 zouzou123gen-20080327130703-6vtek6uxy3vua543 1054 arn...@gm...-20080327215831-dmg5mkufskabwkro + 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 1053 zouzou123gen-20080327130703-6vtek6uxy3vua543 1054 arn...@gm...-20080327215831-dmg5mkufskabwkro 1055 arn...@gm...-20080327231459-cdztcv25alsuyqmf Deleted: dcplusplus/trunk/smartwin/include/smartwin/FreeCommonDialog.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/FreeCommonDialog.h 2008-03-29 07:16:04 UTC (rev 1079) +++ dcplusplus/trunk/smartwin/include/smartwin/FreeCommonDialog.h 2008-03-29 07:22:00 UTC (rev 1080) @@ -1,62 +0,0 @@ -/* - Copyright (c) 2005, Thomas Hansen - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the SmartWin++ nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -#ifndef FreeCommonDialog_h -#define FreeCommonDialog_h - -#include "WindowsHeaders.h" - -namespace SmartWin -{ -// begin namespace SmartWin - -/// Helper class for instantiating "free" common dialogs -/** If you need for instance a WidgetChooseColor with no particular parent then use - * this class as the Parent argument... Related classes: - * <ul> - * <li>WidgetChooseColor</li> - * <li>WidgetChooseFont</li> - * <li>WidgetLoadFile</li> - * <li>WidgetSaveFile</li> - * <li>WidgetMessageBox</li> - * </ul> - */ -class FreeCommonDialog -{ - FreeCommonDialog(); // To ensure we never instantiate it! -public: - /// Helper contract function needed by the Common Dialogs which can use this as - /// Parent - HWND handle() - { return 0; - } // Contract to dialog -}; - -// end namespace SmartWin -} - -#endif Modified: dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h 2008-03-29 07:16:04 UTC (rev 1079) +++ dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h 2008-03-29 07:22:00 UTC (rev 1080) @@ -32,7 +32,7 @@ #include "widgets/Button.h" #include "widgets/FolderDialog.h" #include "widgets/WidgetCheckBox.h" -#include "widgets/WidgetChooseColor.h" +#include "widgets/ColorDialog.h" #include "widgets/WidgetComboBox.h" #include "widgets/WidgetListView.h" #include "widgets/WidgetDateTimePicker.h" @@ -185,8 +185,8 @@ /// SaveFileDialog class and object type. typedef SmartWin::WidgetSaveFile WidgetSaveFile; - /// WidgetChooseColor class and object type. - typedef SmartWin::WidgetChooseColor WidgetChooseColor; + /// ColorDialog class and object type. + typedef SmartWin::ColorDialog ColorDialog; /// ComboBox class type. typedef SmartWin::WidgetComboBox WidgetComboBox; @@ -262,10 +262,10 @@ */ WidgetSaveFile createSaveFile(); - /// Creates a WidgetChooseColor and returns it. + /// Creates a ColorDialog and returns it. /** Usable to let user choose font from the system installed fonts. */ - WidgetChooseColor createChooseColor(); + ColorDialog createColorDialog(); // TODO: Update, this isn't an automated collected Widget anymore... /// Creates a Message Box and returns a pointer to it. @@ -500,10 +500,10 @@ } template<typename ContainerWidgetType> -typename WidgetFactory< ContainerWidgetType >::WidgetChooseColor -WidgetFactory< ContainerWidgetType >::createChooseColor() +typename WidgetFactory< ContainerWidgetType >::ColorDialog +WidgetFactory< ContainerWidgetType >::createColorDialog() { - return WidgetChooseColor( this ); + return ColorDialog( this ); } template<typename ContainerWidgetType> Copied: dcplusplus/trunk/smartwin/include/smartwin/widgets/ColorDialog.h (from rev 1079, dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseColor.h) =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/ColorDialog.h (rev 0) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/ColorDialog.h 2008-03-29 07:22:00 UTC (rev 1080) @@ -0,0 +1,140 @@ +/* + Copyright ( c ) 2005, Thomas Hansen + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met : + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the SmartWin++ nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + ( INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#ifndef ColorDialog_h +#define ColorDialog_h + +#include "../Widget.h" + +namespace SmartWin +{ +// begin namespace SmartWin + +/// ChooseColorDialog class +/** \ingroup WidgetControls + * \image html choosecolor.png + * Class for showing a common ChooseColorDialog box. <br> + * Either derive from it or call WidgetFactory::createColorDialog. <br> + * Note! <br> + * If you wish to use this class with EventHandlerClass classes other than those from + * SmartWin you need to expose a public function called "parent" taking no arguments + * returning an HWND. <br> + * the complete signature of the function will then be "HWND parent()" <br> + * This is one of few Widgets in SmartWin++ which can be used without linking in the + * actual library! + */ +class ColorDialog +{ +public: + /// Class type + typedef ColorDialog ThisType; + + /// Object type + /** Note, not a pointer!!!! + */ + typedef ThisType ObjectType; + + /// Helper class for ColorDialog + /** Is used as the parameter to the ColorDialog to set the custom colors + * and to set the initially default color + */ + class ColorParams + { + friend class ColorDialog; + COLORREF itsColor; + COLORREF itsCustomColors[16]; + + public: + /// Default constructor + /** Initializes custom colors to "usable colors" and default color to yellow. + */ + ColorParams(); + + /// Overloaded constructor taking only default color + /** Initializes custom colors to "usable colors" and default color to the + * given color. + */ + ColorParams( COLORREF defaultColor ); + + /// Overloaded constructor taking default color and custom color + /** Initializes custom colors and default color to whatever is passed in + */ + ColorParams( COLORREF defaultColor, COLORREF customColors[16] ); + + /// Returns the currently selected color + COLORREF getColor() const; + }; + + /// Shows the Choose Color Dialog + /** Returns a ColorParams object, if user presses Ok the userPressedOk will be + * true, else if user pressed Cancel the userPressedOk obviously will be false. + * <br> + * This dialog "remembers" its state from call to call. If you manipulate the + * Custom Colors, the next time it displays, it will have the same Custom + * Colors. <br> + * Note! <br> + * This is true even across DIFFERENT instances of the dialog!! <br> + * If basic is true dialog will be showed with only basic functionality, if + * allowFullOpen is true dialog will allow the user to show "more info". + */ + bool open( ColorParams& params, bool basic = true, bool allowFullOpen = true ); + + /// Expicit constructor taking pointer to parent + explicit ColorDialog( Widget * parent = 0 ); + + ~ColorDialog() { } + +private: + ColorParams itsColorParams; + Widget* itsParent; + + HWND getParentHandle() { return itsParent ? itsParent->handle() : NULL; } +}; + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Implementation of class +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +inline COLORREF ColorDialog::ColorParams::getColor() const +{ + return itsColor; +} + +inline ColorDialog::ColorParams::ColorParams( COLORREF defaultColor, COLORREF customColors[16] ) + : itsColor( defaultColor ) +{ + memcpy(itsCustomColors, customColors, sizeof(itsCustomColors)); +} + +inline ColorDialog::ColorDialog( Widget * parent ) + : itsParent( parent ) +{ +} + +// end namespace SmartWin +} + +#endif Deleted: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseColor.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseColor.h 2008-03-29 07:16:04 UTC (rev 1079) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseColor.h 2008-03-29 07:22:00 UTC (rev 1080) @@ -1,263 +0,0 @@ -/* - Copyright ( c ) 2005, Thomas Hansen - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met : - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the SmartWin++ nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - ( INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -#ifndef WidgetChooseColor_h -#define WidgetChooseColor_h - -#include "../Widget.h" - -namespace SmartWin -{ -// begin namespace SmartWin - -/// ChooseColorDialog class -/** \ingroup WidgetControls - * \image html choosecolor.png - * Class for showing a common ChooseColorDialog box. <br> - * Either derive from it or call WidgetFactory::createChooseColor. <br> - * Note! <br> - * If you wish to use this class with EventHandlerClass classes other than those from - * SmartWin you need to expose a public function called "parent" taking no arguments - * returning an HWND. <br> - * the complete signature of the function will then be "HWND parent()" <br> - * This is one of few Widgets in SmartWin++ which can be used without linking in the - * actual library! - */ -class WidgetChooseColor -{ -public: - /// Class type - typedef WidgetChooseColor ThisType; - - /// Object type - /** Note, not a pointer!!!! - */ - typedef ThisType ObjectType; - - /// Helper class for WidgetChooseColor - /** Is used as the parameter to the WidgetChooseColor to set the custom colors - * and to set the initially default color - */ - class ColorParams - { - friend class WidgetChooseColor; - COLORREF itsColor; - COLORREF itsCustomColors[16]; - bool itsUserPressedOk; - - public: - /// Default constructor - /** Initializes custom colors to "usable colors" and default color to yellow. - */ - ColorParams(); - - /// Overloaded constructor taking only default color - /** Initializes custom colors to "usable colors" and default color to the - * given color. - */ - ColorParams( COLORREF defaultColor ); - - /// Overloaded constructor taking default color and custom color - /** Initializes custom colors and default color to whatever is passed in - */ - ColorParams( COLORREF defaultColor, COLORREF customColors[16] ); - - /// Returns the currently selected color - COLORREF getColor() const; - - /// True if user pressed Ok in dialog - /** Use this one to determine if the user action was "OK". If user pressed - * cancel in the dialog this function will return false! - */ - bool userPressedOk() const; - }; - - /// Shows the Choose Color Dialog - /** Returns a ColorParams object, if user presses Ok the userPressedOk will be - * true, else if user pressed Cancel the userPressedOk obviously will be false. - * <br> - * This dialog "remembers" its state from call to call. If you manipulate the - * Custom Colors, the next time it displays, it will have the same Custom - * Colors. <br> - * Note! <br> - * This is true even across DIFFERENT instances of the dialog!! <br> - * If basic is true dialog will be showed with only basic functionality, if - * allowFullOpen is true dialog will allow the user to show "more info". - */ - ColorParams showDialog( bool basic = true, bool allowFullOpen = true ); - - /// Shows the Choose Color Dialog - /** Returns a ColorParams object, if user presses Ok the userPressedOk will be - * true, else if user pressed Cancel the userPressedOk obviously will be false. - * <br> - * Note! <br> - * This function "resets" the remembered state of the dialog meaning if you've - * manipulated the "remembered" state the colorParams object will be the next - * state if you press ok! <br> - * If you press Cancel the "old" state ( either default one or from a previous - * call to this or sibling function will become it's "current state" ) <br> - * If basic is true dialog will be showed with only basic functionality, if - * allowFullOpen is true dialog will allow the user to show "more info". - */ - ColorParams showDialog( const ColorParams & colorParams, bool basic = true, bool allowFullOpen = true ); - - /// Expicit constructor taking pointer to parent - explicit WidgetChooseColor( Widget * parent = 0 ); - - virtual ~WidgetChooseColor() - {} - -private: - ColorParams itsColorParams; - Widget* itsParent; - - HWND getParentHandle() { return itsParent ? itsParent->handle() : NULL; } -}; - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Implementation of class -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -inline -WidgetChooseColor::ColorParams::ColorParams() - : itsColor( 0x0000FFFF ) - , itsUserPressedOk( false ) -{ - itsCustomColors[0] = 0x00000000; - itsCustomColors[1] = 0x33333333; - itsCustomColors[2] = 0x66666666; - itsCustomColors[3] = 0x99999999; - itsCustomColors[4] = 0xCCCCCCCC; - itsCustomColors[5] = 0xFFFFFFFF; - itsCustomColors[6] = 0x0000FFFF; - itsCustomColors[7] = 0x000000FF; - itsCustomColors[8] = 0x0000FF00; - itsCustomColors[9] = 0x00FF0000; - itsCustomColors[10] = 0x00FFFF00; - itsCustomColors[11] = 0x00FF00FF; - itsCustomColors[12] = 0x002244BB; - itsCustomColors[13] = 0x0000CC99; - itsCustomColors[14] = 0x00AA7700; - itsCustomColors[15] = 0x00997755; -} - -inline WidgetChooseColor::ColorParams::ColorParams( COLORREF defaultColor ) - : itsColor( defaultColor ) - , itsUserPressedOk( false ) -{ - itsCustomColors[0] = 0x00000000; - itsCustomColors[1] = 0x33333333; - itsCustomColors[2] = 0x66666666; - itsCustomColors[3] = 0x99999999; - itsCustomColors[4] = 0xCCCCCCCC; - itsCustomColors[5] = 0xFFFFFFFF; - itsCustomColors[6] = 0x0000FFFF; - itsCustomColors[7] = 0x000000FF; - itsCustomColors[8] = 0x0000FF00; - itsCustomColors[9] = 0x00FF0000; - itsCustomColors[10] = 0x00FFFF00; - itsCustomColors[11] = 0x00FF00FF; - itsCustomColors[12] = 0x002244BB; - itsCustomColors[13] = 0x0000CC99; - itsCustomColors[14] = 0x00AA7700; - itsCustomColors[15] = 0x00997755; -} - -inline COLORREF WidgetChooseColor::ColorParams::getColor() const -{ - return itsColor; -} - -inline WidgetChooseColor::ColorParams::ColorParams( COLORREF defaultColor, COLORREF customColors[16] ) - : itsColor( defaultColor ) - , itsUserPressedOk( false ) -{ - memcpy(itsCustomColors, customColors, sizeof(itsCustomColors)); -} - -inline bool WidgetChooseColor::ColorParams::userPressedOk() const -{ - return itsUserPressedOk; -} - -inline WidgetChooseColor::ColorParams WidgetChooseColor::showDialog( bool basic, bool allowFullOpen ) -{ - CHOOSECOLOR cc; - cc.lStructSize = ( DWORD ) sizeof( CHOOSECOLOR ); - cc.hwndOwner = getParentHandle(); - cc.hInstance = NULL; - cc.rgbResult = itsColorParams.itsColor; - cc.lpCustColors = itsColorParams.itsCustomColors; - cc.Flags = CC_ANYCOLOR | CC_RGBINIT; - if ( !basic ) - cc.Flags |= CC_FULLOPEN; - if ( !allowFullOpen ) - cc.Flags |= CC_PREVENTFULLOPEN; - cc.lCustData = 0; - cc.lpfnHook = 0; - cc.lpTemplateName = NULL; - - itsColorParams.itsUserPressedOk = ::ChooseColor( & cc ) == TRUE; - if ( itsColorParams.itsUserPressedOk ) - { - itsColorParams.itsColor = cc.rgbResult; - } - return itsColorParams; -} - -inline WidgetChooseColor::ColorParams WidgetChooseColor::showDialog( const ColorParams & colorParams, bool basic, bool allowFullOpen ){ - CHOOSECOLOR cc; - cc.lStructSize = ( DWORD ) sizeof( CHOOSECOLOR ); - cc.hwndOwner = getParentHandle(); - cc.hInstance = NULL; - cc.rgbResult = colorParams.itsColor; - cc.lpCustColors = itsColorParams.itsCustomColors; - cc.Flags = CC_ANYCOLOR | CC_RGBINIT; - if ( !basic ) - cc.Flags |= CC_FULLOPEN; - if ( !allowFullOpen ) - cc.Flags |= CC_PREVENTFULLOPEN; - cc.lCustData = NULL; - cc.lpfnHook = NULL; - cc.lpTemplateName = NULL; - - itsColorParams.itsUserPressedOk = ::ChooseColor( & cc ) == TRUE; - if ( itsColorParams.itsUserPressedOk ) - { - itsColorParams.itsColor = cc.rgbResult; - } - return itsColorParams; -} - -inline WidgetChooseColor::WidgetChooseColor( Widget * parent ) - : itsParent( parent ) -{ -} - -// end namespace SmartWin -} - -#endif Added: dcplusplus/trunk/smartwin/source/widgets/ColorDialog.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/ColorDialog.cpp (rev 0) +++ dcplusplus/trunk/smartwin/source/widgets/ColorDialog.cpp 2008-03-29 07:22:00 UTC (rev 1080) @@ -0,0 +1,47 @@ +#include "../../include/smartwin/widgets/ColorDialog.h" + +namespace SmartWin { + +bool ColorDialog::open( ColorParams & colorParams, bool basic, bool allowFullOpen ) { + CHOOSECOLOR cc; + cc.lStructSize = ( DWORD ) sizeof( CHOOSECOLOR ); + cc.hwndOwner = getParentHandle(); + cc.hInstance = NULL; + cc.rgbResult = colorParams.itsColor; + cc.lpCustColors = itsColorParams.itsCustomColors; + cc.Flags = CC_ANYCOLOR | CC_RGBINIT; + if ( !basic ) + cc.Flags |= CC_FULLOPEN; + if ( !allowFullOpen ) + cc.Flags |= CC_PREVENTFULLOPEN; + cc.lCustData = NULL; + cc.lpfnHook = NULL; + cc.lpTemplateName = NULL; + + if(::ChooseColor( & cc ) == TRUE) { + colorParams.itsColor = cc.rgbResult; + return true; + } + return false; +} + +COLORREF defaultColors[16] = { + 0x00000000, 0x33333333, 0x66666666, 0x99999999, + 0xCCCCCCCC, 0xFFFFFFFF, 0x0000FFFF, 0x000000FF, + 0x0000FF00, 0x00FF0000, 0x00FFFF00, 0x00FF00FF, + 0x002244BB, 0x0000CC99, 0x00AA7700, 0x00997755 +}; + +ColorDialog::ColorParams::ColorParams() + : itsColor( 0x0000FFFF ) +{ + memcpy(itsCustomColors, defaultColors, sizeof(itsCustomColors)); +} + +ColorDialog::ColorParams::ColorParams( COLORREF defaultColor ) + : itsColor( defaultColor ) +{ + memcpy(itsCustomColors, defaultColors, sizeof(itsCustomColors)); +} + +} Modified: dcplusplus/trunk/win32/Appearance2Page.cpp =================================================================== --- dcplusplus/trunk/win32/Appearance2Page.cpp 2008-03-29 07:16:04 UTC (rev 1079) +++ dcplusplus/trunk/win32/Appearance2Page.cpp 2008-03-29 07:22:00 UTC (rev 1080) @@ -116,9 +116,8 @@ } void Appearance2Page::handleBackgroundClicked() { - WidgetChooseColor::ColorParams initialColorParams(bg), - colorParams = createChooseColor().showDialog(initialColorParams); - if(colorParams.userPressedOk()) { + ColorDialog::ColorParams colorParams(bg); + if(createColorDialog().open(colorParams)) { bg = colorParams.getColor(); example->setColor(fg, bg); example->invalidateWidget(); @@ -139,17 +138,17 @@ } void Appearance2Page::handleULClicked() { - WidgetChooseColor::ColorParams initialColorParams(upBar), - colorParams = createChooseColor().showDialog(initialColorParams); - if(colorParams.userPressedOk()) + ColorDialog::ColorParams colorParams(upBar); + if(createColorDialog().open(colorParams)) { upBar = colorParams.getColor(); + } } void Appearance2Page::handleDLClicked() { - WidgetChooseColor::ColorParams initialColorParams(downBar), - colorParams = createChooseColor().showDialog(initialColorParams); - if(colorParams.userPressedOk()) + ColorDialog::ColorParams colorParams(downBar); + if(createColorDialog().open(colorParams)) { downBar = colorParams.getColor(); + } } void Appearance2Page::handleBrowseClicked() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |