libyui  3.4.2
YLayoutBox Class Referenceabstract

A vertical or horizontal stacking of widgets, implementing HBox and VBox. More...

#include <YLayoutBox.h>

Inheritance diagram for YLayoutBox:
YWidget

Public Types

typedef std::vector< int > sizeVector
 
typedef std::vector< int > posVector
 

Public Member Functions

virtual ~YLayoutBox ()
 Destructor.
 
virtual const char * widgetClass () const
 Returns a descriptive name of this widget class for logging, debugging etc.
 
YUIDimension primary () const
 Return the primary dimension, i.e., the dimension this LayoutBox lays out its children in: YD_VERT for a VBox, YD_HORIZ for a HBox.
 
YUIDimension secondary () const
 Return the secondary dimension.
 
bool debugLayout () const
 Returns 'true' if layout debugging (verbose logging during layout) is on.
 
void setDebugLayout (bool deb=true)
 Enable or disable layout debugging.
 
virtual int preferredSize (YUIDimension dim)
 Preferred size of the widget in the specified dimension. More...
 
virtual int preferredWidth ()
 Preferred width of the widget. More...
 
virtual int preferredHeight ()
 Preferred height of the widget. More...
 
virtual void setSize (int newWidth, int newHeight)
 Sets the size of the layout box. More...
 
virtual bool stretchable (YUIDimension dimension) const
 Returns the stretchability of the layout box: The layout box is stretchable if one of the children is stretchable in this dimension or if one of the child widgets has a layout weight in this dimension. More...
 
virtual void moveChild (YWidget *child, int newX, int newY)=0
 Move a child to a new position. More...
 
- Public Member Functions inherited from YWidget
virtual ~YWidget ()
 Destructor.
 
virtual std::string debugLabel () const
 Returns a descriptive label of this widget instance. More...
 
std::string helpText () const
 Return the help text for this widget.
 
void setHelpText (const std::string &helpText)
 Set a help text for this widget. More...
 
virtual const YPropertySetpropertySet ()
 Return this class's property set. More...
 
virtual bool setProperty (const std::string &propertyName, const YPropertyValue &val)
 Set a property. More...
 
virtual YPropertyValue getProperty (const std::string &propertyName)
 Get a property. More...
 
bool hasChildren () const
 Returns 'true' if this widget has any children.
 
YWidgetfirstChild () const
 Returns the first child or 0 if there is none. More...
 
YWidgetlastChild () const
 Returns the last child or 0 if there is none.
 
YWidgetListIterator childrenBegin () const
 Return an iterator that points to the first child or to childrenEnd() if there are no children.
 
YWidgetListIterator childrenEnd () const
 Return an interator that points after the last child.
 
YWidgetListConstIterator childrenConstBegin () const
 Return a const iterator that points to the first child or to childrenEnd() if there are no children.
 
YWidgetListConstIterator childrenConstEnd () const
 Return a const interator that points after the last child.
 
YWidgetListIterator begin ()
 A helper for the range-based "for" loop. More...
 
YWidgetListIterator end ()
 A helper for the range-based "for" loop. More...
 
int childrenCount () const
 Returns the current number of children.
 
bool contains (YWidget *child) const
 Checks if 'child' is a (direct!) child of this widget.
 
virtual void addChild (YWidget *child)
 Add a new child. More...
 
virtual void removeChild (YWidget *child)
 Remove a child. More...
 
void deleteChildren ()
 Delete all children and remove them from the children manager's list.
 
YWidgetparent () const
 Return this widget's parent or 0 if it doesn't have a parent.
 
bool hasParent () const
 Return 'true' if this widget has a parent, 'false' if not.
 
void setParent (YWidget *newParent)
 Set this widget's parent.
 
YDialogfindDialog ()
 Traverse up the widget hierarchy and find the dialog this widget belongs to. More...
 
YWidgetfindWidget (YWidgetID *id, bool doThrow=true) const
 Recursively find a widget by its ID. More...
 
bool isValid () const
 Checks whether or not this object is valid. More...
 
bool beingDestroyed () const
 Check if this widget is in the process of being destroyed.
 
void * widgetRep () const
 Return a pointer to the underlying toolkit's (Qt, ...) widget representing this abstract UI widget.
 
void setWidgetRep (void *toolkitWidgetRep)
 Set the pointer to the underlying toolkit's (Qt, ...) widget representing this abstract UI widget. More...
 
bool hasId () const
 Returns 'true' if this widget has an ID.
 
YWidgetIDid () const
 Returns this widget's ID.
 
void setId (YWidgetID *newId_disown)
 Set this widget's ID. More...
 
