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

#include <scrollarea.hpp>

Inheritance diagram for fcn::ScrollArea:
fcn::MouseListener fcn::Widget

Public Types

enum class  ScrollPolicy : uint8_t { ShowAlways = 0 , ShowNever , ShowAuto }
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 }

Public Member Functions

void adjustSize () override
void draw (Graphics *graphics) override
void expandContent ()
void expandContent (bool recursion) override
Rectangle getChildrenArea () override
WidgetgetContent () const
int getDownButtonScrollAmount () const
int getHorizontalMaxScroll ()
int getHorizontalScrollAmount () const
ScrollPolicy getHorizontalScrollPolicy () const
int getLeftButtonScrollAmount () const
int getRightButtonScrollAmount () const
int getScrollbarWidth () const
int getUpButtonScrollAmount () const
int getVerticalMaxScroll ()
int getVerticalScrollAmount () const
ScrollPolicy getVerticalScrollPolicy () const
virtual WidgetgetWidgetAt (int x, int y)
bool isOpaque () const
void logic () override
void mouseDragged (MouseEvent &mouseEvent) override
void mousePressed (MouseEvent &mouseEvent) override
void mouseReleased (MouseEvent &mouseEvent) override
void mouseWheelMovedDown (MouseEvent &mouseEvent) override
void mouseWheelMovedLeft (MouseEvent &mouseEvent) override
void mouseWheelMovedRight (MouseEvent &mouseEvent) override
void mouseWheelMovedUp (MouseEvent &mouseEvent) override
ScrollArea & operator= (ScrollArea &&)=delete
ScrollArea & operator= (ScrollArea const &)=delete
void resizeToContent (bool recursion=true) override
 ScrollArea (ScrollArea &&)=delete
 ScrollArea (ScrollArea const &)=delete
 ScrollArea (Widget *content)
 ScrollArea (Widget *content, ScrollPolicy hPolicy, ScrollPolicy vPolicy)
void setContent (Widget *widget)
void setDimension (Rectangle const &dimension) override
void setDownButtonScrollAmount (int amount)
void setHeight (int height) override
void setHorizontalScrollAmount (int hScroll)
void setHorizontalScrollPolicy (ScrollPolicy hPolicy)
void setLeftButtonScrollAmount (int amount)
void setOpaque (bool opaque)
void setRightButtonScrollAmount (int amount)
void setScrollAmount (int hScroll, int vScroll)
void setScrollbarWidth (int width)
void setScrollPolicy (ScrollPolicy hPolicy, ScrollPolicy vPolicy)
void setUpButtonScrollAmount (int amount)
void setVerticalScrollAmount (int vScroll)
void setVerticalScrollPolicy (ScrollPolicy vPolicy)
void setWidth (int width) override
void showWidgetPart (Widget *widget, Rectangle area) override
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)
MouseListeneroperator= (MouseListener &&)=default
MouseListeneroperator= (MouseListener 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 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 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)
virtual void setBackgroundColor (Color const &color)
virtual void setBaseColor (Color const &color)
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)
void setEnabled (bool enabled)
void setFixedSize (Size const &size)
void setFocusable (bool focusable)
virtual void setFocused (bool focused)
virtual void setFont (Font *font)
virtual void setForegroundColor (Color const &color)
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 setSelectionColor (Color const &color)
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)
void setX (int x)
void setY (int y)
virtual void showPart (Rectangle rectangle)
virtual void textInput (TextInputEvent &event)
 Widget ()
 Widget (Widget &&)=delete
 Widget (Widget const &)=delete

Protected Member Functions

virtual void checkPolicies ()
virtual void drawBackground (Graphics *graphics)
virtual void drawDownButton (Graphics *graphics)
virtual void drawHBar (Graphics *graphics)
virtual void drawHMarker (Graphics *graphics)
virtual void drawLeftButton (Graphics *graphics)
virtual void drawRightButton (Graphics *graphics)
virtual void drawUpButton (Graphics *graphics)
virtual void drawVBar (Graphics *graphics)
virtual void drawVMarker (Graphics *graphics)
Rectangle getDownButtonDimension ()
Rectangle getHorizontalBarDimension ()
Rectangle getHorizontalMarkerDimension ()
Rectangle getLeftButtonDimension ()
Rectangle getRightButtonDimension ()
Rectangle getUpButtonDimension ()
Rectangle getVerticalBarDimension ()
Rectangle getVerticalMarkerDimension ()
Protected Member Functions inherited from fcn::MouseListener
 MouseListener ()=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 mDownButtonPressed {false}
