home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IFRAME.HPP
< prev
next >
Wrap
Text File
|
1993-10-22
|
40KB
|
743 lines
#ifndef _IFRAME_
#define _IFRAME_
/*******************************************************************************
* FILE NAME: iframe.hpp *
* *
* DESCRIPTION: *
* This file contains the declaration(s) of the class(es): *
* IFrameWindow - Class representing OS/2 PM "frame" windows. *
* *
* 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 _IBASE_
#include <ibase.hpp>
#endif
#ifndef _IWINDOW_
#include <iwindow.hpp>
#endif
#ifndef _IHANDLE_
#include <ihandle.hpp>
#endif
#ifndef _IRESLIB_
#include <ireslib.hpp>
#endif
#ifndef _ICCONST_
#include <icconst.h>
#endif
#ifndef _IRECT_
#include <irect.hpp>
#endif
#ifndef _ICMDEVT_
#include <icmdevt.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
/*----------------------------------------------------------------------------*/
/* Turn off warning for compiler generated copy/assignment */
/*----------------------------------------------------------------------------*/
#pragma info(nocpy)
class IFrameExtensions;
class IFrameExtension;
class IFrameHandler;
class IColor;
class IFrameWindowData;
class IFrameWindow : public IWindow {
typedef IWindow
Inherited;
/*******************************************************************************
* The IFrameWindow class is used to create OS/2 frame windows. Such windows *
* are typically children of the desktop and parent/owner windows of the User *
* Interface Class Library dialogs and controls. *
* *
* The primary distinction between an IFrameWindow and a generic IWindow is *
* that frame windows are conceptually comprised of a number of child windows. *
* Frame windows can include any combination of the following. Components *
* that have an asterisk (*) next to them are default components. *
* *
* - A title bar * *
* - A system menu * *
* - Minimize and maximize buttons * *
* - A window list * *
* - A sizing border * *
* - A double-byte character set (DBCS) status area * *
* - A menu bar *
* - A client window *
* *
* The User Interface Class Library has classes that allow you to manipulate *
* several of these components. Those classes are: *
* *
* - ITitle (title bar) *
* - ISystemMenu (system menu) *
* - IMenuBar (menu bar) *
* *
* The frame's client window is essentially the control that corresponds to *
* the rectangular portion of the frame window not occupied by the other frame *
* controls. *
* *
* In addition to the standard Presentation Manager frame controls, *
* IFrameWindow supports additional frame extensions. These extensions are *
* primarily application-specific, although a general-purpose information area *
* extension is provided by the IInfoArea class. Extensions are added to the *
* frame by providing an IWindow and specifying the portion of the frame to be *
* occupied by the window. The extension can fill a portion of the standard *
* title bar area (the left- or right-hand side of a given width) or the *
* standard client area (the top or bottom edge of a given height). *
*******************************************************************************/
public:
class Style;
/*------------------------- Constructors/Destructor ----------------------------
| There are eight ways to construct frame windows. The first three ways use |
| the given window or resource ID to attempt to create the frame from a |
| dialog template that contains the frame attributes. If no dialog resource |
| is found, a plain frame window is constructed and given the window ID |
| specified in the argument resource ID. You can construct frame windows |
| from a dialog template as follows: |
| |
| - From a given window ID. |
| - From a given resource ID and optional owner window pointer. |
| - From a given resource ID, parent window, and owner window. |
| |
| The remaining constructors presume that the window to be constructed is not |
| to be created from a dialog template. Instead, the frame attributes are |
| specified as additional constructor arguments. You can construct frame |
| windows without a dialog template as follows: |
| |
| - From the window handle of an existing frame window. |
| - From a resource ID and frame style. |
| - From a frame style and optional resource ID. |
| - From a title, and optional resource ID and frame style. |
| - From a full set of frame attributes: resource ID, parent, owner, |
| initial rectangle (position and size), and optional style and title. |
------------------------------------------------------------------------------*/
IFrameWindow ( unsigned long id = IC_DEFAULT_FRAME_ID );
IFrameWindow ( const IResourceId &resId,
IWindow *owner = 0 );
IFrameWindow ( const IResourceId &resId,
IWindow *parent,
IWindow *owner );
IFrameWindow ( const IWindowHandle &hwnd );
IFrameWindow ( const IResourceId &resId,
const IFrameWindow::Style &style );
IFrameWindow ( const IFrameWindow::Style &style,
const IResourceId &resId = IC_DEFAULT_FRAME_ID );
IFrameWindow ( const char *title,
const IResourceId &resId = IC_DEFAULT_FRAME_ID,
const IFrameWindow::Style &style = defaultStyle() );
IFrameWindow ( const IResourceId &resId,
IWindow *parent,
IWindow *owner,
const IRectangle &initRect,
const IFrameWindow::Style &style = defaultStyle(),
const char *title = 0 );
virtual
~IFrameWindow ( );
/*---------------------------------- Style -------------------------------------
| The following functions provide a means to set and query frame window |
| styles: |
| Style - Nested class that provides static members that define the set of |
| valid frame window styles. These styles can be used in |
| conjunction with the styles defined by the IWindow::Style nested |
| class. |
| |
| The valid frame window styles are: |
| |
| classDefaultStyle - The original default style for this class, which is |
| titleBar | systemMenu | minimizeButton | windowList |
| maximizeButton | sizingBorder | appDBCSStatus. |
| accelerator - Associates an accelerator key table with the frame |
| window. The table is loaded from the application's |
| resource library. |
| alignNoAdjust - Restricts adjustment of the frame position. As a |
| consequence of setting this style, certain |
| performance optimizations obtained by such |
| alignment are lost. |
| animated - Shows the frame window with "animation" when it is |
| opened, closed, or restored. |
| appDBCSStatus - Includes a DBCS status area in the frame window |
| when it is displayed in a DBCS environment. |
| border - Puts a border around the frame window. |
| dialogBackground - Gives a frame (not created from a dialog template) |
| the system dialog background color. Without this |
| style, the frame has the system window background |
| color. |
| dialogBorder - Puts a dialog border around the frame window. |
| hideButton - Provides the frame window with a hide button. This |
| style is mutually exclusive with the minimizeButton |
| style. |
| horizontalScroll - Provides a horizontal scroll bar in the frame |
| window. |
| maximizeButton - Provides a maximize button in the frame window. |
| maximized - Causes the frame window to be created in the |
| maximized state. |
| menuBar - Provides the frame window with a menu bar, which is |
| loaded from the application's resource library. |
| If you want to construct the frame window |
| dynamically instead of from a resource library, use |
| the IMenuBar class instead of the menuBar style. |
| minimizeButton - Provides a minimize button in the frame window. |
| This style is mutually exclusive with the |
| hideButton style. |
| minimized - Causes the frame window to be created in the |
| minimized state. |
| minimizedIcon - Associates an icon with the frame window. This |
| icon is used when the frame window is minimized. |
| noMoveWithOwner - Disables the default behavior of moving frame |
| windows automatically with their owner. |
| shellPosition - Sets the initial position of the window to a |
| location and size dictated by the system shell. |
| sizingBorder - Puts a sizing border around the frame window. |
| systemMenu - Provides a system menu in the frame window. |
| systemModal - Sets the frame window in system modal mode. |
| titleBar - Provides a title bar for the frame window. |
| verticalScroll - Provides a vertical scroll bar in the frame window. |
| windowList - Adds an entry for this frame window to the system |
| window list. |
| |
| The following functions provide 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 frame windows. |
-----------------------------------------------------------------------------*/
INESTEDBITFLAGCLASSDEF1( Style, IFrameWindow, IWindow );
static const Style
classDefaultStyle,
accelerator,
alignNoAdjust,
animated,
appDBCSStatus,
border,
dialogBackground,
dialogBorder,
hideButton,
horizontalScroll,
maximizeButton,
maximized,
menuBar,
minimizeButton,
minimized,
minimizedIcon,
noMoveWithOwner,
shellPosition,
sizingBorder,
systemMenu,
systemModal,
titleBar,
verticalScroll,
windowList;
static Style
defaultStyle ( );
static void
setDefaultStyle ( const Style &aStyle );
/*----------------------- System Menu Related Actions --------------------------
| These functions deal with frame operations related to the actions on the |
| system menu: |
| close - Closes the frame window. |
| maximize - Maximizes the window. |
| maximizeRect - Returns the window rectangle coordinates to which it is |
| maximized. |
| minimize - Minimizes the window. |
| minimizeRect - Returns the window rectangle coordinates to which it is |
| minimized. |
| restore - Restores a maximized or minimized window. |
| restoreRect - Returns the window rectangle coordinates to which the |
| window is restored. |
| setRestoreRect - Changes the rectangle coordinates to which the window |
| is restored. |
| nextShellRect - Returns the system-recommended coordinates of the next |
| main window. |
------------------------------------------------------------------------------*/
virtual IFrameWindow
&close ( ),
&maximize ( ),
&minimize ( ),
&restore ( ),
&setRestoreRect ( const IRectangle &aRect );
virtual IRectangle
maximizeRect ( ) const,
minimizeRect ( ) const,
restoreRect ( ) const;
static IRectangle
nextShellRect ( );
/*---------------------- Moving/Sizing Related Actions -------------------------
| These functions deal with moving and sizing the frame and client windows: |
| moveSizeToClient - Sizes and positions the frame window around the client |
| rectangle. |
| clientRectFor - Returns the client window rectangle based on the size |
| and position of the frame window and its extensions. |
| frameRectFor - Returns the frame window rectangle based on the size |
| and position of the client rectangle, and the frame |
| window's extensions. |
------------------------------------------------------------------------------*/
virtual IFrameWindow
&moveSizeToClient ( const IRectangle& clientRect );
virtual IRectangle
clientRectFor ( const IRectangle& frameRect ) const,
frameRectFor ( const IRectangle& clientRect ) const;
/*----------------------- Set and Query Size Border-----------------------------
| The following functions provide a means to set or query either the width |
| or height of the frame window, or both simultaneously: |
| borderWidth - Returns the screen coordinates for the width of the |
| frame window's border. |
| borderHeight - Returns the screen coordinates for the height of the |
| frame window's border. |
| borderSize - Returns the screen coordinates for both the width and |
| the height of the frame window's border. |
| setBorderWidth - Sets the screen coordinates for the width of the frame |
| window's border. |
| setBorderHeight - Sets the screen coordinates for the height of the frame |
| window's border. |
| setBorderSize - Sets the screen coordinates for both the width and the |
| height of the frame window's border. |
------------------------------------------------------------------------------*/
unsigned short
borderWidth ( ) const,
borderHeight ( ) const;
ISize
borderSize ( ) const;
IFrameWindow
&setBorderWidth ( unsigned short cx ),
&setBorderHeight ( unsigned short cy ),
&setBorderSize ( const ISize &size ),
&setBorderSize ( unsigned short cxcy ),
&setBorderSize ( unsigned short cx, unsigned short cy );
/*------------------------------ Modal Display ---------------------------------
| These functions are applied to use a frame window (dialog) in an |
| application-modal fashion: |
| showModally - Causes the frame to be displayed in application-modal mode |
| (all other application windows are disabled). |
| dismiss - Dismisses a frame window by hiding it and, if modal, causes |
| the completion of the showModally function call that |
| triggered its display. |
| result - Returns the most recent result for this frame. The most |
| recent result is the value specified when the window was |
| last dismissed. |
| setResult - Sets the result for this frame. |
| notifyOwner - Posts a command event to the frame's (dialog's) owner. |
------------------------------------------------------------------------------*/
virtual unsigned long
showModally ( ),
result ( ) const;
virtual IFrameWindow
&dismiss ( unsigned long result = 0 ),
&setResult ( unsigned long result ),
¬ifyOwner ( unsigned short id,
ICommandEvent::Source source = ICommandEvent::unknown,
Boolean ptrDevice = false );
/*----------------------------- Application Icon -------------------------------
| These functions permit management of the application icon used in the |
| frame's system menu or when the frame is minimized: |
| icon - Returns the pointer handle of the window icon. |
| setIcon - Sets the window icon. |
------------------------------------------------------------------------------*/
virtual IPointerHandle
icon ( ) const;
virtual IFrameWindow
&setIcon ( const IPointerHandle &icon ),
&setIcon ( const IResourceId &iconResId ),
&setIcon ( unsigned long iconResId );
/*---------------------- ColorArea Enumeration ---------------------------------
| ColorArea - Enumeration that is used to replace the color for a particular |
| area of the frame window. The valid values are: |
| background - Sets the color of the frame window's |
| background. |
| foreground - Sets the color of the frame window's |
| foreground. |
| shadow - Sets the color of the frame window's |
| shadow. |
| disableBackground - Sets the color of the frame window's |
| background when the frame window is |
| disabled. |
| activeBorder - Sets the color to be used for the frame |
| window's border when the frame window is |
| active. |
| inactiveBorder - Sets the color to be used for the frame |
| window's border when the frame window is |
| inactive. |
| frameBorder - Sets the color to be used for the border |
| drawn around the children of the frame |
| window. |
------------------------------------------------------------------------------*/
enum ColorArea {
background,
foreground,
shadow,
disableBackground,
activeBorder,
inactiveBorder,
frameBorder };
/*-------------------------- Set and Query Color ------------------------------
| The following functions provide a mean to set and query the frame window |
| color: |
| setColor - Changes the color of the specified frame window area. |
| color - Returns the color of the specified frame window area. |
| usesDialogBackground - Returns if the frame uses the system dialog |
| background color (rather than the system window background |
| color). This function is not sensitive to whether an |
| overriding background color has not been assigned with the |
| setColor function. |
------------------------------------------------------------------------------*/
IFrameWindow
&setColor ( ColorArea value,
const IColor& color );
IColor
color ( ColorArea value ) const;
Boolean
usesDialogBackground ( ) const;
/*------------------------------ Client Control --------------------------------
| These functions are used to manipulate the frame client control. The frame |
| client is much like any of the other frame controls, but this control will |
| receive notification of certain events not handled by the frame itself. |
| For example, it receives notification for most ICommandEvents that originate |
| from the frame menu bar. |
| clientHandle - Returns the IWindowHandle of the client window or a NULL |
| handle if no client window exists. |
| client - Returns a pointer to the IWindow that corresponds to the |
| client window or 0 if no client window exists. |
| setClient - Specifies the IWindow that corresponds to the frame client |
| area. |
------------------------------------------------------------------------------*/
virtual IWindowHandle
clientHandle ( ) const;
virtual IWindow
*client ( ) const;
virtual IFrameWindow
&setClient ( IWindow *newClient );
/*----------------------------- Frame Extensions -------------------------------
| These functions provide the capability to add extensions to the standard |
| frame window. Such extensions are simply additional windows placed in |
| specific locations. The information area implemented by the IInfoArea |
| class is an example of such an extension. |
| Location - Enumeration that provides the possible locations at |
| which an extension can be located. The valid values |
| are: |
| leftOfTitleBar - To the left of the frame title |
| area (but to the right of the |
| system menu, if there is one). |
| rightOfTitleBar - To the right of the frame title. |
| leftOfMenuBar - To the left of the menu bar. |
| rightOfMenuBar - To the right of the menu bar. |
| leftOfClient - At the left-hand side of the |
| client area. |
| rightOfClient - At the right-hand side of the |
| client area. |
| aboveClient - At the top of the client area. |
| belowClient - At the bottom of the client area. |
| SeparatorType - Enumerator that provides the possible types of |
| separators that will be drawn between the extension |
| and the window to which it is attached: |
| none - No separator will be drawn. |
| thinLine - A thin separator line (1 pel wide) will |
| be drawn. |
| thickLine - A thick separator line (3 pels wide) |
| will be drawn. |
| addExtension - Adds a window as a frame extension. Arguments |
| indicate where the extension is to be located and what |
| portion of the location window is to be allocated to |
| this extension. The portion can be specified as |
| either a fixed width and height or a floating point |
| value holding a percentage. For example, 0 < x < 1.0. |
| removeExtension - Removes a frame extension (window). |
| setExtensionSize - Resets a frame extension's size. |
| update - Causes the frame window to reconfigure all its |
| controls and extensions. This function is called |
| automatically by the addExtension and setClient member |
| functions. |
------------------------------------------------------------------------------*/
enum Location
{
leftOfTitleBar,
rightOfTitleBar,
leftOfMenuBar,
rightOfMenuBar,
leftOfClient,
rightOfClient,
aboveClient,
belowClient
};
enum SeparatorType
{
none,
thinLine,
thickLine
};
virtual IFrameWindow
&addExtension ( IWindow *aWindow,
Location aLocation,
unsigned long widthOrHeight,
SeparatorType separator = thinLine ),
&addExtension ( IWindow *aWindow,
Location aLocation,
int widthOrHeight,
SeparatorType separator = thinLine ),
&addExtension ( IWindow *aWindow,
Location aLocation,
double percentage,
SeparatorType separator = thinLine ),
&removeExtension ( IWindow *aWindow ),
&setExtensionSize ( IWindow *aWindow,
int widthOrHeight ),
&setExtensionSize ( IWindow *aWindow,
double widthOrHeight ),
&show ( Boolean showWindow = true ),
&update ( );
/*---------------------------- Window Destruction ------------------------------
| These functions deal with the destruction of the PM window associated |
| with this object when the window is closed: |
| setDestroyOnClose - Sets the destroy window flag on or off. |
| willDestroyOnClose - Returns the state of the destroy window flag; the |
| default is on. |
------------------------------------------------------------------------------*/
virtual IFrameWindow
&setDestroyOnClose ( Boolean onOrOff = true );
Boolean
willDestroyOnClose ( ) const;
/*--------------------------------- Testing ------------------------------------
| These functions test various attributes of the frame window: |
| isFlashing - Returns true if the frame is currently flashing. |
| isMaximized - Returns true if the frame window is currently maximized. |
| isMinimized - Returns true if the frame window is currently minimized. |
| isModal - Returns true if the window is currently being displayed in |
| application-modal mode. |
------------------------------------------------------------------------------*/
Boolean
isFlashing ( ) const,
isMaximized ( ) const,
isMinimized ( ) const,
isModal ( ) const;
/*------------------------------- Window List ----------------------------------
|These functions are used to add and remove frame titles from the window list: |
| addToWindowList - Adds this frame's title as a window list entry. |
| This is done automatically if the frame is |
| constructed with the windowList style flag set. |
| removeFromWindowList - Removes this frame's entry from the window list. |
------------------------------------------------------------------------------*/
virtual IFrameWindow
&addToWindowList ( ),
&removeFromWindowList ( );
/*------------------------- Standard Control Access ----------------------------
|This function is used to get information about the standard controls: |
| handleFor - Returns the IWindowHandle that corresponds to a standard frame |
| control. If the control is not present, the function returns 0. |
------------------------------------------------------------------------------*/
virtual IWindowHandle
handleFor ( const Style &aStdConstrol ) const;
/*------------------------------ Miscellaneous ---------------------------------
|These functions are used to make the frame start and stop flashing: |
| beginFlashing - Starts flashing the frame to alert the user to something |
| that requires immediate attention. |
| endFlashing - Stops flashing the frame window. |
------------------------------------------------------------------------------*/
virtual IFrameWindow
&beginFlashing ( ),
&endFlashing ( );
/*------------------------------- DBCS Support ---------------------------------
|This function is used to share DBCS information between a parent and child |
|frame: |
| shareParentDBCSStatus - Causes a child frame to share the DBCS status |
| control of its parent. If either the child or |
| parent do not have the appDBCSStatus style set, |
| then this function has no effect. |
------------------------------------------------------------------------------*/
virtual IFrameWindow
&shareParentDBCSStatus ( );
/*------------------------- Sibling Order --------------------------------------
| These functions affect the ordering of windows with their siblings. The |
| window order (or Z Order) is used when tabbing or painting sibling windows. |
| Window painting starts from the bottom sibling and proceeds to the top |
| window. Cursor tabbing occurs from the top sibling and proceeds |
| to the bottom window. |
| setDefaultOrdering - Determines whether new windows are created on |
| top of their sibling windows or behind them. By |
| default, windows are created behind their |
| other siblings. If this function is called |
| with a value of IWindow::onTopOfSiblings, new |
| windows will be created on top of their siblings.|
| defaultOrdering - Returns the order in which new windows will be |
| created relative to their sibling windows. |
------------------------------------------------------------------------------*/
static void
setDefaultOrdering ( IWindow::SiblingOrder ordering);
static IWindow::SiblingOrder
defaultOrdering ( );
protected:
/*------------------------------ Implementation --------------------------------
| extensions - Returns a pointer to the frame extensions collection. |
| setExtensions - Sets a pointer to the frame extensions collection. |
| findExtension - Locates the extension that corresponds to a given |
| IWindow. |
| initialize - Specifies to use a common frame window construction. |
| tryToLoadDialog - Attempts to load the dialog window and if it fails, |
| calls initialize. |
| create - Creates a Presentation Manager frame window. |
| start - Creates a frame handler and adds it to the (newly |
| created) frame window. |
| flagsFrom - Converts the Style value to the corresponding FCF_* |
| flags. |
| styleFrom - Converts the Style value to the corresponding WS_* |
| flags. |
| deferCreation - Additional style that can be specified by derived |
| classes in cases where the derived class will create |
| the frame window (perhaps by calling |
| IFrameWindow::initialize or IFrameWindow::create). |
| addDefaultHandler - Adds the default frame handler to a newly created |
| frame. |
| removeDefaultHandler - Removes the default frame handler from the frame |
| upon destruction. |
------------------------------------------------------------------------------*/
IFrameExtensions
*extensions ( ) const;
static const Style
deferCreation;
unsigned
findExtension ( IWindow *window );
IFrameWindow
&setExtensions ( IFrameExtensions *p ),
&tryToLoadDialog ( const IResourceId &resId,
IWindow *parent = 0,
IWindow *owner = 0 ),
&initialize ( const IResourceId &resId,
const Style &style,
IWindow *parent = 0,
IWindow *owner = 0,
const IRectangle &initRect = nextShellRect(),
const char *title = 0 );
IWindowHandle
create ( unsigned long id,
const char *title,
unsigned long style,
const char *windowClass,
const IWindowHandle &parent,
const IWindowHandle &owner,
const IRectangle &initRect,
const void *ctlData,
const void *presParams,
IWindow::SiblingOrder ordering=defaultOrdering());
IFrameWindow
&start ( const IWindowHandle &hwnd ),
&addDefaultHandler ( ),
&removeDefaultHandler ( );
static unsigned long
flagsFrom ( const Style &style ),
styleFrom ( const Style &style );
private: /*------------------------ PRIVATE ----------------------------------*/
static const Style
styleBits;
static Style
currentDefault;
static IWindow::SiblingOrder
siblingCreateOrder;
IFrameExtensions
*pExtensions;
IFrameWindow
&addExtension ( IFrameExtension *p );
IFrameWindowData
*pData;
unsigned
flags;
unsigned long
rc;
IPointerHandle
frameIcon;
static const unsigned
destroyOnClose,
hasDefaultHandler,
modal,
needsUpdating,
fromDlgTemplate,
standardFrame,
hasBeenClosed;
friend class IFrameHandler;
}; // class IFrame
INESTEDBITFLAGCLASSFUNCS(Style, IFrameWindow);
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing and warning messages. */
/*----------------------------------------------------------------------------*/
#pragma pack()
#pragma info(restore)
#endif // _IFRAME_