home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
ISUBMENU.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
14KB
|
262 lines
#ifndef _ISUBMENU_
#define _ISUBMENU_
/******************************************************************************
* FILE NAME: isubmenu.hpp *
* *
* DESCRIPTION: *
* Declaration of the class: *
* ISubmenu - This class is used to create an object to represent *
* a submenu from a window handle. *
* *
* COPYRIGHT: *
* Licensed Materials - Property of IBM *
* (c) Copyright IBM Corporation 1992, 1993 *
* US Government Users Restricted Rights - Use duplication *
* or disclosure restricted by GSA ADP Schedule Contract *
* with IBM Corp. *
*******************************************************************************/
#ifndef _IMENU_
#include <imenu.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
/*----------------------------------------------------------------------------*/
/* Turn off warning for compiler generated copy/assignment */
/*----------------------------------------------------------------------------*/
#pragma info(nocpy)
class IMenuItem;
class ISubmenu : public IMenu {
typedef IMenu
Inherited;
/*******************************************************************************
* The ISubmenu class is used to create an object to represent a submenu from *
* a menu handle. This class overrides IMenu functions to provide undoable *
* menu item operations. The menu item operations are intended to act on a *
* submenu. Any changes will be undone when the menu terminates. *
*******************************************************************************/
public:
/*----------------------- Constructor/Destructor -------------------------------
| The only way to construct instances of this class is with a window handle |
| of the submenu window. |
------------------------------------------------------------------------------*/
ISubmenu(const IWindowHandle& submenuHandle);
virtual
~ISubmenu();
/*-------------------------------- Accessors -----------------------------------
| This function provides a means of getting the window handle of instances of |
| this class: |
| handle - Returns the submenu window handle. |
------------------------------------------------------------------------------*/
virtual IWindowHandle
handle ( ) const;
/*--------------------------- Add Menu Item ------------------------------------
| The following functions provide a means to add menu items to the instances |
| of this submenu class. |
| addItem - Adds a menu item represented by an instance of IMenuItem |
| as the last item in a menu or submenu. |
| addText - Adds a text menu item as the last item in a menu or |
| submenu. |
| addBitmap - Adds a bit-map menu item as the last item in a menu or |
| submenu. |
| addSeparator - Adds a separator menu item as the last item in a menu or |
| submenu. |
------------------------------------------------------------------------------*/
ISubmenu
&addItem ( IMenuItem &menuItem ),
&addText ( unsigned long newItemId,
const char* itemText ),
&addText ( unsigned long newItemId,
const IResourceId &newItemTextResId ),
&addBitmap ( unsigned long newItemId,
const IBitmapHandle &itemBitmap ),
&addBitmap ( unsigned long newItemId,
const IResourceId &newItemBitmapResId ),
&addBitmap ( unsigned long newItemId,
unsigned long newItemBitmapResId );
virtual ISubmenu
&addSeparator ( unsigned long newItemId );
/*------------------------Replace Menu Item -----------------------------------
| The following functions provide a means to replace menu items of the |
| instances of this submenu class. |
| setItem - Replaces a specified menu item's style and representation. |
| setText - Replaces a specified menu item's text. |
| setBitmap - Replaces a specified menu item bit map. |
------------------------------------------------------------------------------*/
virtual ISubmenu
&setItem ( const IMenuItem &menuItem ),
&setText ( unsigned long menuItemId,
const char* newText ),
&setText ( unsigned long menuItemId,
const IResourceId &newTextResId ),
&setBitmap ( unsigned long menuItemId,
const IBitmapHandle &bitmapHandle ),
&setBitmap ( unsigned long menuItemId,
const IResourceId &newBitmapResId ),
&setBitmap ( unsigned long menuItemId,
unsigned long newBitmapResId );
/*-----------------------Delete/Remove Menu Item/Submenu-----------------------
| The following functions provide a means to delete menu items and remove a |
| submenu of the instances of this submenu class. |
| deleteItem - Removes the specified item from a menu. |
| removeSubmenu - Removes a menu item submenu indicator and destroys the |
| submenu. This member function is typically used to |
| remove a cascading menu. |
------------------------------------------------------------------------------*/
virtual ISubmenu
&deleteItem ( unsigned long itemId ),
&removeSubmenu ( unsigned long itemWithSubmenuId );
/*---------------------Change Menu-item State, Add and Delete-------------------
| The ISubmenu class overrides each of the following IMenu member functions. |
| In each of its overridden versions of these functions, ISubmenu actually |
| calls each of the IMenu versions of the functions to cause the menu to |
| change. Then, it stores information about how the menu was changed so that |
| it can be undone. |
| checkItem - Places a check mark in front of the menu item. |
| uncheckItem - Removes the check mark from the menu item. |
| enableItem - Makes the menu item selectable. |
| disableItem - Makes the menu item unselectable. |
------------------------------------------------------------------------------*/
virtual ISubmenu
&checkItem ( unsigned long itemId,
Boolean checked = true ),
&uncheckItem ( unsigned long itemId ),
&enableItem ( unsigned long itemId,
Boolean enabled = true ),
&disableItem ( unsigned long itemId );
/*--------------------- Undo Changes -------------------------------------------
| This function restores the submenu. |
| undo - Reverses all the changes made to the menu using the ISubmenu member |
| functions. You should not need to call this function since it is |
| called automatically by the IMenuHandler. |
------------------------------------------------------------------------------*/
ISubmenu
&undo();
class Cursor : public IBase {
/*******************************************************************************
* The ISubmenu::Cursor class creates and manages the cursor for menu items. *
*******************************************************************************/
public :
/*------------------ Constructor/Destructor ---------------------------------
| The only way to construct an instance of this class is with an instance |
| of an ISubmenu. |
---------------------------------------------------------------------------*/
Cursor(const ISubmenu& menu);
/*------------------------ Cursor Movement ------------------------
| The following functions provide a means to move the cursor |
| position: |
| setToFirst - Points to the first menu item. |
| setToNext - Points to the next menu item. If there is |
| none, the cursor is invalidated. |
| setToPrevious - Points to the previous menu item. If there |
| is none, the cursor is invalidated. |
| setToLast - Points to the last menu item. |
-----------------------------------------------------------------*/
Boolean
setToFirst ( ),
setToNext ( ),
setToPrevious ( ),
setToLast ( );
/*--------------- Cursor Validation ------------------------------+
| The following functions provide a means to validate the cursor: |
| isValid - Queries whether this cursor points to a valid |
| menu item. |
| invalidate - Flags this cursor as invalid. |
+----------------------------------------------------------------*/
Boolean
isValid ( ) const;
void
invalidate ( );
private : /*------------------- PRIVATE ------------------------*/
friend class ISubmenu;
long
lCurrent;
ISubmenu*
pSubmenu;
};
/*-------------------- Menu Item Operations with Cursor ------------------------
| The following functions provide a means to manage the menu item of |
| instances of this class. |
| elementAt - Returns the menu item at the cursor position. |
| deleteAt - Deletes the menu item at the cursor position and sets |
| the cursor to the menu item that precedes the deleted |
| menu item. |
| removeSubmenuAt - Removes the menu item at the cursor position submenu |
| indicator and destroys the sub-menu. This member |
| function is typically used to remove cascading menus. |
| addAt - Adds the menu item at the cursor by pushing everything |
| after cursor. |
| addNextAt - Adds the menu item as the next item in the submenu and |
| sets the cursor there. |
| cursor - Returns an instance of Cursor and sets the cursor to |
| point to the specific menu item. |
------------------------------------------------------------------------------*/
IMenuItem
elementAt ( const Cursor& cursor ) const;
ISubmenu
&deleteAt ( Cursor& cursor ),
&removeSubmenuAt ( Cursor& cursor ),
&addAt ( IMenuItem& menuItem,
Cursor& cursor ),
&addNextAt ( IMenuItem& menuItem,
Cursor& cursor );
Cursor
cursor ( unsigned long itemId) const;
/*----------------------- Private -----------------------------------*/
private:
void
setUndoAddItem(unsigned long itemId),
setUndoChangeItem(const IMenuItem& origItem);
unsigned long
menuItemId ( const Cursor& cursor ) const;
IWindowHandle
hwndHandle;
void*
pItemList;
/*------------------- Hidden Functions. -----------------------------------
| The following inherited functions are hidden in this class. |
|-------------------------------------------------------------------------*/
ISubmenu(const IMenu&);
ISubmenu &operator=(const IMenu&);
};
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing and warning messages. */
/*----------------------------------------------------------------------------*/
#pragma pack()
#pragma info(restore)
/*--------------------------------- Inlines ----------------------------------*/
#ifndef I_NO_INLINES
#include <isubmenu.inl>
#endif
#endif