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

FXDockBar.h

00001 /******************************************************************************** 00002 * * 00003 * D o c k B a r W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2004,2005 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.17.2.1 2005/02/10 15:41:36 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. 00040 */ 00041 class FXAPI FXDockBar : public FXPacker { 00042 FXDECLARE(FXDockBar) 00043 protected: 00044 FXComposite *drydock; // Parent when docked 00045 FXComposite *wetdock; // Parent when floating 00046 FXint gripx; // Grip offset x 00047 FXint gripy; // Grip offset y 00048 FXuchar allowed; // Where we're allowed to dock 00049 protected: 00050 FXDockBar(); 00051 FXbool insideDock(FXDockSite* docksite,FXint barx,FXint bary); 00052 private: 00053 FXDockBar(const FXDockBar&); 00054 FXDockBar &operator=(const FXDockBar&); 00055 public: 00056 long onCmdUndock(FXObject*,FXSelector,void*); 00057 long onUpdUndock(FXObject*,FXSelector,void*); 00058 long onCmdDockTop(FXObject*,FXSelector,void*); 00059 long onUpdDockTop(FXObject*,FXSelector,void*); 00060 long onCmdDockBottom(FXObject*,FXSelector,void*); 00061 long onUpdDockBottom(FXObject*,FXSelector,void*); 00062 long onCmdDockLeft(FXObject*,FXSelector,void*); 00063 long onUpdDockLeft(FXObject*,FXSelector,void*); 00064 long onCmdDockRight(FXObject*,FXSelector,void*); 00065 long onUpdDockRight(FXObject*,FXSelector,void*); 00066 long onUpdDockFlip(FXObject*,FXSelector,void*); 00067 long onBeginDragGrip(FXObject*,FXSelector,void*); 00068 long onEndDragGrip(FXObject*,FXSelector,void*); 00069 long onDraggedGrip(FXObject*,FXSelector,void*); 00070 long onPopupMenu(FXObject*,FXSelector,void*); 00071 long onDockTimer(FXObject*,FXSelector,void*); 00072 public: 00073 enum { 00074 ID_DOCK_FLOAT=FXPacker::ID_LAST, /// Undock the dock bar 00075 ID_DOCK_TOP, /// Dock on the top 00076 ID_DOCK_BOTTOM, /// Dock on the bottom 00077 ID_DOCK_LEFT, /// Dock on the left 00078 ID_DOCK_RIGHT, /// Dock on the right 00079 ID_DOCK_FLIP, /// Flip orientation 00080 ID_TOOLBARGRIP, /// Tool bar grip 00081 ID_TIMER, 00082 ID_LAST 00083 }; 00084 public: 00085 enum { 00086 ALLOW_NOWHERE=0, /// Don't allow docking anywhere 00087 ALLOW_TOP=1, /// Docking at the top only 00088 ALLOW_BOTTOM=2, /// Docking at the bottom only 00089 ALLOW_LEFT=4, /// Docking at the left only 00090 ALLOW_RIGHT=8, /// Docking at the right only 00091 ALLOW_HORIZONTAL=ALLOW_TOP|ALLOW_BOTTOM, /// Docking at the top and bottom 00092 ALLOW_VERTICAL=ALLOW_LEFT|ALLOW_RIGHT, /// Docking at the left and right 00093 ALLOW_EVERYWHERE=ALLOW_HORIZONTAL|ALLOW_VERTICAL /// Docking can be everywhere 00094 }; 00095 public: 00096 00097 /** 00098 * Construct a floatable dock bar, with a default parent p and an 00099 * alternate parent q. To allow docking and dragging the default parent 00100 * p must be of type FXDockSite, and the alternate parent q must be of 00101 * type FXToolBarShell. 00102 * Normally, the dock bar is docked under a window p of type FXDockSite. 00103 * When floated, the toolbar can be docked under window q, which is 00104 * usually an kind of FXToolBarShell window. 00105 */ 00106 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); 00107 00108 /** 00109 * Construct a non-floatable dock bar. 00110 * The dock bar can not be undocked. 00111 */ 00112 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); 00113 00114 /// Return true if docked 00115 FXbool isDocked() const; 00116 00117 /** 00118 * Set parent when docked. 00119 * If it was docked, reparent under the new docking window. 00120 */ 00121 void setDryDock(FXComposite* dry); 00122 00123 /** 00124 * Set parent when floating. 00125 * If it was undocked, then reparent under the new floating window. 00126 */ 00127 void setWetDock(FXComposite* wet); 00128 00129 /// Return parent when docked 00130 FXComposite* getDryDock() const { return drydock; } 00131 00132 /// Return parent when floating 00133 FXComposite* getWetDock() const { return wetdock; } 00134 00135 /// Search for dock against given side of main window 00136 FXDockSite* findDockAtSide(FXuint side=LAYOUT_SIDE_TOP); 00137 00138 /// Search for dock close to coordinates rootx, rooty 00139 FXDockSite* findDockNear(FXint rootx,FXint rooty); 00140 00141 /** 00142 * Dock the bar against the given side, after some other widget. 00143 * However, if after is -1, it will be docked as the innermost bar just before 00144 * the work-area, while if after is 0, if will be docked as the outermost bar. 00145 */ 00146 virtual void dock(FXDockSite* docksite,FXWindow* before=NULL); 00147 00148 /** 00149 * Dock the bar against the given side, near the given position relative 00150 * to the toolbar dock's origin. 00151 */ 00152 virtual void dock(FXDockSite* docksite,FXint localx,FXint localy); 00153 00154 /** 00155 * Undock or float the bar. 00156 * The initial position of the wet dock is a few pixels 00157 * below and to the right of the original docked position. 00158 */ 00159 virtual void undock(FXint rootx,FXint rooty); 00160 00161 /** 00162 * Change set of sides where docking is allowed. 00163 * The default is to allow docking on all sides. 00164 */ 00165 void allowedSides(FXuchar allow=ALLOW_EVERYWHERE){ allowed=allow; } 00166 00167 /** 00168 * Return set of sides where docking is allowed 00169 */ 00170 FXuchar allowedSides() const { return allowed; } 00171 00172 /// Save toolbar to a stream 00173 virtual void save(FXStream& store) const; 00174 00175 /// Load toolbar from a stream 00176 virtual void load(FXStream& store); 00177 00178 /// Destroy 00179 virtual ~FXDockBar(); 00180 }; 00181 00182 } 00183 00184 #endif

Copyright © 1997-2005 Jeroen van der Zijp