lecui 1.0.0-alpha.20
lecui C++ user interface library
Public Types | Public Member Functions | Static Public Member Functions | List of all members
liblec::lecui::widgets::icon Class Reference

Icon widget. To instantiate and add to a container use the add static method. More...

#include <icon.h>

Inheritance diagram for liblec::lecui::widgets::icon:
liblec::lecui::widgets::widget liblec::lecui::widgets::badge_widget

Public Types

enum class  icon_text_position { right , left , top , bottom }
 Text position in icon. More...
 
- Public Types inherited from liblec::lecui::widgets::widget
enum class  cursor_type { arrow , hand , caret }
 Mouse cursor type. More...
 

Public Member Functions

 icon ()
 Constructor.
 
bool operator== (const icon &param)
 Check whether widget specs are equal. Only those properties that require the widget resources to be re-created are considered. More...
 
bool operator!= (const icon &param)
 Check whether widget specs are NOT equal. Only those properties that require the widget resources to be re-created are considered. More...
 
std::string & text () override
 Get or set the widget text. More...
 
icontext (const std::string &text)
 Set the widget's text. More...
 
std::string & tooltip () override
 Get or set the widget's tooltip text. More...
 
icontooltip (const std::string &tooltip)
 Set the tooltip text. More...
 
badge_specsbadge () override
 Get or set the badge specs. More...
 
iconbadge (const badge_specs &badge)
 Set the badge specs. More...
 
lecui::rectrect () override
 Get or set the position and dimensions of the widget. More...
 
iconrect (const lecui::rect &rect)
 Set the position and dimensions of the widget. More...
 
resize_paramson_resize () override
 Get or set the behaviour of the widget when its container is resized. More...
 
iconon_resize (const resize_params &on_resize)
 Set the behaviour of the widget when its container is resized. More...
 
cursor_typecursor () override
 Get or set the mouse cursor to use then over the widget. More...
 
iconcursor (const cursor_type cursor)
 Set the mouse cursor to use when over the widget. More...
 
std::string & font () override
 Get or set the default widget font, e.g. "Georgia". More...
 
iconfont (const std::string &font)
 Set the default widget font. More...
 
float & font_size () override
 Get or set the default widget font size in points, e.g. 9.0f. More...
 
iconfont_size (const float &font_size)
 Set the widget's font size. More...
 
colorcolor_text () override
 Get or set the color of the widget's text. More...
 
iconcolor_text (const color &color_text)
 Set the color of the widget's text. More...
 
colorcolor_fill () override
 Get or set the fill color of the widget. More...
 
iconcolor_fill (const color &color_fill)
 Set the fill color of the widget. More...
 
colorcolor_hot () override
 Get or set the widget's color when the mouse is hovered over it. More...
 
iconcolor_hot (const color &color_hot)
 Set the widget's color when the mouse is hovered over it. More...
 
colorcolor_selected () override
 Get or set the widget's color when selected. More...
 
iconcolor_selected (const color &color_selected)
 Set the widget's color when selected. More...
 
colorcolor_disabled () override
 Get or set the widget's color when it is disabled. More...
 
iconcolor_disabled (const color &color_disabled)
 Set the widget's color when it is disabled. More...
 
float & border ()
 Get or set the thickness of the border. More...
 
iconborder (const float &border)
 Set the thickness of the border. More...
 
colorcolor_border ()
 Get or set the color of the border. More...
 
iconcolor_border (const color &color_border)
 Set the color of the border. More...
 
float & corner_radius_x ()
 Get or set the horizontal radius of the corners. More...
 
iconcorner_radius_x (const float &corner_radius_x)
 Set the horizontal radius of the corners. More...
 
float & corner_radius_y ()
 Get or set the vertical radius of the corners. More...
 
iconcorner_radius_y (const float &corner_radius_y)
 Set the vertical radius of the corners. More...
 
float & max_image_size ()
 Get or set the maximum size of the image square's side. More...
 
iconmax_image_size (const float &max_image_size)
 Set the maximum size of the image square's side. More...
 
colorcolor_text_description ()
 Get or set the color of the description text. More...
 
iconcolor_text_description (const color &color_text_description)
 Set the color of the description text. More...
 
float & font_size_description ()
 Get or set the size of the description text. More...
 
iconfont_size_description (const float &font_size_description)
 Set the size of the description text. More...
 
int & png_resource ()
 Get or set the icon's PNG resource. More...
 
iconpng_resource (const int &png_resource)
 Set the icon's PNG resource. More...
 
std::string & file ()
 Get or set the path to the icon's image file. More...
 
iconfile (const std::string &file)
 Set the path to the icon's image file. More...
 
image_qualityquality ()
 Get or set the quality of the image in the icon. More...
 
iconquality (const image_quality &quality)
 Set the quality of the image in the icon. More...
 
std::string & description ()
 Get or set the description text. More...
 
icondescription (const std::string &description)
 Set the description text. More...
 
icon_text_positiontext_position ()
 Get or set the position of the text. More...
 
icontext_position (const icon_text_position &text_position)
 Set the position of the text. More...
 
float & gap ()
 Get or set the gap between the text and the image and the text. More...
 
icongap (const float &gap)
 Set the gap between the text and the image and the text. More...
 
float & padding ()
 Get or set the padding to use around the icon. More...
 
iconpadding (const float &padding)
 Set the padding to use around the icon. More...
 
float & opacity ()
 Get or set the opacity of the image. More...
 
iconopacity (const float &opacity)
 Set the opacity of the image. More...
 
- Public Member Functions inherited from liblec::lecui::widgets::widget
 widget ()
 Widget constructor.
 
virtual ~widget ()
 Widget descructor.
 
bool operator== (const widget &param)
 Check whether widget's basic specifications are equal. Only those properties that require the widget's basic resources to be re-created are considered. More...
 
bool operator!= (const widget &param)
 Check whether widget's basic specifications are NOT equal. Only those properties that require the widget's basic resources to be re-created are considered. More...
 
virtual std::string & text ()=0
 Get or set the widget text. More...
 
virtual std::string & tooltip ()=0
 Get or set the widget's tooltip text. More...
 
virtual lecui::rectrect ()=0
 Get or set the position and dimensions of the widget. More...
 
virtual resize_paramson_resize ()=0
 Get or set the behaviour of the widget when its container is resized. More...
 
virtual cursor_typecursor ()=0
 Get or set the mouse cursor to use then over the widget. More...
 
virtual std::string & font ()=0
 Get or set the default widget font, e.g. "Georgia". More...
 
virtual float & font_size ()=0
 Get or set the default widget font size in points, e.g. 9.0f. More...
 
virtual colorcolor_text ()=0
 Get or set the color of the widget's text. More...
 
virtual colorcolor_fill ()=0
 Get or set the fill color of the widget. More...
 
virtual colorcolor_hot ()=0
 Get or set the widget's color when the mouse is hovered over it. More...
 
virtual colorcolor_selected ()=0
 Get or set the widget's color when selected. More...
 
virtual colorcolor_disabled ()=0
 Get or set the widget's color when it's disabled. More...
 
basic_eventsevents ()
 Widget events. More...
 
const std::string & alias ()
 The widget's alias, either user defined or automatically generated by the library. More...
 
- Public Member Functions inherited from liblec::lecui::widgets::badge_widget
bool operator== (const badge_widget &param)
 Check whether two badges are equal. Only those badge properties that require the badge's resources to be re-created are considered. More...
 
bool operator!= (const badge_widget &param)
 Check whether two badges are NOT equal. Only those badge properties that require the badge's resources to be re-created are considered. More...
 
virtual badge_specsbadge ()=0
 Get or set the widget's badge. More...
 

Static Public Member Functions

static iconadd (containers::page &page, const std::string &alias=std::string())
 Add an icon to a container. More...
 
