home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
ISETCV.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
26KB
|
416 lines
#ifndef _ISETCV_
#define _ISETCV_
/*******************************************************************************
* FILE NAME: isetcv.hpp *
* *
* DESCRIPTION: *
* Declaration of the class(es): *
* ISetCanvas - This canvas class arranges its child windows in row or *
* column decks. *
* *
* 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 ACTIVITY: *
*******************************************************************************/
#ifndef _ICANVAS_
#include <icanvas.hpp>
#endif
#ifndef _IPOINT_
#include <ipoint.hpp>
#endif
#ifndef _IRECT_
#include <irect.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
// Forward declarations for other classes:
class IColor;
class ISetCanvasObject;
class IString;
class ISetCanvas : public ICanvas {
typedef ICanvas
Inherited;
/*******************************************************************************
* The ISetCanvas class is a window that organizes its child windows in row or *
* column decks. "Deck" is the direction-independent term for a line of child *
* windows in a set canvas. A horizontal deck is equivalent to a row and a *
* vertical deck is equivalent to a column. *
* *
* An ISetCanvas can hold more than one deck of child windows, but all the *
* decks must have the same orientation. The decks must all be either *
* horizontal or vertical. This class is designed to arrange fixed-size child *
* windows of similar size, such as a row of push buttons or a group of radio *
* buttons, because child windows are divided among multiple decks evenly by *
* number rather than size. ISetCanvas also sizes and positions its child *
* windows based on their minimum sizes (see IWindow::minimumSize and *
* IWindow::calcMinimumSize) instead of the size of the canvas. *
* *
* The ISetCanvas class provides a number of alignment and packing options to *
* allow for better control of how child windows are positioned. *
* *
* Example: *
* ISetCanvas scvPushButtons(0, parent, owner); *
* scvPushButtons.setDeckOrientation(ISetCanvas::horizontal); *
* // add controls to the set canvas by making them child windows *
* IPushButton pbApply(ID_APPLY, &scvPushButtons, &scvPushButtons, *
* IRectangle(), *
* IPushButton::classDefaultStyle | *
* IPushButton::defaultButton | *
* IControl::group | IControl::tabStop); *
* IPushButton pbReset(ID_RESET, &scvPushButtons, &scvPushButtons); *
* IPushButton pbUndo(ID_UNDO, &scvPushButtons, &scvPushButtons); *
* IPushButton pbCancel(SC_CLOSE, &scvPushButtons, &scvPushButtons, *
* IRectangle(), *
* IPushButton::classDefaultStyle | *
* IPushButton::systemCommand); *
*******************************************************************************/
public:
class Style; // forward declaration for nested class
/*-------------------------- Constructor/Destructor ----------------------------
| You can construct instances of this class by creating a set canvas window |
| with the specified window ID, parent window, owner window, rectangle, and |
| style. |
------------------------------------------------------------------------------*/
ISetCanvas ( unsigned long id,
IWindow* parent,
IWindow* owner,
const IRectangle& initial = IRectangle(),
const Style& style = defaultStyle() );
virtual
~ISetCanvas ( );
/*---------------------------------- Style -------------------------------------
| The following functions provide a means to set and query styles for |
| ISetCanvas objets: |
| |
| Style - Nested class that provides static members that define the set of |
| valid styles for ISetCanvas objects. 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 ISetCanvas::Style class and initialize |
| it like: |
| ISetCanvas::Style style = ISetCanvas::verticalDecks | |
| ISetCanvas::packExpanded | |
| ISetCanvas::centerAlign | |
| IWindow::visible; |
| An object of this type is provided when the ISetCanvas objet is |
| created. A customizable default is used if no styles are |
| specified. Once the object is constructed, ISetCanvas, ICanvas, |
| and IWindow member functions can be used to set or query the |
| object's style. |
| |
| The declaration of the ISetCanvas::Style nested class is |
| generated by the INESTEDBITFLAGCLASSDEF2 macro. |
| |
| The valid ISetCanvas object styles are: |
| classDefaultStyle - Original default style for this class, which is |
| horizontalDecks | packTight | leftAlign | topAlign |
| | IWindow::visible. |
| horizontalDecks - Child windows are organized in rows. Multiple rows |
| are arranged from top to bottom. (This style |
| cannot be specified with verticalDecks.) |
| verticalDecks - Child windows are organized in columns. Multiple |
| columns are arranged from left to right. (This |
| style cannot be specified with horizontalDecks.) |
| packTight - Child windows are sized to their minimum size and |
| are separated within a deck by the pad amount only. |
| (This style cannot be specified with packEven or |
| packExpanded.) |
| packEven - Child windows are sized to their minimum size and |
| spaced so that corresponding windows in each deck |
| are aligned. This gives the appearance of their |
| being arranged in both rows and columns. Child |
| windows within a deck can be separated by more than |
| the pad amount as a result. (This style cannot be |
| specified with packTight or packExpanded.) |
| packExpanded - Similar to packEven, except that the child windows |
| are grown rather than being spaced by more than the |
| pad amount. All child windows are sized to be the |
| same as the largest child window. (This style |
| cannot be specified with packTight or packEven.) |
| leftAlign - Child windows are left-aligned. (This style is |
| ignored if it is used with both packTight and |
| horizontalDecks. It is also ignored if it is used |
| with packExpanded, and cannot be specified with |
| rightAlign or centerAlign.) |
| rightAlign - Child windows are right-aligned. (This style is |
| ignored if it is used with both packTight and |
| horizontalDecks. It is also ignored if it is used |
| with packExpanded, and cannot be specified with |
| leftAlign or centerAlign.) |
| centerAlign - Child windows are horizontally-centered. (This |
| style is ignored if it is used with both packTight |
| and horizontalDecks. It is also ignored if it is |
| used with packExpanded, and cannot be specified |
| with leftAlign or rightAlign.) |
| topAlign - Child windows are top-aligned. (This style is |
| ignored if it is used with both packTight and |
| verticalDecks. It is also ignored if it is used |
| with packExpanded, and cannot be specified with |
| bottomAlign or centerVerticalAlign.) |
| bottomAlign - Child windows are bottom-aligned. (This style is |
| ignored if it is used with both packTight and |
| verticalDecks. It is also ignored if it is used |
| with packExpanded, and cannot be specified with |
| topAlign or centerVerticalAlign.) |
| centerVerticalAlign - Child windows are vertically-centered. (This style |
| is ignored if it is used with both packTight and |
| verticalDecks. It is also ignored if it is used |
| with packExpanded, and cannot be specified with |
| topAlign or bottomAlign.) |
| |
| 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 ISetCanvas |
| objects. |
------------------------------------------------------------------------------*/
INESTEDBITFLAGCLASSDEF2(Style, ISetCanvas, ICanvas, IWindow);
// style class definition
static const Style
classDefaultStyle,
horizontalDecks,
verticalDecks,
packTight,
packEven,
packExpanded,
leftAlign,
rightAlign,
centerAlign,
topAlign,
bottomAlign,
centerVerticalAlign;
static Style
defaultStyle ( );
static void
setDefaultStyle ( const Style& style );
/*---------------------------- 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: |
| DeckOrientation - Enumeration that specifies the directions in which |
| you can orient the decks of child windows. The |
| valid values are: |
| horizontal - Arranges the child windows in the |
| canvas horizontally in rows, from |
| left to right. Decks in rows are |
| arranged from top to bottom. |
| vertical - Arranges the child windows in the |
| canvas vertically in columns, from |
| top to bottom. Decks in columns are |
| arranged from left to right. |
| deckOrientation - Returns the direction of the decks. |
| setDeckOrientation - Sets the direction of the decks. |
| PackType - Enumeration that specifies the ways in which you can |
| provide space between child windows in decks. The |
| valid values are: |
| tight - Child windows are sized to their |
| minimum size and are separated within |
| a deck by the pad amount only. |
| even - Child windows are sized to their |
| minimum size and spaced so that |
| corresponding windows in each deck are |
| aligned. This gives the appearance of |
| their being arranged in both rows and |
| columns. Child windows within a deck |
| can be separated by more than the pad |
| amount as a result. |
| expanded - Similar to even, except the child |
| windows are grown rather than being |
| spaced by more than the pad amount. |
| Child windows are grown to be the same |
| size as the largest child window. |
| packType - Returns how child windows are spaced in decks. |
| setPackType - Sets how child windows are spaced in decks. |
| Alignment - Enumeration that specifies how you can align child |
| windows in a deck. The valid values are: |
| topLeft - Aligns the child windows in the |
| canvas to the top and left edge of |
| their place in a deck. |
| topCenter - Aligns the child windows in the |
| canvas to the top and center edge |
| of their place in a deck. |
| topRight - Aligns the child windows in the |
| canvas to the top and right edge of |
| their place in a deck. |
| centerLeft - Aligns the child windows in the |
| canvas to the center and left edge |
| of their place in a deck. |
| centerCenter - Aligns the child windows in the |
| canvas to the center of their place |
| in a deck. |
| centerRight - Aligns the child windows in the |
| canvas to the center and right edge |
| of their place in a deck. |
| bottomLeft - Aligns the child windows in the |
| canvas to the bottom and left edge |
| of their place in a deck. |
| bottomCenter - Aligns the child windows in the |
| canvas to the bottom and center |
| edge of their place in a deck. |
| bottomRight - Aligns the child windows in the |
| canvas to the bottom and right edge |
| of their place in a deck. |
| alignment - Returns how child windows are aligned in decks. |
| setAlignment - Sets how child windows are aligned in decks. |
------------------------------------------------------------------------------*/
enum DeckOrientation { horizontal, vertical };
DeckOrientation
deckOrientation ( ) const;
ISetCanvas
&setDeckOrientation ( DeckOrientation value );
enum PackType { tight, even, expanded };
PackType
packType ( ) const;
ISetCanvas
&setPackType ( PackType value );
enum Alignment { topLeft, topCenter, topRight,
centerLeft, centerCenter, centerRight,
bottomLeft, bottomCenter, bottomRight };
Alignment
alignment ( ) const;
ISetCanvas
&setAlignment ( Alignment value );
/*-------------------------------- Accessors -----------------------------------
| These functions provide the means of getting and setting accessible |
| attributes of instances of this class: |
| deckCount - Returns the maximum number of decks used by the canvas. |
| margin - Returns the margin width and height, which is the space |
| between the edge of the canvas and the outermost child |
| windows. |
| pad - Returns the pad width and height, which is the space |
| between child windows in a deck and between multiple decks. |
| setDeckCount - Sets the maximum number of decks used by the canvas. |
| setMargin - Sets the margin width and height, which is the space |
| between the edge of the canvas and the outermost child |
| windows. |
| setPad - Sets the pad width and height, which is the space between |
| child windows in a deck and between multiple decks. |
------------------------------------------------------------------------------*/
unsigned long
deckCount ( ) const;
ISize
margin ( ) const,
pad ( ) const;
ISetCanvas
&setDeckCount ( unsigned long decks ),
&setMargin ( const ISize& margin ),
&setPad ( const ISize& pad );
/*----------------------------------- Text -------------------------------------
| These functions provide the means of adding a group box around the canvas, |
| removing the group box, and querying the text of the group box: |
| setText - Causes a group box with the given text to be drawn around the |
| canvas. If necessary, the canvas is grown to fill the width of |
| the group box. If no text is specified, an existing group box |
| is removed. |
| text - Returns the text of the group box. If the canvas has no |
| surrounding group box, an empty IString is returned. |
------------------------------------------------------------------------------*/
virtual ISetCanvas
&setText ( const char* text ),
&setText ( const IResourceId& text );
virtual IString
text ( ) const;
/*------------------------------- Enumerations ---------------------------------
| The following enumeration is defined: |
| ColorArea - Enumeration that is used to specify an area of the canvas |
| that can be affected with color. The valid value is: |
| background - The portion of the canvas not occupied by any |
| child controls. |
------------------------------------------------------------------------------*/
enum ColorArea {
background
};
/*---------------------------------- Color -------------------------------------
| These functions set and query the color of the canvas: |
| setColor - Sets the specified color of the canvas. |
| color - Returns the specified color of the canvas. |
------------------------------------------------------------------------------*/
ISetCanvas
&setColor ( ColorArea area, const IColor& color );
IColor
color ( ColorArea area ) const;
/*-------------------------------- Overrides -----------------------------------
| This class overrides the following inherited function: |
| setLayoutDistorted - Treats a minimum size change for a child window like |
| a layout change. |
------------------------------------------------------------------------------*/
virtual ISetCanvas
&setLayoutDistorted ( unsigned long layoutAttributeOn,
unsigned long layoutAttributeOff );
protected:
/*-------------------------------- Overrides -----------------------------------
| This function is overridden to position and size child windows using the |
| layout options provided by this canvas: |
| layout - Positions and sizes child windows. |
------------------------------------------------------------------------------*/
virtual ISetCanvas
&layout ( );
/*------------------------------ Implementation --------------------------------
| This function provides support for a surrounding group box: |
| expandForText - Determines how much larger the canvas must be to include |
| a group box with text. |
------------------------------------------------------------------------------*/
ISetCanvas
&expandForText ( );
private:
/*--------------------------------- Private ----------------------------------*/
ISetCanvas ( const ISetCanvas& );
ISetCanvas
&operator= ( const ISetCanvas& );
static Style
currentDefaultStyle;
unsigned long
ulClNumDecks;
Style
scsClStyle;
ISize
sizClMargin,
sizClPad;
friend Boolean
ISetCanvasDeleter ( ISetCanvasObject* const& element,
void* anything );
}; // ISetCanvas
INESTEDBITFLAGCLASSFUNCS(Style, ISetCanvas);
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing. */
/*----------------------------------------------------------------------------*/
#pragma pack()
/*----------------------------- Inline Functions -----------------------------*/
#ifndef I_NO_INLINES
#include <isetcv.inl>
#endif
#endif /* _ISETCV_ */