MyGUI  3.2.1
MyGUI_DDContainer.h
Go to the documentation of this file.
00001 /*
00002  * This source file is part of MyGUI. For the latest info, see http://mygui.info/
00003  * Distributed under the MIT License
00004  * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
00005  */
00006 
00007 #ifndef __MYGUI_DDCONTAINER_H__
00008 #define __MYGUI_DDCONTAINER_H__
00009 
00010 #include "MyGUI_Prerequest.h"
00011 #include "MyGUI_Widget.h"
00012 #include "MyGUI_DDItemInfo.h"
00013 #include "MyGUI_EventPair.h"
00014 
00015 namespace MyGUI
00016 {
00017 
00018     typedef delegates::CMultiDelegate3<DDContainer*, const DDItemInfo&, bool&> EventHandle_DDContainerPtrCDDItemInfoRefBoolRef;
00019     typedef delegates::CMultiDelegate3<DDContainer*, const DDItemInfo&, bool> EventHandle_DDContainerPtrCDDItemInfoRefBool;
00020     typedef delegates::CMultiDelegate2<DDContainer*, DDItemState> EventHandle_EventHandle_DDContainerPtrDDItemState;
00021     typedef delegates::CDelegate3<DDContainer*, Widget*&, IntCoord&> EventHandle_EventHandle_DDContainerPtrWidgetPtrRefIntCoordRef;
00022 
00023 
00027     class MYGUI_EXPORT DDContainer :
00028         public Widget
00029     {
00030         MYGUI_RTTI_DERIVED( DDContainer )
00031 
00032     public:
00033         DDContainer();
00034 
00038         void setNeedDragDrop(bool _value);
00040         bool getNeedDragDrop() const;
00041 
00042         void resetDrag();
00043 
00044         /*events:*/
00051         EventHandle_DDContainerPtrCDDItemInfoRefBoolRef eventStartDrag;
00052 
00059         EventHandle_DDContainerPtrCDDItemInfoRefBoolRef eventRequestDrop;
00060 
00067         EventHandle_DDContainerPtrCDDItemInfoRefBool eventDropResult;
00068 
00074         EventHandle_EventHandle_DDContainerPtrDDItemState eventChangeDDState;
00075 
00082         EventHandle_EventHandle_DDContainerPtrWidgetPtrRefIntCoordRef requestDragWidgetInfo;
00083 
00084 
00085         /*internal:*/
00086         // метод для установления стейта айтема
00087         virtual void _setContainerItemInfo(size_t _index, bool _set, bool _accept);
00088 
00093         delegates::CMultiDelegate1<DDContainer*> _eventInvalideContainer;
00094 
00101         delegates::CMultiDelegate3<DDContainer*, Widget*, const DDWidgetState&> eventUpdateDropState;
00102 
00103     protected:
00104         virtual void onMouseButtonPressed(int _left, int _top, MouseButton _id);
00105         virtual void onMouseButtonReleased(int _left, int _top, MouseButton _id);
00106         virtual void onMouseDrag(int _left, int _top, MouseButton _id);
00107 
00108         virtual void notifyInvalideDrop(DDContainer* _sender);
00109 
00110         virtual void removeDropItems();
00111         virtual void updateDropItems();
00112         virtual void updateDropItemsState(const DDWidgetState& _state);
00113 
00114         void mouseDrag(MouseButton _id);
00115         void mouseButtonReleased(MouseButton _id);
00116         void mouseButtonPressed(MouseButton _id);
00117 
00118         void endDrop(bool _reset);
00119 
00120         virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
00121 
00122     protected:
00123         bool mDropResult;
00124         bool mNeedDrop;
00125         bool mStartDrop;
00126 
00127         Widget* mOldDrop;
00128         Widget* mCurrentSender;
00129 
00130         DDItemInfo mDropInfo;
00131 
00132         size_t mDropSenderIndex;
00133 
00134         // список виджетов для дропа
00135         Widget* mDropItem;
00136         IntCoord mDropDimension;
00137 
00138         IntPoint mClickInWidget;
00139 
00140         // нужно и виджету поддержка драг энд дропа
00141         bool mNeedDragDrop;
00142 
00143         DDContainer* mReseiverContainer;
00144     };
00145 
00146 } // namespace MyGUI
00147 
00148 #endif // __MYGUI_DDCONTAINER_H__