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

FX4Splitter.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * F o u r - W a y S p l i t t e r *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1999,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FX4Splitter.h,v 1.30 2006/02/20 03:32:12 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FX4SPLITTER_H
25 #define FX4SPLITTER_H
26 
27 #ifndef FXCOMPOSITE_H
28 #include "FXComposite.h"
29 #endif
30 
31 namespace FX {
32 
33 // Splitter options
34 enum {
35  FOURSPLITTER_TRACKING = 0x00008000, // Track continuously during split
37  };
38 
39 
40 
41 /**
42 * The four-way splitter is a layout manager which manages
43 * four children like four panes in a window.
44 * You can use a four-way splitter for example in a CAD program
45 * where you may want to maintain three orthographic views, and
46 * one oblique view of a model.
47 * The four-way splitter allows interactive repartitioning of the
48 * panes by means of moving the central splitter bars.
49 * When the four-way splitter is itself resized, each child is
50 * proportionally resized, maintaining the same split-percentage.
51 * The four-way splitter widget sends a SEL_CHANGED to its target
52 * during the resizing of the panes; at the end of the resize interaction,
53 * it sends a SEL_COMMAND to signify that the resize operation is complete.
54 */
55 class FXAPI FX4Splitter : public FXComposite {
57 private:
58  FXint splitx; // Current x split
59  FXint splity; // Current y split
60  FXint barsize; // Size of the splitter bar
61  FXint fhor; // Horizontal split fraction
62  FXint fver; // Vertical split fraction
63  FXint offx;
64  FXint offy;
65  FXuchar mode;
66 protected:
67  FX4Splitter();
68  FXuchar getMode(FXint x,FXint y);
69  void moveSplit(FXint x,FXint y);
70  void drawSplit(FXint x,FXint y,FXuint m);
71  void adjustLayout();
72 private:
73  FX4Splitter(const FX4Splitter&);
74  FX4Splitter &operator=(const FX4Splitter&);
75 public:
76  long onLeftBtnPress(FXObject*,FXSelector,void*);
77  long onLeftBtnRelease(FXObject*,FXSelector,void*);
78  long onMotion(FXObject*,FXSelector,void*);
79  long onFocusUp(FXObject*,FXSelector,void*);
80  long onFocusDown(FXObject*,FXSelector,void*);
81  long onFocusLeft(FXObject*,FXSelector,void*);
82  long onFocusRight(FXObject*,FXSelector,void*);
83  long onCmdExpand(FXObject*,FXSelector,void*);
84  long onUpdExpand(FXObject*,FXSelector,void*);
85 public:
86  enum {
87  ExpandNone = 0, /// None expanded
88  ExpandTopLeft = 1, /// Expand top left child
89  ExpandTopRight = 2, /// Expand top right child
90  ExpandBottomLeft = 4, /// Expand bottom left child
91  ExpandBottomRight = 8, /// Expand bottom right child
92  ExpandTop = ExpandTopLeft|ExpandTopRight, /// Expand top children
93  ExpandBottom = ExpandBottomLeft|ExpandBottomRight, /// Expand bottom children
94  ExpandLeft = ExpandTopLeft|ExpandBottomLeft, /// Expand left children
95  ExpandRight = ExpandTopRight|ExpandBottomRight, /// Expand right children
96  ExpandAll = ExpandLeft|ExpandRight /// Expand all children
97  };
98 public:
99  enum {
100  ID_EXPAND_NONE=FXComposite::ID_LAST+ExpandNone,
101  ID_EXPAND_TOP=ID_EXPAND_NONE+ExpandTop,
102  ID_EXPAND_BOTTOM=ID_EXPAND_NONE+ExpandBottom,
103  ID_EXPAND_LEFT=ID_EXPAND_NONE+ExpandLeft,
104  ID_EXPAND_RIGHT=ID_EXPAND_NONE+ExpandRight,
105  ID_EXPAND_TOPLEFT=ID_EXPAND_NONE+ExpandTopLeft,
106  ID_EXPAND_TOPRIGHT=ID_EXPAND_NONE+ExpandTopRight,
107  ID_EXPAND_BOTTOMLEFT=ID_EXPAND_NONE+ExpandBottomLeft,
108  ID_EXPAND_BOTTOMRIGHT=ID_EXPAND_NONE+ExpandBottomRight,
109  ID_EXPAND_ALL=ID_EXPAND_NONE+ExpandAll,
110  ID_LAST
111  };
112 public:
113 
114  /// Create 4-way splitter, initially shown as four unexpanded panes
116 
117  /// Create 4-way splitter, initially shown as four unexpanded panes; notifies target about size changes
119 
120  /// Get top left child, if any
121  FXWindow *getTopLeft() const;
122 
123  /// Get top right child, if any
124  FXWindow *getTopRight() const;
125 
126  /// Get bottom left child, if any
127  FXWindow *getBottomLeft() const;
128 
129  /// Get bottom right child, if any
130  FXWindow *getBottomRight() const;
131 
132  /// Get horizontal split fraction
133  FXint getHSplit() const { return fhor; }
134 
135  /// Get vertical split fraction
136  FXint getVSplit() const { return fver; }
137 
138  /// Change horizontal split fraction
139  void setHSplit(FXint s);
140 
141  /// Change vertical split fraction
142  void setVSplit(FXint s);
143 
144  /// Perform layout
145  virtual void layout();
146 
147  /// Get default width
148  virtual FXint getDefaultWidth();
149 
150  /// Get default height
151  virtual FXint getDefaultHeight();
152 
153  /// Return current splitter style
154  FXuint getSplitterStyle() const;
155 
156  /// Change splitter style
157  void setSplitterStyle(FXuint style);
158 
159  /// Change splitter bar width
160  void setBarSize(FXint bs);
161 
162  /// Get splitter bar width
163  FXint getBarSize() const { return barsize; }
164 
165  /// Change set of expanded children
166  void setExpanded(FXuint set=FX4Splitter::ExpandAll);
167 
168  /// Get set of expanded children
169  FXuint getExpanded() const;
170 
171  /// Save to stream
172  virtual void save(FXStream& store) const;
173 
174  /// Load from stream
175  virtual void load(FXStream& store);
176  };
177 
178 }
179 
180 #endif
Base class for all windows.
Definition: FXWindow.h:115
Definition: FXWindow.h:241
unsigned int FXuint
Definition: fxdefs.h:396
FXuint FXSelector
Association key.
Definition: FXObject.h:53
#define FXAPI
Definition: fxdefs.h:122
Base composite.
Definition: FXComposite.h:35
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:99
Track continuously during split.
Definition: FX4Splitter.h:38
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:397
Expand all children.
Definition: FX4Splitter.h:85
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
unsigned char FXuchar
Definition: fxdefs.h:392
Definition: FX4Splitter.h:39
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
The four-way splitter is a layout manager which manages four children like four panes in a window...
Definition: FX4Splitter.h:62

Copyright © 1997-2005 Jeroen van der Zijp