From: Julian Smart Date: Sun, 27 Jan 2002 19:58:13 +0000 (+0000) Subject: Added first cut at sizer topic, based on Robert's manual and X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1c0c339c2d391168461dece5e97571f5f12a5026 Added first cut at sizer topic, based on Robert's manual and individual class reference docs. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13859 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/latex/wx/boxsizer.tex b/docs/latex/wx/boxsizer.tex index 6652598925..239eb9d0a1 100644 --- a/docs/latex/wx/boxsizer.tex +++ b/docs/latex/wx/boxsizer.tex @@ -3,92 +3,17 @@ The basic idea behind a box sizer is that windows will most often be laid out in rather simple basic geometry, typically in a row or a column or several hierarchies of either. -As an example, we will construct a dialog that will contain a text field at the top and -two buttons at the bottom. This can be seen as a top-hierarchy column with the text at -the top and buttons at the bottom and a low-hierarchy row with an OK button to the left -and a Cancel button to the right. In many cases (particularly dialogs under Unix and -normal frames) the main window will be resizable by the user and this change of size -will have to get propagated to its children. In our case, we want the text area to grow -with the dialog, whereas the button shall have a fixed size. In addition, there will be -a thin border around all controls to make the dialog look nice and - to make matter worse - -the buttons shall be centred as the width of the dialog changes. - -It is the unique feature of a box sizer, that it can grow in both directions (height and -width) but can distribute its growth in the main direction (horizontal for a row) {\it unevenly} -among its children. In our example case, the vertical sizer is supposed to propagate all its -height changes to only the text area, not to the button area. This is determined by the {\it option} parameter -when adding a window (or another sizer) to a sizer. It is interpreted -as a weight factor, i.e. it can be zero, indicating that the window may not be resized -at all, or above zero. If several windows have a value above zero, the value is interpreted -relative to the sum of all weight factors of the sizer, so when adding two windows with -a value of 1, they will both get resized equally much and each half as much as the sizer -owning them. Then what do we do when a column sizer changes its width? This behaviour is -controlled by {\it flags} (the second parameter of the Add() function): Zero or no flag -indicates that the window will preserve it is original size, wxGROW flag (same as wxEXPAND) -forces the window to grow with the sizer, and wxSHAPED flag tells the window to change it is -size proportionally, preserving original aspect ratio. When wxGROW flag is not used, -the item can be aligned within available space. wxALIGN\_LEFT, wxALIGN\_TOP, wxALIGN\_RIGHT, -wxALIGN\_BOTTOM, wxALIGN\_CENTER\_HORIZONTAL and wxALIGN\_CENTER\_VERTICAL do what they say. -wxALIGN\_CENTRE (same as wxALIGN\_CENTER) is defined as (wxALIGN\_CENTER\_HORIZONTAL | -wxALIGN\_CENTER\_VERTICAL). Default alignment is wxALIGN\_LEFT | wxALIGN\_TOP. - -As mentioned above, any window belonging to a sizer may have border, and it can be specified -which of the four sides may have this border, using the wxTOP, wxLEFT, wxRIGHT and wxBOTTOM -constants or wxALL for all directions (and you may also use wxNORTH, wxWEST etc instead). These -flags can be used in combination with the alignment flags above as the second parameter of the -Add() method using the binary or operator |. The sizer of the border also must be made known, -and it is the third parameter in the Add() method. This means, that the entire behaviour of -a sizer and its children can be controlled by the three parameters of the Add() method. - -\begin{verbatim} -// we want to get a dialog that is stretchable because it -// has a text ctrl at the top and two buttons at the bottom - -MyDialog::MyDialog(wxFrame *parent, wxWindowID id, const wxString &title ) - : wxDialog(parent, id, title, wxDefaultPosition, wxDefaultSize, - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) -{ - wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); - - // create text ctrl with minimal size 100x60 - topsizer->Add( - new wxTextCtrl( this, -1, "My text.", wxDefaultPosition, wxSize(100,60), wxTE_MULTILINE), - 1, // make vertically stretchable - wxEXPAND | // make horizontally stretchable - wxALL, // and make border all around - 10 ); // set border width to 10 - - - wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL ); - button_sizer->Add( - new wxButton( this, wxID_OK, "OK" ), - 0, // make horizontally unstretchable - wxALL, // make border all around (implicit top alignment) - 10 ); // set border width to 10 - button_sizer->Add( - new wxButton( this, wxID_CANCEL, "Cancel" ), - 0, // make horizontally unstretchable - wxALL, // make border all around (implicit top alignment) - 10 ); // set border width to 10 - - topsizer->Add( - button_sizer, - 0, // make vertically unstretchable - wxALIGN_CENTER ); // no border and centre horizontally - - SetAutoLayout( TRUE ); // tell dialog to use sizer - SetSizer( topsizer ); // actually set the sizer - - topsizer->Fit( this ); // set size to minimum size as calculated by the sizer - topsizer->SetSizeHints( this ); // set size hints to honour mininum size -} -\end{verbatim} +For more information, please see \helpref{Programming with wxBoxSizer}{boxsizerprogramming}. \wxheading{Derived from} \helpref{wxSizer}{wxsizer}\\ \helpref{wxObject}{wxobject} +\wxheading{See also} + +\helpref{wxSizer}{wxsizer}, \helpref{Sizer overview}{sizeroverview} + \membersection{wxBoxSizer::wxBoxSizer}\label{wxboxsizerwxboxsizer} \func{}{wxBoxSizer}{\param{int }{orient}} diff --git a/docs/latex/wx/category.tex b/docs/latex/wx/category.tex index 2fdb6315e0..bfd880b459 100644 --- a/docs/latex/wx/category.tex +++ b/docs/latex/wx/category.tex @@ -3,7 +3,6 @@ \setfooter{\thepage}{}{}{}{}{\thepage}% A classification of wxWindows classes by category. -\twocolwidtha{5cm} {\large {\bf Managed windows}} @@ -11,6 +10,7 @@ There are several types of window that are directly controlled by the window manager (such as MS Windows, or the Motif Window Manager). Frames may contain windows, and dialog boxes may directly contain controls. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxDialog}{wxdialog}}{Dialog box} \twocolitem{\helpref{wxFrame}{wxframe}}{Normal frame} @@ -30,6 +30,7 @@ See also {\bf Common dialogs}. The following are a variety of classes that are derived from wxWindow. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxPanel}{wxpanel}}{A window whose colour changes according to current user settings} \twocolitem{\helpref{wxScrolledWindow}{wxscrolledwindow}}{Window with automatically managed scrollbars} @@ -53,6 +54,7 @@ The following are a variety of classes that are derived from wxWindow. Common dialogs are ready-made dialog classes which are frequently used in an application. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxDialog}{wxdialog}}{Base class for common dialogs} \twocolitem{\helpref{wxColourDialog}{wxcolourdialog}}{Colour chooser dialog} @@ -75,6 +77,7 @@ in an application. Typically, these are small windows which provide interaction with the user. Controls that are not static can have \helpref{validators}{wxvalidator} associated with them. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxControl}{wxcontrol}}{The base class for controls} \twocolitem{\helpref{wxButton}{wxbutton}}{Push button control, displaying text} @@ -105,6 +108,7 @@ that are not static can have \helpref{validators}{wxvalidator} associated with t {\large {\bf Menus}} +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxMenu}{wxmenu}}{Displays a series of menu items for selection} \twocolitem{\helpref{wxMenuBar}{wxmenubar}}{Contains a series of menus for use with a frame} @@ -113,26 +117,30 @@ that are not static can have \helpref{validators}{wxvalidator} associated with t {\large {\bf Window layout}} -There are two different systems for layouting windows (and dialogs in particular). +There are two different systems for laying out windows (and dialogs in particular). One is based upon so-called sizers and it requires less typing, thinking and calculating and will in almost all cases produce dialogs looking equally well on all platforms, the -other is based on so-called constraints and allows for more detailed layouts. +other is based on so-called constraints and is deprecated, though still available. -These are the classes relevant to the sizer-based layout. +\overview{Sizer overview}{sizeroverview} describes sizer-based layout. +These are the classes relevant to sizer-based layout. + +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \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{wxBoxSizer}{wxboxsizer}}{A sizer for laying out windows in a row or column} -\twocolitem{\helpref{wxStaticBoxSizer}{wxstaticboxsizer}}{Same as wxBoxSizer, but with surrounding static box} -\twocolitem{\helpref{wxNotebookSizer}{wxnotebooksizer}}{Sizer to use with the wxNotebook control.} +\twocolitem{\helpref{wxStaticBoxSizer}{wxstaticboxsizer}}{Same as wxBoxSizer, but with a surrounding static box} +\twocolitem{\helpref{wxNotebookSizer}{wxnotebooksizer}}{Sizer to use with the wxNotebook control} \end{twocollist} -\overview{Overview}{constraintsoverview} over the constraints-based layout. +\overview{Constraints overview}{constraintsoverview} describes constraints-based layout. These are the classes relevant to constraints-based window layout. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxIndividualLayoutConstraint}{wxindividuallayoutconstraint}}{Represents a single constraint dimension} \twocolitem{\helpref{wxLayoutConstraints}{wxlayoutconstraints}}{Represents the constraints for a window class} @@ -146,6 +154,7 @@ Device contexts are surfaces that may be drawn on, and provide an abstraction that allows parameterisation of your drawing code by passing different device contexts. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxClientDC}{wxclientdc}}{A device context to access the client area outside {\bf OnPaint} events} \twocolitem{\helpref{wxPaintDC}{wxpaintdc}}{A device context to access the client area inside {\bf OnPaint} events} @@ -164,6 +173,7 @@ by passing different device contexts. These classes are related to drawing on device contexts and windows. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxColour}{wxcolour}}{Represents the red, blue and green elements of a colour} \twocolitem{\helpref{wxDCClipper}{wxdcclipper}}{Wraps the operations of setting and destroying the clipping region} @@ -190,6 +200,7 @@ These classes are related to drawing on device contexts and windows. An event object contains information about a specific event. Event handlers (usually member functions) have a single, event argument. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxActivateEvent}{wxactivateevent}}{A window or application activation event} \twocolitem{\helpref{wxCalendarEvent}{wxcalendarevent}}{Used with \helpref{wxCalendarCtrl}{wxcalendarctrl}} @@ -237,6 +248,7 @@ An event object contains information about a specific event. Event handlers These are the window validators, used for filtering and validating user input. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxValidator}{wxvalidator}}{Base validator class} \twocolitem{\helpref{wxTextValidator}{wxtextvalidator}}{Text control validator class} @@ -247,6 +259,7 @@ user input. These are the data structure classes supported by wxWindows. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxCmdLineParser}{wxcmdlineparser}}{Command line parser class} \twocolitem{\helpref{wxDate}{wxdate}}{A class for date manipulation (deprecated in favour of wxDateTime)} @@ -282,6 +295,7 @@ These are the data structure classes supported by wxWindows. wxWindows supports run-time manipulation of class information, and dynamic creation of objects given class names. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxClassInfo}{wxclassinfo}}{Holds run-time class information} \twocolitem{\helpref{wxObject}{wxobject}}{Root class for classes with run-time information} @@ -295,6 +309,7 @@ creation of objects given class names. wxWindows provides several classes and functions for the message logging. Please see the \helpref{wxLog overview}{wxlogoverview} for more details. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxLog}{wxlog}}{The base log class} \twocolitem{\helpref{wxLogStderr}{wxlogstderr}}{Log messages to a C STDIO stream} @@ -317,6 +332,7 @@ to redirect output sent to {\tt cout} to a \helpref{wxTextCtrl}{wxtextctrl}} wxWindows supports some aspects of debugging an application through classes, functions and macros. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxDebugContext}{wxdebugcontext}}{Provides memory-checking facilities} %\twocolitem{\helpref{wxDebugStreamBuf}{wxdebugstreambuf}}{A stream buffer writing to the debug stream} @@ -330,6 +346,7 @@ classes, functions and macros. wxWindows provides its own classes for socket based networking. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxDialUpManager}{wxdialupmanager}}{Provides functions to check the status of network connection and to establish one} \twocolitem{\helpref{wxIPV4address}{wxipv4address}}{Represents an Internet address} @@ -350,6 +367,7 @@ wxWindows provides its own classes for socket based networking. wxWindows provides a simple interprocess communications facilities based on DDE. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxDDEClient}{wxddeclient}}{Represents a client} \twocolitem{\helpref{wxDDEConnection}{wxddeconnection}}{Represents the connection between a client and a server} @@ -367,6 +385,7 @@ based on DDE. wxWindows supports a document/view framework which provides housekeeping for a document-centric application. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxDocument}{wxdocument}}{Represents a document} \twocolitem{\helpref{wxView}{wxview}}{Represents a view} @@ -386,6 +405,7 @@ A printing and previewing framework is implemented to make it relatively straightforward to provide document printing facilities. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxPreviewFrame}{wxpreviewframe}}{Frame for displaying a print preview} \twocolitem{\helpref{wxPreviewCanvas}{wxpreviewcanvas}}{Canvas for displaying a print preview} @@ -405,6 +425,7 @@ facilities. \overview{Drag and drop and clipboard overview}{wxdndoverview} +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxDataObject}{wxdataobject}}{Data object class} \twocolitem{\helpref{wxDataFormat}{wxdataformat}}{Represents a data format} @@ -424,6 +445,7 @@ facilities. wxWindows has several small classes to work with disk files, see \helpref{file classes overview}{wxfileoverview} for more details. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxFileName}{wxfilename}}{Operations with the file name and attributes} \twocolitem{\helpref{wxDir}{wxdir}}{Class for enumerating files/subdirectories.} @@ -439,6 +461,7 @@ overview}{wxfileoverview} for more details. wxWindows has its own set of stream classes, as an alternative to often buggy standard stream libraries, and to provide enhanced functionality. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxStreamBase}{wxstreambase}}{Stream base class} \twocolitem{\helpref{wxStreamBuffer}{wxstreambuffer}}{Stream buffer class} @@ -473,6 +496,7 @@ libraries, and to provide enhanced functionality. wxWindows provides a set of classes to make use of the native thread capabilities of the various platforms. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxThread}{wxthread}}{Thread class} \twocolitem{\helpref{wxMutex}{wxmutex}}{Mutex class} @@ -487,6 +511,7 @@ capabilities of the various platforms. wxWindows provides a set of classes to display text in HTML format. These class include a help system based on the HTML widget. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxHtmlHelpController}{wxhtmlhelpcontroller}}{HTML help controller class} \twocolitem{\helpref{wxHtmlWindow}{wxhtmlwindow}}{HTML window class} @@ -503,6 +528,7 @@ class include a help system based on the HTML widget. wxWindows provides a set of classes that implement an extensible virtual file system, used internally by the HTML classes. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxFSFile}{wxfsfile}}{Represents a file in the virtual file system} \twocolitem{\helpref{wxFileSystem}{wxfilesystem}}{Main interface for the virtual file system} @@ -516,6 +542,7 @@ used internally by the HTML classes. Resources allow your application to create controls and other user interface elements from specifications stored in an XML format. +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxXmlResource}{wxxmlresource}}{The main class for working with resources.} \twocolitem{\helpref{wxXmlResourceHandler}{wxxmlresourcehandler}}{The base class for XML resource handlers.} @@ -523,6 +550,7 @@ from specifications stored in an XML format. {\large {\bf Online help}} +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxHelpController}{wxhelpcontroller}}{Family of classes for controlling help windows} \twocolitem{\helpref{wxHtmlHelpController}{wxhtmlhelpcontroller}}{HTML help controller class} @@ -543,6 +571,7 @@ product. The new version by Remstar, known as wxODBC, is more powerful, portable, flexible and better supported, so please use the classes below for working with databases: +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxDb}{wxdb}}{ODBC database connection} \twocolitem{\helpref{wxDbTable}{wxdbtable}}{Provides access to a database table} @@ -559,6 +588,7 @@ working with databases: The documentation for the older classes is still included, but you should avoid using any of them in the new programs: +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxDatabase}{wxdatabase}}{Database class} \twocolitem{\helpref{wxQueryCol}{wxquerycol}}{Class representing a column} @@ -568,6 +598,7 @@ using any of them in the new programs: {\large {\bf Miscellaneous}} +\twocolwidtha{6cm} \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxApp}{wxapp}}{Application class} \twocolitem{\helpref{wxCaret}{wxcaret}}{A caret (cursor) object} diff --git a/docs/latex/wx/flexsizr.tex b/docs/latex/wx/flexsizr.tex index 3b7e39f0e1..d7456bbc21 100644 --- a/docs/latex/wx/flexsizr.tex +++ b/docs/latex/wx/flexsizr.tex @@ -12,6 +12,10 @@ the \helpref{wxGridSizer}{wxgridsizer}. \helpref{wxSizer}{wxsizer}\\ \helpref{wxObject}{wxobject} +\wxheading{See also} + +\helpref{wxSizer}{wxsizer}, \helpref{Sizer overview}{sizeroverview} + \membersection{wxFlexGridSizer::wxFlexGridSizer}\label{wxflexgridsizerwxflexgridsizer} \func{}{wxFlexGridSizer}{\param{int }{rows}, \param{int }{cols}, \param{int }{vgap}, \param{int }{hgap}} diff --git a/docs/latex/wx/gridsizr.tex b/docs/latex/wx/gridsizr.tex index 82a70ec5b6..70005bbee9 100644 --- a/docs/latex/wx/gridsizr.tex +++ b/docs/latex/wx/gridsizr.tex @@ -10,6 +10,10 @@ the height of each field is the height of the tallest child. \helpref{wxSizer}{wxsizer}\\ \helpref{wxObject}{wxobject} +\wxheading{See also} + +\helpref{wxSizer}{wxsizer}, \helpref{Sizer overview}{sizeroverview} + \membersection{wxGridSizer::wxGridSizer}\label{wxgridsizerwxgridsizer} \func{}{wxGridSizer}{\param{int }{rows}, \param{int }{cols}, \param{int }{vgap}, \param{int }{hgap}} @@ -22,7 +26,6 @@ calculated to form the total number of children in the sizer, thus making the sizer grow dynamically. {\it vgap} and {\it hgap} define extra space between all children. - \membersection{wxGridSizer::GetCols}\label{wxgridsizergetcols} \func{int}{GetCols}{} diff --git a/docs/latex/wx/nbsizer.tex b/docs/latex/wx/nbsizer.tex index 9a9f915704..29a93e5be6 100644 --- a/docs/latex/wx/nbsizer.tex +++ b/docs/latex/wx/nbsizer.tex @@ -7,37 +7,17 @@ The only thing this sizer does is to determine the size of the biggest page of the notebook and report an adjusted minimal size to a more toplevel sizer. -In order to query the size of notebook page, this page needs to have its -own sizer, otherwise the wxNotebookSizer will ignore it. Notebook pages -get there sizer by assiging one to them using \helpref{wxWindow::SetSizer}{wxwindowsetsizer} -and setting the auto-layout option to TRUE using -\helpref{wxWindow::SetAutoLayout}{wxwindowsetautolayout}. Here is one -example showing how to add a notebook page that the notebook sizer is -aware of: - -\begin{verbatim} - wxNotebook *notebook = new wxNotebook( &dialog, -1 ); - wxNotebookSizer *nbs = new wxNotebookSizer( notebook ); - - // Add panel as notebook page - wxPanel *panel = new wxPanel( notebook, -1 ); - notebook->AddPage( panel, "My Notebook Page" ); - - wxBoxSizer *panelsizer = new wxBoxSizer( wxVERTICAL ); - - // Add controls to panel and panelsizer here... - - panel->SetAutoLayout( TRUE ); - panel->SetSizer( panelsizer ); -\end{verbatim} - -See also \helpref{wxSizer}{wxsizer}, \helpref{wxNotebook}{wxnotebook}. +For more information, please see \helpref{Programming with wxNotebookSizer}{notebooksizerprogramming}. \wxheading{Derived from} \helpref{wxSizer}{wxsizer}\\ \helpref{wxObject}{wxobject} +\wxheading{See also} + +\helpref{wxSizer}{wxsizer}, \helpref{wxNotebook}{wxnotebook}, \helpref{Sizer overview}{sizeroverview} + \latexignore{\rtfignore{\wxheading{Members}}} \membersection{wxNotebookSizer::wxNotebookSizer}\label{wxnotebooksizerwxnotebooksizer} diff --git a/docs/latex/wx/sbsizer.tex b/docs/latex/wx/sbsizer.tex index 3cc226a5b4..37849082fc 100644 --- a/docs/latex/wx/sbsizer.tex +++ b/docs/latex/wx/sbsizer.tex @@ -4,15 +4,16 @@ wxStaticBoxSizer is a sizer derived from wxBoxSizer but adds a static box around the sizer. Note that this static box has to be created separately. -See also \helpref{wxSizer}{wxsizer}, \helpref{wxStaticBox}{wxstaticbox} and - \helpref{wxBoxSizer}{wxboxsizer}. - \wxheading{Derived from} \helpref{wxBoxSizer}{wxboxsizer}\\ \helpref{wxSizer}{wxsizer}\\ \helpref{wxObject}{wxobject} +\wxheading{See also} + +\helpref{wxSizer}{wxsizer}, \helpref{wxStaticBox}{wxstaticbox}, \helpref{wxBoxSizer}{wxboxsizer}, \helpref{Sizer overview}{sizeroverview} + \latexignore{\rtfignore{\wxheading{Members}}} \membersection{wxStaticBoxSizer::wxStaticBoxSizer}\label{wxstaticboxsizerwxstaticboxsizer} diff --git a/docs/latex/wx/sizer.tex b/docs/latex/wx/sizer.tex index 25494f5789..f39b4aeabc 100644 --- a/docs/latex/wx/sizer.tex +++ b/docs/latex/wx/sizer.tex @@ -33,6 +33,10 @@ capabilities for the various virtual methods.} \helpref{wxObject}{wxobject} +\wxheading{See also} + +\helpref{Sizer overview}{sizeroverview} + \latexignore{\rtfignore{\wxheading{Members}}} \membersection{wxSizer::wxSizer}\label{wxsizerwxsizer} diff --git a/docs/latex/wx/sizer00.bmp b/docs/latex/wx/sizer00.bmp new file mode 100644 index 0000000000..f9a1905a83 Binary files /dev/null and b/docs/latex/wx/sizer00.bmp differ diff --git a/docs/latex/wx/sizer00.gif b/docs/latex/wx/sizer00.gif new file mode 100644 index 0000000000..e6fe21d7a0 Binary files /dev/null and b/docs/latex/wx/sizer00.gif differ diff --git a/docs/latex/wx/sizer01.bmp b/docs/latex/wx/sizer01.bmp new file mode 100644 index 0000000000..b5ae0f77c7 Binary files /dev/null and b/docs/latex/wx/sizer01.bmp differ diff --git a/docs/latex/wx/sizer01.gif b/docs/latex/wx/sizer01.gif new file mode 100644 index 0000000000..3284a3ff44 Binary files /dev/null and b/docs/latex/wx/sizer01.gif differ diff --git a/docs/latex/wx/sizer02.bmp b/docs/latex/wx/sizer02.bmp new file mode 100644 index 0000000000..1b68da9772 Binary files /dev/null and b/docs/latex/wx/sizer02.bmp differ diff --git a/docs/latex/wx/sizer02.gif b/docs/latex/wx/sizer02.gif new file mode 100644 index 0000000000..891ad5acfa Binary files /dev/null and b/docs/latex/wx/sizer02.gif differ diff --git a/docs/latex/wx/sizer03.bmp b/docs/latex/wx/sizer03.bmp new file mode 100644 index 0000000000..d093307dcb Binary files /dev/null and b/docs/latex/wx/sizer03.bmp differ diff --git a/docs/latex/wx/sizer03.gif b/docs/latex/wx/sizer03.gif new file mode 100644 index 0000000000..3d3c9f9ae2 Binary files /dev/null and b/docs/latex/wx/sizer03.gif differ diff --git a/docs/latex/wx/sizer04.bmp b/docs/latex/wx/sizer04.bmp new file mode 100644 index 0000000000..04df07073b Binary files /dev/null and b/docs/latex/wx/sizer04.bmp differ diff --git a/docs/latex/wx/sizer04.gif b/docs/latex/wx/sizer04.gif new file mode 100644 index 0000000000..b72db4174f Binary files /dev/null and b/docs/latex/wx/sizer04.gif differ diff --git a/docs/latex/wx/sizer05.bmp b/docs/latex/wx/sizer05.bmp new file mode 100644 index 0000000000..9d90496173 Binary files /dev/null and b/docs/latex/wx/sizer05.bmp differ diff --git a/docs/latex/wx/sizer05.gif b/docs/latex/wx/sizer05.gif new file mode 100644 index 0000000000..5a0c06a0db Binary files /dev/null and b/docs/latex/wx/sizer05.gif differ diff --git a/docs/latex/wx/sizer06.bmp b/docs/latex/wx/sizer06.bmp new file mode 100644 index 0000000000..ccc2e9f174 Binary files /dev/null and b/docs/latex/wx/sizer06.bmp differ diff --git a/docs/latex/wx/sizer06.gif b/docs/latex/wx/sizer06.gif new file mode 100644 index 0000000000..2eebd32366 Binary files /dev/null and b/docs/latex/wx/sizer06.gif differ diff --git a/docs/latex/wx/sizer07.bmp b/docs/latex/wx/sizer07.bmp new file mode 100644 index 0000000000..4797967f24 Binary files /dev/null and b/docs/latex/wx/sizer07.bmp differ diff --git a/docs/latex/wx/sizer07.gif b/docs/latex/wx/sizer07.gif new file mode 100644 index 0000000000..3097ef4e99 Binary files /dev/null and b/docs/latex/wx/sizer07.gif differ diff --git a/docs/latex/wx/sizer08.bmp b/docs/latex/wx/sizer08.bmp new file mode 100644 index 0000000000..21040933bc Binary files /dev/null and b/docs/latex/wx/sizer08.bmp differ diff --git a/docs/latex/wx/sizer08.gif b/docs/latex/wx/sizer08.gif new file mode 100644 index 0000000000..4e32edca1a Binary files /dev/null and b/docs/latex/wx/sizer08.gif differ diff --git a/docs/latex/wx/sizer09.bmp b/docs/latex/wx/sizer09.bmp new file mode 100644 index 0000000000..a29ca7601c Binary files /dev/null and b/docs/latex/wx/sizer09.bmp differ diff --git a/docs/latex/wx/sizer09.gif b/docs/latex/wx/sizer09.gif new file mode 100644 index 0000000000..9aff20396b Binary files /dev/null and b/docs/latex/wx/sizer09.gif differ diff --git a/docs/latex/wx/sizer10.bmp b/docs/latex/wx/sizer10.bmp new file mode 100644 index 0000000000..0ddafc917e Binary files /dev/null and b/docs/latex/wx/sizer10.bmp differ diff --git a/docs/latex/wx/sizer10.gif b/docs/latex/wx/sizer10.gif new file mode 100644 index 0000000000..ce45d6945b Binary files /dev/null and b/docs/latex/wx/sizer10.gif differ diff --git a/docs/latex/wx/sizer11.bmp b/docs/latex/wx/sizer11.bmp new file mode 100644 index 0000000000..ca7e6c428f Binary files /dev/null and b/docs/latex/wx/sizer11.bmp differ diff --git a/docs/latex/wx/sizer11.gif b/docs/latex/wx/sizer11.gif new file mode 100644 index 0000000000..40dec1c00a Binary files /dev/null and b/docs/latex/wx/sizer11.gif differ diff --git a/docs/latex/wx/tconstr.tex b/docs/latex/wx/tconstr.tex index cd3fda2d90..6eea4c6c49 100644 --- a/docs/latex/wx/tconstr.tex +++ b/docs/latex/wx/tconstr.tex @@ -2,7 +2,7 @@ Classes: \helpref{wxLayoutConstraints}{wxlayoutconstraints}, \helpref{wxIndividualLayoutConstraint}{wxindividuallayoutconstraint}. -{\bf Note:} constraints are now deprecated and you should use \helpref{wxSizers}{wxsizer} instead. +{\bf Note:} constraints are now deprecated and you should use \helpref{sizers}{sizeroverview} instead. Objects of class wxLayoutConstraint can be associated with a window to define the way it is laid out, with respect to its siblings or the parent. diff --git a/docs/latex/wx/topics.tex b/docs/latex/wx/topics.tex index 588e1ebaff..df229b76a7 100644 --- a/docs/latex/wx/topics.tex +++ b/docs/latex/wx/topics.tex @@ -30,6 +30,7 @@ This chapter contains a selection of topic overviews, first things first: \input tdialog.tex \input tvalidat.tex \input tconstr.tex +\input tsizer.tex \input tresourc.tex \input txrc.tex \input tscroll.tex diff --git a/docs/latex/wx/tsizer.tex b/docs/latex/wx/tsizer.tex new file mode 100644 index 0000000000..0dd77ea938 --- /dev/null +++ b/docs/latex/wx/tsizer.tex @@ -0,0 +1,318 @@ +\section{Sizer overview}\label{sizeroverview} + +Classes: \helpref{wxSizer}{wxsizer}, \helpref{wxGridSizer}{wxgridsizer}, +\helpref{wxFlexGridSizer}{wxflexgridsizer}, \helpref{wxBoxSizer}{wxboxsizer}, +\helpref{wxStaticBoxSizer}{wxstaticboxsizer}, +\helpref{wxNotebookSizer}{wxnotebooksizer} + +Sizers, as represented by the wxSizer class and its descendants in +the wxWindows class hierarchy, have become the method of choice to +define the layout of controls in dialogs in wxWindows because of +their ability to create visually appealing dialogs independent of the +platform, taking into account the differences in size and style of +the individual controls. Unlike the original wxWindows Dialog Editor, +editors such as wxDesigner, wxrcedit, XRCed and wxWorkshop create dialogs based exclusively on sizers, +practically forcing the user to create platform independent layouts without compromises. + +The next section describes and shows what can be done with sizers. +The following sections briefly describe how to program with individual sizer classes. + +For information about the new wxWindows resource system, which can describe +sizer-based dialogs, see the \helpref{XML-based resource system overview}{xrcoverview}. + +\subsection{The idea behind sizers}\label{ideabehindsizers} + +The layout algorithm used by sizers in wxWindows is closely related to layout +systems in other GUI toolkits, such as Java's AWT, the GTK toolkit or the Qt toolkit. It is +based upon the idea of individual subwindows reporting their minimal required +size and their ability to get stretched if the size of the parent window has changed. +This will most often mean that the programmer does not set the start-up size of +a dialog, the dialog will rather be assigned a sizer and this sizer +will be queried about the recommended size. This sizer in turn will query its +children (which can be normal windows, empty space or other sizers) so that +a hierarchy of sizers can be constructed. Note that wxSizer does not derive from wxWindow +and thus does not interfere with tab ordering and requires very few resources compared +to a real window on screen. + +What makes sizers so well fitted for use in wxWindows is the fact that every control +reports its own minimal size and the algorithm can handle differences in font sizes +or different window (dialog item) sizes on different platforms without problems. For example, if +the standard font as well as the overall design of Linux/GTK widgets requires more space than +on Windows, the initial dialog size will automatically be bigger on Linux/GTK than on Windows. + +There are currently five different kinds of sizers available in wxWindows. Each represents +either a certain way to lay out dialog items in a dialog or it fulfils a special task +such as wrapping a static box around a dialog item (or another sizer). These sizers will +be discussed one by one in the text below. For more detailed information on how to use sizers +programmatically, please refer to the section \helpref{Programming with Sizers}{sizersprogramming}. + +\subsubsection{Common features}\label{sizerscommonfeatures} + +All sizers are containers, that is, they are used to lay out one dialog item (or several +dialog items), which they contain. Such items are sometimes referred to as the children +of the sizer. Independent of how the individual sizers lay out their children, all children +have certain features in common: + +{\bf A minimal size:} This minimal size is usually identical to +the initial size of the controls and may either be set explicitly in the wxSize field +of the control constructor or may be calculated by wxWindows, typically by setting +the height and/or the width of the item to -1. Note that only some controls can +calculate their size (such as a checkbox) whereas others (such as a listbox) +don't have any natural width or height and thus require an explicit size. Some controls +can calculate their height, but not their width (e.g. a single line text control): + +\center{ +\image{}{sizer03.gif} + +\image{}{sizer04.gif} + +\image{}{sizer05.gif} +} + +{\bf A border:} The border is just empty space and is used to separate dialog items +in a dialog. This border can either be all around, or at any combination of sides +such as only above and below the control. The thickness of this border must be set +explicitly, typically 5 points. The following samples show dialogs with only one +dialog item (a button) and a border of 0, 5, and 10 pixels around the button: + +\center{ +\image{}{sizer00.gif} + +\image{}{sizer01.gif} + +\image{}{sizer02.gif} +} + +{\bf An alignment:} Often, a dialog item is given more space than its minimal size +plus its border. Depending on what flags are used for the respective dialog +item, the dialog item can be made to fill out the available space entirely, i.e. +it will grow to a size larger than the minimal size, or it will be moved to either +the centre of the available space or to either side of the space. The following +sample shows a listbox and three buttons in a horizontal box sizer; one button +is centred, one is aligned at the top, one is aligned at the bottom: + +\center{ +\image{}{sizer06.gif} +} + +{\bf A stretch factor:} If a sizer contains more than one child and it is offered +more space than its children and their borders need, the question arises how to +distribute the surplus space among the children. For this purpose, a stretch +factor may be assigned to each child, where the default value of 0 indicates that the child +will not get more space than its requested minimum size. A value of more than zero +is interpreted in relation to the sum of all stretch factors in the children +of the respective sizer, i.e. if two children get a stretch factor of 1, they will +get half the extra space each {\it independent of whether one control has a minimal +sizer inferior to the other or not}. The following sample shows a dialog with +three buttons, the first one has a stretch factor of 1 and thus gets stretched, +whereas the other two buttons have a stretch factor of zero and keep their +initial width: + +\center{ +\image{}{sizer07.gif} +} + +Within wxDesigner, this stretch factor gets set from the {\it Option} menu. + +\wxheading{wxBoxSizer} + +\helpref{wxBoxSizer}{wxboxsizer} can lay out its children either vertically +or horizontally, depending on what flag is being used in its constructor. +When using a vertical sizer, each child can be centered, aligned to the +right or aligned to the left. Correspondingly, when using a horizontal +sizer, each child can be centered, aligned at the bottom or aligned at +the top. The stretch factor described in the last paragraph is used +for the main orientation, i.e. when using a horizontal box sizer, the +stretch factor determines how much the child can be stretched horizontally. +The following sample shows the same dialog as in the last sample, +only the box sizer is a vertical box sizer now: + +\center{ +\image{}{sizer08.gif} +} + +\wxheading{wxStaticBoxSizer} + +\helpref{wxStaticBoxSixer}{wxstaticboxsizer} is the same as a wxBoxSizer, but surrounded by a +static box. Here is a sample: + +\center{ +\image{}{sizer09.gif} +} + +\wxheading{wxGridSizer} + +\helpref{wxGridSizer}{wxgridsizer} is a two-dimensional sizer. All children are given the +same size, which is the minimal size required by the biggest child, in +this case the text control in the left bottom border. Either the number +of columns or the number or rows is fixed and the grid sizer will grow +in the respectively other orientation if new children are added: + +\center{ +\image{}{sizer10.gif} +} + +For programming information, see \helpref{wxGridSizer}{wxgridsizer}. + +\wxheading{wxFlexGridSizer} + +Another two-dimensional sizer derived from +wxGridSizer. The width of each column and the height of each row +are calculated individually according the minimal requirements +from the respectively biggest child. Additionally, columns and +rows can be declared to be stretchable if the sizer is assigned +a size different from that which it requested. The following sample shows +the same dialog as the one above, but using a flex grid sizer: + +\center{ +\image{}{sizer11.gif} +} + +\wxheading{wxNotebookSizer} + +\helpref{wxNotebookSizer}{wxnotebooksizer} can be used in +connection with notebooks. It calculates the size of each +notebook page and sets the size of the notebook to the size +of the biggest page plus some extra space required for the +notebook tabs and decorations. + +\subsection{Programming with wxBoxSizer}\label{boxsizerprogramming} + +The basic idea behind a \helpref{wxBoxSizer}{wxboxsizer} is that windows will most often be laid out in rather +simple basic geometry, typically in a row or a column or several hierarchies of either. + +As an example, we will construct a dialog that will contain a text field at the top and +two buttons at the bottom. This can be seen as a top-hierarchy column with the text at +the top and buttons at the bottom and a low-hierarchy row with an OK button to the left +and a Cancel button to the right. In many cases (particularly dialogs under Unix and +normal frames) the main window will be resizable by the user and this change of size +will have to get propagated to its children. In our case, we want the text area to grow +with the dialog, whereas the button shall have a fixed size. In addition, there will be +a thin border around all controls to make the dialog look nice and - to make matter worse - +the buttons shall be centred as the width of the dialog changes. + +It is the unique feature of a box sizer, that it can grow in both directions (height and +width) but can distribute its growth in the main direction (horizontal for a row) {\it unevenly} +among its children. In our example case, the vertical sizer is supposed to propagate all its +height changes to only the text area, not to the button area. This is determined by the {\it option} parameter +when adding a window (or another sizer) to a sizer. It is interpreted +as a weight factor, i.e. it can be zero, indicating that the window may not be resized +at all, or above zero. If several windows have a value above zero, the value is interpreted +relative to the sum of all weight factors of the sizer, so when adding two windows with +a value of 1, they will both get resized equally much and each half as much as the sizer +owning them. Then what do we do when a column sizer changes its width? This behaviour is +controlled by {\it flags} (the second parameter of the Add() function): Zero or no flag +indicates that the window will preserve it is original size, wxGROW flag (same as wxEXPAND) +forces the window to grow with the sizer, and wxSHAPED flag tells the window to change it is +size proportionally, preserving original aspect ratio. When wxGROW flag is not used, +the item can be aligned within available space. wxALIGN\_LEFT, wxALIGN\_TOP, wxALIGN\_RIGHT, +wxALIGN\_BOTTOM, wxALIGN\_CENTER\_HORIZONTAL and wxALIGN\_CENTER\_VERTICAL do what they say. +wxALIGN\_CENTRE (same as wxALIGN\_CENTER) is defined as (wxALIGN\_CENTER\_HORIZONTAL | +wxALIGN\_CENTER\_VERTICAL). Default alignment is wxALIGN\_LEFT | wxALIGN\_TOP. + +As mentioned above, any window belonging to a sizer may have border, and it can be specified +which of the four sides may have this border, using the wxTOP, wxLEFT, wxRIGHT and wxBOTTOM +constants or wxALL for all directions (and you may also use wxNORTH, wxWEST etc instead). These +flags can be used in combination with the alignment flags above as the second parameter of the +Add() method using the binary or operator |. The sizer of the border also must be made known, +and it is the third parameter in the Add() method. This means, that the entire behaviour of +a sizer and its children can be controlled by the three parameters of the Add() method. + +\begin{verbatim} +// we want to get a dialog that is stretchable because it +// has a text ctrl at the top and two buttons at the bottom + +MyDialog::MyDialog(wxFrame *parent, wxWindowID id, const wxString &title ) + : wxDialog(parent, id, title, wxDefaultPosition, wxDefaultSize, + wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) +{ + wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); + + // create text ctrl with minimal size 100x60 + topsizer->Add( + new wxTextCtrl( this, -1, "My text.", wxDefaultPosition, wxSize(100,60), wxTE_MULTILINE), + 1, // make vertically stretchable + wxEXPAND | // make horizontally stretchable + wxALL, // and make border all around + 10 ); // set border width to 10 + + + wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL ); + button_sizer->Add( + new wxButton( this, wxID_OK, "OK" ), + 0, // make horizontally unstretchable + wxALL, // make border all around (implicit top alignment) + 10 ); // set border width to 10 + button_sizer->Add( + new wxButton( this, wxID_CANCEL, "Cancel" ), + 0, // make horizontally unstretchable + wxALL, // make border all around (implicit top alignment) + 10 ); // set border width to 10 + + topsizer->Add( + button_sizer, + 0, // make vertically unstretchable + wxALIGN_CENTER ); // no border and centre horizontally + + SetAutoLayout( TRUE ); // tell dialog to use sizer + SetSizer( topsizer ); // actually set the sizer + + topsizer->Fit( this ); // set size to minimum size as calculated by the sizer + topsizer->SetSizeHints( this ); // set size hints to honour mininum size +} +\end{verbatim} + +\subsection{Programming with wxGridSizer}\label{gridsizerprogramming} + +\helpref{wxGridSizer}{wxgridsizer} is a sizer which lays out its children in a two-dimensional +table with all table fields having the same size, +i.e. the width of each field is the width of the widest child, +the height of each field is the height of the tallest child. + +\subsection{Programming with wxFlexGridSizer}\label{flexgridsizerprogramming} + +\helpref{wxFlexGridSizer}{wxflexgridsizer} is a sizer which lays out its children in a two-dimensional +table with all table fields in one row having the same +height and all fields in one column having the same width, but all +rows or all columns are not necessarily the same height or width as in +the \helpref{wxGridSizer}{wxgridsizer}. + +\subsection{Programming with wxNotebookSizer}\label{notebooksizerprogramming} + +\helpref{wxNotebookSizer}{wxnotebooksizer} is a specialized sizer to make sizers work in connection +with using notebooks. This sizer is different from any other sizer as +you must not add any children to it - instead, it queries the notebook class itself. +The only thing this sizer does is to determine the size of the biggest +page of the notebook and report an adjusted minimal size to a more toplevel +sizer. + +In order to query the size of notebook page, this page needs to have its +own sizer, otherwise the wxNotebookSizer will ignore it. Notebook pages +get there sizer by assiging one to them using \helpref{wxWindow::SetSizer}{wxwindowsetsizer} +and setting the auto-layout option to TRUE using +\helpref{wxWindow::SetAutoLayout}{wxwindowsetautolayout}. Here is one +example showing how to add a notebook page that the notebook sizer is +aware of: + +\begin{verbatim} + wxNotebook *notebook = new wxNotebook( &dialog, -1 ); + wxNotebookSizer *nbs = new wxNotebookSizer( notebook ); + + // Add panel as notebook page + wxPanel *panel = new wxPanel( notebook, -1 ); + notebook->AddPage( panel, "My Notebook Page" ); + + wxBoxSizer *panelsizer = new wxBoxSizer( wxVERTICAL ); + + // Add controls to panel and panelsizer here... + + panel->SetAutoLayout( TRUE ); + panel->SetSizer( panelsizer ); +\end{verbatim} + +\subsection{Programming with wxStaticBoxSizer}\label{staticboxsizerprogramming} + +\helpref{wxStaticBoxSizer}{wxstaticboxsizer} is a sizer derived from wxBoxSizer but adds a static +box around the sizer. Note that this static box has to be created +separately. + diff --git a/docs/latex/wx/txrc.tex b/docs/latex/wx/txrc.tex index b117c11be5..08e8368244 100644 --- a/docs/latex/wx/txrc.tex +++ b/docs/latex/wx/txrc.tex @@ -461,77 +461,8 @@ This is the XML file (resource.xrc) for the XRC sample. \subsection{XRC file format}\label{xrcfileformat} -\subsubsection{Introduction to the XRC file format}\label{xrcfileformatintro} - -This note describes the file format used for storing XRC resources that are -used by wxXmlResource class. It is probably only useful for those implementing -dialog editors with XRC support, or for those writing XRC files by hand. - -If you only want to use the resources, you can choose from a number of editors, -as listed in \helpref{XRC concepts}{xrcconcepts}. - -The XRC format is based on XML 1.0 (please consult W3C's specification). There -is no DTD available since it is not possible to fully describe the format with -the limited expressive power of DTDs. - -\subsubsection{XRC terminology}\label{xrcterminology} - -The usual XML terminology applies. In particular, we shall use the terms -{\it node}, {\it property} and {\it value} in the XML sense: - -\begin{verbatim} - ... -\end{verbatim} - -The term "attribute" is specific to XRC and refers to a property-less subnode -of an or node. In the example bellow, , - -\end{verbatim} - -\subsubsection{XRC format high-level description} - -An XRC resource file is a well-formed XML 1.0 document. - -The root node of XRC document must be . The node has -optional {\it version} property. Default version (in absence of the version -property) is "0.0.0.0". The version consists of four integers separated by -periods. Version of XRC format changes only if there was an incompatible -change introduced (i.e. either the library cannot understand old resource -files or older versions of the library wouldn't understand the new format). -The first three integers are major, minor and release number of the wxWindows -release when the change was introduced, the last one is revision number and -is 0 for the first incompatible change in given wxWindows release, 1 for -the second, and so on. - -Differences between versions are described within this document in paragraphs -entitled {\it Version Note}. - -The node is only allowed to have and -subnodes, all of which must have the "name" property. - - - TODO (name, class, subclass) - - - TODO (name, ref, subclass) - -\subsubsection{Common XRC attributes} - -Coming soon. - -\subsubsection{Supported classes} - -Coming soon. +Please see Technical Note 14 (docs/tech/tn0014.txt) in your wxWindows +distribution. \subsection{Adding new resource handlers}\label{newresourcehandlers}