Added wxGridBagSizer, a grid sizer where item positions can be

specified and row/col spanning is allowed.

Updated docs, the layout sample, files.bkl, and updated makefiles.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24416 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-11-06 01:31:44 +00:00
parent 5d1000e7f1
commit 20b35a6916
32 changed files with 2198 additions and 259 deletions

View File

@@ -136,6 +136,7 @@ These are the classes relevant to sizer-based layout.
\twocolitem{\helpref{wxSizer}{wxsizer}}{Abstract base class}
\twocolitem{\helpref{wxGridSizer}{wxgridsizer}}{A sizer for laying out windows in a grid with all fields having the same size}
\twocolitem{\helpref{wxFlexGridSizer}{wxflexgridsizer}}{A sizer for laying out windows in a flexible grid}
\twocolitem{\helpref{wxGridBagSizer}{wxgridbagsizer}}{Another grid sizer that lets you specify the cell an item is in, and items can span rows and/or columns.}
\twocolitem{\helpref{wxBoxSizer}{wxboxsizer}}{A sizer for laying out windows in a row or column}
\twocolitem{\helpref{wxStaticBoxSizer}{wxstaticboxsizer}}{Same as wxBoxSizer, but with a surrounding static box}
\twocolitem{\helpref{wxNotebookSizer}{wxnotebooksizer}}{Sizer to use with the wxNotebook control}

View File

@@ -119,12 +119,16 @@
\input fsfile.tex
\input ftp.tex
\input gauge.tex
\input gbposition.tex
\input gbsizeritem.tex
\input gbspan.tex
\input gdiobj.tex
\input dirctrl.tex
\input valgen.tex
\input glcanvas.tex
\input grid.tex
\input gridattr.tex
\input gridbagsizer.tex
\input gridedit.tex
\input gridevt.tex
\input gridrend.tex
@@ -264,6 +268,7 @@
\input size.tex
\input sizeevt.tex
\input sizer.tex
\input sizeritem.tex
\input slider.tex
\input sckaddr.tex
\input socket.tex

View File

@@ -0,0 +1,64 @@
\section{\class{wxGBPosition}}\label{wxgbposition}
This class represents the position of an item in a virtual grid of
rows and columns managed by a \helpref{wxGridBagSizer}{wxgridbagsizer}.
\wxheading{Derived from}
No base class
\wxheading{Include files}
<wx/gbsizer.h>
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxGBPosition::wxGBPosition}\label{wxgbpositionwxgbposition}
\func{}{wxGBPosition}{\void}
\func{}{wxGBPosition}{\param{int }{row}, \param{int }{col}}
Construct a new wxGBPosition, optionally setting the row and column.
The default is (0,0).
\membersection{wxGBPosition::GetCol}\label{wxgbpositiongetcol}
\constfunc{int}{GetCol}{\void}
Get the current column value.
\membersection{wxGBPosition::GetRow}\label{wxgbpositiongetrow}
\constfunc{int}{GetRow}{\void}
Get the current row value.
\membersection{wxGBPosition::SetCol}\label{wxgbpositionsetcol}
\func{void}{SetCol}{\param{int }{col}}
Set a new column value.
\membersection{wxGBPosition::SetRow}\label{wxgbpositionsetrow}
\func{void}{SetRow}{\param{int }{row}}
Set a new row value.
\membersection{wxGBPosition::operator!}\label{wxgbpositionoperatorunknown}
\constfunc{bool}{operator!}{\param{const wxGBPosition\& }{p}}
Is the wxGBPosition valid? (An invalid wxGBPosition is (-1,-1). )
\membersection{wxGBPosition::operator==}\label{wxgbpositionoperatorequal}
\constfunc{bool operator}{operator==}{\param{const wxGBPosition\& }{p}}
Compare equality of two wxGBPositions.

View File

