CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Properties | List of all members
ctkLayoutManager Class Referenceabstract

#include <Libs/Widgets/ctkLayoutManager.h>

Inheritance diagram for ctkLayoutManager:
Inheritance graph
[legend]
Collaboration diagram for ctkLayoutManager:
Collaboration graph
[legend]

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
 

Detailed Description

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:

<layout type=\"tab\">
<item>
<layout type=\"horizontal\" split=\"true\">
<item splitSize=\"500\"><view/></item>
<item splitSize=\"250\">
<layout type=\"vertical\">
<item><view verticalStretch=\"1\"/></item>
<item><view verticalStretch=\"2\"/></item>
<item>
<layout type=\"grid\">
<item row=\"0\" column=\"1\"><view verticalStretch=\"1\"/></item>
<item row=\"1\" column=\"0\"><view verticalStretch=\"1\"/></item>
</layout>
</item>
</layout>
</item>
<item splitSize=\"250\"><view/></item>
</layout>
</item>
<item><view name=\"tab2\"/></item>
<item><view name=\"tab3\"/></item>
</layout>
const QDomDocument layout() const

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].

See also
ctkSimpleLayoutManager, ctkLayoutViewFactory

Definition at line 83 of file ctkLayoutManager.h.

Constructor & Destructor Documentation

◆ ctkLayoutManager() [1/3]

ctkLayoutManager::ctkLayoutManager ( QObject *  parent = 0)

Constructor.

◆ ctkLayoutManager() [2/3]

ctkLayoutManager::ctkLayoutManager ( QWidget *  viewport,
QObject *  parent 
)
explicit

◆ ~ctkLayoutManager()

virtual ctkLayoutManager::~ctkLayoutManager ( )
virtual

Destructor.

◆ ctkLayoutManager() [3/3]

ctkLayoutManager::ctkLayoutManager ( ctkLayoutManagerPrivate *  ptr,
QWidget *  viewport,
QObject *  parent 
)
protected

Member Function Documentation

◆ addChildItemToLayout()

virtual void ctkLayoutManager::addChildItemToLayout ( QDomElement  itemElement,
QLayoutItem *  childItem,
QLayoutItem *  layoutItem 
)
protectedvirtual

Insert a child item into a layout.

See also
processLayoutElement()

◆ clearLayout()

void ctkLayoutManager::clearLayout ( )
protected

◆ layout()

const QDomDocument ctkLayoutManager::layout ( ) const
protected

◆ layoutChanged

void ctkLayoutManager::layoutChanged ( )
signal

◆ layoutFromXML()

virtual QLayoutItem* ctkLayoutManager::layoutFromXML ( QDomElement  layoutElement)
protectedvirtual

Create the QLayoutItem for a "layout" XML element.

See also
processLayoutElement()

◆ onViewportChanged()

virtual void ctkLayoutManager::onViewportChanged ( )
protectedvirtual

◆ processElement()

virtual QLayoutItem* ctkLayoutManager::processElement ( QDomElement  element)
protectedvirtual

Create the QLayoutItem for an XML element (e.g. "layout", "view"...) and its nested elements.

See also
processLayoutElement()

◆ processItemElement()

void ctkLayoutManager::processItemElement ( QDomElement  layoutElement,
QLayoutItem *  layoutItem 
)
protected

Create the QLayoutItem(s) of the "item" XML element.

See also
processItemElement()

◆ processLayoutElement()

virtual QLayoutItem* ctkLayoutManager::processLayoutElement ( QDomElement  layoutElement)
protectedvirtual

Create the QLayoutItem for a "layout" XML element and its nested elements.

See also
processElement(), layoutFromXML(), processItemElement(), addChildItemToLayout()

◆ refresh()

void ctkLayoutManager::refresh ( )

◆ setLayout()

virtual void ctkLayoutManager::setLayout ( const QDomDocument &  newLayout)
protectedvirtual

◆ setSpacing()

void ctkLayoutManager::setSpacing ( int  spacing)

Set the spacing property value.

See also
spacing

◆ setupLayout()

virtual void ctkLayoutManager::setupLayout ( )
protectedvirtual

Reimplemented in ctkLayoutFactory.

◆ setupView()

virtual void ctkLayoutManager::setupView ( QDomElement  layoutElement,
QWidget *  view 
)
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.

See also
viewsFromXML()

Reimplemented in ctkLayoutFactory.

◆ setViewport()

Q_INVOKABLE void ctkLayoutManager::setViewport ( QWidget *  widget)

◆ spacing()

int ctkLayoutManager::spacing ( ) const

Return the spacing property value.

See also
spacing

◆ viewFromXML()

virtual QWidget* ctkLayoutManager::viewFromXML ( QDomElement  layoutElement)
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.

See also
viewsFromXML(), setupView()

Implemented in ctkLayoutFactory.

◆ viewport()

Q_INVOKABLE QWidget* ctkLayoutManager::viewport ( ) const

◆ viewsFromXML()

virtual QList<QWidget*> ctkLayoutManager::viewsFromXML ( QDomElement  layoutElement)
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.

See also
viewFromXML(),

Reimplemented in ctkLayoutFactory.

◆ widgetItemFromXML()

QWidgetItem* ctkLayoutManager::widgetItemFromXML ( QDomElement  layoutElement)
protected

Utility method that creates, setups and wraps into a QWidgetItem the widget of a view XML element.

See also
widgetsItemsFromXML(), viewFromXML()

◆ widgetItemsFromXML()

QList<QLayoutItem*> ctkLayoutManager::widgetItemsFromXML ( QDomElement  layoutElement)
protected

Create, setup and wrap into QWidgetItems the widgets of a view XML element.

Member Data Documentation

◆ d_ptr

QScopedPointer<ctkLayoutManagerPrivate> ctkLayoutManager::d_ptr
protected

Definition at line 115 of file ctkLayoutManager.h.

Property Documentation

◆ spacing

int ctkLayoutManager::spacing
readwrite

Spacing between the widgets in all the layouts.

See also
spacing(), setSpacing()

Definition at line 1 of file ctkLayoutManager.h.


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