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

FXPacker.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * P a c k e r C o n t a i n e r W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,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: FXPacker.h,v 1.21 2006/01/22 17:58:07 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXPACKER_H
25 #define FXPACKER_H
26 
27 #ifndef FXCOMPOSITE_H
28 #include "FXComposite.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// Default spacing
35 enum { DEFAULT_SPACING = 4 };
36 
37 
38 /**
39 * Packer is a layout manager which automatically places child windows
40 * inside its area against the left, right, top, or bottom side.
41 * Each time a child is placed, the remaining space is decreased by the
42 * amount of space taken by the child window.
43 * The side against which a child is placed is determined by the LAYOUT_SIDE_TOP,
44 * LAYOUT_SIDE_BOTTOM, LAYOUT_SIDE_LEFT, and LAYOUT_SIDE_RIGHT hints given by
45 * the child window. Other layout hints from the child are observed as far as
46 * sensible. So for example, a child placed against the right edge can still
47 * have LAYOUT_FILL_Y or LAYOUT_TOP, and so on.
48 * The last child may have both LAYOUT_FILL_X and LAYOUT_FILL_Y, in which
49 * case it will be placed to take all remaining space.
50 */
51 class FXAPI FXPacker : public FXComposite {
53 protected:
54  FXColor baseColor; // Base color
55  FXColor hiliteColor; // Highlight color
56  FXColor shadowColor; // Shadow color
57  FXColor borderColor; // Border color
58  FXint padtop; // Top margin
59  FXint padbottom; // Bottom margin
60  FXint padleft; // Left margin
61  FXint padright; // Right margin
62  FXint hspacing; // Horizontal child spacing
63  FXint vspacing; // Vertical child spacing
64  FXint border; // Border width
65 protected:
66  FXPacker();
67  void drawBorderRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
68  void drawRaisedRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
69  void drawSunkenRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
70  void drawRidgeRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
71  void drawGrooveRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
72  void drawDoubleRaisedRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
73  void drawDoubleSunkenRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
74  void drawFocusRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
75  void drawFrame(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
76 private:
77  FXPacker(const FXPacker&);
78  FXPacker &operator=(const FXPacker&);
79 public:
80  long onPaint(FXObject*,FXSelector,void*);
81  long onFocusUp(FXObject*,FXSelector,void*);
82  long onFocusDown(FXObject*,FXSelector,void*);
83  long onFocusLeft(FXObject*,FXSelector,void*);
84  long onFocusRight(FXObject*,FXSelector,void*);
85 public:
86 
87  /// Construct packer layout manager
89 
90  /// Return default width
91  virtual FXint getDefaultWidth();
92 
93  /// Return default height
94  virtual FXint getDefaultHeight();
95 
96  /// Perform layout
97  virtual void layout();
98 
99  /// Change frame style
100  void setFrameStyle(FXuint style);
101 
102  /// Get current frame style
103  FXuint getFrameStyle() const;
104 
105  /// Change packing hints
106  void setPackingHints(FXuint ph);
107 
108  /// Return packing hints
109  FXuint getPackingHints() const;
110 
111  /// Get border width
112  FXint getBorderWidth() const { return border; }
113 
114  /// Change top padding
115  void setPadTop(FXint pt);
116 
117  /// Get top interior padding
118  FXint getPadTop() const { return padtop; }
119 
120  /// Change bottom padding
121  void setPadBottom(FXint pb);
122 
123  /// Get bottom interior padding
124  FXint getPadBottom() const { return padbottom; }
125 
126  /// Change left padding
127  void setPadLeft(FXint pl);
128 
129  /// Get left interior padding
130  FXint getPadLeft() const { return padleft; }
131 
132  /// Change right padding
133  void setPadRight(FXint pr);
134 
135  /// Get right interior padding
136  FXint getPadRight() const { return padright; }
137 
138  /// Change highlight color
139  void setHiliteColor(FXColor clr);
140 
141  /// Get highlight color
142  FXColor getHiliteColor() const { return hiliteColor; }
143 
144  /// Change shadow color
145  void setShadowColor(FXColor clr);
146 
147  /// Get shadow color
148  FXColor getShadowColor() const { return shadowColor; }
149 
150  /// Change border color
151  void setBorderColor(FXColor clr);
152 
153  /// Get border color
154  FXColor getBorderColor() const { return borderColor; }
155 
156  /// Change base gui color
157  void setBaseColor(FXColor clr);
158 
159  /// Get base gui color
160  FXColor getBaseColor() const { return baseColor; }
161 
162  /// Change horizontal inter-child spacing
163  void setHSpacing(FXint hs);
164 
165  /// Return current horizontal inter-child spacing
166  FXint getHSpacing() const { return hspacing; }
167 
168  /// Change vertical inter-child spacing
169  void setVSpacing(FXint vs);
170 
171  /// Return current vertical inter-child spacing
172  FXint getVSpacing() const { return vspacing; }
173 
174  /// Save to stream
175  virtual void save(FXStream& store) const;
176 
177  /// Load from stream
178  virtual void load(FXStream& store);
179  };
180 
181 }
182 
183 #endif
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
FXuint FXColor
Definition: fxdefs.h:454
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:397
Packer is a layout manager which automatically places child windows inside its area against the left...
Definition: FXPacker.h:58
Definition: FXPacker.h:38
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
Window Device Context.
Definition: FXDCWindow.h:52
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92

Copyright © 1997-2005 Jeroen van der Zijp