Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

csLayout Class Reference

csLayout is our baseclass for various derived classes like csFlowLayout, csBoxLayout, csGridBagLayout and others. More...

#include <cslayout.h>

Inheritance diagram for csLayout:

csDialog csComponent csAbsoluteLayout csBoxLayout csFlowLayout csGridLayout csLayout2 List of all members.

Public Types

enum  LAYOUTING_PHASES { PHASE_0 = 0, PHASE_1 = 1 }

Public Methods

 csLayout (csComponent *iParent, csDialogFrameStyle iFrameStyle=csdfsNone)
virtual csLayoutConstraintAddLayoutComponent (csComponent *comp)
 A components is added to a layout by creating it and passing the layout component as its parent component. More...

virtual void RemoveLayoutComponent (csComponent *comp)
 remove a component from the layout.

virtual void SuggestSize (int &sugw, int &sugh)=0
 return best size for this layout.

virtual void LayoutContainer ()=0
 recalc positions and sizes of components.

virtual void InvalidateLayout ()
 make sure next time the layout is drawn the components are layed out first.

virtual int GetLayoutingPhase ()
 return current phase of layouting.

virtual void SetLayoutingPhase (int phase)
 set current phase of layouting.

virtual csPoint GetPhase0Size ()
 save size of first phase for later reference.

virtual bool TwoPhaseLayoutingEnabled ()
 is the two phase layouting enabled ?

virtual void Insert (csComponent *child)
 new impl. for csComponent.

virtual bool HandleEvent (iEvent &Event)
 Handle input events.

virtual void Draw ()
 Draw the component (only dirty rectangle should be redrawn).

virtual bool SetRect (int xmin, int ymin, int xmax, int ymax)
 Do auto-placement work if enabled.

virtual void FixSize (int &newWidth, int &newHeight)
 Fix dialog size when resizing.


Public Attributes

csRect insets
 preserve space at the 4 borders of a layout.

csLayoutConstraint c
 Here we have the constraint a components will be layout with. When a component is added a copy of this will be made and attached to the component.


Static Public Methods

void SetTwoPhaseLayoutingGlobally (bool on)
 enable or disable 2 phase layouting.


Protected Attributes

bool bRecalcLayout
 do we need to recalc the positions and sizes of placed components ?

csConstraintVector vConstraints
 collect all constraints here.

csLayoutConstraintlc
 a pointer to the current constraint.


Static Protected Attributes

bool mUseTwoPhaseLayoutingGlobally
 A shortcoming of the original java layouts is that components are asked for its preferred size without knowing at what size its parent component will be layout in the end. More...

int mCurrentLayoutingPhase

Detailed Description

csLayout is our baseclass for various derived classes like csFlowLayout, csBoxLayout, csGridBagLayout and others.

What are layouts for ?

Usually one designs dialogs, forms etc. by placing components like listcontrols, inputlines, treecontrols and so on at absolute locations inside the dialog. While this is fine for a fixed size of your dialog it turns out to be pretty ugly if you want allow resizing of dialogs, forms etc. A comparable ugly effect you achive by running an application in different window sizes.

Layouts will help you to overcome this drawback. They will allow you to relatively place a control and to resize components when necessary.

Layouts are themselfs csComponents and have a transparent canvas. Thus you will not note them. One important issue about layouts is that they will transfer all Events of type csevCommand to its parent control. This will allow you overwrite just one HandleEvent to receive all commands from the components embedded in the layouts no matter how deeply nested they are.


Member Function Documentation

csLayoutConstraint * csLayout::AddLayoutComponent ( csComponent * comp ) [virtual]
 

A components is added to a layout by creating it and passing the layout component as its parent component.

If you insist of doing some voodoo you should use AddLayoutComponent to add it to the layout.

 IN:  the component to add
 OUT: the constraint that is used to layout the component
      (a copy of variable c  see above)
 


Member Data Documentation

bool csLayout::mUseTwoPhaseLayoutingGlobally [static, protected]
 

A shortcoming of the original java layouts is that components are asked for its preferred size without knowing at what size its parent component will be layout in the end.

So the two phase layout is an attempt to overcome this. Currently only FlowLayout uses this.


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000