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.19 2002/01/18 22:42:54 jeroen Exp $                     *
00023 ********************************************************************************/
00024 #ifndef FXSPLITTER_H
00025 #define FXSPLITTER_H
00026 
00027 #ifndef FXCOMPOSITE_H
00028 #include "FXComposite.h"
00029 #endif
00030 
00031 
00032 
00033 /// Splitter options
00034 enum {
00035   SPLITTER_HORIZONTAL = 0,                  /// Split horizontally
00036   SPLITTER_VERTICAL   = 0x00008000,         /// Split vertically
00037   SPLITTER_REVERSED   = 0x00010000,         /// Reverse-anchored
00038   SPLITTER_TRACKING   = 0x00020000,         /// Track continuous during split
00039   SPLITTER_NORMAL     = SPLITTER_HORIZONTAL
00040   };
00041 
00042 
00043 
00044 /**
00045 * Splitter window is used to interactively repartition
00046 * two or more subpanes.
00047 * Space may be subdivided horizontally or vertically.
00048 * When the splitter is itself resized, the right-most (bottom-most)
00049 * child window will be resized unless the splitter window is reversed;
00050 * if the splitter is reversed, the left-most (top-most) child window
00051 * will be resized instead.
00052 * The splitter widget sends a SEL_CHANGED to its target
00053 * during the resizing of the panes; at the end of the resize interaction,
00054 * it sends a SEL_COMMAND to signify that the resize operation is complete.
00055 * Normally, children are resizable from 0 upwards; however, if the child
00056 * in a horizontally oriented splitter has LAYOUT_FILL_X in combination with
00057 * LAYOUT_FIX_WIDTH, it will not be made smaller than its default width,
00058 * except when the child is the last visible widget (or first when the option
00059 * SPLITTER_REVERSED has been passed to the splitter).
00060 * In a vertically oriented splitter, children with LAYOUT_FILL_Y and
00061 * LAYOUT_FIX_HEIGHT behave analogously.
00062 * These options only affect interactive resizing.
00063 */
00064 class FXAPI FXSplitter : public FXComposite {
00065   FXDECLARE(FXSplitter)
00066 private:
00067   FXWindow *window;         // Window being resized
00068   FXint     split;          // Split value
00069   FXint     offset;         // Mouse offset
00070   FXint     barsize;        // Size of the splitter bar
00071 protected:
00072   FXSplitter();
00073   virtual void layout();
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   /// Change splitter style
00110   void setSplitterStyle(FXuint style);
00111 
00112   /// Return current splitter style
00113   FXuint getSplitterStyle() const;
00114 
00115   /// Change splitter bar size
00116   void setBarSize(FXint bs);
00117 
00118   /// Return current bar size
00119   FXint getBarSize() const { return barsize; }
00120 
00121   /// Save to stream
00122   virtual void save(FXStream& store) const;
00123 
00124   /// Load from stream
00125   virtual void load(FXStream& store);
00126 
00127   /// Destroy splitter
00128   virtual ~FXSplitter();
00129   };
00130 
00131 
00132 #endif