int mDownButtonScrollAmount {10}
bool mHBarVisible {false}
int mHorizontalMarkerDragOffset {0}
ScrollPolicy mHPolicy {ScrollPolicy::ShowAuto}
int mHScroll {0}
bool mIsHorizontalMarkerDragged {false}
bool mIsVerticalMarkerDragged {false}
bool mLeftButtonPressed {false}
int mLeftButtonScrollAmount {10}
bool mOpaque {true}
bool mRightButtonPressed {false}
int mRightButtonScrollAmount {10}
int mScrollbarWidth {12}
bool mUpButtonPressed {false}
int mUpButtonScrollAmount {10}
bool mVBarVisible {false}
int mVerticalMarkerDragOffset {0}
ScrollPolicy mVPolicy {ScrollPolicy::ShowAuto}
int mVScroll {0}
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

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 scrollable viewport for viewing widgets larger than the visible area.

Implementation if a scrollable area used to view widgets larger than the scroll area. A scroll area can be customized to always show scroll bars or to show them only when necessary.

Definition at line 29 of file scrollarea.hpp.

Member Enumeration Documentation

◆ ScrollPolicy

enum class fcn::ScrollArea::ScrollPolicy : uint8_t
strong

Scroll policies for the horizontal and vertical scrollbar.

The policies are:

SHOW_ALWAYS - Always show the scrollbars no matter what. SHOW_NEVER - Never show the scrollbars no matter what. SHOW_AUTO - Show the scrollbars only when needed. That is if the content grows larger then the ScrollArea.

Definition at line 41 of file scrollarea.hpp.

Constructor & Destructor Documentation

◆ ScrollArea() [1/3]

fcn::ScrollArea::ScrollArea ( )

Definition at line 19 of file scrollarea.cpp.

◆ ScrollArea() [2/3]

fcn::ScrollArea::ScrollArea ( Widget * content)
explicit

Constructor.

Parameters
contentThe content of the scroll area.

Definition at line 24 of file scrollarea.cpp.

References fcn::Widget::addMouseListener(), setContent(), and fcn::Widget::Widget().

◆ ScrollArea() [3/3]

fcn::ScrollArea::ScrollArea ( Widget * content,
ScrollPolicy hPolicy,
ScrollPolicy vPolicy )

Constructor.

Parameters
contentThe content of the scroll area.
hPolicyThe policy for the horizontal scrollbar. See enum with policies.
vPolicyThe policy for the vertical scrollbar. See enum with policies.

Definition at line 31 of file scrollarea.cpp.

References fcn::Widget::addMouseListener(), setContent(), and fcn::Widget::Widget().

◆ ~ScrollArea()

fcn::ScrollArea::~ScrollArea ( )
override

Definition at line 38 of file scrollarea.cpp.

Member Function Documentation

◆ adjustSize()

void fcn::ScrollArea::adjustSize ( )
overridevirtual

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

Reimplemented from fcn::Widget.

Definition at line 1018 of file scrollarea.cpp.

References fcn::Widget::adjustSize(), getContent(), fcn::Size::getHeight(), fcn::Widget::getMinSize(), fcn::Size::getWidth(), setHeight(), setWidth(), and fcn::Widget::Widget().

◆ checkPolicies()

◆ draw()

void fcn::ScrollArea::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 281 of file scrollarea.cpp.

References drawBackground(), drawDownButton(), drawHBar(), drawHMarker(), drawLeftButton(), drawRightButton(), drawUpButton(), drawVBar(), drawVMarker(), fcn::Graphics::fillRectangle(), fcn::Widget::getBaseColor(), fcn::Widget::getHeight(), fcn::Widget::getWidth(), mHBarVisible, mScrollbarWidth, mVBarVisible, and fcn::Graphics::setColor().

◆ drawBackground()

void fcn::ScrollArea::drawBackground ( Graphics * graphics)
protectedvirtual

Draws the background of the scroll area, that is the area behind the content.

Parameters
graphicsa Graphics object to draw with.

Definition at line 348 of file scrollarea.cpp.

