ManaPlus
|
#include <listbox.h>
Public Member Functions | |
ListBox (const Widget2 *const widget, ListModel *const listModel, const std::string &skin) | |
~ListBox () | |
void | postInit () |
void | draw (Graphics *const graphics) |
void | safeDraw (Graphics *const graphics) |
void | updateAlpha () |
void | keyPressed (KeyEvent &event) |
void | mouseWheelMovedUp (MouseEvent &event) |
void | mouseWheelMovedDown (MouseEvent &event) |
void | mousePressed (MouseEvent &event) |
void | mouseReleased (MouseEvent &event) |
void | mouseReleased1 (const MouseEvent &event) |
void | mouseDragged (MouseEvent &event) |
void | refocus () |
void | setDistributeMousePressed (const bool b) |
virtual void | adjustSize () |
void | logic () |
virtual int | getSelectionByMouse (const int y) const |
void | setCenter (const bool b) |
int | getPressedIndex () const |
virtual unsigned int | getRowHeight () const |
void | setRowHeight (unsigned int n) |
int | getSelected () const |
void | setSelected (const int selected) |
void | setListModel (ListModel *listModel) |
ListModel * | getListModel () const |
bool | isWrappingEnabled () const |
void | setWrappingEnabled (const bool wrappingEnabled) |
void | addSelectionListener (SelectionListener *const selectionListener) |
void | removeSelectionListener (SelectionListener *const selectionListener) |
void | distributeValueChangedEvent () |
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 |
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 | requestFocus () |
virtual void | requestMoveToTop () |
virtual void | requestMoveToBottom () |
virtual void | setFocusHandler (FocusHandler *const focusHandler) |
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 |
virtual Widget * | getWidgetAt (int x, int y) |
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 Rect | getChildrenArea () |
virtual FocusHandler * | getInternalFocusHandler () |
void | setInternalFocusHandler (FocusHandler *const internalFocusHandler) |
virtual void | moveToTop (Widget *widget) |
virtual void | moveToBottom (Widget *widget) |
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 () |
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 | mouseClicked (MouseEvent &event) |
virtual void | mouseMoved (MouseEvent &event) |
Public Member Functions inherited from KeyListener | |
virtual | ~KeyListener () |
virtual void | keyReleased (KeyEvent &event) |
Protected Types | |
typedef std::list< SelectionListener * > | SelectionListenerList |
typedef SelectionListenerList::iterator | SelectionListenerIterator |
Protected Types inherited from Widget | |
typedef std::list< MouseListener * > | MouseListenerList |
typedef MouseListenerList::iterator | MouseListenerIterator |
typedef std::list< KeyListener * > | KeyListenerList |
typedef KeyListenerList::iterator | KeyListenerIterator |
typedef std::list< ActionListener * > | ActionListenerList |
typedef ActionListenerList::iterator | ActionListenerIterator |
typedef std::list< WidgetDeathListener * > | WidgetDeathListenerList |
typedef WidgetDeathListenerList::iterator | WidgetDeathListenerIterator |
typedef std::list< FocusListener * > | FocusListenerList |
typedef FocusListenerList::iterator | FocusListenerIterator |
typedef std::list< WidgetListener * > | WidgetListenerList |
typedef WidgetListenerList::iterator | WidgetListenerIterator |
Static Protected Attributes | |
static float | mAlpha = 1.0 |
Static Protected Attributes inherited from Widget | |
static Font * | mGlobalFont = 0 |
Additional Inherited Members | |
Static Public Member Functions inherited from Widget | |
static void | setGlobalFont (Font *const font) |
static Font * | getGloablFont () |
static void | cleanGlobalFont () |
static bool | widgetExists (const Widget *const widget) |
static void | distributeWindowResizeEvent () |
static Widget * | callPostInit (Widget *const widget) |
Data Fields inherited from Widget | |
Visible | mVisible |
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 () | |
A list box, meant to be used inside a scroll area. Same as the Guichan list box except this one doesn't have a background, instead completely relying on the scroll area. It also adds selection listener functionality.
|
protected |
|
protected |
ListBox::ListBox | ( | const Widget2 *const | widget, |
ListModel *const | listModel, | ||
const std::string & | skin | ||
) |
Constructor.
Definition at line 89 of file listbox.cpp.
References Widget::addKeyListener(), Widget::addMouseListener(), CAST_U32, Widget::getFont(), Font::getHeight(), Skin::getOption(), Skin::getPadding(), Widget2::getThemeColor(), Theme::getThemePath(), Theme::load(), Widget::mForegroundColor, Widget2::mForegroundColor2, mItemPadding, mPadding, mRowHeight, mSkin, Widget::setFocusable(), Widget::setWidth(), and theme.
ListBox::~ListBox | ( | ) |
Definition at line 145 of file listbox.cpp.
References gui, mSkin, Gui::removeDragged(), theme, and Theme::unload().
void ListBox::addSelectionListener | ( | SelectionListener *const | selectionListener | ) |
Adds a selection listener to the list box. When the selection changes an event will be sent to all selection listeners of the list box.
If you delete your selection listener, be sure to also remove it using removeSelectionListener().
selectionListener | The selection listener to add. |
Definition at line 435 of file listbox.cpp.
References mSelectionListeners.
Referenced by BuyDialog::init(), SellDialog::postInit(), TextSelectDialog::postInit(), ServerDialog::ServerDialog(), Setup_Colors::Setup_Colors(), and ShopWindow::ShopWindow().
|
virtual |
Reimplemented in ShopListBox, ExtendedListBox, and ColorPage.
Definition at line 374 of file listbox.cpp.
References BLOCK_END, BLOCK_START, CAST_S32, ListModel::getNumberOfElements(), getRowHeight(), mListModel, mPadding, and Widget::setHeight().
Referenced by ExtendedListBox::adjustSize(), PopupList::adjustSize(), logic(), postInit(), and setListModel().
void ListBox::distributeValueChangedEvent | ( | ) |
Distributes a value changed event to all selection listeners of the list box.
Definition at line 446 of file listbox.cpp.
References FOR_EACH, and mSelectionListeners.
Referenced by setSelected().
|
virtual |
Draws the list box.
Implements Widget.
Reimplemented in SkillListBox, ShopListBox, and ServersListBox.
Definition at line 163 of file listbox.cpp.
References Color::a, BLOCK_END, BLOCK_START, CAST_S32, CAST_U32, Font::drawString(), Graphics::fillRectangle(), ListModel::getElementAt(), Widget::getFont(), ListModel::getNumberOfElements(), getRowHeight(), Font::getWidth(), mAlpha, mCenterText, Widget::mDimension, Widget::mForegroundColor, Widget2::mForegroundColor2, mForegroundSelectedColor, mForegroundSelectedColor2, mHighlightColor, mItemPadding, mListModel, mPadding, mSelected, Graphics::setColor(), updateAlpha(), Rect::width, and y.
Referenced by safeDraw().
|
inline |
Gets the list model used.
Definition at line 194 of file listbox.h.
References mListModel.
Referenced by keyPressed().
|
inline |
|
inlinevirtual |
Reimplemented in SkillListBox, and ServersListBox.
Definition at line 156 of file listbox.h.
References mRowHeight.
Referenced by ColorPage::adjustSize(), adjustSize(), ColorPage::ColorPage(), ColorPage::draw(), draw(), getSelectionByMouse(), mouseDragged(), NpcSellDialog::sellOneItem(), and setSelected().
|
inline |
Gets the selected item as an index in the list model.
Definition at line 168 of file listbox.h.
References mSelected.
Referenced by SellDialog::action(), Setup_Input::action(), Setup_Video::action(), BuyDialog::action(), MailWindow::action(), NpcDialog::action(), QuestsWindow::action(), ServerDialog::action(), ShopWindow::action(), TextSelectDialog::action(), WorldSelectDialog::action(), ServerDialog::connectToSelectedServer(), PopupList::getSelected(), EmoteWindow::getSelectedColor(), EmoteWindow::getSelectedFont(), SkillListBox::getSelectedInfo(), EmoteWindow::getSelectedTextIndex(), ServerDialog::keyPressed(), ServerDialog::loadServers(), AvatarListBox::mousePressed(), NpcDialog::move(), BuyingStoreSellDialog::sellAction(), EggSelectionDialog::sellAction(), InsertCardDialog::sellAction(), NpcSellDialog::sellAction(), ShopSellDialog::sellAction(), NpcSellDialog::sellManyItems(), NpcSellDialog::sellOneItem(), SellDialog::updateButtonsAndLabels(), BuyDialog::updateButtonsAndLabels(), ShopWindow::updateButtonsAndLabels(), TextSelectDialog::updateButtonsAndLabels(), Setup_Colors::updateGradType(), Setup_Colors::valueChanged(), ServerDialog::valueChanged(), MailWindow::viewNext(), and MailWindow::viewPrev().
|
virtual |
Reimplemented in ExtendedListBox.
Definition at line 392 of file listbox.cpp.
References CAST_S32, getRowHeight(), mPadding, and y.
Referenced by ExtendedListBox::getSelectionByMouse(), mouseDragged(), mousePressed(), PopupList::mousePressed(), mouseReleased(), PopupList::mouseReleased(), ShopListBox::mouseReleased(), and mouseReleased1().
|
inline |
Checks whether the list box wraps when selecting items with a keyboard.
Wrapping means that the selection of items will be wrapped. That is, if the first item is selected and up is pressed, the last item will get selected. If the last item is selected and down is pressed, the first item will get selected.
Definition at line 209 of file listbox.h.
References mWrappingEnabled.
|
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 246 of file listbox.cpp.
References Widget::distributeActionEvent(), getListModel(), ListModel::getNumberOfElements(), InputAction::GUI_DOWN, InputAction::GUI_END, InputAction::GUI_HOME, InputAction::GUI_SELECT, InputAction::GUI_UP, mSelected, mWrappingEnabled, and setSelected().
Referenced by ServerDialog::keyPressed().
|
virtual |
Called for all widgets in the gui each time Gui::logic is called. You can do logic stuff here like playing an animation.
Reimplemented from Widget.
Definition at line 385 of file listbox.cpp.
References adjustSize(), BLOCK_END, and BLOCK_START.
|
virtual |
Called when the mouse has moved and the mouse has previously been pressed on the widget.
event | Describes the event. |
Reimplemented from MouseListener.
Reimplemented in SkillListBox.
Definition at line 355 of file listbox.cpp.
References MouseEvent::getButton(), getRowHeight(), getSelectionByMouse(), MouseEvent::getY(), MouseButton::LEFT, and setSelected().
Referenced by SkillListBox::mouseDragged(), and mouseReleased().
|
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.
Reimplemented in SkillListBox.
Definition at line 304 of file listbox.cpp.
References getSelectionByMouse(), MouseEvent::getY(), Widget::mMouseConsume, and mPressedIndex.
Referenced by SkillListBox::mousePressed().
|
virtual |
Called when a mouse button has been released on the widget area.
event | Describes the event. |
Reimplemented from MouseListener.
Reimplemented in SkillListBox, and ShopListBox.
Definition at line 311 of file listbox.cpp.
References MouseEvent::getClickCount(), getSelectionByMouse(), MouseEvent::getY(), gui, mDistributeMousePressed, mOldSelected, mouseDragged(), mouseReleased1(), mPressedIndex, mSelected, and Gui::resetClickCount().
Referenced by ShopListBox::mouseReleased(), and SkillListBox::mouseReleased().
void ListBox::mouseReleased1 | ( | const MouseEvent & | event | ) |
Definition at line 346 of file listbox.cpp.
References Widget::distributeActionEvent(), MouseEvent::getButton(), getSelectionByMouse(), MouseEvent::getY(), MouseButton::LEFT, and setSelected().
Referenced by mouseReleased().
|
virtual |
Called when the mouse wheel has moved down on the widget area.
event | Describes the event. |
Reimplemented from MouseListener.
Definition at line 300 of file listbox.cpp.
|
virtual |
Called when the mouse wheel has moved up on the widget area.
event | Describes the event. |
Reimplemented from MouseListener.
Definition at line 296 of file listbox.cpp.
|
virtual |
void ListBox::refocus | ( | ) |
Definition at line 365 of file listbox.cpp.
References Widget::isFocusable(), Widget::mFocusHandler, and FocusHandler::requestFocus().
Referenced by NpcDialog::refocus().
void ListBox::removeSelectionListener | ( | SelectionListener *const | selectionListener | ) |
Removes a selection listener from the list box.
selectionListener | The selection listener to remove. |
Definition at line 440 of file listbox.cpp.
References mSelectionListeners.
|
virtual |
Implements Widget.
Reimplemented in SkillListBox, ShopListBox, and ServersListBox.
Definition at line 289 of file listbox.cpp.
References draw().
|
inline |
Definition at line 150 of file listbox.h.
References mCenterText.
Referenced by EmoteWindow::postInit().
|
inline |
Definition at line 141 of file listbox.h.
References mDistributeMousePressed.
Referenced by BuyDialog::init(), NpcDialog::NpcDialog(), PopupList::PopupList(), SellDialog::postInit(), and TextSelectDialog::postInit().
void ListBox::setListModel | ( | ListModel * | listModel | ) |
Sets the list model to use.
listModel | the list model to use. |
Definition at line 428 of file listbox.cpp.
References adjustSize(), mListModel, and mSelected.
Referenced by PopupList::setListModel().
|
inline |
Definition at line 159 of file listbox.h.
References mRowHeight.
Referenced by NpcDialog::NpcDialog(), and QuestsWindow::QuestsWindow().
void ListBox::setSelected | ( | const int | selected | ) |
Sets the selected item. The selected item is represented by an index from the list model.
selected | the selected item as an index from the list model. |
Definition at line 399 of file listbox.cpp.
References CAST_S32, distributeValueChangedEvent(), ListModel::getNumberOfElements(), getRowHeight(), Rect::height, mListModel, mSelected, Widget::showPart(), and Rect::y.
Referenced by Setup_Input::action(), ServerDialog::action(), NpcDialog::buildLayout(), Setup_Video::cancel(), MailWindow::clear(), EmoteWindow::clearFont(), EmoteWindow::clearText(), keyPressed(), ServerDialog::keyPressed(), ServerDialog::loadServers(), mouseDragged(), AvatarListBox::mousePressed(), ShopListBox::mouseReleased(), mouseReleased1(), NpcDialog::move(), NpcDialog::parseListItems(), ServerDialog::postInit(), QuestsWindow::rebuild(), SellDialog::reset(), BuyDialog::reset(), ColorPage::resetAction(), QuestsWindow::selectQuest(), NpcSellDialog::sellOneItem(), PopupList::setSelected(), Setup_Video::Setup_Video(), MailWindow::viewNext(), MailWindow::viewPrev(), and WorldSelectDialog::WorldSelectDialog().
|
inline |
Sets the list box to wrap or not when selecting items with a keyboard.
Wrapping means that the selection of items will be wrapped. That is, if the first item is selected and up is pressed, the last item will get selected. If the last item is selected and down is pressed, the first item will get selected.
Definition at line 223 of file listbox.h.
References mWrappingEnabled.
Referenced by NpcDialog::NpcDialog().
void ListBox::updateAlpha | ( | ) |
Update the alpha value to the graphic components.
Definition at line 154 of file listbox.cpp.
References Theme::getMinimumOpacity(), Settings::guiAlpha, mAlpha, settings, and theme.
Referenced by ColorPage::draw(), ExtendedListBox::draw(), draw(), ServersListBox::draw(), SkillListBox::draw(), AvatarListBox::draw(), and AvatarListBox::safeDraw().
|
staticprotected |
Definition at line 292 of file listbox.h.
Referenced by ColorPage::draw(), ExtendedListBox::draw(), draw(), ServersListBox::draw(), ShopListBox::draw(), SkillListBox::draw(), and updateAlpha().
|
protected |
Definition at line 294 of file listbox.h.
Referenced by draw(), and setCenter().
|
protected |
Definition at line 293 of file listbox.h.
Referenced by mouseReleased(), and setDistributeMousePressed().
|
protected |
Definition at line 284 of file listbox.h.
Referenced by ExtendedListBox::draw(), draw(), ServersListBox::draw(), and ShopListBox::draw().
|
protected |
Definition at line 285 of file listbox.h.
Referenced by ExtendedListBox::draw(), draw(), ServersListBox::draw(), and ShopListBox::draw().
|
protected |
Definition at line 283 of file listbox.h.
Referenced by ColorPage::draw(), ExtendedListBox::draw(), draw(), ServersListBox::draw(), ShopListBox::draw(), SkillListBox::draw(), ServersListBox::ServersListBox(), ShopListBox::ShopListBox(), and SkillListBox::SkillListBox().
|
protected |
Definition at line 290 of file listbox.h.
Referenced by ColorPage::ColorPage(), draw(), and ListBox().
|
protected |
The list model to use.
Definition at line 261 of file listbox.h.
Referenced by ColorPage::adjustSize(), adjustSize(), ShopListBox::adjustSize(), ColorPage::ColorPage(), ColorPage::draw(), ExtendedListBox::draw(), draw(), ServersListBox::draw(), ShopListBox::draw(), SkillListBox::draw(), AvatarListBox::draw(), getListModel(), SkillListBox::getSelectedInfo(), AvatarListBox::mousePressed(), SkillListBox::mousePressed(), AvatarListBox::safeDraw(), setListModel(), and setSelected().
|
protected |
Definition at line 286 of file listbox.h.
Referenced by mouseReleased().
|
protected |
Definition at line 287 of file listbox.h.
Referenced by ColorPage::adjustSize(), ExtendedListBox::adjustSize(), adjustSize(), ShopListBox::adjustSize(), ColorPage::ColorPage(), ColorPage::draw(), ExtendedListBox::draw(), draw(), ServersListBox::draw(), ShopListBox::draw(), SkillListBox::draw(), AvatarListBox::draw(), ExtendedListBox::getSelectionByMouse(), getSelectionByMouse(), SkillListBox::getSkillByEvent(), ListBox(), ShopListBox::mouseMoved(), AvatarListBox::mousePressed(), SkillListBox::mousePressed(), AvatarListBox::safeDraw(), and SkillListBox::SkillListBox().
|
protected |
Definition at line 288 of file listbox.h.
Referenced by getPressedIndex(), mousePressed(), and mouseReleased().
|
protected |
Definition at line 289 of file listbox.h.
Referenced by ShopListBox::adjustSize(), ColorPage::ColorPage(), ExtendedListBox::draw(), ShopListBox::draw(), ExtendedListBox::ExtendedListBox(), getRowHeight(), SkillListBox::getRowHeight(), ExtendedListBox::getSelectionByMouse(), ListBox(), ShopListBox::mouseMoved(), setRowHeight(), ShopListBox::ShopListBox(), and SkillListBox::SkillListBox().
|
protected |
The selected item as an index in the list model.
Definition at line 256 of file listbox.h.
Referenced by ColorPage::draw(), ExtendedListBox::draw(), draw(), ServersListBox::draw(), ShopListBox::draw(), SkillListBox::draw(), getSelected(), keyPressed(), SkillListBox::mousePressed(), mouseReleased(), ShopListBox::mouseReleased(), setListModel(), and setSelected().
|
protected |
The selection listeners of the list box.
Definition at line 276 of file listbox.h.
Referenced by addSelectionListener(), distributeValueChangedEvent(), and removeSelectionListener().
|
protected |
Definition at line 291 of file listbox.h.
Referenced by ColorPage::ColorPage(), ListBox(), and ~ListBox().
|
protected |
True if wrapping is enabled, false otherwise.
Definition at line 266 of file listbox.h.
Referenced by isWrappingEnabled(), keyPressed(), and setWrappingEnabled().