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

FX4Splitter.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                       F o u r - W a y   S p l i t t e r                       *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1999,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: FX4Splitter.h,v 1.21 2002/01/18 22:42:51 jeroen Exp $                    *
00023 ********************************************************************************/
00024 #ifndef FX4SPLITTER_H
00025 #define FX4SPLITTER_H
00026 
00027 #ifndef FXCOMPOSITE_H
00028 #include "FXComposite.h"
00029 #endif
00030 
00031 
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     expanded;       // Panes which are expanded
00061   FXint     barsize;        // Size of the splitter bar
00062   FXint     fhor;           // Horizontal split fraction
00063   FXint     fver;           // Vertical split fraction
00064   FXint     offx;
00065   FXint     offy;
00066   FXuchar   mode;
00067 protected:
00068   FX4Splitter();
00069   FXuchar getMode(FXint x,FXint y);
00070   void moveSplit(FXint x,FXint y);
00071   void drawSplit(FXint x,FXint y);
00072   void adjustLayout();
00073   virtual void layout();
00074 private:
00075   FX4Splitter(const FX4Splitter&);
00076   FX4Splitter &operator=(const FX4Splitter&);
00077 public:
00078   long onLeftBtnPress(FXObject*,FXSelector,void*);
00079   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00080   long onMotion(FXObject*,FXSelector,void*);
00081   long onFocusUp(FXObject*,FXSelector,void*);
00082   long onFocusDown(FXObject*,FXSelector,void*);
00083   long onFocusLeft(FXObject*,FXSelector,void*);
00084   long onFocusRight(FXObject*,FXSelector,void*);
00085   long onCmdExpand(FXObject*,FXSelector,void*);
00086   long onUpdExpand(FXObject*,FXSelector,void*);
00087 public:
00088   enum {
00089     ID_EXPAND_ALL=FXComposite::ID_LAST,
00090     ID_EXPAND_TOPLEFT,
00091     ID_EXPAND_TOPRIGHT,
00092     ID_EXPAND_BOTTOMLEFT,
00093     ID_EXPAND_BOTTOMRIGHT,
00094     ID_LAST
00095     };
00096 public:
00097 
00098   /// Create 4-way splitter, initially shown as four unexpanded panes
00099   FX4Splitter(FXComposite* p,FXuint opts=FOURSPLITTER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00100 
00101   /// Create 4-way splitter, initially shown as four unexpanded panes; notifies target about size changes
00102   FX4Splitter(FXComposite* p,FXObject* tgt,FXSelector sel,FXuint opts=FOURSPLITTER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00103 
00104   /// Get top left child, if any
00105   FXWindow *getTopLeft() const;
00106 
00107   /// Get top right child, if any
00108   FXWindow *getTopRight() const;
00109 
00110   /// Get bottom left child, if any
00111   FXWindow *getBottomLeft() const;
00112 
00113   /// Get bottom right child, if any
00114   FXWindow *getBottomRight() const;
00115 
00116   /// Get horizontal split fraction
00117   FXint getHSplit() const { return fhor; }
00118 
00119   /// Get vertical split fraction
00120   FXint getVSplit() const { return fver; }
00121 
00122   /// Change horizontal split fraction
00123   void setHSplit(FXint s);
00124 
00125   /// Change vertical split fraction
00126   void setVSplit(FXint s);
00127 
00128   /// Get default width
00129   virtual FXint getDefaultWidth();
00130 
00131   /// Get default height
00132   virtual FXint getDefaultHeight();
00133 
00134   /// Return current splitter style
00135   FXuint getSplitterStyle() const;
00136 
00137   /// Change splitter style
00138   void setSplitterStyle(FXuint style);
00139 
00140   /// Change splitter bar width
00141   void setBarSize(FXint bs);
00142 
00143   /// Get splitter bar width
00144   FXint getBarSize() const { return barsize; }
00145 
00146   /// Expand child (ex=0..3), or restore to 4-way split (ex=-1)
00147   void setExpanded(FXint ex);
00148 
00149   /// Get expanded child, or -1 if not expanded
00150   FXint getExpanded() const { return expanded; }
00151 
00152   /// Save to stream
00153   virtual void save(FXStream& store) const;
00154 
00155   /// Load from stream
00156   virtual void load(FXStream& store);
00157   };
00158 
00159 
00160 #endif