home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
ISPLITCV.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
16KB
|
316 lines
#ifndef _ISPLITCV_
#define _ISPLITCV_
/*******************************************************************************
* FILE NAME: isplitcv.hpp *
* *
* DESCRIPTION: *
* Declaration of the class(es): *
* ISplitCanvas - This canvas class places its children controls in a *
* vertical or horizontal stack with split-bar between *
* them. *
* *
* COPYRIGHT: *
* Licensed Materials - Property of IBM *
* (C) Copyright IBM Corporation 1992, 1993 *
* All Rights Reserved *
* US Government Users Restricted Rights - Use, duplication, or disclosure *
* restricted by GSA ADP Schedule Contract with IBM Corp. *
* *
* CHANGE HISTORY: *
*******************************************************************************/
#ifndef _ICANVAS_
#include <icanvas.hpp>
#endif
#ifndef _ICOLOR_
#include <icolor.hpp>
#endif
#ifndef _IRECT_
#include <irect.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
// Forward declarations for other classes:
class ISplitCanvasHandler;
class ISplitPercentageSet;
class ISplitPercentage;
class ISplitCanvas : public ICanvas {
typedef ICanvas
Inherited;
/*******************************************************************************
* The ISplitCanvas class is a control class that gives you a way to split a *
* window into two or more window panes by simply creating and adding controls. *
* The number of controls that you add determines the number of panes in the *
* split canvas. The window panes can be separated by split bars, which is *
* the default style. By dragging the split bars, a user can dynamically *
* change the visible amount of each control. You can stack the controls *
* either vertically (the default) or horizontally. *
* *
* EXAMPLE: *
* *
* void main(int argc,char **argv) *
* { *
* MyFrame* myFrame = new IFrameWindow(); *
* ISplitCanvas* mySplitCV = new ISplitCanvas(ID_CANVAS, myFrame, myFrame, *
* IRectangle (), *
* IWindow::visible | *
* ISplitCanvas::horizontal); *
* myFrame->setClient(mySplitCV); *
* IStaticText* txt1 = new IStaticText(ID_STATIC1, mySplitCV, mySplitCV); *
* IListBox* lbx1 = new IEntryField(ID_ENTRY1, mySplitCV, mySplitCV, *
* IRectangle(), *
* IWindow::visible | *
* IListBox::noAdjustPosition); *
* *
* txt1->setText("Ford Tempo Pricing Details - 1993"); *
* lbx1->addAsFirst("$12,500"); *
* lbx1->addAsFirst("$11,500"); *
* lbx1->addAsFirst("$10,500"); *
* *
* mySplitCV->setSplitWindowPercentage(txt1, 20); *
* mySplitCV->setSplitWindowPercentage(ent1, 20); *
* mySplitCV->setSplitWindowPercentage(ent2, 20); *
* mySplitCV->setSplitWindowPercentage(lbx1, 40); *
* *
* show(); *
* *
* } *
* *
*******************************************************************************/
public:
/*-------------------------------- Style ----------------------------------
The following functions provide a means to set and query split canvas
styles:
Style - Nested class that provides static members that define the set of
valid split canvas styles. These styles can be used in
conjunction with the styles defined by the nested classes
ICanvas::Style and IWindow::Style. For example, you could
define an instance of the ISplitCanvas::Style class and
initialize it like:
ISplitCanvas::Style
style = ISplitCanvas::horizontal | IWindow::visible;
An object of this type is provided when the split canvas is
created. A customizable default is used if no styles are
specified. Once the object is constructed, ISplitCanvas,
ICanvas, and IWindow member functions can be used to set or
query the object's style.
The declaration of the ISplitCanvas::Style nested class is
generated by the INESTEDBITFLAGCLASSDEF2 macro.
The valid split canvas styles are:
classDefaultStyle - Original default style for this class, which is
vertical | IWindow::visible.
horizontal - The split bar will be drawn horizontally. The
panes will be placed top to bottom. This
style cannot be specified with vertical.
vertical - The split bar will be drawn vertically. The panes
will be placed left to right. This style is the
default. It cannot be specified with horizontal.
noSplitBars - The canvas will not have any split bars.
The following functions provide a means of getting and setting the default
style for this class:
defaultStyle - Returns the current default style. This is the same as
classDefaultStyle unless setDefaultStyle has been
called.
setDefaultStyle - Sets the default style for all subsequent split
canvases.
-------------------------------------------------------------------------*/
INESTEDBITFLAGCLASSDEF2(Style, ISplitCanvas, ICanvas, IWindow);
// style class definition
static const Style
horizontal,
vertical,
noSplitBars,
classDefaultStyle;
static Style
defaultStyle ( );
static void
setDefaultStyle ( const Style& style );
/*-------------------------- Constructor/Destructor ----------------------------
| You can construct instances of this class from a window ID, parent window, |
| owner window, rectangle, and style. This creates the specified split |
| canvas window. |
------------------------------------------------------------------------------*/
ISplitCanvas ( unsigned long windowId,
IWindow* parent,
IWindow* owner,
const IRectangle& initialSize = IRectangle(),
const Style& style = defaultStyle() );
virtual
~ISplitCanvas ( );
/*------------------------------- Enumerators ----------------------------------
| The following enumerations are defined for this class: |
| Orientation - Enumeration that specifies the direction of the split bar. |
| Values are: |
| horizontalSplit - The split bar is drawn horizontally. |
| The panes are placed top to bottom. |
| verticalSplit - The split bar is drawn vertically. |
| The panes are placed left to right. |
| |
| SplitBarArea - Enumeration that specifies the area of the split bar |
| referred to in an operation. Values are: |
| splitBarEdge - The top and bottom edges of a |
| horizontal split bar or the left and |
| right edges of a vertical split bar. |
| splitBarMiddle - The middle of the split bar. |
------------------------------------------------------------------------------*/
enum Orientation { horizontalSplit, verticalSplit };
enum SplitBarArea { splitBarEdge, splitBarMiddle};
/*---------------------------- Style Manipulation ------------------------------
| These functions are used to set and query the default style for new objects |
| of this class or the styles of an existing instance: |
| orientation - Returns the direction in which the split-bar is drawn. |
| setOrientation - Sets the direction in which the split-bar is drawn. |
------------------------------------------------------------------------------*/
Orientation
orientation ( ) const;
ISplitCanvas
&setOrientation ( Orientation value );
/*-------------------------------- Accessors -----------------------------------
| These functions provide a means of getting and setting accessible |
| attributes of instances of this class: |
| setSplitWindowPercentage - Sets the percentage of the canvas to be |
| occupied by the specified window. |
| NOTE: This function does not cause the split |
| canvas to be immediately updated if it |
| is already being shown. You must call |
| the IWindow::refresh function to update |
| the appearance of the canvas. |
| splitWindowPercentage - Gets the percentage of the canvas currently |
| occupied by the specified window. |
| setSplitBarThickness - Sets the thickness of the specified portion of |
| the split bar. It must be one the values of |
| the SplitBarArea enumeration. |
| splitBarThickness - Gets the thickness of the specified portion of |
| the split bar. It must be one the values of |
| the SplitBarArea enumeration. |
------------------------------------------------------------------------------*/
ISplitCanvas
&setSplitWindowPercentage ( IWindow* window,
unsigned long percentage );
unsigned long
splitWindowPercentage ( IWindow* window );
ISplitCanvas
&setSplitBarThickness ( SplitBarArea value,
unsigned long thickness );
unsigned long
splitBarThickness ( SplitBarArea value );
/*----------------------------- Color Operations -------------------------------
| The following functions provide a means for setting and getting the color |
| of the middle or edge of a split bar: |
| setColor - Sets the color to be used for the specified portion of the |
| split bar. It must be one of the values of the SplitBarArea |
| enumeration. |
| color - Returns the color used for the specified portion of the split |
| bar. It must be one of the values of the SplitBarArea |
| enumeration. |
------------------------------------------------------------------------------*/
IColor
color ( SplitBarArea value ) const;
ISplitCanvas
&setColor ( SplitBarArea value,
const IColor& color );
/*-------------------------------- Overrides -----------------------------------
| This class overrides the following inherited functions: |
| setLayoutDistorted - Treats a size change like a layout change. |
------------------------------------------------------------------------------*/
virtual ISplitCanvas
&setLayoutDistorted ( unsigned long layoutAttributeOn,
unsigned long layoutAttributeOff );
protected:
/*------------------------------ Implementation --------------------------------
| These functions implement the canvas layout algorithm: |
| layout - Computes the position and size of all child |
| controls. |
------------------------------------------------------------------------------*/
virtual ISplitCanvas
&layout ( );
private:
/*--------------------------------- Private ----------------------------------*/
ISplitCanvas ( const ISplitCanvas& );
static Style
currentDefaultStyle;
ISplitCanvas
&operator= ( const ISplitCanvas& );
void
resolveRatios ( );
ISplitCanvas
&setResolvedPercentage ( IWindow* window,
unsigned long percentage );
unsigned long
resolvedPercentage ( IWindow* window );
Boolean
bClVertical,
bClRatiosNotResolved,
bClNoSplitBars;
unsigned long
ulClMiddleThickness,
ulClEdgeThickness,
ulClChildCount;
IColor
clrClMiddleColor,
clrClEdgeColor;
ISize
sizClCanvasSize;
ISplitPercentageSet
*pClSplitPercentageSet;
ISplitCanvasHandler
*pClSplitCanvasHandler;
friend class ISplitCanvasHandler;
friend Boolean
ISplitPercentageDeleter ( ISplitPercentage* const& splitPercentageObj,
void* anything );
}; // ISplitCanvas
INESTEDBITFLAGCLASSFUNCS(Style, ISplitCanvas);
// global style functions
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing. */
/*----------------------------------------------------------------------------*/
#pragma pack()
/*----------------------------- Inline Functions -----------------------------*/
#ifndef I_NO_INLINES
#include <isplitcv.inl>
#endif
#endif /* _ISPLITCV_ */