Laxkit
0.0.7.1
|
Divvies up the child boxes into multiple rows or columns. More...
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< SquishyBox > | list |
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 ListBox * | newSubBox () |
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< SquishyBox > | wholelist |
The master list of boxes. | |
int | arrangedstate |
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.
*** 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..
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().
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.
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().
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().
|
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().
|
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().
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().
|
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().
|
protected |
The master list of boxes.
this->list contains the arranged rows of the RowColBox. Each element of list is a list of box pointers that point to the elements of wholelist. When adding, popping and flushing, the actions are performend on wholelist rather than list.
Referenced by Laxkit::IconSelector::AddBox(), Laxkit::PrintDialog::addOptions(), Laxkit::TabFrame::AddWin(), arrangeBoxes(), Laxkit::FileDialog::ClearFinalButton(), Laxkit::IconSelector::drawbox(), Laxkit::BoxSelector::Event(), Laxkit::FileDialog::FileDialog(), Laxkit::RowFrame::findWindow(), Laxkit::RowFrame::findWindowIndex(), Flush(), Laxkit::SimplePrint::init(), Laxkit::TabFrame::init(), Laxkit::FileDialog::init(), Laxkit::BoxSelector::LBDown(), Laxkit::TabFrame::mapWindow(), Laxkit::BoxSelector::MouseInWhich(), Laxkit::BoxSelector::MouseMove(), Laxkit::FileDialog::OkButton(), Laxkit::Overwrite::Overwrite(), Pop(), Push(), Laxkit::BoxSelector::Refresh(), Laxkit::BoxSelector::Select(), Laxkit::TabFrame::SelectN(), Laxkit::BoxSelector::SelectN(), Laxkit::BoxSelector::send(), Laxkit::RowFrame::Sync(), Laxkit::BoxSelector::sync(), Laxkit::BoxSelector::togglebox(), Laxkit::TabFrame::WheelDown(), and Laxkit::TabFrame::WheelUp().