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