FifeGUI 0.3.0
A C++ GUI library designed for games.
fcn::DropDown Class Reference

#include <dropdown.hpp>

Inheritance diagram for fcn::DropDown:
fcn::ActionListener fcn::KeyListener fcn::MouseListener fcn::FocusListener fcn::SelectionListener fcn::Widget

Public Member Functions

void action (ActionEvent const &actionEvent) override
void addSelectionListener (SelectionListener *selectionListener)
void adjustHeight ()
void adjustSize () override
virtual void death (Event const &event)
void draw (Graphics *graphics) override
 DropDown (DropDown &&)=delete
 DropDown (DropDown const &)=delete
 DropDown (ListModel *listModel=nullptr, ScrollArea *scrollArea=nullptr, ListBox *listBox=nullptr)
void focusLost (Event const &event) override
Rectangle getChildrenArea () override
ListModelgetListModel () const
int getSelected () const
void keyPressed (KeyEvent &keyEvent) override
void mouseDragged (MouseEvent &mouseEvent) override
void mousePressed (MouseEvent &mouseEvent) override
void mouseReleased (MouseEvent &mouseEvent) override
void mouseWheelMovedDown (MouseEvent &mouseEvent) override
void mouseWheelMovedUp (MouseEvent &mouseEvent) override
DropDownoperator= (DropDown &&)=delete
DropDownoperator= (DropDown const &)=delete
void removeSelectionListener (SelectionListener *selectionListener)
void resizeToContent (bool recursion=true) override
void setBackgroundColor (Color const &color) override
void setBaseColor (Color const &color) override
void setFont (Font *font) override
void setForegroundColor (Color const &color) override
void setListModel (ListModel *listModel)
void setSelected (int selected)
void setSelectionColor (Color const &color) override
void valueChanged (SelectionEvent const &event) override
Public Member Functions inherited from fcn::ActionListener
 ActionListener (ActionListener &&)=delete
 ActionListener (ActionListener const &)=delete
ActionListener & operator= (ActionListener &&)=delete
ActionListener & operator= (ActionListener const &)=delete
Public Member Functions inherited from fcn::KeyListener
 KeyListener (KeyListener &&)=default
 KeyListener (KeyListener const &)=default
virtual void keyReleased (KeyEvent &keyEvent)
KeyListeneroperator= (KeyListener &&)=default
KeyListeneroperator= (KeyListener const &)=default
Public Member Functions inherited from fcn::MouseListener
virtual void mouseClicked (MouseEvent &mouseEvent)
virtual void mouseEntered (MouseEvent &mouseEvent)
virtual void mouseExited (MouseEvent &mouseEvent)
 MouseListener (MouseListener &&)=default
 MouseListener (MouseListener const &)=default
virtual void mouseMoved (MouseEvent &mouseEvent)
virtual void mouseWheelMovedLeft (MouseEvent &mouseEvent)
virtual void mouseWheelMovedRight (MouseEvent &mouseEvent)
MouseListeneroperator= (MouseListener &&)=default
MouseListeneroperator= (MouseListener const &)=default
Public Member Functions inherited from fcn::FocusListener
virtual void focusGained (Event const &event)
 FocusListener (FocusListener &&)=delete
 FocusListener (FocusListener const &)=delete
FocusListener & operator= (FocusListener &&)=delete
FocusListener & operator= (FocusListener const &)=delete
Public Member Functions inherited from fcn::SelectionListener
SelectionListeneroperator= (SelectionListener &&)=default
SelectionListeneroperator= (SelectionListener const &)=default
 SelectionListener (SelectionListener &&)=default
 SelectionListener (SelectionListener const &)=default
Public Member Functions inherited from fcn::Widget
virtual void _draw (Graphics *graphics)
virtual FocusHandler_getFocusHandler ()
virtual std::list< FocusListener * > const & _getFocusListeners ()
virtual FocusHandler_getInternalFocusHandler ()
virtual std::list< KeyListener * > const & _getKeyListeners ()
virtual std::list< MouseListener * > const & _getMouseListeners ()
virtual void _logic ()
virtual void _setFocusHandler (FocusHandler *focusHandler)
virtual void _setParent (Widget *parent)
void adaptLayout ()
virtual void adaptLayout (bool top)
void addActionListener (ActionListener *actionListener)
void addDeathListener (DeathListener *deathListener)
void addDropTargetListener (DropTargetListener *listener)
void addFocusListener (FocusListener *focusListener)
void addKeyListener (KeyListener *keyListener)
void addMouseListener (MouseListener *mouseListener)
void addWidgetListener (WidgetListener *widgetListener)
bool captureMouse ()
bool contains (int x, int y) const
virtual void drawBorder (Graphics *graphics)
void drawBorder (Graphics *graphics, unsigned int sides) const
virtual void drawOutline (Graphics *graphics)
virtual void drawSelectionFrame (Graphics *graphics)
void expandContent ()
virtual void expandContent (bool recursion)
virtual void focusNext ()
virtual void focusPrevious ()
virtual void fontChanged ()
virtual void getAbsolutePosition (int &x, int &y) const
std::string const & getActionEventId () const
Color const & getBackgroundColor () const
Color const & getBaseColor () const
Color const & getBorderColor () const
unsigned int getBorderSides () const
unsigned int getBorderSize () const
unsigned int getBorderStyle () const
unsigned int getChildrenCount () const
Rectangle const & getDimension () const
Size const & getFixedSize () const
FontgetFont () const
Color const & getForegroundColor () const
int getHeight () const
std::string const & getId () const
void getLastPosition (int &x, int &y) const
int getMarginBottom () const
int getMarginLeft () const
int getMarginRight () const
int getMarginTop () const
Size const & getMaxSize () const
Size const & getMinSize () const
Color const & getOutlineColor () const
unsigned int getOutlineSize () const
unsigned int getPaddingBottom () const
unsigned int getPaddingLeft () const
unsigned int getPaddingRight () const
unsigned int getPaddingTop () const
virtual WidgetgetParent () const
Color const & getSelectionColor () const
SelectionMode getSelectionMode () const
virtual WidgetgetTop () const
unsigned int getVisibleChildrenCount () const
WidgetgetWidgetAt (int x, int y)
virtual WidgetgetWidgetAt (int x, int y, Widget *exclude)
std::list< Widget * > getWidgetsIn (Rectangle const &area)
virtual std::list< Widget * > getWidgetsIn (Rectangle const &area, Widget *ignore)
int getWidth () const
int getX () const
int getY () const
bool hasMouseCapture () const
bool isDescendantOf (Widget const *ancestor) const noexcept
bool isEnabled () const
bool isFixedSize () const
bool isFocusable () const
virtual bool isFocused () const
bool isHorizontalExpand () const
bool isInsideActiveMouseModal () const noexcept
bool isLastPositionSet () const
virtual bool isLayouted ()
virtual bool isModalFocusable () const
virtual bool isModalFocused () const
virtual bool isModalMouseInputFocusable () const
bool isMouseInside (MouseEvent const &mouseEvent) const
bool isSetVisible () const
bool isTabInEnabled () const
bool isTabOutEnabled () const
virtual bool isUnderMouseModal () const
bool isVerticalExpand () const
bool isVisible () const
virtual void logic ()
virtual void moveToBottom (Widget *widget)
virtual void moveToTop (Widget *widget)
virtual void onFocusChanged ()
virtual void onFocusGained ()
virtual void onFocusLost ()
Widgetoperator= (Widget &&)=delete
Widgetoperator= (Widget const &)=delete
void releaseMouse ()
void removeActionListener (ActionListener *actionListener)
void removeDeathListener (DeathListener *deathListener)
void removeDropTargetListener (DropTargetListener *listener)
void removeFocusListener (FocusListener *focusListener)
void removeKeyListener (KeyListener *keyListener)
void removeMouseListener (MouseListener *mouseListener)
void removeWidgetListener (WidgetListener *widgetListener)
virtual void requestFocus ()
virtual void requestMoveToBottom ()
virtual void requestMoveToTop ()
void setActionEventId (std::string const &actionEventId)
void setBorderBottom (unsigned int size, unsigned int style)
virtual void setBorderColor (Color const &color)
void setBorderSides (unsigned int sides)
void setBorderSize (unsigned int size)
void setBorderStyle (unsigned int style)
void setBorderTop (unsigned int size, unsigned int style)
virtual void setDimension (Rectangle const &dimension)
void setEnabled (bool enabled)
void setFixedSize (Size const &size)
void setFocusable (bool focusable)
virtual void setFocused (bool focused)
virtual void setHeight (int height)
void setHorizontalExpand (bool expand)
void setId (std::string const &id)
void setInternalFocusHandler (FocusHandler *internalFocusHandler)
void setLastPosition (int x, int y)
void setMargin (int margin)
void setMarginBottom (int margin)
void setMarginLeft (int margin)
void setMarginRight (int margin)
void setMarginTop (int margin)
void setMaxSize (Size const &size)
void setMinSize (Size const &size)
virtual void setOutlineColor (Color const &color)
void setOutlineSize (unsigned int size)
void setPadding (unsigned int padding)
void setPaddingBottom (unsigned int padding)
void setPaddingLeft (unsigned int padding)
void setPaddingRight (unsigned int padding)
void setPaddingTop (unsigned int padding)
void setPosition (int x, int y)
virtual void setSelectionMode (SelectionMode mode)
virtual void setSize (int width, int height)
void setTabInEnabled (bool enabled)
void setTabOutEnabled (bool enabled)
void setVerticalExpand (bool expand)
void setVisible (bool visible)
virtual void setWidth (int width)
void setX (int x)
void setY (int y)
virtual void showPart (Rectangle rectangle)
virtual void showWidgetPart (Widget *widget, Rectangle area)
virtual void textInput (TextInputEvent &event)
 Widget ()
 Widget (Widget &&)=delete
 Widget (Widget const &)=delete

Protected Types

using SelectionListenerIterator = SelectionListenerList::iterator
using SelectionListenerList = std::list<SelectionListener*>

Protected Member Functions

void distributeValueChangedEvent ()
virtual void drawButton (Graphics *graphics)
virtual void dropDown ()
virtual void foldUp ()
Protected Member Functions inherited from fcn::ActionListener
 ActionListener ()=default
Protected Member Functions inherited from fcn::KeyListener
 KeyListener ()=default
Protected Member Functions inherited from fcn::MouseListener
 MouseListener ()=default
Protected Member Functions inherited from fcn::FocusListener
 FocusListener ()=default
Protected Member Functions inherited from fcn::SelectionListener
 SelectionListener ()=default
Protected Member Functions inherited from fcn::Widget
void add (Widget *widget)
void calculateSize ()
void distributeActionEvent ()
void distributeAncestorHiddenEvent (Widget *ancestor)
void distributeAncestorMovedEvent (Widget *ancestor)
void distributeAncestorShownEvent (Widget *ancestor)
void distributeDragDrop (DragEvent &event)
bool distributeDragEnter (DragEvent &event)
void distributeDragHover (DragEvent &event)
void distributeDragLeave (DragEvent &event)
void distributeHiddenEvent ()
void distributeMovedEvent ()
void distributeResizedEvent ()
void distributeShownEvent ()
virtual WidgetfindWidgetById (std::string const &id)
std::list< Widget * > const & getChildren () const
virtual void remove (Widget *widget)
virtual void removeAllChildren ()
void resizeToChildren ()

Protected Attributes

bool mDroppedDown {false}
int mFoldedUpHeight {0}
bool mInternalListBox {false}
bool mInternalScrollArea {false}
bool mIsDragged {false}
ListBoxmListBox
std::unique_ptr< ListBoxmOwnedListBox
std::unique_ptr< ScrollAreamOwnedScrollArea
bool mPushed {false}
ScrollAreamScrollArea
SelectionListenerList mSelectionListeners
Protected Attributes inherited from fcn::Widget
std::string mActionEventId
std::list< ActionListener * > mActionListeners
Color mBackgroundColor {0xf9fafb}
Color mBaseColor {0xe5e7eb}
Color mBorderColor {0xd1d5db}
unsigned int mBorderSides {BORDER_ALL}
unsigned int mBorderSize {0}
unsigned int mBorderStyle {BORDER_STYLE_FLAT}
std::list< Widget * > mChildren
FontmCurrentFont {nullptr}
std::list< DeathListener * > mDeathListeners
Rectangle mDimension
std::list< DropTargetListener * > mDropTargetListeners
bool mEnabled {true}
Size mFixedSize {-1, -1}
bool mFixedSizeUsed {false}
bool mFocusable {false}
bool mFocused {false}
FocusHandlermFocusHandler {nullptr}
std::list< FocusListener * > mFocusListeners
Color mForegroundColor {0x1f2933}
bool mHExpand {false}
std::string mId
FocusHandlermInternalFocusHandler {nullptr}
std::list< KeyListener * > mKeyListeners
int mLastX {0}
int mLastY {0}
int mMarginBottom {0}
int mMarginLeft {0}
int mMarginRight {0}
int mMarginTop {0}
Size mMaxSize {std::numeric_limits<int>::max(), std::numeric_limits<int>::max()}
Size mMinSize {0, 0}
std::list< MouseListener * > mMouseListeners
Rectangle mOffsetRect
Color mOutlineColor {0x9ca3af}
unsigned int mOutlineSize {0}
unsigned int mPaddingBottom {0}
unsigned int mPaddingLeft {0}
unsigned int mPaddingRight {0}
unsigned int mPaddingTop {0}
WidgetmParent {nullptr}
Color mSelectionColor {0x3b82f6}
SelectionMode mSelectionMode {SelectionMode::None}
bool mTabIn {true}
bool mTabOut {true}
bool mVExpand {false}
bool mVisible {true}
std::list< WidgetListener * > mWidgetListeners

Additional Inherited Members

Public Types inherited from fcn::Widget
enum  BorderSide : uint8_t {
  BORDER_NONE = 0 , BORDER_LEFT = 1 << 0 , BORDER_TOP = 1 << 1 , BORDER_RIGHT = 1 << 2 ,
  BORDER_BOTTOM = 1 << 3 , BORDER_ALL = BORDER_LEFT | BORDER_TOP | BORDER_RIGHT | BORDER_BOTTOM
}
enum  BorderStyle : uint8_t { BORDER_STYLE_BEVEL = 0 , BORDER_STYLE_FLAT = 1 }
enum class  SelectionMode : uint8_t { None = 0 , Border = 1 , Background = 2 }
Static Public Member Functions inherited from fcn::Widget
static DeathListener_getGuiDeathListener ()
static VisibilityEventHandler_getVisibilityEventHandler ()
static void _setGuiDeathListener (DeathListener *deathListener)
static void _setVisibilityEventHandler (VisibilityEventHandler *visibilityEventHandler)
static WidgetgetMouseCapture ()
static void resetGlobalFont ()
static void setGlobalFont (Font *font)
static bool widgetExists (Widget const *widget)
Static Protected Attributes inherited from fcn::Widget
static DefaultFont mDefaultFont
static FontmGlobalFont = nullptr
static DeathListenermGuiDeathListener = nullptr
static VisibilityEventHandlermVisibilityEventHandler = nullptr
static std::list< Widget * > mWidgetInstances
static WidgetsMouseCapture = nullptr

Detailed Description

A dropdown list widget allowing single item selection from a list.

The drop down consists of an internal ScrollArea and an internal ListBox. The drop down also uses an internal FocusHandler to handle the focus of the internal ScrollArea and the internal ListBox. The scroll area and the list box can be passed to the drop down if a custom scroll area and or a custom list box is preferable.

To be able display a list the drop down uses a user provided list model. A list model can be any class that implements the ListModel interface.

If an item is selected in the drop down a select event will be sent to all selection listeners of the drop down. If an item is selected by using a mouse click or by using the enter or space key an action event will be sent to all action listeners of the drop down.

Definition at line 49 of file dropdown.hpp.

Member Typedef Documentation

◆ SelectionListenerIterator

using fcn::DropDown::SelectionListenerIterator = SelectionListenerList::iterator
protected

Iterator for SelectionListenerList.

Definition at line 286 of file dropdown.hpp.

◆ SelectionListenerList

List of SelectionListener.

Definition at line 278 of file dropdown.hpp.

Constructor & Destructor Documentation

◆ DropDown()

fcn::DropDown::DropDown ( ListModel * listModel = nullptr,
ScrollArea * scrollArea = nullptr,
ListBox * listBox = nullptr )
explicit

◆ ~DropDown()

fcn::DropDown::~DropDown ( )
override

Definition at line 62 of file dropdown.cpp.

Member Function Documentation

◆ action()

void fcn::DropDown::action ( ActionEvent const & actionEvent)
overridevirtual

Handles an action event emitted by a widget.

Invoked when a widget triggers an action, providing details about the event via the ActionEvent object.

Parameters
actionEventThe action event data.

Implements fcn::ActionListener.

Definition at line 392 of file dropdown.cpp.

References fcn::Widget::distributeActionEvent(), foldUp(), and fcn::Widget::mFocusHandler.

◆ addSelectionListener()

void fcn::DropDown::addSelectionListener ( SelectionListener * selectionListener)

Adds a selection listener to the drop down.

When the selection changes an event will be sent to all selection listeners of the drop down.

If you delete your selection listener, be sure to also remove it using removeSelectionListener().

Parameters
selectionListenerthe selection listener to add.

Definition at line 497 of file dropdown.cpp.

References mSelectionListeners, and fcn::SelectionListener::SelectionListener().

◆ adjustHeight()

void fcn::DropDown::adjustHeight ( )

Adjusts the height of the drop down to fit the height of the drop down's parent's height.

It's used to not make the drop down draw itself outside of it's parent if folded down.

Definition at line 288 of file dropdown.cpp.

References fcn::Widget::getChildrenArea(), fcn::Widget::getFont(), fcn::Font::getHeight(), fcn::Widget::getParent(), fcn::Widget::getWidth(), fcn::Widget::getY(), fcn::Rectangle::height, mDroppedDown, mListBox, mScrollArea, fcn::Widget::setHeight(), and fcn::throwException().

Referenced by adjustSize(), DropDown(), dropDown(), foldUp(), resizeToContent(), and setListModel().

◆ adjustSize()

void fcn::DropDown::adjustSize ( )
overridevirtual

Resizes the widget's size to fit the content exactly.

Reimplemented from fcn::Widget.

Definition at line 342 of file dropdown.cpp.

References adjustHeight().

◆ death()

void fcn::DropDown::death ( Event const & event)
virtual

DeathListener callback invoked when a observed widget is destroyed.

Definition at line 381 of file dropdown.cpp.

References fcn::Event::getSource(), mOwnedScrollArea, and mScrollArea.

◆ distributeValueChangedEvent()

void fcn::DropDown::distributeValueChangedEvent ( )
protected

Distributes a value changed event to all selection listeners of the drop down.

Definition at line 508 of file dropdown.cpp.

References mSelectionListeners.

Referenced by valueChanged().

◆ draw()

void fcn::DropDown::draw ( Graphics * graphics)
overridevirtual

Draws the widget.

The call to draw is initiated by the widget's parent. 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. If a widget has children, the parent's draw function will always be called before the children's draw functions are called.

Note
A widget with children won't draw its children unless the children area given by Widget::getChildrenArea returns a none empty rectangle inside the widgets dimension. The children area is considered relative to the widget's position.
Parameters
graphicsA graphics object to draw with.
See also
getChildrenArea, drawOutline, drawBorder

Implements fcn::Widget.

Definition at line 72 of file dropdown.cpp.

References fcn::Color::a, drawButton(), fcn::Graphics::drawLine(), fcn::Graphics::drawRectangle(), fcn::Graphics::drawText(), fcn::Graphics::fillRectangle(), fcn::Widget::getBackgroundColor(), fcn::Widget::getBaseColor(), fcn::Graphics::getCurrentClipArea(), fcn::Widget::getFont(), fcn::Widget::getForegroundColor(), fcn::Widget::getHeight(), fcn::Widget::getSelectionColor(), fcn::Widget::getWidth(), fcn::Rectangle::height, fcn::Widget::isFocused(), mDroppedDown, mFoldedUpHeight, mListBox, fcn::Graphics::popClipArea(), fcn::Graphics::pushClipArea(), fcn::Graphics::setColor(), fcn::Graphics::setFont(), and fcn::Rectangle::width.

