From: <arn...@us...> - 2008-03-29 06:09:17
|
Revision: 1069 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=1069&view=rev Author: arnetheduck Date: 2008-03-28 23:09:14 -0700 (Fri, 28 Mar 2008) Log Message: ----------- Split off min/max Modified Paths: -------------- dcplusplus/trunk/smartwin/include/smartwin/Policies.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectControl.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSizable.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetWindowBase.h Added Paths: ----------- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectMinMax.h Property Changed: ---------------- dcplusplus/trunk/ Property changes on: dcplusplus/trunk ___________________________________________________________________ Name: bzr:revision-info - timestamp: 2008-03-26 13:43:45.282999992 +0100 committer: zouzou123gen properties: branch-nick: bzr + timestamp: 2008-03-26 17:20:31.842000008 +0100 committer: Jacek Sieka <arn...@gm...> properties: branch-nick: dcplusplus Name: bzr:file-ids - + smartwin/include/smartwin/aspects/AspectMinMax.h aspectminmax.h-20080326161823-8s7owo1xy79ij3ve-1 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 + 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 Modified: dcplusplus/trunk/smartwin/include/smartwin/Policies.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/Policies.h 2008-03-29 06:08:36 UTC (rev 1068) +++ dcplusplus/trunk/smartwin/include/smartwin/Policies.h 2008-03-29 06:09:14 UTC (rev 1069) @@ -37,6 +37,8 @@ template<typename Policy> class MessageMapPolicy : public Policy { public: + typedef MessageMapPolicy<Policy> PolicyType; + MessageMapPolicy(Widget* parent) : Policy(parent) { } static LRESULT CALLBACK wndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectControl.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectControl.h 2008-03-29 06:08:36 UTC (rev 1068) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectControl.h 2008-03-29 06:09:14 UTC (rev 1069) @@ -37,9 +37,6 @@ /// Object type typedef ThisType* ObjectType; - - /// Policy type - typedef MessageMapPolicy<Policies::Subclassed> PolicyType; unsigned int getControlId(); Added: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectMinMax.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectMinMax.h (rev 0) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectMinMax.h 2008-03-29 06:09:14 UTC (rev 1069) @@ -0,0 +1,115 @@ +/* + 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 AspectMinMax_h +#define AspectMinMax_h + +#include "../Widget.h" +#include "../Place.h" +#include "../xCeption.h" +#include "../Dispatchers.h" +#include "../Events.h" + +namespace SmartWin +{ +// begin namespace SmartWin + +/// \ingroup AspectClasses +/// \ingroup WidgetLayout +/// Aspect class used by Widgets that have the possibility of setting and getting a +/// "size" property of their objects. +/** E.g. the WidgetTextBox have a "size" Aspect therefore it realizes the + * AspectMinMax through inheritance. <br> + * Note! <br> + * All coordinates have zenith top-left corner of either the desktop display or the + * client area of the parent Widget. <br> + * Note! <br> + * There are two different ways to calculate the position of a Widget, one is in + * screen coordinates which starts top left of the desktop window, the other way is + * relative to its parent Widget which starts at the top left of the parent Widgets + * client area which is the total area of the Widget after the border, menu, toolbar + * etc have been taken away. <br> + * In addition all bounding Rectangles dealt with through this class are giving + * their down right coordinates in SIZES and not in POSITIONS! + */ +template< class WidgetType > +class AspectMinMax +{ + WidgetType& W() { return *static_cast<WidgetType*>(this); } + const WidgetType& W() const { return *static_cast<const WidgetType*>(this); } + + HWND H() const { return W().handle(); } + +public: + /// Maximize your window + /** This will make the window fill the whole area that the window has available. + * <br> + * This function cannot be called for any Widget types other than those derived + * from WidgetWindowBase. + */ + void maximize(); + + /// Minimize your window + /** This will make the window become minimized. <br> + * This function cannot be called for any Widget types other than those derived + * from WidgetWindowBase. + */ + void minimize(); + + /// Restores your window + /** This will make the window become restored. <br> + * This function cannot be called for any Widget types other than those derived + * from WidgetWindowBase. + */ + void restore(); + +protected: + virtual ~AspectMinMax() { } +}; + +template< class WidgetType > +void AspectMinMax< WidgetType >::maximize() +{ + ::ShowWindow(H(), SW_SHOWMAXIMIZED ); +} + +template< class WidgetType > +void AspectMinMax< WidgetType >::minimize() +{ + ::ShowWindow(H(), SW_MINIMIZE ); +} + +template< class WidgetType > +void AspectMinMax< WidgetType >::restore() +{ + ::ShowWindow(H(), SW_RESTORE ); +} + +// end namespace SmartWin +} + +#endif Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSizable.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSizable.h 2008-03-29 06:08:36 UTC (rev 1068) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSizable.h 2008-03-29 06:09:14 UTC (rev 1069) @@ -196,28 +196,6 @@ */ Point getTextSize( const SmartUtil::tstring & text ); - /// Maximize your window - /** This will make the window fill the whole area that the window has available. - * <br> - * This function cannot be called for any Widget types other than those derived - * from WidgetWindowBase. - */ - void maximize(); - - /// Minimize your window - /** This will make the window become minimized. <br> - * This function cannot be called for any Widget types other than those derived - * from WidgetWindowBase. - */ - void minimize(); - - /// Restores your window - /** This will make the window become restored. <br> - * This function cannot be called for any Widget types other than those derived - * from WidgetWindowBase. - */ - void restore(); - /// Brings the widget to the front /** Makes the widget become the front most widget meaning it will not be obscured * by other widgets which are contained in the same container widget. <br> @@ -416,7 +394,6 @@ return this->getBounds().pos; } - template< class WidgetType > Point AspectSizable< WidgetType >::getScreenPosition() const { @@ -425,8 +402,6 @@ return Point( rc.left, rc.top ); } - - template< class WidgetType > Point AspectSizable< WidgetType >::getClientAreaSize() const { @@ -456,48 +431,6 @@ } template< class WidgetType > -void AspectSizable< WidgetType >::maximize() -{ - // Magic Enum construct!! - // If you get a compile time error in the next line you are trying to maximize - // a window which doesn't support being maximized, e.g. a WidgetButton or WidgetTreeView -#ifdef _MSC_VER - typename WidgetType::MaxiMiniRestorable; -#else - typename WidgetType::MaxiMiniRestorable checker; -#endif - ::ShowWindow(H(), SW_SHOWMAXIMIZED ); -} - -template< class WidgetType > -void AspectSizable< WidgetType >::minimize() -{ - // Magic Enum construct!! - // If you get a compile time error in the next line you are trying to minimize - // a window which soesn't support being minimized, e.g. a WidgetButton or WidgetTreeView -#ifdef _MSC_VER - typename WidgetType::MaxiMiniRestorable; -#else - typename WidgetType::MaxiMiniRestorable checker; -#endif - ::ShowWindow(H(), SW_MINIMIZE ); -} - -template< class WidgetType > -void AspectSizable< WidgetType >::restore() -{ - // Magic Enum construct!! - // If you get a compile time error in the next line you are trying to restore - // a window which soesn't support being restored, e.g. a WidgetButton or WidgetTreeView -#ifdef _MSC_VER - typename WidgetType::MaxiMiniRestorable; -#else - typename WidgetType::MaxiMiniRestorable checker; -#endif - ::ShowWindow(H(), SW_RESTORE ); -} - -template< class WidgetType > void AspectSizable< WidgetType >::bringToFront() { ::SetWindowPos(H(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetWindowBase.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetWindowBase.h 2008-03-29 06:08:36 UTC (rev 1068) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetWindowBase.h 2008-03-29 06:09:14 UTC (rev 1069) @@ -42,6 +42,7 @@ #include "../aspects/AspectFont.h" #include "../aspects/AspectHelp.h" #include "../aspects/AspectKeyboard.h" +#include "../aspects/AspectMinMax.h" #include "../aspects/AspectMouse.h" #include "../aspects/AspectPainting.h" #include "../aspects/AspectRaw.h" @@ -96,6 +97,7 @@ public AspectFont< WidgetWindowBase< Policy > >, public AspectHelp< WidgetWindowBase< Policy > >, public AspectKeyboard< WidgetWindowBase< Policy > >, + public AspectMinMax<WidgetWindowBase<Policy> >, public AspectMouse< WidgetWindowBase< Policy > >, public AspectPainting< WidgetWindowBase< Policy > >, public AspectRaw< WidgetWindowBase< Policy > >, @@ -151,14 +153,6 @@ typedef MessageMapPolicy< Policy > PolicyType; - // The next line must be included in Widgets that are supposed to support being - // Maximized, Minimized or Restored. It's a Magic Enum construct and can be - // read about at - // http://blog.notus.no/thomas/PermaLink.aspx?guid=c311fe7e-40d5-48a2-baa3-f69957d5f313 - // The enum is dereferenced in AspectSizable::restore/minimize/maximize - enum MaxiMiniRestorable - {}; - // TODO: Outfactor into WidgetClosable /// Event Handler setter for the Closing Event /** If supplied event handler is called before the window is closed. <br> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |