Gorgon Game Engine
RadioButtons< T_, W_ > Class Template Reference

Allows the use of radio buttons working together. More...

Inheritance diagram for RadioButtons< T_, W_ >:
[legend]

Public Member Functions

 RadioButtons (const UI::Template &temp)
 
 RadioButtons (Registry::TemplateType type=Registry::Radio_Regular)
 
virtual bool Activate () override
 Activates the widget. More...
 
void Add (const T_ value)
 
void Add (const T_ value, std::string text)
 
void ChangeValue (const T_ &before, const T_ &after)
 Changes the value of the given element. More...
 
void Disable (const T_ &value)
 Disables the given element. More...
 
void Enable (const T_ &value)
 Enables the given element. More...
 
bool EnsureVisible (const UI::Widget &) override
 Ensures the widget is visible. More...
 
Geometry::Size GetInteriorSize () const override
 Should return the interior (usable) size of the container. More...
 
Geometry::Point GetLocation () const override
 Returns the location of the widget. More...
 
Geometry::Size GetSize () const override
 Returns the size of the widget. More...
 
virtual bool IsEnabled () const override
 Returns whether the widget is enabled. More...
 
bool IsEnabled (const T_ &value) const
 Returns if given element is enabled. More...
 
bool IsVisible () const override
 Should return whether the container is visible. More...
 
bool KeyEvent (Input::Key key, float state) override
 This function should be called whenever a key is pressed or released. More...
 
void Move (const Geometry::Point &location) override
 Moves this widget to the given position. More...
 
RadioButtonsoperator= (const T_ value)
 Assigns a new value to the radio control. More...
 
virtual void Resize (const Geometry::Size &size) override
 Radio buttons height is automatically adjusted. Only width will be used. More...
 
bool ResizeInterior (Geometry::Size size) override
 Should resize the interior (usable) size of the container. More...
 
void SetColumns (int value)
 Changes the number of columns. More...
 
virtual void SetEnabled (bool value) override
 Sets the enabled state of the widget. More...
 
void SetEnabled (const T_ &value, bool state)
 Sets the enabled state the given element. More...
 
void SetSpacing (int value)
 
void ToggleEnabled (const T_ &value)
 Toggles enabled state of the given element. More...
 
- Public Member Functions inherited from Widget
 Widget ()
 
 Widget (Widget &&)=default
 
virtual ~Widget ()
 
bool AllowFocus () const
 If this widget can be focused currently. More...
 
virtual bool CharacterEvent (Char)
 This function should be called whenever a character is received from operating system. More...
 
bool Defocus ()
 Removes the focus from this widget if this widget is focused. More...
 
void Disable ()
 Disables the widget so that the user cannot interact with it. More...
 
virtual bool Done ()
 For widgets that supports it, this will trigger finalization the user interaction. More...
 
void Enable ()
 Enables the widget so that the user can interact with it. More...
 
bool EnsureVisible () const
 Ensures this widget is visible in its container by scrolling it into view. More...
 
bool Focus ()
 Transfers the focus to this widget. More...
 
Geometry::Bounds GetBounds () const
 Returns the bounds of the widget. More...
 
int GetHeight () const
 Returns the height of the widget. More...
 
WidgetContainerGetParent () const
 Returns the parent of this widget, throws if it does not have a parent. More...
 
int GetWidth () const
 Returns the width of the widget. More...
 
bool HasParent () const
 Returns if this widget has a parent. More...
 
void Hide ()
 Hides this widget, when hidden, widgets cannot gain focus. More...
 
bool IsFloating () const
 Returns floating status of this widget. More...
 
bool IsFocused () const
 Returns if this widget is focused. More...
 
bool IsVisible () const
 Returns if the widget is visible. More...
 
void Move (int x, int y)
 Moves this widget to the given position. More...
 
bool Remove ()
 Removes the widget from its parent. More...
 
virtual void Resize (int w, int h)
 Changes the size of the widget. More...
 
void SetHeight (int height)
 Sets the height of the widget. More...
 
virtual void SetIsFloating (bool value)
 Sets floating status of this widget. More...
 
void setname (std::string value)
 This is a debug feature. More...
 
void SetVisible (bool value)
 Changes the visibility of the widget. More...
 
void SetWidth (int width)
 Sets the width of the widget. More...
 
void Show ()
 Shows this widget, widgets are visible by default. More...
 
void ToggleEnabled ()
 Toggles enabled state of the widget. More...
 
void ToggleVisible ()
 Toggles the visibility state of the widget. More...
 

Protected Member Functions

virtual bool addingwidget (Widget &widget) override
 
virtual void addto (Layer &layer) override
 When called, widget should locate itself on to this layer. More...
 
virtual bool allowfocus () const override
 Should return true if the widget can be focused. More...
 
virtual void focused () override
 This is called after the focus is transferred to this widget. More...
 
Gorgon::Layergetlayer () override
 Returns the layer that will be used to place the contained widgets. More...
 
virtual void parentenabledchanged (bool state) override
 This function is called when the parent's enabled state changes. More...
 
void rearrange ()
 
virtual void removefrom (Layer &layer) override
 When called, widget should remove itself from the given layer. More...
 
virtual bool removingwidget (Widget &) override
 
UI::ExtenderRequestResponse RequestExtender (const Layer &self) override
 This function will return a container that will act as an extender. More...
 
virtual void setlayerorder (Layer &, int order) override
 When called, widget should reorder itself in layer hierarchy. More...
 
- Protected Member Functions inherited from Widget
virtual void addedto (WidgetContainer &container)
 Called when this widget added to the given container. More...
 
virtual bool addingto (WidgetContainer &)
 Called when it is about to be added to the given container. More...
 
virtual void boundschanged ()
 Call this function when the widget bounds is changed. More...
 
virtual bool canloosefocus () const
 Should return true if the widget can loose the focus right now. More...
 
virtual void displaced ()
 Call this function when the widget container causes it to be displaced. More...
 
virtual void removed ()
 Called after this widget is removed from its parent. More...
 
virtual bool removingfrom ()
 Called before this widget is removed from its parent. More...
 
- Protected Member Functions inherited from RadioControl< T_, Checkbox >
void changing (TwoStateControl &control, bool state, bool &allow)
 
void clearall ()
 
virtual void elementadded (const T_ &index)
 
 RadioControl ()
 Default constructor. Use filling constructor if possible. More...
 
 RadioControl (const RadioControl &)=delete
 No copying. More...
 
 RadioControl (std::initializer_list< std::pair< const T_, Checkbox & >> elm, T_ current=T_())
 Filling constructor that prepares RadioControl from the start. More...
 
 RadioControl (std::initializer_list< std::pair< const T_, Checkbox * >> elm, T_ current=T_())
 Filling constructor that prepares RadioControl from the start. More...
 
virtual ~RadioControl ()
 
void Add (const T_ value, Checkbox &control)
 Adds the given element to this controller. More...
 
auto begin ()
 For iteration. More...
 
auto begin () const
 For iteration. More...
 
void ChangeValue (const T_ &before, const T_ &after)
 Changes the value of the given element. More...
 
auto end ()
 For iteration. More...
 
auto end () const
 For iteration. More...
 
bool Exists (const T_ value) const
 Returns if the given element exists. More...
 
T_ Get () const
 Returns the current value. More...
 
int GetColumns () const
 Returns the number of columns when placing the widgets. More...
 
 operator T_ () const
 Returns the current value. More...
 
RadioControloperator= (const T_ value)
 Assigns a new value to the radio control. More...
 
void PlaceIn (C_ &container, Geometry::Point start, int spacing)
 This function will add all widgets in this controller to the given container. More...
 
bool Set (const T_ value)
 Assigns a new value to the radio control. More...
 
void SetColumns (int value)
 Changes the number of columns when placing the widgets. More...
 
- Protected Member Functions inherited from WidgetContainer
virtual bool addingwidget (Widget &)
 This function can return false to prevent the given widget from getting added to the container. More...
 
virtual void childboundschanged (Widget *source)
 The boundary of any of the children is changed. Source could be nullptr. More...
 
bool distributecharevent (Char c)
 Distributes a pressed character to the focused widget. More...
 
bool distributekeyevent (Input::Key key, float state, bool handlestandard)
 Distributes the pressed key to the focused widget. More...
 
void distributeparentenabled (bool state)
 Distributes a enabled state to children. More...
 
bool handlestandardkey (Input::Key key)
 Performs the standard operations (tab/enter/escape) More...
 
virtual bool removingwidget (Widget &)
 This function is called before removing a widget. More...
 
