5#ifndef INCLUDE_FIFECHAN_WIDGETS_LISTBOX_HPP_
6#define INCLUDE_FIFECHAN_WIDGETS_LISTBOX_HPP_
10#include "fifechan/keylistener.hpp"
11#include "fifechan/listmodel.hpp"
12#include "fifechan/mouselistener.hpp"
13#include "fifechan/platform.hpp"
14#include "fifechan/widget.hpp"
33 class FIFEGUI_API ListBox :
public Widget,
public MouseListener,
public KeyListener
45 ~ListBox()
override =
default;
47 ListBox(ListBox
const &) =
delete;
48 ListBox& operator=(ListBox
const &) =
delete;
49 ListBox(ListBox&&) =
delete;
50 ListBox& operator=(ListBox&&) =
delete;
147 void logic()
override;
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
void setListModel(ListModel *listModel)
Sets the list model to use.
void setWrappingEnabled(bool wrappingEnabled)
Sets the list box to wrap or not when selecting items with a keyboard.
void adjustSize() override
Resizes the widget's size to fit the content exactly.
void resizeToContent(bool recursion) override
Resize this widget to fit its content.
int getSelected() const
Gets the selected item as an index in the list model.
void mouseWheelMovedDown(MouseEvent &mouseEvent) override
Called when the mouse wheel has moved down on the widget area.
void mouseDragged(MouseEvent &mouseEvent) override
Called when the mouse has moved and the mouse has previously been pressed on the widget.
bool isWrappingEnabled() const
Checks whether the list box wraps when selecting items with a keyboard.
void mouseWheelMovedUp(MouseEvent &mouseEvent) override
Called when the mouse wheel has moved up on the widget area.
SelectionListenerList::iterator SelectionListenerIterator
Typedef.
int mSelected
The selected item as an index in the list model.
void logic() override
Called for all widgets in the gui each time Gui::logic is called.
void addSelectionListener(SelectionListener *selectionListener)
Adds a selection listener to the list box.
void adjustSizeImpl()
Concrete implementation of adjustSize.
void removeSelectionListener(SelectionListener *selectionListener)
Removes a selection listener from the list box.
bool mWrappingEnabled
True if wrapping is enabled, false otherwise.
void mousePressed(MouseEvent &mouseEvent) override
Called when a mouse button has been pressed on the widget area.
void keyPressed(KeyEvent &keyEvent) override
Called if a key is pressed when the widget has keyboard focus.
ListModel * mListModel
The list model to use.
ListModel * getListModel() const
Gets the list model used.
void draw(Graphics *graphics) override
Draws the widget.
SelectionListenerList mSelectionListeners
The selection listeners of the list box.
void distributeValueChangedEvent()
Distributes a value changed event to all selection listeners of the list box.
void setSelected(int selected)
Sets the selected item.
std::list< SelectionListener * > SelectionListenerList
Typdef.
virtual unsigned int getRowHeight() const
Gets the height of a row.
Interface for a data model representing a list (used by ListBox/DropDown).
Represents a mouse event.
Interface for listening to selection change events.