home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IRADIOBT.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
10KB
|
189 lines
#ifndef _IRADIOBT_
#define _IRADIOBT_
/*******************************************************************************
* FILE NAME: iradiobt.hpp *
* *
* DESCRIPTION: *
* Declaration of the class(es): *
* IRadioButton - This class creates and manages the radio 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 _ISETBUT_
#include <isetbut.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 IRadioButton : public ISettingButton {
typedef ISettingButton Inherited;
/*******************************************************************************
* The IRadioButton class creates and manages the radio button control window. *
* *
* EXAMPLE: *
* IRadioButton rbChoice(ID_CHOICE, this, this, IRectangle(10,10,80,22)); *
* rbChoice.setText("Cold and Bitter"); *
*******************************************************************************/
public:
/*------------------ Style ------------------------------------------------
The following functions provide a means to set and query radio button
styles:
Style - Nested class that provides static members that define the set of
valid radio 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 IRadioButton::Style
class and initialize it like:
IRadioButton::Style
style = IRadioButton::autoSelect | IControl::tabStop;
An object of this type is provided when the radio button is
created. A customizable default is used if no styles are
specified. Once the object is constructed, IRadioButton,
IWindow, IControl, and IButton member functions can be used to
set or query the object's style.
The declaration of the IRadioButton::Style nested class is
generated by the INESTEDBITFLAGCLASSDEF3 macro.
The valid radio button styles are:
classDefaultStyle - Original default style for this class, which is
autoSelect | IWindow::visible.
autoSelect - A selection technique in which moving the keyboard
cursor automatically changes the current selection.
noCursorSelect - Causes the radio button not to select itself when
given the focus as the result of an arrow key or tab
key.
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 radio
buttons.
-------------------------------------------------------------------------*/
INESTEDBITFLAGCLASSDEF3(Style, IRadioButton,
IWindow, IControl, IButton);
// style class definition
static const Style
classDefaultStyle,
autoSelect,
noCursorSelect;
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 radio button control and an object for it. |
| - From the ID of a radio button control on a dialog window. This |
| creates the object for the specified radio button control. |
| - From the window handle of an existing radio button control. This |
| creates the object for the specified radio button control. |
------------------------------------------------------------------------------*/
IRadioButton(unsigned long id,
IWindow* parent,
IWindow* owner,
const IRectangle& initial= IRectangle(),
const Style& style = defaultStyle() );
IRadioButton(unsigned long id,
IWindow* parentDialog);
IRadioButton(const IWindowHandle& handle);
virtual ~IRadioButton();
/*-------------------------------- Overloaded Auto-select ----------------------
| These operations are overloaded since the actual style setting is different: |
| enableAutoSelect - Adds or removes the autoSelect style. |
| disableAutoSelect - Removes the autoSelect style from the radio button |
| control. |
| isAutoSelect - Returns true if the radio button control has the |
| autoSelect style set; otherwise, false is returned. |
------------------------------------------------------------------------------*/
virtual IRadioButton
&enableAutoSelect(Boolean enable=true),
&disableAutoSelect();
virtual Boolean
isAutoSelect() const;
/*----------------------------- Cursor Select Style ----------------------------
| These operations test, enable, and disable the radio button cursor-select |
| style: |
| enableCursorSelect - Makes the radio button cursor-selectable. |
| disableCursorSelect - Adds the noCursorSelect radio button style. |
| isCursorSelect - Returns true if the radio button is cursor- |
| selectable. |
------------------------------------------------------------------------------*/
IRadioButton
&enableCursorSelect(Boolean enable=true),
&disableCursorSelect();
Boolean
isCursorSelect() const;
/*----------------------------- Select Button Index ----------------------------
| selectedIndex - Returns the 0-based index of the selected radio button in |
| a group. If no radio button is selected, a value of -1 |
| is returned. |
| |
| WARNING: If selectedIndex is called without a radio |
| button being selected, some versions of OS/2 may |
| experience system instability. |
------------------------------------------------------------------------------*/
unsigned long
selectedIndex() const;
protected:
/*----------------------------- Layout Size ------------------------------------
| calcMinimumSize - Returns the recommended minimum size of this radio button |
| control. The size is based on the text string length and |
| the current font. |
------------------------------------------------------------------------------*/
virtual ISize
calcMinimumSize() const;
private:
/*--------------------------------- PRIVATE ----------------------------------*/
IRadioButton(const IRadioButton&);
IRadioButton& operator=(const IRadioButton&);
static Style
currentDefaultStyle;
}; // class IRadioButton
INESTEDBITFLAGCLASSFUNCS(Style, IRadioButton);
// global style functions
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing. */
/*----------------------------------------------------------------------------*/
#pragma pack()
#endif // _IRADIOBT_