@@ -0,0 +1,102 @@
\section{\class{wxGBSizerItem}}\label{wxgbsizeritem}
The wxGBSizerItem class is used by the
\helpref{wxGridBagSizer}{wxgridbagsizer} for tracking the items in the
sizer. It adds grid position and spanning information to the normal
\helpref{wxSizerItem}{wxsizeritem} by adding
\helpref{wxGBPosition}{wxgbposition} and \helpref{wxGBSpan}{wxgbspan}
attrbibutes. Most of the time you will not need to use a
wxGBSizerItem directly in your code, but there are a couple of cases
where it is handy.
\wxheading{Derived from}
\helpref{wxSizerItem}{wxsizeritem}
\wxheading{Include files}
<wx/gbsizer.h>
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxGBSizerItem::wxGBSizerItem}\label{wxgbsizeritemwxgbsizeritem}
\func{}{wxGBSizerItem}{\param{int }{width}, \param{int }{height}, \param{const wxGBPosition\& }{pos}, \param{const wxGBSpan\& }{span}, \param{int }{flag}, \param{int }{border}, \param{wxObject* }{userData}}
Construct a sizer item for tracking a spacer.
\func{}{wxGBSizerItem}{\param{wxWindow* }{window}, \param{const wxGBPosition\& }{pos}, \param{const wxGBSpan\& }{span}, \param{int }{flag}, \param{int }{border}, \param{wxObject* }{userData}}
Construct a sizer item for tracking a window.
\func{}{wxGBSizerItem}{\param{wxSizer* }{sizer}, \param{const wxGBPosition\& }{pos}, \param{const wxGBSpan\& }{span}, \param{int }{flag}, \param{int }{border}, \param{wxObject* }{userData}}
Construct a sizer item for tracking a subsizer.
\membersection{wxGBSizerItem::GetEndPos}\label{wxgbsizeritemgetendpos}
\func{void}{GetEndPos}{\param{int\& }{row}, \param{int\& }{col}}
Get the row and column of the endpoint of this item
\membersection{wxGBSizerItem::GetPos}\label{wxgbsizeritemgetpos}
\constfunc{wxGBPosition}{GetPos}{\void}
\constfunc{void}{GetPos}{\param{int\& }{row}, \param{int\& }{col}}
Get the grid position of the item.
\membersection{wxGBSizerItem::GetSpan}\label{wxgbsizeritemgetspan}
\constfunc{wxGBSpan}{GetSpan}{\void}
\constfunc{void}{GetSpan}{\param{int\& }{rowspan}, \param{int\& }{colspan}}
Get the row and column spanning of the item.
\membersection{wxGBSizerItem::Intersects}\label{wxgbsizeritemintersects}
\func{bool}{Intersects}{\param{const wxGBSizerItem\& }{other}}
Returns true if this item and the other item instersect
\func{bool}{Intersects}{\param{const wxGBPosition\& }{pos}, \param{const wxGBSpan\& }{span}}
Returns true if the given pos/span would intersect with this item.
\membersection{wxGBSizerItem::SetPos}\label{wxgbsizeritemsetpos}
\func{bool}{SetPos}{\param{const wxGBPosition\& }{pos}}
If the item is already a member of a sizer then first ensure that
there is no other item that would intersect with this one at the new
position, then set the new position. Returns true if the change is
successful and after the next Layout the item will be moved.
\membersection{wxGBSizerItem::SetSpan}\label{wxgbsizeritemsetspan}
\func{bool}{SetSpan}{\param{const wxGBSpan\& }{span}}
If the item is already a member of a sizer then first ensure that
there is no other item that would intersect with this one with its new
spanning size, then set the new spanning. Returns true if the change
is successful and after the next Layout the item will be resized.

68
docs/latex/wx/gbspan.tex Normal file
View File

