From: <arn...@us...> - 2008-03-21 20:03:27
|
Revision: 1049 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=1049&view=rev Author: arnetheduck Date: 2008-03-21 13:03:18 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Change callback implementation Modified Paths: -------------- dcplusplus/trunk/smartwin/include/smartwin/Message.h dcplusplus/trunk/smartwin/include/smartwin/Policies.h dcplusplus/trunk/smartwin/include/smartwin/Widget.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectActivate.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectBackgroundColor.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectClickable.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectCommand.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectContextMenu.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectControl.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectDblClickable.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectDragDrop.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectEnabled.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectEraseBackground.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectFocus.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectHelp.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectKeyboard.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectMouse.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectPainting.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectRaw.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectScrollable.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSelection.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSizable.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectText.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectUpdate.h dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectVisible.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetDateTimePicker.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetListView.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetListViewEditBox.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetModalDialog.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabSheet.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTextBox.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTreeView.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetWindow.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetWindowBase.h dcplusplus/trunk/smartwin/source/Message.cpp dcplusplus/trunk/smartwin/source/Widget.cpp dcplusplus/trunk/smartwin/source/widgets/WidgetDialog.cpp dcplusplus/trunk/smartwin/source/widgets/WidgetMDIChild.cpp dcplusplus/trunk/smartwin/source/widgets/WidgetMDIParent.cpp dcplusplus/trunk/smartwin/source/widgets/WidgetMenu.cpp dcplusplus/trunk/smartwin/source/widgets/WidgetToolTip.cpp dcplusplus/trunk/smartwin/source/widgets/WidgetToolbar.cpp dcplusplus/trunk/win32/TypedListView.h dcplusplus/trunk/win32/TypedTreeView.h Modified: dcplusplus/trunk/smartwin/include/smartwin/Message.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/Message.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/Message.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -30,6 +30,8 @@ #include "WindowsHeaders.h" +#include <functional> + namespace SmartWin { // begin namespace SmartWin @@ -43,8 +45,6 @@ struct Message { public: - // Note! - // We're asserting this constructor comes from a setter for an event callback /// Constructor taking a System Message /** Use this one if you need to e.g. handle an AspectRaw::onRaw Event and the * only interesting parameter to figure out what Message to handle is the actual @@ -70,12 +70,12 @@ // forceValues will if false "manipulate" the values for easy comparison Message( const MSG& msg ); - ~Message() - {} + ~Message() { } bool operator<(const Message& rhs) const; bool operator==(const Message& rhs) const; private: + friend class std::tr1::hash<Message>; /// Contains the actual Message UINT msg; @@ -83,7 +83,20 @@ LPARAM param; }; +inline bool Message::operator==( const Message & right ) const { + return msg == right.msg && param == right.param; +} + // end namespace SmartWin } +namespace std { namespace tr1 { +template<> +struct hash<SmartWin::Message> { + size_t operator()(const SmartWin::Message& message) const { return message.msg * 31 + message.param; } +}; + +} } + + #endif Modified: dcplusplus/trunk/smartwin/include/smartwin/Policies.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/Policies.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/Policies.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -52,30 +52,21 @@ // Try to get the this pointer Widget* w = hwnd_cast<Widget*>(handler); - if(!w) { - if(handler != hwnd) { - Policy* p = hwnd_cast<Policy*>(hwnd); - if(p) { - return p->returnUnhandled(hwnd, uMsg, wParam, lParam); - } - } - return Policy::returnUnknown(hwnd, uMsg, wParam, lParam); - } + if(w) { #ifdef WINCE - if(uMsg == WM_DESTROY) { + if(uMsg == WM_DESTROY) { #else - if(uMsg == WM_NCDESTROY) { + if(uMsg == WM_NCDESTROY) { #endif - - w->kill(); - return Policy::returnDestroyed(hwnd, uMsg, wParam, lParam); - } - - LRESULT res = 0; - if(w->tryFire(msg, res)) { - return Policy::returnHandled(res, hwnd, uMsg, wParam, lParam); - } + w->kill(); + return Policy::returnDestroyed(hwnd, uMsg, wParam, lParam); + } + LRESULT res = 0; + if(w->tryFire(msg, res)) { + return Policy::returnHandled(res, hwnd, uMsg, wParam, lParam); + } + } Policy* p; if(handler != hwnd) { @@ -104,21 +95,10 @@ handler = reinterpret_cast<HWND>(lParam); } break; - case WM_DRAWITEM : { - /// @todo Not sure who should handle these.... - handler = hwnd; - } break; case WM_NOTIFY : { NMHDR* nmhdr = reinterpret_cast<NMHDR*>(lParam); handler = nmhdr->hwndFrom; } break; - /// @todo Not sure who should handle these.... - case WM_HSCROLL : - case WM_VSCROLL : - case WM_MEASUREITEM : - case WM_INITMENUPOPUP : { - handler = hwnd; - } break; case WM_COMMAND: { if(lParam != 0) { handler = reinterpret_cast<HWND>(lParam); @@ -144,7 +124,6 @@ : public Widget { public: - // Note; SmartWin::Widget won't actually be initialized here because of the virtual inheritance Dialog(Widget* parent) : Widget(parent) { } static LRESULT returnDestroyed(HWND hWnd, UINT msg, WPARAM wPar, LPARAM lPar) { @@ -180,9 +159,8 @@ if ( uMsg == WM_INITDIALOG ) { // extracting the this pointer and stuffing it into the Window with SetProp - Widget* This = static_cast<Widget*>(reinterpret_cast< Widget * >( lParam )); - This->setHandle( hwnd ); - This->setProp(); + Dialog* This = reinterpret_cast<Dialog*>(lParam); + This->attach( hwnd ); } } }; @@ -236,9 +214,8 @@ if ( uMsg == WM_NCCREATE ) { // extracting the this pointer and stuffing it into the Window with SetProp CREATESTRUCT * cs = reinterpret_cast< CREATESTRUCT * >( lParam ); - Widget* This = static_cast<Widget*>(reinterpret_cast< Widget * >( cs->lpCreateParams )); - This->setHandle( hWnd ); - This->setProp(); + Normal* This = reinterpret_cast<Normal*>( cs->lpCreateParams ); + This->attach( hWnd ); } } }; @@ -254,29 +231,15 @@ return Normal::returnUnhandled(hWnd, msg, wPar, lPar); } - virtual void attach( unsigned id ) { - Normal::attach(id); - createMessageMap(); + virtual HWND create(const Widget::Seed& seed) { + attach(Widget::create(seed)); } - - void create( const Widget::Seed & cs) { - Normal::create(cs); - createMessageMap(); - } virtual void attach(HWND hwnd) { Normal::attach(hwnd); - createMessageMap(); + oldProc = reinterpret_cast< WNDPROC >( ::SetWindowLongPtr( handle(), GWL_WNDPROC, ( LONG_PTR ) &MessageMapPolicy<Subclassed>::wndProc ) ); } - - /// Call this function from your overridden create() if you add a new Widget to - /// make the Windows Message Procedure dispatching map right. - void createMessageMap() { - if(!oldProc) { - setProp(); - oldProc = reinterpret_cast< WNDPROC >( ::SetWindowLongPtr( handle(), GWL_WNDPROC, ( LONG_PTR ) &MessageMapPolicy<Subclassed>::wndProc ) ); - } - } + using Normal::attach; private: WNDPROC oldProc; @@ -330,9 +293,8 @@ CREATESTRUCT * cs = reinterpret_cast< CREATESTRUCT * >( lParam ); MDICREATESTRUCT * mcs = reinterpret_cast< MDICREATESTRUCT*>(cs->lpCreateParams); - Widget* This = static_cast<Widget*>(reinterpret_cast< Widget * >( mcs->lParam )); - This->setHandle( hWnd ); - This->setProp(); + MDIChild* This = reinterpret_cast<MDIChild*>(mcs->lParam); + This->attach(hWnd); } } }; @@ -356,8 +318,9 @@ WidgetType* This = static_cast<WidgetType*>(this); if(!handled && msg.message == WM_COMMAND && This->getMDIParent()) { Widget* active = hwnd_cast<Widget*>(This->getMDIParent()->getActive()); - if(active) + if(active) { handled = active->tryFire(msg, retVal); + } } return handled; } Modified: dcplusplus/trunk/smartwin/include/smartwin/Widget.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/Widget.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/Widget.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -35,8 +35,9 @@ #include <boost/noncopyable.hpp> #include <memory> +#include <list> #include <functional> -#include <map> +#include <tr1/unordered_map> namespace SmartWin { @@ -108,27 +109,23 @@ * If you need to do directly manipulation of the window use this function to * retrieve the HWND of the Widget. */ - HWND handle() const { return itsHandle; } + HWND handle() const; /// Send a message to the Widget /** If you need to be able to send a message to a Widget then use this function * as it will unroll into <br> * a ::SendMessage from the Windows API */ - LRESULT sendMessage( UINT msg, WPARAM wParam = 0, LPARAM lParam = 0 ) const { - return ::SendMessage(handle(), msg, wParam, lParam); - } + LRESULT sendMessage( UINT msg, WPARAM wParam = 0, LPARAM lParam = 0) const; - bool postMessage(UINT msg, WPARAM wParam = 0, LPARAM lParam = 0) const { - return ::PostMessage(handle(), msg, wParam, lParam); - } + bool postMessage(UINT msg, WPARAM wParam = 0, LPARAM lParam = 0) const; /// Returns the parent Widget of the Widget /** Most Widgets have got a parent, this function will retrieve a pointer to the * Widgets parent, if the Widget doesn't have a parent it will return a null * pointer. */ - Widget * getParent() const { return itsParent; } + Widget* getParent() const; /// Repaints the whole window /** Invalidate the window and repaints it. @@ -155,20 +152,15 @@ * style (if true add style, else remove) */ void addRemoveExStyle( DWORD addStyle, bool add ); - - void setProp() { ::SetProp(handle(), propAtom, reinterpret_cast<HANDLE>(this) ); } typedef std::tr1::function<bool(const MSG& msg, LRESULT& ret)> CallbackType; + typedef std::list<CallbackType> CallbackList; + typedef std::tr1::unordered_map<Message, CallbackList> CallbackCollectionType; - // We only support one Callback per message, so a map is appropriate - typedef std::map<Message, CallbackType> CallbackCollectionType; - - /// Adds a new Callback into the Callback collection or replaces the existing one - void setCallback(const Message& msg, const CallbackType& callback ); + /// Adds a new callback - multiple callbacks for the same message will be called in the order they were added + void addCallback(const Message& msg, const CallbackType& callback ); - CallbackCollectionType & getCallbacks() { - return itsCallbacks; - } + CallbackCollectionType & getCallbacks(); /// Returns true if fired, else false virtual bool tryFire( const MSG & msg, LRESULT & retVal ); @@ -176,16 +168,14 @@ /** This will be called when it's time to delete the widget */ virtual void kill(); - void setHandle(HWND hWnd) { itsHandle = hWnd; } - protected: - Widget( Widget * parent, HWND hWnd = NULL ); + Widget(Widget * parent); virtual ~Widget(); // Creates the Widget, should NOT be called directly but overridden in the // derived class (with no parameters) - void create( const Seed & cs ); + virtual HWND create( const Seed & cs ); virtual void attach(HWND wnd); @@ -195,26 +185,50 @@ * Should normally not be called directly but rather called from e.g. one of the * creational functions found in the WidgetFactory class. */ - virtual void attach( unsigned id ); + void attach( unsigned id ); private: friend class Application; template<typename T> friend T hwnd_cast(HWND hwnd); - HWND itsHandle; - Widget * itsParent; - // Contains the list of signals we're (this window) processing CallbackCollectionType itsCallbacks; - /// The ATOM with which the pointer to the MessageMapBase is registered on the HWND + Widget * itsParent; + HWND itsHandle; + + /// The atom with which the pointer to the MessageMapBase is registered on the HWND static GlobalAtom propAtom; }; +inline Widget::Widget( Widget * parent ) : itsParent(parent), itsHandle(NULL) { + +} + +inline LRESULT Widget::sendMessage( UINT msg, WPARAM wParam, LPARAM lParam) const { + return ::SendMessage(handle(), msg, wParam, lParam); +} + +inline bool Widget::postMessage(UINT msg, WPARAM wParam, LPARAM lParam) const { + return ::PostMessage(handle(), msg, wParam, lParam); +} + +inline HWND Widget::handle() const { + return itsHandle; +} + +inline Widget* Widget::getParent() const { + return itsParent; +} + inline bool Widget::hasStyle(DWORD style) { return (::GetWindowLong(this->handle(), GWL_STYLE) & style) == style; } +inline Widget::CallbackCollectionType& Widget::getCallbacks() { + return itsCallbacks; +} + template<typename T> T hwnd_cast(HWND hwnd) { Widget* w = reinterpret_cast<Widget*>(::GetProp(hwnd, Widget::propAtom)); Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectActivate.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectActivate.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectActivate.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -76,7 +76,7 @@ * Parameter passed is bool */ void onActivate(const typename Dispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message(WM_ACTIVATE), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectBackgroundColor.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectBackgroundColor.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectBackgroundColor.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -78,7 +78,7 @@ */ void onBackgroundColor(const typename Dispatcher::F& f) { WidgetType* This = static_cast<WidgetType*>(this); - This->setCallback( + This->addCallback( This->getBackgroundColorMessage(), Dispatcher(f, This ) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectClickable.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectClickable.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectClickable.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -54,7 +54,7 @@ * something else. No parameters are passed. */ void onClicked(const typename Dispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( static_cast<WidgetType*>(this)->getClickMessage(), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectCommand.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectCommand.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectCommand.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -10,19 +10,19 @@ typedef Dispatchers::VoidVoid<> Dispatcher; public: void onCommand(const Dispatcher::F& f, unsigned id) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message(WM_COMMAND, id), Dispatcher(f) ); } void onCommand(const Dispatcher::F& f, unsigned controlId, unsigned code) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message(WM_COMMAND, MAKEWPARAM(controlId, code)), Dispatcher(f) ); } void onSysCommand(const Dispatcher::F& f, unsigned id) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message(WM_SYSCOMMAND, id), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectContextMenu.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectContextMenu.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectContextMenu.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -22,7 +22,7 @@ public: void onContextMenu(const typename Dispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message( WM_CONTEXTMENU ), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectControl.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectControl.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectControl.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -39,7 +39,7 @@ unsigned int getControlId(); - void create(const Seed& cs); + virtual HWND create(const Seed& cs); protected: typedef AspectControl<WidgetType> ControlType; @@ -52,9 +52,9 @@ } template<typename WidgetType> -void AspectControl<WidgetType>::create(const Seed& cs) { +HWND AspectControl<WidgetType>::create(const Seed& cs) { xAssert((cs.style & WS_CHILD) == WS_CHILD, _T("Common controls must have WS_CHILD style")); - PolicyType::create(cs); + return PolicyType::create(cs); } template<typename WidgetType> Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectDblClickable.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectDblClickable.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectDblClickable.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -52,7 +52,7 @@ */ void onDblClicked(const Dispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( WidgetType::getDblClickMessage(), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectDragDrop.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectDragDrop.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectDragDrop.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -90,7 +90,7 @@ * } */ void onDragDrop(const typename Dispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message( WM_DROPFILES ), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectEnabled.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectEnabled.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectEnabled.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -84,7 +84,7 @@ * No parameters are passed. */ void onEnabled(const typename Dispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message( WM_ENABLE ), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectEraseBackground.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectEraseBackground.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectEraseBackground.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -70,13 +70,13 @@ * background property of the Widget. */ void onEraseBackground(const typename Dispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message( WM_ERASEBKGND ), Dispatcher(f, static_cast<WidgetType*>(this) ) ); } void noEraseBackground() { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message( WM_ERASEBKGND ), &AspectEraseBackground<WidgetType>::noEraseDispatcher ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectFocus.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectFocus.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectFocus.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -68,7 +68,7 @@ * parameters are passed. */ void onKillFocus(const typename KillFocusDispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message( WM_KILLFOCUS ), KillFocusDispatcher(f) ); } @@ -79,7 +79,7 @@ * parameters are passed. */ void onFocus(const typename FocusDispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message( WM_SETFOCUS ), FocusDispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectHelp.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectHelp.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectHelp.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -9,7 +9,7 @@ public: void onHelp(const typename Dispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message( WM_HELP ), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectKeyboard.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectKeyboard.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectKeyboard.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -157,7 +157,7 @@ {} void onKey(UINT msg, const typename Dispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message( msg ), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectMouse.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectMouse.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectMouse.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -196,7 +196,7 @@ protected: void onMouse(UINT msg, const typename Dispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message( msg ), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectPainting.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectPainting.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectPainting.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -66,7 +66,7 @@ * Parameters passed is Canvas & */ void onPainting(const typename Dispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message( WM_PAINT ), Dispatcher(f, static_cast<WidgetType*>(this) ) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectRaw.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectRaw.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectRaw.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -80,7 +80,7 @@ /// WARNING, this function uses the natural wparam/lparam order, not the inverted that previous /// smartwin versions did. The two functions above emulate the old behaviour though... void onRaw(const typename Dispatcher::F& f, const Message & msg) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( msg, Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectScrollable.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectScrollable.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectScrollable.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -54,7 +54,7 @@ * No parameters are passed. */ void onScrollHorz(const Dispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message( WM_HSCROLL ), Dispatcher(f) ); } @@ -67,7 +67,7 @@ * No parameters are passed. */ void onScrollVert(const Dispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message( WM_VSCROLL ), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSelection.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSelection.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSelection.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -64,7 +64,7 @@ * No parameters are passed. */ void onSelectionChanged(const typename Dispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( static_cast<WidgetType*>(this)->getSelectionChangedMessage(), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSizable.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSizable.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSizable.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -295,7 +295,7 @@ * information. */ void onSized(const typename SizeDispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message( WM_SIZE ), SizeDispatcher(f) ); } @@ -306,7 +306,7 @@ * passed is Point which is the new position of the Widget */ void onMoved(const typename MoveDispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message( WM_MOVE ), MoveDispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectText.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectText.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectText.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -88,7 +88,7 @@ * Widget. */ void onTextChanging(const typename Dispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message( WM_SETTEXT ), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectUpdate.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectUpdate.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectUpdate.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -52,7 +52,7 @@ /** When the Widget value/text is being updated this event will be raised. */ void onUpdate(const Dispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( WidgetType::getUpdateMessage(), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectVisible.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectVisible.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectVisible.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -81,7 +81,7 @@ * invisible. */ void onVisibilityChanged(const typename Dispatcher::F& f) { - static_cast<WidgetType*>(this)->setCallback( + static_cast<WidgetType*>(this)->addCallback( Message( WM_SHOWWINDOW ), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetDateTimePicker.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetDateTimePicker.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetDateTimePicker.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -116,7 +116,7 @@ * when the WidgetDateTimePicker date value is changed. */ void onDateTimeChanged(const Dispatcher::F& f) { - setCallback( + addCallback( Message( WM_NOTIFY, DTN_DATETIMECHANGE ), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetListView.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetListView.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetListView.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -591,7 +591,7 @@ if ( this->getReadOnly() ) this->setReadOnly( false ); MessageMapType * ptrThis = boost::polymorphic_cast< MessageMapType * >( this ); - ptrThis->setCallback( + ptrThis->addCallback( typename MessageMapType::SignalTupleType( private_::SignalContent( Message( WM_NOTIFY, LVN_ENDLABELEDIT ), @@ -610,7 +610,7 @@ if ( this->getReadOnly() ) this->setReadOnly( false ); MessageMapType * ptrThis = boost::polymorphic_cast< MessageMapType * >( this ); - ptrThis->setCallback( + ptrThis->addCallback( typename MessageMapType::SignalTupleType( private_::SignalContent( Message( WM_NOTIFY, LVN_ENDLABELEDIT ), @@ -628,7 +628,7 @@ void WidgetListView::onCustomPainting( typename MessageMapControl< EventHandlerClass, WidgetListView >::itsVoidUnsignedUnsignedBoolCanvasRectangle eventHandler ) { MessageMapType * ptrThis = boost::polymorphic_cast< MessageMapType * >( this ); - ptrThis->setCallback( + ptrThis->addCallback( typename MessageMapType::SignalTupleType( private_::SignalContent( Message( WM_NOTIFY, NM_CUSTOMDRAW ), @@ -646,7 +646,7 @@ void WidgetListView::onCustomPainting( typename MessageMapControl< EventHandlerClass, WidgetListView >::voidUnsignedUnsignedBoolCanvasRectangle eventHandler ) { MessageMapType * ptrThis = boost::polymorphic_cast< MessageMapType * >( this ); - ptrThis->setCallback( + ptrThis->addCallback( typename MessageMapType::SignalTupleType( private_::SignalContent( Message( WM_NOTIFY, NM_CUSTOMDRAW ), @@ -662,7 +662,7 @@ #endif inline void WidgetListView::onColumnClick( const HeaderDispatcher::F& f ) { - this->setCallback( + this->addCallback( Message( WM_NOTIFY, LVN_COLUMNCLICK ), HeaderDispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetListViewEditBox.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetListViewEditBox.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetListViewEditBox.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -49,8 +49,6 @@ // Object type typedef ThisType * ObjectType; - void createSubclass( HWND hWnd ); - explicit ListViewEditBox( SmartWin::Widget * parent ); virtual ~ListViewEditBox() @@ -69,11 +67,6 @@ xAssert( parent, _T( "Cant have a TextBox without a parent..." ) ); } -inline void ListViewEditBox::createSubclass( HWND hWnd ) -{ - setHandle(hWnd); - this->createMessageMap(); -} #ifdef PORT_ME template< class EventHandlerClass > LRESULT ListViewEditBox< EventHandlerClass >::sendWidgetMessage( HWND hWnd, UINT msg, WPARAM & wPar, LPARAM & lPar ) Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetModalDialog.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetModalDialog.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetModalDialog.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -134,7 +134,7 @@ * controls! */ void onInitDialog(const Dispatcher::F& f) { - setCallback( + addCallback( Message( WM_INITDIALOG ), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabSheet.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabSheet.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabSheet.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -142,13 +142,13 @@ * validation of fields etc...) */ void onSelectionChanging(const ChangingDispatcher::F& f) { - setCallback( + addCallback( Message( WM_NOTIFY, TCN_SELCHANGING ), ChangingDispatcher(f, this ) ); } void onSelectionChanged(const ChangedDispatcher::F& f) { - setCallback( + addCallback( Message( WM_NOTIFY, TCN_SELCHANGE ), ChangedDispatcher(f, this ) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTextBox.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTextBox.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTextBox.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -368,7 +368,7 @@ } inline void WidgetTextBoxBase::onTextChanged( const Dispatcher::F& f ) { - this->setCallback( + this->addCallback( Message( WM_COMMAND, MAKEWPARAM(this->getControlId(), EN_CHANGE) ), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTreeView.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTreeView.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTreeView.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -256,7 +256,7 @@ * updated or false if you want to disallow the item to actually become updated! */ void onValidateEditLabels(const Dispatcher::F& f) { - setCallback( + addCallback( Message( WM_NOTIFY, TVN_ENDLABELEDIT ), Dispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetWindow.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetWindow.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetWindow.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -144,7 +144,7 @@ * can add/remove styles and add remove EX styles etc. */ void onCreate(const CreateDispatcher::F& f) { - setCallback( + addCallback( Message( WM_CREATE ), CreateDispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetWindowBase.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetWindowBase.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetWindowBase.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -167,7 +167,7 @@ * the window is NOT allowed to actually close!! */ void onClosing(const typename CloseDispatcher::F& f) { - this->setCallback( + this->addCallback( Message( WM_CLOSE ), CloseDispatcher(f, this) ); } @@ -269,7 +269,7 @@ { ::SetTimer( this->handle(), id, static_cast< UINT >( milliSecond ), NULL); - setCallback( + addCallback( Message( WM_TIMER, id ), TimerDispatcher(f) ); } Modified: dcplusplus/trunk/smartwin/source/Message.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/Message.cpp 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/source/Message.cpp 2008-03-21 20:03:18 UTC (rev 1049) @@ -54,27 +54,22 @@ } } -Message::Message(const MSG& msg_ ) - : msg(msg_.message), +Message::Message(const MSG& msg_ ) : + msg(msg_.message), param( 0 ) { - switch ( msg ) - { - case WM_NOTIFY : - { + switch ( msg ) { + case WM_NOTIFY: { NMHDR * ptrOriginal = reinterpret_cast< NMHDR * >( msg_.lParam ); param = ptrOriginal->code; } break; - case WM_SYSCOMMAND : { - param = msg_.wParam & 0xfff0; - break; - } - case WM_TIMER: - { + case WM_SYSCOMMAND: { + param = msg_.wParam & 0xfff0; + } break; + case WM_TIMER: { param = msg_.wParam; } break; - case WM_COMMAND : - { + case WM_COMMAND: { if(msg_.lParam == 0) { param = LOWORD( msg_.wParam ); } else { @@ -84,10 +79,10 @@ } } -bool Message::operator <( const Message & right ) const -{ - if ( msg < right.msg ) +bool Message::operator <( const Message & right ) const { + if ( msg < right.msg ) { return true; + } if(msg == right.msg && param < right.param) { return true; @@ -95,9 +90,5 @@ return false; } -bool Message::operator == ( const Message & right ) const { - return msg == right.msg && param == right.param; -} - // end namespace SmartWin } Modified: dcplusplus/trunk/smartwin/source/Widget.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/Widget.cpp 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/source/Widget.cpp 2008-03-21 20:03:18 UTC (rev 1049) @@ -47,25 +47,18 @@ { // begin namespace SmartWin -Widget::Widget( Widget * parent, HWND hWnd ) : - itsHandle( hWnd ), - itsParent( parent ) -{ +Widget::~Widget() { + } -Widget::~Widget() -{ -} - // Subclasses a dialog item inside a dialog, usually used in combination with Dialog resources. -void Widget::attach( unsigned id ) -{ +void Widget::attach( unsigned id ) { if ( !itsParent ) throw xCeption( _T( "Can't attach a Widget without a parent..." ) ); - itsHandle = ::GetDlgItem( itsParent->handle(), id ); - if ( !itsHandle ) + HWND hWnd = ::GetDlgItem( itsParent->handle(), id ); + if ( !hWnd ) throw xCeption( _T( "GetDlgItem failed." ) ); - + attach(hWnd); } void Widget::updateWidget() @@ -74,19 +67,16 @@ ::UpdateWindow( itsHandle ); } -void Widget::invalidateWidget() -{ +void Widget::invalidateWidget() { ::InvalidateRect( itsHandle, 0, TRUE ); } -void Widget::kill() -{ +void Widget::kill() { delete this; } -void Widget::create( const Seed & cs ) -{ - itsHandle = ::CreateWindowEx( cs.exStyle, +HWND Widget::create( const Seed & cs ) { + HWND hWnd = ::CreateWindowEx( cs.exStyle, cs.className, cs.caption.c_str(), cs.style, @@ -96,15 +86,19 @@ Application::instance().getAppHandle(), reinterpret_cast< LPVOID >( this ) ); - if ( !itsHandle ) - { + if (!hWnd) { // The most common error is to forget WS_CHILD in the styles throw xCeption( _T( "CreateWindowEx in Widget::create fizzled ..." ) ); } + return hWnd; } void Widget::attach(HWND hwnd) { + if(itsHandle) { + throw xCeption(_T("You may not attach to a widget that's already attached")); + } itsHandle = hwnd; + ::SetProp(hwnd, propAtom, reinterpret_cast<HANDLE>(this) ); } void Widget::addRemoveStyle( DWORD addStyle, bool add ) @@ -157,14 +151,8 @@ GlobalAtom Widget::propAtom(_T("SmartWin::Widget*")); -void Widget::setCallback( const Message& msg, const CallbackType& callback ) -{ - CallbackCollectionType::iterator i = itsCallbacks.find(msg); - if(i == itsCallbacks.end()) { - itsCallbacks.insert(std::make_pair(msg, callback)); - } else { - i->second = callback; - } +void Widget::addCallback( const Message& msg, const CallbackType& callback ) { + itsCallbacks[msg].push_back(callback); } bool Widget::tryFire( const MSG & msg, LRESULT & retVal ) { @@ -172,7 +160,12 @@ Message msgComparer( msg ); CallbackCollectionType::iterator i = itsCallbacks.find(msgComparer); if(i != itsCallbacks.end()) { - return i->second( msg, retVal ); + CallbackList& list = i->second; + for(CallbackList::iterator j = list.begin(); j != list.end(); ++j) { + if((*j)(msg, retVal)) { + return true; + } + } } return false; } Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetDialog.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetDialog.cpp 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetDialog.cpp 2008-03-21 20:03:18 UTC (rev 1049) @@ -11,10 +11,8 @@ reinterpret_cast< LPARAM >( static_cast< Widget * >( this ) ) ); if ( !wnd ) { - xCeption x( _T( "CreateDialogParam failed." ) ); - throw x; + throw xCeption( _T( "CreateDialogParam failed." ) ); } - setHandle(wnd); } } Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetMDIChild.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetMDIChild.cpp 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetMDIChild.cpp 2008-03-21 20:03:18 UTC (rev 1049) @@ -34,7 +34,6 @@ xCeption x( _T( "CreateWindowEx in WidgetMDIChild::createMDIChild fizzled..." ) ); throw x; } - setHandle(wnd); } bool WidgetMDIChild::tryFire(const MSG& msg, LRESULT& retVal) { Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetMDIParent.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetMDIParent.cpp 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetMDIParent.cpp 2008-03-21 20:03:18 UTC (rev 1049) @@ -28,12 +28,8 @@ if ( !wnd ) { // The most common error is to forget WS_CHILD in the styles - xCeption x( _T( "CreateWindowEx in Widget::create fizzled ..." ) ); - throw x; + throw xCeption( _T( "CreateWindowEx in Widget::create fizzled ..." ) ); } - setHandle(wnd); - - ThisType::createMessageMap(); } } Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetMenu.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetMenu.cpp 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetMenu.cpp 2008-03-21 20:03:18 UTC (rev 1049) @@ -66,8 +66,8 @@ } // set default drawing - itsParent->setCallback(Message(WM_DRAWITEM), DrawItemDispatcher(std::tr1::bind(&WidgetMenu::handleDrawItem, this, _1, _2))); - itsParent->setCallback(Message(WM_MEASUREITEM), MeasureItemDispatcher(std::tr1::bind(&WidgetMenu::handleMeasureItem, this, _1))); + itsParent->addCallback(Message(WM_DRAWITEM), DrawItemDispatcher(std::tr1::bind(&WidgetMenu::handleDrawItem, this, _1, _2))); + itsParent->addCallback(Message(WM_MEASUREITEM), MeasureItemDispatcher(std::tr1::bind(&WidgetMenu::handleMeasureItem, this, _1))); } } @@ -194,7 +194,7 @@ void WidgetMenu::addCommands() { for(CallbackMap::iterator i = callbacks.begin(); i != callbacks.end(); ++i) { - itsParent->setCallback(Message(WM_COMMAND, i->first), i->second); + itsParent->addCallback(Message(WM_COMMAND, i->first), i->second); } for(std::vector< ObjectType >::iterator i = itsChildren.begin(); i != itsChildren.end(); ++i) { (*i)->addCommands(); Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetToolTip.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetToolTip.cpp 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetToolTip.cpp 2008-03-21 20:03:18 UTC (rev 1049) @@ -20,7 +20,7 @@ } void WidgetToolTip::setTool(Widget* widget, const Dispatcher::F& f) { - setCallback( + addCallback( Message(WM_NOTIFY, TTN_GETDISPINFO), Dispatcher(f) ); Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetToolbar.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetToolbar.cpp 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetToolbar.cpp 2008-03-21 20:03:18 UTC (rev 1049) @@ -46,7 +46,7 @@ } if(f) - setCallback(Message(WM_COMMAND, id), Dispatcher(f)); + addCallback(Message(WM_COMMAND, id), Dispatcher(f)); } bool WidgetToolbar::tryFire( const MSG & msg, LRESULT & retVal ) Modified: dcplusplus/trunk/win32/TypedListView.h =================================================================== --- dcplusplus/trunk/win32/TypedListView.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/win32/TypedListView.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -43,7 +43,7 @@ void create( const typename BaseType::Seed & cs = BaseType::Seed() ) { BaseType::create(cs); - this->setCallback( + this->addCallback( SmartWin::Message( WM_NOTIFY, LVN_GETDISPINFO ), &ThisType::TypedListViewDispatcher ); this->onColumnClick(std::tr1::bind(&ThisType::handleColumnClick, this, _1)); Modified: dcplusplus/trunk/win32/TypedTreeView.h =================================================================== --- dcplusplus/trunk/win32/TypedTreeView.h 2008-03-19 11:07:22 UTC (rev 1048) +++ dcplusplus/trunk/win32/TypedTreeView.h 2008-03-21 20:03:18 UTC (rev 1049) @@ -34,7 +34,7 @@ void create( const typename BaseType::Seed & cs = BaseType::Seed() ) { BaseType::create(cs); - this->setCallback( + this->addCallback( SmartWin::Message( WM_NOTIFY, TVN_GETDISPINFO ), &TypedTreeViewDispatcher ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |