+ if (button_release_event)
+ copy_to_undo_buffer = TRUE;
+
+ if (button)
+ {
+ if (!button_press_event)
+ DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
+
+ last_sx = sx;
+ last_sy = sy;
+ }
+ }
+ break;
+
+ case ED_CTRL_ID_LINE:
+ case ED_CTRL_ID_RECTANGLE:
+ case ED_CTRL_ID_FILLED_BOX:
+ {
+ static int last_sx = -1;
+ static int last_sy = -1;
+ static int start_sx = -1;
+ static int start_sy = -1;
+ void (*draw_func)(int, int, int, int, int, boolean);
+
+ if (drawing_function == ED_CTRL_ID_LINE)
+ draw_func = DrawLine;
+ else if (drawing_function == ED_CTRL_ID_RECTANGLE)
+ draw_func = DrawRectangle;
+ else
+ draw_func = DrawFilledBox;
+
+ if (button_press_event)
+ {
+ last_sx = start_sx = sx;
+ last_sy = start_sy = sy;
+ }
+ else if (button_release_event)
+ {
+ draw_func(start_sx, start_sy, sx, sy, last_element, TRUE);
+ copy_to_undo_buffer = TRUE;
+ }
+ else if (last_sx != sx || last_sy != sy)
+ {
+ draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
+ draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
+ last_sx = sx;
+ last_sy = sy;
+ }
+ }
+ break;
+
+ case 999:
+ {
+ static int last_sx = -1;
+ static int last_sy = -1;
+
+ if (last_sx == -1)