References fcn::Graphics::fillRectangle(), fcn::Widget::getBackgroundColor(), getChildrenArea(), isOpaque(), and fcn::Graphics::setColor().

Referenced by draw().

◆ drawDownButton()

◆ drawHBar()

void fcn::ScrollArea::drawHBar ( Graphics * graphics)
protectedvirtual

◆ drawHMarker()

void fcn::ScrollArea::drawHMarker ( Graphics * graphics)
protectedvirtual

◆ drawLeftButton()

◆ drawRightButton()

◆ drawUpButton()

◆ drawVBar()

void fcn::ScrollArea::drawVBar ( Graphics * graphics)
protectedvirtual

◆ drawVMarker()

void fcn::ScrollArea::drawVMarker ( Graphics * graphics)
protectedvirtual

◆ expandContent() [1/2]

void fcn::Widget::expandContent ( )
inline

Expands the child widgets to the size of this widget, calls recursively all childs.

This is a convenience wrapper that calls expandContent(true).

Definition at line 1597 of file widget.hpp.

◆ expandContent() [2/2]

void fcn::ScrollArea::expandContent ( bool recursion)
overridevirtual

Expands child widgets to fit this widget's size.

Parameters
recursionIf true, call expandContent recursively on children.

Reimplemented from fcn::Widget.

Definition at line 1029 of file scrollarea.cpp.

References checkPolicies(), fcn::Widget::expandContent(), getContent(), fcn::Widget::getHeight(), fcn::Widget::getWidth(), setHeight(), setWidth(), and fcn::Widget::Widget().

◆ getChildrenArea()

Rectangle fcn::ScrollArea::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 770 of file scrollarea.cpp.

References fcn::Widget::getHeight(), fcn::Widget::getWidth(), fcn::Rectangle::isEmpty(), mHBarVisible, mScrollbarWidth, and mVBarVisible.

Referenced by drawBackground(), getHorizontalMarkerDimension(), getHorizontalMaxScroll(), getVerticalMarkerDimension(), getVerticalMaxScroll(), getWidgetAt(), mousePressed(), mouseWheelMovedDown(), mouseWheelMovedLeft(), mouseWheelMovedRight(), and mouseWheelMovedUp().

◆ getContent()

◆ getDownButtonDimension()

Rectangle fcn::ScrollArea::getDownButtonDimension ( )
protected

Gets the down button dimension.

Returns
the dimension of the down button.

Definition at line 731 of file scrollarea.cpp.

References fcn::Widget::getHeight(), fcn::Widget::getWidth(), mHBarVisible, mScrollbarWidth, and mVBarVisible.

Referenced by drawDownButton(), getVerticalBarDimension(), and mousePressed().

◆ getDownButtonScrollAmount()

int fcn::ScrollArea::getDownButtonScrollAmount ( ) const

Gets the amount to scroll in pixels when the down scroll button is pushed.

Returns
The amount to scroll in pixels.
See also
setDownButtonScrollAmount

Definition at line 1078 of file scrollarea.cpp.

References mDownButtonScrollAmount.

◆ getHorizontalBarDimension()

Rectangle fcn::ScrollArea::getHorizontalBarDimension ( )
protected

Gets the horizontal scrollbar dimension.

Returns
the dimension of the horizontal scrollbar.

Definition at line 805 of file scrollarea.cpp.

References fcn::Widget::getHeight(), getLeftButtonDimension(), getRightButtonDimension(), fcn::Widget::getWidth(), mHBarVisible, mScrollbarWidth, mVBarVisible, and fcn::Rectangle::width.

Referenced by drawHBar(), getHorizontalMarkerDimension(), mouseDragged(), and mousePressed().

◆ getHorizontalMarkerDimension()

Rectangle fcn::ScrollArea::getHorizontalMarkerDimension ( )
protected

◆ getHorizontalMaxScroll()

int fcn::ScrollArea::getHorizontalMaxScroll ( )

Gets the maximum amount of horizontal scroll.

Returns
The horizontal max scroll.

Definition at line 142 of file scrollarea.cpp.

References checkPolicies(), fcn::Widget::getBorderSize(), getChildrenArea(), getContent(), fcn::Widget::getWidth(), and fcn::Rectangle::width.

