Mana
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
GuiTable Class Referencefinal

A table, with rows and columns made out of sub-widgets. More...

#include <table.h>

Inheritance diagram for GuiTable:
TableModelListener

Public Member Functions

 GuiTable (TableModel *initialModel=nullptr, gcn::Color background=0xffffff, bool opacity=true)
 
 ~GuiTable () override
 
TableModelgetModel () const
 Retrieves the active table model.
 
void setModel (TableModel *m)
 Sets the table model.
 
void setSelected (int row, int column)
 
int getSelectedRow () const
 
int getSelectedColumn () const
 
void setSelectedRow (int selected)
 
void setSelectedColumn (int selected)
 
bool isWrappingEnabled () const
 
void setWrappingEnabled (bool wrappingEnabled)
 
gcn::Rectangle getChildrenArea () override
 
void setLinewiseSelection (bool linewise)
 Toggle whether to use linewise selection mode, in which the table selects an entire line at a time, rather than a single cell.
 
void draw (gcn::Graphics *graphics) override
 
void drawFrame (gcn::Graphics *graphics) override
 
gcn::Widget * getWidgetAt (int x, int y) override
 
void moveToTop (gcn::Widget *child) override
 
void moveToBottom (gcn::Widget *child) override
 
void _setFocusHandler (gcn::FocusHandler *focusHandler) override
 
void keyPressed (gcn::KeyEvent &keyEvent) override
 
void setOpaque (bool opaque)
 Sets the table to be opaque, that is sets the table to display its background.
 
bool isOpaque () const
 Checks if the table is opaque, that is if the table area displays its background.
 
void mousePressed (gcn::MouseEvent &mouseEvent) override
 
void mouseWheelMovedUp (gcn::MouseEvent &mouseEvent) override
 
void mouseWheelMovedDown (gcn::MouseEvent &mouseEvent) override
 
void mouseDragged (gcn::MouseEvent &mouseEvent) override
 
void modelUpdated (bool) override
 Must be invoked by the TableModel whenever a global change is about to occur or has occurred (e.g., when a row or column is being removed or added).
 
- Public Member Functions inherited from TableModelListener
virtual ~TableModelListener ()
 

Protected Member Functions

void uninstallActionListeners ()
 Frees all action listeners on inner widgets.
 
void installActionListeners ()
 Installs all action listeners on inner widgets.
 
int getRowHeight () const
 
int getColumnWidth (int i) const
 

Private Member Functions

int getRowForY (int y) const
 
int getColumnForX (int x) const
 
void recomputeDimensions ()
 

Private Attributes

bool mLinewiseMode = false
 
bool mWrappingEnabled = false
 
bool mOpaque
 
gcn::Color mBackgroundColor
 Holds the background color of the table.
 
TableModelmModel = nullptr
 
int mSelectedRow = 0
 
int mSelectedColumn = 0
 
gcn::Widget * mTopWidget = nullptr
 If someone moves a fresh widget to the top, we must display it.
 
std::vector< GuiTableActionListener * > mActionListeners
 Vector for compactness; used as a list in practice.
 

Friends

class GuiTableActionListener
 

Detailed Description

A table, with rows and columns made out of sub-widgets.

Largely inspired by (and can be thought of as a generalisation of) the guichan listbox implementation.

Normally you want this within a ScrollArea.

Definition at line 43 of file table.h.

Constructor & Destructor Documentation

◆ GuiTable()

GuiTable::GuiTable ( TableModel initialModel = nullptr,
gcn::Color  background = 0xffffff,
bool  opacity = true 
)

Definition at line 80 of file table.cpp.

◆ ~GuiTable()

GuiTable::~GuiTable ( )
override

Definition at line 92 of file table.cpp.

Member Function Documentation

◆ _setFocusHandler()

void GuiTable::_setFocusHandler ( gcn::FocusHandler *  focusHandler)
override

Definition at line 531 of file table.cpp.

◆ draw()

void GuiTable::draw ( gcn::Graphics *  graphics)
override

Definition at line 257 of file table.cpp.

◆ drawFrame()

void GuiTable::drawFrame ( gcn::Graphics *  graphics)
inlineoverride

Definition at line 106 of file table.h.

◆ getChildrenArea()

gcn::Rectangle GuiTable::getChildrenArea ( )
override

Definition at line 363 of file table.cpp.

◆ getColumnForX()

int GuiTable::getColumnForX ( int  x) const
private

Definition at line 513 of file table.cpp.

◆ getColumnWidth()

int GuiTable::getColumnWidth ( int  i) const
protected

Definition at line 171 of file table.cpp.

◆ getModel()

TableModel * GuiTable::getModel ( ) const

Retrieves the active table model.

Definition at line 98 of file table.cpp.

◆ getRowForY()

int GuiTable::getRowForY ( int  y) const
private

Definition at line 500 of file table.cpp.

◆ getRowHeight()

int GuiTable::getRowHeight ( ) const
protected

Definition at line 164 of file table.cpp.

◆ getSelectedColumn()

int GuiTable::getSelectedColumn ( ) const

Definition at line 154 of file table.cpp.

◆ getSelectedRow()

int GuiTable::getSelectedRow ( ) const

Definition at line 149 of file table.cpp.

◆ getWidgetAt()

gcn::Widget * GuiTable::getWidgetAt ( int  x,
int  y 
)
override

