home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IPUSHBUT.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
10KB
|
201 lines
#ifndef _IPUSHBUT_
#define _IPUSHBUT_
/*******************************************************************************
* FILE NAME: ipushbut.hpp *
* *
* DESCRIPTION: *
* Declaration of the class(es): *
* IPushbutton - This class creates and manages the pushbutton 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 _IBUTTON_
#include <ibutton.hpp>
#endif
// Forward declarations for other classes:
class IRectangle;
class ISize;
class IWindowHandle;
#ifndef _IRECT_
#include <irect.hpp>
#endif
#ifndef _IBITFLAG_
#include <ibitflag.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
class IPushButton : public IButton {
typedef IButton Inherited;
/*******************************************************************************
* The IPushButton class creates and manages the 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 push button was not created from a dialog template, then the *
* application is responsible for processing the Enter key and calling the *
* push button's inherited click function. *
* *
* EXAMPLE: *
* IPushButton pbCancel(ID_CANCEL, this, this, IRectangle(10,10,80,22)); *
* pbCancel.setText("Cancel"); *
*******************************************************************************/
public:
/*------------------- Style -----------------------------------------------
The following functions provide a means to set and query push button styles:
Style - Nested class that provides static members that define the set of
valid push button styles. These styles can be used in
conjunction with the styles defined by the nested classes
IWindow::Style, IControl::Style, and IButton::Style. For
example, you could define an instance of the IPushButton::Style
class and initialize it like:
IPushButton::Style
style = IPushButton::help | IControl::tabStop;
An object of this type is provided when the push button is
created. A customizable default is used if no styles are
specified. Once the object is constructed, IPushButton,
IWindow, IControl, and IButton member functions can be used to
set or query the object's style.
The declaration of the IPushButton::Style nested class is
generated by the INESTEDBITFLAGCLASSDEF3 macro.
The valid push button styles are:
classDefaultStyle - Original default style for this class, which is
IWindow::visible.
help - Causes a help event, instead of a command event, to
be generated when the push button is pressed.
systemCommand - Causes a system command event, instead of a command
event, to be generated when the push button is
pressed.
defaultButton - Making a push button the default allows it to be
selected with the Enter key without having the cursor
on the push button. Visually, a default push button
has a darker and thicker border.
noBorder - The push button will be displayed without a border
around itself.
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 push buttons.
-------------------------------------------------------------------------*/
INESTEDBITFLAGCLASSDEF3(Style, IPushButton, IWindow,
IControl, IButton);
// style class definition
static const Style
classDefaultStyle,
help,
systemCommand,
defaultButton,
noBorder;
static Style
defaultStyle();
static void
setDefaultStyle(Style style);
/*------------------------ Constructors ----------------------------------------
| You can construct instances of this class in the following ways: |
| - From a control ID, parent and owner windows, rectangle, and style. |
| This creates the specified push button control and an object for it. |
| - From the ID of a push button control on a dialog window. This creates |
| the object for the specified push button control. |
| - From the window handle of an existing push button control. This |
| creates the object for the specified push button control. |
------------------------------------------------------------------------------*/
IPushButton(unsigned long id,
IWindow* parent,
IWindow* owner,
const IRectangle& initial= IRectangle(),
const Style& style = defaultStyle() );
IPushButton(unsigned long id,
IWindow* parentDialog);
IPushButton(const IWindowHandle& handle);
virtual ~IPushButton();
/*-------------------------------- Style Functions -----------------------------
| These functions provide a means of getting and setting the default style |
| attributes of instances of this class: |
| isDefault - Returns true if the defaultButton style is set. |
| enableDefault - Adds or removes the defaultButton style. |
| disableDefault - Removes the defaultButton style from the push |
| button. |
| isHelp - Returns true if the help style is set. |
| enableHelp - Adds or removes the help style. |
| disableHelp - Removes the help style from the push button. |
| isSystemCommand - Returns true if the systemCommand style is set. |
| enableSystemCommand - Adds or removes the systemCommand style. |
| disableSystemCommand - Removes the systemCommand style from the push |
| button. |
| isBorder - Returns true if the push button has a border. |
| enableBorder - Adds or removes the push button border. |
| disableBorder - Removes the border from the push button. This also |
| prevents the background of the push button from |
| being drawn with the color that is currently set |
| for background drawing. |
------------------------------------------------------------------------------*/
Boolean
isDefault() const,
isHelp() const,
isSystemCommand() const,
isBorder() const;
IPushButton
&enableDefault(Boolean enable=true),
&disableDefault(),
&enableHelp(Boolean enable=true),
&disableHelp(),
&enableSystemCommand(Boolean enable=true),
&disableSystemCommand(),
&enableBorder(Boolean enable=true),
&disableBorder();
protected:
/*----------------------------- Layout Size ------------------------------------
| calcMinimumSize - Returns the recommended minimum size of this push button |
| control. The size is based on the text string length and |
| the current font. |
------------------------------------------------------------------------------*/
virtual ISize
calcMinimumSize() const;
private:
/*--------------------------------- PRIVATE ----------------------------------*/
IPushButton(const IPushButton&);
IPushButton& operator=(const IPushButton&);
static Style
currentDefaultStyle;
}; // class IPushButton
INESTEDBITFLAGCLASSFUNCS(Style, IPushButton);
// global style functions
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing. */
/*----------------------------------------------------------------------------*/
#pragma pack()
#endif // _IPUSHBUT_