Referenced by getHorizontalMarkerDimension(), mouseDragged(), and setHorizontalScrollAmount().

◆ getHorizontalScrollAmount()

int fcn::ScrollArea::getHorizontalScrollAmount ( ) const

Gets the amount that is scrolled horizontally.

Returns
The scroll amount on horizontal scroll.
See also
setHorizontalScrollAmount, setScrollAmount

Definition at line 131 of file scrollarea.cpp.

References mHScroll.

Referenced by getHorizontalMarkerDimension(), logic(), mousePressed(), mouseWheelMovedLeft(), and mouseWheelMovedRight().

◆ getHorizontalScrollPolicy()

ScrollArea::ScrollPolicy fcn::ScrollArea::getHorizontalScrollPolicy ( ) const

Gets the horizontal scrollbar policy.

See enum with policies.

Returns
The policy for the horizontal scrollbar policy.
See also
setHorizontalScrollPolicy, setScrollPolicy

Definition at line 75 of file scrollarea.cpp.

References mHPolicy.

◆ getLeftButtonDimension()

Rectangle fcn::ScrollArea::getLeftButtonDimension ( )
protected

Gets the left button dimension.

Returns
the dimension of the left button.

Definition at line 746 of file scrollarea.cpp.

References fcn::Widget::getHeight(), mHBarVisible, and mScrollbarWidth.

Referenced by drawLeftButton(), getHorizontalBarDimension(), and mousePressed().

◆ getLeftButtonScrollAmount()

int fcn::ScrollArea::getLeftButtonScrollAmount ( ) const

Gets the amount to scroll in pixels when the left scroll button is pushed.

Returns
The amount to scroll in pixels.
See also
setLeftButtonScrollAmount

Definition at line 1063 of file scrollarea.cpp.

References mLeftButtonScrollAmount.

◆ getRightButtonDimension()

Rectangle fcn::ScrollArea::getRightButtonDimension ( )
protected

Gets the right button dimension.

Returns
the dimension of the right button.

Definition at line 755 of file scrollarea.cpp.

References fcn::Widget::getHeight(), fcn::Widget::getWidth(), mHBarVisible, mScrollbarWidth, and mVBarVisible.

Referenced by drawRightButton(), getHorizontalBarDimension(), and mousePressed().

◆ getRightButtonScrollAmount()

int fcn::ScrollArea::getRightButtonScrollAmount ( ) const

Gets the amount to scroll in pixels when the right scroll button is pushed.

Returns
The amount to scroll in pixels.
See also
setRightButtonScrollAmount

Definition at line 1068 of file scrollarea.cpp.

References mRightButtonScrollAmount.

◆ getScrollbarWidth()

int fcn::ScrollArea::getScrollbarWidth ( ) const

Gets the width of the scroll bars.

Returns
the width of the ScrollBar.
See also
setScrollbarWidth

Definition at line 187 of file scrollarea.cpp.

References mScrollbarWidth.

◆ getUpButtonDimension()

Rectangle fcn::ScrollArea::getUpButtonDimension ( )
protected

Gets the up button dimension.

Returns
the dimension of the up button.

Definition at line 722 of file scrollarea.cpp.

References fcn::Widget::getWidth(), mScrollbarWidth, and mVBarVisible.

Referenced by drawUpButton(), getVerticalBarDimension(), and mousePressed().

◆ getUpButtonScrollAmount()

int fcn::ScrollArea::getUpButtonScrollAmount ( ) const

Gets the amount to scroll in pixels when the up scroll button is pushed.

Returns
The amount to scroll in pixels.
See also
setUpButtonScrollAmount

Definition at line 1073 of file scrollarea.cpp.

References mUpButtonScrollAmount.

◆ getVerticalBarDimension()

Rectangle fcn::ScrollArea::getVerticalBarDimension ( )
protected

Gets the vertical scrollbar dimension.

Returns
the dimension of the vertical scrollbar.

Definition at line 784 of file scrollarea.cpp.

References getDownButtonDimension(), fcn::Widget::getHeight(), getUpButtonDimension(), fcn::Widget::getWidth(), fcn::Rectangle::height, mHBarVisible, mScrollbarWidth, and mVBarVisible.

Referenced by drawVBar(), getVerticalMarkerDimension(), mouseDragged(), and mousePressed().

◆ getVerticalMarkerDimension()

