splitter.h
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:11k
- /*
- * splitter.h
- *
- * Splitter Interactor GUI class.
- *
- * Portable Windows Library
- *
- * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is Portable Windows Library.
- *
- * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
- *
- * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * $Log: splitter.h,v $
- * Revision 1.10 1999/03/09 08:01:47 robertj
- * Changed comments for doc++ support (more to come).
- *
- * Revision 1.9 1999/02/16 08:08:28 robertj
- * MSVC 6.0 compatibility changes.
- *
- * Revision 1.8 1998/09/23 06:19:59 robertj
- * Added open source copyright license.
- *
- * Revision 1.7 1996/04/30 12:33:43 robertj
- * Changed "inPixels" boolean to enum for three coordinate systems.
- *
- * Revision 1.6 1995/07/02 01:20:57 robertj
- * Removed OnDoubleClick() and added BOOL to OnMouseDown() for double click.
- *
- * Revision 1.5 1995/06/17 11:13:27 robertj
- * Documentation update.
- *
- * Revision 1.4 1995/06/04 12:37:17 robertj
- * Added function to set splitter split by percentage.
- *
- * Revision 1.3 1995/03/14 12:42:41 robertj
- * Updated documentation to use HTML codes.
- *
- * Revision 1.2 1995/01/16 09:42:06 robertj
- * Documentation.
- *
- * Revision 1.1 1994/10/23 04:58:43 robertj
- * Initial revision
- *
- */
- #ifndef _SPLITTER_H
- #define _SPLITTER_H
- #ifdef __GNUC__
- #pragma interface
- #endif
- /**An interactor that allow the placement of two other interactors next to
- each other with a bar between them that allows the adjustment of the
- proportions that the two interactors take up.
-
- The last two child interactors of the splitter are used as the two
- interactors to "split".
- This is an abstract class for horizontal and vertical versions.
- */
- class PSplitter : public PInteractor
- {
- PCLASSINFO(PSplitter, PInteractor);
- public:
- /**@name Construction */
- //@{
- /** Create a splitter interactor. */
- PSplitter(
- PInteractor * parent /// Parent interactor for splitter.
- );
- //@}
- /**@name New functions for class */
- //@{
- /**This function sets the split to the specified percentage, adjusting the
- child windows accordingly.
- */
- virtual void SetPercent(
- PDIMENSION percent /// Percentage split.
- ) = 0;
- //@}
- protected:
- /**@name Overrides from class PInteractor */
- //@{
- /**The system calls this whenever the mouse moves over the interactors
- usable area.
-
- This behaviour in a splitter is to track the movement of the "bar"
- between the two interactors.
- */
- virtual void OnMouseMove(
- PKeyCode button,
- /**This key code is used to determine the modifiers (eg shift, control
- etc) that were active while the mouse was moved over the interactor.
- The value part of the key code is irrelevent.
- */
- const PPoint & where
- /**The position of the mouse pointer provided in pixels with its origin
- at the top left of the interactor.
- */
- );
- /**The system calls this whenever a mouse button is pressed in the
- interactors usable area.
-
- This behaviour in a splitter is to begin tracking the movement of the
- "bar" between the two interactors.
- */
- virtual void OnMouseDown(
- PKeyCode button,
- /**This key code is used to determine which mouse button was pressed and
- what modifiers that were active at that time. The mouse button that
- caused this call back is in the value part of the key code. The
- modifiers may indicate other mouse buttons being down at the same
- time.
- */
- const PPoint & where,
- /**The position of the mouse pointer provided in pixels with its origin
- at the top left of the interactor.
- */
- BOOL doubleClick
- /// Is TRUE if the mouse down is the second click of a double click.
- );
- /**The system calls this whenever a mouse button is released in the
- interactors usable area.
-
- This behaviour in a splitter is to finish tracking the movement of the
- "bar" between the two interactors. The two child interactors are then
- resized at this point via a call to the splitter
- ref{PInteractor::SetDimensions()} function.
- */
- virtual void OnMouseUp(
- PKeyCode button,
- /**This key code is used to determine which mouse button was pressed and
- what modifiers that were active at that time. The mouse button that
- caused this call back is in the value part of the key code. The
- modifiers may indicate other mouse buttons being down at the same
- time.
- */
- const PPoint & where
- /**The position of the mouse pointer provided in pixels with its origin
- at the top left of the interactor.
- */
- );
- /**The system calls this whenever it requires that the interactors usable
- area needs to be updated and redrawn.
- This behaviour in a splitter is to draw the "bar" between the two
- interactors.
- */
- virtual void OnRedraw(
- PCanvas & canvas /// Canvas to use when drawing the interactor contents.
- );
- //@}
- /**@name New functions for class */
- //@{
- /**Track the adjustment of the splitter divider. This is called from the
- ancestor class during the mouse tracking operation. It determines
- whether the bar moves vertically or horzontally.
- */
- virtual void TrackSplitter(
- const PPoint & where /// Mouse location during the track.
- ) = 0;
- /**Adjust the child interactors according to the split.
- */
- void AdjustChildInteractors(
- PDIMENSION width1, /// Width of first child interactor.
- PDIMENSION height1, /// Height of first child interactor.
- PORDINATE x2, /// X position of second child interactor.
- PORDINATE y2, /// Y position of second child interactor.
- PDIMENSION width2, /// Width of second child interactor.
- PDIMENSION height2 /// Height of second child interactor.
- );
- //@}
- // Member variables
- /// Rectangle for the position of the bar between the interactors.
- PRect splitBar;
- /**Canvas used to draw the tracking of the movement of the bar between
- the interactors. This is only non-null when the mouse was clicked in
- the interactor, ie via ref{OnMouseDown()}.
- */
- PDrawCanvas * trackCanvas;
- };
- /**An interactor that allow the placement of two other interactors next to
- each other with a bar between them that allows the adjustment of the
- proportions that the two interactors take up.
-
- The last two child interactors of the splitter are used as the two
- interactors to "split".
- This places the two interactors to the left and right with a vertical "bar"
- between them.
- */
- class PVerticalSplitter : public PSplitter
- {
- PCLASSINFO(PVerticalSplitter, PSplitter);
- public:
- /**@name Construction */
- //@{
- /** Create a verical splitter interactor. */
- PVerticalSplitter(
- PInteractor * parent /// Parent interactor for splitter.
- );
- //@}
- /**@name Overrides from class PSplitter */
- //@{
- /**This function sets the split to the specified percentage, adjusting the
- child windows accordingly.
- */
- void SetPercent(
- PDIMENSION percent /// Percentage split.
- );
- //@}
- protected:
- /**@name Overrides from class PInteractor */
- //@{
- /**Set the dimensions of the interactor, and then resize the two child
- interactors being split. The original proportions given to the child
- interactors is maintained.
- */
- virtual void _SetDimensions(
- PDIMENSION width, /// New width to apply to interactor.
- PDIMENSION height, /// New height to apply to interactor.
- CoordinateSystem coords /// Coordinate system to use.
- );
- //@}
- /**@name Overrides from class PSplitter */
- //@{
- /**Track the adjustment of the splitter divider. This is called from the
- ancestor class during the mouse tracking operation. It determines
- whether the bar moves vertically or horzontally. In this case
- horizontally.
- */
- virtual void TrackSplitter(
- const PPoint & where // Mouse location during the track.
- );
- //@}
- };
- /**An interactor that allow the placement of two other interactors next to
- each other with a bar between them that allows the adjustment of the
- proportions that the two interactors take up.
-
- The last two child interactors of the splitter are used as the two
- interactors to "split".
- This places the two interactors to the top and bottom with a horizontal
- "bar" between them.
- */
- class PHorizontalSplitter : public PSplitter
- {
- PCLASSINFO(PHorizontalSplitter, PSplitter);
- public:
- /**@name Construction */
- //@{
- PHorizontalSplitter(
- PInteractor * parent // Parent interactor for splitter.
- );
- // Create a horizontal splitter interactor.
- //@}
- /**@name Overrides from class PSplitter */
- //@{
- /**This function sets the split to the specified percentage, adjusting the
- child windows accordingly.
- */
- void SetPercent(
- PDIMENSION percent /// Percentage split.
- );
- //@}
- protected:
- /**@name Overrides from class PInteractor */
- //@{
- /**Set the dimensions of the interactor, and then resize the two child
- interactors being split. The original proportions given to the child
- interactors is maintained.
- */
- virtual void _SetDimensions(
- PDIMENSION width, /// New width to apply to interactor.
- PDIMENSION height, /// New height to apply to interactor.
- CoordinateSystem coords /// Coordinate system to use.
- );
- //@}
- /**@name Overrides from class PSplitter */
- //@{
- /**Track the adjustment of the splitter divider. This is called from the
- ancestor class during the mouse tracking operation. It determines
- whether the bar moves vertically or horzontally. In this case
- vertically.
- */
- virtual void TrackSplitter(
- const PPoint & where /// Mouse location during the track.
- );
- //@}
- };
- #endif
- // End Of File ///////////////////////////////////////////////////////////////