Laxkit  0.0.7.1
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
Laxkit::RowColBox Class Reference

Divvies up the child boxes into multiple rows or columns. More...

Inheritance diagram for Laxkit::RowColBox:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 RowColBox (unsigned int nflags, int nx, int nw, int npw, int nws, int nwg, int nhalign, int nhgap, int ny, int nh, int nph, int nhs, int nhg, int nvalign, int nvgap)
 Main RowColBox constructor.
virtual void Push (SquishyBox *box, char islocal=0, int where=-1)
 Push box onto wholelist with islocal.
virtual int Pop (int which=-1)
 Remove box with index which from wholelist.
virtual void Flush ()
 Flush list, and if list does not exist, then create a new list.
virtual int arrangeBoxes (int distributetoo=0)
 Set up SquishyBox::list to contain rows and columns based on boxes in wholelist.
virtual int distributeBoxes (int setmetrics=0)
 Assign the x,y,w,h of the child boxes.
- Public Member Functions inherited from Laxkit::ListBox
 ListBox (unsigned int flag=0)
 Create box as either BOX_VERTICAL or BOX_HORIZONTAL. Other flag values are ignored.
 ListBox (unsigned int nflags, int nx, int nw, int npw, int nws, int nwg, int nhalign, int nhgap, int ny, int nh, int nph, int nhs, int nhg, int nvalign, int nvgap)
virtual int WrapToExtent ()
 Sets this->pw,s,g/ph,s,g to be the sum of the metrics of the boxes in list.
virtual void sync ()
 Sync the box to the already set values of x,y,w,h.
virtual int figureDimensions (ListBox *target, int *nextrow=NULL, SquishyBox **boxes=NULL, int n=0, double *squishx=NULL, double *squishy=NULL)
 Finds pw,s,g/ph,s,g based on the boxes in list.
- Public Member Functions inherited from Laxkit::SquishyBox
 SquishyBox (unsigned int nflags, int nx, int nw, int npw, int nws, int nwg, int nhalign, int nhgap, int ny, int nh, int nph, int nhs, int nhg, int nvalign, int nvgap)
 SquishyBox Constructor.
virtual int hideBox (int yeshide)
 hideBox(0) makes the box visible, otherwise, make it hidden. Returns state after call.
virtual int hidden ()
 Return whether the box is hidden or not.
virtual void sync (int xx, int yy, int ww, int hh)
 Sync the box to x,y,w,h.
virtual int x ()
virtual int w ()
virtual int pw ()
virtual int ws ()
virtual int wg ()
virtual int halign ()
virtual int hgap ()
virtual int y ()
virtual int h ()
virtual int ph ()
virtual int hs ()
virtual int hg ()
virtual int valign ()
virtual int vgap ()
virtual int x (int val)
virtual int w (int val)
virtual int pw (int val)
virtual int ws (int val)
virtual int wg (int val)
virtual int halign (int val)
virtual int hgap (int val)
virtual int y (int val)
virtual int h (int val)
virtual int ph (int val)
virtual int hs (int val)
virtual int hg (int val)
virtual int valign (int val)
virtual int vgap (int val)
virtual int fpenalty ()
virtual int fpenalty (int val)
virtual int lpenalty ()
virtual int lpenalty (int val)

Public Attributes

unsigned int elementflags
- Public Attributes inherited from Laxkit::ListBox
PtrStack< SquishyBoxlist
- Public Attributes inherited from Laxkit::SquishyBox
int m [14]
int pad
 Pad placed around a box, which can be where a bevel or window border would go.
int padinset
 Pad to inset the child boxes.
int fpen
 The penalty in the flow direction.
int lpen
 The penalty perpendicular to the flow direction.
unsigned long flags

Protected Member Functions

virtual ListBoxnewSubBox ()
 Return a new box that holds a whole row or column.
virtual void filterflags ()
 Take what is in flags, and remake flags to be reasonable for a RowColBox.

Protected Attributes

PtrStack< SquishyBoxwholelist
 The master list of boxes.
int arrangedstate

Detailed Description

Divvies up the child boxes into multiple rows or columns.

This class redefines ListBox's storage and arrange mechanism to separate a list of boxes into multiple rows and columns by fitting boxes until the total preferred width is greater than the actual width. If a sequence of boxes can be compressed to fit on the line and remain in its squish zone, then it is, otherwise the boxes up to but not including the one causing the overflow are designated for that row, and the next row gets configured.

Todo:

*** need to debug laying out where boxes put in fixed width, but the whole height wraps to the vertical extent of the child boxes

*** would be nice to auto layout in multiple columns if the boxes allow it.