Rectangle fcn::ScrollArea::getVerticalMarkerDimension ( )
protected

◆ getVerticalMaxScroll()

int fcn::ScrollArea::getVerticalMaxScroll ( )

Gets the maximum amount of vertical scroll.

Returns
The vertical max scroll.

Definition at line 159 of file scrollarea.cpp.

References checkPolicies(), fcn::Widget::getBorderSize(), getChildrenArea(), getContent(), fcn::Widget::getHeight(), and fcn::Rectangle::height.

Referenced by getVerticalMarkerDimension(), mouseDragged(), and setVerticalScrollAmount().

◆ getVerticalScrollAmount()

int fcn::ScrollArea::getVerticalScrollAmount ( ) const

Gets the amount that is scrolled vertically.

Returns
The scroll amount on vertical scroll.
See also
setVerticalScrollAmount, setScrollAmount

Definition at line 113 of file scrollarea.cpp.

References mVScroll.

Referenced by getVerticalMarkerDimension(), logic(), mousePressed(), mouseWheelMovedDown(), and mouseWheelMovedUp().

◆ getVerticalScrollPolicy()

ScrollArea::ScrollPolicy fcn::ScrollArea::getVerticalScrollPolicy ( ) const

Gets the vertical scrollbar policy.

See enum with policies.

Returns
The policy for the vertical scrollbar.
See also
setVerticalScrollPolicy, setScrollPolicy

Definition at line 86 of file scrollarea.cpp.

References mVPolicy.

◆ getWidgetAt()

Widget * fcn::ScrollArea::getWidgetAt ( int x,
int y )
virtual

Hit-test for widgets inside the scroll area.

Parameters
xX coordinate to test (local).
yY coordinate to test (local).
Returns
The widget at (x,y) or nullptr if none.

Definition at line 898 of file scrollarea.cpp.

References getChildrenArea(), getContent(), and fcn::Widget::Widget().

◆ isOpaque()

bool fcn::ScrollArea::isOpaque ( ) const

Checks if the scroll area is opaque, that is if the scroll area displays its background.

Returns
True if the scroll area is opaque, false otherwise.

Definition at line 1088 of file scrollarea.cpp.

References mOpaque.

Referenced by drawBackground().

◆ logic()

void fcn::ScrollArea::logic ( )
overridevirtual

Called for all widgets in the GUI each time Gui::logic is called.

You can do logic stuff here like playing an animation.

See also
Gui::logic

Reimplemented from fcn::Widget.

Definition at line 629 of file scrollarea.cpp.

References checkPolicies(), fcn::Widget::getBorderSize(), getContent(), getHorizontalScrollAmount(), getVerticalScrollAmount(), fcn::Widget::logic(), mHScroll, mVScroll, setHorizontalScrollAmount(), fcn::Widget::setPosition(), and setVerticalScrollAmount().

◆ mouseDragged()

◆ mousePressed()

◆ mouseReleased()

void fcn::ScrollArea::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 238 of file scrollarea.cpp.

References fcn::InputEvent::consume(), mDownButtonPressed, mIsHorizontalMarkerDragged, mIsVerticalMarkerDragged, mLeftButtonPressed, mRightButtonPressed, and mUpButtonPressed.

◆ mouseWheelMovedDown()

void fcn::ScrollArea::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 923 of file scrollarea.cpp.

References fcn::InputEvent::consume(), getChildrenArea(), getVerticalScrollAmount(), fcn::InputEvent::isConsumed(), mVBarVisible, and setVerticalScrollAmount().

◆ mouseWheelMovedLeft()

void fcn::ScrollArea::mouseWheelMovedLeft ( MouseEvent & mouseEvent)
overridevirtual

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

Parameters
mouseEventDescribes the event.

Reimplemented from fcn::MouseListener.

Definition at line 955 of file scrollarea.cpp.

References fcn::InputEvent::consume(), getChildrenArea(), getHorizontalScrollAmount(), fcn::InputEvent::isConsumed(), mHBarVisible, and setHorizontalScrollAmount().

◆ mouseWheelMovedRight()

void fcn::ScrollArea::mouseWheelMovedRight ( MouseEvent & mouseEvent)
overridevirtual

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

Parameters
mouseEventDescribes the event.

Reimplemented from fcn::MouseListener.