Definition at line 482 of file table.cpp.

◆ installActionListeners()

void GuiTable::installActionListeners ( )
protected

Installs all action listeners on inner widgets.

Definition at line 237 of file table.cpp.

◆ isOpaque()

bool GuiTable::isOpaque ( ) const
inline

Checks if the table is opaque, that is if the table area displays its background.

Returns
True if the table is opaque, false otherwise.

Definition at line 133 of file table.h.

◆ isWrappingEnabled()

bool GuiTable::isWrappingEnabled ( ) const
inline

Definition at line 82 of file table.h.

◆ keyPressed()

void GuiTable::keyPressed ( gcn::KeyEvent &  keyEvent)
override

Definition at line 369 of file table.cpp.

◆ modelUpdated()

void GuiTable::modelUpdated ( bool  completed)
overridevirtual

Must be invoked by the TableModel whenever a global change is about to occur or has occurred (e.g., when a row or column is being removed or added).

This method is triggered twice, once before and once after the update.

Parameters
completedwhether we are signalling the end of the update

Implements TableModelListener.

Definition at line 468 of file table.cpp.

◆ mouseDragged()

void GuiTable::mouseDragged ( gcn::MouseEvent &  mouseEvent)
override

Definition at line 454 of file table.cpp.

◆ mousePressed()

void GuiTable::mousePressed ( gcn::MouseEvent &  mouseEvent)
override

Definition at line 413 of file table.cpp.

◆ mouseWheelMovedDown()

void GuiTable::mouseWheelMovedDown ( gcn::MouseEvent &  mouseEvent)
override

Definition at line 444 of file table.cpp.

◆ mouseWheelMovedUp()

void GuiTable::mouseWheelMovedUp ( gcn::MouseEvent &  mouseEvent)
override

Definition at line 431 of file table.cpp.

◆ moveToBottom()

void GuiTable::moveToBottom ( gcn::Widget *  child)
override

Definition at line 356 of file table.cpp.

◆ moveToTop()

void GuiTable::moveToTop ( gcn::Widget *  child)
override

Definition at line 350 of file table.cpp.

◆ recomputeDimensions()

void GuiTable::recomputeDimensions ( )
private

Definition at line 121 of file table.cpp.

◆ setLinewiseSelection()

void GuiTable::setLinewiseSelection ( bool  linewise)

Toggle whether to use linewise selection mode, in which the table selects an entire line at a time, rather than a single cell.

Note that column information is tracked even in linewise selection mode; this mode therefore only affects visualisation.

Disabled by default.

Parameters
linewiseWhether to enable linewise selection mode

Definition at line 159 of file table.cpp.

◆ setModel()

void GuiTable::setModel ( TableModel m)

Sets the table model.

Note that actions issued by widgets returned from the model will update the table selection, but only AFTER any event handlers installed within the widget have been triggered. To be notified after such an update, add an action listener to the table instead.

Definition at line 103 of file table.cpp.

◆ setOpaque()

void GuiTable::setOpaque ( bool  opaque)
inline

Sets the table to be opaque, that is sets the table to display its background.

Parameters
opaqueTrue if the table should be opaque, false otherwise.

Definition at line 125 of file table.h.

◆ setSelected()

void GuiTable::setSelected ( int  row,
int  column 
)

Definition at line 143 of file table.cpp.

◆ setSelectedColumn()

void GuiTable::setSelectedColumn ( int  selected)

Definition at line 206 of file table.cpp.

◆ setSelectedRow()

void GuiTable::setSelectedRow ( int  selected)

Definition at line 178 of file table.cpp.

◆ setWrappingEnabled()

void GuiTable::setWrappingEnabled ( bool  wrappingEnabled)
inline

Definition at line 84 of file table.h.

◆ uninstallActionListeners()

void GuiTable::uninstallActionListeners ( )
protected

Frees all action listeners on inner widgets.

Definition at line 231 of file table.cpp.

Friends And Related Symbol Documentation

◆ GuiTableActionListener

friend class GuiTableActionListener
friend

Definition at line 49 of file table.h.

Member Data Documentation

◆ mActionListeners

std::vector<GuiTableActionListener *> GuiTable::mActionListeners
private

Vector for compactness; used as a list in practice.

Definition at line 179 of file table.h.

◆ mBackgroundColor

gcn::Color GuiTable::mBackgroundColor
private

Holds the background color of the table.

Definition at line 168 of file table.h.

◆ mLinewiseMode

bool GuiTable::mLinewiseMode = false
private

Definition at line 161 of file table.h.

◆ mModel

TableModel* GuiTable::mModel = nullptr
private

Definition at line 170 of file table.h.

◆ mOpaque

bool GuiTable::mOpaque
private

Definition at line 163 of file table.h.

◆ mSelectedColumn

int GuiTable::mSelectedColumn = 0
private

Definition at line 173 of file table.h.

◆ mSelectedRow

int GuiTable::mSelectedRow = 0
private

Definition at line 172 of file table.h.

◆ mTopWidget

gcn::Widget* GuiTable::mTopWidget = nullptr
private

If someone moves a fresh widget to the top, we must display it.

Definition at line 176 of file table.h.

◆ mWrappingEnabled

bool GuiTable::mWrappingEnabled = false
private

Definition at line 162 of file table.h.


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