KwikPeg Manuals
Home
PegRadioButton
Examples
Examples
Index
Index


Members
Styles
Signals
Overview Derived from class PegThing
and PegTextThing

The PegRadioButton class provides a mutually exclusive selection indicator. When a PegRadioButton is selected, all sibling radio buttons are marked as NOT selected.

In order to permit multiple sets of radio buttons to coexist within a single window or dialog, you must group each set of buttons into a separate container object. The PegGroup class is commonly used for this purpose. However, you can also use a transparent PegThing object as a container. Radio button objects that have the same parent are mutually exclusive. Without giving the sets of radio button different parents, you would be unable to have multiple radio buttons (from different sets) selected at the same time.



 See Also

PegBitmapButton

PegTextButton

PegGroup

PegCheckBox



 Styles

The PegRadioButton class supports the following style flags:

FF_NONE No frame.
FF_THIN Thin frame.
FF_THICK Thick 3D frame.
FF_RAISED Raised 3D frame.
FF_RECESSED Recessed 3D frame.
AF_ENABLED  This style flag is used to indicate that the object can be selected.
BF_SELECTED  This style flag is actually a state flag which indicates if a button object is currently selected. For the object to be selectable, the object's AF_ENABLED style flag must be set.


 Signals

The PegRadioButton class generates the following signals:

PSF_DOT_ON Sent by radio button and menu button when selected.
PSF_DOT_OFF Sent by radio button and menu button when unselected.

Top of page


 Members

Constructors:

PegRadioButton(PegRect &Rect,
  const PEGCHAR *text,
  WORD wId = 0, WORD wStyle = AF_ENABLED)

This constructor creates a PegRadioButton object at a specific location within a rectangle specified by parameter Rect.

PegRadioButton(SIGNED iLeft, SIGNED itop,
  const PEGCHAR *text,
  WORD wId = 0, WORD wStyle = AF_ENABLED)

This constructor creates a PegRadioButton with its top left corner located at (iLeft,iTop). The text will be rendered in the default radio button font. The object automatically adjusts its width and height to accommodate the font used to display the text string.

 

Public Functions:

virtual void Draw(void)

The PegRadioButton class overrides the Draw() function to draw the radio button indicator bitmap and radio button text.

virtual BOOL IsSelected(void)

This function returns TRUE if the radio button is selected, else FALSE.

virtual SIGNED Message(const PegMessage &Mesg)

The PegRadioButton class catches the PM_LBUTTONDOWN message to toggle the radio button selection state.

virtual void SetSelected(BOOL bSelected = TRUE)

This function sets the selection state of a radio button to match parameter bSelected. If bSelected is TRUE, the radio button is marked as selected. Otherwise, the radio button is marked as not selected.


Top of page


 Examples

The following examples illustrate several different styles of PegRadioButton objects:



The following code fragment creates a PegGroup object and adds several radio buttons to the group. The radio button Button1 will initially be selected.

void MyWindow::AddSelectGroup(void)
{
    PegRect ChildRect;
    ChildRect.Set(20, 20, 120, 100);

    PegGroup *pGroup =
        new PegGroup(ChildRect, "Select One");

    pGroup->Add(new PegRadioButton(30, 30,
        "Button1", IDR_BUTTON1, AF_ENABLED|BF_SELECTED));
    pGroup->Add(new PegRadioButton(30, 50,
        "Button2", IDR_BUTTON2));
    pGroup->Add(new PegRadioButton(30, 70,
        "Button3", IDR_BUTTON3));

    Add(pGroup);
}



Top of page
KwikPeg Manuals
Home
Index
Index

 
Copyright © 2000-2003