Definition at line 939 of file scrollarea.cpp.

References fcn::InputEvent::consume(), getChildrenArea(), getHorizontalScrollAmount(), fcn::InputEvent::isConsumed(), mHBarVisible, and setHorizontalScrollAmount().

◆ mouseWheelMovedUp()

void fcn::ScrollArea::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 907 of file scrollarea.cpp.

References fcn::InputEvent::consume(), getChildrenArea(), getVerticalScrollAmount(), fcn::InputEvent::isConsumed(), mVBarVisible, and setVerticalScrollAmount().

◆ resizeToContent()

void fcn::ScrollArea::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 1006 of file scrollarea.cpp.

References getContent(), fcn::Size::getHeight(), fcn::Widget::getMinSize(), fcn::Size::getWidth(), fcn::Widget::resizeToContent(), setHeight(), setWidth(), and fcn::Widget::Widget().

◆ setContent()

void fcn::ScrollArea::setContent ( Widget * widget)

Sets the content.

Parameters
widgetThe content of the scroll area.

Definition at line 48 of file scrollarea.cpp.

References fcn::Widget::add(), checkPolicies(), fcn::Widget::removeAllChildren(), fcn::Widget::setPosition(), and fcn::Widget::Widget().

Referenced by ScrollArea(), and ScrollArea().

◆ setDimension()

void fcn::ScrollArea::setDimension ( Rectangle const & dimension)
overridevirtual

◆ setDownButtonScrollAmount()

void fcn::ScrollArea::setDownButtonScrollAmount ( int amount)

Sets the amount to scroll in pixels when the down scroll button is pushed.

Parameters
amountThe amount to scroll in pixels.
See also
getDownButtonScrollAmount

Definition at line 1058 of file scrollarea.cpp.

References mDownButtonScrollAmount.

◆ setHeight()

void fcn::ScrollArea::setHeight ( int height)
overridevirtual

Set the height of the scroll area.

Reimplemented from fcn::Widget.

Definition at line 982 of file scrollarea.cpp.

References checkPolicies(), getContent(), fcn::Widget::getHeight(), fcn::Widget::setHeight(), and fcn::Widget::Widget().

Referenced by adjustSize(), expandContent(), and resizeToContent().

◆ setHorizontalScrollAmount()

void fcn::ScrollArea::setHorizontalScrollAmount ( int hScroll)

Sets the amount to scroll horizontally.

Parameters
hScrollThe amount to scroll.
See also
getHorizontalScrollAmount

Definition at line 118 of file scrollarea.cpp.

References getHorizontalMaxScroll(), and mHScroll.

Referenced by logic(), mouseDragged(), mousePressed(), mouseWheelMovedLeft(), mouseWheelMovedRight(), setScrollAmount(), and showWidgetPart().

◆ setHorizontalScrollPolicy()

void fcn::ScrollArea::setHorizontalScrollPolicy ( ScrollPolicy hPolicy)

Sets the horizontal scrollbar policy.

See enum with policies.

Parameters
hPolicyThe policy for the horizontal scrollbar.
See also
getHorizontalScrollPolicy

Definition at line 69 of file scrollarea.cpp.

References checkPolicies(), and mHPolicy.

◆ setLeftButtonScrollAmount()

void fcn::ScrollArea::setLeftButtonScrollAmount ( int amount)

Sets the amount to scroll in pixels when the left scroll button is pushed.

Parameters
amountThe amount to scroll in pixels.
See also
getLeftButtonScrollAmount

Definition at line 1043 of file scrollarea.cpp.

References mLeftButtonScrollAmount.

◆ setOpaque()

void fcn::ScrollArea::setOpaque ( bool opaque)

Sets the scroll area to be opaque, that is sets the scroll area to display its background.

Parameters
opaqueTrue if the scroll area should be opaque, false otherwise.

Definition at line 1083 of file scrollarea.cpp.

References mOpaque.

◆ setRightButtonScrollAmount()

void fcn::ScrollArea::setRightButtonScrollAmount ( int amount)

Sets the amount to scroll in pixels when the right scroll button is pushed.

Parameters
amountThe amount to scroll in pixels.
See also
getRightButtonScrollAmount

Definition at line 1048 of file scrollarea.cpp.

References mRightButtonScrollAmount.

◆ setScrollAmount()

