Envision
A visual programming IDE for object-oriented languages
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
Visualization::FormElement Class Referenceabstract

Base class for all the form elements, that can be added as a form to a DeclarativeItem. More...

Inheritance diagram for Visualization::FormElement:
Visualization::SuperFormElement< ShapeFormElement, FormElement > Visualization::SuperFormElement< BorderFormElement, FormElement > Visualization::ItemWrapperFormElement< ParentType, ChildItemType > Visualization::LayoutFormElement Visualization::ShapeFormElement Visualization::BorderFormElement Visualization::SuperFormElement< VisualizationItemWrapperFormElement< ParentType, VisualizationType, externalSynchronization >, ItemWrapperFormElement< ParentType, VisualizationType > > Visualization::SuperFormElement< NodeWithVisualizationItemWrapperFormElement< ParentType, VisualizationType >, ItemWrapperFormElement< ParentType, VisualizationType > > Visualization::SuperFormElement< NodeItemWrapperFormElement< ParentType >, ItemWrapperFormElement< ParentType > > Visualization::VisualizationItemWrapperFormElement< ParentType, VisualizationType, externalSynchronization > Visualization::NodeWithVisualizationItemWrapperFormElement< ParentType, VisualizationType > Visualization::NodeItemWrapperFormElement< ParentType >

Public Member Functions

 FormElement ()=default
 
 FormElement (const FormElement &other)
 
virtual ~FormElement ()
 
virtual QList< const Item *const DeclarativeItemBase::* > allHandledChildPointers ()
 Returns a list of all pointer to child items of this form. More...
 
virtual FormElementclone () const =0
 Copy this element and all its children into a new element tree. More...
 
FormElementcloneIfAlreadyUsed ()
 
virtual void computeSize (Item *item, int availableWidth, int availableHeight)=0
 Method called inside the item's updateGeometry method to compute it's size and position it's child elements. More...
 
virtual void destroyChildItems (Item *item, QList< const Item *const DeclarativeItemBase::* > handledChildren)
 This method is recursively called on all form elements to destroy all the information they might have about a specific item. More...
 
virtual bool elementOrChildHasFocus (Item *item) const
 Method called inside the item's elementOrChildHasFocus and by some layout form elements. More...
 
int height (Item *item) const
 Returns the cached height of this form element for the specified item. More...
 
virtual bool isEmpty (const Item *item) const
 Method called inside the item's isEmpty method, and by some layout form elements. More...
 
bool isFormRoot () const
 
FormElementoperator= (const FormElement &)=delete
 
FormElementparent () const
 
QPoint pos (Item *item) const
 Returns the cached position of this form element for the specified item. More...
 
virtual QList< ItemRegionregions (DeclarativeItemBase *item, int parentX=0, int parentY=0)
 Method called inside the item's regions method and returns cursor and item regions of all contained form elements for this item. More...
 
FormElementsetBottomMargin (int bottom)
 Sets the bottom margin of this form element. More...
 
FormElementsetFormRoot ()
 Sets this element to be a formRoot. More...
 
virtual void setItemPositions (Item *item, int parentX=0, int parentY=0)
 Method called inside the item's updateGeometry method to recursively position it's child items relative to the item's position. More...
 
FormElementsetLeftMargin (int left)
 Sets the left margin of this form element. More...
 
FormElementsetMargins (int left, int top, int right, int bottom)
 Sets the left, top, right and bottom margins to the respective values. More...
 
FormElementsetMargins (int margin)
 Sets all the margins of this form element to the value specified as margin. More...
 
void setPos (Item *item, const QPoint &position)
 Caches the position of this form element for the specified item. More...
 
FormElementsetRightMargin (int right)
 Sets the right margin of this form element. More...
 
FormElementsetTopMargin (int top)
 Sets the top margin of this form element. More...
 
virtual QList< FormElement * > shapeElements ()
 Returns the list of shape elements inside this form element. More...
 
QSize size (Item *item) const
 Returns the cached size of this form element for the specified item. More...
 
