Laxkit
0.0.7.1
|
A box with x,y,w,h, prefered w/h, and allowable shrink and expand values for w/h. More...
Public Member Functions | |
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 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 (int xx, int yy, int ww, int hh) |
Sync the box to x,y,w,h. | |
virtual void | sync () |
Sync the box to the already set values of 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 | |
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 |
A box with x,y,w,h, prefered w/h, and allowable shrink and expand values for w/h.
Usually, you will set the preferred width, shrink, grow, align, and gap, and the box sync() process will automatically compute the x,y, and actual width and height.
Say a box's preferred width is 5, and it has a shrink of 3 and a grow of 4, then the squish zone, or the acceptable actual width, of the box is somewhere in the range [2,9] (from 2 to 9 inclusive).
Also keeps track of preferred per-box vertical and horizontal alignment within any extra space that results when the box must fit in a space that is outside its squish zone. This is particularly meant for aligning in extra space in a table cell, or when laying out rows valign is used, when laying out columns, halign is used. The typical values for v/halign range 0 to 100. 100 means top align, 0 means bottom, 50 centers, everything else does the proportional thing. A super-duper feature that is not implemented would be to have aligning to a baseline.
The base SquishyBox only has metric information. ListBox is a box, with a list of internal boxes. This list can be either a horizontal or vertical list (flags has BOX_HORIZONTAL (the default) or BOX_VERTICAL), with descriptive options held in flags. More complicated arrangements are made with other derived classes, notably RowColBox and TableBox.
This is a moderately adaptible structure to hold info to lay out windows and icons nicely. It is simplification of the box-glue-penalty format of TeX. Penalties are restricted to nothing special (==0), force line break (<0), and never line break (>0). The glue and box are also roughly combined into this class, such that one would always have box(w1)-(no break)-glue(w2,s,g), and the glue's width, shrink and grow are always used. In TeX, the glue acts like the space between words, but here, the boxes all kind of but up against each other. So anyway.
The horizontal and vertical metric information is stored in the m array, with the horizontal values first (x,w,pw,ws,wg,halign,hgap), followed by the vertical values (y,h,ph,hs,hg,valign,vgap). The penalty is stored in fpen (penalty in the flow direction) and lpen (penalty in the line direction).
To sum up:
m, holds horizontal and vertical metric information pad = analogous to a window border: space around the box. say pad==5, and the box's x,y,w,h are (0,0,10,20), then the box+pad fills a rectangle (x,y,w,h)=(-5,-5,20,30) padinset = space within the box to inset child boxes fpen = penalty in the flow direction: 0=nothing, <0 force break, >0 never break lpen = would be penalty in direction of the next line
The following all go in SquishyBox::flags:
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.
nflags | See above for BOX_* flags |
nx | New x position |
nw | New width |
npw | New preferred width |
nws | New horizontal shrink |
nwg | New horizontal grow |
nhalign | New horizontal align, 0=bottom/right, 100=top/left, 50=center, etc. |
nhgap | New horizontal gap, ignored at edges |
ny | New y position |
nh | New height |
nph | New preferred height |
nhs | New vertical shrink |
nhg | New vertical grow |
nvalign | New vertical align, 0=bottom/right, 100=top/left, 50=center, etc. |
nvgap | New vertical gap, ignored at edges |
hideBox(0) makes the box visible, otherwise, make it hidden. Returns state after call.
Sync the box to x,y,w,h.
Currently, this always simply assigns x,y,w,h straight away, then calls sync(). This is just a shortcut to set the x,y,w,h. The end result must always be that it then calls sync().
When a window derived from a SquishyBox is resized, it would then call sync(0,0,win_w,win_h).
Referenced by Laxkit::ListBox::distributeBoxes(), and Laxkit::StackFrame::Sync().
|
virtual |
Sync the box to the already set values of x,y,w,h.
This is meant to be called only when a definite x,y,w,h have already been assigned for this SquishyBox, such as by its parent box, and *this must rearrange its contents according to the new dimensions.
Default here is to do nothing, since a plain SquishyBox has no contents.
Reimplemented in Laxkit::ListBox, Laxkit::BoxSelector, and Laxkit::WinFrameBox.
|
virtual |
Sets this->pw,s,g/ph,s,g to be the sum of the metrics of the boxes in list.
Note that it does NOT set this->x,y,w,h.
Default here is simply to return 0, since plain SquishyBox has no contents. Returns 0 success, nonzero error.
Reimplemented in Laxkit::ListBox, and Laxkit::StackFrame.
int Laxkit::SquishyBox::fpen |
The penalty in the flow direction.
Currently: 0 = nothing special.
>0 = never break a line after this box
<0 = always break a line after this box
Though in the future, this may change to be a truer response to penalties. You can use BOX_NO_BREAK (currently==1000000) and BOX_MUST_BREAK (currently==-1000000) to be safer against such future changes.
int Laxkit::SquishyBox::lpen |
The penalty perpendicular to the flow direction.
This value is currently ignored in the Laxkit.
int Laxkit::SquishyBox::pad |
Pad placed around a box, which can be where a bevel or window border would go.
This is ignored within the box, but containing boxes can use it to inset things properly.
Referenced by Laxkit::MessageBox::AddButton(), Laxkit::StackFrame::AddWin(), Laxkit::RowFrame::AddWin(), Laxkit::ListBox::distributeBoxes(), Laxkit::IconSelector::drawbox(), Laxkit::ListBox::figureDimensions(), Laxkit::IconSelector::FillBox(), Laxkit::StackFrame::findWhichBar(), Laxkit::BoxSelector::MouseInWhich(), and Laxkit::RowFrame::RowFrame().
int Laxkit::SquishyBox::padinset |
Pad to inset the child boxes.
If a box is 100 wide, and padinset=5, then the boxes are put in a space 90 wide.
Referenced by Laxkit::BoxSelector::BoxSelector(), Laxkit::ListBox::distributeBoxes(), Laxkit::ListBox::figureDimensions(), Laxkit::MessageBox::MessageBox(), Laxkit::RowColBox::newSubBox(), and Laxkit::RowFrame::RowFrame().