Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: 14/2/2005 00003 author: Paul D Turner 00004 *************************************************************************/ 00005 /*************************************************************************** 00006 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00007 * 00008 * Permission is hereby granted, free of charge, to any person obtaining 00009 * a copy of this software and associated documentation files (the 00010 * "Software"), to deal in the Software without restriction, including 00011 * without limitation the rights to use, copy, modify, merge, publish, 00012 * distribute, sublicense, and/or sell copies of the Software, and to 00013 * permit persons to whom the Software is furnished to do so, subject to 00014 * the following conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be 00017 * included in all copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00020 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00021 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00022 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00023 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00024 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00025 * OTHER DEALINGS IN THE SOFTWARE. 00026 ***************************************************************************/ 00027 #ifndef _CEGUIDragContainer_h_ 00028 #define _CEGUIDragContainer_h_ 00029 00030 #include "../Window.h" 00031 #include "../WindowFactory.h" 00032 00033 #if defined(_MSC_VER) 00034 # pragma warning(push) 00035 # pragma warning(disable : 4251) 00036 #endif 00037 00038 // Start of CEGUI namespace section 00039 namespace CEGUI 00040 { 00045 class CEGUIEXPORT DragContainer : public Window 00046 { 00047 public: 00048 /************************************************************************* 00049 Constants 00050 *************************************************************************/ 00051 static const String WidgetTypeName; 00052 static const String EventNamespace; 00053 00058 static const String EventDragStarted; 00064 static const String EventDragEnded; 00070 static const String EventDragPositionChanged; 00076 static const String EventDragEnabledChanged; 00082 static const String EventDragAlphaChanged; 00088 static const String EventDragMouseCursorChanged; 00094 static const String EventDragThresholdChanged; 00101 static const String EventDragDropTargetChanged; 00102 00103 /************************************************************************* 00104 Object Construction and Destruction 00105 *************************************************************************/ 00110 DragContainer(const String& type, const String& name); 00111 00116 virtual ~DragContainer(void); 00117 00118 /************************************************************************* 00119 Public Interface to DragContainer 00120 *************************************************************************/ 00129 bool isDraggingEnabled(void) const; 00130 00142 void setDraggingEnabled(bool setting); 00143 00152 bool isBeingDragged(void) const; 00153 00165 float getPixelDragThreshold(void) const; 00166 00181 void setPixelDragThreshold(float pixels); 00182 00191 float getDragAlpha(void) const; 00192 00208 void setDragAlpha(float alpha); 00209 00218 const Image* getDragCursorImage(void) const; 00219 00234 void setDragCursorImage(const Image* image); 00235 00252 void setDragCursorImage(const String& name); 00253 00265 Window* getCurrentDropTarget(void) const; 00266 00275 bool isStickyModeEnabled() const; 00276 00285 void setStickyModeEnabled(bool setting); 00286 00303 bool pickUp(const bool force_sticky = false); 00304 00318 void setFixedDragOffset(const UVector2& offset); 00319 00333 const UVector2& getFixedDragOffset() const; 00334 00345 void setUsingFixedDragOffset(const bool enable); 00346 00357 bool isUsingFixedDragOffset() const; 00358 00359 // Window class overrides. 00360 void getRenderingContext_impl(RenderingContext& ctx) const; 00361 00362 protected: 00363 /************************************************************************* 00364 Protected Implementation Methods 00365 *************************************************************************/ 00378 bool isDraggingThresholdExceeded(const Vector2f& local_mouse); 00379 00387 void initialiseDragging(void); 00388 00399 void doDragging(const Vector2f& local_mouse); 00400 00405 void updateActiveMouseCursor(void) const; 00406 00407 /************************************************************************* 00408 Overrides of methods in Window 00409 *************************************************************************/ 00410 00411 /************************************************************************* 00412 Overrides for Event handler methods 00413 *************************************************************************/ 00414 virtual void onMouseButtonDown(MouseEventArgs& e); 00415 virtual void onMouseButtonUp(MouseEventArgs& e); 00416 virtual void onMouseMove(MouseEventArgs& e); 00417 virtual void onCaptureLost(WindowEventArgs& e); 00418 virtual void onAlphaChanged(WindowEventArgs& e); 00419 virtual void onClippingChanged(WindowEventArgs& e);/*Window::drawSelf(z);*/ 00420 virtual void onMoved(ElementEventArgs& e); 00421 00422 /************************************************************************* 00423 New Event handler methods 00424 *************************************************************************/ 00435 virtual void onDragStarted(WindowEventArgs& e); 00436 00447 virtual void onDragEnded(WindowEventArgs& e); 00448 00459 virtual void onDragPositionChanged(WindowEventArgs& e); 00460 00469 virtual void onDragEnabledChanged(WindowEventArgs& e); 00470 00479 virtual void onDragAlphaChanged(WindowEventArgs& e); 00480 00489 virtual void onDragMouseCursorChanged(WindowEventArgs& e); 00490 00499 virtual void onDragThresholdChanged(WindowEventArgs& e); 00500 00516 virtual void onDragDropTargetChanged(DragDropEventArgs& e); 00517 00518 /************************************************************************* 00519 Data 00520 *************************************************************************/ 00521 bool d_draggingEnabled; 00522 bool d_leftMouseDown; 00523 bool d_dragging; 00524 UVector2 d_dragPoint; 00525 UVector2 d_startPosition; 00526 float d_dragThreshold; 00527 float d_dragAlpha; 00528 float d_storedAlpha; 00529 bool d_storedClipState; 00530 Window* d_dropTarget; 00531 const Image* d_dragCursorImage; 00532 bool d_dropflag; 00533 00534 bool d_stickyMode; 00536 bool d_pickedUp; 00538 bool d_usingFixedDragOffset; 00540 UVector2 d_fixedDragOffset; 00541 00542 private: 00543 /************************************************************************* 00544 Implementation methods 00545 *************************************************************************/ 00553 void addDragContainerProperties(void); 00554 }; 00555 00556 } // End of CEGUI namespace section 00557 00558 00559 #if defined(_MSC_VER) 00560 # pragma warning(pop) 00561 #endif 00562 00563 #endif // end of guard _CEGUIDragContainer_h_