next up previous contents index
Next: Setup Panel Up: Graphic Windows Previous: Event Handler for

Editor Actions

 

The file ui_action.c contains all editor operations that are called exclusively by the event handlers for keyboard and pointer events. The basic structures of the functions that process selected units look very much alike. The concept is the following:

IF operation can not be performed THEN
  error message;
  return;

delete marks of all selected units;
WHILE there is a selected unit DO
 IF desired operation for this unit can be  performed THEN
   execute operation;
   change graphic if necessary;
 ELSE
   report (if desired)
END WHILE
keep graphic and values in info panel consistent;
Redraw marks for selected units;

To perform the actions Units Copy and Units Move, it first has to be checked, whether all target positions in the grid are available for the operation. Therefore, the function ui_action_checkNewPositions() checks, whether the target position is empty for UI_ACTION_COPY, or occupied by unselected units for UI_ACTION_MOVE. The whole operation is skipped if an error condition results from the check.

After links or units have been deleted, it is possible that information in the info panel has become invalid. A call to ui_info_makeInfoPanelConsistent() assures consistency in that panel.

Often it is necessary to reiterate the list of selected units within the while-loop (e.g. the function ui_action_linksMakeClique() generates connections between all selected units). In that case, a second while-loop is used that traverses the selection list, either from the start, or from the current element.



Niels Mache
Wed May 17 11:23:58 MET DST 1995