home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IMCELCV.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
21KB
|
373 lines
#ifndef _IMCELCV_
#define _IMCELCV_
/*******************************************************************************
* FILE NAME: imcelcv.hpp *
* *
* DESCRIPTION: *
* Declaration of the class(es): *
* IMultiCellCanvas - This canvas class organizes its children window *
* into cells of a multi-cell canvas. *
* *
* 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. *
* *
*******************************************************************************/
#ifndef _ICANVAS_
#include <icanvas.hpp>
#endif
#ifndef _IRECT_
#include <irect.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
class IMCCvCell;
class IRCHeader;
class IColor;
class IMultiCellCanvas : public ICanvas {
typedef ICanvas
Inherited;
/*******************************************************************************
* The IMultiCellCanvas class is a control class that manages a collection of *
* child windows in a similar way that data is stored in a spread-sheet. The *
* canvas is a two dimensional array of "cells" with an origin of (1, 1) in *
* the upper left corner. Windows are added to the multiple-cell canvas by *
* specifying a starting cell and, optionally, a number of contiguous columns, *
* rows, or a combination thereof. Here's an example. See the User Interface *
* Class Library Reference for more information. *
* *
* EXAMPLE: *
* *
* void main(int argc,char **argv) *
* { *
* MyFrame* myFrame = new IFrameWindow(); *
* IMultiCellCanvas* myMultiCell = new IMultiCellCanvas(ID_CANVAS, myFrame, *
* myFrame); *
* myFrame->setClient(myMultiCell); *
* IStaticText* txt1 = new IStaticText(ID_STATIC1, myMultiCell, myMultiCell);*
* IStaticText* txt2 = new IStaticText(ID_STATIC2, myMultiCell, myMultiCell);*
* IStaticText* txt3 = new IStaticText(ID_STATIC3, myMultiCell, myMultiCell);*
* IStaticText* txt4 = new IStaticText(ID_STATIC4, myMultiCell, myMultiCell);*
* IEntryField* ent5 = new IEntryField(ID_ENTRY5, myMultiCell, myMultiCell);*
* IEntryField* ent6 = new IEntryField(ID_ENTRY6, myMultiCell, myMultiCell);*
* IEntryField* ent7 = new IEntryField(ID_ENTRY7, myMultiCell, myMultiCell);*
* IStaticText* txt8 = new IStaticText(ID_STATIC8, myMultiCell, myMultiCell);*
* IBitmapControl* bmp9 = new IBitmapControl(ID_BMP9, myMultiCell, *
* myMultiCell, ID_BMP9); *
* *
* txt1->setText("Ford Tempo Pricing Details - 1993"); *
* txt2->setText("Suggested Retail"); *
* txt3->setText("Current Lot Price"); *
* txt4->setText("Current Financing Charges"); *
* ent5->setText("$12,500"); *
* ent6->setText("$10,500"); *
* ent7->setText("$ ,500"); *
* txt8->setText("Note: Data as of Jan 30, 1993"); *
* *
* myMultiCell->addToCell(txt1, 2,1 ,5,1); *
* myMultiCell->addToCell(txt2, 2,3); *
* myMultiCell->addToCell(txt3, 2,4); *
* myMultiCell->addToCell(txt4, 2,5); *
* myMultiCell->addToCell(ent5, 4,3); *
* myMultiCell->addToCell(ent6, 4,4); *
* myMultiCell->addToCell(ent7, 4,5); *
* myMultiCell->addToCell(txt8, 2,7 ,3,1); *
* myMultiCell->addToCell(bmp9, 6,2 ,1,5); *
* myMultiCell->setColumnWidth(5, 10); *
* myMultiCell->setColumnWidth(7, 3); *
* *
* myFrame->show(); *
* *
* IApplication::current().run(); *
* } *
* *
*******************************************************************************/
public:
/*-------------------------------- Style ----------------------------------
The following functions provide a means to set and query multiple-cell
canvas styles:
Style - Nested class that provides static members that define the set of
valid multiple-cell 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 IMultiCellCanvas::Style class and
initialize it like:
IMultiCellCanvas::Style
style = IWindow::visible;
An object of this type is provided when the multiple-cell
canvas is created. A customizable default is used if no styles
are specified. Once the object is constructed, IMultiCellCanvas,
ICanvas, and IWindow member functions can be used to set or
query the object's style.
The declaration of the IMultiCellCanvas::Style nested class is
generated by the INESTEDBITFLAGCLASSDEF2 macro.
The valid multiple-cell canvas styles are:
classDefaultStyle - Original default style for this class, which is
IWindow::visible.
gridLines - Causes the multiple-cell canvas to have grid lines
between the rows and columns of the canvas.
dragLines - Causes the multiple-cell canvas to have draggable
grid lines between the rows and columns of the canvas.
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 multiple-cell
canvases.
-------------------------------------------------------------------------*/
INESTEDBITFLAGCLASSDEF2(Style, IMultiCellCanvas, ICanvas, IWindow);
// style class definition
static const Style
classDefaultStyle,
dragLines,
gridLines;
static Style
defaultStyle ( );
static void
setDefaultStyle ( const Style& style );
/*------------------------------- Constructor ----------------------------------
| A multiple-cell canvas is constructed by providing a window identifier, |
| parent, owner, initial position and size, and style. |
------------------------------------------------------------------------------*/
IMultiCellCanvas ( unsigned long windowIdentifier,
IWindow* parent,
IWindow* owner,
const IRectangle& initialSize = IRectangle(),
const Style& style = defaultStyle() );
virtual
~IMultiCellCanvas ( );
/*------------------------------ Cell Contents ---------------------------------
| These functions provide a means of placing child windows into the cells of |
| the multiple-cell canvas: |
| addToCell - Specifies the starting cell into which a window should |
| be placed. Optionally, the number of columns or rows |
| that the window occupies can be specified. By default, |
| a multiple-cell canvas has no windows. Therefore, this |
| function must be called to add windows to the canvas. |
| Note: This function does not cause the multiple-cell |
| 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. |
| removeFromCell - Removes a window from the canvas. If the cell is |
| specified, the window that occupies that cell will be |
| removed. If the window is specified, the canvas will be |
| searched to find the cell that contains the window. If |
| the window is found, it will be removed; otherwise, 0 is |
| returned. |
| Note: This function does not cause the multiple-cell |
| 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. |
| windowInCell - Returns the child window that occupies the specified |
| cell. |
------------------------------------------------------------------------------*/
virtual IMultiCellCanvas
&addToCell ( IWindow* childWindow,
unsigned long startingColumn,
unsigned long startingRow,
unsigned long numberOfColumns = 1,
unsigned long numberOfRows = 1 );
virtual IWindow
*removeFromCell ( const IWindow* childWindow ),
*removeFromCell ( unsigned long column,
unsigned long row );
virtual IWindow
*windowInCell ( unsigned long startingColumn,
unsigned long startingRow ) const;
/*------------------------- Row and Column Behavior ----------------------------
| These functions provide a means of setting the width of columns and height |
| of rows in the canvas, as well as setting their ability to expand with the |
| canvas: |
| setColumnWidth - Defines a width value to be used to increase the |
| width of a column beyond the minimum width of the |
| windows contained in the column. If the expandable |
| argument is set to true, windows in the column will |
| be expanded horizontally when the canvas expands |
| beyond the minimum canvas size. |
| Note: This function does not cause the multiple-cell |
| 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. |
| setRowHeight - Defines a height value to be used to increase the |
| height of a row beyond the minimum height of the |
| windows contained in the row. If the expandable |
| argument is set to true, windows in the row will be |
| expanded vertically when the canvas expands beyond |
| the minimum canvas size. |
| Note: This function does not cause the multiple-cell |
| 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. |
| columnWidth - Returns the current width of the specified column, |
| in pixels. |
| rowHeight - Returns the current height of the specified row, in |
| pixels. |
| setDefaultCell - A static function that sets the default width for a |
| column and height for a row that does not contain a |
| window. The initial default for both rows and |
| columns is 10 pixels. |
| defaultCell - Queries the current default cell size. This is a |
| static function. |
| isColumnExpandable - Returns true if the specified column can be expanded |
| when the canvas expands beyond the minimum canvas |
| size. |
| isRowExpandable - Returns true if the specified row can be expanded |
| when the canvas expands beyond the minimum canvas |
| size. |
------------------------------------------------------------------------------*/
IMultiCellCanvas
&setColumnWidth ( unsigned long column,
unsigned long widthInPixels,
Boolean expandable = false ),
&setRowHeight ( unsigned long row,
unsigned long heightInPixels,
Boolean expandable = false );
unsigned long
columnWidth ( unsigned long column ) const,
rowHeight ( unsigned long row ) const;
static void
setDefaultCell ( const ISize& widthAndHeight );
static ISize
defaultCell ( );
Boolean
isColumnExpandable ( unsigned long column ) const,
isRowExpandable ( unsigned long row ) const;
/*----------------------------- Color Operations -------------------------------
| The following functions provide a means for setting and getting the color |
| of the background of the multiple-cell canvas: |
| setColor - Sets the color to be used for the background of the canvas. |
| color - Returns the color used for the background of the canvas. |
------------------------------------------------------------------------------*/
IColor
color ( ) const;
IMultiCellCanvas
&setColor ( const IColor& color );
/*---------------------------- 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: |
| hasDragLines - Returns true if the dragLines style is set. |
| hasGridLines - Returns true if the gridLines style is set. |
| disableDragLines - Disables the dragLines style of the multiple-cell |
| canvas. |
| enableDragLines - Enables the dragLines style of the multiple-cell |
| canvas. |
| disableGridLines - Disables the gridLines style of the multiple-cell |
| canvas. |
| enableGridLines - Enables the gridLines style of the multiple-cell |
| canvas. |
------------------------------------------------------------------------------*/
Boolean
hasDragLines ( ) const,
hasGridLines ( ) const;
IMultiCellCanvas
&disableDragLines ( ),
&enableDragLines ( Boolean enable = true ),
&disableGridLines ( ),
&enableGridLines ( Boolean enable = true );
/*-------------------------------- Overrides -----------------------------------
| This class overrides the following inherited function: |
| setLayoutDistorted - Treats a size change like a layout change. |
------------------------------------------------------------------------------*/
virtual IMultiCellCanvas
&setLayoutDistorted ( unsigned long layoutAttributeOn,
unsigned long layoutAttributeOff );
protected:
/*----------------------- Canvas Layout Implementation -------------------------
| This function implements the canvas layout algorithm: |
| layout - Computes the child windows' positions and sizes based on the |
| contents of the cells, the set size for rows and columns, and |
| the expandability of rows and columns. |
------------------------------------------------------------------------------*/
virtual IMultiCellCanvas
&layout ( );
private:
/*--------------------------------- Private ----------------------------------*/
IMultiCellCanvas ( const IMultiCellCanvas& );
IMultiCellCanvas
&operator= ( const IMultiCellCanvas& );
IMultiCellCanvas
&pass1 ( ),
&pass2 ( ),
&pass3 ( ),
&pass4 ( ),
&computeExpandedRowsCols ( );
static Style
currentDefaultStyle;
static unsigned long
ulDefaultWidth,
ulDefaultHeight;
Boolean
fMulti,
fExpand,
bClDragLines,
bClGridLines;
friend class IRowColumnHeaderList;
friend class IMultiCellCanvasList;
friend class IMultiCellCanvasHandler;
IMultiCellCanvasList
*pCanvasList;
IRowColumnHeaderList
*pRowColHeaderList;
IMultiCellCanvasHandler
*pCanvasHandler;
friend Boolean IRowColHeaderInitializer ( IRCHeader* const& header,
void* anything );
friend Boolean IMultiCellCanvasDeleter ( IMCCvCell* const& cell,
void* anything );
friend Boolean IRowColumnHeaderDeleter ( IRCHeader* const& header,
void* anything );
}; // IMultiCellCanvas
INESTEDBITFLAGCLASSFUNCS(Style, IMultiCellCanvas);
// global style functions
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing. */
/*----------------------------------------------------------------------------*/
#pragma pack()
#endif /* _IMCELCV_ */