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

FXSplitter.h

00001 /******************************************************************************** 00002 * * 00003 * S p l i t t e r W i n d o w W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1997,2005 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: FXSplitter.h,v 1.28 2005/01/16 16:06:06 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXSPLITTER_H 00025 #define FXSPLITTER_H 00026 00027 #ifndef FXCOMPOSITE_H 00028 #include "FXComposite.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00034 /// Splitter options 00035 enum { 00036 SPLITTER_HORIZONTAL = 0, /// Split horizontally 00037 SPLITTER_VERTICAL = 0x00008000, /// Split vertically 00038 SPLITTER_REVERSED = 0x00010000, /// Reverse-anchored 00039 SPLITTER_TRACKING = 0x00020000, /// Track continuous during split 00040 SPLITTER_NORMAL = SPLITTER_HORIZONTAL 00041 }; 00042 00043 00044 00045 /** 00046 * Splitter window is used to interactively repartition 00047 * two or more subpanels. 00048 * Space may be subdivided horizontally (SPLITTER_HORIZONTAL, which 00049 * the default) or vertically (SPLITTER_VERTICAL option). 00050 * When the splitter is itself resized, the right-most (bottom-most) 00051 * child window will be resized unless the splitter window is reversed; 00052 * if the splitter is reversed, the left-most (top-most) child window 00053 * will be resized instead. 00054 * The splitter widget sends a SEL_CHANGED to its target 00055 * during the resizing of the panels; at the end of the resize interaction, 00056 * it sends a SEL_COMMAND to signify that the resize operation is complete. 00057 * Normally, children are resizable from 0 upwards; however, if the child 00058 * in a horizontally oriented splitter has LAYOUT_FILL_X in combination with 00059 * LAYOUT_FIX_WIDTH, it will not be made smaller than its default width, 00060 * except when the child is the last visible widget (or first when the option 00061 * SPLITTER_REVERSED has been passed to the splitter). 00062 * In a vertically oriented splitter, children with LAYOUT_FILL_Y and 00063 * LAYOUT_FIX_HEIGHT behave analogously. 00064 */ 00065 class FXAPI FXSplitter : public FXComposite { 00066 FXDECLARE(FXSplitter) 00067 private: 00068 FXWindow *window; // Window being resized 00069 FXint split; // Split value 00070 FXint offset; // Mouse offset 00071 FXint barsize; // Size of the splitter bar 00072 protected: 00073 FXSplitter(); 00074 void adjustHLayout(); 00075 void adjustVLayout(); 00076 void moveHSplit(FXint amount); 00077 void moveVSplit(FXint amount); 00078 void drawHSplit(FXint pos); 00079 void drawVSplit(FXint pos); 00080 FXWindow* findHSplit(FXint pos); 00081 FXWindow* findVSplit(FXint pos); 00082 private: 00083 FXSplitter(const FXSplitter&); 00084 FXSplitter& operator=(const FXSplitter&); 00085 public: 00086 long onLeftBtnPress(FXObject*,FXSelector,void*); 00087 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00088 long onMotion(FXObject*,FXSelector,void*); 00089 long onFocusNext(FXObject*,FXSelector,void*); 00090 long onFocusPrev(FXObject*,FXSelector,void*); 00091 long onFocusUp(FXObject*,FXSelector,void*); 00092 long onFocusDown(FXObject*,FXSelector,void*); 00093 long onFocusLeft(FXObject*,FXSelector,void*); 00094 long onFocusRight(FXObject*,FXSelector,void*); 00095 public: 00096 00097 /// Construct new splitter widget 00098 FXSplitter(FXComposite* p,FXuint opts=SPLITTER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); 00099 00100 /// Construct new splitter widget, which will notify target about size changes 00101 FXSplitter(FXComposite* p,FXObject* tgt,FXSelector sel,FXuint opts=SPLITTER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); 00102 00103 /// Get default width 00104 virtual FXint getDefaultWidth(); 00105 00106 /// Get default height 00107 virtual FXint getDefaultHeight(); 00108 00109 /// Perform layout 00110 virtual void layout(); 00111 00112 /// Return size of the panel at index 00113 FXint getSplit(FXint index) const; 00114 00115 /// Change the size of panel at the given index 00116 void setSplit(FXint index,FXint size); 00117 00118 /// Change splitter style 00119 void setSplitterStyle(FXuint style); 00120 00121 /// Return current splitter style 00122 FXuint getSplitterStyle() const; 00123 00124 /// Change splitter bar size 00125 void setBarSize(FXint bs); 00126 00127 /// Return current bar size 00128 FXint getBarSize() const { return barsize; } 00129 00130 /// Save to stream 00131 virtual void save(FXStream& store) const; 00132 00133 /// Load from stream 00134 virtual void load(FXStream& store); 00135 00136 /// Destroy splitter 00137 virtual ~FXSplitter(); 00138 }; 00139 00140 } 00141 00142 #endif

Copyright © 1997-2005 Jeroen van der Zijp