![]() |
CTK
0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
|
#include <Libs/Widgets/ctkLayoutManager.h>
Signals | |
void | layoutChanged () |
Public Member Functions | |
ctkLayoutManager (QObject *parent=0) | |
Constructor. More... | |
ctkLayoutManager (QWidget *viewport, QObject *parent) | |
void | refresh () |
void | setSpacing (int spacing) |
Q_INVOKABLE void | setViewport (QWidget *widget) |
int | spacing () const |
Q_INVOKABLE QWidget * | viewport () const |
virtual | ~ctkLayoutManager () |
Destructor. More... | |
Protected Member Functions | |
virtual void | addChildItemToLayout (QDomElement itemElement, QLayoutItem *childItem, QLayoutItem *layoutItem) |
void | clearLayout () |
ctkLayoutManager (ctkLayoutManagerPrivate *ptr, QWidget *viewport, QObject *parent) | |
const QDomDocument | layout () const |
virtual QLayoutItem * | layoutFromXML (QDomElement layoutElement) |
virtual void | onViewportChanged () |
virtual QLayoutItem * | processElement (QDomElement element) |
void | processItemElement (QDomElement layoutElement, QLayoutItem *layoutItem) |
virtual QLayoutItem * | processLayoutElement (QDomElement layoutElement) |
virtual void | setLayout (const QDomDocument &newLayout) |
virtual void | setupLayout () |
virtual void | setupView (QDomElement layoutElement, QWidget *view) |
virtual QWidget * | viewFromXML (QDomElement layoutElement)=0 |
virtual QList< QWidget * > | viewsFromXML (QDomElement layoutElement) |
QWidgetItem * | widgetItemFromXML (QDomElement layoutElement) |
QList< QLayoutItem * > | widgetItemsFromXML (QDomElement layoutElement) |
Protected Attributes | |
QScopedPointer< ctkLayoutManagerPrivate > | d_ptr |
Properties | |
int | spacing |
ctkLayoutManager is a layout manager that populates a widget (viewport) with widgets described into an XML document. To be used, ctkLayoutManager class must be derived and a subset of virtual methods must be reimplemented to support custom views. See below an example of layout XML document:
The layout elements describe widget containers that embed one or multiple items. Arrangement of items are specified by type attribute of the layout element; supported values: vertical, horizontal, grid, tab. The item elements describe widgets or layouts that are children of layouts. The view elements can be any type of QWidget. viewFromXML() must be reimplemented to return the type(s) of QWidget(s) to use wherever the view element is listed in the layout. The XML element can contain any XML attribute to be parsed by viewFromXML() method.
For horizontal and vertical layouts, setting split attribute to "true" makes the views resizeable. Default size can be set using splitSize attribute of child items.
Relative size of views can be adjusted by specifying stretch factors in horizontalStretch and verticalStretch attributes. The stretch factor must be an integer in the range of [0,255].
Definition at line 83 of file ctkLayoutManager.h.
ctkLayoutManager::ctkLayoutManager | ( | QObject * | parent = 0 | ) |
Constructor.
|
explicit |
|
virtual |
Destructor.
|
protected |
|
protectedvirtual |
Insert a child item into a layout.
|
protected |
|
protected |
|
signal |
|
protectedvirtual |
Create the QLayoutItem for a "layout" XML element.
|
protectedvirtual |
|
protectedvirtual |
Create the QLayoutItem for an XML element (e.g. "layout", "view"...) and its nested elements.
|
protected |
Create the QLayoutItem(s) of the "item" XML element.
|
protectedvirtual |
Create the QLayoutItem for a "layout" XML element and its nested elements.
void ctkLayoutManager::refresh | ( | ) |
|
protectedvirtual |
void ctkLayoutManager::setSpacing | ( | int | spacing | ) |
Set the spacing property value.
|
protectedvirtual |
Reimplemented in ctkLayoutFactory.
|
protectedvirtual |
Method is called each time a view is made visible into a layout. This method can be reimplemented. Sets the widget visibility to true by default.
Reimplemented in ctkLayoutFactory.
Q_INVOKABLE void ctkLayoutManager::setViewport | ( | QWidget * | widget | ) |
int ctkLayoutManager::spacing | ( | ) | const |
Return the spacing property value.
|
protectedpure virtual |
Virtual method that returns a widget from a "view" layout element. You are ensured that the tagName of the element is "view". The XML element can contain an arbitrary number of XML attributes. Create the widget if needed or reuse it from a previous call.
Implemented in ctkLayoutFactory.
Q_INVOKABLE QWidget* ctkLayoutManager::viewport | ( | ) | const |
|
protectedvirtual |
Virtual method that returns a list of widgets from a "view" layout element. If the parent "item" element has a "multiple=true" XML attribute, the "view" layout element can describe many widgets instead of just one widget. The returned widgets will automatically be layout into their parent layout (e.g. boxlayout). This method can be reimplemented. Returns viewFromXML() by default.
Reimplemented in ctkLayoutFactory.
|
protected |
Utility method that creates, setups and wraps into a QWidgetItem the widget of a view XML element.
|
protected |
Create, setup and wrap into QWidgetItems the widgets of a view XML element.
|
protected |
Definition at line 115 of file ctkLayoutManager.h.
|
readwrite |
Spacing between the widgets in all the layouts.
Definition at line 1 of file ctkLayoutManager.h.