ManaPlus
|
#include <guitable.h>
Public Member Functions | |
GuiTable (const Widget2 *const widget, TableModel *const initial_model, const Opaque opacity) | |
~GuiTable () | |
void | setModel (TableModel *const m) |
const TableModel * | getModel () const |
void | setSelected (const int row, const int column) |
int | getSelectedRow () const |
int | getSelectedColumn () const |
void | setSelectedRow (const int selected) |
void | setSelectedColumn (const int selected) |
bool | isWrappingEnabled () const |
void | setWrappingEnabled (bool wrappingEnabled) |
Rect | getChildrenArea () |
void | setLinewiseSelection (bool linewise) |
void | draw (Graphics *const graphics) |
void | safeDraw (Graphics *const graphics) |
Widget * | getWidgetAt (int x, int y) |
void | moveToTop (Widget *const widget) |
void | moveToBottom (Widget *const widget) |
void | setFocusHandler (FocusHandler *const focusHandler) |
void | keyPressed (KeyEvent &event) |
void | setOpaque (Opaque opaque) |
bool | isOpaque () const |
void | mousePressed (MouseEvent &event) |
void | mouseWheelMovedUp (MouseEvent &event) |
void | mouseWheelMovedDown (MouseEvent &event) |
void | mouseDragged (MouseEvent &event) |
void | modelUpdated (const bool completed) |
void | requestFocus () |
void | setSelectableGui (bool b) |
Public Member Functions inherited from Widget | |
Widget (const Widget2 *const widget) | |
~Widget () | |
virtual void | drawFrame (Graphics *graphics) |
virtual void | safeDrawFrame (Graphics *graphics) |
void | setFrameSize (const unsigned int frameSize) |
unsigned int | getFrameSize () const |
virtual void | logic () |
Widget * | getParent () const |
void | setWidth (const int width) |
int | getWidth () const |
void | setHeight (const int height) |
int | getHeight () const |
void | setSize (const int width, const int height) |
void | setX (const int x) |
int | getX () const |
void | setY (const int y) |
int | getY () const |
void | setPosition (const int x, const int y) |
void | setDimension (const Rect &dimension) |
const Rect & | getDimension () const |
void | setFocusable (const bool focusable) |
bool | isFocusable () const |
virtual bool | isFocused () const |
void | setEnabled (const bool enabled) |
bool | isEnabled () const |
void | setVisible (Visible visible) |
bool | isVisible () const |
void | setBaseColor (const Color &color) |
const Color & | getBaseColor () const |
void | setForegroundColor (const Color &color) |
const Color & | getForegroundColor () const |
void | setBackgroundColor (const Color &color) |
const Color & | getBackgroundColor () const |
virtual void | requestMoveToTop () |
virtual void | requestMoveToBottom () |
FocusHandler * | getFocusHandler () |
void | addActionListener (ActionListener *const actionListener) |
void | removeActionListener (ActionListener *const actionListener) |
void | addDeathListener (WidgetDeathListener *const deathListener) |
void | removeDeathListener (WidgetDeathListener *const deathListener) |
void | addMouseListener (MouseListener *const mouseListener) |
void | removeMouseListener (MouseListener *const mouseListener) |
void | addKeyListener (KeyListener *const keyListener) |
void | removeKeyListener (KeyListener *const keyListener) |
void | addFocusListener (FocusListener *const focusListener) |
void | removeFocusListener (FocusListener *const focusListener) |
void | addWidgetListener (WidgetListener *const widgetListener) |
void | removeWidgetListener (WidgetListener *const widgetListener) |
void | setActionEventId (const std::string &actionEventId) |
const std::string & | getActionEventId () const |
virtual void | getAbsolutePosition (int &x, int &y) const |
virtual void | setParent (Widget *parent) |
Font * | getFont () const |
void | setFont (Font *const font) |
virtual void | fontChanged () |
bool | isTabInEnabled () const |
void | setTabInEnabled (const bool enabled) |
bool | isTabOutEnabled () const |
void | setTabOutEnabled (const bool enabled) |
void | requestModalFocus () |
virtual void | requestModalMouseInputFocus () |
virtual void | releaseModalFocus () |
virtual void | releaseModalMouseInputFocus () |
virtual bool | isModalFocused () const |
virtual bool | isModalMouseInputFocused () const |
const std::list< MouseListener * > & | getMouseListeners () const A_CONST |
const std::list< KeyListener * > & | getKeyListeners () const A_CONST |
const std::list< FocusListener * > & | getFocusListeners () const A_CONST |
virtual FocusHandler * | getInternalFocusHandler () |
void | setInternalFocusHandler (FocusHandler *const internalFocusHandler) |
virtual void | focusNext () |
virtual void | focusPrevious () |
virtual void | showWidgetPart (Widget *const widget, const Rect &area) |
void | setId (const std::string &id) |
const std::string & | getId () const |
virtual void | showPart (const Rect &rectangle) |
bool | isAllowLogic () const |
void | setMouseConsume (const bool b) |
bool | isMouseConsume () const |
void | setRedraw (const bool b) |
virtual bool | isSelectable () const |
void | setSelectable (const bool selectable) |
void | windowResized () |
virtual void | postInit () |
Public Member Functions inherited from Widget2 | |
virtual | ~Widget2 () |
const Color & | getThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE |
const Color & | getThemeCharColor (const signed char c, bool &valid) const A_INLINE |
virtual void | setWidget2 (const Widget2 *const widget) |
void | setPalette (int palette) |
void | checkPalette () |
void | setForegroundColor2 (const Color &color) |
Widget * | getWindow () const |
virtual void | setWindow (Widget *const window) |
Public Member Functions inherited from MouseListener | |
virtual | ~MouseListener () |
virtual void | mouseEntered (MouseEvent &event) |
virtual void | mouseExited (MouseEvent &event) |
virtual void | mouseReleased (MouseEvent &event) |
virtual void | mouseClicked (MouseEvent &event) |
virtual void | mouseMoved (MouseEvent &event) |
Public Member Functions inherited from KeyListener | |
virtual | ~KeyListener () |
virtual void | keyReleased (KeyEvent &event) |
Public Member Functions inherited from TableModelListener | |
TableModelListener () | |
virtual | ~TableModelListener () |
Protected Member Functions | |
void | uninstallActionListeners () |
void | installActionListeners () |
int | getRowHeight () const |
int | getColumnWidth (const int i) const |
Protected Member Functions inherited from Widget | |
void | distributeActionEvent () |
void | distributeResizedEvent () |
void | distributeMovedEvent () |
void | distributeHiddenEvent () |
void | distributeShownEvent () |
Protected Member Functions inherited from Widget2 | |
Widget2 (const Widget2 *const widget) | |
Protected Member Functions inherited from MouseListener | |
MouseListener () | |
Protected Member Functions inherited from KeyListener | |
KeyListener () | |
Private Member Functions | |
int | getRowForY (const int y) const |
int | getColumnForX (const int x) const |
void | recomputeDimensions () |
Private Attributes | |
TableModel * | mModel |
Widget * | mTopWidget |
std::vector< GuiTableActionListener * > | mActionListeners2 |
Color | mHighlightColor |
int | mSelectedRow |
int | mSelectedColumn |
bool | mLinewiseMode |
bool | mWrappingEnabled |
Opaque | mOpaque |
bool | mSelectableGui |
Static Private Attributes | |
static float | mAlpha = 1.0 |
Friends | |
class | GuiTableActionListener |
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 49 of file guitable.h.
GuiTable::GuiTable | ( | const Widget2 *const | widget, |
TableModel *const | initial_model, | ||
const Opaque | opacity | ||
) |
Definition at line 43 of file guitable.cpp.
References Widget::addKeyListener(), Widget::addMouseListener(), LinkHighlightMode::BACKGROUND, Widget2::getThemeColor(), Widget::mAllowLogic, Widget::mBackgroundColor, Widget::setFocusable(), and setModel().
GuiTable::~GuiTable | ( | ) |
Definition at line 71 of file guitable.cpp.
References delete2, gui, mModel, Gui::removeDragged(), and uninstallActionListeners().
|
virtual |
Draws the widget. It is called by the parent widget when it is time for the widget to draw itself. The graphics object is set up so that all drawing is relative to the widget, i.e coordinate (0,0) is the top left corner of the widget. It is not possible to draw outside of a widget's dimension.
graphics | aA graphics object to draw with. |
Implements Widget.
Definition at line 227 of file guitable.cpp.
References Color::a, BLOCK_END, BLOCK_START, CAST_S32, CAST_U32, Widget::draw(), Graphics::fillRectangle(), TableModel::getColumns(), getColumnWidth(), Widget::getDimension(), TableModel::getElementAt(), Widget::getHeight(), getRowHeight(), TableModel::getRows(), Widget::getWidth(), Settings::guiAlpha, Rect::height, mAlpha, Widget::mBackgroundColor, Widget::mDimension, mHighlightColor, mLinewiseMode, mModel, mOpaque, mSelectedColumn, mSelectedRow, mTopWidget, Opaque_true, Graphics::popClipArea(), Graphics::pushClipArea(), Graphics::setColor(), Widget::setDimension(), settings, Rect::width, Rect::y, and y.
|
virtual |
Gets the area of the widget occupied by the widget's children. By default this method returns an empty rectangle as not all widgets are containers. If you want to make a container this method should return the area where the children resides. This method is used when drawing children of a widget when computing clip rectangles for the children.
An example of a widget that overloads this method is ScrollArea. A ScrollArea has a view of its contant and that view is the children area. The size of a ScrollArea's children area might vary depending on if the scroll bars of the ScrollArea is shown or not.
Reimplemented from Widget.
Definition at line 476 of file guitable.cpp.
References Rect::height, Widget::mDimension, and Rect::width.
|
private |
Definition at line 631 of file guitable.cpp.
References TableModel::getColumns(), getColumnWidth(), mModel, and x.
Referenced by getWidgetAt(), mouseDragged(), and mousePressed().
|
protected |
Definition at line 146 of file guitable.cpp.
References TableModel::getColumnWidth(), and mModel.
Referenced by draw(), getColumnForX(), recomputeDimensions(), and safeDraw().
const TableModel * GuiTable::getModel | ( | ) | const |
|
private |
Definition at line 618 of file guitable.cpp.
References getRowHeight(), TableModel::getRows(), mModel, and y.
Referenced by getWidgetAt(), mouseDragged(), and mousePressed().
|
protected |
Definition at line 141 of file guitable.cpp.
References TableModel::getRowHeight(), and mModel.
Referenced by draw(), getRowForY(), recomputeDimensions(), and safeDraw().
int GuiTable::getSelectedColumn | ( | ) | const |
Definition at line 136 of file guitable.cpp.
References mSelectedColumn.
int GuiTable::getSelectedRow | ( | ) | const |
Definition at line 131 of file guitable.cpp.
References mSelectedRow.
Referenced by Setup_Relations::action(), mouseWheelMovedDown(), and mouseWheelMovedUp().
|
virtual |
Gets a widget from a certain position in the widget. This function is used to decide which gets mouse input, thus it can be overloaded to change that behaviour.
NOTE: This always returns NULL if the widget is not a container.
x | The x coordinate of the widget to get. |
y | The y coordinate of the widget to get. |
Reimplemented from Widget.
Definition at line 595 of file guitable.cpp.
References getColumnForX(), Widget::getDimension(), TableModel::getElementAt(), getRowForY(), Widget::isFocusable(), Rect::isPointInRect(), mModel, mTopWidget, x, and y.
|
protected |
Installs all action listeners on inner widgets.
Definition at line 205 of file guitable.cpp.
References TableModel::getColumns(), TableModel::getElementAt(), Widget::getFocusHandler(), TableModel::getRows(), GuiTableActionListener, mActionListeners2, mModel, and setFocusHandler().
Referenced by modelUpdated(), and setModel().
|
inline |
Checks if the table is opaque, that is if the table area displays its background.
Definition at line 146 of file guitable.h.
References mOpaque, and Opaque_true.
|
inline |
|
virtual |
Called if a key is pressed when the widget has keyboard focus. If a key is held down the widget will generate multiple key presses.
event | Discribes the event. |
Reimplemented from KeyListener.
Definition at line 482 of file guitable.cpp.
References Widget::distributeActionEvent(), TableModel::getColumns(), TableModel::getRows(), InputAction::GUI_DOWN, InputAction::GUI_END, InputAction::GUI_HOME, InputAction::GUI_LEFT, InputAction::GUI_RIGHT, InputAction::GUI_SELECT, InputAction::GUI_UP, mModel, mSelectedColumn, mSelectedRow, setSelectedColumn(), and setSelectedRow().
|
virtual |
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.
completed | whether we are signalling the end of the update |
Implements TableModelListener.
Definition at line 581 of file guitable.cpp.
References installActionListeners(), mTopWidget, recomputeDimensions(), and uninstallActionListeners().
|
virtual |
Called when the mouse has moved and the mouse has previously been pressed on the widget.
event | Describes the event. |
Reimplemented from MouseListener.
Definition at line 568 of file guitable.cpp.
References MouseEvent::getButton(), getColumnForX(), getRowForY(), MouseEvent::getX(), MouseEvent::getY(), MouseButton::LEFT, setSelectedColumn(), setSelectedRow(), x, and y.
|
virtual |
Called when a mouse button has been pressed on the widget area.
NOTE: A mouse press is NOT equal to a mouse click. Use mouseClickMessage to check for mouse clicks.
event | Describes the event. |
Reimplemented from MouseListener.
Definition at line 526 of file guitable.cpp.
References Widget::distributeActionEvent(), MouseEvent::getButton(), getColumnForX(), getRowForY(), MouseEvent::getX(), MouseEvent::getY(), MouseButton::LEFT, mSelectableGui, mSelectedColumn, and mSelectedRow.
|
virtual |
Called when the mouse wheel has moved down on the widget area.
event | Describes the event. |
Reimplemented from MouseListener.
Definition at line 559 of file guitable.cpp.
References getSelectedRow(), Widget::isFocused(), and setSelectedRow().
|
virtual |
Called when the mouse wheel has moved up on the widget area.
event | Describes the event. |
Reimplemented from MouseListener.
Definition at line 548 of file guitable.cpp.
References getSelectedRow(), Widget::isFocused(), mWrappingEnabled, and setSelectedRow().
|
virtual |
Moves a widget in this widget to the bottom of this widget. The moved widget will be drawn below all other widgets in this widget.
widget | The widget to move to the bottom. |
Reimplemented from Widget.
Definition at line 469 of file guitable.cpp.
References Widget::moveToBottom(), and mTopWidget.
|
virtual |
Moves a widget to the top of this widget. The moved widget will be drawn above all other widgets in this widget.
widget | The widget to move to the top. |
Reimplemented from Widget.
Definition at line 463 of file guitable.cpp.
References Widget::moveToTop(), and mTopWidget.
|
private |
Definition at line 100 of file guitable.cpp.
References TableModel::getColumns(), getColumnWidth(), getRowHeight(), TableModel::getRows(), mModel, mSelectableGui, mSelectedColumn, mSelectedRow, Widget::setHeight(), and Widget::setWidth().
Referenced by modelUpdated(), and setModel().
|
virtual |
Requests focus for the widget. A widget will only recieve focus if it is focusable.
Reimplemented from Widget.
Definition at line 671 of file guitable.cpp.
References Widget::mFocusHandler, and Widget::requestFocus().
|
virtual |
Implements Widget.
Definition at line 345 of file guitable.cpp.
References Color::a, BLOCK_END, BLOCK_START, CAST_S32, CAST_U32, Graphics::fillRectangle(), TableModel::getColumns(), getColumnWidth(), Widget::getDimension(), TableModel::getElementAt(), Widget::getHeight(), getRowHeight(), TableModel::getRows(), Widget::getWidth(), Settings::guiAlpha, Rect::height, mAlpha, Widget::mBackgroundColor, Widget::mDimension, mHighlightColor, mLinewiseMode, mModel, mOpaque, mSelectedColumn, mSelectedRow, mTopWidget, Opaque_true, Graphics::popClipArea(), Graphics::pushClipArea(), Widget::safeDraw(), Graphics::setColor(), Widget::setDimension(), settings, Rect::width, Rect::y, and y.
|
virtual |
Sets the focus handler to be used.
WARNING: This function is used internally and should not be called or overloaded unless you know what you are doing.
focusHandler | The focus handler to use. |
Reimplemented from Widget.
Definition at line 649 of file guitable.cpp.
References TableModel::getColumns(), TableModel::getElementAt(), TableModel::getRows(), mModel, and Widget::setFocusHandler().
Referenced by installActionListeners().
|
inline |
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.
linewise | Whether to enable linewise selection mode |
Definition at line 112 of file guitable.h.
References mLinewiseMode.
Referenced by Setup_Relations::Setup_Relations().
void GuiTable::setModel | ( | TableModel *const | 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 85 of file guitable.cpp.
References installActionListeners(), TableModel::installListener(), mModel, recomputeDimensions(), TableModel::removeListener(), and uninstallActionListeners().
Referenced by GuiTable(), and Setup_Relations::updateAll().
|
inline |
Sets the table to be opaque, that is sets the table to display its background.
opaque | True if the table should be opaque, false otherwise. |
Definition at line 137 of file guitable.h.
References mOpaque.
Referenced by Setup_Relations::Setup_Relations().
|
inline |
Definition at line 163 of file guitable.h.
References mSelectableGui.
Referenced by Setup_Relations::Setup_Relations().
void GuiTable::setSelected | ( | const int | row, |
const int | column | ||
) |
Definition at line 125 of file guitable.cpp.
References mSelectedColumn, and mSelectedRow.
Referenced by GuiTableActionListener::action().
void GuiTable::setSelectedColumn | ( | const int | selected | ) |
Definition at line 180 of file guitable.cpp.
References TableModel::getColumns(), mModel, mSelectedColumn, and mWrappingEnabled.
Referenced by keyPressed(), and mouseDragged().
void GuiTable::setSelectedRow | ( | const int | selected | ) |
Definition at line 151 of file guitable.cpp.
References TableModel::getRows(), mModel, mSelectableGui, mSelectedRow, and mWrappingEnabled.
Referenced by keyPressed(), mouseDragged(), mouseWheelMovedDown(), and mouseWheelMovedUp().
|
inline |
|
protected |
Frees all action listeners on inner widgets.
Definition at line 199 of file guitable.cpp.
References delete_all(), and mActionListeners2.
Referenced by modelUpdated(), setModel(), and ~GuiTable().
|
friend |
Definition at line 55 of file guitable.h.
Referenced by installActionListeners().
|
private |
Vector for compactness; used as a list in practice.
Definition at line 192 of file guitable.h.
Referenced by installActionListeners(), and uninstallActionListeners().
|
staticprivate |
Definition at line 184 of file guitable.h.
Referenced by draw(), and safeDraw().
|
private |
Holds the background color of the table.
Definition at line 197 of file guitable.h.
Referenced by draw(), and safeDraw().
|
private |
Definition at line 202 of file guitable.h.
Referenced by draw(), safeDraw(), and setLinewiseSelection().
|
private |
Definition at line 186 of file guitable.h.
Referenced by draw(), getColumnForX(), getColumnWidth(), getModel(), getRowForY(), getRowHeight(), getWidgetAt(), installActionListeners(), keyPressed(), recomputeDimensions(), safeDraw(), setFocusHandler(), setModel(), setSelectedColumn(), setSelectedRow(), and ~GuiTable().
|
private |
Definition at line 204 of file guitable.h.
Referenced by draw(), isOpaque(), safeDraw(), and setOpaque().
|
private |
Definition at line 205 of file guitable.h.
Referenced by mousePressed(), recomputeDimensions(), setSelectableGui(), and setSelectedRow().
|
private |
Definition at line 200 of file guitable.h.
Referenced by draw(), getSelectedColumn(), keyPressed(), mousePressed(), recomputeDimensions(), safeDraw(), setSelected(), and setSelectedColumn().
|
private |
Definition at line 199 of file guitable.h.
Referenced by draw(), getSelectedRow(), keyPressed(), mousePressed(), recomputeDimensions(), safeDraw(), setSelected(), and setSelectedRow().
|
private |
If someone moves a fresh widget to the top, we must display it.
Definition at line 189 of file guitable.h.
Referenced by draw(), getWidgetAt(), modelUpdated(), moveToBottom(), moveToTop(), and safeDraw().
|
private |
Definition at line 203 of file guitable.h.
Referenced by isWrappingEnabled(), mouseWheelMovedUp(), setSelectedColumn(), setSelectedRow(), and setWrappingEnabled().