virtual void widgetadded (Widget &)
 This function is called after a widget is added. More...
 
virtual void widgetremoved (Widget &)
 This function is called after a widget is removed. More...
 
 WidgetContainer ()=default
 
 WidgetContainer (WidgetContainer &&)=default
 
virtual ~WidgetContainer ()
 Virtual destructor. More...
 
bool Add (Widget &widget)
 Adds the given widget to this container. More...
 
void AttachOrganizer (Organizers::Base &organizer)
 Attaches an organizer to this container. More...
 
auto begin ()
 Returns the begin iterator for the contained widgets. More...
 
auto begin () const
 Returns the begin iterator for the contained widgets. More...
 
void ChangeFocusOrder (Widget &widget, int order)
 Changes the focus order of the given widget. More...
 
void ChangeZorder (Widget &widget, int order)
 Changes the z-order of the widget. More...
 
virtual bool CharacterEvent (Char c)
 This function should be called whenever a character is received from operating system. More...
 
template<class O_ , class ... Args_>
O_ & CreateOrganizer (Args_ &&... args)
 Creates a new organizer that lives with this container. More...
 
FocusStrategy CurrentFocusStrategy () const
 Returns the active focus strategy. This function will not return Inherit. More...
 
void Disable ()
 Disables the container, disallowing interactions of all widgets in it. More...
 
void DisableTabSwitch ()
 Disable tab switching. More...
 
void Displaced ()
 Call this function if the container or widgets in it is moved without move function is called. More...
 
void Enable ()
 Enables the container, allowing interaction with the widgets in it. More...
 
void EnableTabSwitch ()
 Enable tab switching. More...
 
auto end ()
 Returns the end iterator for the contained widgets. More...
 
auto end () const
 Returns the end iterator for the contained widgets. More...
 
bool FocusFirst ()
 Focuses the first widget that accepts focus. More...
 
bool FocusLast ()
 Focuses the last widget in the container. More...
 
bool FocusNext ()
 Focuses the next widget that accepts focus. More...
 
bool FocusNext (const Widget &widget)
 Focuses the next widget that accepts focus starting from the given focus index. More...
 
bool FocusNext (int after)
 Focuses the next widget that accepts focus starting from the given focus index. More...
 
bool FocusPrevious ()
 Focuses the previous widget that accepts focus. More...
 
bool FocusPrevious (const Widget &widget)
 Focuses the previous widget that accepts focus. More...
 
bool FocusPrevious (int before)
 Focuses the previous widget that accepts focus. More...
 
void ForceRemove (Widget &widget)
 Forcefully removes the given widget from this container. More...
 
void ForceRemoveFocus ()
 Forcefully removes the focus from the focused widget. More...
 
virtual WidgetGetCancel () const
 Returns the cancel element of the container which is called when the use presses escape key. More...
 
int GetCount () const
 Returns the number of widgets in this container. More...
 
virtual WidgetGetDefault () const
 Returns the default element of the container. More...
 
WidgetGetFocus () const
 Returns the focused widget. More...
 
int GetFocusOrder (const Widget &widget) const
 
FocusStrategy GetFocusStrategy () const
 Returns the focus strategy set to this container. More...
 
Organizers::BaseGetOrganizer () const
 Returns the organizer controlling this container. More...
 
virtual bool HasCancel () const
 Returns if this container has a cancel widget. More...
 
virtual bool HasDefault () const
 Returns if this container has a default object. More...
 
bool HasFocusedWidget () const
 Returns if this container has a focused widget. More...
 
bool HasOrganizer () const
 Returns if this container has an organizer. More...
 
bool Insert (Widget &widget, int index)
 Add the given widget to this container. More...
 
virtual bool IsTabSwitchEnabled () const
 Check if tab switch is enabled. More...
 
WidgetContaineroperator= (WidgetContainer &&)=default
 
Widgetoperator[] (int ind)
 Returns the widget at the given index. More...
 
const Widgetoperator[] (int ind) const
 Returns the widget at the given index. More...
 
bool Remove (Widget &widget)
 Removes the given widget from this container. More...
 
virtual void RemoveCancel ()
 Removes the cancel widget of this container. More...
 
virtual void RemoveDefault ()
 Removes the default widget of this container. More...
 
bool RemoveFocus ()
 Removes the focus from the focused widget. More...
 
