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

FXDockBar.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * D o c k B a r 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: FXDockBar.h,v 1.24 2006/01/22 17:58:00 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXDOCKBAR_H
25 #define FXDOCKBAR_H
26 
27 #ifndef FXPACKER_H
28 #include "FXPacker.h"
29 #endif
30 
31 namespace FX {
32 
33 class FXDockSite;
34 
35 
36 /**
37 * A dock bar widget can be docked inside a dock site widget, or floated
38 * around freely. Users can move, undock, and dock the dock bar widget
39 * by means of a handle such as a tool bar grip. When docking, the dock
40 * bar sends a SEL_DOCKED message to its target; when undocking, it sends
41 * a SEL_FLOATED message. In either case the dock site involved is passed
42 * in the void* pointer argument of the message.
43 */
44 class FXAPI FXDockBar : public FXPacker {
46 protected:
47  FXComposite *drydock; // Parent when docked
48  FXComposite *wetdock; // Parent when floating
49  FXint gripx; // Grip offset x
50  FXint gripy; // Grip offset y
51  FXuchar allowed; // Where we're allowed to dock
52 protected:
53  FXDockBar();
54 private:
55  FXDockBar(const FXDockBar&);
56  FXDockBar &operator=(const FXDockBar&);
57 public:
58  long onCmdUndock(FXObject*,FXSelector,void*);
59  long onUpdUndock(FXObject*,FXSelector,void*);
60  long onCmdDockTop(FXObject*,FXSelector,void*);
61  long onUpdDockTop(FXObject*,FXSelector,void*);
62  long onCmdDockBottom(FXObject*,FXSelector,void*);
63  long onUpdDockBottom(FXObject*,FXSelector,void*);
64  long onCmdDockLeft(FXObject*,FXSelector,void*);
65  long onUpdDockLeft(FXObject*,FXSelector,void*);
66  long onCmdDockRight(FXObject*,FXSelector,void*);
67  long onUpdDockRight(FXObject*,FXSelector,void*);
68  long onUpdDockFlip(FXObject*,FXSelector,void*);
69  long onBeginDragGrip(FXObject*,FXSelector,void*);
70  long onEndDragGrip(FXObject*,FXSelector,void*);
71  long onDraggedGrip(FXObject*,FXSelector,void*);
72  long onPopupMenu(FXObject*,FXSelector,void*);
73  long onDockTimer(FXObject*,FXSelector,void*);
74 public:
75  enum {
76  ID_DOCK_FLOAT=FXPacker::ID_LAST, /// Undock the dock bar
77  ID_DOCK_TOP, /// Dock on the top
78  ID_DOCK_BOTTOM, /// Dock on the bottom
79  ID_DOCK_LEFT, /// Dock on the left
80  ID_DOCK_RIGHT, /// Dock on the right
81  ID_DOCK_FLIP, /// Flip orientation
82  ID_TOOLBARGRIP, /// Tool bar grip
83  ID_TIMER,
84  ID_LAST
85  };
86 public:
87  enum {
88  ALLOW_NOWHERE=0, /// Don't allow docking anywhere
89  ALLOW_TOP=1, /// Docking at the top only
90  ALLOW_BOTTOM=2, /// Docking at the bottom only
91  ALLOW_LEFT=4, /// Docking at the left only
92  ALLOW_RIGHT=8, /// Docking at the right only
93  ALLOW_HORIZONTAL=ALLOW_TOP|ALLOW_BOTTOM, /// Docking at the top and bottom
94  ALLOW_VERTICAL=ALLOW_LEFT|ALLOW_RIGHT, /// Docking at the left and right
95  ALLOW_EVERYWHERE=ALLOW_HORIZONTAL|ALLOW_VERTICAL /// Docking can be everywhere
96  };
97 public:
98 
99  /**
100  * Construct a floatable dock bar, with a default parent p and an
101  * alternate parent q. To allow docking and dragging the default parent
102  * p must be of type FXDockSite, and the alternate parent q must be of
103  * type FXToolBarShell.
104  * Normally, the dock bar is docked under a window p of type FXDockSite.
105  * When floated, the toolbar can be docked under window q, which is
106  * usually an kind of FXToolBarShell window.
107  */
108  FXDockBar(FXComposite* p,FXComposite* q,FXuint opts=LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_X,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=3,FXint pr=3,FXint pt=2,FXint pb=2,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING);
109 
110  /**
111  * Construct a non-floatable dock bar.
112  * The dock bar can not be undocked.
113  */
114  FXDockBar(FXComposite* p,FXuint opts,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=2,FXint pr=3,FXint pt=3,FXint pb=2,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING);
115 
116  /// Return true if docked
117  FXbool isDocked() const;
118 
119  /**
120  * Check if the dock bar would dock or undock if at locaton barx, bary.
121  */
122  FXbool insideDock(FXDockSite* docksite,FXint barx,FXint bary);
123 
124  /**
125  * Set parent when docked.
126  * If it was docked, reparent under the new docking window.
127  */
128  void setDryDock(FXComposite* dry);
130  /**
131  * Set parent when floating.
132  * If it was undocked, then reparent under the new floating window.
133  */
134  void setWetDock(FXComposite* wet);
135 
136  /// Return parent when docked
137  FXComposite* getDryDock() const { return drydock; }
138 
139  /// Return parent when floating
140  FXComposite* getWetDock() const { return wetdock; }
141 
142  /// Search for dock against given side of main window
143  FXDockSite* findDockAtSide(FXuint side=LAYOUT_SIDE_TOP);
144 
145  /// Search for dock close to coordinates rootx, rooty
146  FXDockSite* findDockNear(FXint rootx,FXint rooty);
147 
148  /**
149  * Dock the bar against the given side, after some other widget.
150  * However, if after is -1, it will be docked as the innermost bar just before
151  * the work-area, while if after is 0, if will be docked as the outermost bar.
152  */
153  virtual void dock(FXDockSite* docksite,FXWindow* before=NULL,FXbool notify=FALSE);
154 
155  /**
156  * Dock the bar against the given side, near the given position relative
157  * to the toolbar dock's origin.
158  */
159  virtual void dock(FXDockSite* docksite,FXint localx,FXint localy,FXbool notify);
160 
161  /**
162  * Undock or float the bar.
163  * The initial position of the wet dock is a few pixels
164  * below and to the right of the original docked position.
165  */
166  virtual void undock(FXint rootx,FXint rooty,FXbool notify=FALSE);
167 
168  /**
169  * Change set of sides (a combination of ALLOW_TOP, ALLOW_LEFT, etc.),
170  * where docking is allowed. The default is to allow docking on all sides.
171  */
172  void allowedSides(FXuchar allow){ allowed=allow; }
173 
174  /**
175  * Return set of sides where docking is allowed
176  */
177  FXuchar allowedSides() const { return allowed; }
178 
179  /// Save toolbar to a stream
180  virtual void save(FXStream& store) const;
181 
182  /// Load toolbar from a stream
183  virtual void load(FXStream& store);
184 
185  /// Destroy
186  virtual ~FXDockBar();
187  };
188 
189 }
190 
191 #endif
Pack on top side (default)
Definition: FXWindow.h:41
Definition: FXWindow.h:241
unsigned int FXuint
Definition: fxdefs.h:396
FXuint FXSelector
Association key.
Definition: FXObject.h:53
#define FXAPI
Definition: fxdefs.h:122
FXuchar FXbool
Definition: fxdefs.h:393
Stretch or shrink horizontally.
Definition: FXWindow.h:62
Base composite.
Definition: FXComposite.h:35
#define NULL
Definition: fxdefs.h:41
Stick on top (default)
Definition: FXWindow.h:51
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:397
Packer is a layout manager which automatically places child windows inside its area against the left...
Definition: FXPacker.h:58
Stick on left (default)
Definition: FXWindow.h:47
#define FALSE
Definition: fxdefs.h:35
Definition: FXPacker.h:38
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
unsigned char FXuchar
Definition: fxdefs.h:392
#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