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

FXDockSite.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                         D o c k S i t e   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: FXDockSite.h,v 1.30 2006/01/22 17:58:01 fox Exp $                        *
00023 ********************************************************************************/
00024 #ifndef FXDOCKSITE_H
00025 #define FXDOCKSITE_H
00026 
00027 #ifndef FXPACKER_H
00028 #include "FXPacker.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 class FXDockBar;
00035 
00036 /// Dock site options
00037 enum {
00038   DOCKSITE_WRAP    = 0,           /// Dockbars are wrapped to another galley when not enough space on current galley
00039   DOCKSITE_NO_WRAP = 0x00020000   /// Never wrap dockbars to another galley even if not enough space
00040   };
00041 
00042 
00043 /**
00044 * The dock site widget is a widget where dock bars can be docked.
00045 * Dock site widgets are typically embedded inside the main window, placed
00046 * against those sides where docking of toolbars is to be allowed.
00047 * Dock bars placed inside a dock site are laid out in horizontal or vertical bands
00048 * called galleys.  A toolbar with the LAYOUT_DOCK_SAME hint is preferentially placed
00049 * on the same galley as its previous sibling.  A dock bar with the LAYOUT_DOCK_NEXT is
00050 * always placed on the next galley.
00051 * Each galley will have at least one dock bar shown in it.  Several dock bars
00052 * may be placed side-by-side inside one galley, unless there is insufficient
00053 * room.  If there is insufficient room to place another dock bar, that dock bar
00054 * will be moved to the next galley, even though its LAYOUT_DOCK_NEXT option
00055 * is not set.  This implies that when the main window is resized and more room
00056 * becomes available, it will jump back to its preferred galley.
00057 * Within a galley, dock bars will be placed from left to right, at the given
00058 * x and y coordinates, with the constraints that the dock bar will stay within
00059 * the galley, and do not overlap each other.  It is possible to use LAYOUT_FILL_X
00060 * and/or LAYOUT_FILL_Y to stretch a toolbar to the available space on its galley.
00061 * The galleys are oriented horizontally if the dock site is placed inside
00062 * a top level window using LAYOUT_SIDE_TOP or LAYOUT_SIDE_BOTTOM, and
00063 * vertically oriented if placed with LAYOUT_SIDE_LEFT or LAYOUT_SIDE_RIGHT.
00064 */
00065 class FXAPI FXDockSite : public FXPacker {
00066   FXDECLARE(FXDockSite)
00067 protected:
00068   FXDockSite(){}
00069 private:
00070   FXDockSite(const FXDockSite&);
00071   FXDockSite &operator=(const FXDockSite&);
00072 protected:
00073   void moveVerBar(FXWindow* bar,FXWindow *begin,FXWindow* end,FXint bx,FXint by);
00074   void moveHorBar(FXWindow* bar,FXWindow *begin,FXWindow* end,FXint bx,FXint by);
00075   FXint galleyWidth(FXWindow *begin,FXWindow*& end,FXint space,FXint& require,FXint& expand) const;
00076   FXint galleyHeight(FXWindow *begin,FXWindow*& end,FXint space,FXint& require,FXint& expand) const;
00077 public:
00078 
00079   /**
00080   * Construct a toolbar dock layout manager.  Passing LAYOUT_SIDE_TOP or LAYOUT_SIDE_BOTTOM
00081   * causes the toolbar dock to be oriented horizontally.  Passing LAYOUT_SIDE_LEFT or
00082   * LAYOUT_SIDE_RIGHT causes it to be oriented vertically.
00083   */
00084   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);
00085 
00086   /**
00087   * Return default width.  This is the width the toolbar
00088   * dock would have if no toolbars need to be moved to other
00089   * galleys than they would be logically placed.
00090   */
00091   virtual FXint getDefaultWidth();
00092 
00093   /**
00094   * Return default height.  This is the height the toolbar
00095   * dock would have if no toolbars need to be moved to other
00096   * galleys than they would be logically placed.
00097   */
00098   virtual FXint getDefaultHeight();
00099 
00100   /**
00101   * For a vertically oriented dock site, this computes
00102   * the total width of all the galleys based on any "wrapping"
00103   * needed to fit the toolbars on a galley.
00104   */
00105   virtual FXint getWidthForHeight(FXint h);
00106 
00107   /**
00108   * For a horizontally oriented dock site, this computes
00109   * the total height of all the galleys based on any "wrapping"
00110   * needed to fit the toolbars on a galley.
00111   */
00112   virtual FXint getHeightForWidth(FXint w);
00113 
00114   /// Perform layout
00115   virtual void layout();
00116 
00117   /**
00118   * Move tool bar, changing its options to suite the new position.
00119   * Used by the toolbar dragging to rearrange the toolbars inside the
00120   * toolbar dock.
00121   */
00122   virtual void moveToolBar(FXDockBar* bar,FXint barx,FXint bary);
00123 
00124   /**
00125   * The dock site is notified that the given bar has been added
00126   * logically before the given window, and is to placed on a new
00127   * galley all by itself.  The default implementation adjusts
00128   * the layout options of the bars accordingly.
00129   */
00130   virtual void dockToolBar(FXDockBar* bar,FXWindow* before);
00131 
00132   /**
00133   * The dock site is informed that the given bar has been docked
00134   * at the given coordinates.  The default implementation determines
00135   * where to insert the newly docked bar and adjusts the layout
00136   * options of the bars accordingly.
00137   */
00138   virtual void dockToolBar(FXDockBar* bar,FXint barx,FXint bary);
00139 
00140   /**
00141   * The dock site is informed that the given bar has been removed.
00142   * In the default implementation, the dock site fixes the layout
00143   * options of the remaining bars so they stay in the same place
00144   * if possible.
00145   */
00146   virtual void undockToolBar(FXDockBar* bar);
00147 
00148   /// Change wrap option
00149   void wrapGalleys(FXbool wrap);
00150 
00151   /// Get wrap option
00152   FXbool wrapGalleys() const;
00153   };
00154 
00155 }
00156 
00157 #endif

Copyright © 1997-2005 Jeroen van der Zijp