void RemoveOrganizer ()
 Removes the organizer from this container. More...
 
virtual void SetCancel (Widget &widget)
 Sets the cancel widget of the container. More...
 
virtual void SetDefault (Widget &widget)
 Sets the default object of the container. More...
 
void SetFocusStrategy (FocusStrategy value)
 Sets the focus strategy, see FocusStrategy. More...
 
bool SetFocusTo (Widget &widget)
 Sets the focus to the given widget. More...
 
virtual void SetTabSwitchEnabledState (bool state)
 Sets the state of tab switching. More...
 
void ToggleEnabled ()
 Toggles the enabled state of this container. More...
 
void ToggleTabSwitchEnabledState ()
 Toggles the state of tab switching. More...
 

Protected Attributes

bool enabled
 
Geometry::Point location
 
int spacing
 
const UI::Templatetemp
 
- Protected Attributes inherited from RadioControl< T_, Checkbox >
int columns
 
T_ current
 
Containers::Hashmap< T_, Checkbox > elements
 
bool own
 
std::map< Checkbox *, T_ > reverse
 
Event< RadioControl, T_ > ChangedEvent
 
- Protected Attributes inherited from WidgetContainer
Containers::Collection< Widgetwidgets
 This container is sorted by the focus order. More...
 

Additional Inherited Members

- Public Attributes inherited from Widget
Event< WidgetBoundsChangedEvent
 This event will be fired when the area that the widget occupies on its container is changed. More...
 
std::string dbgname
 
Event< WidgetFocusEvent
 This event will be fired when the widget receives or looses focus. More...
 
Geometry::PointProperty< Widget, &Widget::getlocation, &Widget::move > Location
 
Geometry::SizeProperty< Widget, &Widget::getsize, &Widget::resize > Size
 
- Protected Types inherited from WidgetContainer
enum  FocusStrategy {
  Inherit, AllowAll, Selective, Strict,
  Deny
}
 Defines focus strategy for the container. Default is Inherit. More...
 

Detailed Description

template<class T_, class W_ = Checkbox>
class Gorgon::Widgets::RadioButtons< T_, W_ >

Allows the use of radio buttons working together.

This widget acts as a container for checkboxes that work together. Manually adding/removing widgets will fail. Attaching an organizer to this widget might cause unexpected behavior. All other container functionality should work as intended.

Constructor & Destructor Documentation

◆ RadioButtons() [1/2]

◆ RadioButtons() [2/2]

Member Function Documentation

◆ Activate()

virtual bool Activate ( )
overridevirtual

Activates the widget.

This might perform the action if the widget is a button, forward the focus if it is a label or focus if it is an input field.

Implements Widget.

◆ Add() [1/2]

void Add ( const T_  value)

◆ Add() [2/2]

◆ addingwidget()

virtual bool addingwidget ( Widget widget)
overrideprotectedvirtual

◆ addto()

virtual void addto ( Layer layer)
overrideprotectedvirtual

When called, widget should locate itself on to this layer.

Implements Widget.

References Layer::Add().

◆ allowfocus()

virtual bool allowfocus ( ) const
overrideprotectedvirtual

Should return true if the widget can be focused.

Reimplemented from Widget.

References WidgetContainer::AllowAll, WidgetContainer::CurrentFocusStrategy(), Widget::GetParent(), and Widget::HasParent().

◆ ChangeValue()

◆ Disable()

void Disable ( const T_ &  value)

Disables the given element.

References RadioButtons< T_, W_ >::SetEnabled().

◆ Enable()

void Enable ( const T_ &  value)

Enables the given element.

References RadioButtons< T_, W_ >::SetEnabled().

◆ EnsureVisible()

bool EnsureVisible ( const UI::Widget widget)
overridevirtual

Ensures the widget is visible.

Returns true if the container can be scroll to make sure the given widget is visible. This function cannot be expected to take outside factors into account, such as occlusion. This function does not change the visibility of the widget and will return false if the widget is not visible.

Implements WidgetContainer.

References Widget::EnsureVisible().

◆ focused()

virtual void focused ( )
overrideprotectedvirtual

This is called after the focus is transferred to this widget.

Reimplemented from Widget.

References WidgetContainer::FocusFirst(), and WidgetContainer::HasFocusedWidget().

◆ GetInteriorSize()

Geometry::Size GetInteriorSize ( ) const
overridevirtual