◆ drawButton()

void fcn::DropDown::drawButton ( Graphics * graphics)
protectedvirtual

◆ dropDown()

void fcn::DropDown::dropDown ( )
protectedvirtual

Sets the drop down to be dropped down.

Definition at line 347 of file dropdown.cpp.

References adjustHeight(), fcn::Widget::getHeight(), fcn::Widget::getParent(), mDroppedDown, mFoldedUpHeight, mListBox, and fcn::Widget::moveToTop().

Referenced by keyPressed(), and mousePressed().

◆ focusLost()

void fcn::DropDown::focusLost ( Event const & event)
overridevirtual

Called when a widget loses focus.

Parameters
eventDescribes the event.

Reimplemented from fcn::FocusListener.

Definition at line 373 of file dropdown.cpp.

References foldUp(), and fcn::Widget::mFocusHandler.

◆ foldUp()

void fcn::DropDown::foldUp ( )
protectedvirtual

Sets the drop down to be folded up.

Definition at line 362 of file dropdown.cpp.

References adjustHeight(), mDroppedDown, and fcn::Widget::mFocusHandler.

Referenced by action(), focusLost(), mousePressed(), and mouseReleased().

◆ getChildrenArea()

Rectangle fcn::DropDown::getChildrenArea ( )
overridevirtual

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.

Note
The returned rectangle should be relative to the widget, i.e a rectangle with x and y coordinate (0,0) and with width and height the same as the widget will let the children draw themselves in the whole widget.

An example of a widget that overloads this method is ScrollArea. A ScrollArea has a view of its constant 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.

Returns
The area of the widget occupied by the widget's children.

Reimplemented from fcn::Widget.

Definition at line 401 of file dropdown.cpp.

References fcn::Widget::getHeight(), fcn::Widget::getWidth(), mDroppedDown, and mFoldedUpHeight.

◆ getListModel()

ListModel * fcn::DropDown::getListModel ( ) const

Gets the list model used.

Returns
the ListModel used.
See also
setListModel

Definition at line 283 of file dropdown.cpp.

References mListBox.

◆ getSelected()

int fcn::DropDown::getSelected ( ) const

Gets the selected item as an index in the list model.

Returns
the selected item as an index in the list model.
See also
setSelected

Definition at line 191 of file dropdown.cpp.

References mListBox.

Referenced by keyPressed().

◆ keyPressed()

void fcn::DropDown::keyPressed ( KeyEvent & keyEvent)
overridevirtual

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.

Parameters
keyEventDescribes the event.

Reimplemented from fcn::KeyListener.

Definition at line 201 of file dropdown.cpp.

References fcn::InputEvent::consume(), dropDown(), fcn::KeyEvent::getKey(), getSelected(), fcn::InputEvent::isConsumed(), mDroppedDown, and setSelected().

◆ mouseDragged()

void fcn::DropDown::mouseDragged ( MouseEvent & mouseEvent)
overridevirtual

Called when the mouse has moved and the mouse has previously been pressed on the widget.

Parameters
mouseEventDescribes the event.

Reimplemented from fcn::MouseListener.

Definition at line 269 of file dropdown.cpp.

References fcn::InputEvent::consume(), and mIsDragged.

◆ mousePressed()

void fcn::DropDown::mousePressed ( MouseEvent & mouseEvent)
overridevirtual

Called when a mouse button has been pressed down on the widget area.

Note
A mouse press is NOT equal to a mouse click. Use mouseClicked() for "pressed AND released" (full click) on a widget.
See also
mouseClicked
Parameters
mouseEventDescribes the event.

Reimplemented from fcn::MouseListener.

Definition at line 221 of file dropdown.cpp.

References dropDown(), foldUp(), fcn::MouseEvent::getButton(), fcn::MouseEvent::getY(), fcn::Widget::isMouseInside(), mDroppedDown, fcn::Widget::mFocusHandler, mFoldedUpHeight, and mPushed.

