5#ifndef INCLUDE_FIFECHAN_WIDGETS_DROPDOWN_HPP_
6#define INCLUDE_FIFECHAN_WIDGETS_DROPDOWN_HPP_
11#include "fifechan/actionlistener.hpp"
12#include "fifechan/focushandler.hpp"
13#include "fifechan/focuslistener.hpp"
14#include "fifechan/keylistener.hpp"
15#include "fifechan/mouselistener.hpp"
16#include "fifechan/platform.hpp"
17#include "fifechan/selectionlistener.hpp"
18#include "fifechan/widget.hpp"
46 public ActionListener,
50 public SelectionListener,
Represents an action trigger (e.g., button click).
void draw(Graphics *graphics) override
Draws the widget.
void resizeToContent(bool recursion) override
Resize this widget to fit its content.
virtual void death(Event const &event)
DeathListener callback invoked when a observed widget is destroyed.
void setFont(Font *font) override
Set the font used to render items in the dropdown.
void action(ActionEvent const &actionEvent) override
Called when an action is received from a widget.
DropDown(ListModel *listModel=nullptr, ScrollArea *scrollArea=nullptr, ListBox *listBox=nullptr)
Constructor.
bool mInternalListBox
True if an internal list box is used, false if a list box has been passed to the drop down which the ...
bool mIsDragged
True if the drop down is dragged.
bool mInternalScrollArea
True if an internal scroll area is used, false if a scroll area has been passed to the drop down whic...
void focusLost(Event const &event) override
Called when a widget loses focus.
void adjustSize() override
Resizes the widget's size to fit the content exactly.
ScrollArea * mScrollArea
The scroll area used.
virtual void dropDown()
Sets the drop down to be dropped down.
void mouseWheelMovedDown(MouseEvent &mouseEvent) override
Called when the mouse wheel has moved down on the widget area.
std::unique_ptr< ScrollArea > mOwnedScrollArea
Owned internal scroll area when not supplied externally.
void mouseDragged(MouseEvent &mouseEvent) override
Called when the mouse has moved and the mouse has previously been pressed on the widget.
Rectangle getChildrenArea() override
Gets the area of the widget occupied by the widget's children.
void valueChanged(SelectionEvent const &event) override
Called when the value of a selection has been changed in a Widget.
void removeSelectionListener(SelectionListener *selectionListener)
Removes a selection listener from the drop down.
virtual void drawButton(Graphics *graphics)
Draws the button of the drop down.
SelectionListenerList mSelectionListeners
The selection listener's of the drop down.
int getSelected() const
Gets the selected item as an index in the list model.
ListBox * mListBox
The list box used.
void setListModel(ListModel *listModel)
Sets the list model to use when displaying the list.
void keyPressed(KeyEvent &keyEvent) override
Called if a key is pressed when the widget has keyboard focus.
void mouseReleased(MouseEvent &mouseEvent) override
Called when a mouse button has been released on the widget area.
void setForegroundColor(Color const &color) override
Set the foreground/text color used in the dropdown.
void adjustHeight()
Adjusts the height of the drop down to fit the height of the drop down's parent's height.
void setBackgroundColor(Color const &color) override
Set the explicit background color for the dropdown.
bool mDroppedDown
True if the drop down is dropped down, false otherwise.
bool mPushed
True if the drop down has been pushed with the mouse, false otherwise.
std::list< SelectionListener * > SelectionListenerList
Typedef.
void setSelected(int selected)
Sets the selected item.
void setBaseColor(Color const &color) override
Set the base color used for the dropdown background/controls.
virtual void foldUp()
Sets the drop down to be folded up.
void setSelectionColor(Color const &color) override
Set the color used for the selected item highlight.
void addSelectionListener(SelectionListener *selectionListener)
Adds a selection listener to the drop down.
void distributeValueChangedEvent()
Distributes a value changed event to all selection listeners of the drop down.
ListModel * getListModel() const
Gets the list model used.
std::unique_ptr< ListBox > mOwnedListBox
Owned internal list box when not supplied externally.
FocusHandler mInternalFocusHandler
The internal focus handler used to keep track of focus for the internal list box.
void mousePressed(MouseEvent &mouseEvent) override
Called when a mouse button has been pressed on the widget area.
SelectionListenerList::iterator SelectionListenerIterator
Typedef.
int mFoldedUpHeight
Holds what the height is if the drop down is folded up.
void mouseWheelMovedUp(MouseEvent &mouseEvent) override
Called when the mouse wheel has moved up on the widget area.
Base class for all GUI event objects.
Manages focus navigation and assignment among widgets within a Gui instance.
Abstract interface for font rendering.
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
A scrollable list box allowing item selection.
Interface for a data model representing a list (used by ListBox/DropDown).
Represents a mouse event.
Represents a rectangular area (X, Y, Width, Height).
Represents a change in selection state (e.g., list item selected).