Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXDockSite.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * D o c k S i t e W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2004,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXDockSite.h,v 1.30 2006/01/22 17:58:01 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXDOCKSITE_H
25 #define FXDOCKSITE_H
26 
27 #ifndef FXPACKER_H
28 #include "FXPacker.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 class FXDockBar;
35 
36 /// Dock site options
37 enum {
38  DOCKSITE_WRAP = 0, /// Dockbars are wrapped to another galley when not enough space on current galley
39  DOCKSITE_NO_WRAP = 0x00020000 /// Never wrap dockbars to another galley even if not enough space
40  };
41 
42 
43 /**
44 * The dock site widget is a widget where dock bars can be docked.
45 * Dock site widgets are typically embedded inside the main window, placed
46 * against those sides where docking of toolbars is to be allowed.
47 * Dock bars placed inside a dock site are laid out in horizontal or vertical bands
48 * called galleys. A toolbar with the LAYOUT_DOCK_SAME hint is preferentially placed
49 * on the same galley as its previous sibling. A dock bar with the LAYOUT_DOCK_NEXT is
50 * always placed on the next galley.
51 * Each galley will have at least one dock bar shown in it. Several dock bars
52 * may be placed side-by-side inside one galley, unless there is insufficient
53 * room. If there is insufficient room to place another dock bar, that dock bar
54 * will be moved to the next galley, even though its LAYOUT_DOCK_NEXT option
55 * is not set. This implies that when the main window is resized and more room
56 * becomes available, it will jump back to its preferred galley.
57 * Within a galley, dock bars will be placed from left to right, at the given
58 * x and y coordinates, with the constraints that the dock bar will stay within
59 * the galley, and do not overlap each other. It is possible to use LAYOUT_FILL_X
60 * and/or LAYOUT_FILL_Y to stretch a toolbar to the available space on its galley.
61 * The galleys are oriented horizontally if the dock site is placed inside
62 * a top level window using LAYOUT_SIDE_TOP or LAYOUT_SIDE_BOTTOM, and
63 * vertically oriented if placed with LAYOUT_SIDE_LEFT or LAYOUT_SIDE_RIGHT.
64 */
65 class FXAPI FXDockSite : public FXPacker {
67 protected:
68  FXDockSite(){}
69 private:
70  FXDockSite(const FXDockSite&);
71  FXDockSite &operator=(const FXDockSite&);
72 protected:
73  void moveVerBar(FXWindow* bar,FXWindow *begin,FXWindow* end,FXint bx,FXint by);
74  void moveHorBar(FXWindow* bar,FXWindow *begin,FXWindow* end,FXint bx,FXint by);
75  FXint galleyWidth(FXWindow *begin,FXWindow*& end,FXint space,FXint& require,FXint& expand) const;
76  FXint galleyHeight(FXWindow *begin,FXWindow*& end,FXint space,FXint& require,FXint& expand) const;
77 public:
78 
79  /**
80  * Construct a toolbar dock layout manager. Passing LAYOUT_SIDE_TOP or LAYOUT_SIDE_BOTTOM
81  * causes the toolbar dock to be oriented horizontally. Passing LAYOUT_SIDE_LEFT or
82  * LAYOUT_SIDE_RIGHT causes it to be oriented vertically.
83  */
84  FXDockSite(FXComposite *p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=0,FXint pr=0,FXint pt=0,FXint pb=0,FXint hs=0,FXint vs=0);
85 
86  /**
87  * Return default width. This is the width the toolbar
88  * dock would have if no toolbars need to be moved to other
89  * galleys than they would be logically placed.
90  */
91  virtual FXint getDefaultWidth();
92 
93  /**
94  * Return default height. This is the height the toolbar
95  * dock would have if no toolbars need to be moved to other
96  * galleys than they would be logically placed.
97  */
98  virtual FXint getDefaultHeight();
99 
100  /**
101  * For a vertically oriented dock site, this computes
102  * the total width of all the galleys based on any "wrapping"
103  * needed to fit the toolbars on a galley.
104  */
105  virtual FXint getWidthForHeight(FXint h);
106 
107  /**
108  * For a horizontally oriented dock site, this computes
109  * the total height of all the galleys based on any "wrapping"
110  * needed to fit the toolbars on a galley.
111  */
112  virtual FXint getHeightForWidth(FXint w);
113 
114  /// Perform layout
115  virtual void layout();
116 
117  /**
118  * Move tool bar, changing its options to suite the new position.
119  * Used by the toolbar dragging to rearrange the toolbars inside the
120  * toolbar dock.
121  */
122  virtual void moveToolBar(FXDockBar* bar,FXint barx,FXint bary);
123 
124  /**
125  * The dock site is notified that the given bar has been added
126  * logically before the given window, and is to placed on a new
127  * galley all by itself. The default implementation adjusts
128  * the layout options of the bars accordingly.
129  */
130  virtual void dockToolBar(FXDockBar* bar,FXWindow* before);
131 
132  /**
133  * The dock site is informed that the given bar has been docked
134  * at the given coordinates. The default implementation determines
135  * where to insert the newly docked bar and adjusts the layout
136  * options of the bars accordingly.
137  */
138  virtual void dockToolBar(FXDockBar* bar,FXint barx,FXint bary);
139 
140  /**
141  * The dock site is informed that the given bar has been removed.
142  * In the default implementation, the dock site fixes the layout
143  * options of the remaining bars so they stay in the same place
144  * if possible.
145  */
146  virtual void undockToolBar(FXDockBar* bar);
147 
148  /// Change wrap option
149  void wrapGalleys(FXbool wrap);
150 
151  /// Get wrap option
152  FXbool wrapGalleys() const;
153  };
154 
155 }
156 
157 #endif
Base class for all windows.
Definition: FXWindow.h:115
unsigned int FXuint
Definition: fxdefs.h:396
#define FXAPI
Definition: fxdefs.h:122
FXuchar FXbool
Definition: fxdefs.h:393
Never wrap dockbars to another galley even if not enough space.
Definition: FXDockSite.h:42
Base composite.
Definition: FXComposite.h:35
The dock site widget is a widget where dock bars can be docked.
Definition: FXDockSite.h:72
Dockbars are wrapped to another galley when not enough space on current galley.
Definition: FXDockSite.h:41
int FXint
Definition: fxdefs.h:397
FXString expand(const FXString &file)
Perform tilde or environment variable expansion.
Packer is a layout manager which automatically places child windows inside its area against the left...
Definition: FXPacker.h:58
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
A dock bar widget can be docked inside a dock site widget, or floated around freely.
Definition: FXDockBar.h:44

Copyright © 1997-2005 Jeroen van der Zijp