#include <itemcontainer.h>
Used to show items in inventory and trade dialog.
Definition at line 46 of file itemcontainer.h.
Public Member Functions | |
ItemContainer (Inventory *inventory, bool forceQuantity=false) | |
Constructor. | |
virtual | ~ItemContainer () |
Destructor. | |
void | draw (gcn::Graphics *graphics) |
Draws the items. | |
void | keyPressed (gcn::KeyEvent &event) |
void | keyReleased (gcn::KeyEvent &event) |
void | mousePressed (gcn::MouseEvent &event) |
void | mouseDragged (gcn::MouseEvent &event) |
void | mouseReleased (gcn::MouseEvent &event) |
void | mouseMoved (gcn::MouseEvent &event) |
void | mouseExited (gcn::MouseEvent &event) |
void | widgetResized (const gcn::Event &event) |
Item * | getSelectedItem () const |
Returns the selected item. | |
void | selectNone () |
Sets selected item to NULL. | |
void | addSelectionListener (gcn::SelectionListener *listener) |
Adds a listener to the list that's notified each time a change to the selection occurs. | |
void | removeSelectionListener (gcn::SelectionListener *listener) |
Removes a listener from the list that's notified each time a change to the selection occurs. | |
Private Types | |
enum | Direction { Left, Right, Up, Down } |
enum | SelectionState { SEL_NONE = 0, SEL_SELECTED, SEL_SELECTING, SEL_DESELECTING, SEL_DRAGGING } |
typedef std::list < gcn::SelectionListener * > | SelectionListenerList |
typedef SelectionListenerList::iterator | SelectionListenerIterator |
Private Member Functions | |
void | keyAction () |
Execute all the functionality associated with the action key. | |
void | moveHighlight (Direction direction) |
Moves the highlight in the direction specified. | |
void | setSelectedItem (Item *item) |
Sets the currently selected item. | |
void | refindSelectedItem () |
Find the current item index by the most recently used item ID. | |
void | recalculateHeight () |
Determine and set the height of the container. | |
void | distributeValueChangedEvent () |
Sends out selection events to the list of selection listeners. | |
int | getSlotIndex (int x, int y) const |
Gets the slot index based on the cursor position. | |
Private Attributes | |
Inventory * | mInventory |
int | mGridColumns |
int | mGridRows |
Image * | mSelImg |
Item * | mSelectedItem |
Item * | mHighlightedItem |
SelectionState | mSelectionStatus |
bool | mForceQuantity |
bool | mSwapItems |
bool | mDescItems |
int | mDragPosX |
int | mDragPosY |
ItemPopup * | mItemPopup |
SelectionListenerList | mSelectionListeners |
typedef std::list<gcn::SelectionListener*> ItemContainer::SelectionListenerList [private] |
Definition at line 186 of file itemcontainer.h.
typedef SelectionListenerList::iterator ItemContainer::SelectionListenerIterator [private] |
Definition at line 187 of file itemcontainer.h.
enum ItemContainer::Direction [private] |
enum ItemContainer::SelectionState [private] |
Definition at line 124 of file itemcontainer.h.
ItemContainer::ItemContainer | ( | Inventory * | inventory, | |
bool | forceQuantity = false | |||
) |
Constructor.
Initializes the graphic.
inventory | ||
gridColumns | Amount of columns in grid. | |
gridRows | Amount of rows in grid. | |
offset | Index offset |
Definition at line 52 of file itemcontainer.cpp.
ItemContainer::~ItemContainer | ( | ) | [virtual] |
void ItemContainer::draw | ( | gcn::Graphics * | graphics | ) |
void ItemContainer::keyPressed | ( | gcn::KeyEvent & | event | ) |
Definition at line 172 of file itemcontainer.cpp.
void ItemContainer::keyReleased | ( | gcn::KeyEvent & | event | ) |
Definition at line 201 of file itemcontainer.cpp.
void ItemContainer::mousePressed | ( | gcn::MouseEvent & | event | ) |
Definition at line 215 of file itemcontainer.cpp.
void ItemContainer::mouseDragged | ( | gcn::MouseEvent & | event | ) |
Definition at line 251 of file itemcontainer.cpp.
void ItemContainer::mouseReleased | ( | gcn::MouseEvent & | event | ) |
Definition at line 261 of file itemcontainer.cpp.
void ItemContainer::mouseMoved | ( | gcn::MouseEvent & | event | ) |
Definition at line 292 of file itemcontainer.cpp.
void ItemContainer::mouseExited | ( | gcn::MouseEvent & | event | ) |
Definition at line 308 of file itemcontainer.cpp.
void ItemContainer::widgetResized | ( | const gcn::Event & | event | ) |
Definition at line 313 of file itemcontainer.cpp.
Item* ItemContainer::getSelectedItem | ( | ) | const [inline] |
void ItemContainer::selectNone | ( | ) |
void ItemContainer::addSelectionListener | ( | gcn::SelectionListener * | listener | ) | [inline] |
Adds a listener to the list that's notified each time a change to the selection occurs.
Definition at line 101 of file itemcontainer.h.
void ItemContainer::removeSelectionListener | ( | gcn::SelectionListener * | listener | ) | [inline] |
Removes a listener from the list that's notified each time a change to the selection occurs.
Definition at line 110 of file itemcontainer.h.
void ItemContainer::keyAction | ( | ) | [private] |
Execute all the functionality associated with the action key.
Definition at line 332 of file itemcontainer.cpp.
void ItemContainer::moveHighlight | ( | Direction | direction | ) | [private] |
Moves the highlight in the direction specified.
direction | The move direction of the highlighter. |
Definition at line 369 of file itemcontainer.cpp.
void ItemContainer::setSelectedItem | ( | Item * | item | ) | [private] |
void ItemContainer::refindSelectedItem | ( | ) | [private] |
Find the current item index by the most recently used item ID.
void ItemContainer::recalculateHeight | ( | ) | [private] |
Determine and set the height of the container.
void ItemContainer::distributeValueChangedEvent | ( | void | ) | [private] |
Sends out selection events to the list of selection listeners.
Definition at line 160 of file itemcontainer.cpp.
int ItemContainer::getSlotIndex | ( | int | x, | |
int | y | |||
) | const [private] |
Gets the slot index based on the cursor position.
x | The X coordinate position. | |
y | The Y coordinate position. |
Definition at line 323 of file itemcontainer.cpp.
Inventory* ItemContainer::mInventory [private] |
Definition at line 174 of file itemcontainer.h.
int ItemContainer::mGridColumns [private] |
Definition at line 175 of file itemcontainer.h.
int ItemContainer::mGridRows [private] |
Definition at line 175 of file itemcontainer.h.
Image* ItemContainer::mSelImg [private] |
Definition at line 176 of file itemcontainer.h.
Item* ItemContainer::mSelectedItem [private] |
Definition at line 177 of file itemcontainer.h.
Item * ItemContainer::mHighlightedItem [private] |
Definition at line 177 of file itemcontainer.h.
Definition at line 178 of file itemcontainer.h.
bool ItemContainer::mForceQuantity [private] |
Definition at line 179 of file itemcontainer.h.
bool ItemContainer::mSwapItems [private] |
Definition at line 180 of file itemcontainer.h.
bool ItemContainer::mDescItems [private] |
Definition at line 181 of file itemcontainer.h.
int ItemContainer::mDragPosX [private] |
Definition at line 182 of file itemcontainer.h.
int ItemContainer::mDragPosY [private] |
Definition at line 182 of file itemcontainer.h.
ItemPopup* ItemContainer::mItemPopup [private] |
Definition at line 184 of file itemcontainer.h.
Definition at line 189 of file itemcontainer.h.