A Chart object does not normally propagate resource changes to its sub-objects. To make a Chart object and all of its components non selectable, set resource XmNpropagate to True each time you want the change to be applied to all the chart components, as shown in the code sample below:
XtVaSetValues ((Widget) chart, XmNsensitive, False,
XmNpropagate, True, NULL);
The EditObject actions that control object selection are ObjectSelect, InitAreaSelection, ExtendAreaSelection and EndAreaSelection. These actions are connected as follows in the default EditObject translation table:
| Action | Default Selection Translation |
|---|---|
| Ctrl<Btn1Down> | InitAreaSelection(extend) ObjectSelect(single) |
| None<Btn1Down> | InitAreaSelection(single) ObjectSelect(single) |
| <PtrMoved> | ObjectSelect() |
| <Btn1Up> | ObjectEditEnd() |
This table shows that Button1 is used to select an object. If you press the Ctrl key while doing the selection, the object is added to the list of selected objects. Otherwise, the current selection list is erased before the object is selected. Also, if you drag Button1 while pressing it, all the objects contained in the rectangular area outlined while the cursor is moved will be selected when the button is released.
EditObject callbacks XmNobjectSelectionCallback and XmNobjectDeselectionCallback can be used by the application to determine when an object has been selected or deselected. For objects in a group, the Group object ID is returned as the selected object. Since a Chart is a group of objects, the ChartObject ID will be returned when a chart sub-component is selected. Use function XintChartGetSelectedComponent to find out the type and object ID of the sub-component that was selected. The following code segment shows how to write a selection callback that prints the name of the selected object.
static void ObjectSelectionCallback (Widget, data, cb)
Widget widget;
XtPointer data;
XintEditObjectSelectionCallbackStruct *cb;
{
Object selected_object;
int code;
if (XintIsChart(cb->object))
selected_object = XintChartGetSelectedComponent(cb->object, &code);
else
selected_object = cb->object;
printf("Selected object name = %s\n", XtName((Widget) cb->object));
}
| Action | Default Editing Translation |
|---|---|
| None <Btn1Down> | ObjectEditStart() |
| <PtrMoved> | ObjectEdit() |
| <Btn1Up> | ObjectEditEnd() |
Action ObjectEditStart supports an argument. For example, if you just want the end-user to move objects, you can specify ObjectEditStart(move) in the translation table. If you don't specify an argument to action ObjectEditStart, the behavior of this action is controlled by EditObject resource XmNobjectEditMode. The purpose of this resource is to enable you to modify the behavior of action ObjectEditStart without having to redefine a new translation table. By default, resource XmNobjectEditMode is set to XintEDIT_NONE which disables all editing. To enable full object editing, set this resource to constant XintEDIT_ADJUST. See editobject.c in the demos directory, EditObject subdirectory.
Object editing can also be controlled on an object by object basis using resources XmNmove and XmNshape. These resources are set to True by default. To disable editing for a particular object, set XmNmove and/or XmNshape to False.
For chart objects, in addition to being called for the reasons described above, this callback is also invoked when the chart type has been changed. The callback structure returns both the old and the new chart type.