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

FXToolbar.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                        T o o l b a r   W i d g e t                            *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2000,2002 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: FXToolbar.h,v 1.40 2002/01/18 22:42:55 jeroen Exp $                      *
00023 ********************************************************************************/
00024 #ifndef FXTOOLBAR_H
00025 #define FXTOOLBAR_H
00026 
00027 #ifndef FXPACKER_H
00028 #include "FXPacker.h"
00029 #endif
00030 
00031 
00032 
00033 /**
00034 * Toolbar control.
00035 */
00036 class FXAPI FXToolbar : public FXPacker {
00037   FXDECLARE(FXToolbar)
00038 protected:
00039   FXComposite   *drydock;     // Parent when docked
00040   FXComposite   *wetdock;     // Parent when floating
00041   FXRectangle    outline;     // Outline shown while dragging
00042   FXWindow      *dockafter;   // Dock after this window
00043   FXuint         dockside;    // Dock on this side
00044   FXbool         docking;     // Dock it
00045 protected:
00046   FXToolbar();
00047   virtual void layout();
00048 private:
00049   FXToolbar(const FXToolbar&);
00050   FXToolbar &operator=(const FXToolbar&);
00051 public:
00052   long onCmdUndock(FXObject*,FXSelector,void*);
00053   long onUpdUndock(FXObject*,FXSelector,void*);
00054   long onCmdDockTop(FXObject*,FXSelector,void*);
00055   long onUpdDockTop(FXObject*,FXSelector,void*);
00056   long onCmdDockBottom(FXObject*,FXSelector,void*);
00057   long onUpdDockBottom(FXObject*,FXSelector,void*);
00058   long onCmdDockLeft(FXObject*,FXSelector,void*);
00059   long onUpdDockLeft(FXObject*,FXSelector,void*);
00060   long onCmdDockRight(FXObject*,FXSelector,void*);
00061   long onUpdDockRight(FXObject*,FXSelector,void*);
00062   long onBeginDragGrip(FXObject*,FXSelector,void*);
00063   long onEndDragGrip(FXObject*,FXSelector,void*);
00064   long onDraggedGrip(FXObject*,FXSelector,void*);
00065 public:
00066   enum {
00067     ID_UNDOCK=FXPacker::ID_LAST,  /// Undock the toolbar
00068     ID_DOCK_TOP,                  /// Dock on the top
00069     ID_DOCK_BOTTOM,               /// Dock on the bottom
00070     ID_DOCK_LEFT,                 /// Dock on the left
00071     ID_DOCK_RIGHT,                /// Dock on the right
00072     ID_TOOLBARGRIP,               /// Notifications from toolbar grip
00073     ID_LAST
00074     };
00075 public:
00076 
00077   /**
00078   * Construct a floatable toolbar
00079   * Normally, the toolbar is docked under window p.
00080   * When floated, the toolbar can be docked under window q, which is
00081   * typically an FXToolbarShell window.
00082   */
00083   FXToolbar(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);
00084 
00085   /**
00086   * Construct a non-floatable toolbar.
00087   * The toolbar can not be undocked.
00088   */
00089   FXToolbar(FXComposite* p,FXuint opts=LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_X,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);
00090 
00091   /**
00092   * Set parent when docked.
00093   * If it was docked, reparent under the new docking window.
00094   */
00095   void setDryDock(FXComposite* dry);
00096 
00097   /**
00098   * Set parent when floating.
00099   * If it was undocked, then reparent under the new floating window.
00100   */
00101   void setWetDock(FXComposite* wet);
00102 
00103   /// Return parent when docked
00104   FXComposite* getDryDock() const { return drydock; }
00105 
00106   /// Return parent when floating
00107   FXComposite* getWetDock() const { return wetdock; }
00108 
00109   /// Return true if toolbar is docked
00110   FXbool isDocked() const;
00111 
00112   /**
00113   * Dock the bar against the given side, after some other widget.
00114   * However, if after is -1, it will be docked as the innermost bar just before
00115   * the work-area, while if after is 0, if will be docked as the outermost bar.
00116   */
00117   virtual void dock(FXuint side=LAYOUT_SIDE_TOP,FXWindow* after=(FXWindow*)-1);
00118 
00119   /**
00120   * Undock or float the bar.
00121   * The initial position of the wet dock is a few pixels
00122   * below and to the right of the original docked position.
00123   */
00124   virtual void undock();
00125 
00126   /// Return default width
00127   virtual FXint getDefaultWidth();
00128 
00129   /// Return default height
00130   virtual FXint getDefaultHeight();
00131 
00132   /// Return width for given height
00133   virtual FXint getWidthForHeight(FXint h);
00134 
00135   /// Return height for given width
00136   virtual FXint getHeightForWidth(FXint w);
00137 
00138   /// Set docking side
00139   void setDockingSide(FXuint side=LAYOUT_SIDE_TOP);
00140 
00141   /// Return docking side
00142   FXuint getDockingSide() const;
00143 
00144   /// Save toolbar to a stream
00145   virtual void save(FXStream& store) const;
00146 
00147   /// Load toolbar from a stream
00148   virtual void load(FXStream& store);
00149 
00150   /// Destroy
00151   virtual ~FXToolbar();
00152   };
00153 
00154 
00155 
00156 #endif