home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IINFOA.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
14KB
|
252 lines
#ifndef _IINFOA_
#define _IINFOA_
/*******************************************************************************
* FILE NAME: iinfoa.hpp *
* *
* DESCRIPTION: *
* This file contains the declaration(s) of the class(es): *
* IInfoa - Information area for a frame window *
* *
* 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 _ISTATTXT_
#include <istattxt.hpp>
#endif
#ifndef _IMENUHDR_
#include <imenuhdr.hpp>
#endif
#ifndef _ISTRING_
#include <istring.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
// Forward declarations for other classes:
class IFrameWindow;
class IMenuEvent;
class IModuleHandle;
class IResourceLibrary;
class IInfoArea : public IStaticText, public IMenuHandler {
typedef IStaticText
Inherited;
/*******************************************************************************
* The IInfoArea class objects provide a frame extension at the bottom of the *
* client area that shows information about the frame menu item at which the *
* selection cursor is currently positioned. *
* *
* The information area will display the contents of an entry in a resource *
* string table. The string resource will be obtained by using the same ID as *
* the menu item plus some optional "offset" value that will be added to the *
* menu item ID to locate the corresponding string of information about it. *
* *
* The strings will be loaded from a dynamic link library (DLL). A library *
* name can be specified, or 0 can be used to indicate that the resources *
* should come from the default user appliction resource library. *
* *
* Example: *
* // In .rc file... *
* MENU MENU_ID *
* BEGIN *
* MENUITEM "Item 1", ITEM_1 *
* SUBMENU "Item 2", ITEM_2 *
* BEGIN *
* MENUITEM "Item 2.1", ITEM_21 *
* MENUITEM "Item 2.2", ITEM_22 *
* END *
* END *
* STRINGTABLE *
* BEGIN *
* MENU_ID "Information about menu choices in general" *
* ITEM_1 "Information about menu item 1" *
* ITEM_2 "Information about submenu 2" *
* ITEM_21 "Information about submenu item 2.1" *
* ITEM_22 "Information about submenu item 2.2" *
* END *
* *
* // Create a frame. *
* IFrameWindow *
* frame( IFrame::menuBar, MENU_ID ); *
* *
* // Attach information area: *
* IInfoArea *
* infoArea( &frame ); *
*******************************************************************************/
public:
/*------------------------- Constructors/Destructor ----------------------------
| You can construct an instance of this class with the following required |
| information: |
| - A pointer to the frame window to which the information area is to be |
| attached. |
| - The ID to be given the information area control. The default is 0. |
| - The specification of the resource library from which the information |
| strings are to be loaded. This can be specified by either of the |
| following: |
| - A module handle of the resource DLL |
| - A module handle of 0 for the current .exe |
| - The name of a .DLL file |
| - The name of a .DLL library. |
| The default is the user default library obtained from |
| IApplication::current().resourceLibrary(). |
| |
| The second and third arguments are optional. Either or both can be |
| specified, in any order. |
------------------------------------------------------------------------------*/
IInfoArea ( IFrameWindow *frame,
unsigned long id = 0 );
IInfoArea ( IFrameWindow *frame,
unsigned long id,
const char *resDLLName );
IInfoArea ( IFrameWindow *frame,
const IModuleHandle &resMod,
unsigned long id = 0 );
IInfoArea ( IFrameWindow *frame,
const char *resDLLName,
unsigned long id = 0 );
virtual
~IInfoArea ( );
/*----------------------------- Resource Library -------------------------------
| These functions query and set the resource library from which the |
| information strings are loaded: |
| resourceLibrary - Returns a reference to the library being used. |
| setResourceLibrary - Sets the resource library to be used. This can be |
| specified as a module handle, a .DLL file, or a |
| library name. |
------------------------------------------------------------------------------*/
virtual IResourceLibrary
&resourceLibrary ( ) const;
virtual IInfoArea
&setResourceLibrary ( const IModuleHandle &resMod ),
&setResourceLibrary ( const char *resDLLName );
/*--------------------------- String Table Offset ------------------------------
| These functions query and set the "string table offset" that is added |
| to the menu identifier to obtain the identifier for the string providing |
| the information about the menu item. The default is zero. |
| stringTableOffset - Returns the offset currently in use. |
| setStringTableOffset - Sets the offset to be used to calculate the |
| information string ID. |
------------------------------------------------------------------------------*/
virtual long
stringTableOffset ( ) const;
virtual IInfoArea
&setStringTableOffset ( long newOffset );
/*----------------------- Special Information Strings --------------------------
| These functions query and set the value of the information strings displayed |
| in special circumstances. Each special string can be specified as either |
| an IString or the identifier for a string from the resource library. |
| inactiveText - Returns the text displayed when the menu is inactive. |
| setInactiveText - Sets the text to be used when the menu is inactive. |
| disabledText - Returns the text displayed when the menu item at the |
| selection cursor is disabled. |
| setDisabledText - Sets the text that is to be displayed whenever a |
| disabled menu item becomes the current menu item. |
| To display this text, the setDisabledText function |
| must be called before the disabled menu item is made |
| the current menu item; otherwise, the normal |
| information area text is displayed. |
| missingText - Returns the text to be displayed when the required |
| information string cannot be obtained from the |
| resource library. |
| setMissingText - Sets the text to be displayed when the information |
| string cannot be found. |
------------------------------------------------------------------------------*/
virtual IString
inactiveText ( ) const,
disabledText ( ) const,
missingText ( ) const;
virtual IInfoArea
&setInactiveText ( unsigned long id ),
&setInactiveText ( const IString &id ),
&setDisabledText ( unsigned long id ),
&setDisabledText ( const IString &id ),
&setMissingText ( unsigned long id ),
&setMissingText ( const IString &id );
/*---------------------------- Window Attachment -------------------------------
| These functions permit attaching and detaching the handler of the |
| information area to/from a frame window (these are called automatically by |
| this class): |
| handleEventsFor - Attaches the handler of the information area to |
| the specified frame window. |
| stopHandlingEventsFor - Detaches the handler of the information area from |
| the specified frame window. |
------------------------------------------------------------------------------*/
virtual IInfoArea
&handleEventsFor ( IFrameWindow* frame ),
&stopHandlingEventsFor ( IFrameWindow* frame );
protected:
/*------------------------------ Implementation --------------------------------
| This utility member function is used to implement this class. Derived |
| classes can override it in order to tailor the behavior. |
| informationFor - Returns the information string for the argument menu ID. |
------------------------------------------------------------------------------*/
virtual IString
informationFor ( unsigned long menuId ) const;
/*-------------------------------- Overrides -----------------------------------
| The following functions are overridden from class IMenuHandler in order |
| to handle the menu events appropriately. |
| menuSelected - Places the corresponding information string into the |
| static text frame extension. |
| menuEnded - Places the "inactive" information string into the |
| information area. |
------------------------------------------------------------------------------*/
virtual Boolean
menuSelected ( IMenuEvent& menuEvent ),
menuEnded ( IMenuEvent& menuEvent );
private:
/*--------------------------------- Private ----------------------------------*/
enum Status
{
noneShowing,
missingShowing,
inactiveShowing,
disabledShowing
};
virtual IHandler
&handleEventsFor ( IWindow* window ),
&stopHandlingEventsFor ( IWindow* window );
void
setString ( IString &, unsigned long ),
addTo ( IFrameWindow * ),
showText ( Status newStatus, const IString &text );
Status
status;
IResourceLibrary
*pResLib;
long
strTblOffset;
IString
inactive,
disabled,
missing;
}; // class IInfoArea
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing. */
/*----------------------------------------------------------------------------*/
#pragma pack()
#endif /* _IINFOA_ */