MyGUI 3.0.1
MyGUI_DDContainer.h
Go to the documentation of this file.
00001 
00007 /*
00008     This file is part of MyGUI.
00009 
00010     MyGUI is free software: you can redistribute it and/or modify
00011     it under the terms of the GNU Lesser General Public License as published by
00012     the Free Software Foundation, either version 3 of the License, or
00013     (at your option) any later version.
00014 
00015     MyGUI is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU Lesser General Public License for more details.
00019 
00020     You should have received a copy of the GNU Lesser General Public License
00021     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00022 */
00023 #ifndef __MYGUI_DDCONTAINER_H__
00024 #define __MYGUI_DDCONTAINER_H__
00025 
00026 #include "MyGUI_Prerequest.h"
00027 #include "MyGUI_Widget.h"
00028 #include "MyGUI_DDItemInfo.h"
00029 #include "MyGUI_EventPair.h"
00030 
00031 namespace MyGUI
00032 {
00033 
00034     typedef delegates::CDelegate3<DDContainer*, const DDItemInfo&, bool&> EventHandle_DDContainerPtrCDDItemInfoRefBoolRef;
00035     typedef delegates::CDelegate3<DDContainer*, const DDItemInfo&, bool> EventHandle_DDContainerPtrCDDItemInfoRefBool;
00036     typedef delegates::CDelegate2<DDContainer*, DDItemState> EventHandle_EventHandle_DDContainerPtrDDItemState;
00037     typedef delegates::CDelegate3<DDContainer*, WidgetPtr&, IntCoord&> EventHandle_EventHandle_DDContainerPtrWidgetPtrRefIntCoordRef;
00038 
00039 
00040     class MYGUI_EXPORT DDContainer :
00041         public Widget
00042     {
00043         MYGUI_RTTI_DERIVED( DDContainer )
00044 
00045     public:
00046         DDContainer();
00047 
00051         void setNeedDragDrop(bool _value) { mNeedDragDrop = _value; }
00053         bool getNeedDragDrop() { return mNeedDragDrop; }
00054 
00056         virtual void setProperty(const std::string& _key, const std::string& _value);
00057 
00058     /*event:*/
00065         EventHandle_DDContainerPtrCDDItemInfoRefBoolRef eventStartDrag;
00066 
00073         EventHandle_DDContainerPtrCDDItemInfoRefBoolRef eventRequestDrop;
00074 
00081         EventHandle_DDContainerPtrCDDItemInfoRefBool eventDropResult;
00082 
00088         EventHandle_EventHandle_DDContainerPtrDDItemState eventChangeDDState;
00089 
00096         EventHandle_EventHandle_DDContainerPtrWidgetPtrRefIntCoordRef requestDragWidgetInfo;
00097 
00098 
00099     /*internal:*/
00100         // метод для установления стейта айтема
00101         virtual void _setContainerItemInfo(size_t _index, bool _set, bool _accept) { }
00102 
00103         virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
00104 
00109         EventPair<EventHandle_WidgetVoid, delegates::CDelegate1<DDContainer*> >
00110             _eventInvalideContainer;
00111 
00118         delegates::CDelegate3<DDContainer*, Widget*, const DDWidgetState&>
00119             eventUpdateDropState;
00120 
00121     protected:
00122         virtual ~DDContainer();
00123 
00124         void baseChangeWidgetSkin(ResourceSkin* _info);
00125 
00126         virtual void onMouseButtonPressed(int _left, int _top, MouseButton _id);
00127         virtual void onMouseButtonReleased(int _left, int _top, MouseButton _id);
00128         virtual void onMouseDrag(int _left, int _top);
00129 
00130         virtual void notifyInvalideDrop(DDContainer* _sender);
00131 
00132         virtual void _getContainer(Widget*& _container, size_t& _index);
00133 
00134         virtual void removeDropItems();
00135         virtual void updateDropItems();
00136         virtual void updateDropItemsState(const DDWidgetState& _state);
00137 
00138         void mouseDrag();
00139         void mouseButtonReleased(MouseButton _id);
00140         void mouseButtonPressed(MouseButton _id);
00141 
00142         void endDrop(bool _reset);
00143 
00144     private:
00145         void initialiseWidgetSkin(ResourceSkin* _info);
00146         void shutdownWidgetSkin();
00147 
00148 
00149     protected:
00150         bool mDropResult;
00151         bool mNeedDrop;
00152         bool mStartDrop;
00153 
00154         Widget* mOldDrop;
00155         Widget* mCurrentSender;
00156 
00157         DDItemInfo mDropInfo;
00158 
00159         size_t mDropSenderIndex;
00160 
00161         // список виджетов для дропа
00162         Widget* mDropItem;
00163         IntCoord mDropDimension;
00164 
00165         IntPoint mClickInWidget;
00166 
00167         // нужно и виджету поддержка драг энд дропа
00168         bool mNeedDragDrop;
00169 
00170         DDContainer* mReseiverContainer;
00171     };
00172 
00173 } // namespace MyGUI
00174 
00175 #endif // __MYGUI_DDCONTAINER_H__