void fcn::ScrollArea::setScrollAmount ( int hScroll,
int vScroll )

Sets the amount to scroll horizontally and vertically.

Parameters
hScrollThe amount to scroll on horizontal scroll.
vScrollThe amount to scroll on vertical scroll.
See also
getHorizontalScrollAmount, getVerticalScrollAmount

Definition at line 136 of file scrollarea.cpp.

References setHorizontalScrollAmount(), and setVerticalScrollAmount().

◆ setScrollbarWidth()

void fcn::ScrollArea::setScrollbarWidth ( int width)

Sets the width of the scroll bars.

Parameters
widthThe width of the scroll bars.
See also
getScrollbarWidth

Definition at line 178 of file scrollarea.cpp.

References mScrollbarWidth, and fcn::throwException().

◆ setScrollPolicy()

void fcn::ScrollArea::setScrollPolicy ( ScrollPolicy hPolicy,
ScrollPolicy vPolicy )

Sets the horizontal and vertical scrollbar policy.

Parameters
hPolicyThe policy for the horizontal scrollbar.
vPolicyThe policy for the vertical scrollbar.
See also
getVerticalScrollPolicy, getHorizontalScrollPolicy

Definition at line 91 of file scrollarea.cpp.

References checkPolicies(), mHPolicy, and mVPolicy.

◆ setUpButtonScrollAmount()

void fcn::ScrollArea::setUpButtonScrollAmount ( int amount)

Sets the amount to scroll in pixels when the up scroll button is pushed.

Parameters
amountThe amount to scroll in pixels.
See also
getUpButtonScrollAmount

Definition at line 1053 of file scrollarea.cpp.

References mUpButtonScrollAmount.

◆ setVerticalScrollAmount()

void fcn::ScrollArea::setVerticalScrollAmount ( int vScroll)

Sets the amount to scroll vertically.

Parameters
vScrollThe amount to scroll.
See also
getVerticalScrollAmount

Definition at line 98 of file scrollarea.cpp.

References getVerticalMaxScroll(), and mVScroll.

Referenced by logic(), mouseDragged(), mousePressed(), mouseWheelMovedDown(), mouseWheelMovedUp(), setScrollAmount(), and showWidgetPart().

◆ setVerticalScrollPolicy()

void fcn::ScrollArea::setVerticalScrollPolicy ( ScrollPolicy vPolicy)

Sets the vertical scrollbar policy.

See enum with policies.

Parameters
vPolicyThe policy for the vertical scrollbar.
See also
getVerticalScrollPolicy

Definition at line 80 of file scrollarea.cpp.

References checkPolicies(), and mVPolicy.

◆ setWidth()

void fcn::ScrollArea::setWidth ( int width)
overridevirtual

Set the width of the scroll area.

Reimplemented from fcn::Widget.

Definition at line 971 of file scrollarea.cpp.

References checkPolicies(), getContent(), fcn::Widget::getWidth(), fcn::Widget::setWidth(), and fcn::Widget::Widget().

Referenced by adjustSize(), expandContent(), and resizeToContent().

◆ showWidgetPart()

void fcn::ScrollArea::showWidgetPart ( Widget * widget,
Rectangle area )
overridevirtual

Tries to show a specific part of a widget by moving it.

Used if the widget should act as a container.

Parameters
widgetThe target widget.
areaThe area to show.

Reimplemented from fcn::Widget.

Definition at line 886 of file scrollarea.cpp.

References fcn::Widget::getBorderSize(), getContent(), fcn::Widget::getX(), fcn::Widget::getY(), setHorizontalScrollAmount(), setVerticalScrollAmount(), fcn::Widget::showWidgetPart(), fcn::throwException(), and fcn::Widget::Widget().

Member Data Documentation

◆ mDownButtonPressed

bool fcn::ScrollArea::mDownButtonPressed {false}
protected

True if the down button is pressed, false otherwise.

Definition at line 512 of file scrollarea.hpp.

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

◆ mDownButtonScrollAmount

int fcn::ScrollArea::mDownButtonScrollAmount {10}
protected

Holds the down button scroll amount.

Definition at line 532 of file scrollarea.hpp.

Referenced by getDownButtonScrollAmount(), mousePressed(), and setDownButtonScrollAmount().

◆ mHBarVisible