static iconget (form &fm, const std::string &path)
 Get the specifications of an icon. More...
 

Additional Inherited Members

- Protected Attributes inherited from liblec::lecui::widgets::widget
std::string _text
 The widget's text.
 
std::string _tooltip
 The widget's tooltip text.
 
lecui::rect _rect
 The widget's rectangle.
 
resize_params _on_resize = { 0.f, 0.f, 0.f, 0.f }
 The widget's behaviour when container is resized.
 
cursor_type _cursor = cursor_type::arrow
 The widget's cursor.
 
std::string _font = "Segoe UI"
 The widget's font.
 
float _font_size = 9.f
 The widget's font size.
 
color _color_text = { 0, 0, 0, 255 }
 The color of the widget's text.
 
color _color_fill = { 0, 120, 170, 255 }
 The fill color of the widget.
 
color _color_hot = { 0, 120, 170, 255 }
 The color to indicate when the mouse hovers over the widget.
 
color _color_selected = { 0, 120, 170, 30 }
 The color to indicate when the widget is selected.
 
color _color_disabled = { 180, 180, 180, 255 }
 The color to indicate when the widget is disabled.
 
- Protected Attributes inherited from liblec::lecui::widgets::badge_widget
badge_specs _badge
 The badge's specs.
 

Detailed Description

Icon widget. To instantiate and add to a container use the add static method.

Recommended size with defaults is 180x58px.

Member Enumeration Documentation

◆ icon_text_position

Text position in icon.

Enumerator
right 

Place the text to the right.

left 

Place the text to the left.

top 

Place the text at the top.

bottom 

Place the text at the bottom.

Member Function Documentation

◆ add()

static icon & liblec::lecui::widgets::icon::add ( containers::page page,
const std::string &  alias = std::string() 
)
static

Add an icon to a container.

Parameters
pageThe container to place the widget in.
aliasThe in-page unique alias, e.g. "users".
Returns
A reference to the widget specifications.

If an empty alias is given an internally generated random alias will be assigned.

◆ badge() [1/2]

badge_specs & liblec::lecui::widgets::icon::badge ( )
overridevirtual

Get or set the badge specs.

Returns
A reference to the badge specs.

Implements liblec::lecui::widgets::badge_widget.

◆ badge() [2/2]

icon & liblec::lecui::widgets::icon::badge ( const badge_specs badge)

Set the badge specs.

Parameters
badgeThe badge specs.
Returns
A reference to the modified object.

◆ border() [1/2]

float & liblec::lecui::widgets::icon::border ( )

Get or set the thickness of the border.

Returns
A reference to the border thickness, in pixels.

◆ border() [2/2]

icon & liblec::lecui::widgets::icon::border ( const float &  border)

Set the thickness of the border.

Parameters
borderThe border thickness, in pixels.
Returns
A reference to the modified object.

◆ color_border() [1/2]

color & liblec::lecui::widgets::icon::color_border ( )

Get or set the color of the border.

Returns
A reference to the border color, as defined in color.

◆ color_border() [2/2]

icon & liblec::lecui::widgets::icon::color_border ( const color color_border)

Set the color of the border.

Parameters
color_borderThe border color, as defined in color.
Returns
A reference to the modified object.

◆ color_disabled() [1/2]

color & liblec::lecui::widgets::icon::color_disabled ( )
overridevirtual

Get or set the widget's color when it is disabled.

Returns
a reference to the property.

Implements liblec::lecui::widgets::widget.

◆ color_disabled() [2/2]

icon & liblec::lecui::widgets::icon::color_disabled ( const color color_disabled)

Set the widget's color when it is disabled.

Parameters
color_disabledThe color of the widget when it is disabled, as defined in color.
Returns
A reference to the modified object.

◆ color_fill() [1/2]

color & liblec::lecui::widgets::icon::color_fill ( )
overridevirtual

Get or set the fill color of the widget.

Returns
A reference to the widget's fill color.

Implements liblec::lecui::widgets::widget.

◆ color_fill() [2/2]

icon & liblec::lecui::widgets::icon::color_fill ( const color color_fill)

Set the fill color of the widget.

Parameters
color_fillThe fill color.
Returns
A reference to the modified object.

◆ color_hot() [1/2]

color & liblec::lecui::widgets::icon::color_hot ( )
overridevirtual

Get or set the widget's color when the mouse is hovered over it.

Returns
A reference to the widget's hover color.

Implements liblec::lecui::widgets::widget.

◆ color_hot() [2/2]

icon & liblec::lecui::widgets::icon::color_hot ( const color color_hot)

Set the widget's color when the mouse is hovered over it.

Parameters
color_hotThe color.
Returns
A reference to the modified object.

◆ color_selected() [1/2]

color & liblec::lecui::widgets::icon::color_selected ( )
overridevirtual

Get or set the widget's color when selected.

Returns
A reference to the widget's color when selected.

Implements liblec::lecui::widgets::widget.

◆ color_selected() [2/2]

icon & liblec::lecui::widgets::icon::color_selected ( const color color_selected)

Set the widget's color when selected.

Parameters
color_selectedThe widget's color when selected.
Returns
A reference to the modified object.

◆ color_text() [1/2]

color & liblec::lecui::widgets::icon::color_text ( )
overridevirtual

Get or set the color of the widget's text.

Returns
A reference to the widget's text color.

Implements liblec::lecui::widgets::widget.

◆ color_text() [2/2]

icon & liblec::lecui::widgets::icon::color_text ( const color color_text)

Set the color of the widget's text.

Parameters
color_textThe color of the widget's text.
Returns
A reference to the modified object.

◆ color_text_description() [1/2]

color & liblec::lecui::widgets::icon::color_text_description ( )

Get or set the color of the description text.

Returns
A reference to the color.

◆ color_text_description() [2/2]

icon & liblec::lecui::widgets::icon::color_text_description ( const color color_text_description)

Set the color of the description text.

Parameters
color_text_descriptionThe color, as defined in color.
Returns
A reference to the modified object.

◆ corner_radius_x() [1/2]

float & liblec::lecui::widgets::icon::corner_radius_x ( )

Get or set the horizontal radius of the corners.

Returns
A reference to the radius, in pixels.

◆ corner_radius_x() [2/2]

icon & liblec::lecui::widgets::icon::corner_radius_x ( const float &  corner_radius_x)

Set the horizontal radius of the corners.

Parameters
corner_radius_xThe horizontal radius of the corner, in pixels.
Returns
A reference to the modified object.

◆ corner_radius_y() [1/2]

float & liblec::lecui::widgets::icon::corner_radius_y ( )

Get or set the vertical radius of the corners.

Returns
A reference to the radius, in pixels.

◆ corner_radius_y() [2/2]

icon & liblec::lecui::widgets::icon::corner_radius_y ( const float &  corner_radius_y)

Set the vertical radius of the corners.

Parameters
corner_radius_yThe horizontal radius of the corner, in pixels.
Returns
A reference to the modified object.

◆ cursor() [1/2]

cursor_type & liblec::lecui::widgets::icon::cursor ( )
overridevirtual

Get or set the mouse cursor to use then over the widget.

Returns
A reference to the cursor type as defined in cursor_type.

Implements liblec::lecui::widgets::widget.

◆ cursor() [2/2]

icon & liblec::lecui::widgets::icon::cursor ( const cursor_type  cursor)

Set the mouse cursor to use when over the widget.

Parameters
cursorThe cursor type as defined in cursor_type.
Returns
A reference to the modified object.

◆ description() [1/2]

std::string & liblec::lecui::widgets::icon::description ( )

Get or set the description text.

Returns
A reference to the description text.

◆ description() [2/2]

icon & liblec::lecui::widgets::icon::description ( const std::string &  description)

Set the description text.

Parameters
descriptionThe description text.
Returns
A reference to the modified object.

