Fixed bug in using relative times eg "1 month ago".
[pwlib.git] / include / pwclib / splitter.h
blob66c6c247dcebed80084e453d6064a109166ac8e1
1 /*
2 * splitter.h
4 * Splitter Interactor GUI class.
6 * Portable Windows Library
8 * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
18 * under the License.
20 * The Original Code is Portable Windows Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25 * All Rights Reserved.
27 * Contributor(s): ______________________________________.
29 * $Log$
30 * Revision 1.10 1999/03/09 08:01:47 robertj
31 * Changed comments for doc++ support (more to come).
33 * Revision 1.9 1999/02/16 08:08:28 robertj
34 * MSVC 6.0 compatibility changes.
36 * Revision 1.8 1998/09/23 06:19:59 robertj
37 * Added open source copyright license.
39 * Revision 1.7 1996/04/30 12:33:43 robertj
40 * Changed "inPixels" boolean to enum for three coordinate systems.
42 * Revision 1.6 1995/07/02 01:20:57 robertj
43 * Removed OnDoubleClick() and added BOOL to OnMouseDown() for double click.
45 * Revision 1.5 1995/06/17 11:13:27 robertj
46 * Documentation update.
48 * Revision 1.4 1995/06/04 12:37:17 robertj
49 * Added function to set splitter split by percentage.
51 * Revision 1.3 1995/03/14 12:42:41 robertj
52 * Updated documentation to use HTML codes.
54 * Revision 1.2 1995/01/16 09:42:06 robertj
55 * Documentation.
57 * Revision 1.1 1994/10/23 04:58:43 robertj
58 * Initial revision
62 #ifndef _SPLITTER_H
63 #define _SPLITTER_H
65 #ifdef __GNUC__
66 #pragma interface
67 #endif
71 /**An interactor that allow the placement of two other interactors next to
72 each other with a bar between them that allows the adjustment of the
73 proportions that the two interactors take up.
75 The last two child interactors of the splitter are used as the two
76 interactors to "split".
78 This is an abstract class for horizontal and vertical versions.
80 class PSplitter : public PInteractor
82 PCLASSINFO(PSplitter, PInteractor);
84 public:
85 /**@name Construction */
86 //@{
87 /** Create a splitter interactor. */
88 PSplitter(
89 PInteractor * parent /// Parent interactor for splitter.
91 //@}
94 /**@name New functions for class */
95 //@{
96 /**This function sets the split to the specified percentage, adjusting the
97 child windows accordingly.
99 virtual void SetPercent(
100 PDIMENSION percent /// Percentage split.
101 ) = 0;
102 //@}
105 protected:
106 /**@name Overrides from class PInteractor */
107 //@{
108 /**The system calls this whenever the mouse moves over the interactors
109 usable area.
111 This behaviour in a splitter is to track the movement of the "bar"
112 between the two interactors.
114 virtual void OnMouseMove(
115 PKeyCode button,
116 /**This key code is used to determine the modifiers (eg shift, control
117 etc) that were active while the mouse was moved over the interactor.
118 The value part of the key code is irrelevent.
120 const PPoint & where
121 /**The position of the mouse pointer provided in pixels with its origin
122 at the top left of the interactor.
126 /**The system calls this whenever a mouse button is pressed in the
127 interactors usable area.
129 This behaviour in a splitter is to begin tracking the movement of the
130 "bar" between the two interactors.
132 virtual void OnMouseDown(
133 PKeyCode button,
134 /**This key code is used to determine which mouse button was pressed and
135 what modifiers that were active at that time. The mouse button that
136 caused this call back is in the value part of the key code. The
137 modifiers may indicate other mouse buttons being down at the same
138 time.
140 const PPoint & where,
141 /**The position of the mouse pointer provided in pixels with its origin
142 at the top left of the interactor.
144 BOOL doubleClick
145 /// Is TRUE if the mouse down is the second click of a double click.
149 /**The system calls this whenever a mouse button is released in the
150 interactors usable area.
152 This behaviour in a splitter is to finish tracking the movement of the
153 "bar" between the two interactors. The two child interactors are then
154 resized at this point via a call to the splitter
155 \ref{PInteractor::SetDimensions()} function.
157 virtual void OnMouseUp(
158 PKeyCode button,
159 /**This key code is used to determine which mouse button was pressed and
160 what modifiers that were active at that time. The mouse button that
161 caused this call back is in the value part of the key code. The
162 modifiers may indicate other mouse buttons being down at the same
163 time.
165 const PPoint & where
166 /**The position of the mouse pointer provided in pixels with its origin
167 at the top left of the interactor.
171 /**The system calls this whenever it requires that the interactors usable
172 area needs to be updated and redrawn.
174 This behaviour in a splitter is to draw the "bar" between the two
175 interactors.
177 virtual void OnRedraw(
178 PCanvas & canvas /// Canvas to use when drawing the interactor contents.
180 //@}
183 /**@name New functions for class */
184 //@{
185 /**Track the adjustment of the splitter divider. This is called from the
186 ancestor class during the mouse tracking operation. It determines
187 whether the bar moves vertically or horzontally.
189 virtual void TrackSplitter(
190 const PPoint & where /// Mouse location during the track.
191 ) = 0;
193 /**Adjust the child interactors according to the split.
195 void AdjustChildInteractors(
196 PDIMENSION width1, /// Width of first child interactor.
197 PDIMENSION height1, /// Height of first child interactor.
198 PORDINATE x2, /// X position of second child interactor.
199 PORDINATE y2, /// Y position of second child interactor.
200 PDIMENSION width2, /// Width of second child interactor.
201 PDIMENSION height2 /// Height of second child interactor.
203 //@}
206 // Member variables
207 /// Rectangle for the position of the bar between the interactors.
208 PRect splitBar;
210 /**Canvas used to draw the tracking of the movement of the bar between
211 the interactors. This is only non-null when the mouse was clicked in
212 the interactor, ie via \ref{OnMouseDown()}.
214 PDrawCanvas * trackCanvas;
218 /**An interactor that allow the placement of two other interactors next to
219 each other with a bar between them that allows the adjustment of the
220 proportions that the two interactors take up.
222 The last two child interactors of the splitter are used as the two
223 interactors to "split".
225 This places the two interactors to the left and right with a vertical "bar"
226 between them.
228 class PVerticalSplitter : public PSplitter
230 PCLASSINFO(PVerticalSplitter, PSplitter);
232 public:
233 /**@name Construction */
234 //@{
235 /** Create a verical splitter interactor. */
236 PVerticalSplitter(
237 PInteractor * parent /// Parent interactor for splitter.
239 //@}
241 /**@name Overrides from class PSplitter */
242 //@{
243 /**This function sets the split to the specified percentage, adjusting the
244 child windows accordingly.
246 void SetPercent(
247 PDIMENSION percent /// Percentage split.
249 //@}
252 protected:
253 /**@name Overrides from class PInteractor */
254 //@{
255 /**Set the dimensions of the interactor, and then resize the two child
256 interactors being split. The original proportions given to the child
257 interactors is maintained.
259 virtual void _SetDimensions(
260 PDIMENSION width, /// New width to apply to interactor.
261 PDIMENSION height, /// New height to apply to interactor.
262 CoordinateSystem coords /// Coordinate system to use.
264 //@}
266 /**@name Overrides from class PSplitter */
267 //@{
268 /**Track the adjustment of the splitter divider. This is called from the
269 ancestor class during the mouse tracking operation. It determines
270 whether the bar moves vertically or horzontally. In this case
271 horizontally.
273 virtual void TrackSplitter(
274 const PPoint & where // Mouse location during the track.
276 //@}
281 /**An interactor that allow the placement of two other interactors next to
282 each other with a bar between them that allows the adjustment of the
283 proportions that the two interactors take up.
285 The last two child interactors of the splitter are used as the two
286 interactors to "split".
288 This places the two interactors to the top and bottom with a horizontal
289 "bar" between them.
291 class PHorizontalSplitter : public PSplitter
293 PCLASSINFO(PHorizontalSplitter, PSplitter);
295 public:
296 /**@name Construction */
297 //@{
298 PHorizontalSplitter(
299 PInteractor * parent // Parent interactor for splitter.
301 // Create a horizontal splitter interactor.
302 //@}
304 /**@name Overrides from class PSplitter */
305 //@{
306 /**This function sets the split to the specified percentage, adjusting the
307 child windows accordingly.
309 void SetPercent(
310 PDIMENSION percent /// Percentage split.
312 //@}
315 protected:
316 /**@name Overrides from class PInteractor */
317 //@{
318 /**Set the dimensions of the interactor, and then resize the two child
319 interactors being split. The original proportions given to the child
320 interactors is maintained.
322 virtual void _SetDimensions(
323 PDIMENSION width, /// New width to apply to interactor.
324 PDIMENSION height, /// New height to apply to interactor.
325 CoordinateSystem coords /// Coordinate system to use.
327 //@}
329 /**@name Overrides from class PSplitter */
330 //@{
331 /**Track the adjustment of the splitter divider. This is called from the
332 ancestor class during the mouse tracking operation. It determines
333 whether the bar moves vertically or horzontally. In this case
334 vertically.
336 virtual void TrackSplitter(
337 const PPoint & where /// Mouse location during the track.
339 //@}
344 #endif
346 // End Of File ///////////////////////////////////////////////////////////////