bool fcn::ScrollArea::mHBarVisible {false}
protected

◆ mHorizontalMarkerDragOffset

int fcn::ScrollArea::mHorizontalMarkerDragOffset {0}
protected

Holds the horizontal markers drag offset.

Definition at line 557 of file scrollarea.hpp.

Referenced by mouseDragged(), and mousePressed().

◆ mHPolicy

ScrollPolicy fcn::ScrollArea::mHPolicy {ScrollPolicy::ShowAuto}
protected

Holds the horizontal scroll bar policy.

Definition at line 487 of file scrollarea.hpp.

Referenced by checkPolicies(), getHorizontalScrollPolicy(), setHorizontalScrollPolicy(), and setScrollPolicy().

◆ mHScroll

int fcn::ScrollArea::mHScroll {0}
protected

Holds the horizontal scroll amount.

Definition at line 477 of file scrollarea.hpp.

Referenced by getHorizontalScrollAmount(), logic(), and setHorizontalScrollAmount().

◆ mIsHorizontalMarkerDragged

bool fcn::ScrollArea::mIsHorizontalMarkerDragged {false}
protected

True if the horizontal marked is dragged.

Definition at line 552 of file scrollarea.hpp.

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

◆ mIsVerticalMarkerDragged

bool fcn::ScrollArea::mIsVerticalMarkerDragged {false}
protected

True if the vertical marked is dragged.

Definition at line 547 of file scrollarea.hpp.

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

◆ mLeftButtonPressed

bool fcn::ScrollArea::mLeftButtonPressed {false}
protected

True if the left button is pressed, false otherwise.

Definition at line 517 of file scrollarea.hpp.

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

◆ mLeftButtonScrollAmount

int fcn::ScrollArea::mLeftButtonScrollAmount {10}
protected

Holds the left button scroll amount.

Definition at line 537 of file scrollarea.hpp.

Referenced by getLeftButtonScrollAmount(), mousePressed(), and setLeftButtonScrollAmount().

◆ mOpaque

bool fcn::ScrollArea::mOpaque {true}
protected

True if the scroll area should be opaque (that is display its background), false otherwise.

Definition at line 568 of file scrollarea.hpp.

Referenced by isOpaque(), and setOpaque().

◆ mRightButtonPressed

bool fcn::ScrollArea::mRightButtonPressed {false}
protected

True if the right button is pressed, false otherwise.

Definition at line 522 of file scrollarea.hpp.

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

◆ mRightButtonScrollAmount

int fcn::ScrollArea::mRightButtonScrollAmount {10}
protected

Holds the right button scroll amount.

Definition at line 542 of file scrollarea.hpp.

Referenced by getRightButtonScrollAmount(), mousePressed(), and setRightButtonScrollAmount().

◆ mScrollbarWidth

◆ mUpButtonPressed

bool fcn::ScrollArea::mUpButtonPressed {false}
protected

True if the up button is pressed, false otherwise.

Definition at line 507 of file scrollarea.hpp.

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

◆ mUpButtonScrollAmount

int fcn::ScrollArea::mUpButtonScrollAmount {10}
protected

Holds the up button scroll amount.

Definition at line 527 of file scrollarea.hpp.

Referenced by getUpButtonScrollAmount(), mousePressed(), and setUpButtonScrollAmount().

◆ mVBarVisible

bool fcn::ScrollArea::mVBarVisible {false}
protected

◆ mVerticalMarkerDragOffset

int fcn::ScrollArea::mVerticalMarkerDragOffset {0}
protected

Holds the vertical markers drag offset.

Definition at line 562 of file scrollarea.hpp.

Referenced by mouseDragged(), and mousePressed().

◆ mVPolicy

ScrollPolicy fcn::ScrollArea::mVPolicy {ScrollPolicy::ShowAuto}
protected

Holds the vertical scroll bar policy.

Definition at line 492 of file scrollarea.hpp.

Referenced by checkPolicies(), getVerticalScrollPolicy(), setScrollPolicy(), and setVerticalScrollPolicy().

◆ mVScroll

int fcn::ScrollArea::mVScroll {0}
protected

Holds the vertical scroll amount.

Definition at line 472 of file scrollarea.hpp.

Referenced by getVerticalScrollAmount(), logic(), and setVerticalScrollAmount().


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