◆ file() [1/2]

std::string & liblec::lecui::widgets::icon::file ( )

Get or set the path to the icon's image file.

Returns
A reference to the path.
Returns
PNG resource takes precedence over image file.

◆ file() [2/2]

icon & liblec::lecui::widgets::icon::file ( const std::string &  file)

Set the path to the icon's image file.

Parameters
fileThe path to the file.
Returns
A reference to the modified object.

PNG resource takes precedence over image file.

◆ font() [1/2]

std::string & liblec::lecui::widgets::icon::font ( )
overridevirtual

Get or set the default widget font, e.g. "Georgia".

Returns
A reference to the widget's font name.

Implements liblec::lecui::widgets::widget.

◆ font() [2/2]

icon & liblec::lecui::widgets::icon::font ( const std::string &  font)

Set the default widget font.

Parameters
fontThe font's name, e.g. "Georgia".
Returns
A reference to the modified object.

◆ font_size() [1/2]

float & liblec::lecui::widgets::icon::font_size ( )
overridevirtual

Get or set the default widget font size in points, e.g. 9.0f.

Returns
A reference to the widget's font size.

Implements liblec::lecui::widgets::widget.

◆ font_size() [2/2]

icon & liblec::lecui::widgets::icon::font_size ( const float &  font_size)

Set the widget's font size.

Parameters
font_sizeThe font size in points, e.g. 9.0f.
Returns
A reference to the modified object.

◆ font_size_description() [1/2]

float & liblec::lecui::widgets::icon::font_size_description ( )

Get or set the size of the description text.

Returns
A reference to the size, in points.

◆ font_size_description() [2/2]

icon & liblec::lecui::widgets::icon::font_size_description ( const float &  font_size_description)

Set the size of the description text.

Parameters
font_size_descriptionThe size of the font, in points.
Returns
A reference to the modified object.

◆ gap() [1/2]

float & liblec::lecui::widgets::icon::gap ( )

Get or set the gap between the text and the image and the text.

Returns
A reference to the property, in pixels.

◆ gap() [2/2]

icon & liblec::lecui::widgets::icon::gap ( const float &  gap)

Set the gap between the text and the image and the text.

Parameters
gapThe gap, in pixels.
Returns
A reference to the modified object.

◆ get()

static icon & liblec::lecui::widgets::icon::get ( form fm,
const std::string &  path 
)
static

Get the specifications of an icon.

Parameters
fmA reference to the form.
pathThe full path to the widget, e.g. "sample_page/sample_pane/users".
Returns
A reference to the widget specifications.

Throws on failure. For faster coding and more readable code consider calling this static method through the helper macro provided.

◆ max_image_size() [1/2]

float & liblec::lecui::widgets::icon::max_image_size ( )

Get or set the maximum size of the image square's side.

Returns
A reference to the property, in pixels.

Set to 0.f for unlimited image size.

◆ max_image_size() [2/2]

icon & liblec::lecui::widgets::icon::max_image_size ( const float &  max_image_size)

Set the maximum size of the image square's side.

Parameters
max_image_sizeThe size of the side, in pixels.
Returns
A reference to the modified object.

Set to 0.f for unlimited image size.

◆ on_resize() [1/2]

resize_params & liblec::lecui::widgets::icon::on_resize ( )
overridevirtual

Get or set the behaviour of the widget when its container is resized.

Returns
A reference to the resize parameters as defined in resize_params.

Implements liblec::lecui::widgets::widget.

◆ on_resize() [2/2]

icon & liblec::lecui::widgets::icon::on_resize ( const resize_params on_resize)

Set the behaviour of the widget when its container is resized.

Parameters
on_resizeThe resize parameters as defined in resize_params.
Returns
A reference to the modified object.

◆ opacity() [1/2]

float & liblec::lecui::widgets::icon::opacity ( )

Get or set the opacity of the image.

Returns
A reference to the opacity, as a percentage.

◆ opacity() [2/2]

