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,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: FXSplitter.h,v 1.21 2002/03/12 07:11:31 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 subpanes.
00048 * Space may be subdivided horizontally or vertically.
00049 * When the splitter is itself resized, the right-most (bottom-most)
00050 * child window will be resized unless the splitter window is reversed;
00051 * if the splitter is reversed, the left-most (top-most) child window
00052 * will be resized instead.
00053 * The splitter widget sends a SEL_CHANGED to its target
00054 * during the resizing of the panes; at the end of the resize interaction,
00055 * it sends a SEL_COMMAND to signify that the resize operation is complete.
00056 * Normally, children are resizable from 0 upwards; however, if the child
00057 * in a horizontally oriented splitter has LAYOUT_FILL_X in combination with
00058 * LAYOUT_FIX_WIDTH, it will not be made smaller than its default width,
00059 * except when the child is the last visible widget (or first when the option
00060 * SPLITTER_REVERSED has been passed to the splitter).
00061 * In a vertically oriented splitter, children with LAYOUT_FILL_Y and
00062 * LAYOUT_FIX_HEIGHT behave analogously.
00063 * These options only affect interactive resizing.
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   virtual void layout();
00075   void adjustHLayout();
00076   void adjustVLayout();
00077   void moveHSplit(FXint amount);
00078   void moveVSplit(FXint amount);
00079   void drawHSplit(FXint pos);
00080   void drawVSplit(FXint pos);
00081   FXWindow* findHSplit(FXint pos);
00082   FXWindow* findVSplit(FXint pos);
00083 private:
00084   FXSplitter(const FXSplitter&);
00085   FXSplitter& operator=(const FXSplitter&);
00086 public:
00087   long onLeftBtnPress(FXObject*,FXSelector,void*);
00088   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00089   long onMotion(FXObject*,FXSelector,void*);
00090   long onFocusNext(FXObject*,FXSelector,void*);
00091   long onFocusPrev(FXObject*,FXSelector,void*);
00092   long onFocusUp(FXObject*,FXSelector,void*);
00093   long onFocusDown(FXObject*,FXSelector,void*);
00094   long onFocusLeft(FXObject*,FXSelector,void*);
00095   long onFocusRight(FXObject*,FXSelector,void*);
00096 public:
00097 
00098   /// Construct new splitter widget
00099   FXSplitter(FXComposite* p,FXuint opts=SPLITTER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00100 
00101   /// Construct new splitter widget, which will notify target about size changes
00102   FXSplitter(FXComposite* p,FXObject* tgt,FXSelector sel,FXuint opts=SPLITTER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00103 
00104   /// Get default width
00105   virtual FXint getDefaultWidth();
00106 
00107   /// Get default height
00108   virtual FXint getDefaultHeight();
00109 
00110   /// Change splitter style
00111   void setSplitterStyle(FXuint style);
00112 
00113   /// Return current splitter style
00114   FXuint getSplitterStyle() const;
00115 
00116   /// Change splitter bar size
00117   void setBarSize(FXint bs);
00118 
00119   /// Return current bar size
00120   FXint getBarSize() const { return barsize; }
00121 
00122   /// Save to stream
00123   virtual void save(FXStream& store) const;
00124 
00125   /// Load from stream
00126   virtual void load(FXStream& store);
00127 
00128   /// Destroy splitter
00129   virtual ~FXSplitter();
00130   };
00131 
00132 }
00133 
00134 #endif