home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IGRAPHBT.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
14KB
|
272 lines
#ifndef _IGRAPHBT_
#define _IGRAPHBT_
/*******************************************************************************
* FILE NAME: igraphbt.hpp *
* *
* DESCRIPTION: *
* Declaration of the class(es): *
* IGraphicPushButton - This class creates and manages the graphic push button*
* control 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 _IPUSHBUT_
#include <ipushbut.hpp>
#endif
#ifndef _IRECT_
#include <irect.hpp>
#endif
#ifndef _IBITFLAG_
#include <ibitflag.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
// Forward declarations for other classes:
class IRectangle;
class ISize;
class IWindowHandle;
class IIconControl;
class IGraphicPushButton : public IPushButton {
typedef IPushButton Inherited;
/*******************************************************************************
* The IGraphicPushButton class creates and manages the graphic push button *
* control window. The standard push button generates an ICommandEvent. *
* However, the application can change the window style value to generate a *
* help event or system command event. To change the push button event *
* (message) processing, call the IPushButton::enableHelp and *
* IPushButton::enableSystemCommand functions. These functions add or remove *
* the IPushButton::help and IPushButton::systemCommand styles, respectively. *
* *
* If the graphic push button is not created from a dialog template, the *
* application is responsible for processing the Enter key and calling the *
* push button's inherited IButton::click function. *
* *
* EXAMPLE: *
* IGraphicPushButton pbCancel(ID_CANCEL, this, this, ID_SOMEBMP, *
* IRectangle(10,10,80,22)); *
*******************************************************************************/
public:
/*------------------- Style -----------------------------------------------
The following functions provide a means to set and query graphic push button styles:
Style - Nested class that provides static members that define the set of
valid graphic button styles. These styles can be used in
conjunction with the styles defined by the nested classes
IWindow::Style, IControl::Style, IButton::Style, and
IPushButton::Style. For example, you could define an instance
of the igraphbtton::Style class and initialize it like:
IGraphicPushButton::Style
style = IGraphicPushButton::sizeToGraphic | IPushButton::help |
IControl::tabStop;
An object of this type is provided when the graphic push button
is created. A customizable default is used if no styles are
specified. Once the object is constructed, igraphbtton,
IWindow, IControl, IButton, and IPushButton member functions
can be used to set or query the object's style.
The declaration of the IGraphicPushButton::Style nested class is
generated by the INESTEDBITFLAGCLASSDEF4 macro.
The valid push button styles are:
classDefaultStyle - Original default style for this class, which is
IWindow::visible.
sizeToGraphic - This style causes the graphic inside of the push
button to be displayed using the graphic's actual
size. If the graphic is larger than the push button,
it is clipped. If the graphic is smaller than the
push button, it is centered in the push button.
If you do not use this style, the graphic is stretched
to fill the push button up to its border.
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 graphic push
buttons.
-------------------------------------------------------------------------*/
INESTEDBITFLAGCLASSDEF4(Style, IGraphicPushButton, IWindow,
IControl, IButton, IPushButton);
// style class definition
static const Style
classDefaultStyle,
sizeToGraphic;
static Style
defaultStyle();
static void
setDefaultStyle(Style style);
/*------------------------ Constructors ----------------------------------------
| You can construct instances of this class in the following ways: |
| - From a non-system icon or bit map. This creates a graphic push button |
| with the specified window ID, parent and owner windows, screen position |
| and size, resource library with its specified icon or bit map ID, and |
| window style. Use this constructor if you have not already loaded the |
| bit map or icon and you want to load it from the .dll or .exe of your |
| choice. |
| - From a non-system icon or bit map. This creates a graphic push button |
| with the specified window ID, parent and owner windows, screen position |
| and size, default resource library with its specified icon or bit map |
| ID, and window style. Use this constructor if you have not already |
| loaded the bit map or icon, and you want to load it from the default |
| resource library, which would be from the .exe. |
| - From a non-system bit map. This creates a graphic push button with the |
| specified window ID, parent and owner windows, screen position and |
| size, bit map, and window style. If you already have a bit map handle, |
| use this contructor to put it on the graphic push button. |
| - From a non-system icon. This creates a graphic push button with the |
| specified window ID, parent and owner windows, screen position and |
| size, icon, and window style. If you already have an icon handle, |
| use this constructor to put it on a graphic push button. |
| - From a dialog template. This creates a graphic push button object for |
| the specified push button that has the icon or bit map style from the |
| dialog control. |
| - From an existing icon control. This creates a graphic push button |
| object for the specified bit map or icon push button window handle. |
------------------------------------------------------------------------------*/
IGraphicPushButton(unsigned long id,
IWindow* parent,
IWindow* owner,
const IResourceId& bitmapOrIconId,
const IRectangle& initial= IRectangle(),
const Style& style = defaultStyle() );
IGraphicPushButton(unsigned long id,
IWindow* parent,
IWindow* owner,
unsigned long bitmapOrIconId,
const IRectangle& initial= IRectangle(),
const Style& style = defaultStyle() );
IGraphicPushButton(unsigned long id,
IWindow* parent,
IWindow* owner,
const IBitmapHandle& bitmap = IBitmapHandle(),
const IRectangle& initial= IRectangle(),
const Style& style = defaultStyle() );
IGraphicPushButton(unsigned long id,
IWindow* parent,
IWindow* owner,
const IPointerHandle& icon,
const IRectangle& initial= IRectangle(),
const Style& style = defaultStyle() );
IGraphicPushButton(unsigned long id,
IWindow* parentDialog);
IGraphicPushButton(const IWindowHandle& handle);
virtual ~IGraphicPushButton();
/*------------------------------- Enumerations ---------------------------------
| The following enumerations are defined: |
| GraphicType - Used to query the current type of graphic set into the |
| graphic push button: |
| bitmapType - A bit map has been set into the graphic push |
| button. This is the default value since an |
| IBitmapHandle is the default graphic if no |
| handle or resource ID was passed in. |
| iconType - An icon has been set into the graphic push |
| button. |
------------------------------------------------------------------------------*/
enum GraphicType {
bitmapType,
iconType
};
/*-------------------------------- Query/Set Handle ----------------------------
| setGraphic - Changes the stored graphic to the passed in value. |
| See the definitions of the constructors for |
| information about the passed in values. |
| bitmap - Returns the handle of the currently set bit map. If |
| no bit map has been set into the graphic push button, |
| this returns IBitmapHandle(). |
| icon - Returns the handle of the currently set icon. If no |
| icon has been set into the graphic push button, this |
| returns IIconHandle(). |
| currentGraphicType - Returns the enumerator for the current type of |
| graphic set into the graphic push button. |
| graphicWindow - Returns the IIconControl that is used for drawing the |
| graphic. |
------------------------------------------------------------------------------*/
IGraphicPushButton
&setGraphic( unsigned long bitmapOrIconId ),
&setGraphic( const IResourceId& bitmapOrIconId ),
&setGraphic( const IBitmapHandle& handle ),
&setGraphic( const IPointerHandle& handle);
IPointerHandle
icon ( ) const;
IBitmapHandle
bitmap ( ) const;
GraphicType
currentGraphicType ( ) const;
IIconControl&
graphicWindow() const;
/*-------------------------------- Style Functions -----------------------------
| enableSizeToGraphic - Adds or removes the sizeToGraphic style. |
| disableSizeToGraphic - Removes the sizeToGraphic style. |
| isSizeToGraphic - Returns true if the sizeToGraphic style is set. |
------------------------------------------------------------------------------*/
IGraphicPushButton
&enableSizeToGraphic( Boolean enable = true),
&disableSizeToGraphic();
Boolean
isSizeToGraphic() const;
protected:
/*----------------------------- Layout Size ------------------------------------
| calcMinimumSize - The size is based on the actual size of the stored graphic.|
------------------------------------------------------------------------------*/
virtual ISize
calcMinimumSize() const;
private:
/*--------------------------------- PRIVATE ----------------------------------*/
IGraphicPushButton(const IGraphicPushButton&);
IGraphicPushButton& operator=(const IGraphicPushButton&);
IGraphicPushButton
&initialize(const Style& style,
const IRectangle& initial),
&setControlData(IHandle handle);
static Style
currentDefaultStyle;
IIconControl*
aIcon;
Boolean
bSizeTo,
returnBack;
GraphicType
contains;
}; // class IGraphicPushButton
INESTEDBITFLAGCLASSFUNCS(Style, IGraphicPushButton);
// global style functions
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing. */
/*----------------------------------------------------------------------------*/
#pragma pack()
#endif // _IGRAPHBT_