home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
ICANVAS.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
14KB
|
257 lines
#ifndef _ICANVAS_
#define _ICANVAS_
/*******************************************************************************
* FILE NAME: icanvas.hpp *
* *
* DESCRIPTION: *
* Declaration of the class(es): *
* ICanvas - This class can be used as a client area object, and is also *
* the base class for all other canvas classes. *
* *
* 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 _ICONTROL_
#include <icontrol.hpp>
#endif
#ifndef _IBITFLAG_
#include <ibitflag.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 ICanvasHandler;
class IColor;
class IKeyboardEvent;
class IResourceId;
class IWindowPosBuffer;
class ICanvas : public IControl {
typedef IControl
Inherited;
friend class ICanvasHandler;
/*******************************************************************************
* The ICanvas class can be used as a client area object. A client area *
* object is an intermediate window between an IFrameWindow and its controls *
* and other child windows. The client area for an IFrameWindow is specified *
* using IFrameWindow::setClient. Unlike other canvas classes, ICanvas does *
* not alter the size or position of its child windows. However, its use as a *
* client area or as the parent window of controls that can accept the input *
* focus will provide the following support that can be missing if another *
* class (such as IStaticText) or no window at all is used in its place: *
* *
* - Handling of the tab and cursor movement keys. *
* - Handling of focus change events. *
* - Allows the client area window or the frame window (if a canvas is not *
* the client area window) to be the control point to perform command *
* processing. *
* - Allows the frame window to change the appearance of the mouse pointer. *
* - Prevents the border of the frame window from being overwritten. *
* *
* Additionally, this class is the base class for all other canvas classes, and *
* provides the above behavior for all derived classes. These derived classes *
* provide special layout rules for sizing and positioning their child windows. *
* *
* Example: *
* ICanvas cvPushButtons(0, parent, owner, IRectangle(0, 0, 435, 50)); *
* // add controls to the canvas by making them child windows *
* IPushButton pbApply(ID_APPLY, &cvPushButtons, &cvPushButtons, *
* IRectangle(10, 10, 110, 40), *
* IPushButton::classDefaultStyle | *
* IPushButton::defaultButton | *
* IControl::group | IControl::tabStop); *
* IPushButton pbReset(ID_RESET, &cvPushButtons, &cvPushButtons, *
* IRectangle(115, 10, 215, 40)); *
* IPushButton pbUndo(ID_UNDO, &cvPushButtons, &cvPushButtons, *
* IRectangle(220, 10, 320, 40)); *
* IPushButton pbCancel(SC_CLOSE, &cvPushButtons, &cvPushButtons, *
* IRectangle(325, 10, 425, 40), *
* IPushButton::classDefaultStyle | *
* IPushButton::systemCommand); *
*******************************************************************************/
public:
class Style; // forward declaration for nested class
/*------------------------------- Constructor ----------------------------------
| The only way to construct an instance of this class is to create a canvas |
| window with the specified window ID, parent window, owner window, rectangle, |
| and style. |
------------------------------------------------------------------------------*/
ICanvas ( unsigned long windowId,
IWindow* parent,
IWindow* owner,
const IRectangle& initial = IRectangle(),
const Style& style = defaultStyle() );
virtual
~ICanvas ( );
/*---------------------------------- Style -------------------------------------
| The following functions provide a means to set and query canvas styles: |
| |
| Style - Nested class that provides static members that define the set |
| of valid canvas styles. These styles can be used in conjunction |
| with the styles defined by the IWindow::Style nested class. For |
| example, you could define an instance of the ICanvas::Style |
| class and initialize it like: |
| ICanvas::Style |
| style = ICanvas::classDefaultStyle | |
| IWindow::saveBits; |
| An object of this type is provided when the canvas is created. A |
| customizable default is used if no styles are specified. Once |
| the object is constructed, ICanvas and IWindow member functions |
| can be used to set or query the object's style. |
| |
| The declaration of the ICanvas::Style nested class is generated |
| by the INESTEDBITFLAGCLASSDEF1 macro. |
| |
| The valid canvas style is: |
| classDefaultStyle - The original default style for this class, which is |
| IWindow::visible. |
| |
| The following functions provide a means of getting and setting the default |
| style for new objects of this class: |
| defaultStyle - Returns the current default style, which is the same as |
| classDefaultStyle unless setDefaultStyle has been |
| called. |
| setDefaultStyle - Sets the default style for all subsequent canvases. |
------------------------------------------------------------------------------*/
INESTEDBITFLAGCLASSDEF1(Style, ICanvas, IWindow);
// style class definition
static const Style
classDefaultStyle;
static Style
defaultStyle ( );
static void
setDefaultStyle ( const Style& style );
/*------------------------------- Enumerations ---------------------------------
| The following enumerations are defined: |
| ColorArea - Used to specify an area of the canvas that can be affected |
| with color: |
| background - The background of the canvas (the portion |
| not occupied by child windows). |
------------------------------------------------------------------------------*/
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. |
------------------------------------------------------------------------------*/
ICanvas
&setColor ( ColorArea area, const IColor& color );
IColor
color ( ColorArea area ) const;
/*------------------------- Dialog Behavior Support ----------------------------
| This function returns information used to provide dialog-like keyboard |
| support for the canvas classes: |
| origDefaultButtonHandle - Returns the push button originally identified as |
| being the default. |
------------------------------------------------------------------------------*/
IWindowHandle
origDefaultButtonHandle ( ) const;
/*-------------------------------- Overrides -----------------------------------
| This class overrides the following inherited functions: |
| isTabStop - Returns true if the canvas can be tabbed to based on |
| whether any of its child windows can be tabbed to. |
| defaultPushButton - Returns the first child window that is a default push |
| button, if one exists. |
| matchForMnemonic - Returns the first child window that uses the |
| specified character as a mnemonic. |
| setLayoutDistorted - Provides common canvas processing. |
------------------------------------------------------------------------------*/
virtual Boolean
isTabStop ( ) const;
virtual IWindowHandle
defaultPushButton ( ) const,
matchForMnemonic ( unsigned short character ) const;
virtual ICanvas
&setLayoutDistorted ( unsigned long layoutAttributeOn,
unsigned long layoutAttributeOff );
protected:
/*--------------------------- Protected Overrides ------------------------------
| This class overrides the following inherited protected function: |
| calcMinimumSize - Returns the minimum screen size this control can occupy, |
| based on the size and positions of its child windows. |
------------------------------------------------------------------------------*/
virtual ISize
calcMinimumSize ( ) const;
/*---------------------------------- Layout ------------------------------------
| The following functions provide the major functionality of this class: |
| layout - This function is overridden by derived classes to |
| size and position child windows. |
| layoutSize - Returns the size needed to show all child windows. |
| setLayoutSize - Sets the size needed to show all child windows. |
| fixupChildren - Generates a list of all child windows, determines |
| whether any can be tabbed to, and allows for |
| reversing the order in which they are iterated. |
| areChildrenReversed - States whether the order in which child windows are |
| returned by the IWindow::ChildCursor class has been |
| changed to the order of the child windows' |
| construction. |
------------------------------------------------------------------------------*/
virtual ICanvas
&layout ( );
const ISize
&layoutSize ( ) const;
ICanvas
&setLayoutSize ( const ISize& size );
IWindowPosBuffer
fixupChildren ( );
Boolean
areChildrenReversed ( ) const;
private:
/*--------------------------------- Private ----------------------------------*/
ICanvas ( const ICanvas& );
ICanvas
&operator= ( const ICanvas& );
static Style
currentDefaultStyle;
ISize
sizClLayout;
IWindowHandle
hwndClDefaultButton;
Boolean
bClChildrenReversed,
bClDefaultHandlerAdded;
};
INESTEDBITFLAGCLASSFUNCS(Style, ICanvas);
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing. */
/*----------------------------------------------------------------------------*/
#pragma pack()
/*----------------------------- Inline Functions -----------------------------*/
#ifndef I_NO_INLINES
#include <icanvas.inl>
#endif
#endif /* _ICANVAS_ */