ItemContainer Class Reference
[Core GUI related classes (widgets)]

#include <itemcontainer.h>

List of all members.


Detailed Description

An item container.

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)
ItemgetSelectedItem () 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

InventorymInventory
int mGridColumns
int mGridRows
ImagemSelImg
ItemmSelectedItem
ItemmHighlightedItem
SelectionState mSelectionStatus
bool mForceQuantity
bool mSwapItems
bool mDescItems
int mDragPosX
int mDragPosY
ItemPopupmItemPopup
SelectionListenerList mSelectionListeners

Member Typedef Documentation

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.


Member Enumeration Documentation

enum ItemContainer::Direction [private]

Enumerator:
Left 
Right 
Up 
Down 

Definition at line 116 of file itemcontainer.h.

Enumerator:
SEL_NONE 
SEL_SELECTED 
SEL_SELECTING 
SEL_DESELECTING 
SEL_DRAGGING 

Definition at line 124 of file itemcontainer.h.


Constructor & Destructor Documentation

ItemContainer::ItemContainer ( Inventory inventory,
bool  forceQuantity = false 
)

Constructor.

Initializes the graphic.

Parameters:
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]

Destructor.

Definition at line 77 of file itemcontainer.cpp.


Member Function Documentation

void ItemContainer::draw ( gcn::Graphics *  graphics  ) 

Draws the items.

Definition at line 83 of file itemcontainer.cpp.

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]

Returns the selected item.

Definition at line 89 of file itemcontainer.h.

void ItemContainer::selectNone (  ) 

Sets selected item to NULL.

Definition at line 146 of file itemcontainer.cpp.

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.

Parameters:
direction The move direction of the highlighter.

Definition at line 369 of file itemcontainer.cpp.

void ItemContainer::setSelectedItem ( Item item  )  [private]

Sets the currently selected item.

Definition at line 151 of file itemcontainer.cpp.

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.

Parameters:
x The X coordinate position.
y The Y coordinate position.
Returns:
The slot index on success, -1 on failure.

Definition at line 323 of file itemcontainer.cpp.


Member Data Documentation

Definition at line 174 of file itemcontainer.h.

Definition at line 175 of file itemcontainer.h.

int ItemContainer::mGridRows [private]

Definition at line 175 of file itemcontainer.h.

Definition at line 176 of file itemcontainer.h.

Definition at line 177 of file itemcontainer.h.

Definition at line 177 of file itemcontainer.h.

Definition at line 178 of file itemcontainer.h.

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.

Definition at line 184 of file itemcontainer.h.

Definition at line 189 of file itemcontainer.h.


The documentation for this class was generated from the following files:

Generated on Sun Apr 26 17:30:43 2009 for The Mana World by  doxygen 1.5.5