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

#include <tabbedarea.hpp>

Inheritance diagram for fcn::TabbedArea:
fcn::ActionListener fcn::KeyListener fcn::MouseListener fcn::Widget

Public Member Functions

void action (ActionEvent const &actionEvent) override
virtual void addTab (Tab *tab, Widget *widget)
void adjustSize () override
virtual void death (Event const &event)
void draw (Graphics *graphics) override
void expandContent ()
void expandContent (bool recursion) override
WidgetgetBackgroundWidget ()
Rectangle getChildrenArea () override
virtual unsigned int getHorizontalSpacing () const
Container::LayoutPolicy getLayout () const
int getNumberOfTabs () const
Tab * getSelectedTab () const
virtual int getSelectedTabIndex () const
virtual unsigned int getVerticalSpacing () const
bool isOpaque () const
virtual bool isTabSelected (Tab *tab) const
virtual bool isTabSelected (unsigned int index) const
virtual bool isUniformSize () const
void keyPressed (KeyEvent &keyEvent) override
void mousePressed (MouseEvent &mouseEvent) override
TabbedArea & operator= (TabbedArea &&)=delete
TabbedArea & operator= (TabbedArea const &)=delete
virtual void removeTab (Tab *tab)
virtual void removeTabWithIndex (unsigned int index)
void resizeToContent (bool recursion=true) override
void setBackgroundWidget (Widget *widget)
void setBaseColor (Color const &color) override
void setDimension (Rectangle const &dimension) override
void setHeight (int height) override
virtual void setHorizontalSpacing (unsigned int spacing)
void setLayout (Container::LayoutPolicy policy)
void setOpaque (bool opaque)
virtual void setSelectedTab (Tab *tab)
virtual void setSelectedTab (unsigned int index)
void setSize (int width, int height) override
virtual void setUniformSize (bool uniform)
virtual void setVerticalSpacing (unsigned int spacing)
void setWidth (int width) override
 TabbedArea (TabbedArea &&)=delete
 TabbedArea (TabbedArea const &)=delete
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 mouseDragged (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 mouseReleased (MouseEvent &mouseEvent)
virtual void mouseWheelMovedDown (MouseEvent &mouseEvent)
virtual void mouseWheelMovedLeft (MouseEvent &mouseEvent)
virtual void mouseWheelMovedRight (MouseEvent &mouseEvent)
virtual void mouseWheelMovedUp (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 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)
virtual void setBackgroundColor (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)
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 showWidgetPart (Widget *widget, Rectangle area)
virtual void textInput (TextInputEvent &event)
 Widget ()
 Widget (Widget &&)=delete
 Widget (Widget const &)=delete

Protected Member Functions

void adjustTabPositions ()
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::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 mOpaque {false}
Tab * mSelectedTab {nullptr}
ContainermTabContainer
std::vector< std::pair< Tab *, Widget * > > mTabs
std::vector< std::unique_ptr< Tab > > mTabsToDelete
ContainermWidgetContainer
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

Friends

class Tab

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 container organizing content into selectable tabs.

A tabbed area where a user can display a widget by selecting a tab.

Definition at line 36 of file tabbedarea.hpp.

Constructor & Destructor Documentation

◆ TabbedArea()

fcn::TabbedArea::TabbedArea ( )

Definition at line 23 of file tabbedarea.cpp.

◆ ~TabbedArea()

fcn::TabbedArea::~TabbedArea ( )
override

Definition at line 39 of file tabbedarea.cpp.

Member Function Documentation

◆ action()

void fcn::TabbedArea::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 454 of file tabbedarea.cpp.

References action(), fcn::Event::getSource(), setSelectedTab(), fcn::throwException(), and fcn::Widget::Widget().

Referenced by action().

◆ addTab()

void fcn::TabbedArea::addTab ( Tab * tab,
Widget * widget )
virtual

Adds a tab to the tabbed area.

The tab will not be deleted by the tabbed area when it is removed.

Parameters
tabThe tab widget for the tab.
widgetThe widget to view when the tab is selected.
See also
removeTab, removeTabWithIndex

Definition at line 48 of file tabbedarea.cpp.

References fcn::Widget::adaptLayout(), fcn::Widget::addActionListener(), addTab(), fcn::Widget::getBaseColor(), fcn::Container::getLayout(), getLayout(), mSelectedTab, mTabContainer, mTabs, fcn::Widget::setBaseColor(), fcn::Container::setLayout(), setSelectedTab(), fcn::Tab::setTabbedArea(), and fcn::Widget::Widget().

Referenced by addTab().

◆ adjustSize()

void fcn::TabbedArea::adjustSize ( )
overridevirtual

Adjusts the size of the tab container and the widget container.

Reimplemented from fcn::Widget.

Definition at line 284 of file tabbedarea.cpp.

References adjustSize(), fcn::Widget::getHeight(), getLayout(), fcn::Widget::getWidth(), mTabContainer, mTabs, and mWidgetContainer.

Referenced by adjustSize(), expandContent(), resizeToContent(), setDimension(), setHeight(), setSize(), and setWidth().

◆ adjustTabPositions()

void fcn::TabbedArea::adjustTabPositions ( )
protected

◆ death()

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

DeathListener callback invoked when a child widget dies.

Definition at line 443 of file tabbedarea.cpp.

References death(), and removeTab().

Referenced by death().

◆ draw()

void fcn::TabbedArea::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 214 of file tabbedarea.cpp.

References fcn::Color::a, draw(), fcn::Graphics::drawLine(), fcn::Graphics::fillRectangle(), fcn::Widget::getBaseColor(), fcn::Widget::getHeight(), fcn::Widget::getWidth(), isOpaque(), mSelectedTab, mTabContainer, and fcn::Graphics::setColor().

Referenced by draw().

◆ 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::TabbedArea::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 274 of file tabbedarea.cpp.

References adjustSize(), adjustTabPositions(), expandContent(), mTabContainer, and mWidgetContainer.

Referenced by expandContent().

◆ getBackgroundWidget()

Widget * fcn::TabbedArea::getBackgroundWidget ( )

Get the background widget, or nullptr if none is set.

Definition at line 209 of file tabbedarea.cpp.

References getBackgroundWidget(), mTabContainer, and fcn::Widget::Widget().

Referenced by getBackgroundWidget().

◆ getChildrenArea()

Rectangle fcn::TabbedArea::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 253 of file tabbedarea.cpp.

References fcn::Widget::getBorderSize(), getChildrenArea(), fcn::Widget::getHeight(), fcn::Widget::getPaddingBottom(), fcn::Widget::getPaddingLeft(), fcn::Widget::getPaddingRight(), fcn::Widget::getPaddingTop(), fcn::Widget::getWidth(), fcn::Rectangle::height, fcn::Rectangle::width, fcn::Rectangle::x, and fcn::Rectangle::y.

Referenced by getChildrenArea().

◆ getHorizontalSpacing()

unsigned int fcn::TabbedArea::getHorizontalSpacing ( ) const
virtual

Get the horizontal spacing between rows.

Returns
horizontal spacing in pixels.
See also
setHorizontalSpacing

Definition at line 511 of file tabbedarea.cpp.

References getHorizontalSpacing(), and mTabContainer.

Referenced by getHorizontalSpacing().

◆ getLayout()

Container::LayoutPolicy fcn::TabbedArea::getLayout ( ) const

Gets the layout of the tabbedarea.

Returns
The LayoutPolicy of the tabbedarea.
See also
setLayout, LayoutPolicy

Definition at line 481 of file tabbedarea.cpp.

References getLayout(), and mTabContainer.

Referenced by addTab(), adjustSize(), adjustTabPositions(), and getLayout().

◆ getNumberOfTabs()

int fcn::TabbedArea::getNumberOfTabs ( ) const

Returns the number of tabs in this tabbed area.

Definition at line 117 of file tabbedarea.cpp.

References getNumberOfTabs(), and mTabs.

Referenced by getNumberOfTabs().

◆ getSelectedTab()

Tab * fcn::TabbedArea::getSelectedTab ( ) const

Gets the selected tab.

Returns
The selected tab.
See also
isTabSelected, setSelectedTab

Definition at line 188 of file tabbedarea.cpp.

References getSelectedTab(), and mSelectedTab.

Referenced by getSelectedTab().

◆ getSelectedTabIndex()

int fcn::TabbedArea::getSelectedTabIndex ( ) const
virtual

Gets the index of the selected tab.

Returns
The index of the selected tab. If no tab is selected -1 will be returned.
See also
isTabSelected, setSelectedTab

Definition at line 175 of file tabbedarea.cpp.

References getSelectedTabIndex(), mSelectedTab, and mTabs.

Referenced by getSelectedTabIndex(), keyPressed(), and removeTab().

◆ getVerticalSpacing()

unsigned int fcn::TabbedArea::getVerticalSpacing ( ) const
virtual

Get the vertical spacing between rows.

Returns
vertical spacing in pixels.
See also
setVerticalSpacing

Definition at line 501 of file tabbedarea.cpp.

References getVerticalSpacing(), and mTabContainer.

Referenced by getVerticalSpacing().

◆ isOpaque()

bool fcn::TabbedArea::isOpaque ( ) const

Checks if the tabbed area is opaque or not.

Returns
true if the tabbed area is opaque, false otherwise.
See also
setOpaque

Definition at line 198 of file tabbedarea.cpp.

References isOpaque(), and mOpaque.

Referenced by draw(), and isOpaque().

◆ isTabSelected() [1/2]

bool fcn::TabbedArea::isTabSelected ( Tab * tab) const
virtual

Checks if a tab is selected or not.

Parameters
tabThe tab to check.
Returns
True if the tab is selected, false otherwise.
See also
setSelectedTab

Definition at line 131 of file tabbedarea.cpp.

References isTabSelected(), and mSelectedTab.

◆ isTabSelected() [2/2]

bool fcn::TabbedArea::isTabSelected ( unsigned int index) const
virtual

Checks if a tab given an index is selected or not.

Parameters
indexThe index of the tab to check.
Returns
True if the tab is selected, false otherwise.
See also
setSelectedTab

Definition at line 122 of file tabbedarea.cpp.

References isTabSelected(), mSelectedTab, mTabs, and fcn::throwException().

Referenced by isTabSelected(), and isTabSelected().

◆ isUniformSize()

bool fcn::TabbedArea::isUniformSize ( ) const
virtual

True if the tab container tries to expand the childs to a uniform size.

Returns
True if uniform size is set, otherwise false.
See also
setUniformSize

Definition at line 491 of file tabbedarea.cpp.

References isUniformSize(), and mTabContainer.

Referenced by isUniformSize().

◆ keyPressed()

void fcn::TabbedArea::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 387 of file tabbedarea.cpp.

References fcn::InputEvent::consume(), fcn::KeyEvent::getKey(), getSelectedTabIndex(), fcn::InputEvent::isConsumed(), fcn::Widget::isFocused(), keyPressed(), mTabs, and setSelectedTab().

Referenced by keyPressed().

◆ mousePressed()

void fcn::TabbedArea::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 418 of file tabbedarea.cpp.

References fcn::MouseEvent::getButton(), fcn::Event::getSource(), fcn::MouseEvent::getX(), fcn::MouseEvent::getY(), fcn::Widget::isFocusable(), mousePressed(), mTabContainer, fcn::Widget::requestFocus(), setSelectedTab(), and fcn::Widget::Widget().

Referenced by mousePressed().

◆ removeTab()

void fcn::TabbedArea::removeTab ( Tab * tab)
virtual

Removes a tab from the tabbed area.

Parameters
tabThe tab to remove.
See also
addTab

Definition at line 75 of file tabbedarea.cpp.

References fcn::Widget::adaptLayout(), getSelectedTabIndex(), mSelectedTab, mTabContainer, mTabs, mTabsToDelete, mWidgetContainer, removeTab(), and setSelectedTab().

Referenced by death(), removeTab(), and removeTabWithIndex().

◆ removeTabWithIndex()

void fcn::TabbedArea::removeTabWithIndex ( unsigned int index)
virtual

Removes a tab from the tabbed area.

Parameters
indexThe index of the tab to remove.
See also
addTab

Definition at line 66 of file tabbedarea.cpp.

References mTabs, removeTab(), removeTabWithIndex(), and fcn::throwException().

Referenced by removeTabWithIndex().

◆ resizeToContent()

void fcn::TabbedArea::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 263 of file tabbedarea.cpp.

References adjustSize(), adjustTabPositions(), mTabContainer, mWidgetContainer, fcn::Widget::resizeToChildren(), and resizeToContent().

Referenced by resizeToContent().

◆ setBackgroundWidget()

void fcn::TabbedArea::setBackgroundWidget ( Widget * widget)

Set the background widget which is drawn behind tabs.

Definition at line 203 of file tabbedarea.cpp.

References mTabContainer, mWidgetContainer, setBackgroundWidget(), and fcn::Widget::Widget().

Referenced by setBackgroundWidget().

◆ setBaseColor()

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

Set the base/background color used for the tabbed area.

Reimplemented from fcn::Widget.

Definition at line 466 of file tabbedarea.cpp.

References mTabContainer, mTabs, mWidgetContainer, setBaseColor(), and fcn::Widget::setBaseColor().

Referenced by setBaseColor().

◆ setDimension()

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

Set the area dimension for the tabbed area.

Reimplemented from fcn::Widget.

Definition at line 375 of file tabbedarea.cpp.

References adjustSize(), fcn::Widget::mDimension, setDimension(), and fcn::Widget::setDimension().

Referenced by setDimension().

◆ setHeight()

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

Set the height of the tabbed area in pixels.

Reimplemented from fcn::Widget.

Definition at line 350 of file tabbedarea.cpp.

References adjustSize(), fcn::Widget::mDimension, setHeight(), and fcn::Widget::setHeight().

Referenced by setHeight().

◆ setHorizontalSpacing()

void fcn::TabbedArea::setHorizontalSpacing ( unsigned int spacing)
virtual

Set the horizontal spacing between columns.

Parameters
spacingspacing in pixels.
See also
getHorizontalSpacing

Definition at line 506 of file tabbedarea.cpp.

References mTabContainer, and setHorizontalSpacing().

Referenced by setHorizontalSpacing().

◆ setLayout()

void fcn::TabbedArea::setLayout ( Container::LayoutPolicy policy)

Sets the layout of the tabbedarea.

Parameters
policyThe LayoutPolicy of the tabbedarea.
See also
getLayout, LayoutPolicy

Definition at line 476 of file tabbedarea.cpp.

References mTabContainer, and setLayout().

Referenced by setLayout().

◆ setOpaque()

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

Sets the tabbed area to be opaque or not.

If the tabbed area is opaque its background will be drawn, if it's not opaque its background will not be drawn. By default, a tabbed area is not opaque.

The tabbed area's background is normally only visible behind the tabs, since the container holding the tab contents is opaque by default.

Parameters
opaqueTrue if the tabbed area should be opaque, false otherwise.
See also
isOpaque

Definition at line 193 of file tabbedarea.cpp.

References mOpaque, and setOpaque().

Referenced by setOpaque().

◆ setSelectedTab() [1/2]

void fcn::TabbedArea::setSelectedTab ( Tab * tab)
virtual

Sets a tab to be selected or not.

Parameters
tabThe tab to be selected.
See also
isTabSelected, getSelectedTab

Definition at line 145 of file tabbedarea.cpp.

References fcn::Widget::adaptLayout(), mSelectedTab, mTabs, mWidgetContainer, and setSelectedTab().

◆ setSelectedTab() [2/2]

void fcn::TabbedArea::setSelectedTab ( unsigned int index)
virtual

Sets a tab given an index to be selected.

Parameters
indexThe index of the tab to be selected.
See also
isTabSelected, getSelectedTab

Definition at line 136 of file tabbedarea.cpp.

References mTabs, setSelectedTab(), and fcn::throwException().

Referenced by action(), addTab(), keyPressed(), mousePressed(), removeTab(), setSelectedTab(), and setSelectedTab().

◆ setSize()

void fcn::TabbedArea::setSize ( int width,
int height )
overridevirtual

Set the size (width and height) of the tabbed area in pixels.

Reimplemented from fcn::Widget.

Definition at line 362 of file tabbedarea.cpp.

References adjustSize(), fcn::Widget::mDimension, setSize(), and fcn::Widget::setSize().

Referenced by setSize().

◆ setUniformSize()

void fcn::TabbedArea::setUniformSize ( bool uniform)
virtual

Enables or disables uniform sizing of child elements.

When enabled, available space is distributed so that all children have equal size, if possible. When disabled, free space is distributed evenly without enforcing equal sizes.

Parameters
uniformTrue to enforce uniform child sizes; false otherwise.
See also
isUniformSize()

Definition at line 486 of file tabbedarea.cpp.

References mTabContainer, and setUniformSize().

Referenced by setUniformSize().

◆ setVerticalSpacing()

void fcn::TabbedArea::setVerticalSpacing ( unsigned int spacing)
virtual

Set the vertical spacing between rows.

Parameters
spacingspacing in pixels.
See also
getVerticalSpacing

Definition at line 496 of file tabbedarea.cpp.

References mTabContainer, and setVerticalSpacing().

Referenced by setVerticalSpacing().

◆ setWidth()

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

Set the width of the tabbed area in pixels.

Reimplemented from fcn::Widget.

Definition at line 338 of file tabbedarea.cpp.

References adjustSize(), fcn::Widget::mDimension, setWidth(), and fcn::Widget::setWidth().

Referenced by setWidth().

◆ Tab

friend class Tab
friend

Definition at line 38 of file tabbedarea.hpp.

Member Data Documentation

◆ mOpaque

bool fcn::TabbedArea::mOpaque {false}
protected

True if the tabbed area is opaque, false otherwise.

Definition at line 321 of file tabbedarea.hpp.

Referenced by isOpaque(), and setOpaque().

◆ mSelectedTab

Tab* fcn::TabbedArea::mSelectedTab {nullptr}
protected

Holds the selected tab.

Definition at line 293 of file tabbedarea.hpp.

Referenced by addTab(), draw(), getSelectedTab(), getSelectedTabIndex(), isTabSelected(), isTabSelected(), removeTab(), and setSelectedTab().

◆ mTabContainer

◆ mTabs

std::vector<std::pair<Tab*, Widget*> > fcn::TabbedArea::mTabs
protected

Associates each tab with the widget displayed when it is selected.

Definition at line 316 of file tabbedarea.hpp.

Referenced by addTab(), adjustSize(), adjustTabPositions(), getNumberOfTabs(), getSelectedTabIndex(), isTabSelected(), keyPressed(), removeTab(), removeTabWithIndex(), setBaseColor(), setSelectedTab(), and setSelectedTab().

◆ mTabsToDelete

std::vector<std::unique_ptr<Tab> > fcn::TabbedArea::mTabsToDelete
protected

Stores tabs owned by this instance for automatic destruction.

Contains tabs that were created internally by the tabbed area and must be deleted in the destructor.

Definition at line 311 of file tabbedarea.hpp.

Referenced by removeTab().

◆ mWidgetContainer

Container* fcn::TabbedArea::mWidgetContainer
protected

Holds the container for the widgets.

Definition at line 303 of file tabbedarea.hpp.

Referenced by adjustSize(), expandContent(), removeTab(), resizeToContent(), setBackgroundWidget(), setBaseColor(), and setSelectedTab().


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