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