virtual void setEnabled (bool enabled=true)
 Enable or disable this widget, i.e. More...
 
void setDisabled ()
 Disable this widget (overloaded for better readability).
 
virtual bool isEnabled () const
 Returns 'true' if this widget is enabled.
 
void setStretchable (YUIDimension dim, bool newStretch)
 Set the stretchable state to "newStretch" regardless of any hstretch or vstretch options.
 
void setDefaultStretchable (YUIDimension dim, bool newStretch)
 Set the stretchable state to "newStretch". More...
 
virtual int weight (YUIDimension dim)
 The weight is used in situations where all widgets can get their preferred size and yet space is available. More...
 
bool hasWeight (YUIDimension dim)
 Return whether or not the widget has a weight in the specified dimension.
 
void setWeight (YUIDimension dim, int weight)
 Set a weight in the specified dimension.
 
void setNotify (bool notify=true)
 Sets the Notify property.
 
bool notify () const
 Returns whether the widget will notify, i.e. More...
 
void setNotifyContextMenu (bool notifyContextMenu=true)
 Sets the notifyContextMenu property.
 
bool notifyContextMenu () const
 Returns whether the widget will send an event when the user clicks selects the context menu e.g. More...
 
bool sendKeyEvents () const
 Returns 'true' if this widget should send key events, i.e. More...
 
void setSendKeyEvents (bool doSend)
 Specify whether or not this widget should send key events.
 
bool autoShortcut () const
 Returns 'true' if a keyboard shortcut should automatically be assigned to this widget - without complaints in the log file.
 
void setAutoShortcut (bool _newAutoShortcut)
 Sets the 'autoShortcut' flag.
 
int functionKey () const
 Return a function key number that is assigned to this widget. More...
 
bool hasFunctionKey () const
 Check if a function key is assigned to this widget.
 
