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

FXDockBar.h

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

Copyright © 1997-2009 Jeroen van der Zijp