◆ mouseReleased()

void fcn::DropDown::mouseReleased ( MouseEvent & mouseEvent)
overridevirtual

Called when a mouse button has been released on the widget area.

Parameters
mouseEventDescribes the event.

Reimplemented from fcn::MouseListener.

Definition at line 247 of file dropdown.cpp.

References foldUp(), fcn::MouseEvent::getButton(), fcn::Widget::isMouseInside(), fcn::Widget::isUnderMouseModal(), fcn::Widget::mFocusHandler, mIsDragged, and mPushed.

◆ mouseWheelMovedDown()

void fcn::DropDown::mouseWheelMovedDown ( MouseEvent & mouseEvent)
overridevirtual

Called when the mouse wheel has moved down on the widget area.

Parameters
mouseEventDescribes the event.

Reimplemented from fcn::MouseListener.

Definition at line 474 of file dropdown.cpp.

References fcn::InputEvent::consume(), fcn::Widget::isFocused(), fcn::Widget::isMouseInside(), and mListBox.

◆ mouseWheelMovedUp()

void fcn::DropDown::mouseWheelMovedUp ( MouseEvent & mouseEvent)
overridevirtual

Called when the mouse wheel has moved up on the widget area.

Parameters
mouseEventDescribes the event.

Reimplemented from fcn::MouseListener.

Definition at line 463 of file dropdown.cpp.

References fcn::InputEvent::consume(), fcn::Widget::isFocused(), fcn::Widget::isMouseInside(), and mListBox.

◆ removeSelectionListener()

void fcn::DropDown::removeSelectionListener ( SelectionListener * selectionListener)

Removes a selection listener from the drop down.

Parameters
selectionListenerthe selection listener to remove.

Definition at line 503 of file dropdown.cpp.

References mSelectionListeners, and fcn::SelectionListener::SelectionListener().

◆ resizeToContent()

void fcn::DropDown::resizeToContent ( bool recursion = true)
overridevirtual

Resizes the widget's size to fit the content exactly, calls recursively all childs.

The default value true allows callers to use resizeToContent() without argument.

Parameters
recursionIf true, perform the resize operation recursively on children.

Reimplemented from fcn::Widget.

Definition at line 326 of file dropdown.cpp.

References adjustHeight(), and mScrollArea.

◆ setBackgroundColor()

void fcn::DropDown::setBackgroundColor ( Color const & color)
overridevirtual

Set the explicit background color for the dropdown.

Reimplemented from fcn::Widget.

Definition at line 424 of file dropdown.cpp.

References mInternalListBox, mInternalScrollArea, mListBox, mScrollArea, and fcn::Widget::setBackgroundColor().

◆ setBaseColor()

void fcn::DropDown::setBaseColor ( Color const & color)
overridevirtual

Set the base color used for the dropdown background/controls.

Reimplemented from fcn::Widget.

Definition at line 411 of file dropdown.cpp.

References mInternalListBox, mInternalScrollArea, mListBox, mScrollArea, and fcn::Widget::setBaseColor().

◆ setFont()

void fcn::DropDown::setFont ( Font * font)
overridevirtual

Set the font used to render items in the dropdown.

Reimplemented from fcn::Widget.

Definition at line 450 of file dropdown.cpp.

References mInternalListBox, mInternalScrollArea, mListBox, mScrollArea, and fcn::Widget::setFont().

◆ setForegroundColor()

void fcn::DropDown::setForegroundColor ( Color const & color)
overridevirtual

Set the foreground/text color used in the dropdown.

Reimplemented from fcn::Widget.

Definition at line 437 of file dropdown.cpp.

References mInternalListBox, mInternalScrollArea, mListBox, mScrollArea, and fcn::Widget::setForegroundColor().

◆ setListModel()

void fcn::DropDown::setListModel ( ListModel * listModel)

Sets the list model to use when displaying the list.

Parameters
listModelthe list model to use.
See also
getListModel

Definition at line 276 of file dropdown.cpp.

References adjustHeight(), and mListBox.

Referenced by DropDown().