virtual void setFunctionKey (int fkey_no)
 Assign a function key to this widget (1 for F1, 2 for F2, etc. More...
 
virtual bool setKeyboardFocus ()
 Set the keyboard focus to this widget. More...
 
virtual std::string shortcutString () const
 Get the string of this widget that holds the keyboard shortcut, if any. More...
 
virtual void setShortcutString (const std::string &str)
 Set the string of this widget that holds the keyboard shortcut, if any. More...
 
virtual const char * userInputProperty ()
 The name of the widget property that will return user input, if there is any. More...
 
void dumpWidgetTree (int indentationLevel=0)
 Debugging function: Dump the widget tree from here on to the log file.
 
void dumpDialogWidgetTree ()
 Debugging function: Dump the widget tree from this widget's dialog parent. More...
 
void setChildrenEnabled (bool enabled)
 Enable or disable all widgets in this widget tree.
 
virtual void saveUserInput (YMacroRecorder *macroRecorder)
 Recursively save the user input of all child widgets to a macro recorder: More...
 
void * operator new (size_t size)
 Overloaded operator new to ensure widgets are always created on the heap, never on the stack. More...
 
virtual void startMultipleChanges ()
 In some UIs updating the screen content is an expensive operation. More...
 
virtual void doneMultipleChanges ()
 

Static Public Member Functions

static bool isLayoutStretch (YWidget *child, YUIDimension dimension)
 Check if this is a layout stretch widget in the specfied dimension, i.e. More...
 

Protected Member Functions

 YLayoutBox (YWidget *parent, YUIDimension dim)
 Constructor. More...
 
int childrenTotalWeight (YUIDimension dimension)
 Add up all the children's weights.
 
int childrenMaxPreferredSize (YUIDimension dimension)
 Return the maximum preferred size of all children in the specified dimension.
 
int totalNonWeightedChildrenPreferredSize (YUIDimension dimension)
 Add up all the non-weighted children's preferred sizes in the specified dimension.
 
int countNonWeightedChildren (YUIDimension dimension)
 Count the number of non-weighted children.
 
int countStretchableChildren (YUIDimension dimension)
 Count the number of stretchable ( non-weighted ) children. More...
 
int countLayoutStretchChildren (YUIDimension dimension)
 Count the number of "rubber bands", i.e. More...
 
YWidgetfindDominatingChild ()
 Determine the number of the "dominating child" - the child widget that determines the overall size with respect to its weight. More...
 
void calcPrimaryGeometry (int newSize, sizeVector &childSize, posVector &childPos)
 Calculate the sizes and positions of all children in the primary dimension and store them in "childSize" and "childPos".
 
void calcSecondaryGeometry (int newSize, sizeVector &childSize, posVector &childPos)
 Calculate the sizes and positions of all children in the secondary dimension and store them in "childSize" and "childPos".
 
void doResize (sizeVector &width, sizeVector &height, posVector &x_pos, posVector &y_pos)
 Actually perform resizing and moving the child widgets to the appropriate position. More...
 
- Protected Member Functions inherited from YWidget
 YWidget (YWidget *parent)
 Constructor.
 
YWidgetChildrenManagerchildrenManager () const
 Returns this widget's children manager.
 
void setChildrenManager (YWidgetChildrenManager *manager)
 Sets a new children manager for this widget. More...
 
void setBeingDestroyed ()
 Set the "being destroyed" flag, i.e. More...
 
void dumpWidget (YWidget *w, int indentationLevel)
 Helper function for dumpWidgetTree(): Dump one widget to the log file.
 

Detailed Description

A vertical or horizontal stacking of widgets, implementing HBox and VBox.

Definition at line 37 of file YLayoutBox.h.

Constructor & Destructor Documentation

◆ YLayoutBox()

YLayoutBox::YLayoutBox ( YWidget parent,
YUIDimension  dim 
)
protected

Constructor.

Creates a VBox for dim == YD_VERT or a HBox for YD_HORIZ.

Definition at line 66 of file YLayoutBox.cc.

Member Function Documentation

◆ countLayoutStretchChildren()

int YLayoutBox::countLayoutStretchChildren ( YUIDimension  dimension)
protected

Count the number of "rubber bands", i.e.

the number of stretchable layout spacings ( e.g. {H|V}Weight, {H|V}Spacing ). Only those without a weight are counted.

Definition at line 315 of file YLayoutBox.cc.

◆ countStretchableChildren()

int YLayoutBox::countStretchableChildren ( YUIDimension  dimension)
protected

Count the number of stretchable ( non-weighted ) children.

Note: Weighted children are always considered stretchable.

Definition at line 297 of file YLayoutBox.cc.

◆ doResize()

void YLayoutBox::doResize ( sizeVector &  width,
sizeVector &  height,
posVector &  x_pos,
posVector &  y_pos 
)
protected

Actually perform resizing and moving the child widgets to the appropriate position.

The vectors passed are the sizes previously calculated by calcPrimaryGeometry() and calcSecondaryGeometry().

Definition at line 746 of file YLayoutBox.cc.

◆ findDominatingChild()

YWidget * YLayoutBox::findDominatingChild ( )
protected

Determine the number of the "dominating child" - the child widget that determines the overall size with respect to its weight.

Return 0 if there is no dominating child, i.e. none of the children has a weight specified.

Definition at line 185 of file YLayoutBox.cc.

◆ isLayoutStretch()

bool YLayoutBox::isLayoutStretch ( YWidget child,
YUIDimension  dimension 
)
static

Check if this is a layout stretch widget in the specfied dimension, i.e.

an empty widget that is stretchable.

Definition at line 333 of file YLayoutBox.cc.

◆ moveChild()

virtual void YLayoutBox::moveChild ( YWidget child,
int  newX,
int  newY 
)
pure virtual

Move a child to a new position.

Derived classes are required to implement this.

◆ preferredHeight()

int YLayoutBox::preferredHeight ( )
virtual

Preferred height of the widget.

Reimplemented from YWidget.

Implements YWidget.

Definition at line 165 of file YLayoutBox.cc.

◆ preferredSize()

int YLayoutBox::preferredSize ( YUIDimension  dim)
virtual

Preferred size of the widget in the specified dimension.

Reimplemented from YWidget.

Reimplemented from YWidget.

Definition at line 111 of file YLayoutBox.cc.

◆ preferredWidth()

int YLayoutBox::preferredWidth ( )
virtual

Preferred width of the widget.

Reimplemented from YWidget.

Implements YWidget.

Definition at line 159 of file YLayoutBox.cc.

◆ setSize()

void YLayoutBox::setSize ( int  newWidth,
int  newHeight 
)
virtual

Sets the size of the layout box.

This is where the layout policy is implemented.

Derived classes can reimplement this, but this base class method should be called in the reimplemented function.

Reimplemented from YWidget.

Implements YWidget.

Definition at line 365 of file YLayoutBox.cc.

◆ stretchable()

bool YLayoutBox::stretchable ( YUIDimension  dimension) const
virtual

Returns the stretchability of the layout box: The layout box is stretchable if one of the children is stretchable in this dimension or if one of the child widgets has a layout weight in this dimension.

Reimplemented from YWidget.

Reimplemented from YWidget.

Definition at line 349 of file YLayoutBox.cc.


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