From: <arn...@us...> - 2008-04-07 18:56:54
|
Revision: 1102 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=1102&view=rev Author: arnetheduck Date: 2008-04-07 11:56:50 -0700 (Mon, 07 Apr 2008) Log Message: ----------- Move child windows where they belong in the inheritance structure Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/smartwin/include/smartwin/WidgetCreator.h dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h dcplusplus/trunk/smartwin/include/smartwin/widgets/Control.h dcplusplus/trunk/smartwin/include/smartwin/widgets/Frame.h dcplusplus/trunk/smartwin/include/smartwin/widgets/MDIFrame.h dcplusplus/trunk/smartwin/include/smartwin/widgets/TabSheet.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h dcplusplus/trunk/smartwin/include/smartwin/widgets/Window.h dcplusplus/trunk/smartwin/source/widgets/MDIFrame.cpp dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp dcplusplus/trunk/win32/MDIChildFrame.h dcplusplus/trunk/win32/MainWindow.cpp dcplusplus/trunk/win32/MainWindow.h dcplusplus/trunk/win32/MainWindowFactory.cpp dcplusplus/trunk/win32/SplashWindow.cpp dcplusplus/trunk/win32/TransferView.cpp dcplusplus/trunk/win32/TransferView.h dcplusplus/trunk/win32/WinUtil.cpp Added Paths: ----------- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectCloseable.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectTimer.h dcplusplus/trunk/smartwin/include/smartwin/widgets/Composite.h dcplusplus/trunk/smartwin/include/smartwin/widgets/Container.h dcplusplus/trunk/smartwin/source/widgets/ModalDialog.cpp dcplusplus/trunk/smartwin/source/widgets/ModelessDialog.cpp dcplusplus/trunk/smartwin/source/widgets/Window.cpp Removed Paths: ------------- dcplusplus/trunk/smartwin/source/widgets/WidgetDialog.cpp dcplusplus/trunk/smartwin/source/widgets/WidgetModalDialog.cpp dcplusplus/trunk/smartwin/source/widgets/WidgetWindow.cpp Property Changed: ---------------- dcplusplus/trunk/ Property changes on: dcplusplus/trunk ___________________________________________________________________ Name: bzr:revision-info - timestamp: 2008-03-31 17:25:13.130000114 +0200 committer: zouzou123gen properties: branch-nick: bzr bugs: https://launchpad.net/bugs/209684 fixed + timestamp: 2008-03-31 20:44:36.398000002 +0200 committer: Jacek Sieka <arn...@gm...> properties: branch-nick: dcplusplus Name: bzr:file-ids - + smartwin/include/smartwin/aspects/AspectCloseable.h aspectcloseable.h-20080331184314-ain6peu31zweti0t-1 smartwin/include/smartwin/aspects/AspectTimer.h aspecttimer.h-20080331184314-ain6peu31zweti0t-2 smartwin/include/smartwin/widgets/Composite.h composite.h-20080331184314-ain6peu31zweti0t-3 smartwin/include/smartwin/widgets/Container.h container.h-20080331184314-ain6peu31zweti0t-4 smartwin/source/widgets/ModalDialog.cpp 800@f586c4b0-9d0d-0410-bc51-f1fe239209fc:dcplusplus%2Ftrunk:smartwin%2Fsource%2Fwidgets%2FWidgetModalDialog.cpp smartwin/source/widgets/ModelessDialog.cpp 800@f586c4b0-9d0d-0410-bc51-f1fe239209fc:dcplusplus%2Ftrunk:smartwin%2Fsource%2Fwidgets%2FWidgetDialog.cpp smartwin/source/widgets/Window.cpp 800@f586c4b0-9d0d-0410-bc51-f1fe239209fc:dcplusplus%2Ftrunk:smartwin%2Fsource%2Fwidgets%2FWidgetWindow.cpp 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 1055 arn...@gm...-20080327231459-cdztcv25alsuyqmf 1056 arn...@gm...-20080328085925-gceybsr53oml1p24 1057 arn...@gm...-20080328200512-1sjuu6bcnl2dyd2a 1058 arn...@gm...-20080328210347-bussqjrm5mfswh7o 1059 arn...@gm...-20080329055630-braiir1dskv7a4qm 1060 arn...@gm...-20080329061558-rck8dz60wpj3c5ja 1061 arn...@gm...-20080329081253-if6o5jn329mbzfpl 1062 arn...@gm...-20080329081619-cb4x930j8sp55cs0 1063 arn...@gm...-20080329103216-hgjzo7ra2zixbztd 1064 arn...@gm...-20080329124042-q3aw4iodmo5kafyp 1065 arn...@gm...-20080329124926-2je1z18p0272zpua 1066 arn...@gm...-20080329150901-ehj9t32en7eps2dp 1067 zouzou123gen-20080329153653-36xlvpik2ns9r84r 1068 zouzou123gen-20080329162703-51xr8hg073pg7wq5 1069 zouzou123gen-20080329234706-8ddipdqu0xeudkql 1070 arn...@gm...-20080330081232-ubqr1171ewalrd4q 1071 zouzou123gen-20080330131607-yppbs3mgyjef1cux 1072 zouzou123gen-20080330134835-yv1nogy77ib1uehd 1073 zouzou123gen-20080331124549-alyw7vugdn30piqy 1074 zouzou123gen-20080331135108-q8frtqsin5bosfzm 1075 zouzou123gen-20080331140757-u94q52yccl5lsifk 1076 zouzou123gen-20080331152513-ue1x5qhigcw51348 + 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 1056 arn...@gm...-20080328085925-gceybsr53oml1p24 1057 arn...@gm...-20080328200512-1sjuu6bcnl2dyd2a 1058 arn...@gm...-20080328210347-bussqjrm5mfswh7o 1059 arn...@gm...-20080329055630-braiir1dskv7a4qm 1060 arn...@gm...-20080329061558-rck8dz60wpj3c5ja 1061 arn...@gm...-20080329081253-if6o5jn329mbzfpl 1062 arn...@gm...-20080329081619-cb4x930j8sp55cs0 1063 arn...@gm...-20080329103216-hgjzo7ra2zixbztd 1064 arn...@gm...-20080329124042-q3aw4iodmo5kafyp 1065 arn...@gm...-20080329124926-2je1z18p0272zpua 1066 arn...@gm...-20080329150901-ehj9t32en7eps2dp 1067 zouzou123gen-20080329153653-36xlvpik2ns9r84r 1068 zouzou123gen-20080329162703-51xr8hg073pg7wq5 1069 zouzou123gen-20080329234706-8ddipdqu0xeudkql 1070 arn...@gm...-20080330081232-ubqr1171ewalrd4q 1071 zouzou123gen-20080330131607-yppbs3mgyjef1cux 1072 zouzou123gen-20080330134835-yv1nogy77ib1uehd 1073 zouzou123gen-20080331124549-alyw7vugdn30piqy 1074 zouzou123gen-20080331135108-q8frtqsin5bosfzm 1075 zouzou123gen-20080331140757-u94q52yccl5lsifk 1076 zouzou123gen-20080331152513-ue1x5qhigcw51348 1077 arn...@gm...-20080331184436-a8g6chibmg8nswls Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/changelog.txt 2008-04-07 18:56:50 UTC (rev 1102) @@ -17,6 +17,7 @@ * [L#209099] Fixed non-disappearing controls in search (poy) * [L#208684] Made the Alt key work again for line history in hub window (poy) * [L#209684] Fixed parsing of non-XML hub lists (poy) +* [L#205660] Readded hub column to transfers (thanks mikejj) -- 0.705 2008-03-14 -- * Several patches for better *nix compatibility of the core (thanks steven sheehy et al) Modified: dcplusplus/trunk/smartwin/include/smartwin/WidgetCreator.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/WidgetCreator.h 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/smartwin/include/smartwin/WidgetCreator.h 2008-04-07 18:56:50 UTC (rev 1102) @@ -58,13 +58,6 @@ return retVal; } - static typename WidgetType::ObjectType createWindow( Widget * parent, const typename WidgetType::Seed & cs ) - { - typename WidgetType::ObjectType retVal(new WidgetType( parent )); - retVal->createWindow( cs ); - return retVal; - } - template< class ContainerType > static typename WidgetType::ObjectType create( Widget * parent, ContainerType * container, const typename WidgetType::Seed & cs ) { Modified: dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h 2008-04-07 18:56:50 UTC (rev 1102) @@ -35,6 +35,7 @@ #include "widgets/MessageBox.h" #include "widgets/CheckBox.h" #include "widgets/ComboBox.h" +#include "widgets/Container.h" #include "widgets/Table.h" #include "widgets/DateTime.h" #include "widgets/GroupBox.h" @@ -211,10 +212,10 @@ typedef typename DateTime::ObjectType DateTimePtr; /// WidgetChildWindow class type. - typedef SmartWin::WidgetChildWindow WidgetChildWindow; + typedef SmartWin::Container Container; /// WidgetChildWindow object type. - typedef typename WidgetChildWindow::ObjectType WidgetChildWindowPtr; + typedef typename Container::ObjectType ContainerPtr; /// Window class type. typedef SmartWin::Window Window; @@ -300,7 +301,7 @@ /// Creates a child window and returns a pointer to it. /** DON'T delete the returned pointer!!! */ - WidgetChildWindowPtr createWidgetChildWindow( const typename WidgetChildWindow::Seed & cs = WidgetChildWindow::Seed() ); + ContainerPtr createContainer( const typename Container::Seed & cs = Container::Seed() ); /// Creates a Tree View and returns a pointer to it. /** DON'T delete the returned pointer!!! @@ -540,10 +541,10 @@ } template<typename ContainerWidgetType> -typename WidgetFactory< ContainerWidgetType >::WidgetChildWindowPtr -WidgetFactory< ContainerWidgetType >::createWidgetChildWindow( const typename WidgetChildWindow::Seed & cs ) +typename WidgetFactory< ContainerWidgetType >::ContainerPtr +WidgetFactory< ContainerWidgetType >::createContainer( const typename Container::Seed & cs ) { - return WidgetCreator< WidgetChildWindow >::createWindow( this, cs ); + return WidgetCreator< Container >::create( this, cs ); } template<typename ContainerWidgetType> Added: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectCloseable.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectCloseable.h (rev 0) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectCloseable.h 2008-04-07 18:56:50 UTC (rev 1102) @@ -0,0 +1,62 @@ +#ifndef ASPECTCLOSE_H_ +#define ASPECTCLOSE_H_ + +namespace SmartWin { + +template< class WidgetType > +class AspectCloseable { + WidgetType& W() { return *static_cast<WidgetType*>(this); } + + struct Dispatcher { + typedef std::tr1::function<bool ()> F; + + Dispatcher(const F& f_) : f(f_) { } + + bool operator()(const MSG& msg, LRESULT& ret) { + return !f(); + } + + F f; + }; + +public: + /// Closes the window + /** Call this function to raise the "Closing" event. <br> + * This will normally try to close the window. <br> + * Note! <br> + * If this event is trapped and we in that event handler state that we DON'T + * want to close the window (by returning false) the window will not be close. + * <br> + * Note! <br> + * If the asyncron argument is true the message will be posted to the message + * que meaning that the close event will be done asyncronously and therefore the + * function will return immediately and the close event will be handled when the + * close event pops up in the event handler que. + */ + void close( bool asyncron = false ); + + /// Event Handler setter for the Closing Event + /** If supplied event handler is called before the window is closed. <br> + * Signature of event handler must be "bool foo()" <br> + * If you return true from your event handler the window is closed, otherwise + * the window is NOT allowed to actually close!! + */ + void onClosing(const typename Dispatcher::F& f); +}; + +template< class WidgetType > +void AspectCloseable< WidgetType >::close( bool asyncron ) { + if ( asyncron ) + W().postMessage(WM_CLOSE); // Return now + else + W().sendMessage(WM_CLOSE); // Return after close is done. +} + +template<typename WidgetType> +void AspectCloseable<WidgetType>::onClosing(const typename Dispatcher::F& f) { + W().addCallback(Message(WM_CLOSE), Dispatcher(f)); +} + +} + +#endif /*ASPECTCLOSE_H_*/ Added: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectTimer.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectTimer.h (rev 0) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectTimer.h 2008-04-07 18:56:50 UTC (rev 1102) @@ -0,0 +1,49 @@ +#ifndef ASPECTTIMER_H_ +#define ASPECTTIMER_H_ + +namespace SmartWin { + +template< class WidgetType > +class AspectTimer { + WidgetType& W() { return *static_cast<WidgetType*>(this); } + HWND H() { return W().handle(); } + + struct Dispatcher { + typedef std::tr1::function<bool ()> F; + + Dispatcher(const F& f_) : f(f_) { } + + bool operator()(const MSG& msg, LRESULT& ret) { + if(!f()) { + /// @todo remove from message map as well... + ::KillTimer(msg.hwnd, msg.wParam); + } + return FALSE; + } + + F f; + }; + + +public: + /// Creates a timer object. + /** The supplied function must have the signature bool foo() <br> + * The event function will be called when at least milliSeconds seconds have elapsed. + * If your event handler returns true, it will keep getting called periodically, otherwise + * it will be removed. + */ + void createTimer(const typename Dispatcher::F& f, unsigned int milliSeconds, unsigned int id = 0); + +}; + +template< class WidgetType > +void AspectTimer< WidgetType >::createTimer( const typename Dispatcher::F& f, + unsigned int milliSecond, unsigned int id) +{ + ::SetTimer( H(), id, static_cast< UINT >( milliSecond ), NULL); + W().addCallback(Message( WM_TIMER, id ), Dispatcher(f)); +} + +} + +#endif /*ASPECTTIMER_H_*/ Added: dcplusplus/trunk/smartwin/include/smartwin/widgets/Composite.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/Composite.h (rev 0) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/Composite.h 2008-04-07 18:56:50 UTC (rev 1102) @@ -0,0 +1,95 @@ +#ifndef COMPOSITE_H_ +#define COMPOSITE_H_ + +#include "../aspects/AspectActivate.h" +#include "../aspects/AspectCommand.h" +#include "../aspects/AspectDragDrop.h" +#include "../aspects/AspectEraseBackground.h" +#include "../aspects/AspectFocus.h" +#include "../aspects/AspectFont.h" +#include "../aspects/AspectPainting.h" +#include "../aspects/AspectText.h" +#include "../resources/Icon.h" +#include "../Policies.h" +#include "../WidgetCreator.h" +#include "../WindowClass.h" +#include "Control.h" + +#include <boost/scoped_ptr.hpp> + +namespace SmartWin { + +template<typename Policy> +class Composite : + public Control<Policy>, + // Aspects + public AspectActivate< Composite< Policy > >, + public AspectCommand< Composite< Policy > >, + public AspectDragDrop< Composite< Policy > >, + public AspectEraseBackground< Composite< Policy > >, + public AspectFocus< Composite< Policy > >, + public AspectFont< Composite< Policy > >, + public AspectPainting< Composite< Policy > >, + public AspectText< Composite< Policy > > +{ +public: + typedef Composite<Policy> ThisType; + + typedef ThisType* ObjectType; + + typedef Control<Policy> BaseType; + + /// Seed class + /** This class contains all of the values needed to create the widget. It also + * knows the type of the class whose seed values it contains. Every widget + * should define one of these. + */ + struct Seed : public BaseType::Seed { + IconPtr icon; + IconPtr smallIcon; + HBRUSH background; + LPCTSTR menuName; + HCURSOR cursor; + + /// Fills with default parameters + Seed(DWORD style); + }; + + + template<typename ChildSeed> + typename ChildSeed::ObjectType add(const ChildSeed& seed) { + return WidgetCreator<typename ChildSeed::WidgetType>::create(this, seed); + } + + virtual void create(const Seed& cs); +protected: + friend class WidgetCreator<Composite<Policy> >; + + explicit Composite( Widget * parent ) : BaseType( parent ) + {}; + +private: + boost::scoped_ptr<WindowClass> windowClass; +}; + +template<typename Policy> +Composite<Policy>::Seed::Seed(DWORD style) : + BaseType::Seed(NULL, style | WS_CLIPCHILDREN), + background(( HBRUSH )( COLOR_APPWORKSPACE + 1 )), + menuName(NULL), + cursor(NULL) +{ +} + +template<typename Policy> +void Composite<Policy>::create(const Seed& cs) { + windowClass.reset(new WindowClass(WindowClass::getNewClassName(this), &ThisType::wndProc, cs.menuName, cs.background, cs.icon, cs.smallIcon, cs.cursor)); + + Seed cs2 = cs; + cs2.className = windowClass->getClassName(); + BaseType::create( cs2 ); +} + +} + +#endif /*COMPOSITE_H_*/ Added: dcplusplus/trunk/smartwin/include/smartwin/widgets/Container.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/Container.h (rev 0) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/Container.h 2008-04-07 18:56:50 UTC (rev 1102) @@ -0,0 +1,39 @@ +#ifndef CONTAINER_H_ +#define CONTAINER_H_ + +#include "../Policies.h" +#include "Composite.h" + +namespace SmartWin { + +class Container : + public Composite<Policies::Normal> +{ + friend class WidgetCreator<Container>; +public: + typedef Container ThisType; + + typedef ThisType* ObjectType; + + typedef Composite<Policies::Normal> BaseType; + + struct Seed : public BaseType::Seed { + Seed(); + }; + + // Use our seed type + virtual void create( const Seed& cs = Seed() ); + +protected: + Container(Widget* parent) : BaseType(parent) { } +}; + +inline Container::Seed::Seed() : BaseType::Seed(WS_CHILD | WS_CLIPSIBLINGS) { + +} + +inline void Container::create(const Seed& cs) { + BaseType::create(cs); +} +} +#endif /*CONTAINER_H_*/ Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/Control.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/Control.h 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/Control.h 2008-04-07 18:56:50 UTC (rev 1102) @@ -5,6 +5,7 @@ #include "../xCeption.h" #include "../aspects/AspectBorder.h" +#include "../aspects/AspectCloseable.h" #include "../aspects/AspectContextMenu.h" #include "../aspects/AspectEnabled.h" #include "../aspects/AspectHelp.h" @@ -12,6 +13,7 @@ #include "../aspects/AspectMouse.h" #include "../aspects/AspectRaw.h" #include "../aspects/AspectSizable.h" +#include "../aspects/AspectTimer.h" #include "../aspects/AspectVisible.h" namespace SmartWin { @@ -22,6 +24,7 @@ public MessageMap<Policy>, public AspectBorder<Control<Policy> >, + public AspectCloseable<Control<Policy> >, public AspectContextMenu<Control<Policy> >, public AspectEnabled<Control<Policy> >, public AspectHelp<Control<Policy> >, @@ -29,10 +32,16 @@ public AspectMouse<Control<Policy> >, public AspectRaw<Control<Policy> >, public AspectSizable<Control<Policy> >, + public AspectTimer<Control<Policy> >, public AspectVisible<Control<Policy> > { public: - + typedef MessageMap<Policy> BaseType; + + struct Seed : public BaseType::Seed { + Seed(LPCTSTR className, DWORD style); + }; + protected: typedef Control<Policy> ControlType; @@ -46,6 +55,13 @@ typedef Control<Policies::Subclassed> CommonControl; +template<typename Policy> +Control<Policy>::Seed::Seed(LPCTSTR className, DWORD style) : + BaseType::Seed(NULL, style | WS_VISIBLE) +{ + } +} + #endif /*CONTROL_H_*/ Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/Frame.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/Frame.h 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/Frame.h 2008-04-07 18:56:50 UTC (rev 1102) @@ -30,16 +30,8 @@ #include "../Application.h" #include "../Rectangle.h" -#include "../aspects/AspectActivate.h" -#include "../aspects/AspectCommand.h" -#include "../aspects/AspectDragDrop.h" -#include "../aspects/AspectEraseBackground.h" -#include "../aspects/AspectFocus.h" -#include "../aspects/AspectFont.h" #include "../aspects/AspectMinMax.h" -#include "../aspects/AspectPainting.h" -#include "../aspects/AspectText.h" -#include "Control.h" +#include "Composite.h" namespace SmartWin { @@ -73,102 +65,22 @@ */ template< class Policy > class Frame : - public Control< Policy >, - - // Aspects - public AspectActivate< Frame< Policy > >, - public AspectCommand< Frame< Policy > >, - public AspectDragDrop< Frame< Policy > >, - public AspectEraseBackground< Frame< Policy > >, - public AspectFocus< Frame< Policy > >, - public AspectFont< Frame< Policy > >, - public AspectMinMax<Frame<Policy> >, - public AspectPainting< Frame< Policy > >, - public AspectText< Frame< Policy > > + public Composite< Policy >, + public AspectMinMax<Frame<Policy> > { - struct CloseDispatcher - { - typedef std::tr1::function<bool ()> F; - - CloseDispatcher(const F& f_, Widget* widget_) : f(f_), widget(widget_) { } - - bool operator()(const MSG& msg, LRESULT& ret) { - bool destroy = f(); - - if ( destroy ) { - return false; - } - - return true; - } - - F f; - Widget* widget; - }; - - struct TimerDispatcher - { - typedef std::tr1::function<bool ()> F; - - TimerDispatcher(const F& f_) : f(f_) { } - - bool operator()(const MSG& msg, LRESULT& ret) { - bool keep = f(); - - if(!keep) { - ::KillTimer(msg.hwnd, msg.wParam); - // TODO remove from message map as well... - } - return FALSE; - } - - F f; - }; - public: /// Class type typedef Frame< Policy > ThisType; /// Object type typedef ThisType * ObjectType; + + typedef Composite< Policy > BaseType; + + struct Seed : public BaseType::Seed { + Seed(DWORD style); + }; - // TODO: Outfactor into WidgetClosable - /// Event Handler setter for the Closing Event - /** If supplied event handler is called before the window is closed. <br> - * Signature of event handler must be "bool foo()" <br> - * If you return true from your event handler the window is closed, otherwise - * the window is NOT allowed to actually close!! - */ - void onClosing(const typename CloseDispatcher::F& f) { - this->addCallback( - Message( WM_CLOSE ), CloseDispatcher(f, this) - ); - } - - // TODO: Outfactor into "time Aspect" class - /// Creates a timer object. - /** The supplied function must have the signature bool foo() <br> - * The event function will be called when at least milliSeconds seconds have elapsed. - * If your event handler returns true, it will keep getting called periodically, otherwise - * it will be removed. - */ - void createTimer(const typename TimerDispatcher::F& f, unsigned int milliSeconds, unsigned int id = 0); - - /// Closes the window - /** Call this function to raise the "Closing" event. <br> - * This will normally try to close the window. <br> - * Note! <br> - * If this event is trapped and we in that event handler state that we DON'T - * want to close the window (by returning false) the window will not be close. - * <br> - * Note! <br> - * If the asyncron argument is true the message will be posted to the message - * que meaning that the close event will be done asyncronously and therefore the - * function will return immediately and the close event will be handled when the - * close event pops up in the event handler que. - */ - void close( bool asyncron = false ); - // TODO: Outfactor to system implementation type, see e.g. WidgetFactory #ifndef WINCE /// Animates a window @@ -228,34 +140,17 @@ // directly virtual ~Frame() {} - - }; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Implementation of class /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -template< class Policy > -void Frame< Policy >::createTimer( const typename TimerDispatcher::F& f, - unsigned int milliSecond, unsigned int id) -{ - - ::SetTimer( this->handle(), id, static_cast< UINT >( milliSecond ), NULL); - addCallback( - Message( WM_TIMER, id ), TimerDispatcher(f) - ); +template<typename Policy> +Frame<Policy>::Seed::Seed(DWORD style) : Frame<Policy>::BaseType::Seed(WS_OVERLAPPEDWINDOW) { + } -template< class Policy > -void Frame< Policy >::close( bool asyncron ) -{ - if ( asyncron ) - this->postMessage(WM_CLOSE); // Return now - else - this->sendMessage(WM_CLOSE); // Return after close is done. -} - #ifndef WINCE template< class Policy > void Frame< Policy >::animateSlide( bool show, bool left, unsigned int time ) @@ -340,7 +235,7 @@ template< class Policy > Frame< Policy >::Frame( Widget * parent ) - : Control<Policy>( parent ) + : Composite<Policy>( parent ) { } Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/MDIFrame.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/MDIFrame.h 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/MDIFrame.h 2008-04-07 18:56:50 UTC (rev 1102) @@ -28,11 +28,7 @@ #ifndef MDIFrame_h #define MDIFrame_h -#include "../WindowsHeaders.h" -#include "../Rectangle.h" -#include "../WindowClass.h" #include "Frame.h" -#include <boost/scoped_ptr.hpp> namespace SmartWin { @@ -53,10 +49,8 @@ * features of MDIFrameBase. */ class MDIFrame - : public Frame< Policies::MDIFrame<MDIFrame > > + : public Frame< Policies::MDIFrame<MDIFrame> > { - typedef Frame< Policies::MDIFrame<MDIFrame > > BaseType; - public: /// Class type typedef MDIFrame ThisType; @@ -64,58 +58,30 @@ /// Object type typedef ThisType* ObjectType; + typedef Frame< Policies::MDIFrame<MDIFrame> > BaseType; + /// Seed class /** This class contains all of the values needed to create the widget. It also * knows the type of the class whose seed values it contains. Every widget * should define one of these. */ class Seed - : public Widget::Seed + : public BaseType::Seed { public: - IconPtr icon; - IconPtr iconSmall; - HBRUSH background; - LPCTSTR menuName; - HCURSOR cursor; - /// Fills with default parameters - // explicit to avoid conversion through SmartWin::CreationalStruct Seed(); - }; /// Actually creates the window /** This one creates the window. <br> * All MDIFrames, and classes derived from them must create the Window * before using it with functions such as setBounds() or setVisible( false ). <br> - * The simple version "createWindow()" uses a default Seed for the window attributes. + * The simple version "create()" uses a default Seed for the window attributes. * The seed is not taken a constant because the class name will be generated at registration. */ - void createWindow( Seed = Seed() ); + void create( const Seed& cs = Seed() ); - /// Creates an invisible window, for quiet initialization. - /** Same as createWindow, except that the window lacks WS_VISIBLE. - * Since you must create the window before you add other Widgets, - * and doing so causes a bit of screen flash before the final window - * is ready, createInvisibleWindow() lets you add Widgets while - * the main Widget is not visible. Of course you could do code like <br> - * - * Seed defInvisible = Seed(); <br> - * defInvisible.style= defInvisible.style & ( ~ WS_VISIBLE ); <br> - * createWindow( defInvisible ); <br> - * - * but this is cleaner: <br> - * - * createInvisibleWindow(); <br> - * do init <br> - * setVisible( true ); <br> - * - * The other styles are either defaulted with createInvisibleWindow() - * or specified with createInvisibleWindow( Seed ). - */ - void createInvisibleWindow( Seed seed = Seed() ); - MDIParent* getMDIParent() { return mdi; } protected: // Protected since this Widget we HAVE to inherit from @@ -123,7 +89,6 @@ virtual ~MDIFrame(); private: - boost::scoped_ptr<WindowClass> windowClass; MDIParent* mdi; }; Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/TabSheet.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/TabSheet.h 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/TabSheet.h 2008-04-07 18:56:50 UTC (rev 1102) @@ -59,7 +59,7 @@ * the code area where the user can switch between the different opened files. Use * the onSelectionChanged event to make visible/invisible the different controls you * wish to use in the different tab pages! <br> - * Normally you would add up one WidgetChildWindow for each Tab Page the Tab Control + * Normally you would add up one Container for each Tab Page the Tab Control * has. */ class TabSheet : Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h 2008-04-07 18:56:50 UTC (rev 1102) @@ -3,7 +3,7 @@ #include "TabSheet.h" #include "ToolTip.h" -#include "Window.h" +#include "Container.h" #include "../WindowClass.h" #include <list> #include <vector> @@ -39,29 +39,29 @@ bool toggleActive; }; - void add(WidgetChildWindow* w, const IconPtr& icon); + void add(Container* w, const IconPtr& icon); - void mark(WidgetChildWindow* w); + void mark(Container* w); - void remove(WidgetChildWindow* w); + void remove(Container* w); void next(bool reverse = false); - WidgetChildWindow* getActive(); - void setActive(WidgetChildWindow* w) { setActive(findTab(w)); } + Container* getActive(); + void setActive(Container* w) { setActive(findTab(w)); } - SmartUtil::tstring getTabText(WidgetChildWindow* w); + SmartUtil::tstring getTabText(Container* w); void onTitleChanged(const TitleChangedFunction& f) { titleChangedFunction = f; } + void onTabContextMenu(Container* w, const std::tr1::function<bool (const ScreenCoordinate& pt)>& f); + void onHelp(const HelpFunction& f) { helpFunction = f; } - void onTabContextMenu(WidgetChildWindow* w, const ContextMenuFunction& f); - bool filter(const MSG& msg); TabSheet::ObjectType getTab(); @@ -81,8 +81,8 @@ enum { MAX_TITLE_LENGTH = 20 }; struct TabInfo { - TabInfo(WidgetChildWindow* w_) : w(w_) { } - WidgetChildWindow* w; + TabInfo(Container* w_) : w(w_) { } + Container* w; ContextMenuFunction handleContextMenu; }; @@ -98,24 +98,24 @@ bool inTab; - typedef std::list<WidgetChildWindow*> WindowList; + typedef std::list<Container*> WindowList; typedef WindowList::iterator WindowIter; WindowList viewOrder; Rectangle clientSize; std::vector<IconPtr> icons; int active; - WidgetChildWindow* dragging; + Container* dragging; SmartUtil::tstring tipText; - int findTab(WidgetChildWindow* w); + int findTab(Container* w); void setActive(int i); - TabInfo* getTabInfo(WidgetChildWindow* w); + TabInfo* getTabInfo(Container* w); TabInfo* getTabInfo(int i); - void setTop(WidgetChildWindow* w); + void setTop(Container* w); - bool handleTextChanging(WidgetChildWindow* w, const SmartUtil::tstring& newText); + bool handleTextChanging(Container* w, const SmartUtil::tstring& newText); void handleSized(const SizedEvent&); void handleTabSelected(); LRESULT handleToolTip(LPARAM lParam); @@ -129,7 +129,7 @@ void layout(); int addIcon(const IconPtr& icon); - void swapWidgets(WidgetChildWindow* oldW, WidgetChildWindow* newW); + void swapWidgets(Container* oldW, Container* newW); }; inline TabSheet::ObjectType WidgetTabView::getTab() Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/Window.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/Window.h 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/Window.h 2008-04-07 18:56:50 UTC (rev 1102) @@ -28,12 +28,8 @@ #ifndef Window_h #define Window_h -#include "../Rectangle.h" -#include "../WindowClass.h" #include "Frame.h" -#include <boost/scoped_ptr.hpp> - namespace SmartWin { // begin namespace SmartWin @@ -56,7 +52,6 @@ class Window : public Frame< Policies::Normal > { - typedef Frame< Policies::Normal > BaseType; struct CreateDispatcher { typedef std::tr1::function<void (const CREATESTRUCT&)> F; @@ -81,24 +76,18 @@ /// Object type typedef ThisType* ObjectType; + + typedef Frame<Policies::Normal> BaseType; /// Seed class /** This class contains all of the values needed to create the widget. It also * knows the type of the class whose seed values it contains. Every widget * should define one of these. */ - class Seed - : public Widget::Seed - { + struct Seed : public BaseType::Seed { public: typedef Window::ThisType WidgetType; - IconPtr icon; - IconPtr smallIcon; - HBRUSH background; - LPCTSTR menuName; - HCURSOR cursor; - /// Fills with default parameters Seed(); }; @@ -107,33 +96,11 @@ /** This one creates the window. <br> * All Windows, and classes derived from them must create the Window * before using it with functions such as setBounds() or setVisible( false ). <br> - * The simple version "createWindow()" uses a default Seed for the window attributes. + * The simple version "create()" uses a default Seed for the window attributes. * The seed is not taken a constant because the class name will be generated at registration. */ - void createWindow( Seed cs = Seed() ); + virtual void create( const Seed& cs = Seed() ); - /// Creates an invisible window, for quiet initialization. - /** Same as createWindow, except that the window lacks WS_VISIBLE. - * Since you must create the window before you add other Widgets, - * and doing so causes a bit of screen flash before the final window - * is ready, createInvisibleWindow() lets you add Widgets while - * the main Widget is not visible. Of course you could do code like <br> - * - * Seed defInvisible = Seed(); <br> - * defInvisible.style= defInvisible.style & ( ~ WS_VISIBLE ); <br> - * createWindow( defInvisible ); <br> - * - * but this is cleaner: <br> - * - * createInvisibleWindow(); <br> - * do init <br> - * setVisible( true ); <br> - * - * The other styles are either defaulted with createInvisibleWindow() - * or specified with createInvisibleWindow( Seed ). - */ - void createInvisibleWindow( Seed cs = Seed() ); - // TODO: Check up if the CREATESTRUCT * actualy IS modyfiable...!! /// Setting the event handler for the "create" event /** The event handler must have the signature "void foo( CREATESTRUCT * )" where @@ -163,50 +130,8 @@ explicit Window( Widget * parent = 0 ); virtual ~Window(); -private: - boost::scoped_ptr<WindowClass> windowClass; }; -class WidgetChildWindow - : public Window -{ -public: - typedef WidgetChildWindow ThisType; - typedef ThisType* ObjectType; - - /// Seed class - /** This class contains all of the values needed to create the widget. It also - * knows the type of the class whose seed values it contains. Every widget - * should define one of these. - */ - class Seed - : public Window::Seed - { - public: - /// Fills with default parameters - Seed(); - }; - - //TODO: This could be specialized to take WNDPROC from MessageMap - /// Actually creates the window - /** This one creates the window. It is implemented in case somebody wants to use - * createWindow() without parameters. If it wasn't declared, the compiler would - * call Window::create with Window::Seed, which wouldn't - * create a child window. - */ - void createWindow( const Seed& cs = Seed() ) - { - Window::createWindow( cs ); - } - -protected: - friend class WidgetCreator<WidgetChildWindow>; - - // Unlike Window, WidgetChildWindow must have a parent!!! - explicit WidgetChildWindow( Widget * parent ) : Window( parent ) - {}; -}; - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Implementation of class /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -219,12 +144,6 @@ { } -inline void Window::createInvisibleWindow( Seed cs ) -{ - cs.style= cs.style & ( ~ WS_VISIBLE ); - Window::createWindow( cs ); -} - inline void Window::activatePreviousInstance() { #ifdef PORT_ME @@ -247,11 +166,6 @@ #endif } -inline WidgetChildWindow::Seed::Seed() -{ - this->style = WS_VISIBLE | WS_CHILD; -} - // end namespace SmartWin } Modified: dcplusplus/trunk/smartwin/source/widgets/MDIFrame.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/MDIFrame.cpp 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/smartwin/source/widgets/MDIFrame.cpp 2008-04-07 18:56:50 UTC (rev 1102) @@ -5,24 +5,13 @@ namespace SmartWin { MDIFrame::Seed::Seed() : - Widget::Seed(NULL, WS_VISIBLE | WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN), - background(( HBRUSH )( COLOR_APPWORKSPACE + 1 )), - menuName(NULL), - cursor(NULL) + BaseType::Seed(0) { } -void MDIFrame::createInvisibleWindow( Seed cs ) +void MDIFrame::create( const Seed& cs ) { - cs.style= cs.style & ( ~ WS_VISIBLE ); - MDIFrame::createWindow( cs ); -} - -void MDIFrame::createWindow( Seed cs ) -{ - windowClass.reset(new WindowClass(WindowClass::getNewClassName(this), &ThisType::wndProc, cs.menuName, cs.background, cs.icon, cs.iconSmall, cs.cursor)); - cs.className = windowClass->getClassName(); - Widget::create( cs ); + BaseType::create(cs); mdi = WidgetCreator<MDIParent>::create(this); } Copied: dcplusplus/trunk/smartwin/source/widgets/ModalDialog.cpp (from rev 1101, dcplusplus/trunk/smartwin/source/widgets/WidgetModalDialog.cpp) =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/ModalDialog.cpp (rev 0) +++ dcplusplus/trunk/smartwin/source/widgets/ModalDialog.cpp 2008-04-07 18:56:50 UTC (rev 1102) @@ -0,0 +1,45 @@ +#include "../../include/smartwin/widgets/ModalDialog.h" + +namespace SmartWin { + +int ModalDialog::createDialog( unsigned resourceId ) +{ + // this will not return until the dialog is closed by calling endDialog() with + // a retv + // + INT_PTR retv = ::DialogBoxParam + ( ( Application::instance().getAppHandle() ) + , ( MAKEINTRESOURCE( resourceId ) ) + , ( this->getParent() ? this->getParent()->handle() : 0 ) + , ( (DLGPROC)&ThisType::wndProc ) + , ( reinterpret_cast< LPARAM >( dynamic_cast< Widget * >( this ) ) ) + ); + if ( retv == - 1 ) + { + throw xCeption( _T( "Couldn't create modal dialog" ) ); + } + return static_cast< int >( retv ); +} + +int ModalDialog::createDialog() +{ + // Arrange so the DLGTEMPLATE is followed by 0000 for menu, winclass and title. + unsigned char dlg_menu_winclass_title[ sizeof( DLGTEMPLATE ) + 30 ]; + memset( dlg_menu_winclass_title, 0, sizeof( dlg_menu_winclass_title ) ); + memcpy( dlg_menu_winclass_title, & itsDefaultDlgTemplate, sizeof( DLGTEMPLATE ) ); + + // this will not return until the dialog is closed by calling endDialog() with + // a retv + // + INT_PTR retv = ::DialogBoxIndirectParam + ( Application::instance().getAppHandle() // HINSTANCE hInstance + , ( DLGTEMPLATE * ) dlg_menu_winclass_title // LPCDLGTEMPLATE hDialogTemplate + , this->getParent() ? this->getParent()->handle() : 0 // HWND hWndParent + , (DLGPROC)&ThisType::wndProc // DLGPROC lpDialogFunc + , reinterpret_cast< LPARAM >( dynamic_cast< Widget * >( this ) ) + ); // LPARAM dwInitParam + + return static_cast< int >( retv ); +} + +} Copied: dcplusplus/trunk/smartwin/source/widgets/ModelessDialog.cpp (from rev 1101, dcplusplus/trunk/smartwin/source/widgets/WidgetDialog.cpp) =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/ModelessDialog.cpp (rev 0) +++ dcplusplus/trunk/smartwin/source/widgets/ModelessDialog.cpp 2008-04-07 18:56:50 UTC (rev 1102) @@ -0,0 +1,18 @@ +#include "../../include/smartwin/widgets/ModelessDialog.h" + +namespace SmartWin { + +void ModelessDialog::createDialog( unsigned resourceId ) +{ + HWND wnd = ::CreateDialogParam( Application::instance().getAppHandle(), + MAKEINTRESOURCE( resourceId ), + ( this->getParent() ? this->getParent()->handle() : 0 ), + ( (DLGPROC)&ThisType::wndProc ), + reinterpret_cast< LPARAM >( static_cast< Widget * >( this ) ) ); + + if ( !wnd ) { + throw xCeption( _T( "CreateDialogParam failed." ) ); + } +} + +} Deleted: dcplusplus/trunk/smartwin/source/widgets/WidgetDialog.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetDialog.cpp 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetDialog.cpp 2008-04-07 18:56:50 UTC (rev 1102) @@ -1,18 +0,0 @@ -#include "../../include/smartwin/widgets/ModelessDialog.h" - -namespace SmartWin { - -void ModelessDialog::createDialog( unsigned resourceId ) -{ - HWND wnd = ::CreateDialogParam( Application::instance().getAppHandle(), - MAKEINTRESOURCE( resourceId ), - ( this->getParent() ? this->getParent()->handle() : 0 ), - ( (DLGPROC)&ThisType::wndProc ), - reinterpret_cast< LPARAM >( static_cast< Widget * >( this ) ) ); - - if ( !wnd ) { - throw xCeption( _T( "CreateDialogParam failed." ) ); - } -} - -} Deleted: dcplusplus/trunk/smartwin/source/widgets/WidgetModalDialog.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetModalDialog.cpp 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetModalDialog.cpp 2008-04-07 18:56:50 UTC (rev 1102) @@ -1,45 +0,0 @@ -#include "../../include/smartwin/widgets/ModalDialog.h" - -namespace SmartWin { - -int ModalDialog::createDialog( unsigned resourceId ) -{ - // this will not return until the dialog is closed by calling endDialog() with - // a retv - // - INT_PTR retv = ::DialogBoxParam - ( ( Application::instance().getAppHandle() ) - , ( MAKEINTRESOURCE( resourceId ) ) - , ( this->getParent() ? this->getParent()->handle() : 0 ) - , ( (DLGPROC)&ThisType::wndProc ) - , ( reinterpret_cast< LPARAM >( dynamic_cast< Widget * >( this ) ) ) - ); - if ( retv == - 1 ) - { - throw xCeption( _T( "Couldn't create modal dialog" ) ); - } - return static_cast< int >( retv ); -} - -int ModalDialog::createDialog() -{ - // Arrange so the DLGTEMPLATE is followed by 0000 for menu, winclass and title. - unsigned char dlg_menu_winclass_title[ sizeof( DLGTEMPLATE ) + 30 ]; - memset( dlg_menu_winclass_title, 0, sizeof( dlg_menu_winclass_title ) ); - memcpy( dlg_menu_winclass_title, & itsDefaultDlgTemplate, sizeof( DLGTEMPLATE ) ); - - // this will not return until the dialog is closed by calling endDialog() with - // a retv - // - INT_PTR retv = ::DialogBoxIndirectParam - ( Application::instance().getAppHandle() // HINSTANCE hInstance - , ( DLGTEMPLATE * ) dlg_menu_winclass_title // LPCDLGTEMPLATE hDialogTemplate - , this->getParent() ? this->getParent()->handle() : 0 // HWND hWndParent - , (DLGPROC)&ThisType::wndProc // DLGPROC lpDialogFunc - , reinterpret_cast< LPARAM >( dynamic_cast< Widget * >( this ) ) - ); // LPARAM dwInitParam - - return static_cast< int >( retv ); -} - -} Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2008-04-07 18:56:50 UTC (rev 1102) @@ -1,6 +1,5 @@ #include "../../include/smartwin/widgets/WidgetTabView.h" #include "../../include/smartwin/WidgetCreator.h" -#include "../../include/smartwin/WindowClass.h" namespace SmartWin { @@ -46,7 +45,7 @@ } } -void WidgetTabView::add(WidgetChildWindow* w, const IconPtr& icon) { +void WidgetTabView::add(Container* w, const IconPtr& icon) { int image = addIcon(icon); size_t tabs = tab->size(); TabInfo* ti = new TabInfo(w); @@ -68,17 +67,17 @@ w->onTextChanging(std::tr1::bind(&WidgetTabView::handleTextChanging, this, w, _1)); } -WidgetChildWindow* WidgetTabView::getActive() { +Container* WidgetTabView::getActive() { TabInfo* ti = getTabInfo(tab->getSelected()); return ti ? ti->w : 0; } -void WidgetTabView::remove(WidgetChildWindow* w) { +void WidgetTabView::remove(Container* w) { if(viewOrder.size() > 1 && viewOrder.back() == w) { setActive(*(--(--viewOrder.end()))); } - WidgetChildWindow* cur = getTabInfo(tab->getSelected())->w; + Container* cur = getTabInfo(tab->getSelected())->w; viewOrder.remove(w); @@ -98,14 +97,14 @@ titleChangedFunction(SmartUtil::tstring()); } -SmartUtil::tstring WidgetTabView::getTabText(WidgetChildWindow* w) { +SmartUtil::tstring WidgetTabView::getTabText(Container* w) { int i = findTab(w); if(i != -1) return tab->getText(i); return SmartUtil::tstring(); } -void WidgetTabView::onTabContextMenu(WidgetChildWindow* w, const ContextMenuFunction& f) { +void WidgetTabView::onTabContextMenu(Container* w, const ContextMenuFunction& f) { TabInfo* ti = getTabInfo(w); if(ti) { ti->handleContextMenu = f; @@ -120,7 +119,7 @@ handleTabSelected(); } -void WidgetTabView::swapWidgets(WidgetChildWindow* oldW, WidgetChildWindow* newW) { +void WidgetTabView::swapWidgets(Container* oldW, Container* newW) { sendMessage(WM_SETREDRAW, FALSE); if(oldW) { @@ -161,14 +160,14 @@ titleChangedFunction(ti->w->getText()); } -void WidgetTabView::mark(WidgetChildWindow* w) { +void WidgetTabView::mark(Container* w) { int i = findTab(w); if(i != -1 && i != tab->getSelected()) { tab->setHighlight(i, true); } } -int WidgetTabView::findTab(WidgetChildWindow* w) { +int WidgetTabView::findTab(Container* w) { for(size_t i = 0; i < tab->size(); ++i) { if(getTabInfo(i)->w == w) { return static_cast<int>(i); @@ -177,7 +176,7 @@ return -1; } -WidgetTabView::TabInfo* WidgetTabView::getTabInfo(WidgetChildWindow* w) { +WidgetTabView::TabInfo* WidgetTabView::getTabInfo(Container* w) { return getTabInfo(findTab(w)); } @@ -185,7 +184,7 @@ return i == -1 ? 0 : reinterpret_cast<TabInfo*>(tab->getData(i)); } -bool WidgetTabView::handleTextChanging(WidgetChildWindow* w, const SmartUtil::tstring& newText) { +bool WidgetTabView::handleTextChanging(Container* w, const SmartUtil::tstring& newText) { int i = findTab(w); if(i != -1) { tab->setText(i, formatTitle(newText)); @@ -223,7 +222,7 @@ if(viewOrder.size() < 2) { return; } - WidgetChildWindow* wnd = getActive(); + Container* wnd = getActive(); if(!wnd) { return; } @@ -258,7 +257,7 @@ return; } -void WidgetTabView::setTop(WidgetChildWindow* wnd) { +void WidgetTabView::setTop(Container* wnd) { WindowIter i = std::find(viewOrder.begin(), viewOrder.end(), wnd); if(i != viewOrder.end() && i != --viewOrder.end()) { viewOrder.erase(i); Deleted: dcplusplus/trunk/smartwin/source/widgets/WidgetWindow.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetWindow.cpp 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetWindow.cpp 2008-04-07 18:56:50 UTC (rev 1102) @@ -1,20 +0,0 @@ -#include "../../include/smartwin/widgets/Window.h" - -namespace SmartWin { - -Window::Seed::Seed() : - Widget::Seed(NULL, WS_VISIBLE | WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN), - background(( HBRUSH )( COLOR_APPWORKSPACE + 1 )), - menuName(NULL), - cursor(NULL) -{ -} - -void Window::createWindow( Seed cs ) -{ - windowClass.reset(new WindowClass(WindowClass::getNewClassName(this), &ThisType::wndProc, cs.menuName, cs.background, cs.icon, cs.smallIcon, cs.cursor)); - cs.className = windowClass->getClassName(); - BaseType::create( cs ); -} - -} Copied: dcplusplus/trunk/smartwin/source/widgets/Window.cpp (from rev 1101, dcplusplus/trunk/smartwin/source/widgets/WidgetWindow.cpp) =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/Window.cpp (rev 0) +++ dcplusplus/trunk/smartwin/source/widgets/Window.cpp 2008-04-07 18:56:50 UTC (rev 1102) @@ -0,0 +1,13 @@ +#include "../../include/smartwin/widgets/Window.h" + +namespace SmartWin { + +Window::Seed::Seed() : BaseType::Seed(0) { + +} + +void Window::create(const Seed& cs) { + BaseType::create(cs); +} + +} Modified: dcplusplus/trunk/win32/MDIChildFrame.h =================================================================== --- dcplusplus/trunk/win32/MDIChildFrame.h 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/win32/MDIChildFrame.h 2008-04-07 18:56:50 UTC (rev 1102) @@ -29,13 +29,13 @@ template<typename T> class MDIChildFrame : - public WidgetFactory< SmartWin::WidgetChildWindow >, + public WidgetFactory< SmartWin::Container >, public AspectSpeaker<T>, public AspectStatus<T> { public: typedef MDIChildFrame<T> ThisType; - typedef WidgetFactory< SmartWin::WidgetChildWindow > BaseType; + typedef WidgetFactory< SmartWin::Container > BaseType; protected: MDIChildFrame(SmartWin::WidgetTabView* tabView, const tstring& title, unsigned helpId = 0, SmartWin::IconPtr icon = SmartWin::IconPtr(), bool activate = true) : @@ -55,7 +55,7 @@ cs.background = (HBRUSH)(COLOR_3DFACE + 1); cs.icon = icon; cs.location = tabView->getClientSize(); - this->createWindow(cs); + this->create(cs); if(helpId) setHelpId(helpId); Modified: dcplusplus/trunk/win32/MainWindow.cpp =================================================================== --- dcplusplus/trunk/win32/MainWindow.cpp 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/win32/MainWindow.cpp 2008-04-07 18:56:50 UTC (rev 1102) @@ -170,8 +170,8 @@ cs.caption = _T(APPNAME) _T(" ") _T(VERSIONSTRING); cs.icon = SmartWin::IconPtr(new SmartWin::Icon(IDR_MAINFRAME)); cs.background = (HBRUSH)(COLOR_3DFACE + 1); - createWindow(cs); - + create(cs); + setHelpId(IDH_STARTPAGE); paned = createHPaned(); @@ -326,7 +326,7 @@ void MainWindow::initTransfers() { dcdebug("initTransfers\n"); - transfers = new TransferView(this, getMDIParent()); + transfers = new TransferView(this, getTabView()); paned->setSecond(transfers); } @@ -339,7 +339,7 @@ return true; } - SmartWin::WidgetChildWindow* active = getMDIParent()->getActive(); + SmartWin::Container* active = getTabView()->getActive(); if(active) { if(::IsDialogMessage( active->handle(), & msg )) { return true; @@ -358,7 +358,7 @@ } void MainWindow::handleForward(WPARAM wParam) { - SmartWin::WidgetChildWindow* active = getMDIParent()->getActive(); + SmartWin::Container* active = getTabView()->getActive(); if(active) { active->sendMessage(WM_COMMAND, wParam, 0); } @@ -380,7 +380,7 @@ while ((i = tmp.find(' ')) != string::npos) tmp.erase(i, 1); - HubFrame::openWindow(getMDIParent(), Text::fromT(tmp)); + HubFrame::openWindow(getTabView(), Text::fromT(tmp)); } } @@ -411,12 +411,12 @@ switch (s) { case DOWNLOAD_LISTING: { boost::scoped_ptr<DirectoryListInfo> i(reinterpret_cast<DirectoryListInfo*>(lParam)); - DirectoryListingFrame::openWindow(getMDIParent(), i->file, i->dir, i->user, i->speed); + DirectoryListingFrame::openWindow(getTabView(), i->file, i->dir, i->user, i->speed); } break; case BROWSE_LISTING: { boost::scoped_ptr<DirectoryBrowseInfo> i(reinterpret_cast<DirectoryBrowseInfo*>(lParam)); - DirectoryListingFrame::openWindow(getMDIParent(), i->user, i->text, 0); + DirectoryListingFrame::openWindow(getTabView(), i->user, i->text, 0); } break; case AUTO_CONNECT: { @@ -429,7 +429,7 @@ break; case VIEW_FILE_AND_DELETE: { boost::scoped_ptr<std::string> file(reinterpret_cast<std::string*>(lParam)); - new TextFrame(this->getMDIParent(), *file); + new TextFrame(this->getTabView(), *file); File::deleteFile(*file); } break; @@ -460,7 +460,7 @@ FavoriteHubEntry* entry = *i; if (entry->getConnect()) { if (!entry->getNick().empty() || !SETTING(NICK).empty()) { - HubFrame::openWindow(getMDIParent(), entry->getServer()); + HubFrame::openWindow(getTabView(), entry->getServer()); } } } @@ -711,7 +711,7 @@ if(WinUtil::browseFileList(createLoadDialog(), file)) { UserPtr u = DirectoryListing::getUserFromFilename(Text::fromT(file)); if (u) { - DirectoryListingFrame::openWindow(getMDIParent(), file, Text::toT(Util::emptyString), u, 0); + DirectoryListingFrame::openWindow(getTabView(), file, Text::toT(Util::emptyString), u, 0); } else { createMessageBox().show(T_("Invalid file list name"), _T(APPNAME) _T(" ") _T(VERSIONSTRING)); } @@ -720,7 +720,7 @@ void MainWindow::handleOpenOwnList() { if (!ShareManager::getInstance()->getOwnListFile().empty()) { - DirectoryListingFrame::openWindow(getMDIParent(), Text::toT(ShareManager::getInstance()->getOwnListFile()), Text::toT(Util::emptyString), ClientManager::getInstance()->getMe(), 0); + DirectoryListingFrame::openWindow(getTabView(), Text::toT(ShareManager::getInstance()->getOwnListFile()), Text::toT(Util::emptyString), ClientManager::getInstance()->getMe(), 0); } } @@ -754,7 +754,7 @@ MainWindow* mf = reinterpret_cast<MainWindow*>(p); HWND wnd, wnd2 = NULL; - while( (wnd=::GetWindow(mf->getMDIParent()->getTab()->handle(), GW_CHILD)) != NULL) { + while( (wnd=::GetWindow(mf->getTabView()->getTab()->handle(), GW_CHILD)) != NULL) { if(wnd == wnd2) { ::Sleep(100); } else { @@ -806,7 +806,7 @@ void MainWindow::handleActivate(bool active) { // Forward to active tab window - WidgetChildWindow* w = tabs->getActive(); + Container* w = tabs->getActive(); if(w) { w->sendMessage(WM_ACTIVATE, active ? WA_ACTIVE : WA_INACTIVE); } Modified: dcplusplus/trunk/win32/MainWindow.h =================================================================== --- dcplusplus/trunk/win32/MainWindow.h 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/win32/MainWindow.h 2008-04-07 18:56:50 UTC (rev 1102) @@ -55,8 +55,7 @@ STATUS_LAST }; - /// @deprecated - WidgetTabView* getMDIParent() { return tabs; } + WidgetTabView* getTabView() { return tabs; } virtual bool tryFire( const MSG & msg, LRESULT & retVal ); Modified: dcplusplus/trunk/win32/MainWindowFactory.cpp =================================================================== --- dcplusplus/trunk/win32/MainWindowFactory.cpp 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/win32/MainWindowFactory.cpp 2008-04-07 18:56:50 UTC (rev 1102) @@ -37,43 +37,43 @@ void MainWindow::handleOpenWindow(unsigned id) { switch (id) { case IDC_PUBLIC_HUBS: - PublicHubsFrame::openWindow(getMDIParent()); + PublicHubsFrame::openWindow(getTabView()); break; case IDC_FAVORITE_HUBS: - FavHubsFrame::openWindow(getMDIParent()); + FavHubsFrame::openWindow(getTabView()); break; case IDC_FAVUSERS: - UsersFrame::openWindow(getMDIParent()); + UsersFrame::openWindow(getTabView()); break; case IDC_QUEUE: - QueueFrame::openWindow(getMDIParent()); + QueueFrame::openWindow(getTabView()); break; case IDC_FINISHED_DL: - FinishedDLFrame::openWindow(getMDIParent()); + FinishedDLFrame::openWindow(getTabView()); break; case IDC_WAITING_USERS: - WaitingUsersFrame::openWindow(getMDIParent()); + WaitingUsersFrame::openWindow(getTabView()); break; case IDC_FINISHED_UL: - FinishedULFrame::openWindow(getMDIParent()); + FinishedULFrame::openWindow(getTabView()); break; case IDC_SEARCH: - SearchFrame::openWindow(getMDIParent()); + SearchFrame::openWindow(getTabView()); break; case IDC_ADL_SEARCH: - ADLSearchFrame::openWindow(getMDIParent()); + ADLSearchFrame::openWindow(getTabView()); break; case IDC_SEARCH_SPY: - SpyFrame::openWindow(getMDIParent()); + SpyFrame::openWindow(getTabView()); break; case IDC_NOTEPAD: - NotepadFrame::openWindow(getMDIParent()); + NotepadFrame::openWindow(getTabView()); break; case IDC_SYSTEM_LOG: - SystemFrame::openWindow(getMDIParent()); + SystemFrame::openWindow(getTabView()); break; case IDC_NET_STATS: - StatsFrame::openWindow(getMDIParent()); + StatsFrame::openWindow(getTabView()); break; default: dcassert(0); Modified: dcplusplus/trunk/win32/SplashWindow.cpp =================================================================== --- dcplusplus/trunk/win32/SplashWindow.cpp 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/win32/SplashWindow.cpp 2008-04-07 18:56:50 UTC (rev 1102) @@ -33,14 +33,14 @@ cs.exStyle = WS_EX_STATICEDGE; cs.caption = _T(APPNAME); tmp = new SmartWin::WidgetFactory<SmartWin::Window>(0); - tmp->createWindow(cs); + tmp->create(cs); } { Seed cs; cs.style = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; cs.exStyle = WS_EX_STATICEDGE; cs.caption = _T(APPNAME); - createWindow(cs); + create(cs); } tstring caption = _T(APPNAME) _T(" ") _T(VERSIONSTRING); { Modified: dcplusplus/trunk/win32/TransferView.cpp =================================================================== --- dcplusplus/trunk/win32/TransferView.cpp 2008-04-07 18:54:23 UTC (rev 1101) +++ dcplusplus/trunk/win32/TransferView.cpp 2008-04-07 18:56:50 UTC (rev 1102) @@ -32,14 +32,15 @@ #include <dcpp/Download.h> #include <dcpp/Upload.h> -int TransferView::connectionIndexes[] = { CONNECTION_COLUMN_USER, CONNECTION_COLUMN_STATUS, CONNECTION_CO... [truncated message content] |