CDPBaseContainer Class

The Container is a container widget that supports both svg themes and ordinary pixmap backgrounds. More...

Header: #include <CDPBaseContainer>
Inherits: CDPBaseWidget
Inherited By:

CDPBaseTitle

Public Types

typedef ContainerSvgMap
enum ContainerType { Custom, Container, Title, CSS }

Properties

Public Functions

CDPBaseContainer(QWidget *parent = 0)
virtual ~CDPBaseContainer()
virtual int animHeightMs()
virtual int animHeightPx()
virtual bool animStartIsMax()
virtual int animWidthMs()
virtual int animWidthPx()
virtual bool animate()
virtual int borderMarginBottom()
const QMargins &borderMarginInUse()
virtual int borderMarginLeft()
virtual int borderMarginRight()
virtual int borderMarginTop()
virtual QMargins borderMargins()
virtual QString borderPixmap()
virtual ContainerType containerType()
virtual QString cssFile()
virtual bool isCustom()
virtual void setAnimHeightMs(int value)
virtual void setAnimHeightPx(int value)
virtual void setAnimStartIsMax(bool max)
virtual void setAnimWidthMs(int value)
virtual void setAnimWidthPx(int value)
virtual void setAnimate(bool anim)
virtual void setBorderMarginBottom(int bottom)
virtual void setBorderMarginLeft(int left)
virtual void setBorderMarginRight(int right)
virtual void setBorderMarginTop(int top)
virtual void setBorderMargins(QMargins margins)
virtual void setBorderPixmap(QString name)
virtual void setContainerType(ContainerType type)
virtual void setCssFile(QString cssFile)
virtual void setSvgBorderMargin(bool enable)
QSize sizeHint() const override
virtual bool svgBorderMargin()
virtual bool usingSvgBorderMargins()

Public Slots

virtual void animateHeight()
virtual void animateHeight(bool increase)
virtual void animateHeightToMax()
virtual void animateHeightToMin()
virtual void animateWidth()
virtual void animateWidth(bool increase)
virtual void animateWidthToMax()
virtual void animateWidthToMin()
virtual void polishStyle()
virtual void setWidgetStyle(int style)
virtual void setWidgetTheme(const QString &theme)

Protected Functions

virtual void clearSvg()
virtual void loadPixmaps()
virtual void paintEvent(QPaintEvent *ev)
virtual void processSvgFile(QString svg)

Additional Inherited Members

Detailed Description

The Container is a container widget that supports both svg themes and ordinary pixmap backgrounds.

In addition to being an ordinary widget container it is commonly used to group menu buttons. The container includes properties for animating size which can be used to hide/show the menu. Connect any clickable widget to different slots to animate on height or width, but note that animations will only work when the container is placed in a layout.

A common use case is to have a CDPBaseButton in a top menu (or on a page) with its qt signal, CDPBaseButton::clicked(), connected to the qt slot named, CDPBaseContainer::animateWidth(), in the container (assuming that the container is functioning as a vertical side menu). The user can then press the button to hide/show the side menu and thus make more room for page elements.

Note: Selecting css as styling type without adding a css file will make the container background transparent.

Styling by SVG

Use the svgFile property to style the widget using a svg file. Styling by svg enables switching between different themes in runtime (as long as the files are placed at identical locations within theme directories).

Main element structure

The following tree view shows the svg structure that can be used on the CDPBaseContainer.

svg
└─── Layer1
      ├─── cdpBorderMarginTopLeft     (transparent rect/path)
      ├─── cdpBorderMarginBottomRight (transparent rect/path)
      └─── cdpBackground              (element group)
            ├─── < Path >             (transparent rect/path)
            └─── < Group >            (background graphics)

The following table explains the named elements in more detail.

PropertyTypeDescription
cdpBorderMarginTopLeftrectTransparent rectangle that specifies the left border margin by its width and the top border margin by its height.
cdpBorderMarginBottomRightrectTransparent rectangle that specifies the right border margin by its width and the bottom border margin by its height.
cdpBackgroundrect or an element group containing a rectThe cdpBackground should contain the actual background graphics. To ensure that the svg parser gets the correct background size (and aspect ratio), we have to place a transparent rect along with the graphics within a group element.

Note: Elements that are written with pointy brackets, like < Path >, can be given any name. Avoid cdp prefix as these are special to the parser.

Style element structure

The container supports the following style structure.

svg
├─── Layer1
│     └─── ...                  (see previous section)
└─── Styles
      └─── cdpBackgroundStyleX  (element group)
            ├─── < Path >       (transparent rect/path)
            └─── < Group >      (background graphics)

Member Type Documentation

typedef CDPBaseContainer::ContainerSvgMap

enum CDPBaseContainer::ContainerType

This enum type specifies styling types that can be used on the container:

ConstantValueDescription
CDPBaseContainer::Custom0Style the widget with a custom border pixmap.
CDPBaseContainer::Container1Style the widget using default container border pixmap.
CDPBaseContainer::Title2Style the widget with default title background.
CDPBaseContainer::CSS3Style the widget using a css file.

Property Documentation

animEnable : bool

This property holds whether to enable size animation triggered by qt signals and slots.

Setting animEnabled to true, allows us to connect the slots named animateHeight() and animateWidth() and initiate/toggle the containers height and width. The distance is specified by animHeightPx and animWidthPx while animation duration is set in animHeightMs and animWidthMs.

Note: that the container must be in a layout for the animation to work.

Access functions:

virtual bool animate()
virtual void setAnimate(bool anim)

See also animHeightPx, animWidthPx, animHeightMs, and animWidthMs.

animHeightMs : int

This property holds the duration of the height animation.

Access functions:

