Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
00001 /******************************************************************************** 00002 * * 00003 * D o c k B a r W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2004,2006 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************* 00022 * $Id: FXDockBar.h,v 1.24 2006/01/22 17:58:00 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXDOCKBAR_H 00025 #define FXDOCKBAR_H 00026 00027 #ifndef FXPACKER_H 00028 #include "FXPacker.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 class FXDockSite; 00034 00035 00036 /** 00037 * A dock bar widget can be docked inside a dock site widget, or floated 00038 * around freely. Users can move, undock, and dock the dock bar widget 00039 * by means of a handle such as a tool bar grip. When docking, the dock 00040 * bar sends a SEL_DOCKED message to its target; when undocking, it sends 00041 * a SEL_FLOATED message. In either case the dock site involved is passed 00042 * in the void* pointer argument of the message. 00043 */ 00044 class FXAPI FXDockBar : public FXPacker { 00045 FXDECLARE(FXDockBar) 00046 protected: 00047 FXComposite *drydock; // Parent when docked 00048 FXComposite *wetdock; // Parent when floating 00049 FXint gripx; // Grip offset x 00050 FXint gripy; // Grip offset y 00051 FXuchar allowed; // Where we're allowed to dock 00052 protected: 00053 FXDockBar(); 00054 private: 00055 FXDockBar(const FXDockBar&); 00056 FXDockBar &operator=(const FXDockBar&); 00057 public: 00058 long onCmdUndock(FXObject*,FXSelector,void*); 00059 long onUpdUndock(FXObject*,FXSelector,void*); 00060 long onCmdDockTop(FXObject*,FXSelector,void*); 00061 long onUpdDockTop(FXObject*,FXSelector,void*); 00062 long onCmdDockBottom(FXObject*,FXSelector,void*); 00063 long onUpdDockBottom(FXObject*,FXSelector,void*); 00064 long onCmdDockLeft(FXObject*,FXSelector,void*); 00065 long onUpdDockLeft(FXObject*,FXSelector,void*); 00066 long onCmdDockRight(FXObject*,FXSelector,void*); 00067 long onUpdDockRight(FXObject*,FXSelector,void*); 00068 long onUpdDockFlip(FXObject*,FXSelector,void*); 00069 long onBeginDragGrip(FXObject*,FXSelector,void*); 00070 long onEndDragGrip(FXObject*,FXSelector,void*); 00071 long onDraggedGrip(FXObject*,FXSelector,void*); 00072 long onPopupMenu(FXObject*,FXSelector,void*); 00073 long onDockTimer(FXObject*,FXSelector,void*); 00074 public: 00075 enum { 00076 ID_DOCK_FLOAT=FXPacker::ID_LAST, /// Undock the dock bar 00077 ID_DOCK_TOP, /// Dock on the top 00078 ID_DOCK_BOTTOM, /// Dock on the bottom 00079 ID_DOCK_LEFT, /// Dock on the left 00080 ID_DOCK_RIGHT, /// Dock on the right 00081 ID_DOCK_FLIP, /// Flip orientation 00082 ID_TOOLBARGRIP, /// Tool bar grip 00083 ID_TIMER, 00084 ID_LAST 00085 }; 00086 public: 00087 enum { 00088 ALLOW_NOWHERE=0, /// Don't allow docking anywhere 00089 ALLOW_TOP=1, /// Docking at the top only 00090 ALLOW_BOTTOM=2, /// Docking at the bottom only 00091 ALLOW_LEFT=4, /// Docking at the left only 00092 ALLOW_RIGHT=8, /// Docking at the right only 00093 ALLOW_HORIZONTAL=ALLOW_TOP|ALLOW_BOTTOM, /// Docking at the top and bottom 00094 ALLOW_VERTICAL=ALLOW_LEFT|ALLOW_RIGHT, /// Docking at the left and right 00095 ALLOW_EVERYWHERE=ALLOW_HORIZONTAL|ALLOW_VERTICAL /// Docking can be everywhere 00096 }; 00097 public: 00098 00099 /** 00100 * Construct a floatable dock bar, with a default parent p and an 00101 * alternate parent q. To allow docking and dragging the default parent 00102 * p must be of type FXDockSite, and the alternate parent q must be of 00103 * type FXToolBarShell. 00104 * Normally, the dock bar is docked under a window p of type FXDockSite. 00105 * When floated, the toolbar can be docked under window q, which is 00106 * usually an kind of FXToolBarShell window. 00107 */ 00108 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); 00109 00110 /** 00111 * Construct a non-floatable dock bar. 00112 * The dock bar can not be undocked. 00113 */ 00114 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); 00115 00116 /// Return true if docked 00117 FXbool isDocked() const; 00118 00119 /** 00120 * Check if the dock bar would dock or undock if at locaton barx, bary. 00121 */ 00122 FXbool insideDock(FXDockSite* docksite,FXint barx,FXint bary); 00123 00124 /** 00125 * Set parent when docked. 00126 * If it was docked, reparent under the new docking window. 00127 */ 00128 void setDryDock(FXComposite* dry); 00129 00130 /** 00131 * Set parent when floating. 00132 * If it was undocked, then reparent under the new floating window. 00133 */ 00134 void setWetDock(FXComposite* wet); 00135 00136 /// Return parent when docked 00137 FXComposite* getDryDock() const { return drydock; } 00138 00139 /// Return parent when floating 00140 FXComposite* getWetDock() const { return wetdock; } 00141 00142 /// Search for dock against given side of main window 00143 FXDockSite* findDockAtSide(FXuint side=LAYOUT_SIDE_TOP); 00144 00145 /// Search for dock close to coordinates rootx, rooty 00146 FXDockSite* findDockNear(FXint rootx,FXint rooty); 00147 00148 /** 00149 * Dock the bar against the given side, after some other widget. 00150 * However, if after is -1, it will be docked as the innermost bar just before 00151 * the work-area, while if after is 0, if will be docked as the outermost bar. 00152 */ 00153 virtual void dock(FXDockSite* docksite,FXWindow* before=NULL,FXbool notify=FALSE); 00154 00155 /** 00156 * Dock the bar against the given side, near the given position relative 00157 * to the toolbar dock's origin. 00158 */ 00159 virtual void dock(FXDockSite* docksite,FXint localx,FXint localy,FXbool notify); 00160 00161 /** 00162 * Undock or float the bar. 00163 * The initial position of the wet dock is a few pixels 00164 * below and to the right of the original docked position. 00165 */ 00166 virtual void undock(FXint rootx,FXint rooty,FXbool notify=FALSE); 00167 00168 /** 00169 * Change set of sides (a combination of ALLOW_TOP, ALLOW_LEFT, etc.), 00170 * where docking is allowed. The default is to allow docking on all sides. 00171 */ 00172 void allowedSides(FXuchar allow){ allowed=allow; } 00173 00174 /** 00175 * Return set of sides where docking is allowed 00176 */ 00177 FXuchar allowedSides() const { return allowed; } 00178 00179 /// Save toolbar to a stream 00180 virtual void save(FXStream& store) const; 00181 00182 /// Load toolbar from a stream 00183 virtual void load(FXStream& store); 00184 00185 /// Destroy 00186 virtual ~FXDockBar(); 00187 }; 00188 00189 } 00190 00191 #endif
Copyright © 1997-2005 Jeroen van der Zijp |