]> git.saurik.com Git - wxWidgets.git/blame - contrib/docs/latex/fl/body.tex
Don't use a saved label size incase the size changes. Patch from Hong Yuan.
[wxWidgets.git] / contrib / docs / latex / fl / body.tex
CommitLineData
1c067fe3
WS
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%% Name: body.tex
3%% Purpose: FL documenation
4%% Author: wxWidgets Team
5%% Modified by:
6%% Created:
7%% RCS-ID: $Id$
8%% Copyright: (c) wxWidgets Team
9%% License: wxWindows license
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
499b2ed8
JS
12\chapter{Introduction}\label{introduction}
13\pagenumbering{arabic}%
14\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
15\setfooter{\thepage}{}{}{}{}{\thepage}%
16
4805d825 17\section{What is FL?}\label{whatisfl}
499b2ed8
JS
18
19This manual describes FL (Frame Layout), a
20class library for managing sophisticated window layout,
4805d825
JS
21with panes that can be moved around the main window
22and customized. FL handles many decoration and dragging
23issues, giving applications the kind of docking facilities
24that Visual C++ and Netscape Navigator possess.
25
99718b17
JS
26FL was written by Aleksandras Gluchovas, and is heavily used in
27wxWorkshop which he also wrote the bulk of.
28
29{\bf Please note} that this guide is in its infancy, and contributions
30from FL users are very welcome.
31
4805d825
JS
32The following screenshot (from fl\_demo1) shows a frame with a number of
33bars that can be dragged around. The vertical grippers with
34two lines allow a bar to be dragged in that row, changing the
35ordering of the bar if necessary.
36The dotted grippers (as in Netscape Navigator) allow
37a whole row to be moved, again changing the position of the row
38if required. While moving a bar or row, immediate feedback
39is given as the moving bar displaces other bars.
40
41Other features: the splitter bar shows a dotted thick line as
42it's dragged. Single-clicking on a row handle minimizes it to
43a horizontal tab which is given its own narrow row. This allows
5b5035ce 44the user to temporarily hide a row while allowing quick access
4805d825
JS
45to it when required.
46
47A close button (x) hides a bar completely. You can get it back again
48by right-clicking and selecting the appropriate menu item.
49
99718b17 50A left, right, up or down arrow button expands the pane in that direction.
4805d825
JS
51
52\center{\image{}{screen01.bmp}}
53
54\section{Compiling and using FL}
55
56FL can be found under the 'contrib' hierarchy, in the following directories:
57
58\begin{verbatim}
59 contrib/src/fl
60 contrib/include/wx/fl
61 contrib/samples/fl
99718b17 62 contrib/docs/latex/fl
4805d825
JS
63 docs/html/fl
64 docs/htmlhelp/fl.chm
65 docs/pdf/fl.pdf
66 docs/winhelp/fl.hlp
67\end{verbatim}
68
69To compile FL:
70
71\begin{itemize}\itemsep=0pt
72\item Under Windows using VC++, open the flVC.dsw project
73and compile.
74\item Under Unix, FL should be configured when you configured
75wxWindows. Make FL by changing directory to contrib/src/fl and
99718b17
JS
76type 'make'. {\bf Note:} there is currently a
77problem with the wxWindows build system that means that
78only the static version of library can be built at present.
4805d825
JS
79\end{itemize}
80
81To use FL:
82
83\begin{itemize}\itemsep=0pt
84\item Under Windows using VC++, link with fl[d].lib.
85\item Under Unix, link with libfl[d].a.
86\end{itemize}
87
88\section{FL concepts}
89
99718b17 90These are typical steps when adding FL functionality to your application.
4805d825
JS
91
92\begin{itemize}\itemsep=0pt
99718b17
JS
93\item include the appropriate header files;
94\item create a new \helpref{wxFrameLayout}{wxframelayout} passing the top-level frame and the window that
4805d825 95is interpreted as the main 'client' window;
99718b17
JS
96\item set an updates manager for optimizing drag operations;
97\item add plugins for implementing various features;
98\item add bars;
99\item enable floating mode for the layout if required;
100\item delete the frame layout in the main frame's destructor.
4805d825
JS
101\end{itemize}
102
99718b17
JS
103The following is taken from fl\_demo1 and shows the main code implementing the
104user interface as illustrated in \helpref{What is FL?}{whatisfl}.
105
4805d825 106\begin{verbatim}
99718b17
JS
107// fl headers
108#include "wx/fl/controlbar.h" // core API
109
110// extra plugins
111#include "wx/fl/barhintspl.h" // bevel for bars with "X"s and grooves
112#include "wx/fl/rowdragpl.h" // NC-look with draggable rows
113#include "wx/fl/cbcustom.h" // customization plugin
114#include "wx/fl/hintanimpl.h"
115
116// beauty-care
117#include "wx/fl/gcupdatesmgr.h" // smooth d&d
118#include "wx/fl/antiflickpl.h" // double-buffered repaint of decorations
119#include "wx/fl/dyntbar.h" // auto-layout toolbar
120#include "wx/fl/dyntbarhnd.h" // control-bar dimension handler for it
121
4805d825 122MyFrame::MyFrame(wxFrame *frame)
1c067fe3
WS
123 : wxFrame( frame, wxID_ANY, "wxWindows 2.0 wxFrameLayout Test Application", wxDefaultPosition,
124 wxSize( 700, 500 ),
125 wxCLIP_CHILDREN | wxMINIMIZE_BOX | wxMAXIMIZE_BOX |
126 wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION,
4805d825
JS
127 "freimas" )
128{
129 mpClientWnd = CreateTextCtrl( "Client window" );
1c067fe3 130
4805d825 131 mpLayout = new wxFrameLayout( this, mpClientWnd );
1c067fe3 132
4805d825 133 mpLayout->SetUpdatesManager( new cbGCUpdatesMgr() );
1c067fe3 134
4805d825
JS
135 // setup plugins for testing
136 mpLayout->PushDefaultPlugins();
1c067fe3 137
4805d825
JS
138 mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // fancy "X"es and bevel for bars
139 mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );
140 mpLayout->AddPlugin( CLASSINFO( cbRowDragPlugin ) );
141 mpLayout->AddPlugin( CLASSINFO( cbAntiflickerPlugin ) );
142 mpLayout->AddPlugin( CLASSINFO( cbSimpleCustomizationPlugin ) );
1c067fe3 143
4805d825 144 // drop in some bars
1c067fe3
WS
145 cbDimInfo sizes0( 200,45, // when docked horizontally
146 200,85, // when docked vertically
147 175,35, // when floated
4805d825
JS
148 FALSE, // the bar is not fixed-size
149 4, // vertical gap (bar border)
150 4 // horizontal gap (bar border)
1c067fe3
WS
151 );
152
153 cbDimInfo sizes1( 150,35, // when docked horizontally
154 150,85, // when docked vertically
155 175,35, // when floated
4805d825
JS
156 TRUE, // the bar is not fixed-size
157 4, // vertical gap (bar border)
158 4 // horizontal gap (bar border)
1c067fe3
WS
159 );
160
161 cbDimInfo sizes2( 175,45, // when docked horizontally
162 175,37, // when docked vertically
163 170,35, // when floated
4805d825
JS
164 TRUE, // the bar is not fixed-size
165 4, // vertical gap (bar border)
166 4, // horizontal gap (bar border)
167 new cbDynToolBarDimHandler()
1c067fe3
WS
168 );
169
4805d825
JS
170 mpLayout->AddBar( CreateTextCtrl("Hello"), // bar window
171 sizes0, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc)
172 0, // insert into 0th row (vert. position)
173 0, // offset from the start of row (in pixels)
99718b17 174 "InfoViewer1", // name for reference in customization pop-ups
4805d825
JS
175 TRUE
176 );
1c067fe3 177
4805d825
JS
178 mpLayout->AddBar( CreateTextCtrl("Bye"), // bar window
179 sizes0, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc)
180 1, // insert into 0th row (vert. position)
181 0, // offset from the start of row (in pixels)
99718b17 182 "InfoViewer2", // name for reference in customization pop-ups
4805d825
JS
183 TRUE
184 );
1c067fe3 185
4805d825
JS
186 mpLayout->AddBar( CreateTextCtrl("Fixed0"), // bar window
187 sizes1, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc)
188 0, // insert into 0th row (vert. position)
189 0, // offset from the start of row (in pixels)
99718b17 190 "ToolBar1", // name for reference in customization pop-ups
4805d825
JS
191 TRUE
192 );
1c067fe3 193
4805d825 194 wxDynamicToolBar* pToolBar = new wxDynamicToolBar();
1c067fe3 195
4805d825 196 pToolBar->Create( this, -1 );
1c067fe3 197
4805d825 198 // 1001-1006 ids of command events fired by added tool-buttons
1c067fe3 199
4805d825
JS
200 pToolBar->AddTool( 1001, BMP_DIR "new.bmp" );
201 pToolBar->AddTool( 1002, BMP_DIR "open.bmp" );
202 pToolBar->AddTool( 1003, BMP_DIR "save.bmp" );
1c067fe3 203
4805d825
JS
204 pToolBar->AddTool( 1004, BMP_DIR "cut.bmp" );
205 pToolBar->AddTool( 1005, BMP_DIR "copy.bmp" );
1c067fe3
WS
206 pToolBar->AddTool( 1006, BMP_DIR "paste.bmp" );
207
4805d825
JS
208 mpLayout->AddBar( pToolBar, // bar window (can be NULL)
209 sizes2, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc)
210 0, // insert into 0th row (vert. position)
211 0, // offset from the start of row (in pixels)
99718b17 212 "ToolBar2", // name for reference in customization pop-ups
4805d825
JS
213 FALSE
214 );
1c067fe3 215
4805d825
JS
216 mpLayout->EnableFloating( TRUE ); // off, thinking about wxGtk...
217}
4805d825 218
99718b17
JS
219MyFrame::~MyFrame()
220{
1c067fe3 221 if ( mpLayout)
99718b17
JS
222 delete mpLayout; // should be destroyed manually
223}
224\end{verbatim}
499b2ed8 225
6e8515a3
JS
226\section{Controlling dragging behaviour}\label{controllingdragbehav}
227
228Various pane-dragging behaviours are supported. FL can
229show an outline of where the window would be docked
230if you stopped dragging at that point.
231
232This is a list of properties of interest in the cbCommonPaneProperties
233structure:
234
235\begin{verbatim}
236 bool mRealTimeUpdatesOn; // default: ON
237 bool mOutOfPaneDragOn; // default: ON
238 bool mExactDockPredictionOn; // default: OFF
239 bool mNonDestructFrictionOn; // default: OFF
240\end{verbatim}
241
242To get behaviour similar to Microsoft's DevStudio drag-ghost behaviour,
243mRealTimeUpdatesOn have to be set to FALSE, for example:
244
245\begin{verbatim}
246 cbCommonPaneProperties props;
247 ....
248 ....
249 props.mRealTimeUpdatesOn = FALSE;
250 fl->SetPaneProperties( props, wxALL_PANES );
251\end{verbatim}
252
253{\it mOutOfPaneDragOn} specifies whether bars can be dragged
254away from this pane. (Note: this may not currently be working.)
255
256{\it mExactDockPredictionOn} is only relevant when {\it mRealTimeUpdatesOn} is FALSE,
257and then the hint rectangle behaves a little jumpily. It tries to show
258exatly how the bar would look and where it would be docked if the dragging finished right
259now, i.e. the final position, with all the 'friction-physics' calculated.
260Otherwise the hint flies smothly above the surface only hinting whether the bar
261will be docked vertically or horizontally if dropped now.
262This is a feature you won't find anywhere else!
263
264{\it mNonDestructFirctionOn} causes the bars not being dragged
265to stay where they are, while the currently dragged one is 'diving'
266through the underlaying panes, docking itself in and out in real time.
267Otherwise the stationary bars would be pushed around messing up the composition permanently.
268This flag is irelevant when {\it mRealTimeUpdatesOn} is FALSE, as the ghost-rect
269does not do any docking until the drag finishes.