Should return the interior (usable) size of the container.

Implements WidgetContainer.

References RadioButtons< T_, W_ >::GetSize().

◆ getlayer()

Gorgon::Layer& getlayer ( )
overrideprotectedvirtual

Returns the layer that will be used to place the contained widgets.

Implements WidgetContainer.

◆ GetLocation()

Geometry::Point GetLocation ( ) const
overridevirtual

Returns the location of the widget.

Implements Widget.

References Layer::GetLocation().

◆ GetSize()

Geometry::Size GetSize ( ) const
overridevirtual

Returns the size of the widget.

Implements Widget.

References Layer::GetSize().

◆ IsEnabled() [1/2]

virtual bool IsEnabled ( ) const
overridevirtual

Returns whether the widget is enabled.

Implements Widget.

References RadioButtons< T_, W_ >::enabled.

◆ IsEnabled() [2/2]

bool IsEnabled ( const T_ &  value) const

Returns if given element is enabled.

Returns false if the element is not found.

References RadioControl< T_, Checkbox >::elements.

◆ IsVisible()

bool IsVisible ( ) const
overridevirtual

Should return whether the container is visible.

Due to different container designs and capabilities, setting visibility depends on the particular container

Implements WidgetContainer.

References Layer::IsVisible().

◆ KeyEvent()

bool KeyEvent ( Input::Key  ,
float   
)
overridevirtual

This function should be called whenever a key is pressed or released.

Reimplemented from Widget.

References WidgetContainer::KeyEvent().

◆ Move()

void Move ( const Geometry::Point location)
overridevirtual

Moves this widget to the given position.

Implements Widget.

References RadioButtons< T_, W_ >::location, and Layer::Move().

◆ operator=()

RadioButtons& operator= ( const T_  value)

Assigns a new value to the radio control.

If the specified value exists in the, it will be selected, if not, nothing will be selected.

References RadioControl< T_, Checkbox >::Set().

◆ parentenabledchanged()

virtual void parentenabledchanged ( bool  state)
overrideprotectedvirtual

This function is called when the parent's enabled state changes.

Reimplemented from Widget.

References WidgetContainer::distributeparentenabled(), and RadioButtons< T_, W_ >::IsEnabled().

◆ rearrange()

◆ removefrom()

virtual void removefrom ( Layer layer)
overrideprotectedvirtual

When called, widget should remove itself from the given layer.

Implements Widget.

References Layer::Remove().

◆ removingwidget()

virtual bool removingwidget ( Widget )
overrideprotectedvirtual

◆ RequestExtender()

UI::ExtenderRequestResponse RequestExtender ( const Layer self)
overrideprotectedvirtual

◆ Resize()

virtual void Resize ( const Geometry::Size size)
overridevirtual

◆ ResizeInterior()

bool ResizeInterior ( Geometry::Size  size)
overridevirtual

Should resize the interior (usable) size of the container.

If resize operation cannot set the size exactly to the requested size, this function returns false.

Implements WidgetContainer.

References RadioButtons< T_, W_ >::GetSize(), and RadioButtons< T_, W_ >::Resize().

◆ SetColumns()

void SetColumns ( int  value)

Changes the number of columns.

References RadioButtons< T_, W_ >::rearrange(), and RadioControl< T_, CT_ >::SetColumns().

◆ SetEnabled() [1/2]

virtual void SetEnabled ( bool  value)
overridevirtual

◆ SetEnabled() [2/2]

void SetEnabled ( const T_ &  value,
bool  state 
)

Sets the enabled state the given element.

References RadioControl< T_, Checkbox >::elements.

◆ setlayerorder()

virtual void setlayerorder ( Layer layer,
int  order 
)
overrideprotectedvirtual

When called, widget should reorder itself in layer hierarchy.

Implements Widget.

References Layer::PlaceBefore().

◆ SetSpacing()

void SetSpacing ( int  value)

◆ ToggleEnabled()

void ToggleEnabled ( const T_ &  value)

Toggles enabled state of the given element.

References RadioButtons< T_, W_ >::IsEnabled(), and RadioButtons< T_, W_ >::SetEnabled().

Member Data Documentation

◆ enabled

bool enabled
protected

◆ location

Geometry::Point location
protected

◆ spacing

int spacing
protected

◆ temp

const UI::Template& temp
protected

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