*** need to incorporate internal creation of sub-rows and columns... maybe that should only be done in subclasses? it is easy enough to push a new SquishyBox, but classes like RowFrame have special needs..


Constructor & Destructor Documentation

Laxkit::RowColBox::RowColBox ( unsigned int  nflags,
int  nx,
int  nw,
int  npw,
int  nws,
int  nwg,
int  nhalign,
int  nhgap,
int  ny,
int  nh,
int  nph,
int  nhs,
int  nhg,
int  nvalign,
int  nvgap 
)

Main RowColBox constructor.

This screens nflags and changes it to values appropriate to a RowColBox. To rephrase that, the flags you pass in are likely not exactly what is in flags after the constructor finishes. See filterflags().

References filterflags().


Member Function Documentation

int Laxkit::RowColBox::arrangeBoxes ( int  distributetoo = 0)
virtual

Set up SquishyBox::list to contain rows and columns based on boxes in wholelist.

If BOX_VERTICAL, it lays out rows then columns, otherwise it lays out columns then rows. This preserves the meaning of that from a normal ListBox.

Assumes that w/h are already set.

On success arrangedstate is set to 1 and 0 is returned, otherwise arrangedstate is set to 0 and 1 is returned.

Todo:
*** should implement all 8 LRTB, LRBT, ... Currently horizontal is only LRTB, and vertical is only TBLR.

Reimplemented from Laxkit::ListBox.

References distributeBoxes(), Laxkit::PtrStack< T >::e, Laxkit::ListBox::figureDimensions(), Laxkit::PtrStack< T >::flush(), Laxkit::PtrStack< T >::n, newSubBox(), Laxkit::PtrStack< T >::push(), Laxkit::ListBox::Push(), and wholelist.

Referenced by Laxkit::MessageBox::preinit().

int Laxkit::RowColBox::distributeBoxes ( int  setmetrics = 0)
virtual

Assign the x,y,w,h of the child boxes.

This->x,y,w,h should all already be set.

If arrangedstate!=1, then arrangeBoxes is called, which on success does set arrangedstate to 1. Otherwise this simply calls SquishyBox::distributeBoxes().

Reimplemented from Laxkit::ListBox.

Referenced by arrangeBoxes().

void Laxkit::RowColBox::filterflags ( )
protectedvirtual

Take what is in flags, and remake flags to be reasonable for a RowColBox.

Default for laying rows is for the main list to always stretch row->w (but not necessarily to stretch the actual elements), and h when laying columns. If STRETCH_TO_FILL* was set in flags before calling filterflags(), then those bits are copied to elementflags, and also stay in flags of this.

elementflags are used in newSubBox() to help set the flags for boxes that contain the rows

Referenced by RowColBox().

ListBox * Laxkit::RowColBox::newSubBox ( )
protectedvirtual

Return a new box that holds a whole row or column.

For RowCols that have rows, this returns a box that wraps to y, and stretches x, and vice versa for a columns box.

Consults elementflags to see whether individual boxes should be stretched or spaced within an extra space. For instance when laying out rows, a row might have many different heights of boxes, element flags would indicate whether to stretch the boxes to fill the height. Width stretching in this case is determined by the usual bits of flags, not elementflags. Vice versa for laying out columns.

References Laxkit::ListBox::ListBox(), and Laxkit::SquishyBox::padinset.

Referenced by arrangeBoxes().

int Laxkit::RowColBox::Pop ( int  which = -1)
virtual

Remove box with index which from wholelist.

Default (when which==-1) is to remove the top of the wholelist.

Reimplemented from Laxkit::ListBox.

References Laxkit::PtrStack< T >::remove(), and wholelist.

Referenced by Laxkit::FileDialog::ClearFinalButton().

void Laxkit::RowColBox::Push ( SquishyBox box,
char  islocal = 0,
int  where = -1 
)
virtual

Push box onto wholelist with islocal.

If box==NULL, then this is later on interpreted as a line break.

Sets arrangedstate=0. Nothing is added to list here. list is maintained in arrangeBoxes().

If islocal==0, then do not delete the box when removed. Otherwise, this RowColBox takes possession of the box, and will delete it when no longer needed.

Reimplemented from Laxkit::ListBox.

References Laxkit::PtrStack< T >::push(), and wholelist.

Referenced by Laxkit::RowFrame::AddNull(), and Laxkit::RowFrame::AddWin().


Member Data Documentation

PtrStack< SquishyBox > Laxkit::RowColBox::wholelist
protected

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

Mon Feb 17 2014 11:52:59, Laxkit