Home |
Class PegRadioButton HMI (Human-Machine Interface) Classes |
Class PegRadioButtonPegRadioButton provides a mutually exclusive selection indicator. When a PegRadioButton is selected by the user, it finds all sibling radio buttons and de-selects them. In order to allow multiple radio-buttons to be selected on a single window or dialog, you must group the buttons into separate containers. PegGroup is commonly used for this purpose, although you can also use a transparent PegThing for this purpose just as well. Radio button objects that have the same parent are mutually exclusive, so by grouping the radio buttons onto different parent objects you can allow many different radio buttons to be selected at the same time. class PegRadioButton : public PegButton, public PegTextThing { public: PegRadioButton(PegRect &, const PEGCHAR * Text, PEGUINT wId = 0, PEGUINT wStyle = AF_ENABLED); PegRadioButton(int iLeft, int itop, const PEGCHAR * Text, PEGUINT wId = 0, PEGUINT wStyle = AF_ENABLED); virtual void Draw(void); virtual PEGINT Message(const PegMessage &Mesg); virtual void SetSelected(BOOL bSelected = TRUE); virtual BOOL IsSelected(void); }; Demo programs Table, PegDemo, and Notebook use this class. Style FlagsSignalsPegRadioButton sends PSF_DOT_ON and PSF_DOT_OFF signals. ConstructorsThe first constructor creates a PegRadioButton with a fully defined position and size. The second constructor creates a PegRadioButton that self determines its height and width based on the default font and textwidth of the specified string. Method DrawPegRadioButton overrides the Draw() function to draw the radio button indicator bitmap and radio button text. Method IsSelectedReturns TRUE if the radio button is selected, else FALSE. Method MessagePegRadioButton catches the PM_LBUTTONDOWN message to toggle the radio button selection state. Method SetSelectedSelects or de-selects a radio button at any time. ExamplesThe following are each different styles of PegRadioButton: The following function creates a PegGroup and adds several radio button children 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); }
|