@@ -0,0 +1,68 @@
\section{\class{wxGBSpan}}\label{wxgbspan}
This class is used to hold the row and column spanning attributes of
items in a \helpref{wxGridBagSizer}{wxgridbagsizer}.
\wxheading{Derived from}
No base class
\wxheading{Include files}
<wx/gbsizer.h>
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxGBSpan::wxGBSpan}\label{wxgbspanwxgbspan}
\func{}{wxGBSpan}{\void}
\func{}{wxGBSpan}{\param{int }{rowspan}, \param{int }{colspan}}
Construct a new wxGBSpan, optionally setting the rowspan and colspan.
The default is (1,1). (Meaning that the item occupies one cell in
each direction.
\membersection{wxGBSpan::GetColspan}\label{wxgbspangetcolspan}
\constfunc{int}{GetColspan}{\void}
Get the current colspan value.
\membersection{wxGBSpan::GetRowspan}\label{wxgbspangetrowspan}
\constfunc{int}{GetRowspan}{\void}
Get the current rowspan value.
\membersection{wxGBSpan::SetColspan}\label{wxgbspansetcolspan}
\func{void}{SetColspan}{\param{int }{colspan}}
Set a new colspan value.
\membersection{wxGBSpan::SetRowspan}\label{wxgbspansetrowspan}
\func{void}{SetRowspan}{\param{int }{rowspan}}
Set a new rowspan value.
\membersection{wxGBSpan::operator!}\label{wxgbspanoperatorunknown}
\constfunc{bool}{operator!}{\param{const wxGBSpan\& }{o}}
Is the wxGBSpan valid? (An invalid wxGBPosition is (-1,-1). )
\membersection{wxGBSpan::operator==}\label{wxgbspanoperatorequal}
\constfunc{bool operator}{operator==}{\param{const wxGBSpan\& }{o}}
Compare equality of two wxGBSpans.

View File

@@ -0,0 +1,172 @@
\section{\class{wxGridBagSizer}}\label{wxgridbagsizer}
A \helpref{wxSizer}{wxsizer} that can lay out items in a virtual grid
like a \helpref{wxFlexGridSizer}{wxflexgridsizer} but in this case
explicit positioning of the items is allowed using
\helpref{wxGBPosition}{wxgbposition}, and items can optionally span
more than one row and/or column using \helpref{wxGBSpan}{wxgbspan}.
\wxheading{Derived from}
\helpref{wxFlexGridSizer}{wxflexgridsizer}
\wxheading{Include files}
<wx/gbsizer.h>
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxGridBagSizer::wxGridBagSizer}\label{wxgridbagsizerwxgridbagsizer}
\func{}{wxGridBagSizer}{\param{int }{vgap = 0}, \param{int }{hgap = 0}}
Constructor, with optional parameters to specify the gap between the
rows and columns.
\membersection{wxGridBagSizer::Add}\label{wxgridbagsizeradd}
\func{bool}{Add}{\param{wxWindow* }{window}, \param{const wxGBPosition\& }{pos}, \param{const wxGBSpan\& }{span = wxDefaultSpan}, \param{int }{flag = 0}, \param{int }{border = 0}, \param{wxObject* }{userData = NULL}}
\func{bool}{Add}{\param{wxSizer* }{sizer}, \param{const wxGBPosition\& }{pos}, \param{const wxGBSpan\& }{span = wxDefaultSpan}, \param{int }{flag = 0}, \param{int }{border = 0}, \param{wxObject* }{userData = NULL}}
\func{bool}{Add}{\param{int }{width}, \param{int }{height}, \param{const wxGBPosition\& }{pos}, \param{const wxGBSpan\& }{span = wxDefaultSpan}, \param{int }{flag = 0}, \param{int }{border = 0}, \param{wxObject* }{userData = NULL}}
\func{bool}{Add}{\param{wxGBSizerItem* }{item}}
The Add methods return true if the item was successfully placed at the
given position, false if something was already there.
\membersection{wxGridBagSizer::CalcMin}\label{wxgridbagsizercalcmin}
\func{wxSize}{CalcMin}{\void}
Called when the managed size of the sizer is needed or when layout
needs done.
\membersection{wxGridBagSizer::CheckForIntersection}\label{wxgridbagsizercheckforintersection}
\func{bool}{CheckForIntersection}{\param{wxGBSizerItem* }{item}, \param{wxGBSizerItem* }{excludeItem = NULL}}
\func{bool}{CheckForIntersection}{\param{const wxGBPosition\& }{pos}, \param{const wxGBSpan\& }{span}, \param{wxGBSizerItem* }{excludeItem = NULL}}
Look at all items and see if any intersect (or would overlap) the given
item. Returns true if so, false if there would be no overlap. If an
excludeItem is given then it will not be checked for intersection, for
example it may be the item we are checking the position of.
\membersection{wxGridBagSizer::FindItem}\label{wxgridbagsizerfinditem}
\func{wxGBSizerItem*}{FindItem}{\param{wxWindow* }{window}}
\func{wxGBSizerItem*}{FindItem}{\param{wxSizer* }{sizer}}
Find the sizer item for the given window or subsizer, returns NULL if
not found. (non-recursive)
\membersection{wxGridBagSizer::FindItemAtPosition}\label{wxgridbagsizerfinditematposition}
\func{wxGBSizerItem*}{FindItemAtPosition}{\param{const wxGBPosition\& }{pos}}
Return the sizer item for the given grid cell, or NULL if there is no
item at that position. (non-recursive)
\membersection{wxGridBagSizer::FindItemWithData}\label{wxgridbagsizerfinditemwithdata}
\func{wxGBSizerItem*}{FindItemWithData}{\param{const wxObject* }{userData}}
Return the sizer item that has a matching user data (it only compares
pointer values) or NULL if not found. (non-recursive)
\membersection{wxGridBagSizer::GetEmptyCellSize}\label{wxgridbagsizergetemptycellsize}
\constfunc{wxSize}{GetEmptyCellSize}{\void}
Get the size used for cells in the grid with no item.
\membersection{wxGridBagSizer::GetItemPosition}\label{wxgridbagsizergetitemposition}
\func{wxGBPosition}{GetItemPosition}{\param{wxWindow* }{window}}
\func{wxGBPosition}{GetItemPosition}{\param{wxSizer* }{sizer}}
\func{wxGBPosition}{GetItemPosition}{\param{size\_t }{index}}
Get the grid position of the specified item.
\membersection{wxGridBagSizer::GetItemSpan}\label{wxgridbagsizergetitemspan}
\func{wxGBSpan}{GetItemSpan}{\param{wxWindow* }{window}}
\func{wxGBSpan}{GetItemSpan}{\param{wxSizer* }{sizer}}
\func{wxGBSpan}{GetItemSpan}{\param{size\_t }{index}}
Get the row/col spanning of the specified item
\membersection{wxGridBagSizer::RecalcSizes}\label{wxgridbagsizerrecalcsizes}
\func{void}{RecalcSizes}{\void}
Called when the managed size of the sizer is needed or when layout
needs done.
\membersection{wxGridBagSizer::SetEmptyCellSize}\label{wxgridbagsizersetemptycellsize}
\func{void}{SetEmptyCellSize}{\param{const wxSize\& }{sz}}
Set the size used for cells in the grid with no item.
\membersection{wxGridBagSizer::SetItemPosition}\label{wxgridbagsizersetitemposition}
\func{bool}{SetItemPosition}{\param{wxWindow* }{window}, \param{const wxGBPosition\& }{pos}}
\func{bool}{SetItemPosition}{\param{wxSizer* }{sizer}, \param{const wxGBPosition\& }{pos}}
\func{bool}{SetItemPosition}{\param{size\_t }{index}, \param{const wxGBPosition\& }{pos}}
Set the grid position of the specified item. Returns true on success.
If the move is not allowed (because an item is already there) then
false is returned.
\membersection{wxGridBagSizer::SetItemSpan}\label{wxgridbagsizersetitemspan}
\func{bool}{SetItemSpan}{\param{wxWindow* }{window}, \param{const wxGBSpan\& }{span}}
\func{bool}{SetItemSpan}{\param{wxSizer* }{sizer}, \param{const wxGBSpan\& }{span}}
\func{bool}{SetItemSpan}{\param{size\_t }{index}, \param{const wxGBSpan\& }{span}}
Set the row/col spanning of the specified item. Returns true on
success. If the move is not allowed (because an item is already there)
then false is returned.