virtual bool sizeDependsOnParent (const Item *item) const =0
 Method called inside the item's sizeDependsOnParent method, and by some layout form elements. More...
 
virtual void synchronizeWithItem (Item *item)
 Method called inside the item's determineChildren method to let the form element and it's children update their information about items and nodes belonging to this item. More...
 
int width (Item *item) const
 Returns the cached width of this form element for the specified item. More...
 
int x (Item *item) const
 Returns the cached position on the x-axis of this form element for the specified item. More...
 
int xEnd (Item *item) const
 Returns the cached position on the x-axis where this form element ends for the specified item. More...
 
int y (Item *item) const
 Returns the cached position on the y-axis of this form element for the specified item. More...
 
int yEnd (Item *item) const
 Returns the cached position on the y-axis where this form element ends for the specified item. More...
 

Protected Member Functions

void addChild (FormElement *child)
 Adds a child to the list of children. More...
 
int bottomMargin ()
 Returns the bottom margin. More...
 
const QVector< FormElement * > & children () const
 Returns the list of children. More...
 
int leftMargin ()
 Returns the left margin. More...
 
void removeChild (FormElement *child)
 Removes a child from the list of children. More...
 
int rightMargin ()
 Returns the right margin. More...
 
void setSize (Item *item, const QSize &size)
 Caches the size of this form element for the specified item. More...
 
int topMargin ()
 Returns the top margin. More...
 

Private Member Functions

void clearCache (const Item *item)
 Clears the element property cache of this form element for a specific item. More...
 
ElementCachegetCache (const Item *item) const
 Returns the element property cache of this form element for a specific item. More...
 

Private Attributes

QVector< FormElement * > children_ {}
 
QHash< const Item *, ElementCache * > elementCache_ {}
 
bool isFormRoot_ {}
 
int marginBottom_ {}
 
int marginLeft_ {}
 
int marginRight_ {}
 
int marginTop_ {}
 
FormElementparent_ {}
 

Detailed Description

Base class for all the form elements, that can be added as a form to a DeclarativeItem.

It implements some basic behavior, such as a list of children, and margins.

Constructor & Destructor Documentation

◆ FormElement() [1/2]

Visualization::FormElement::FormElement ( )
default

◆ FormElement() [2/2]

Visualization::FormElement::FormElement ( const FormElement other)

◆ ~FormElement()

Visualization::FormElement::~FormElement ( )
virtual

Member Function Documentation

◆ addChild()

void Visualization::FormElement::addChild ( FormElement child)
protected

Adds a child to the list of children.

◆ allHandledChildPointers()

QList< const Item *const DeclarativeItemBase::* > Visualization::FormElement::allHandledChildPointers ( )
virtual

Returns a list of all pointer to child items of this form.

This list should only be used for comparison as in destroyChildItems() and should not be used for writing.

Reimplemented in Visualization::ItemWrapperFormElement< ParentType, ChildItemType >.

◆ bottomMargin()

int Visualization::FormElement::bottomMargin ( )
inlineprotected

Returns the bottom margin.

◆ children()

const QVector< FormElement * > & Visualization::FormElement::children ( ) const
inlineprotected

Returns the list of children.

◆ clearCache()

void Visualization::FormElement::clearCache ( const Item item)
private

Clears the element property cache of this form element for a specific item.

◆ clone()

virtual FormElement* Visualization::FormElement::clone ( ) const
pure virtual

◆ cloneIfAlreadyUsed()

FormElement * Visualization::FormElement::cloneIfAlreadyUsed ( )

◆ computeSize()

virtual void Visualization::FormElement::computeSize ( Item item,
int  availableWidth,
int  availableHeight 
)
pure virtual

Method called inside the item's updateGeometry method to compute it's size and position it's child elements.

The arguments availableWidth and availableHeight are similar to those of Item::updateGeometry. If they are zero, the form element calculates its minimum size, if it they are bigger, the element tries to stretch/grow to this size, but not further.

Implemented in Visualization::ShapeFormElement, Visualization::ItemWrapperFormElement< ParentType, ChildItemType >, and Visualization::BorderFormElement.

