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