240
docs/latex/wx/sizeritem.tex Normal file
View File

@@ -0,0 +1,240 @@
\section{\class{wxSizerItem}}\label{wxsizeritem}
The wxSizerItem class is used to track the position, size and other
attributes of each item managed by a \helpref{wxSizer}{wxsizer}. In
normal usage user code should never need to deal directly with a
wxSizerItem, but derived sizer classes will.
\wxheading{Derived from}
\helpref{wxObject}{wxobject}
\wxheading{Include files}
<wx/sizer.h>
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxSizerItem::wxSizerItem}\label{wxsizeritemwxsizeritem}
\func{}{wxSizerItem}{\param{int }{width}, \param{int }{height}, \param{int }{proportion}, \param{int }{flag}, \param{int }{border}, \param{wxObject* }{userData}}
Construct a sizer item for tracking a spacer.
\func{}{wxSizerItem}{\param{wxWindow* }{window}, \param{int }{proportion}, \param{int }{flag}, \param{int }{border}, \param{wxObject* }{userData}}
Construct a sizer item for tracking a window.
\func{}{wxSizerItem}{\param{wxSizer* }{sizer}, \param{int }{proportion}, \param{int }{flag}, \param{int }{border}, \param{wxObject* }{userData}}
Construct a sizer item for tracking a subsizer.
\membersection{wxSizerItem::\destruct{wxSizerItem}}\label{wxsizeritemdtor}
\func{}{\destruct{wxSizerItem}}{\void}
Deletes the user data and subsizer, if any.
\membersection{wxSizerItem::CalcMin}\label{wxsizeritemcalcmin}
\func{wxSize}{CalcMin}{\void}
Calculates the minimum desired size for the item, including any space
needed by borders.
\membersection{wxSizerItem::DeleteWindows}\label{wxsizeritemdeletewindows}
\func{void}{DeleteWindows}{\void}
Destroy the window or the windows in a subsizer, depending on the type
of item.
\membersection{wxSizerItem::DetachSizer}\label{wxsizeritemdetachsizer}
\func{void}{DetachSizer}{\void}
Enable deleting the SizerItem without destroying the contained sizer.
\membersection{wxSizerItem::GetBorder}\label{wxsizeritemgetborder}
\constfunc{int}{GetBorder}{\void}
Return the border attribute.
\membersection{wxSizerItem::GetFlag}\label{wxsizeritemgetflag}
\constfunc{int}{GetFlag}{\void}
Return the flags attribute.
\membersection{wxSizerItem::GetMinSize}\label{wxsizeritemgetminsize}
\constfunc{wxSize}{GetMinSize}{\void}
Get the minimum size needed for the item.
\membersection{wxSizerItem::GetPosition}\label{wxsizeritemgetposition}
\constfunc{wxPoint}{GetPosition}{\void}
What is the current position of the item, as set in the last Layout.
\membersection{wxSizerItem::GetProportion}\label{wxsizeritemgetproportion}
\constfunc{int}{GetProportion}{\void}
Get the proportion item attribute.
\membersection{wxSizerItem::GetRatio}\label{wxsizeritemgetratio}
\constfunc{float}{GetRatio}{\void}
Get the ration item attribute.
\membersection{wxSizerItem::GetSize}\label{wxsizeritemgetsize}
\constfunc{wxSize}{GetSize}{\void}
Get the current size of the item, as set in the last Layout.
\membersection{wxSizerItem::GetSizer}\label{wxsizeritemgetsizer}
\constfunc{wxSizer*}{GetSizer}{\void}
If this item is tracking a sizer, return it. NULL otherwise.
\membersection{wxSizerItem::GetSpacer}\label{wxsizeritemgetspacer}
\constfunc{const wxSize\&}{GetSpacer}{\void}
If this item is tracking a spacer, return its size.
\membersection{wxSizerItem::GetUserData}\label{wxsizeritemgetuserdata}
\constfunc{wxObject*}{GetUserData}{\void}
Get the userData item attribute.
\membersection{wxSizerItem::GetWindow}\label{wxsizeritemgetwindow}
\constfunc{wxWindow*}{GetWindow}{\void}
If this item is trackign a window then return it. NULL otherwise.
\membersection{wxSizerItem::IsShown}\label{wxsizeritemisshown}
\constfunc{bool}{IsShown}{\void}
Is this item shown?
\membersection{wxSizerItem::IsSizer}\label{wxsizeritemissizer}
\constfunc{bool}{IsSizer}{\void}
Is this item a sizer?
\membersection{wxSizerItem::IsSpacer}\label{wxsizeritemisspacer}
\constfunc{bool}{IsSpacer}{\void}
Is this item a spacer?
\membersection{wxSizerItem::IsWindow}\label{wxsizeritemiswindow}
\constfunc{bool}{IsWindow}{\void}
Is this item a window?
\membersection{wxSizerItem::SetBorder}\label{wxsizeritemsetborder}
\func{void}{SetBorder}{\param{int }{border}}
Set the border item attribute.
\membersection{wxSizerItem::SetDimension}\label{wxsizeritemsetdimension}
\func{void}{SetDimension}{\param{wxPoint }{pos}, \param{wxSize }{size}}
Set the position and size of the space allocated to the sizer, and
adjust the position and size of the item to be within that space
taking alignment and borders into account.
\membersection{wxSizerItem::SetFlag}\label{wxsizeritemsetflag}
\func{void}{SetFlag}{\param{int }{flag}}
Set the flag item attribute.
\membersection{wxSizerItem::SetInitSize}\label{wxsizeritemsetinitsize}
\func{void}{SetInitSize}{\param{int }{x}, \param{int }{y}}
\membersection{wxSizerItem::SetProportion}\label{wxsizeritemsetproportion}
\func{void}{SetProportion}{\param{int }{proportion}}
Set the proportion item attribute.
\membersection{wxSizerItem::SetRatio}\label{wxsizeritemsetratio}
\func{void}{SetRatio}{\param{int }{width}, \param{int }{height}}
\func{void}{SetRatio}{\param{wxSize }{size}}
\func{void}{SetRatio}{\param{float }{ratio}}
Set the ratio item attribute.
\membersection{wxSizerItem::SetSizer}\label{wxsizeritemsetsizer}
\func{void}{SetSizer}{\param{wxSizer* }{sizer}}
Set the sizer tracked by this item.
\membersection{wxSizerItem::SetSpacer}\label{wxsizeritemsetspacer}
\func{void}{SetSpacer}{\param{const wxSize\& }{size}}
Set the size of the spacer tracked by this item.
\membersection{wxSizerItem::SetWindow}\label{wxsizeritemsetwindow}
\func{void}{SetWindow}{\param{wxWindow* }{window}}
Set the window to be tracked by thsi item.
\membersection{wxSizerItem::Show}\label{wxsizeritemshow}
\func{void}{Show}{\param{bool }{show}}
Set the show item attribute, which sizers use to determine if the item
is to be made part of the layout or not. If the item is tracking a
window then it is shown or hidden as needed.