◆ destroyChildItems()

void Visualization::FormElement::destroyChildItems ( Item item,
QList< const Item *const DeclarativeItemBase::* >  handledChildren 
)
virtual

This method is recursively called on all form elements to destroy all the information they might have about a specific item.

It is called in two cases:

  • When the item is being destroyed. In that case all information and child items should be destroyed. The second argument is an empty list.
  • When the current form is changing. In that case only information pertaining to child items which are not definitely handled by the new form should be removed. The second argument is a list of all child item pointer handled by the new form.

Reimplemented in Visualization::ItemWrapperFormElement< ParentType, ChildItemType >.

◆ elementOrChildHasFocus()

bool Visualization::FormElement::elementOrChildHasFocus ( Item item) const
virtual

Method called inside the item's elementOrChildHasFocus and by some layout form elements.

It recursively determines if this form element or any of its children has the focus for the specified item.

Reimplemented in Visualization::ItemWrapperFormElement< ParentType, ChildItemType >.

◆ getCache()

ElementCache & Visualization::FormElement::getCache ( const Item item) const
private

Returns the element property cache of this form element for a specific item.

◆ height()

int Visualization::FormElement::height ( Item item) const
inline

Returns the cached height of this form element for the specified item.

◆ isEmpty()

bool Visualization::FormElement::isEmpty ( const Item item) const
virtual

Method called inside the item's isEmpty method, and by some layout form elements.

It recursively determines whether the form element is empty for the specified item.

Reimplemented in Visualization::ShapeFormElement, Visualization::ItemWrapperFormElement< ParentType, ChildItemType >, and Visualization::BorderFormElement.

◆ isFormRoot()

bool Visualization::FormElement::isFormRoot ( ) const
inline

◆ leftMargin()

int Visualization::FormElement::leftMargin ( )
inlineprotected

Returns the left margin.

◆ operator=()

FormElement& Visualization::FormElement::operator= ( const FormElement )
delete

◆ parent()

FormElement * Visualization::FormElement::parent ( ) const
inline

◆ pos()

QPoint Visualization::FormElement::pos ( Item item) const
inline

Returns the cached position of this form element for the specified item.

◆ regions()

QList< ItemRegion > Visualization::FormElement::regions ( DeclarativeItemBase item,
int  parentX = 0,
int  parentY = 0 
)
virtual

Method called inside the item's regions method and returns cursor and item regions of all contained form elements for this item.

parentX and parentY are the offsets that this element needs to have from the parent item (similar to the setItemPositions method).

Reimplemented in Visualization::ItemWrapperFormElement< ParentType, ChildItemType >.

◆ removeChild()

void Visualization::FormElement::removeChild ( FormElement child)
protected

Removes a child from the list of children.

◆ rightMargin()

int Visualization::FormElement::rightMargin ( )
inlineprotected

Returns the right margin.

◆ setBottomMargin()

FormElement * Visualization::FormElement::setBottomMargin ( int  bottom)
inline

Sets the bottom margin of this form element.

Returns a pointer to this FormElement.

◆ setFormRoot()

FormElement * Visualization::FormElement::setFormRoot ( )

Sets this element to be a formRoot.

◆ setItemPositions()

void Visualization::FormElement::setItemPositions ( Item item,
int  parentX = 0,
int  parentY = 0 
)
virtual

Method called inside the item's updateGeometry method to recursively position it's child items relative to the item's position.

parentX and parentY are the offsets that this form element needs to have from the parent item. The element then puts its children at this offset plus the offset for its children relative to itself.

Reimplemented in Visualization::ItemWrapperFormElement< ParentType, ChildItemType >.

◆ setLeftMargin()

FormElement * Visualization::FormElement::setLeftMargin ( int  left)
inline

Sets the left margin of this form element.

Returns a pointer to this form Element.

◆ setMargins() [1/2]

FormElement * Visualization::FormElement::setMargins ( int  left,
int  top,
int  right,
int  bottom 
)
inline

