Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
00001 /******************************************************************************** 00002 * * 00003 * F o u r - W a y S p l i t t e r * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1999,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: FX4Splitter.h,v 1.30 2006/02/20 03:32:12 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FX4SPLITTER_H 00025 #define FX4SPLITTER_H 00026 00027 #ifndef FXCOMPOSITE_H 00028 #include "FXComposite.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 // Splitter options 00034 enum { 00035 FOURSPLITTER_TRACKING = 0x00008000, // Track continuously during split 00036 FOURSPLITTER_NORMAL = 0 00037 }; 00038 00039 00040 00041 /** 00042 * The four-way splitter is a layout manager which manages 00043 * four children like four panes in a window. 00044 * You can use a four-way splitter for example in a CAD program 00045 * where you may want to maintain three orthographic views, and 00046 * one oblique view of a model. 00047 * The four-way splitter allows interactive repartitioning of the 00048 * panes by means of moving the central splitter bars. 00049 * When the four-way splitter is itself resized, each child is 00050 * proportionally resized, maintaining the same split-percentage. 00051 * The four-way splitter widget sends a SEL_CHANGED to its target 00052 * during the resizing of the panes; at the end of the resize interaction, 00053 * it sends a SEL_COMMAND to signify that the resize operation is complete. 00054 */ 00055 class FXAPI FX4Splitter : public FXComposite { 00056 FXDECLARE(FX4Splitter) 00057 private: 00058 FXint splitx; // Current x split 00059 FXint splity; // Current y split 00060 FXint barsize; // Size of the splitter bar 00061 FXint fhor; // Horizontal split fraction 00062 FXint fver; // Vertical split fraction 00063 FXint offx; 00064 FXint offy; 00065 FXuchar mode; 00066 protected: 00067 FX4Splitter(); 00068 FXuchar getMode(FXint x,FXint y); 00069 void moveSplit(FXint x,FXint y); 00070 void drawSplit(FXint x,FXint y,FXuint m); 00071 void adjustLayout(); 00072 private: 00073 FX4Splitter(const FX4Splitter&); 00074 FX4Splitter &operator=(const FX4Splitter&); 00075 public: 00076 long onLeftBtnPress(FXObject*,FXSelector,void*); 00077 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00078 long onMotion(FXObject*,FXSelector,void*); 00079 long onFocusUp(FXObject*,FXSelector,void*); 00080 long onFocusDown(FXObject*,FXSelector,void*); 00081 long onFocusLeft(FXObject*,FXSelector,void*); 00082 long onFocusRight(FXObject*,FXSelector,void*); 00083 long onCmdExpand(FXObject*,FXSelector,void*); 00084 long onUpdExpand(FXObject*,FXSelector,void*); 00085 public: 00086 enum { 00087 ExpandNone = 0, /// None expanded 00088 ExpandTopLeft = 1, /// Expand top left child 00089 ExpandTopRight = 2, /// Expand top right child 00090 ExpandBottomLeft = 4, /// Expand bottom left child 00091 ExpandBottomRight = 8, /// Expand bottom right child 00092 ExpandTop = ExpandTopLeft|ExpandTopRight, /// Expand top children 00093 ExpandBottom = ExpandBottomLeft|ExpandBottomRight, /// Expand bottom children 00094 ExpandLeft = ExpandTopLeft|ExpandBottomLeft, /// Expand left children 00095 ExpandRight = ExpandTopRight|ExpandBottomRight, /// Expand right children 00096 ExpandAll = ExpandLeft|ExpandRight /// Expand all children 00097 }; 00098 public: 00099 enum { 00100 ID_EXPAND_NONE=FXComposite::ID_LAST+ExpandNone, 00101 ID_EXPAND_TOP=ID_EXPAND_NONE+ExpandTop, 00102 ID_EXPAND_BOTTOM=ID_EXPAND_NONE+ExpandBottom, 00103 ID_EXPAND_LEFT=ID_EXPAND_NONE+ExpandLeft, 00104 ID_EXPAND_RIGHT=ID_EXPAND_NONE+ExpandRight, 00105 ID_EXPAND_TOPLEFT=ID_EXPAND_NONE+ExpandTopLeft, 00106 ID_EXPAND_TOPRIGHT=ID_EXPAND_NONE+ExpandTopRight, 00107 ID_EXPAND_BOTTOMLEFT=ID_EXPAND_NONE+ExpandBottomLeft, 00108 ID_EXPAND_BOTTOMRIGHT=ID_EXPAND_NONE+ExpandBottomRight, 00109 ID_EXPAND_ALL=ID_EXPAND_NONE+ExpandAll, 00110 ID_LAST 00111 }; 00112 public: 00113 00114 /// Create 4-way splitter, initially shown as four unexpanded panes 00115 FX4Splitter(FXComposite* p,FXuint opts=FOURSPLITTER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); 00116 00117 /// Create 4-way splitter, initially shown as four unexpanded panes; notifies target about size changes 00118 FX4Splitter(FXComposite* p,FXObject* tgt,FXSelector sel,FXuint opts=FOURSPLITTER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); 00119 00120 /// Get top left child, if any 00121 FXWindow *getTopLeft() const; 00122 00123 /// Get top right child, if any 00124 FXWindow *getTopRight() const; 00125 00126 /// Get bottom left child, if any 00127 FXWindow *getBottomLeft() const; 00128 00129 /// Get bottom right child, if any 00130 FXWindow *getBottomRight() const; 00131 00132 /// Get horizontal split fraction 00133 FXint getHSplit() const { return fhor; } 00134 00135 /// Get vertical split fraction 00136 FXint getVSplit() const { return fver; } 00137 00138 /// Change horizontal split fraction 00139 void setHSplit(FXint s); 00140 00141 /// Change vertical split fraction 00142 void setVSplit(FXint s); 00143 00144 /// Perform layout 00145 virtual void layout(); 00146 00147 /// Get default width 00148 virtual FXint getDefaultWidth(); 00149 00150 /// Get default height 00151 virtual FXint getDefaultHeight(); 00152 00153 /// Return current splitter style 00154 FXuint getSplitterStyle() const; 00155 00156 /// Change splitter style 00157 void setSplitterStyle(FXuint style); 00158 00159 /// Change splitter bar width 00160 void setBarSize(FXint bs); 00161 00162 /// Get splitter bar width 00163 FXint getBarSize() const { return barsize; } 00164 00165 /// Change set of expanded children 00166 void setExpanded(FXuint set=FX4Splitter::ExpandAll); 00167 00168 /// Get set of expanded children 00169 FXuint getExpanded() const; 00170 00171 /// Save to stream 00172 virtual void save(FXStream& store) const; 00173 00174 /// Load from stream 00175 virtual void load(FXStream& store); 00176 }; 00177 00178 } 00179 00180 #endif
Copyright © 1997-2005 Jeroen van der Zijp |