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

FX4Splitter.h

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

Copyright © 1997-2010 Jeroen van der Zijp