Sets the left, top, right and bottom margins to the respective values.

Returns a pointer to this FormElement.

◆ setMargins() [2/2]

FormElement * Visualization::FormElement::setMargins ( int  margin)
inline

Sets all the margins of this form element to the value specified as margin.

Returns a pointer to this FormElement.

◆ setPos()

void Visualization::FormElement::setPos ( Item item,
const QPoint &  position 
)
inline

Caches the position of this form element for the specified item.

◆ setRightMargin()

FormElement * Visualization::FormElement::setRightMargin ( int  right)
inline

Sets the right margin of this form element.

Returns a pointer to this FormElement.

◆ setSize()

void Visualization::FormElement::setSize ( Item item,
const QSize &  size 
)
inlineprotected

Caches the size of this form element for the specified item.

◆ setTopMargin()

FormElement * Visualization::FormElement::setTopMargin ( int  top)
inline

Sets the top margin of this form element.

Returns a pointer to this FormElement.

◆ shapeElements()

QList< FormElement * > Visualization::FormElement::shapeElements ( )
virtual

Returns the list of shape elements inside this form element.

Recursively collects the shape elements from the element's children. Method is called once after the static initialization of the visualization item type.

Reimplemented in Visualization::ShapeFormElement.

◆ size()

QSize Visualization::FormElement::size ( Item item) const
inline

Returns the cached size of this form element for the specified item.

◆ sizeDependsOnParent()

virtual bool Visualization::FormElement::sizeDependsOnParent ( const Item item) const
pure virtual

Method called inside the item's sizeDependsOnParent method, and by some layout form elements.

If the form element returns true it can be, that computeSize is called on it a second time with non-zero availableWidth and availableHeight.

Implemented in Visualization::ShapeFormElement, Visualization::ItemWrapperFormElement< ParentType, ChildItemType >, and Visualization::BorderFormElement.

◆ synchronizeWithItem()

void Visualization::FormElement::synchronizeWithItem ( Item item)
virtual

Method called inside the item's determineChildren method to let the form element and it's children update their information about items and nodes belonging to this item.

If any nodes or child items changed, this method allows the item wrappers and sequential layout to reflect those changes.

Reimplemented in Visualization::VisualizationItemWrapperFormElement< ParentType, VisualizationType, externalSynchronization >, Visualization::NodeWithVisualizationItemWrapperFormElement< ParentType, VisualizationType >, and Visualization::NodeItemWrapperFormElement< ParentType >.

◆ topMargin()

int Visualization::FormElement::topMargin ( )
inlineprotected

Returns the top margin.

◆ width()

int Visualization::FormElement::width ( Item item) const
inline

Returns the cached width of this form element for the specified item.

◆ x()

int Visualization::FormElement::x ( Item item) const
inline

Returns the cached position on the x-axis of this form element for the specified item.

◆ xEnd()

int Visualization::FormElement::xEnd ( Item item) const
inline

Returns the cached position on the x-axis where this form element ends for the specified item.

That is the position on the x-axis + width.

◆ y()

int Visualization::FormElement::y ( Item item) const
inline

Returns the cached position on the y-axis of this form element for the specified item.

◆ yEnd()

int Visualization::FormElement::yEnd ( Item item) const
inline

Returns the cached position on the y-axis where this form element ends for the specified item.

That is the position on the y-axis + height.

Member Data Documentation

◆ children_

QVector<FormElement*> Visualization::FormElement::children_ {}
private

◆ elementCache_

QHash<const Item*, ElementCache*> Visualization::FormElement::elementCache_ {}
mutableprivate

◆ isFormRoot_

bool Visualization::FormElement::isFormRoot_ {}
private

◆ marginBottom_

int Visualization::FormElement::marginBottom_ {}
private

◆ marginLeft_

int Visualization::FormElement::marginLeft_ {}
private

◆ marginRight_

int Visualization::FormElement::marginRight_ {}
private

◆ marginTop_

int Visualization::FormElement::marginTop_ {}
private

◆ parent_

FormElement* Visualization::FormElement::parent_ {}
private