DESCRIPTION The FlatCheckBox widget is a special class of OLIT widget, called a "Flat Widget". A Flat widget is basically a single widget which manages a set of 'like' components (CheckBox items in this case). The flat widget gives the appearance of many widgets, however they consume only a fraction of memory as the same implementation using an equivalent normal widget hierarchy. The FlatCheckBox widget implements a NonExclusive Choice object. For more detailed and complete information on the Flatcheckbox Widget, see the following sections in the OPEN LOOK Intrinsics Toolkit Widget Set Reference Guide: . FLAT CHECKBOX WIDGET (3W) . FLAT WIDGET LAYOUT (3W) . FLATTENED WIDGETS (3W) EXAMPLE CODE The following code was written to Create the example Flat CheckBox Widget close to the one shown in the Table (All color specific code has been removed for simplification): /**************************************************************************************/ #include #include #include #include #include #include /* Declare resources which we'll need to set for each individual * subobject in the FlatCheckbox. (all other resources will be * inherited from the FlatCheckbox container). */ typedef struct { XtArgVal label; /* label string of subobject */ XtArgVal set; /* state of checkbox subobject */ } FlatCheckboxItem; String attributes[] = { XtNlabel, XtNset }; /* * Initialize resource values for each subobject */ static FlatCheckboxItem subobjects[] ={ {(XtArgVal)"Owner", (XtArgVal)True}, {(XtArgVal)"Group", (XtArgVal)False}, {(XtArgVal)"World", (XtArgVal)False} }; /***************************************************************** * selectedCB: Callback called when one of the sub-items on the * checkbox is checked. *****************************************************************/ void selectedCB(w, clientData, callData) Widget w; XtPointer clientData, callData; { OlFlatCallData *fcd = (OlFlatCallData*)callData; int subitem = fcd->item_index; /* index of item selected */ /* An Item has been checked.... */ printf("Access added for %s\n", subobjects[subitem].label); } /***************************************************************** * unselectedCB: Callback called when one of the sub-items on the * checkbox is unchecked. *****************************************************************/ void unselectedCB(w, clientData, callData) Widget w; XtPointer clientData, callData; { OlFlatCallData *fcd = (OlFlatCallData*)callData; int subitem = fcd->item_index; /* index of item selected */ /* An Item has been Unchecked.... */ printf("Access removed for %s\n", subobjects[subitem].label); } /*****************************************************************/ main(argc, argv) int argc; char **argv; { Widget toplevel, controlarea, caption, flatcheckbox; int i; toplevel = OlInitialize(argv[0], "Test", NULL, 0, &argc, argv); controlarea = XtVaCreateManagedWidget("controls", controlAreaWidgetClass, toplevel, XtNvPad, (XtArgVal)10, XtNhPad, (XtArgVal)10, NULL); caption = XtVaCreateManagedWidget("caption", captionWidgetClass, controlarea, XtNlabel, (XtArgVal)"File Access:", XtNalignment, (XtArgVal)OL_TOP, XtNposition, (XtArgVal)OL_LEFT, XtNspace, (XtArgVal)20, NULL); /* * Create FlatCheckBox widget... */ flatcheckbox = XtVaCreateManagedWidget("flatcheckbox", flatCheckBoxWidgetClass, caption, XtNlayoutType, (XtArgVal)OL_FIXEDCOLS, XtNmeasure, (XtArgVal)1, /* Set pointer to SubObject structure */ XtNitems, (XtArgVal)subobjects, XtNnumItems, (XtArgVal)XtNumber(subobjects), /* Set the attributes being set for subobjects*/ XtNitemFields, (XtArgVal)attributes, XtNnumItemFields,(XtArgVal)XtNumber(attributes), /* Declare routines to be called for * check/unchecking of subobjects. * NOTE: WE DO NOT SET THESE AS NORMAL CALLBACKS * with XtAddCallback(). */ XtNselectProc, (XtArgVal)selectedCB, XtNunselectProc,(XtArgVal)unselectedCB, NULL); XtRealizeWidget(toplevel); XtMainLoop(); } /******************************END EXAMPLE****************************/ RESOURCES ________________________________________________________________________________________________ Resource Name Type Default Brief Description ________________________________________________________________________________________________ XtNaccelerator String NULL String which defines accelerator key XtNacceleratorText String Dynamic string to be displayed as accelerator XtNancestorSensitive Boolean TRUE Will immediate parent receive events? XtNbackground Pixel White background color of widget XtNbackgroundPixmap Pixmap (none) pixmap used for tiling the background XtNborderWidth Dimension 0 width in pixels of object border XtNclientData XtPointer NULL data supplied to callback procedures XtNconsumeEvent XtCallbackList NULL routines called on virtual events XtNdepth Cardinal (parent's) depth (in pixels) of widget XtNfont XFontStruct* OPEN LOOK font font used as Checkbox's label XtNfontColor Pixel Black label font's color XtNforeground Pixel Black foreground color of widget XtNgravity int CenterGravity the gravity of subobjects as group XtNhPad Dimension 4 size in pixels of margin on sides XtNhSpace Dimension 4 space in pixels between columns XtNheight Dimension (calculated) height of widget's window in pixels XtNinputFocusColor Pixel Red color of input focus indicator XtNitemFields String* NULL pointer to resources set for subobject XtNitemGravity int NorthWestGravity gravity of subobjects in row/column XtNitemMaxHeight Dimension OL_IGNORE max allowable height for subobjects XtNitemMaxWidth Dimension OL_IGNORE max allowable width for subobjects XtNitemMinHeight Dimension OL_IGNORE min allowable height for subobjects XtNitemMinWidth Dimension OL_IGNORE min allowable width for subobjects XtNitems XtPointer NULL pointer to subobject structure XtNitemsTouched Boolean False see manpage XtNlabel String (classname) string used for label XtNlabelImage XImage * (classname) pointer to image used for label XtNlabelJustify OlDefine OL_LEFT position of label relative to checkbox XtNlabelTile Boolean FALSE should background be tiled with pixmap? XtNlayoutHeight OlDefine OL_MINIMIZE resize policy for flat widget XtNlayoutType OlDefine OL_FIXEDROWS layout policy for subobjects XtNlayoutWidth OlDefine OL_MINIMIZE resize policy for flat widget XtNmanaged Boolean TRUE is subobject managed? XtNmappedWhenManaged Boolean TRUE will widget be mapped when managed? XtNmeasure int 1 * number of rows/cols or fixed hgt/wth XtNmnemonic Usigned char NULL key used to activate widget XtNnumItemFields Cardinal 0 number of resources set for subobject XtNnumItems Cardinal 0 number of subobjects in Flat widget XtNposition OlDefine OL_LEFT which side of child caption is placed XtNreferenceName String NULL see manpage XtNreferenceWidget Widget NULL see manpage XtNsameHeight OlDefine OL_ALL size policy for subobjects' height XtNsameWidth OlDefine OL_COLUMNS size policy for subobjects in column XtNselectProc XtCallbackProc NULL routine called when subobject selected XtNsensitive Boolean TRUE will widget receive input events? XtNset Boolean TRUE current state of checkbox XtNtraversalOn Boolean TRUE is mouseless turned "on" for widget? XtNunselectProc XtCallbackProc NULL routine called when subobject unselected XtNuserData XtPointer NULL storage for user defined data XtNvPad Dimension 4 size in pixels of top/bottom margins XtNvSpace Dimension 4 space in pixels between rows XtNwidth Dimension (calculated) width of widget's window in pixels XtNx Position 0 x coord of widget's upper left corner XtNy Position 0 y coord of widget's uuper left corner