virtual int animHeightMs()
virtual void setAnimHeightMs(int value)

See also animHeightPx, animEnable, animWidthMs, and animWidthPx.

animHeightPx : int

This property holds the distance to move during height animation.

Access functions:

virtual int animHeightPx()
virtual void setAnimHeightPx(int value)

See also animWidthPx, animEnable, animHeightMs, and animWidthMs.

animStartIsMax : bool

This property holds whether or not the initial size is max or min.

Access functions:

virtual bool animStartIsMax()
virtual void setAnimStartIsMax(bool max)

See also animHeightPx, animEnable, animWidthMs, animWidthPx, and animHeightMs.

animWidthMs : int

This property holds the duration of the width animation.

Access functions:

virtual int animWidthMs()
virtual void setAnimWidthMs(int value)

See also animHeightPx, animEnable, animHeightMs, and animWidthPx.

animWidthPx : int

This property holds the distance to move during width animation.

Access functions:

virtual int animWidthPx()
virtual void setAnimWidthPx(int value)

See also animHeightPx, animEnable, animHeightMs, and animWidthMs.

borderMarginBottom : int

This property holds the bottom border margin.

Note that it will show the svg border margin if the svgBorderMargins property is set.

Access functions:

virtual int borderMarginBottom()
virtual void setBorderMarginBottom(int bottom)

See also borderPixmap and svgBorderMargins.

borderMarginLeft : int

This property holds the left border margin.

Note that it will show the svg border margin if the svgBorderMargins property is set.

Access functions:

virtual int borderMarginLeft()
virtual void setBorderMarginLeft(int left)

See also borderPixmap and svgBorderMargins.

borderMarginRight : int

This property holds the right border margin.

Note that it will show the svg border margin if the svgBorderMargins property is set.

Access functions:

virtual int borderMarginRight()
virtual void setBorderMarginRight(int right)

See also borderPixmap and svgBorderMargins.

borderMarginTop : int

This property holds the top border margin.

Note that it will show the svg border margin if the svgBorderMargins property is set.

Access functions:

virtual int borderMarginTop()
virtual void setBorderMarginTop(int top)

See also borderPixmap and svgBorderMargins.

borderPixmap : QString

This property holds the border pixmap to show in the container.

The path can be either to a resource or a file on a disk. Note that resources can be overridden by files on disk with identical names. The property can only be edited when the type property is set to "Custom".

Access functions:

virtual QString borderPixmap()
virtual void setBorderPixmap(QString name)

See also svgBorderMargins.

cssFile : QString

This property holds the css file to style the widget.

Similar to the borderPixmap, the path is updated for the selected theme. Note that when both a css file and a borderPixmap is present, we have to select the CSS type to disable borderPixmap (for instance to style the container itself).

Access functions:

virtual QString cssFile()
virtual void setCssFile(QString cssFile)

See also borderPixmap.

svgBorderMargins : bool

This property holds whether to use the border margins provided in the svg file.

Note: the borderMargin properties will show the svg border margins when svgBorderMargins is set. Trying to change the borderMargins while svgBorderMargins is enabled will change the non svg border margins, but the changes wont show until the svgBorderMargins property is set to false.

Access functions:

virtual bool svgBorderMargin()
virtual void setSvgBorderMargin(bool enable)

See also borderPixmap, borderMarginBottom, borderMarginLeft, borderMarginTop, and borderMarginRight.

type : ContainerType

This property holds the styling type to use when styling the widget.

Setting it to "Custom", "Container" or "Title", changes the string in the borderPixmap property. The only difference is that the borderPixmap property can only be edited when type is set to "Custom". The type named "CSS" is different as it disables the borderPixmap and selects cssFile instead. When no cssFile is specified, the widget will function as an ordinary qt widget and show as transparent.

Access functions:

virtual ContainerType containerType()
virtual void setContainerType(ContainerType type)

See also borderPixmap and cssFile.

Member Function Documentation

CDPBaseContainer::CDPBaseContainer(QWidget *parent = 0)

Default constructs an instance of CDPBaseContainer.

[virtual] CDPBaseContainer::~CDPBaseContainer()

Destroys the instance of CDPBaseContainer. The destructor is virtual.

[virtual slot] void CDPBaseContainer::animateHeight()

[virtual slot] void CDPBaseContainer::animateHeight(bool increase)

[virtual slot] void CDPBaseContainer::animateHeightToMax()

[virtual slot] void CDPBaseContainer::animateHeightToMin()

[virtual slot] void CDPBaseContainer::animateWidth()

[virtual slot] void CDPBaseContainer::animateWidth(bool increase)

[virtual slot] void CDPBaseContainer::animateWidthToMax()

[virtual slot] void CDPBaseContainer::animateWidthToMin()

const QMargins &CDPBaseContainer::borderMarginInUse()

[virtual] QMargins CDPBaseContainer::borderMargins()

See also setBorderMargins().

[virtual protected] void CDPBaseContainer::clearSvg()

[virtual] bool CDPBaseContainer::isCustom()

[virtual protected] void CDPBaseContainer::loadPixmaps()

[virtual protected] void CDPBaseContainer::paintEvent(QPaintEvent *ev)

[virtual slot] void CDPBaseContainer::polishStyle()

[virtual protected] void CDPBaseContainer::processSvgFile(QString svg)

[virtual] void CDPBaseContainer::setBorderMargins(QMargins margins)

See also borderMargins().

[virtual slot] void CDPBaseContainer::setWidgetStyle(int style)

[virtual slot] void CDPBaseContainer::setWidgetTheme(const QString &theme)

QSize CDPBaseContainer::sizeHint() const

[virtual] bool CDPBaseContainer::usingSvgBorderMargins()