/usr/include/CEGUI/elements/CEGUIDragContainer.h is in libcegui-mk2-dev 0.7.6-3.3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 | /***********************************************************************
filename: CEGUIDragContainer.h
created: 14/2/2005
author: Paul D Turner
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
#ifndef _CEGUIDragContainer_h_
#define _CEGUIDragContainer_h_
#include "../CEGUIWindow.h"
#include "../CEGUIWindowFactory.h"
#include "CEGUIDragContainerProperties.h"
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4251)
#endif
// Start of CEGUI namespace section
namespace CEGUI
{
/*!
\brief
Generic drag & drop enabled window class
*/
class CEGUIEXPORT DragContainer : public Window
{
public:
/*************************************************************************
Constants
*************************************************************************/
static const String WidgetTypeName; //!< Type name for DragContainer.
static const String EventNamespace; //!< Namespace for global events
/** Event fired when the user begins dragging the DragContainer.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the DragContainer that the user
* has started to drag.
*/
static const String EventDragStarted;
/** Event fired when the user releases the DragContainer.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the DragContainer that the user has
* released.
*/
static const String EventDragEnded;
/** Event fired when the drag position has changed.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the DragContainer whose position has
* changed due to the user dragging it.
*/
static const String EventDragPositionChanged;
/** Event fired when dragging is enabled or disabled.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the DragContainer whose setting has
* been changed.
*/
static const String EventDragEnabledChanged;
/** Event fired when the alpha value used when dragging is changed.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the DragContainer whose drag alpha
* value has been changed.
*/
static const String EventDragAlphaChanged;
/** Event fired when the mouse cursor to used when dragging is changed.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the DragContainer whose dragging
* mouse cursor image has been changed.
*/
static const String EventDragMouseCursorChanged;
/** Event fired when the drag pixel threshold is changed.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the DragContainer whose dragging pixel
* threshold has been changed.
*/
static const String EventDragThresholdChanged;
/** Event fired when the drop target changes.
* Handlers are passed a const DragDropEventArgs reference with
* WindowEventArgs::window set to the Window that is now the target
* window and DragDropEventArgs::dragDropItem set to the DragContainer
* whose target has changed.
*/
static const String EventDragDropTargetChanged;
/*************************************************************************
Object Construction and Destruction
*************************************************************************/
/*!
\brief
Constructor for DragContainer objects
*/
DragContainer(const String& type, const String& name);
/*!
\brief
Destructor for DragContainer objects
*/
virtual ~DragContainer(void);
/*************************************************************************
Public Interface to DragContainer
*************************************************************************/
/*!
\brief
Return whether dragging is currently enabled for this DragContainer.
\return
- true if dragging is enabled and the DragContainer may be dragged.
- false if dragging is disabled and the DragContainer may not be dragged.
*/
bool isDraggingEnabled(void) const;
/*!
\brief
Set whether dragging is currently enabled for this DragContainer.
\param setting
- true to enable dragging so that the DragContainer may be dragged.
- false to disabled dragging so that the DragContainer may not be dragged.
\return
Nothing.
*/
void setDraggingEnabled(bool setting);
/*!
\brief
Return whether the DragContainer is currently being dragged.
\return
- true if the DragContainer is being dragged.
- false if te DragContainer is not being dragged.
*/
bool isBeingDragged(void) const;
/*!
\brief
Return the current drag threshold in pixels.
The drag threshold is the number of pixels that the mouse must be
moved with the left button held down in order to commence a drag
operation.
\return
float value indicating the current drag threshold value.
*/
float getPixelDragThreshold(void) const;
/*!
\brief
Set the current drag threshold in pixels.
The drag threshold is the number of pixels that the mouse must be
moved with the left button held down in order to commence a drag
operation.
\param pixels
float value indicating the new drag threshold value.
\return
Nothing.
*/
void setPixelDragThreshold(float pixels);
/*!
\brief
Return the alpha value that will be set on the DragContainer while a drag operation is
in progress.
\return
Current alpha value to use whilst dragging.
*/
float getDragAlpha(void) const;
/*!
\brief
Set the alpha value to be set on the DragContainer when a drag operation is
in progress.
This method can be used while a drag is in progress to update the alpha. Note that
the normal setAlpha method does not affect alpha while a drag is in progress, but
once the drag operation has ended, any value set via setAlpha will be restored.
\param alpha
Alpha value to use whilst dragging.
\return
Nothing.
*/
void setDragAlpha(float alpha);
/*!
\brief
Return the Image currently set to be used for the mouse cursor when a
drag operation is in progress.
\return
Image object currently set to be used as the mouse cursor when dragging.
*/
const Image* getDragCursorImage(void) const;
/*!
\brief
Set the Image to be used for the mouse cursor when a drag operation is
in progress.
This method may be used during a drag operation to update the current mouse
cursor image.
\param image
Image object to be used as the mouse cursor while dragging.
\return
Nothing.
*/
void setDragCursorImage(const Image* image);
/*!
\brief
Set the Image to be used for the mouse cursor when a drag operation is
in progress.
This method may be used during a drag operation to update the current mouse
cursor image.
\param image
One of the MouseCursorImage enumerated values.
\return
Nothing.
*/
void setDragCursorImage(MouseCursorImage image);
/*!
\brief
Set the Image to be used for the mouse cursor when a drag operation is
in progress.
This method may be used during a drag operation to update the current mouse
cursor image.
\param imageset
String holding the name of the Imageset that contains the Image to be used.
\param image
Image defined for the Imageset \a imageset to be used as the mouse cursor
when dragging.
\return
Nothing.
\exception UnknownObjectException thrown if either \a imageset or \a image are unknown.
*/
void setDragCursorImage(const String& imageset, const String& image);
/*!
\brief
Return the Window object that is the current drop target for the DragContainer.
The drop target for a DragContainer is basically the Window that the DragContainer
is within while being dragged. The drop target may be 0 to indicate no target.
\return
Pointer to a Window object that contains the DragContainer whilst being dragged, or
0 to indicate no current target.
*/
Window* getCurrentDropTarget(void) const;
/*!
\brief
Return whether sticky mode is enable or disabled.
\return
- true if sticky mode is enabled.
- false if sticky mode is disabled.
*/
bool isStickyModeEnabled() const;
/*!
\brief
Enable or disable sticky mode.
\param setting
- true to enable sticky mode.
- false to disable sticky mode.
*/
void setStickyModeEnabled(bool setting);
/*!
\brief
Immediately pick up the DragContainer and optionally set the sticky
mode in order to allow this to happen. Any current interaction
(i.e. mouse capture) will be interrupted.
\param force_sticky
- true to automatically enable the sticky mode in order to
facilitate picking up the DragContainer.
- false to ignore the pick up request if the sticky mode is not
alraedy enabled (default).
\return
- true if the DragContainer was successfully picked up.
- false if the DragContainer was not picked up.
*/
bool pickUp(const bool force_sticky = false);
/*!
\brief
Set the fixed mouse cursor dragging offset to be used for this
DragContainer.
\param offset
UVector2 describing the fixed offset to be used when dragging this
DragContainer.
\note
This offset is only used if it's use is enabled via the
setUsingFixedDragOffset function.
*/
void setFixedDragOffset(const UVector2& offset);
/*!
\brief
Return the fixed mouse cursor dragging offset to be used for this
DragContainer.
\return
UVector2 describing the fixed offset used when dragging this
DragContainer.
\note
This offset is only used if it's use is enabled via the
setUsingFixedDragOffset function.
*/
const UVector2& getFixedDragOffset() const;
/*!
\brief
Set whether the fixed dragging offset - as set with the
setFixedDragOffset - function will be used, or whether the built-in
positioning will be used.
\param enable
- true to enabled the use of the fixed offset.
- false to use the regular logic.
*/
void setUsingFixedDragOffset(const bool enable);
/*!
\brief
Return whether the fixed dragging offset - as set with the
setFixedDragOffset function - will be used, or whether the built-in
positioning will be used.
\param enable
- true to enabled the use of the fixed offset.
- false to use the regular logic.
*/
bool isUsingFixedDragOffset() const;
// Window class overrides.
void getRenderingContext_impl(RenderingContext& ctx) const;
protected:
/*************************************************************************
Protected Implementation Methods
*************************************************************************/
/*!
\brief
Return whether the required minimum movement threshold before initiating dragging
has been exceeded.
\param local_mouse
Mouse position as a pixel offset from the top-left corner of this window.
\return
- true if the threshold has been exceeded and dragging should be initiated.
- false if the threshold has not been exceeded.
*/
bool isDraggingThresholdExceeded(const Point& local_mouse);
/*!
\brief
Initialise the required states to put the window into dragging mode.
\return
Nothing.
*/
void initialiseDragging(void);
/*!
\brief
Update state for window dragging.
\param local_mouse
Mouse position as a pixel offset from the top-left corner of this window.
\return
Nothing.
*/
void doDragging(const Point& local_mouse);
/*!
\brief
Method to update mouse cursor image
*/
void updateActiveMouseCursor(void) const;
/*!
\brief
Return whether this window was inherited from the given class name at some point in the inheritance hierarchy.
\param class_name
The class name that is to be checked.
\return
true if this window was inherited from \a class_name. false if not.
*/
virtual bool testClassName_impl(const String& class_name) const
{
if (class_name=="DragContainer") return true;
return Window::testClassName_impl(class_name);
}
/*************************************************************************
Overrides of methods in Window
*************************************************************************/
/*************************************************************************
Overrides for Event handler methods
*************************************************************************/
virtual void onMouseButtonDown(MouseEventArgs& e);
virtual void onMouseButtonUp(MouseEventArgs& e);
virtual void onMouseMove(MouseEventArgs& e);
virtual void onCaptureLost(WindowEventArgs& e);
virtual void onAlphaChanged(WindowEventArgs& e);
virtual void onClippingChanged(WindowEventArgs& e);/*Window::drawSelf(z);*/
virtual void onMoved(WindowEventArgs& e);
/*************************************************************************
New Event handler methods
*************************************************************************/
/*!
\brief
Method called when dragging commences
\param e
WindowEventArgs object containing any relevant data.
\return
Nothing.
*/
virtual void onDragStarted(WindowEventArgs& e);
/*!
\brief
Method called when dragging ends.
\param e
WindowEventArgs object containing any relevant data.
\return
Nothing.
*/
virtual void onDragEnded(WindowEventArgs& e);
/*!
\brief
Method called when the dragged object position is changed.
\param e
WindowEventArgs object containing any relevant data.
\return
Nothing.
*/
virtual void onDragPositionChanged(WindowEventArgs& e);
/*!
\brief
Method called when the dragging state is enabled or disabled
\param e
WindowEventArgs object.
\return
Nothing.
*/
virtual void onDragEnabledChanged(WindowEventArgs& e);
/*!
\brief
Method called when the alpha value to use when dragging is changed.
\param e
WindowEventArgs object.
\return
Nothing.
*/
virtual void onDragAlphaChanged(WindowEventArgs& e);
/*!
\brief
Method called when the mouse cursor to use when dragging is changed.
\param e
WindowEventArgs object.
\return
Nothing.
*/
virtual void onDragMouseCursorChanged(WindowEventArgs& e);
/*!
\brief
Method called when the movement threshold required to trigger dragging is changed.
\param e
WindowEventArgs object.
\return
Nothing.
*/
virtual void onDragThresholdChanged(WindowEventArgs& e);
/*!
\brief
Method called when the current drop target of this DragContainer changes.
\note
This event fires just prior to the target field being changed. The default implementation
changes the drop target, you can examine the old and new targets before calling the default
implementation to make the actual change (and fire appropriate events for the Window objects
involved).
\param e
DragDropEventArgs object initialised as follows:
- dragDropItem is initialised to the DragContainer triggering the event (typically 'this').
- window is initialised to point to the Window which will be the new drop target.
\return
Nothing.
*/
virtual void onDragDropTargetChanged(DragDropEventArgs& e);
/*************************************************************************
Data
*************************************************************************/
bool d_draggingEnabled; //!< True when dragging is enabled.
bool d_leftMouseDown; //!< True when left mouse button is down.
bool d_dragging; //!< true when being dragged.
UVector2 d_dragPoint; //!< point we are being dragged at.
UVector2 d_startPosition; //!< position prior to dragging.
float d_dragThreshold; //!< Pixels mouse must move before dragging commences.
float d_dragAlpha; //!< Alpha value to set when dragging.
float d_storedAlpha; //!< Alpha value to re-set when dragging ends.
bool d_storedClipState; //!< Parent clip state to re-set.
Window* d_dropTarget; //!< Target window for possible drop operation.
const Image* d_dragCursorImage; //!< Image to use for mouse cursor when dragging.
bool d_dropflag; //!< True when we're being dropped
//! true when we're in 'sticky' mode.
bool d_stickyMode;
//! true after been picked-up / dragged via sticky mode
bool d_pickedUp;
//! true if fixed mouse offset is used for dragging position.
bool d_usingFixedDragOffset;
//! current fixed mouse offset value.
UVector2 d_fixedDragOffset;
private:
/*************************************************************************
Static properties for the Spinner widget
*************************************************************************/
static DragContainerProperties::DragAlpha d_dragAlphaProperty;
static DragContainerProperties::DragCursorImage d_dragCursorImageProperty;
static DragContainerProperties::DraggingEnabled d_dragEnabledProperty;
static DragContainerProperties::DragThreshold d_dragThresholdProperty;
static DragContainerProperties::StickyMode d_stickyModeProperty;
static DragContainerProperties::FixedDragOffset d_fixedDragOffsetProperty;
static DragContainerProperties::UseFixedDragOffset d_useFixedDragOffsetProperty;
/*************************************************************************
Implementation methods
*************************************************************************/
/*!
\brief
Adds properties specific to the DragContainer base class.
\return
Nothing.
*/
void addDragContainerProperties(void);
};
} // End of CEGUI namespace section
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#endif // end of guard _CEGUIDragContainer_h_
|