+static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
+{
+ int from_sx, from_sy;
+ int to_sx, to_sy;
+
+ if (from_x > to_x)
+ swap_numbers(&from_x, &to_x);
+
+ if (from_y > to_y)
+ swap_numbers(&from_y, &to_y);
+
+ from_sx = SX + from_x * MINI_TILEX;
+ from_sy = SY + from_y * MINI_TILEY;
+ to_sx = SX + to_x * MINI_TILEX + MINI_TILEX - 1;
+ to_sy = SY + to_y * MINI_TILEY + MINI_TILEY - 1;
+
+ XSetForeground(display, gc, WhitePixel(display, screen));
+
+ XDrawLine(display, drawto, gc, from_sx, from_sy, to_sx, from_sy);
+ XDrawLine(display, drawto, gc, to_sx, from_sy, to_sx, to_sy);
+ XDrawLine(display, drawto, gc, to_sx, to_sy, from_sx, to_sy);
+ XDrawLine(display, drawto, gc, from_sx, to_sy, from_sx, from_sy);
+
+ XSetForeground(display, gc, BlackPixel(display, screen));
+
+ if (from_x == to_x && from_y == to_y)
+ MarkTileDirty(from_x/2, from_y/2);
+ else
+ redraw_mask |= REDRAW_FIELD;
+}
+
+static void SelectArea(int from_x, int from_y, int to_x, int to_y,
+ int element, boolean change_level)
+{
+ if (element == -1 || change_level)
+ DrawRectangle(from_x, from_y, to_x, to_y, -1, FALSE);
+ else
+ DrawAreaBorder(from_x, from_y, to_x, to_y);
+}
+
+/* values for CopyBrushExt() */
+#define CB_AREA_TO_BRUSH 0
+#define CB_BRUSH_TO_LEVEL 1
+
+static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y, int mode)
+{
+ static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
+ static brush_from_x, brush_from_y;
+ static brush_to_x, brush_to_y;
+ int x, y;
+
+ if (from_x > to_x)
+ swap_numbers(&from_x, &to_x);
+
+ if (from_y > to_y)
+ swap_numbers(&from_y, &to_y);
+
+ if (mode == CB_AREA_TO_BRUSH)
+ {
+ for (y=from_y; y<=to_y; y++)
+ for (x=from_x; x<=to_x; x++)
+ brush_buffer[x][y] = Feld[x][y];
+
+ brush_from_x = from_x;
+ brush_from_y = from_y;
+ brush_to_x = to_x;
+ brush_to_y = to_y;
+ }
+ else
+ {
+ for (y=brush_from_y; y<=brush_to_y; y++)
+ for (x=brush_from_x; x<=brush_to_x; x++)
+ Feld[x][y] = brush_buffer[x][y];
+ CopyLevelToUndoBuffer();
+ }
+}
+
+static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y)
+{
+ CopyBrushExt(from_x, from_y, to_x, to_y, CB_AREA_TO_BRUSH);
+}
+
+#if 0
+static void CopyBrushToLevel()
+{
+ CopyBrushExt(0, 0, 0, 0, CB_BRUSH_TO_LEVEL);
+}
+#endif
+