◆ setSelected()

void fcn::DropDown::setSelected ( int selected)

Sets the selected item.

The selected item is represented by an index from the list model.

Parameters
selectedthe selected item as an index from the list model.
See also
getSelected

Definition at line 196 of file dropdown.cpp.

References mListBox.

Referenced by keyPressed().

◆ setSelectionColor()

void fcn::DropDown::setSelectionColor ( Color const & color)
overridevirtual

Set the color used for the selected item highlight.

Reimplemented from fcn::Widget.

Definition at line 483 of file dropdown.cpp.

References mInternalListBox, mListBox, and fcn::Widget::setSelectionColor().

◆ valueChanged()

void fcn::DropDown::valueChanged ( SelectionEvent const & event)
overridevirtual

Called when the value of a selection has been changed in a Widget.

It is used to be able to receive a notification that a value has been changed.

Parameters
eventThe event of the value change.

Reimplemented from fcn::SelectionListener.

Definition at line 492 of file dropdown.cpp.

References distributeValueChangedEvent().

Member Data Documentation

◆ mDroppedDown

bool fcn::DropDown::mDroppedDown {false}
protected

True if the drop down is dropped down, false otherwise.

Definition at line 223 of file dropdown.hpp.

Referenced by adjustHeight(), draw(), dropDown(), foldUp(), getChildrenArea(), keyPressed(), and mousePressed().

◆ mFoldedUpHeight

int fcn::DropDown::mFoldedUpHeight {0}
protected

Holds what the height is if the drop down is folded up.

Used when checking if the list of the drop down was clicked or if the upper part of the drop down was clicked on a mouse click.

Definition at line 236 of file dropdown.hpp.

Referenced by draw(), dropDown(), getChildrenArea(), and mousePressed().

◆ mInternalListBox

bool fcn::DropDown::mInternalListBox {false}
protected

True if an internal list box is used, false if a list box has been passed to the drop down which the drop down should not deleted in it's destructor.

Definition at line 270 of file dropdown.hpp.

Referenced by DropDown(), setBackgroundColor(), setBaseColor(), setFont(), setForegroundColor(), and setSelectionColor().

◆ mInternalScrollArea

bool fcn::DropDown::mInternalScrollArea {false}
protected

True if an internal scroll area is used, false if a scroll area has been passed to the drop down which the drop down should not deleted in it's destructor.

Definition at line 263 of file dropdown.hpp.

Referenced by DropDown(), setBackgroundColor(), setBaseColor(), setFont(), and setForegroundColor().

◆ mIsDragged

bool fcn::DropDown::mIsDragged {false}
protected

True if the drop down is dragged.

Definition at line 275 of file dropdown.hpp.

Referenced by mouseDragged(), and mouseReleased().

◆ mListBox

◆ mOwnedListBox

std::unique_ptr<ListBox> fcn::DropDown::mOwnedListBox
protected

Owned internal list box when not supplied externally.

Definition at line 246 of file dropdown.hpp.

Referenced by DropDown().

◆ mOwnedScrollArea

std::unique_ptr<ScrollArea> fcn::DropDown::mOwnedScrollArea
protected

Owned internal scroll area when not supplied externally.

Definition at line 241 of file dropdown.hpp.

Referenced by death(), and DropDown().

◆ mPushed

bool fcn::DropDown::mPushed {false}
protected

True if the drop down has been pushed with the mouse, false otherwise.

Definition at line 229 of file dropdown.hpp.

Referenced by drawButton(), mousePressed(), and mouseReleased().

◆ mScrollArea

ScrollArea* fcn::DropDown::mScrollArea
protected

The scroll area used.

Definition at line 251 of file dropdown.hpp.

Referenced by adjustHeight(), death(), DropDown(), resizeToContent(), setBackgroundColor(), setBaseColor(), setFont(), and setForegroundColor().

◆ mSelectionListeners

SelectionListenerList fcn::DropDown::mSelectionListeners
protected

The selection listener's of the drop down.

Definition at line 283 of file dropdown.hpp.

Referenced by addSelectionListener(), distributeValueChangedEvent(), and removeSelectionListener().


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