Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Inserting radio buttons and labels into an XY container

After creating the radio buttons and their labels, c_simple_widget_app_CreateRadioButtons() inserts these widgets into an XY container, as described in the following procedure:

  1. Get the preferred extent for the first radio button, then set the extent for both radio buttons, as follows:
    (void) IWidget_GetPreferredExtent(pMe->piwRadio1, &we);
    
    IWidget_SetExtent(pMe->piwRadio1, &we);
    
    IWidget_SetExtent(pMe->piwRadio2, &we);
  2. Set the position of each radio button and insert it into the XY container. The position is specified as x and y coordinates in a WidgetPos structure. The application must also set the bVisible member of the structure to TRUE for the widget to be visible on the display. For example:
    // set position for radio button 1 in the XY container
    dwpos.x = 20;
    dwpos.y = 80;
    dwpos.bVisible = TRUE;
        
    // insert radio button 1 in the XY container
    if (AEE_SUCCESS != IXYContainer_Insert(pMe->picXYCon, pMe->piwRadio1,
                WIDGET_ZNORMAL, &dwpos)) {
        return FALSE;
    }
        
    // set position for radio button 2 in the XY container
    dwpos.x = 20;
    dwpos.y = 110;
    dwpos.bVisible = TRUE;
    
    // insert radio button 2 in the XY container
    if (AEE_SUCCESS != IXYContainer_Insert(pMe->picXYCon, pMe->piwRadio2,
                WIDGET_ZNORMAL, &dwpos)) {
        return FALSE;
    }
  3. Set the position of the static widgets (the labels for the radio buttons) and insert them into the XY container, as follows:
    // set position for label 1 in the XY container
    dwpos.x = 40;
    dwpos.y = 80;
    dwpos.bVisible = TRUE;
        
    // insert label 1 in the XY container
    if (AEE_SUCCESS != IXYContainer_Insert(pMe->picXYCon, pMe->piwRText1,
                WIDGET_ZNORMAL, &dwpos)) {
        return FALSE;
    }
    
    // set position for label 2 in the XY container
    dwpos.x = 40;
    dwpos.y = 110;
    dwpos.bVisible = TRUE;
    
    // insert label 2 in the XY container
    if (AEE_SUCCESS != IXYContainer_Insert(pMe->picXYCon, pMe->piwRText2,
                WIDGET_ZNORMAL, &dwpos)) {
        return FALSE;
    }
  4. Before exiting the function, release the model pointer. The radio buttons have references to the group model.
    IModel_Release(piRadioGroupModel);
    

When the application is run, the radio buttons and labels look like this: