Page Contents

Topics

Classes

QLThemeableBox Class

#include <QLayers/qlthemeablebox.h>

Inherits: QLThemeable
Inherited By: QLDialog, QLWidget

Public Functions

LAttribute* border_fill() const
LAttribute* border_thickness() const
LAttribute* corner_radii_bottom_left() const
LAttribute* corner_radii_bottom_right() const
LAttribute* corner_radii_top_left() const
LAttribute* corner_radii_top_right() const
LAttribute* fill() const
LAttribute* margins_bottom() const
LAttribute* margins_left() const
LAttribute* margins_right() const
LAttribute* margins_top() const
void set_margin(double margin)
void set_margin(double left, double top, double right, double bottom)

Static Public Functions

QPainterPath box_path(const QRect& box_rect, const LCornerRadii& corner_radii)

Protected Functions

void init_attributes()
void paint(QWidget* widget)

Detailed Description

QLThemeableBox Example

A QLThemeableBox is a QLThemeable that defines attributes and painting functionality for a box-shaped widget.

Painting the Box

Classes that inherit QLThemeableBox (which should also inherit QWidget or other QWidget types) should override their paintEvent() functions to call paint(), passing along a pointer to themselves. The following is a example from QLWidget:

void QLWidget::paintEvent(QPaintEvent* event)
{
    paint(this);
}

This will draw the box across the width and height of the widget.

Box Attributes

Themeable-boxes come with a set of LAttribute objects that are used to give them certain appearances.

Border

A border is drawn on the box if the border thickness attribute is greater than 0. The border fill attribute determines what color or gradient should be used to fill the border with. These are considered grouped attributes.

The border attributes are obtained through border_thickness() and border_fill().

The corners of the border are affected by the box's corner radii attributes.

Corner Radii

There is an attribute for every corner of the box. These are considered grouped attributes.

The corner radii attributes are obtained through corner_radii_top_left(), corner_radii_top_right(), corner_radii_bottom_left(), and corner_radii_bottom_right().

Fill

There is a fill attribute that determines what color or gradient should be used to fill the inside of the box with.

Margin

There are four margin attributes, one for each side of the box. They can be changed to shorten the draw dimensions. These are considered grouped attributes.

The margins attributes are obtained through margins_left(), margins_top(), margins_right(), and margins_bottom().

See also: set_margin()

Member Function Documentation

LAttribute* border_fill() const

Returns a pointer to the border fill attribute of this themeable.

LAttribute* border_thickness() const

Returns a pointer to the border thickness attribute of this themeable.

QPainterPath box_path(const QRect& box_rect, const LCornerRadii& corner_radii)

Static

Returns a box-shaped QPainterPath with the given box_rect and corner_radii.

LAttribute* corner_radii_bottom_left() const

Returns a pointer to the bottom-left corner radii attribute of this themeable.

LAttribute* corner_radii_bottom_right() const

Returns a pointer to the bottom-right corner radii attribute of this themeable.

LAttribute* corner_radii_top_left() const

Returns a pointer to the top-left corner radii attribute of this themeable.

LAttribute* corner_radii_top_right() const

Returns a pointer to the top-right corner radii attribute of this themeable.

LAttribute* fill() const

Returns a pointer to the fill attribute of this themeable.

void init_attributes()

Protected

Initializes the attributes.

QLThemeableBox subclasses need to call this function manually.

LAttribute* margins_bottom() const

Returns a pointer to the bottom margin attribute of this themeable.

LAttribute* margins_left() const

Returns a pointer to the left margin attribute of this themeable.

LAttribute* margins_right() const

Returns a pointer to the right margin attribute of this themeable.

LAttribute* margins_top() const

Returns a pointer to the top margin attribute of this themeable.

void paint(QWidget* widget)

Protected

Paints widget using the attributes of this QLThemeableBox.

QLThemeableBox subclasses should call this function from overriden paintEvent() functions.

void set_margin(double left, double top, double right, double bottom)

Sets the margin attributes individually.

void set_margin(double margin)

Sets all margin attributes with one value.