icon & liblec::lecui::widgets::icon::opacity ( const float &  opacity)

Set the opacity of the image.

Parameters
opacityThe opacity of the image, as a percentage.
Returns
A reference to the modified object.

◆ operator!=()

bool liblec::lecui::widgets::icon::operator!= ( const icon param)

Check whether widget specs are NOT equal. Only those properties that require the widget resources to be re-created are considered.

Parameters
paramThe specs to compare to.
Returns
Returns true if the specs are NOT equal, else false.

◆ operator==()

bool liblec::lecui::widgets::icon::operator== ( const icon param)

Check whether widget specs are equal. Only those properties that require the widget resources to be re-created are considered.

Parameters
paramThe specs to compare to.
Returns
Returns true if the specs are equal, else false.

◆ padding() [1/2]

float & liblec::lecui::widgets::icon::padding ( )

Get or set the padding to use around the icon.

Returns
A reference to the property, in pixels.

◆ padding() [2/2]

icon & liblec::lecui::widgets::icon::padding ( const float &  padding)

Set the padding to use around the icon.

Parameters
paddingThe padding, in pixels.
Returns
A reference to the modified object.

◆ png_resource() [1/2]

int & liblec::lecui::widgets::icon::png_resource ( )

Get or set the icon's PNG resource.

Returns
A reference to the resource's ID.

PNG resource takes precedence over image file.

◆ png_resource() [2/2]

icon & liblec::lecui::widgets::icon::png_resource ( const int &  png_resource)

Set the icon's PNG resource.

Parameters
png_resourceThe ID of PNG resource.
Returns
A reference to the modified object.

PNG resource takes precedence over image file.

◆ quality() [1/2]

image_quality & liblec::lecui::widgets::icon::quality ( )

Get or set the quality of the image in the icon.

Returns
A reference to the quality property.

Lower quality means greater performance and vice-versa.

◆ quality() [2/2]

icon & liblec::lecui::widgets::icon::quality ( const image_quality quality)

Set the quality of the image in the icon.

Parameters
qualityThe quality of the image, as defined in image_quality.
Returns
A reference to the modified object.

Lower quality means greater performance and vice-versa.

◆ rect() [1/2]

lecui::rect & liblec::lecui::widgets::icon::rect ( )
overridevirtual

Get or set the position and dimensions of the widget.

Returns
A reference to the widget rectangle.

The position is in reference to the widget's container.

Implements liblec::lecui::widgets::widget.

◆ rect() [2/2]

icon & liblec::lecui::widgets::icon::rect ( const lecui::rect rect)

Set the position and dimensions of the widget.

Parameters
rectThe widget's rectangle.
Returns
A reference to the modified object.

◆ text() [1/2]

std::string & liblec::lecui::widgets::icon::text ( )
overridevirtual

Get or set the widget text.

Returns
A reference to the widget text.

Implements liblec::lecui::widgets::widget.

◆ text() [2/2]

icon & liblec::lecui::widgets::icon::text ( const std::string &  text)

Set the widget's text.

Parameters
textThe text.
Returns
A reference to the modified object.

◆ text_position() [1/2]

icon_text_position & liblec::lecui::widgets::icon::text_position ( )

Get or set the position of the text.

Returns
A reference to the text position.

◆ text_position() [2/2]

icon & liblec::lecui::widgets::icon::text_position ( const icon_text_position text_position)

Set the position of the text.

Parameters
text_positionThe position of the text as defined in icon_text_position.
Returns
A reference to the modified object.

◆ tooltip() [1/2]

std::string & liblec::lecui::widgets::icon::tooltip ( )
overridevirtual

Get or set the widget's tooltip text.

Returns
A reference to the tooltip text.

Implements liblec::lecui::widgets::widget.

◆ tooltip() [2/2]

icon & liblec::lecui::widgets::icon::tooltip ( const std::string &  tooltip)

Set the tooltip text.

Parameters
tooltipThe tooltip text.
Returns
A reference to the modified object.

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