| Methods Index |
CSubviewSubclasses: None
CRadioGroup is a class that groups radio buttons. By definition, radio buttons must be grouped together. Unlike check boxes, which allow the user to select multiple options by checking more than one box at a time, radio buttons within a group can be selected only one at a time. Selecting one radio button means to deselect another.
If you call
FindResourceView in a CWindow and pass in the resource ID of the first radio button, you will get a handle to the CRadioGroup, not the first radio button in the group. Then, to get a handle to the first radio button in the group, you can call CRadioGroup::FindResourceView method, using the resource ID of the first radio button.
Friends
friend
class
CResourceWindow;
Private Data Members
long
itsSelectedId;
The ID of selected button
int
itsBorderSpace;
Spacing between buttons and grouper
BOOLEAN
itHasBorder;
Whether to draw a border
Public Methods
CRadioGroup(CSubview *theEnclosure,
const CPoint& theTopLeft,
BOOLEAN hasBorder = FALSE);
theEnclosure is a pointer to the subview that will contain the radio group. theTopLeft is a coordinate location, local to the enclosure, that is used to place the group. hasBorder indicates whether the group has a visible border. If hasBorder is set to TRUE, the border and the background area of the CRadioGroup are drawn; if it is set to FALSE, neither are drawn.
CRadioGroup(CSubview *theEnclosure, long theContainerId,
long theId);
theEnclosure is a pointer to the subview that will contain the radio group. theContainerId is the containing window ID, and theID specifies the group of radio buttons.
CRadioGroup(const CRadioGroup& theGroup);
CRadioGroup& operator= (const CRadioGroup& theGroup);
virtual ~CRadioGroup(void);
BOOLEAN IRadioGroup(BOOLEAN hasBorder = FALSE,
BOOLEAN isVisible = TRUE,
GLUETYPE theGlue = NULLSTICKY);
virtual long AddButton(const CPoint &aPoint,
const CStringRW& theButtonTitle = NULLString,
long theCommand = NULLcmd,
long theAttributes = 0L,
GLUETYPE theGlue = NULLSTICKY);
AddButton takes a coordinate where the button will be located (&aPoint); a title, which is the string of text that appears beside the button; the number of the command that is generated when the button is selected; and a glue type. theAttributes takes a value from a set of the XVT Portability Toolkit-provided attributes that you can give to native views. You can OR together the appropriate control flag constants into an attribute value. For a listing of the possible values, see under "Constructor and Operator Methods".virtual long AddButtons(long theFirstResourceId,
int theNumberOfButtons,
int theFirstCommand,
long theAttributes = 0L,
int theSelectedButton = 0,
UNITS theSeparation = 0,
DIRECTION theDirection = VERTICAL);
theFirstResourceId is the ID number of the string resource associated with the first button in the group; ID numbers for the strings associated with other buttons created in the group are assigned successively, based on this number. theNumberOfButtons specifies the total number of buttons you want to add to the group. If the number of buttons is five, the resources are traversed from the first resource all the way through four more.
theFirstCommand is the number of the command that is generated when the first button is selected. Each time a new button in the group is created, this number is incremented by one. theAttributes takes a value from a set of the XVT Portability Toolkit-provided attributes that you can give to native views. You can OR together the appropriate control flag constants into an attribute value. For a listing of the possible values, see under "Constructor and Operator Methods".
theSelectedButton is a number ranging from one all the way through the total number of buttons inserted into the group. It is the number of the button that you want to be selected upon creation. theSeparation and theDirection both pertain to the actual placement of the buttons. The buttons can be placed either vertically or horizontally (direction), and you specify the number of pixels that separate each button from the next.AddButtons returns the ID number of the button corresponding to the first resource ID. The IDs of the remaining buttons created.
Step 1: Define radio button titles as
string resources in the URL file:
STRING 212 "Hello"Step 2: Create a radio group and add buttons as follows:
STRING 211 "Bonjour"
STRING 210 "Hola"
CSubview* enc;
CPoint point;
...
CRadioGroup *group = new CRadioGroup(enc, point);
...
group->AddButtons(210, // STRING ID of first button
3, // number of buttons
10, // command for first button
NULL, // XVT attributes
2, // the selected button
5, // separation between buttons
HORIZONTAL); // layout
virtual void RemoveButton(long theButtonId);
virtual long FindResButtonId(long theContainerId, long theId);
virtual void SetSelectedButton(long id);
virtual long GetSelectedButton(void) const;
virtual void Draw(const CRect& theClippingRegion);
theClippingRegion is the portion of the group that needs to be drawn, and it is in global, window-relative coordinates.
virtual void SetBorderSpace(int thePixelSpace);
thePixelSpace) between the grouper and the buttons it contains.
virtual int GetBorderSpace(void) const;
virtual void AddResourceButtonInternal(
long theContainerId, long theId);
long AddButtonInternal(const CPoint &aPoint,
const CStringRW& theButtonTitle = NULLString,
long theCommand = NULLcmd,
long theAttributes = 0L,
GLUETYPE theGlue = NULLSTICKY);
void CopyButtons(const CRadioGroup &theRadioGroup);
theRadioGroup.