Crazy Eddie's GUI System  ${CEGUI_VERSION}
InventoryItem.h
1 /***********************************************************************
2  created: Fri Apr 22 2011
3  author: Paul D Turner <paul@cegui.org.uk>
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _InventoryItem_h_
28 #define _InventoryItem_h_
29 
30 #include "InventoryBase.h"
31 #include <CEGUI/widgets/DragContainer.h>
32 
33 // Start of CEGUI namespace section
34 namespace CEGUI
35 {
36 // class representing an item that can be drag/dropped between
37 // InventoryReceiver objects.
39 {
40 public:
41  static const String WidgetTypeName;
42  static const String EventNamespace;
43 
44  InventoryItem(const String& type, const String& name);
45 
46  // return whether the specified content location is solid.
47  bool isSolidAtLocation(int x, int y) const;
48 
49  // set the content based on the given array. Input array must
50  // hold enough data given the current content size.
51  void setItemLayout(const bool* layout);
52 
53  // return current X grid location on InventoryReceiver. -1 means
54  // invalid / not set. This is typically set and invalidated by the
55  // InventoryReciever::addItemAtLocation and InventoryReciever::removeItem
56  // calls respectively.
57  int locationOnReceiverX() const;
58 
59  // return current Y grid location on InventoryReceiver. -1 means
60  // invalid / not set. This is typically set and invalidated by the
61  // InventoryReciever::addItemAtLocation and InventoryReciever::removeItem
62  // calls respectively.
63  int locationOnReceiverY() const;
64 
65  // set the current grid location. Note this does not update anything as
66  // far as the receiver goes. You will not normally call this directly, see
67  // InventoryReciever::addItemAtLocation instead.
68  void setLocationOnReceiver(int x, int y);
69 
70  // returns whether the current drag/drop target is a valid drop location for
71  // this InventoryItem. Only meaningful if isBeingDragged returns true.
72  bool currentDropTargetIsValid() const;
73 
74  // base class overrides
75  bool isHit(const Vector2f& position, const bool allow_disabled = false) const;
76  void setContentSize(int width, int height);
77 
78 protected:
79  // base class overrides
80  void onMoved(ElementEventArgs& e);
83  Rectf gridBasePixelRect() const;
84 
85  // whether the current drag / drop target is a valid drop location for this
86  // item
87  bool d_validDropTarget;
88  // where our data is on our receivers content map.
89  int d_receiverLocationX;
90  // where our data is on our receivers content map.
91  int d_receiverLocationY;
92 };
93 
94 } // End of CEGUI namespace section
95 
96 #endif // end of guard _InventoryItem_h_
97 
Generic drag & drop enabled window class.
Definition: cegui/include/CEGUI/widgets/DragContainer.h:45
Main namespace for Crazy Eddie&#39;s GUI Library.
Definition: cegui/include/CEGUI/Affector.h:42
EventArgs based class used for certain drag/drop notifications.
Definition: cegui/include/CEGUI/InputEvent.h:341
void onDragDropTargetChanged(DragDropEventArgs &e)
Method called when the current drop target of this DragContainer changes.
Definition: InventoryItem.cpp:172
void onMoved(ElementEventArgs &e)
Handler called when the window&#39;s position changes.
Definition: InventoryItem.cpp:148
Definition: InventoryBase.h:37
void populateGeometryBuffer()
Update the rendering cache.
Definition: InventoryItem.cpp:111
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: cegui/include/CEGUI/Element.h:210
bool isHit(const Vector2f &position, const bool allow_disabled=false) const
check if the given pixel position would hit this window.
Definition: InventoryItem.cpp:90
Definition: InventoryItem.h:38
String class used within the GUI system.
Definition: cegui/include/CEGUI/String.h:62