added configurability of editor control buttons (toolbox buttons)
[rocksndiamonds.git] / src / editor.c
index 9ce3bd5b1369f4b622be84da24beb02da8af7865..6a95010a354f054ba20386ed8e4b398cbc6de469 100644 (file)
   -----------------------------------------------------------------------------
 */
 
-/* positions in the level editor */
-#if 1
-#define ED_WIN_MB_LEFT_XPOS            (editor.palette.element_left.x)
-#define ED_WIN_MB_LEFT_YPOS            (editor.palette.element_left.y)
-#define ED_WIN_MB_MIDDLE_XPOS          (editor.palette.element_middle.x)
-#define ED_WIN_MB_MIDDLE_YPOS          (editor.palette.element_middle.y)
-#define ED_WIN_MB_RIGHT_XPOS           (editor.palette.element_right.x)
-#define ED_WIN_MB_RIGHT_YPOS           (editor.palette.element_right.y)
-#else
-#define ED_WIN_MB_LEFT_XPOS            6
-#define ED_WIN_MB_LEFT_YPOS            258
-#define ED_WIN_MB_MIDDLE_XPOS          42
-#define ED_WIN_MB_MIDDLE_YPOS          ED_WIN_MB_LEFT_YPOS
-#define ED_WIN_MB_RIGHT_XPOS           78
-#define ED_WIN_MB_RIGHT_YPOS           ED_WIN_MB_LEFT_YPOS
-#endif
-
 /* values for the control window */
-#define ED_CTRL_NO_BUTTONS_GFX_XPOS    6
-#define ED_CTRL_NO_BUTTONS_GFX_YPOS    286
-#define ED_CTRL1_BUTTONS_GFX_YPOS      236
-#define ED_CTRL2_BUTTONS_GFX_YPOS      236
-#define ED_CTRL3_BUTTONS_GFX_YPOS      324
-#define ED_CTRL4_BUTTONS_GFX_XPOS      44
-#define ED_CTRL4_BUTTONS_GFX_YPOS      214
-#define ED_CTRL1_BUTTONS_ALT_GFX_YPOS  142
-#define ED_CTRL3_BUTTONS_ALT_GFX_YPOS  302
-
-#define ED_CTRL1_BUTTON_XSIZE          22
-#define ED_CTRL1_BUTTON_YSIZE          22
-#define ED_CTRL1_BUTTONS_XPOS          6
-#define ED_CTRL1_BUTTONS_YPOS          6
-#define ED_CTRL2_BUTTON_XSIZE          30
-#define ED_CTRL2_BUTTON_YSIZE          20
-#define ED_CTRL2_BUTTONS_XPOS          5
-#define ED_CTRL2_BUTTONS_YPOS          99
-#define ED_CTRL3_BUTTON_XSIZE          22
-#define ED_CTRL3_BUTTON_YSIZE          22
-#define ED_CTRL3_BUTTONS_XPOS          6
-#define ED_CTRL3_BUTTONS_YPOS          6
-#define ED_CTRL4_BUTTON_XSIZE          22
-#define ED_CTRL4_BUTTON_YSIZE          22
-#define ED_CTRL4_BUTTONS_XPOS          6
-#define ED_CTRL4_BUTTONS_YPOS          6
-
 #define ED_CTRL1_BUTTONS_HORIZ         4
 #define ED_CTRL1_BUTTONS_VERT          4
 #define ED_CTRL2_BUTTONS_HORIZ         3
 #define ED_CTRL3_BUTTONS_VERT          1
 #define ED_CTRL4_BUTTONS_HORIZ         2
 #define ED_CTRL4_BUTTONS_VERT          1
+#define ED_CTRL5_BUTTONS_HORIZ         1
+#define ED_CTRL5_BUTTONS_VERT          1
 
 #define ED_NUM_CTRL1_BUTTONS   (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
 #define ED_NUM_CTRL2_BUTTONS   (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
 #define ED_NUM_CTRL3_BUTTONS   (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
 #define ED_NUM_CTRL4_BUTTONS   (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
+#define ED_NUM_CTRL5_BUTTONS   (ED_CTRL5_BUTTONS_HORIZ * ED_CTRL5_BUTTONS_VERT)
 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS   + ED_NUM_CTRL2_BUTTONS)
 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
-#define ED_NUM_CTRL_BUTTONS    (ED_NUM_CTRL1_BUTTONS + \
-                               ED_NUM_CTRL2_BUTTONS +  \
-                               ED_NUM_CTRL3_BUTTONS +  \
-                               ED_NUM_CTRL4_BUTTONS)
+#define ED_NUM_CTRL1_4_BUTTONS (ED_NUM_CTRL1_3_BUTTONS + ED_NUM_CTRL4_BUTTONS)
+#define ED_NUM_CTRL_BUTTONS    (ED_NUM_CTRL1_4_BUTTONS + ED_NUM_CTRL5_BUTTONS)
 
 /* values for the element list */
-#if 1
 #define ED_ELEMENTLIST_XPOS            (editor.palette.x)
 #define ED_ELEMENTLIST_YPOS            (editor.palette.y)
-#define ED_ELEMENTLIST_XSIZE           20
-#define ED_ELEMENTLIST_YSIZE           20
-#else
-#define ED_ELEMENTLIST_XPOS            5
-#define ED_ELEMENTLIST_YPOS            30
-#define ED_ELEMENTLIST_XSIZE           20
-#define ED_ELEMENTLIST_YSIZE           20
-#endif
-#if 1
-// #define ED_ELEMENTLIST_BUTTONS_HORIZ        4
-// #define ED_ELEMENTLIST_BUTTONS_VERT 9
+#define ED_ELEMENTLIST_XSIZE           (graphic_info[IMG_EDITOR_PALETTE_BUTTON].width)
+#define ED_ELEMENTLIST_YSIZE           (graphic_info[IMG_EDITOR_PALETTE_BUTTON].height)
 #define ED_ELEMENTLIST_BUTTONS_HORIZ   (editor.palette.cols)
 #define ED_ELEMENTLIST_BUTTONS_VERT    (editor.palette.rows)
-#else
-#define ED_ELEMENTLIST_BUTTONS_HORIZ   4
-#define ED_ELEMENTLIST_BUTTONS_VERT    11
-#endif
 #define ED_NUM_ELEMENTLIST_BUTTONS     (ED_ELEMENTLIST_BUTTONS_HORIZ * \
                                         ED_ELEMENTLIST_BUTTONS_VERT)
 
 #define ED_SCROLLBAR2_XPOS             50
 #define ED_SCROLLBAR2_YPOS             20
 
-#define ED_SCROLLBUTTON2_XSIZE         10
-#define ED_SCROLLBUTTON2_YSIZE         10
+#define ED_SCROLLBUTTON2_XSIZE         (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].width)
+#define ED_SCROLLBUTTON2_YSIZE         (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].height)
 
-#if 1
 #define ED_SCROLL2_UP_XPOS             (ED_ELEMENTLIST_XPOS +          \
                                         ED_ELEMENTLIST_BUTTONS_HORIZ * \
                                         ED_ELEMENTLIST_XSIZE)
 #define ED_SCROLL2_VERTICAL_YSIZE      (ED_ELEMENTLIST_BUTTONS_VERT *  \
                                         ED_ELEMENTLIST_YSIZE -         \
                                         2 * ED_SCROLLBUTTON2_YSIZE)
-#else
-#define ED_SCROLL2_UP_XPOS             85
-#define ED_SCROLL2_UP_YPOS             30
-#define ED_SCROLL2_DOWN_XPOS           ED_SCROLL2_UP_XPOS
-#define ED_SCROLL2_DOWN_YPOS           (ED_SCROLL2_UP_YPOS +           \
-                                        ED_ELEMENTLIST_BUTTONS_VERT *  \
-                                        ED_ELEMENTLIST_YSIZE -         \
-                                        ED_SCROLLBUTTON2_YSIZE)
-#define ED_SCROLL2_VERTICAL_XPOS       ED_SCROLL2_UP_XPOS
-#define ED_SCROLL2_VERTICAL_YPOS       (ED_SCROLL2_UP_YPOS +           \
-                                        ED_SCROLLBUTTON2_YSIZE)
-#define ED_SCROLL2_VERTICAL_XSIZE      ED_SCROLLBUTTON2_XSIZE
-#define ED_SCROLL2_VERTICAL_YSIZE      (ED_ELEMENTLIST_BUTTONS_VERT *  \
-                                        ED_ELEMENTLIST_YSIZE -         \
-                                        2 * ED_SCROLLBUTTON2_YSIZE)
-#endif
 
 /* values for checkbutton gadgets */
 #define ED_CHECKBUTTON_XSIZE           ED_BUTTON_COUNT_XSIZE
 #define ED_WIN_COUNT_YPOS              ED_BUTTON_COUNT_YPOS
 #define ED_WIN_COUNT_XSIZE             52
 #define ED_WIN_COUNT_YSIZE             ED_BUTTON_COUNT_YSIZE
-#define ED_WIN_COUNT2_XPOS             27
-#define ED_WIN_COUNT2_YPOS             3
-#define ED_WIN_COUNT2_XSIZE            46
-#define ED_WIN_COUNT2_YSIZE            ED_BUTTON_COUNT_YSIZE
 
 #define ED_BUTTON_MINUS_XPOS           2
 #define ED_BUTTON_MINUS_YPOS           ED_BUTTON_COUNT_YPOS
 #define GADGET_ID_TEXT                 (GADGET_ID_TOOLBOX_FIRST + 7)
 #define GADGET_ID_FLOOD_FILL           (GADGET_ID_TOOLBOX_FIRST + 8)
 #define GADGET_ID_WRAP_LEFT            (GADGET_ID_TOOLBOX_FIRST + 9)
-#define GADGET_ID_PROPERTIES           (GADGET_ID_TOOLBOX_FIRST + 10)
+#define GADGET_ID_ZOOM                 (GADGET_ID_TOOLBOX_FIRST + 10)
 #define GADGET_ID_WRAP_RIGHT           (GADGET_ID_TOOLBOX_FIRST + 11)
 #define GADGET_ID_RANDOM_PLACEMENT     (GADGET_ID_TOOLBOX_FIRST + 12)
 #define GADGET_ID_GRAB_BRUSH           (GADGET_ID_TOOLBOX_FIRST + 13)
 #define GADGET_ID_CUSTOM_COPY          (GADGET_ID_TOOLBOX_FIRST + 25)
 #define GADGET_ID_CUSTOM_PASTE         (GADGET_ID_TOOLBOX_FIRST + 26)
 
+#define GADGET_ID_PROPERTIES           (GADGET_ID_TOOLBOX_FIRST + 27)
+
 /* counter gadget identifiers */
-#define GADGET_ID_COUNTER_FIRST                (GADGET_ID_TOOLBOX_FIRST + 27)
+#define GADGET_ID_COUNTER_FIRST                (GADGET_ID_TOOLBOX_FIRST + 28)
 
 #define GADGET_ID_SELECT_LEVEL_DOWN    (GADGET_ID_COUNTER_FIRST + 0)
 #define GADGET_ID_SELECT_LEVEL_TEXT    (GADGET_ID_COUNTER_FIRST + 1)
 #define RANDOM_USE_QUANTITY            1
 
 /* maximal size of level editor drawing area */
-#if NEW_TILESIZE
-#define MAX_ED_FIELDX          (SCR_FIELDX)
-#define MAX_ED_FIELDY          (SCR_FIELDY - 1)
-#else
-#define MAX_ED_FIELDX          (2 * SCR_FIELDX)
-#define MAX_ED_FIELDY          (2 * SCR_FIELDY - 1)
-#endif
+#define MAX_ED_FIELDX                  (SCR_FIELDX)
+#define MAX_ED_FIELDY                  (SCR_FIELDY - 1)
 
 
 /*
 
 static struct
 {
+  int graphic;
+  int gadget_id;
+  struct XY *pos;
+  int gadget_type;
+  char *infotext;
   char shortcut;
-  char *text;
-} control_info[ED_NUM_CTRL_BUTTONS] =
+} controlbutton_info[ED_NUM_CTRL_BUTTONS] =
 {
   /* note: some additional characters are already reserved for "cheat mode"
      shortcuts (":XYZ" style) -- for details, see "events.c" */
 
-  { 's',       "draw single items"                     },
-  { 'd',       "draw connected items"                  },
-  { 'l',       "draw lines"                            },
-  { 'a',       "draw arcs"                             },
-  { 'r',       "draw outline rectangles"               },
-  { 'R',       "draw filled rectangles"                },
-  { '\0',      "wrap (rotate) level up"                },
-  { 't',       "enter text elements"                   },
-  { 'f',       "flood fill"                            },
-  { '\0',      "wrap (rotate) level left"              },
-  { '?',       "properties of drawing element"         },
-  { '\0',      "wrap (rotate) level right"             },
-  { '\0',      "random element placement"              },
-  { 'b',       "grab brush"                            },
-  { '\0',      "wrap (rotate) level down"              },
-  { ',',       "pick drawing element"                  },
-
-  { 'U',       "undo last operation"                   },
-  { 'I',       "properties of level"                   },
-  { 'S',       "save level"                            },
-  { 'C',       "clear level"                           },
-  { 'T',       "test level"                            },
-  { 'E',       "exit level editor"                     },
-
-  { '\0',      "copy settings from other element"      },
-  { '\0',      "copy settings to other element"        },
-  { '\0',      "exchange element with other element"   },
-
-  { '\0',      "copy settings from this element"       },
-  { '\0',      "paste settings to this element"        },
+  /* ---------- toolbox control buttons ------------------------------------ */
+
+  {
+    IMG_EDITOR_BUTTON_GFX_DRAW_SINGLE,         GADGET_ID_SINGLE_ITEMS,
+    &editor.button.draw_single,                        GD_TYPE_RADIO_BUTTON,
+    "draw single items",                       's'
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_DRAW_CONNECTED,      GADGET_ID_CONNECTED_ITEMS,
+    &editor.button.draw_connected,             GD_TYPE_RADIO_BUTTON,
+    "draw connected items",                    'd'
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_DRAW_LINE,           GADGET_ID_LINE,
+    &editor.button.draw_line,                  GD_TYPE_RADIO_BUTTON,
+    "draw lines",                              'l'
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_DRAW_ARC,            GADGET_ID_ARC,
+    &editor.button.draw_arc,                   GD_TYPE_RADIO_BUTTON,
+    "draw arcs",                               'a'
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_DRAW_RECTANGLE,      GADGET_ID_RECTANGLE,
+    &editor.button.draw_rectangle,             GD_TYPE_RADIO_BUTTON,
+    "draw outline rectangles",                 'r'
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_DRAW_FILLED_BOX,     GADGET_ID_FILLED_BOX,
+    &editor.button.draw_filled_box,            GD_TYPE_RADIO_BUTTON,
+    "draw filled rectangles",                  'R'
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_ROTATE_UP,           GADGET_ID_WRAP_UP,
+    &editor.button.rotate_up,                  GD_TYPE_NORMAL_BUTTON,
+    "wrap (rotate) level up",                  0
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_DRAW_TEXT,           GADGET_ID_TEXT,
+    &editor.button.draw_text,                  GD_TYPE_RADIO_BUTTON,
+    "enter text elements",                     't'
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_FLOOD_FILL,          GADGET_ID_FLOOD_FILL,
+    &editor.button.flood_fill,                 GD_TYPE_RADIO_BUTTON,
+    "flood fill",                              'f'
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_ROTATE_LEFT,         GADGET_ID_WRAP_LEFT,
+    &editor.button.rotate_left,                        GD_TYPE_NORMAL_BUTTON,
+    "wrap (rotate) level left",                        0
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_ZOOM_LEVEL,          GADGET_ID_ZOOM,
+    &editor.button.zoom_level,                 GD_TYPE_NORMAL_BUTTON,
+    "zoom level tile size",                    'z'
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_ROTATE_RIGHT,                GADGET_ID_WRAP_RIGHT,
+    &editor.button.rotate_right,               GD_TYPE_NORMAL_BUTTON,
+    "wrap (rotate) level right",               0
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_DRAW_RANDOM,         GADGET_ID_RANDOM_PLACEMENT,
+    &editor.button.draw_random,                        GD_TYPE_NORMAL_BUTTON,
+    "random element placement",                        0
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_GRAB_BRUSH,          GADGET_ID_GRAB_BRUSH,
+    &editor.button.grab_brush,                 GD_TYPE_RADIO_BUTTON,
+    "grab brush",                              'b'
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_ROTATE_DOWN,         GADGET_ID_WRAP_DOWN,
+    &editor.button.rotate_down,                        GD_TYPE_NORMAL_BUTTON,
+    "wrap (rotate) level down",                        0
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_PICK_ELEMENT,                GADGET_ID_PICK_ELEMENT,
+    &editor.button.pick_element,               GD_TYPE_RADIO_BUTTON,
+    "pick drawing element",                    ','
+  },
+
+  /* ---------- level control buttons -------------------------------------- */
+
+  {
+    IMG_EDITOR_BUTTON_GFX_UNDO,                        GADGET_ID_UNDO,
+    &editor.button.undo,                       GD_TYPE_NORMAL_BUTTON,
+    "undo last operation",                     'U'
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_CONF,                        GADGET_ID_INFO,
+    &editor.button.conf,                       GD_TYPE_NORMAL_BUTTON,
+    "properties of level",                     'I'
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_SAVE,                        GADGET_ID_SAVE,
+    &editor.button.save,                       GD_TYPE_NORMAL_BUTTON,
+    "save level",                              'S'
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_CLEAR,               GADGET_ID_CLEAR,
+    &editor.button.clear,                      GD_TYPE_NORMAL_BUTTON,
+    "clear level",                             'C'
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_TEST,                        GADGET_ID_TEST,
+    &editor.button.test,                       GD_TYPE_NORMAL_BUTTON,
+    "test level",                              'T'
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_EXIT,                        GADGET_ID_EXIT,
+    &editor.button.exit,                       GD_TYPE_NORMAL_BUTTON,
+    "exit level editor",                       'E'
+  },
+
+  /* ---------- CE and GE control buttons ---------------------------------- */
+
+  {
+    IMG_EDITOR_BUTTON_GFX_CE_COPY_FROM,                GADGET_ID_CUSTOM_COPY_FROM,
+    &editor.button.ce_copy_from,               GD_TYPE_RADIO_BUTTON,
+    "copy settings from other element",                0
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_CE_COPY_TO,          GADGET_ID_CUSTOM_COPY_TO,
+    &editor.button.ce_copy_to,                 GD_TYPE_RADIO_BUTTON,
+    "copy settings to other element",          0
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_CE_SWAP,             GADGET_ID_CUSTOM_EXCHANGE,
+    &editor.button.ce_swap,                    GD_TYPE_RADIO_BUTTON,
+    "exchange element with other element",     0
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_CE_COPY,             GADGET_ID_CUSTOM_COPY,
+    &editor.button.ce_copy,                    GD_TYPE_NORMAL_BUTTON,
+    "copy settings from this element",         0
+  },
+  {
+    IMG_EDITOR_BUTTON_GFX_CE_PASTE,            GADGET_ID_CUSTOM_PASTE,
+    &editor.button.ce_paste,                   GD_TYPE_NORMAL_BUTTON,
+    "paste settings to this element",          0
+  },
+
+  /* ---------- palette control buttons ------------------------------------ */
+
+  {
+    IMG_EDITOR_BUTTON_GFX_PROPERTIES,          GADGET_ID_PROPERTIES,
+    &editor.button.properties,                 GD_TYPE_NORMAL_BUTTON,
+    "properties of drawing element",           'p'
+  }
 };
 
 static int random_placement_value = 10;
@@ -1092,11 +1136,7 @@ static struct
   /* ---------- current level number --------------------------------------- */
 
   {
-#if 1
     -1, -1,    /* these values are not constant, but can change at runtime */
-#else
-    DX + 5 - SX,                       DY + 3 - SY,
-#endif
     1,                                 100,
     GADGET_ID_SELECT_LEVEL_DOWN,       GADGET_ID_SELECT_LEVEL_UP,
     GADGET_ID_SELECT_LEVEL_TEXT,       GADGET_ID_NONE,
@@ -2513,8 +2553,6 @@ static struct
   },
 };
 
-#if 1
-
 static struct
 {
   int x, y;
@@ -2595,136 +2633,6 @@ static struct
   }
 };
 
-#else
-
-static struct
-{
-  int gd_x, gd_y;
-  int x, y;
-  int gadget_id;
-  char *infotext;
-} scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
-{
-  {
-    ED_SCROLLBUTTON_XPOS,   ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE,
-#if 1
-    -1, -1,    /* these values are not constant, but can change at runtime */
-#else
-    ED_SCROLL_UP_XPOS,      ED_SCROLL_UP_YPOS,
-#endif
-    GADGET_ID_SCROLL_UP,
-    "scroll level editing area up"
-  },
-  {
-    ED_SCROLLBUTTON_XPOS,   ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE,
-#if 1
-    -1, -1,    /* these values are not constant, but can change at runtime */
-#else
-    ED_SCROLL_DOWN_XPOS,    ED_SCROLL_DOWN_YPOS,
-#endif
-    GADGET_ID_SCROLL_DOWN,
-    "scroll level editing area down"
-  },
-  {
-    ED_SCROLLBUTTON_XPOS,   ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE,
-#if 1
-    -1, -1,    /* these values are not constant, but can change at runtime */
-#else
-    ED_SCROLL_LEFT_XPOS,    ED_SCROLL_LEFT_YPOS,
-#endif
-    GADGET_ID_SCROLL_LEFT,
-    "scroll level editing area left"
-  },
-  {
-    ED_SCROLLBUTTON_XPOS,   ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE,
-#if 1
-    -1, -1,    /* these values are not constant, but can change at runtime */
-#else
-    ED_SCROLL_RIGHT_XPOS,   ED_SCROLL_RIGHT_YPOS,
-#endif
-    GADGET_ID_SCROLL_RIGHT,
-    "scroll level editing area right"
-  },
-  {
-    ED_SCROLLBUTTON2_XPOS,  ED_SCROLLBUTTON2_YPOS + 0 * ED_SCROLLBUTTON2_YSIZE,
-    ED_SCROLL2_UP_XPOS,     ED_SCROLL2_UP_YPOS,
-    GADGET_ID_SCROLL_LIST_UP,
-    "scroll element list up ('Page Up')"
-  },
-  {
-    ED_SCROLLBUTTON2_XPOS,  ED_SCROLLBUTTON2_YPOS + 1 * ED_SCROLLBUTTON2_YSIZE,
-    ED_SCROLL2_DOWN_XPOS,   ED_SCROLL2_DOWN_YPOS,
-    GADGET_ID_SCROLL_LIST_DOWN,
-    "scroll element list down ('Page Down')"
-  },
-};
-
-static struct
-{
-  int gd_x, gd_y;
-  int x, y;
-  int width, height;
-  int wheel_x, wheel_y;
-  int wheel_width, wheel_height;
-  int type;
-  int gadget_id;
-  char *infotext;
-} scrollbar_info[ED_NUM_SCROLLBARS] =
-{
-  {
-    ED_SCROLLBAR_XPOS,                 ED_SCROLLBAR_YPOS,
-#if 1
-    -1, -1,    /* these values are not constant, but can change at runtime */
-    -1, -1,    /* these values are not constant, but can change at runtime */
-    -1, -1,    /* these values are not constant, but can change at runtime */
-    -1, -1,    /* these values are not constant, but can change at runtime */
-#else
-    SX + ED_SCROLL_HORIZONTAL_XPOS,    SY + ED_SCROLL_HORIZONTAL_YPOS,
-    ED_SCROLL_HORIZONTAL_XSIZE,                ED_SCROLL_HORIZONTAL_YSIZE,
-    SX,                                        SY,
-    SXSIZE,                            SYSIZE,
-#endif
-    GD_TYPE_SCROLLBAR_HORIZONTAL,
-    GADGET_ID_SCROLL_HORIZONTAL,
-    "scroll level editing area horizontally"
-  },
-  {
-    ED_SCROLLBAR_XPOS,                 ED_SCROLLBAR_YPOS,
-#if 1
-    -1, -1,    /* these values are not constant, but can change at runtime */
-    -1, -1,    /* these values are not constant, but can change at runtime */
-    -1, -1,    /* these values are not constant, but can change at runtime */
-    -1, -1,    /* these values are not constant, but can change at runtime */
-#else
-    SX + ED_SCROLL_VERTICAL_XPOS,      SY + ED_SCROLL_VERTICAL_YPOS,
-    ED_SCROLL_VERTICAL_XSIZE,          ED_SCROLL_VERTICAL_YSIZE,
-    SX,                                        SY,
-    SXSIZE,                            SYSIZE,
-#endif
-    GD_TYPE_SCROLLBAR_VERTICAL,
-    GADGET_ID_SCROLL_VERTICAL,
-    "scroll level editing area vertically"
-  },
-  {
-    ED_SCROLLBAR2_XPOS,                        ED_SCROLLBAR2_YPOS,
-#if 1
-    -1, -1,    /* these values are not constant, but can change at runtime */
-    ED_SCROLL2_VERTICAL_XSIZE,         ED_SCROLL2_VERTICAL_YSIZE,
-    -1, -1,    /* these values are not constant, but can change at runtime */
-    -1, -1,    /* these values are not constant, but can change at runtime */
-#else
-    DX + ED_SCROLL2_VERTICAL_XPOS,     DY + ED_SCROLL2_VERTICAL_YPOS,
-    ED_SCROLL2_VERTICAL_XSIZE,         ED_SCROLL2_VERTICAL_YSIZE,
-    DX,                                        DY,
-    DXSIZE,                            DYSIZE,
-#endif
-    GD_TYPE_SCROLLBAR_VERTICAL,
-    GADGET_ID_SCROLL_LIST_VERTICAL,
-    "scroll element list vertically"
-  }
-};
-
-#endif
 
 static struct
 {
@@ -2963,15 +2871,8 @@ static struct
     ED_ELEMENT_SETTINGS_XPOS(0),       ED_ELEMENT_SETTINGS_YPOS(1),
     GADGET_ID_CUSTOM_USE_GRAPHIC,      GADGET_ID_NONE,
     &custom_element.use_gfx_element,
-
-    /* !!! add separate "use existing element sound" !!! */
-#if 0
-    NULL,
-    "use graphic/sound of element:",   "use existing graphic and sound"
-#else
     NULL,
     "use graphic of element:",         "use existing element graphic"
-#endif
   },
   {
     ED_ELEMENT_SETTINGS_XPOS(0),       ED_ELEMENT_SETTINGS_YPOS(2),
@@ -3165,11 +3066,7 @@ static struct
     0,                                 0,
     GADGET_ID_DRAWING_LEVEL,           GADGET_ID_NONE,
     NULL,
-#if 1
     -1, -1,    /* these values are not constant, but can change at runtime */
-#else
-    MAX_ED_FIELDX, MAX_ED_FIELDY,
-#endif
     NULL, NULL, NULL,                  NULL
   },
 
@@ -3431,20 +3328,12 @@ static struct
 */
 
 /* actual size of level editor drawing area */
-#if 1
 static int ed_fieldx, ed_fieldy;
-#else
-static int ed_fieldx = MAX_ED_FIELDX - 1, ed_fieldy = MAX_ED_FIELDY - 1;
-#endif
 
 /* actual position of level editor drawing area in level playfield */
 static int level_xpos = -1, level_ypos = -1;
 
-#if 1
 #define IN_ED_FIELD(x,y)       IN_FIELD(x, y, ed_fieldx, ed_fieldy)
-#else
-#define IN_ED_FIELD(x,y)  ((x)>=0 && (x)<ed_fieldx && (y)>=0 &&(y)<ed_fieldy)
-#endif
 
 /* drawing elements on the three mouse buttons */
 static int new_element1 = EL_WALL;
@@ -3487,13 +3376,8 @@ static void PrintEditorGadgetInfoText(struct GadgetInfo *);
 
 static int num_editor_gadgets = 0;     /* dynamically determined */
 
-#if 1
 static struct GadgetInfo **level_editor_gadget = NULL;
 static int *right_gadget_border = NULL;
-#else
-static struct GadgetInfo *level_editor_gadget[NUM_EDITOR_GADGETS];
-static int right_gadget_border[NUM_EDITOR_GADGETS];
-#endif
 
 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
@@ -4204,13 +4088,13 @@ static int editor_el_chars[] =
   EL_CHAR('^'),
   EL_CHAR('_'),
 
-  EL_CHAR('©'),
-  EL_CHAR('Ä'),
-  EL_CHAR('Ö'),
-  EL_CHAR('Ü'),
+  EL_CHAR(CHAR_BYTE_COPYRIGHT),
+  EL_CHAR(CHAR_BYTE_UMLAUT_A),
+  EL_CHAR(CHAR_BYTE_UMLAUT_O),
+  EL_CHAR(CHAR_BYTE_UMLAUT_U),
 
-  EL_CHAR('°'),
-  EL_CHAR('®'),
+  EL_CHAR(CHAR_BYTE_DEGREE),
+  EL_CHAR(CHAR_BYTE_REGISTERED),
   EL_CHAR(FONT_ASCII_CURSOR),
   EL_CHAR(FONT_ASCII_BUTTON),
 
@@ -4314,13 +4198,13 @@ static int editor_el_steel_chars[] =
   EL_STEEL_CHAR('^'),
   EL_STEEL_CHAR('_'),
 
-  EL_STEEL_CHAR('©'),
-  EL_STEEL_CHAR('Ä'),
-  EL_STEEL_CHAR('Ö'),
-  EL_STEEL_CHAR('Ü'),
+  EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
+  EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
+  EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
+  EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
 
-  EL_STEEL_CHAR('°'),
-  EL_STEEL_CHAR('®'),
+  EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
+  EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
   EL_STEEL_CHAR(FONT_ASCII_CURSOR),
   EL_STEEL_CHAR(FONT_ASCII_BUTTON),
 
@@ -4796,18 +4680,10 @@ static int num_editor_hl_dynamic = SIZEOF_ARRAY_INT(editor_hl_dynamic);
 static int num_editor_el_dynamic = 0;
 
 static int editor_hl_empty[] = { EL_EMPTY };
-#if 1
 static int *editor_el_empty = NULL;    /* dynamically allocated */
-#else
-static int editor_el_empty[ED_NUM_ELEMENTLIST_BUTTONS];
-#endif
 
 static int *editor_hl_empty_ptr = editor_hl_empty;
-#if 1
 static int *editor_el_empty_ptr = NULL;
-#else
-static int *editor_el_empty_ptr = editor_el_empty;
-#endif
 static int num_editor_hl_empty = 0;
 static int num_editor_el_empty = 0;    /* dynamically determined, if needed */
 
@@ -5001,27 +4877,47 @@ static char *getElementInfoText(int element)
   return info_text;
 }
 
-char *getElementDescriptionFilename(int element)
+static char *getElementDescriptionFilenameExt(char *basename)
 {
-  char *docs_dir = options.docs_directory;
   char *elements_subdir = "elements";
+  static char *elements_subdir2 = NULL;
   static char *filename = NULL;
-  char basename[MAX_FILENAME_LEN];
+
+  if (elements_subdir2 == NULL)
+    elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
 
   checked_free(filename);
 
-  /* 1st try: look for element description file for exactly this element */
-  sprintf(basename, "%s.txt", element_info[element].token_name);
-  filename = getPath3(docs_dir, elements_subdir, basename);
+  /* 1st try: look for element description in current level set directory */
+  filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
   if (fileExists(filename))
     return filename;
 
   free(filename);
 
+  /* 2nd try: look for element description in the game's base directory */
+  filename = getPath3(options.docs_directory, elements_subdir, basename);
+  if (fileExists(filename))
+    return filename;
+
+  return NULL;
+}
+
+char *getElementDescriptionFilename(int element)
+{
+  char basename[MAX_FILENAME_LEN];
+  char *filename;
+
+  /* 1st try: look for element description file for exactly this element */
+  sprintf(basename, "%s.txt", element_info[element].token_name);
+  filename = getElementDescriptionFilenameExt(basename);
+  if (filename != NULL)
+    return filename;
+
   /* 2nd try: look for element description file for this element's class */
   sprintf(basename, "%s.txt", element_info[element].class_name);
-  filename = getPath3(docs_dir, elements_subdir, basename);
-  if (fileExists(filename))
+  filename = getElementDescriptionFilenameExt(basename);
+  if (filename != NULL)
     return filename;
 
   return NULL;
@@ -5140,7 +5036,9 @@ static void ReinitializeElementList()
     {
       if (setup.editor.el_headlines)
       {
-       num_editor_elements += *editor_elements_info[i].headline_list_size;
+       // required for correct padding of palette headline buttons
+       if (*editor_elements_info[i].headline_list_size > 0)
+         num_editor_elements += editor.palette.cols;
 
        for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
        {
@@ -5154,7 +5052,13 @@ static void ReinitializeElementList()
       if (found_inactive_cascade)
        continue;
 
-      num_editor_elements += *editor_elements_info[i].element_list_size;
+      // required for correct padding of palette element buttons
+      int element_list_size = *editor_elements_info[i].element_list_size;
+      int element_rows =
+       (element_list_size + editor.palette.cols - 1) / editor.palette.cols;
+      int element_buttons = editor.palette.cols * element_rows;
+
+      num_editor_elements += element_buttons;
     }
   }
 
@@ -5178,9 +5082,16 @@ static void ReinitializeElementList()
     {
       if (setup.editor.el_headlines)
       {
-       for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
+       // required for correct padding of palette headline buttons
+       int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
+                            editor.palette.cols : 0);
+
+       for (j = 0; j < headline_size; j++)
        {
-         int element = (*editor_elements_info[i].headline_list)[j];
+         // use empty elements for padding of palette headline buttons
+         int element = (j < *editor_elements_info[i].headline_list_size ?
+                        (*editor_elements_info[i].headline_list)[j] :
+                        editor_el_empty[0]);
 
          editor_elements[pos++] = element;
 
@@ -5192,8 +5103,19 @@ static void ReinitializeElementList()
       if (found_inactive_cascade)
        continue;
 
-      for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
+      // required for correct padding of palette element buttons
+      int element_list_size = *editor_elements_info[i].element_list_size;
+      int element_rows =
+       (element_list_size + editor.palette.cols - 1) / editor.palette.cols;
+      int element_buttons = editor.palette.cols * element_rows;
+
+      // copy all elements from element list
+      for (j = 0; j < element_list_size; j++)
        editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
+
+      // use empty elements for padding of palette element buttons
+      for (j = 0; j < element_buttons - element_list_size; j++)
+       editor_elements[pos++] = editor_el_empty[0];
     }
   }
 
@@ -5368,49 +5290,55 @@ static void ScrollMiniLevel(int from_x, int from_y, int scroll)
   BackToFront();
 }
 
+void getElementListGraphicSource(int element, Bitmap **bitmap, int *x, int *y)
+{
+  int graphic = el2edimg(element);
+  int tile_size = (editor.palette.tile_size >= TILESIZE ? TILESIZE :
+                  MINI_TILESIZE);
+
+  getSizedGraphicSource(graphic, 0, tile_size, bitmap, x, y);
+}
+
 static void CreateControlButtons()
 {
-  Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
   struct GadgetInfo *gi;
-  unsigned int event_mask;
   int i;
 
   /* create toolbox buttons */
   for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
   {
-    int id = i;
-    int width, height;
-    int gd_xoffset, gd_yoffset;
-    int gd_x1, gd_x2, gd_y1, gd_y2;
-    int button_type;
-    int radio_button_nr;
-    boolean checked;
-
-    if (id == GADGET_ID_SINGLE_ITEMS ||
-       id == GADGET_ID_CONNECTED_ITEMS ||
-       id == GADGET_ID_LINE ||
-       id == GADGET_ID_ARC ||
-       id == GADGET_ID_TEXT ||
-       id == GADGET_ID_RECTANGLE ||
-       id == GADGET_ID_FILLED_BOX ||
-       id == GADGET_ID_FLOOD_FILL ||
-       id == GADGET_ID_GRAB_BRUSH ||
-       id == GADGET_ID_PICK_ELEMENT ||
-       id == GADGET_ID_CUSTOM_COPY_FROM ||
-       id == GADGET_ID_CUSTOM_COPY_TO ||
-       id == GADGET_ID_CUSTOM_EXCHANGE)
+    int id = controlbutton_info[i].gadget_id;
+    int type = controlbutton_info[i].gadget_type;
+    int graphic = controlbutton_info[i].graphic;
+    struct XY *pos = controlbutton_info[i].pos;
+    struct GraphicInfo *gd = &graphic_info[graphic];
+    Bitmap *gd_bitmap = gd->bitmap;
+    int gd_x1 = gd->src_x;
+    int gd_y1 = gd->src_y;
+    int gd_x2 = gd->src_x + gd->pressed_xoffset;
+    int gd_y2 = gd->src_y + gd->pressed_yoffset;
+    int gd_x1a = gd->src_x + gd->active_xoffset;
+    int gd_y1a = gd->src_y + gd->active_yoffset;
+    int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
+    int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
+    int width  = gd->width;
+    int height = gd->height;
+    int x = pos->x;
+    int y = pos->y;
+    unsigned int event_mask;
+    int radio_button_nr = RADIO_NR_NONE;
+    boolean checked = FALSE;
+
+    if (type == GD_TYPE_RADIO_BUTTON)
     {
-      button_type = GD_TYPE_RADIO_BUTTON;
-      radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
-      checked = (id == drawing_function ? TRUE : FALSE);
       event_mask = GD_EVENT_PRESSED;
+      radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
+
+      if (id == drawing_function)
+       checked = TRUE;
     }
     else
     {
-      button_type = GD_TYPE_NORMAL_BUTTON;
-      radio_button_nr = RADIO_NR_NONE;
-      checked = FALSE;
-
       if (id == GADGET_ID_WRAP_LEFT ||
          id == GADGET_ID_WRAP_RIGHT ||
          id == GADGET_ID_WRAP_UP ||
@@ -5420,82 +5348,32 @@ static void CreateControlButtons()
        event_mask = GD_EVENT_RELEASED;
     }
 
-    if (id < ED_NUM_CTRL1_BUTTONS)
-    {
-      int x = i % ED_CTRL1_BUTTONS_HORIZ;
-      int y = i / ED_CTRL1_BUTTONS_HORIZ;
-
-      gd_xoffset = ED_CTRL1_BUTTONS_XPOS + x * ED_CTRL1_BUTTON_XSIZE;
-      gd_yoffset = ED_CTRL1_BUTTONS_YPOS + y * ED_CTRL1_BUTTON_YSIZE;
-      width  = ED_CTRL1_BUTTON_XSIZE;
-      height = ED_CTRL1_BUTTON_YSIZE;
-
-      gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
-      gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
-      gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_GFX_YPOS     + gd_yoffset;
-      gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
-    }
-    else if (id < ED_NUM_CTRL1_2_BUTTONS)
-    {
-      int x = (i - ED_NUM_CTRL1_BUTTONS) % ED_CTRL2_BUTTONS_HORIZ;
-      int y = (i - ED_NUM_CTRL1_BUTTONS) / ED_CTRL2_BUTTONS_HORIZ;
-
-      gd_xoffset = ED_CTRL2_BUTTONS_XPOS + x * ED_CTRL2_BUTTON_XSIZE;
-      gd_yoffset = ED_CTRL2_BUTTONS_YPOS + y * ED_CTRL2_BUTTON_YSIZE;
-      width  = ED_CTRL2_BUTTON_XSIZE;
-      height = ED_CTRL2_BUTTON_YSIZE;
-
-      gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
-      gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
-      gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL2_BUTTONS_GFX_YPOS + gd_yoffset;
-      gd_y2 = 0;       /* no alternative graphic for these buttons */
-    }
-    else if (id < ED_NUM_CTRL1_3_BUTTONS)
+    if (id == GADGET_ID_PROPERTIES)
     {
-      int x = (i - ED_NUM_CTRL1_2_BUTTONS) % ED_CTRL3_BUTTONS_HORIZ + 1;
-      int y = (i - ED_NUM_CTRL1_2_BUTTONS) / ED_CTRL3_BUTTONS_HORIZ;
-
-      gd_xoffset = ED_CTRL3_BUTTONS_XPOS + x * ED_CTRL3_BUTTON_XSIZE;
-      gd_yoffset = ED_CTRL3_BUTTONS_YPOS + y * ED_CTRL3_BUTTON_YSIZE;
-      width  = ED_CTRL3_BUTTON_XSIZE;
-      height = ED_CTRL3_BUTTON_YSIZE;
-
-      gd_x1 = DOOR_GFX_PAGEX6 + gd_xoffset;
-      gd_x2 = DOOR_GFX_PAGEX5 + gd_xoffset;
-      gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_GFX_YPOS     + gd_yoffset;
-      gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
+      x += DX;
+      y += DY;
     }
     else
     {
-      int x = (i - ED_NUM_CTRL1_3_BUTTONS) % ED_CTRL4_BUTTONS_HORIZ;
-      int y = (i - ED_NUM_CTRL1_3_BUTTONS) / ED_CTRL4_BUTTONS_HORIZ + 3;
-
-      gd_xoffset = ED_CTRL4_BUTTONS_XPOS + x * ED_CTRL4_BUTTON_XSIZE;
-      gd_yoffset = ED_CTRL4_BUTTONS_YPOS + y * ED_CTRL4_BUTTON_YSIZE;
-      width  = ED_CTRL4_BUTTON_XSIZE;
-      height = ED_CTRL4_BUTTON_YSIZE;
-
-      gd_x1 = DOOR_GFX_PAGEX6 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset;
-      gd_x2 = DOOR_GFX_PAGEX5 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset;
-      gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL4_BUTTONS_GFX_YPOS + gd_yoffset;
-      gd_y2 = 0;       /* no alternative graphic for these buttons */
+      x += EX;
+      y += EY;
     }
 
     gi = CreateGadget(GDI_CUSTOM_ID, id,
                      GDI_CUSTOM_TYPE_ID, i,
-                     GDI_INFO_TEXT, control_info[i].text,
-                     GDI_X, EX + gd_xoffset,
-                     GDI_Y, EY + gd_yoffset,
+                     GDI_INFO_TEXT, controlbutton_info[i].infotext,
+                     GDI_X, x,
+                     GDI_Y, y,
                      GDI_WIDTH, width,
                      GDI_HEIGHT, height,
-                     GDI_TYPE, button_type,
+                     GDI_TYPE, type,
                      GDI_STATE, GD_BUTTON_UNPRESSED,
                      GDI_RADIO_NR, radio_button_nr,
                      GDI_CHECKED, checked,
                      GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
-                     GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
-                     GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
-                     GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
+                     GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
+                     GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1a, gd_y1a,
+                     GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2a, gd_y2a,
                      GDI_EVENT_MASK, event_mask,
                      GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
                      GDI_CALLBACK_ACTION, HandleControlButtons,
@@ -5508,7 +5386,6 @@ static void CreateControlButtons()
   }
 
   /* these values are not constant, but can change at runtime */
-#if 1
   scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x    = ED_SCROLL_UP_XPOS;
   scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y    = ED_SCROLL_UP_YPOS;
   scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x  = ED_SCROLL_DOWN_XPOS;
@@ -5521,78 +5398,34 @@ static void CreateControlButtons()
   scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y    = ED_SCROLL2_UP_YPOS;
   scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x  = ED_SCROLL2_DOWN_XPOS;
   scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y  = ED_SCROLL2_DOWN_YPOS;
-#else
-  scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_UP].x    = ED_SCROLL_UP_XPOS;
-  scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_UP].y    = ED_SCROLL_UP_YPOS;
-  scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].x  = ED_SCROLL_DOWN_XPOS;
-  scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].y  = ED_SCROLL_DOWN_YPOS;
-  scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_LEFT].x  = ED_SCROLL_LEFT_XPOS;
-  scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_LEFT].y  = ED_SCROLL_LEFT_YPOS;
-  scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
-  scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
-#endif
 
   /* create buttons for scrolling of drawing area and element list */
   for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
   {
     int id = scrollbutton_info[i].gadget_id;
-#if 1
     int graphic = scrollbutton_info[i].graphic;
     struct GraphicInfo *gd = &graphic_info[graphic];
-#endif
-    int x, y, width, height;
-    int gd_x1, gd_x2, gd_y1, gd_y2;
-
-#if 1
-    x = scrollbutton_pos[i].x;
-    y = scrollbutton_pos[i].y;
-#else
-    x = scrollbutton_info[i].x;
-    y = scrollbutton_info[i].y;
-#endif
-
-    event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
+    Bitmap *gd_bitmap = gd->bitmap;
+    int gd_x1 = gd->src_x;
+    int gd_y1 = gd->src_y;
+    int gd_x2 = gd->src_x + gd->pressed_xoffset;
+    int gd_y2 = gd->src_y + gd->pressed_yoffset;
+    int width  = gd->width;
+    int height = gd->height;
+    int x = scrollbutton_pos[i].x;
+    int y = scrollbutton_pos[i].y;
+    unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
 
     if (id == GADGET_ID_SCROLL_LIST_UP ||
        id == GADGET_ID_SCROLL_LIST_DOWN)
     {
       x += DX;
       y += DY;
-#if 1
-      width  = gd->width;
-      height = gd->height;
-      gd_x1 = gd->src_x;
-      gd_y1 = gd->src_y;
-      gd_x2 = gd->src_x + gd->pressed_xoffset;
-      gd_y2 = gd->src_y + gd->pressed_yoffset;
-#else
-      width = ED_SCROLLBUTTON2_XSIZE;
-      height = ED_SCROLLBUTTON2_YSIZE;
-      gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
-      gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
-      gd_x2 = gd_x1 - ED_SCROLLBUTTON2_XSIZE;
-      gd_y2 = gd_y1;
-#endif
     }
     else
     {
       x += SX;
       y += SY;
-#if 1
-      width  = gd->width;
-      height = gd->height;
-      gd_x1 = gd->src_x;
-      gd_y1 = gd->src_y;
-      gd_x2 = gd->src_x + gd->pressed_xoffset;
-      gd_y2 = gd->src_y + gd->pressed_yoffset;
-#else
-      width = ED_SCROLLBUTTON_XSIZE;
-      height = ED_SCROLLBUTTON_YSIZE;
-      gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
-      gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
-      gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
-      gd_y2 = gd_y1;
-#endif
     }
 
     gi = CreateGadget(GDI_CUSTOM_ID, id,
@@ -5620,71 +5453,43 @@ static void CreateControlButtons()
   /* create buttons for element list */
   for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
   {
-    struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_PALETTE_BUTTON];
+    int id = GADGET_ID_ELEMENTLIST_FIRST + i;
+    int graphic = IMG_EDITOR_PALETTE_BUTTON;
+    struct GraphicInfo *gd = &graphic_info[graphic];
+    Bitmap *gd_bitmap = gd->bitmap;
     Bitmap *deco_bitmap;
     int deco_x, deco_y, deco_xpos, deco_ypos;
-    int gd_xoffset, gd_yoffset;
-#if 1
-    int gd_x1, gd_y1, gd_x2, gd_y2;
-#else
-    int gd_x1, gd_x2, gd_y;
-#endif
-    int x = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
-    int y = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
-    int id = GADGET_ID_ELEMENTLIST_FIRST + i;
+    int gd_x1 = gd->src_x;
+    int gd_y1 = gd->src_y;
+    int gd_x2 = gd->src_x + gd->pressed_xoffset;
+    int gd_y2 = gd->src_y + gd->pressed_yoffset;
+    int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
+    int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
+    int x = DX + ED_ELEMENTLIST_XPOS + xx * gd->width;
+    int y = DY + ED_ELEMENTLIST_YPOS + yy * gd->height;
     int element = editor_elements[i];
+    int tile_size = (editor.palette.tile_size >= TILESIZE ? TILESIZE :
+                    MINI_TILESIZE);
+    unsigned int event_mask = GD_EVENT_RELEASED;
 
-    event_mask = GD_EVENT_RELEASED;
-
-#if 1
-    gd_xoffset = ED_ELEMENTLIST_XPOS + x * gd->width;
-    gd_yoffset = ED_ELEMENTLIST_YPOS + y * gd->height;
-
-    gd_x1 = gd->src_x;
-    gd_y1 = gd->src_y;
-    gd_x2 = gd->src_x + gd->pressed_xoffset;
-    gd_y2 = gd->src_y + gd->pressed_yoffset;
-
-    getMiniGraphicSource(el2edimg(element), &deco_bitmap, &deco_x, &deco_y);
-    deco_xpos = (gd->width  - MINI_TILEX) / 2;
-    deco_ypos = (gd->height - MINI_TILEY) / 2;
-#else
-    gd_xoffset = ED_ELEMENTLIST_XPOS + x * ED_ELEMENTLIST_XSIZE;
-    gd_yoffset = ED_ELEMENTLIST_YPOS + y * ED_ELEMENTLIST_YSIZE;
-
-    gd_x1 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS + ED_ELEMENTLIST_XSIZE;
-    gd_x2 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS;
-    gd_y  = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS;
-
-    getMiniGraphicSource(el2edimg(element), &deco_bitmap, &deco_x, &deco_y);
-    deco_xpos = (ED_ELEMENTLIST_XSIZE - MINI_TILEX) / 2;
-    deco_ypos = (ED_ELEMENTLIST_YSIZE - MINI_TILEY) / 2;
-#endif
+    getElementListGraphicSource(element, &deco_bitmap, &deco_x, &deco_y);
+    deco_xpos = (gd->width  - tile_size) / 2;
+    deco_ypos = (gd->height - tile_size) / 2;
 
     gi = CreateGadget(GDI_CUSTOM_ID, id,
                      GDI_CUSTOM_TYPE_ID, i,
                      GDI_INFO_TEXT, getElementInfoText(element),
-                     GDI_X, DX + gd_xoffset,
-                     GDI_Y, DY + gd_yoffset,
-#if 1
+                     GDI_X, x,
+                     GDI_Y, y,
                      GDI_WIDTH, gd->width,
                      GDI_HEIGHT, gd->height,
-#else
-                     GDI_WIDTH, ED_ELEMENTLIST_XSIZE,
-                     GDI_HEIGHT, ED_ELEMENTLIST_YSIZE,
-#endif
                      GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
                      GDI_STATE, GD_BUTTON_UNPRESSED,
-#if 1
-                     GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
-                     GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
-#else
-                     GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y,
-                     GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y,
-#endif
+                     GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
+                     GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
                      GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
                      GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
-                     GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
+                     GDI_DECORATION_SIZE, tile_size, tile_size,
                      GDI_DECORATION_SHIFTING, 1, 1,
                      GDI_EVENT_MASK, event_mask,
                      GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
@@ -5703,10 +5508,6 @@ static void CreateCounterButtons()
   int max_infotext_len = getMaxInfoTextLength();
   int i;
 
-  /* these values are not constant, but can change at runtime */
-  counterbutton_info[ED_COUNTER_ID_SELECT_LEVEL].x = DX + 5 - SX;
-  counterbutton_info[ED_COUNTER_ID_SELECT_LEVEL].y = DY + 3 - SY;
-
   for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
   {
     int j;
@@ -5739,7 +5540,6 @@ static void CreateCounterButtons()
 
       if (i == ED_COUNTER_ID_SELECT_LEVEL)
       {
-#if 1
        int graphic = (j == 0 ?
                       IMG_EDITOR_BUTTON_GFX_PREV_LEVEL :
                       IMG_EDITOR_BUTTON_GFX_NEXT_LEVEL);
@@ -5749,9 +5549,16 @@ static void CreateCounterButtons()
 
        event_mask |= GD_EVENT_RELEASED;
 
-       if (j == 1)
-         x += 2 * ED_GADGET_DISTANCE;
-       y += ED_GADGET_DISTANCE;
+       if (j == 0)
+       {
+         x = DX + editor.button.prev_level.x;
+         y = DY + editor.button.prev_level.y;
+       }
+       else
+       {
+         x = DX + editor.button.next_level.x;
+         y = DY + editor.button.next_level.y;
+       }
 
        gd_x1 = gd->src_x;
        gd_y1 = gd->src_y;
@@ -5759,24 +5566,6 @@ static void CreateCounterButtons()
        gd_y2 = gd->src_y + gd->pressed_yoffset;
        x_size = gd->width;
        y_size = gd->height;
-#else
-       int sid = (j == 0 ?
-                  ED_SCROLLBUTTON_ID_AREA_LEFT :
-                  ED_SCROLLBUTTON_ID_AREA_RIGHT);
-
-       event_mask |= GD_EVENT_RELEASED;
-
-       if (j == 1)
-         x += 2 * ED_GADGET_DISTANCE;
-       y += ED_GADGET_DISTANCE;
-
-       gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[sid].gd_x;
-       gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
-       gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[sid].gd_y;
-       gd_y2 = gd_y1;
-       x_size = ED_SCROLLBUTTON_XSIZE;
-       y_size = ED_SCROLLBUTTON_YSIZE;
-#endif
       }
       else
       {
@@ -5822,24 +5611,28 @@ static void CreateCounterButtons()
        int font_type = FONT_INPUT_1;
        int font_type_active = FONT_INPUT_1_ACTIVE;
        int gd_width = ED_WIN_COUNT_XSIZE;
+       int border_size = ED_BORDER_SIZE;
 
        id = counterbutton_info[i].gadget_id_text;
        event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
 
        if (i == ED_COUNTER_ID_SELECT_LEVEL)
        {
+         int graphic = IMG_EDITOR_INPUT_GFX_LEVEL_NUMBER;
+         struct GraphicInfo *gd = &graphic_info[graphic];
+
+         gd_bitmap = gd->bitmap;
+
+         x = DX + editor.input.level_number.x;
+         y = DY + editor.input.level_number.y;
+
+         gd_x = gd->src_x;
+         gd_y = gd->src_y;
+         gd_width = gd->width;
+         border_size = gd->border_size;
+
          font_type = FONT_LEVEL_NUMBER;
-#if 1
          font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
-#else
-         font_type_active = FONT_LEVEL_NUMBER;
-#endif
-         x += 2 * ED_GADGET_DISTANCE;
-         y -= ED_GADGET_DISTANCE;
-
-         gd_x = DOOR_GFX_PAGEX6 + ED_WIN_COUNT2_XPOS;
-         gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT2_YPOS;
-         gd_width = ED_WIN_COUNT2_XSIZE;
        }
        else
        {
@@ -5861,7 +5654,7 @@ static void CreateCounterButtons()
                          GDI_TEXT_FONT_ACTIVE, font_type_active,
                          GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
                          GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
-                         GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
+                         GDI_BORDER_SIZE, border_size, border_size,
                          GDI_DESIGN_WIDTH, gd_width,
                          GDI_EVENT_MASK, event_mask,
                          GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
@@ -6085,9 +5878,11 @@ static void CreateSelectboxGadgets()
                      GDI_Y, y,
                      GDI_TYPE, GD_TYPE_SELECTBOX,
                      GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
+                     GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
                      GDI_TEXT_SIZE, selectbox_info[i].size,
                      GDI_TEXT_FONT, FONT_INPUT_1,
                      GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
+                     GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
                      GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
                      GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
                      GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
@@ -6257,7 +6052,6 @@ static void CreateScrollbarGadgets()
   int i;
 
   /* these values are not constant, but can change at runtime */
-#if 1
   scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
     SX + ED_SCROLL_HORIZONTAL_XPOS;
   scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
@@ -6296,57 +6090,13 @@ static void CreateScrollbarGadgets()
   scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = DY;
   scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width  = DXSIZE;
   scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = DYSIZE;
-#else
-  scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
-    SX + ED_SCROLL_HORIZONTAL_XPOS;
-  scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
-    SY + ED_SCROLL_HORIZONTAL_YPOS;
-  scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
-    ED_SCROLL_HORIZONTAL_XSIZE;
-  scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
-    ED_SCROLL_HORIZONTAL_YSIZE;
-  scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x      = SX;
-  scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y      = SY;
-  scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width  = SXSIZE;
-  scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
-
-  scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
-    SX + ED_SCROLL_VERTICAL_XPOS;
-  scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
-    SY + ED_SCROLL_VERTICAL_YPOS;
-  scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
-    ED_SCROLL_VERTICAL_XSIZE;
-  scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
-    ED_SCROLL_VERTICAL_YSIZE;
-  scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x      = SX;
-  scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y      = SY;
-  scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width  = SXSIZE;
-  scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
-
-  scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
-    DX + ED_SCROLL2_VERTICAL_XPOS;
-  scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
-    DY + ED_SCROLL2_VERTICAL_YPOS;
-  scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
-    ED_SCROLL2_VERTICAL_XSIZE;
-  scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
-    ED_SCROLL2_VERTICAL_YSIZE;
-  scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = DX;
-  scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = DY;
-  scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width  = DXSIZE;
-  scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = DYSIZE;
-#endif
 
   for (i = 0; i < ED_NUM_SCROLLBARS; i++)
   {
     int id = scrollbar_info[i].gadget_id;
-#if 1
     int graphic = scrollbar_info[i].graphic;
     struct GraphicInfo *gd = &graphic_info[graphic];
     Bitmap *gd_bitmap = gd->bitmap;
-#else
-    Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
-#endif
     int gd_x1, gd_x2, gd_y1, gd_y2;
     struct GadgetInfo *gi;
     int items_max, items_visible, item_position;
@@ -6376,48 +6126,26 @@ static void CreateScrollbarGadgets()
 
     event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
 
-#if 1
     gd_x1 = gd->src_x;
     gd_y1 = gd->src_y;
     gd_x2 = gd->src_x + gd->pressed_xoffset;
     gd_y2 = gd->src_y + gd->pressed_yoffset;
-#else
-    gd_x1 = DOOR_GFX_PAGEX8 + scrollbar_info[i].gd_x;
-    gd_x2 = (gd_x1 - (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL ?
-                     scrollbar_info[i].height : scrollbar_info[i].width));
-    gd_y1 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
-    gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
-#endif
 
     gi = CreateGadget(GDI_CUSTOM_ID, id,
                      GDI_CUSTOM_TYPE_ID, i,
                      GDI_INFO_TEXT, scrollbar_info[i].infotext,
-#if 1
                      GDI_X, scrollbar_pos[i].x,
                      GDI_Y, scrollbar_pos[i].y,
                      GDI_WIDTH, scrollbar_pos[i].width,
                      GDI_HEIGHT, scrollbar_pos[i].height,
-#else
-                     GDI_X, scrollbar_info[i].x,
-                     GDI_Y, scrollbar_info[i].y,
-                     GDI_WIDTH, scrollbar_info[i].width,
-                     GDI_HEIGHT, scrollbar_info[i].height,
-#endif
                      GDI_TYPE, scrollbar_info[i].type,
                      GDI_SCROLLBAR_ITEMS_MAX, items_max,
                      GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
                      GDI_SCROLLBAR_ITEM_POSITION, item_position,
-#if 1
                      GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
                      GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
                      GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
                      GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
-#else
-                     GDI_WHEEL_AREA_X, scrollbar_info[i].wheel_x,
-                     GDI_WHEEL_AREA_Y, scrollbar_info[i].wheel_y,
-                     GDI_WHEEL_AREA_WIDTH, scrollbar_info[i].wheel_width,
-                     GDI_WHEEL_AREA_HEIGHT, scrollbar_info[i].wheel_height,
-#endif
                      GDI_STATE, GD_BUTTON_UNPRESSED,
                      GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
                      GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
@@ -6682,6 +6410,9 @@ static void MapControlButtons()
   for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
     MapGadget(level_editor_gadget[i]);
 
+  /* map toolbox buttons (element properties button) */
+  MapGadget(level_editor_gadget[ED_NUM_CTRL1_4_BUTTONS]);
+
   /* map buttons to select elements */
   for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
     MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
@@ -6939,26 +6670,27 @@ static void UnmapLevelEditorToolboxCustomGadgets()
 
 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
 {
-  Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
   int i;
 
   for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
   {
     if (i != GADGET_ID_SINGLE_ITEMS &&
-       i != GADGET_ID_PROPERTIES &&
        i != GADGET_ID_PICK_ELEMENT)
     {
       struct GadgetInfo *gi = level_editor_gadget[i];
 
       if (map)
+      {
        MapGadget(gi);
+      }
       else
       {
+       int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
+       struct GraphicInfo *gd = &graphic_info[graphic];
+
        UnmapGadget(gi);
 
-       BlitBitmap(gd_bitmap, drawto,
-                  DOOR_GFX_PAGEX6 + ED_CTRL_NO_BUTTONS_GFX_XPOS,
-                  DOOR_GFX_PAGEY1 + ED_CTRL_NO_BUTTONS_GFX_YPOS,
+       BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
                   gi->width, gi->height, gi->x, gi->y);
 
        redraw_mask |= REDRAW_DOOR_3;
@@ -6986,16 +6718,10 @@ static void UnmapLevelEditorFieldGadgets()
 {
   int i;
 
-#if 1
   for (i = 0; i < num_editor_gadgets; i++)
     if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
                          level_editor_gadget[i]->y))
       UnmapGadget(level_editor_gadget[i]);
-#else
-  for (i = 0; i < NUM_EDITOR_GADGETS; i++)
-    if (level_editor_gadget[i]->x < SX + SXSIZE)
-      UnmapGadget(level_editor_gadget[i]);
-#endif
 }
 
 void UnmapLevelEditorGadgets()
@@ -7033,13 +6759,6 @@ static boolean LevelChanged()
   boolean field_changed = FALSE;
   int x, y;
 
-#if 1
-  /* changed read-only levels can now be saved in personal level set */
-#else
-  if (leveldir_current->readonly)
-    return FALSE;
-#endif
-
   for (y = 0; y < lev_fieldy; y++) 
     for (x = 0; x < lev_fieldx; x++)
       if (Feld[x][y] != level.field[x][y])
@@ -7745,51 +7464,21 @@ static boolean playfield_area_changed = FALSE;
 
 void DrawLevelEd()
 {
-  int old_sx = SX;
-  int old_sy = SY;
-  int old_sxsize = SXSIZE;
-  int old_sysize = SYSIZE;
-
   StopAnimation();
 
   CloseDoor(DOOR_CLOSE_ALL);
 
-#if 1
   FadeOut(REDRAW_FIELD);
-  // FadeOut(REDRAW_ALL);
-#endif
 
-#if 1
   /* needed after playing if editor playfield area has different size */
   ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
-#endif
 
-#if 1
   /* needed if different viewport properties defined for editor */
   ChangeViewportPropertiesIfNeeded();
-#endif
 
-  if (old_sx != SX ||
-      old_sy != SY ||
-      old_sxsize != SXSIZE ||
-      old_sysize != SYSIZE)
-  {
-    playfield_area_changed = TRUE;
+  playfield_area_changed = DrawingAreaChanged();
 
-#if 0
-    printf("::: %d, %d, %d, %d != %d, %d, %d, %d\n",
-          old_sx, old_sy, old_sxsize, old_sysize,
-          SX, SY, SXSIZE, SYSIZE);
-#endif
-  }
-  else
-    playfield_area_changed = FALSE;
-
-#if 1
   OpenDoor(DOOR_OPEN_1 | DOOR_OPEN_2 | DOOR_NO_DELAY);
-#else
-  OpenDoor(DOOR_OPEN_2 | DOOR_NO_DELAY);
-#endif
 
 #if DEBUG
   CheckElementDescriptions();
@@ -7814,20 +7503,14 @@ void DrawLevelEd()
     level_ypos = -1;
   }
 
+  /* needed for gadgets drawn on background (like palette scrollbar) */
+  SetDoorBackgroundImage(IMG_UNDEFINED);
+
   /* copy default editor door content to main double buffer */
-#if 1
   BlitBitmap(graphic_info[IMG_BACKGROUND_PALETTE].bitmap, drawto,
             graphic_info[IMG_BACKGROUND_PALETTE].src_x,
             graphic_info[IMG_BACKGROUND_PALETTE].src_y,
             DXSIZE, DYSIZE, DX, DY);
-#else
-  BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
-            DOOR_GFX_PAGEX6, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
-#endif
-
-#if 0
-  printf("::: %d, %d  /  %d, %d\n", VX, VY, EX, EY);
-#endif
 
   /* draw bigger door */
   DrawSpecialEditorDoor();
@@ -7836,55 +7519,25 @@ void DrawLevelEd()
   BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
             DOOR_GFX_PAGEX8, 236, EXSIZE, EYSIZE, EX, EY);
 
-  redraw_mask |= REDRAW_ALL;
+  // redraw_mask |= REDRAW_ALL;
 
-#if 1
   FreeLevelEditorGadgets();
   CreateLevelEditorGadgets();
-#endif
 
   ReinitializeElementList();           /* update dynamic level element list */
   ReinitializeElementListButtons();    /* custom element may look different */
 
   InitElementPropertiesGfxElement();
 
-#if 1
   UnmapAllGadgets();
-#else
-  UnmapTapeButtons();
-#endif
   MapControlButtons();
 
-#if 0
-  FadeOut(REDRAW_FIELD);
-#endif
-
   DrawEditModeWindow();
 
-#if 1
   FadeIn(playfield_area_changed ? REDRAW_ALL : REDRAW_FIELD);
-#else
-  FadeIn(REDRAW_FIELD);
-  // FadeIn(REDRAW_ALL);
-#endif
 
   /* copy actual editor door content to door double buffer for OpenDoor() */
-#if 1
   BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
-#else
-  BlitBitmap(drawto, bitmap_db_door,
-            DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
-#endif
-
-#if 0
-  /* draw new control window (with border) to window */
-  redraw_mask |= REDRAW_ALL;
-  BackToFront();
-#endif
-
-#if 0
-  OpenDoor(DOOR_OPEN_1);
-#endif
 }
 
 static void AdjustDrawingAreaGadgets()
@@ -7922,32 +7575,20 @@ static void AdjustDrawingAreaGadgets()
   ed_fieldy = (ed_ysize < MAX_ED_FIELDY ? ed_ysize : max_ed_fieldy);
 
   ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
-              GDI_WIDTH, ed_fieldx * MINI_TILEX,
-              GDI_HEIGHT, ed_fieldy * MINI_TILEY,
               GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
               GDI_END);
 
   xoffset = (ed_fieldx == MAX_ED_FIELDX ? ED_SCROLLBUTTON_XSIZE : 0);
   yoffset = (ed_fieldy == MAX_ED_FIELDY ? ED_SCROLLBUTTON_YSIZE : 0);
 
-#if 1
   x = SX + scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x + xoffset;
   y = SX + scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y + yoffset;
-#else
-  x = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].x + xoffset;
-  y = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].y + yoffset;
-#endif
 
   ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT], GDI_X, x, GDI_END);
   ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN], GDI_Y, y, GDI_END);
 
-#if 1
   width  = scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width + xoffset;
   height = scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height + yoffset;
-#else
-  width  = scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width + xoffset;
-  height = scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].height + yoffset;
-#endif
 
   ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
               GDI_WIDTH, width,
@@ -8097,39 +7738,41 @@ static void ModifyEditorElementList()
 
     UnmapGadget(gi);
 
-    getMiniGraphicSource(el2edimg(element), &gd->bitmap, &gd->x, &gd->y);
+    getElementListGraphicSource(element, &gd->bitmap, &gd->x, &gd->y);
+
     ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
 
     MapGadget(gi);
   }
 }
 
+static void DrawDrawingElement(int element, struct EditorPaletteElementInfo *e)
+{
+  int graphic = el2edimg(element);
+  int tile_size = (e->tile_size >= TILESIZE ? TILESIZE : MINI_TILESIZE);
+
+  DrawSizedGraphicExt(drawto, DX + e->x, DY + e->y, graphic, 0, tile_size);
+}
+
 static void PickDrawingElement(int button, int element)
 {
+  struct
+  {
+    int *new_element;
+    struct EditorPaletteElementInfo *e;
+  } de, drawing_elements[] =
+  {
+    { &new_element1,   &editor.palette.element_left    },
+    { &new_element2,   &editor.palette.element_middle  },
+    { &new_element3,   &editor.palette.element_right   },
+  };
+
   if (button < 1 || button > 3)
     return;
 
-  if (button == 1)
-  {
-    new_element1 = element;
-    DrawMiniGraphicExt(drawto,
-                      DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
-                      el2edimg(new_element1));
-  }
-  else if (button == 2)
-  {
-    new_element2 = element;
-    DrawMiniGraphicExt(drawto,
-                      DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
-                      el2edimg(new_element2));
-  }
-  else
-  {
-    new_element3 = element;
-    DrawMiniGraphicExt(drawto,
-                      DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
-                      el2edimg(new_element3));
-  }
+  de = drawing_elements[button - 1];
+
+  DrawDrawingElement((*de.new_element = element), de.e);
 
   redraw_mask |= REDRAW_DOOR_1;
 }
@@ -8179,10 +7822,6 @@ static void DrawLevelInfoTabulatorGadgets()
   Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
   int id_first = ED_TEXTBUTTON_ID_LEVELINFO_LEVEL;
   int id_last  = ED_TEXTBUTTON_ID_LEVELINFO_EDITOR;
-#if 1
-#else
-  int max_tabs = 2;
-#endif
   int i;
 
   for (i = id_first; i <= id_last; i++)
@@ -8202,19 +7841,11 @@ static void DrawLevelInfoTabulatorGadgets()
     MapTextbuttonGadget(i);
   }
 
-#if 1
   /* draw little border line below tabulator buttons */
   if (tab_color != BLACK_PIXEL)                        /* black => transparent */
     FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
                  getTabulatorBarWidth(), ED_GADGET_DISTANCE,
                  tab_color);
-#else
-  /* draw little border line below tabulator buttons */
-  if (tab_color != BLACK_PIXEL)                        /* black => transparent */
-    FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
-                 max_tabs * gd_gi1->width + (max_tabs -1) * ED_GADGET_DISTANCE,
-                 ED_GADGET_DISTANCE, tab_color);
-#endif
 }
 
 static void DrawPropertiesTabulatorGadgets()
@@ -8226,10 +7857,6 @@ static void DrawPropertiesTabulatorGadgets()
   Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
   int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
   int id_last  = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
-#if 1
-#else
-  int max_tabs = 4;
-#endif
   int i;
 
   /* draw two config tabulators for player elements */
@@ -8263,19 +7890,11 @@ static void DrawPropertiesTabulatorGadgets()
     MapTextbuttonGadget(i);
   }
 
-#if 1
   /* draw little border line below tabulator buttons */
   if (tab_color != BLACK_PIXEL)                        /* black => transparent */
     FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
                  getTabulatorBarWidth(), ED_GADGET_DISTANCE,
                  tab_color);
-#else
-  /* draw little border line below tabulator buttons */
-  if (tab_color != BLACK_PIXEL)                        /* black => transparent */
-    FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height + 1,
-                 max_tabs * gd_gi1->width + (max_tabs -1) * ED_GADGET_DISTANCE,
-                 ED_GADGET_DISTANCE, tab_color);
-#endif
 }
 
 static void DrawLevelInfoLevel()
@@ -8324,19 +7943,7 @@ static void DrawLevelInfoWindow()
   SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
   ClearField();
 
-#if 1
-#if 1
   DrawTextSCentered(ED_SETTINGS1_YPOS, FONT_TITLE_1, "Global Settings");
-#else
-  DrawTextSCentered(ED_SETTINGS1_YPOS, FONT_TITLE_1, "Level Settings");
-  DrawTextSCentered(ED_SETTINGS2_YPOS, FONT_TITLE_1, "Editor Settings");
-#endif
-#else
-  DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
-          "Level Settings", FONT_TITLE_1);
-  DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS2_YPOS,
-          "Editor Settings", FONT_TITLE_1);
-#endif
 
   DrawLevelInfoTabulatorGadgets();
 
@@ -8574,21 +8181,11 @@ static int PrintElementDescriptionFromFile(char *filename, int start_line)
   int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
   int max_lines_drawable = max_lines_per_screen - start_line;
 
-#if 0
-  printf("::: SYSIZE == %d [%d / %d / %d]\n", SYSIZE,
-        max_chars_per_line, max_lines_per_screen, max_lines_drawable);
-#endif
-
   if (start_line >= max_lines_per_screen)
     return FALSE;
 
-#if 1
   return DrawTextFile(sx, sy, filename, font_nr, max_chars_per_line, -1,
                      max_lines_drawable, 0, -1, TRUE, FALSE, FALSE);
-#else
-  return DrawTextFile(sx, sy, filename, font_nr, max_chars_per_line, -1,
-                     max_lines_per_screen, 0, -1, TRUE, FALSE, FALSE);
-#endif
 }
 
 static void DrawPropertiesInfo()
@@ -9310,12 +8907,7 @@ static void DrawPropertiesWindow()
   SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
   ClearField();
 
-#if 1
   DrawTextSCentered(ED_SETTINGS1_YPOS, FONT_TITLE_1, "Element Settings");
-#else
-  DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
-          "Element Settings", FONT_TITLE_1);
-#endif
 
   FrameCounter = 0;    /* restart animation frame counter */
 
@@ -10539,11 +10131,7 @@ static void SelectArea(int from_x, int from_y, int to_x, int to_y,
 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
                         int button, int mode)
 {
-#if 1
   static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
-#else
-  static short brush_buffer[MAX_ED_FIELDX][MAX_ED_FIELDY];
-#endif
   static int brush_width, brush_height;
   static int last_cursor_x = -1, last_cursor_y = -1;
   static boolean delete_old_brush;
@@ -10574,7 +10162,10 @@ static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
        else if (element >= NUM_FILE_ELEMENTS)
          element_mapped = EL_UNKNOWN;
 
-       printf("%c%03d", (mode == CB_DUMP_BRUSH ? '`' : '¸'), element_mapped);
+       // dump brush as level sketch text for the R'n'D forum:
+       // - large tiles: `xxx (0x60 ASCII)
+       // - small tiles: ¸xxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
+       printf("%s%03d", (mode == CB_DUMP_BRUSH ? "`" : "¸"), element_mapped);
       }
 
       printf("\n");
@@ -10725,9 +10316,6 @@ static int DrawLevelText(int sx, int sy, char letter, int mode)
 {
   static short delete_buffer[MAX_LEV_FIELDX];
   static int start_sx;
-#if 0
-  static int start_sy;
-#endif
   static int last_sx, last_sy;
   static boolean typing = FALSE;
   int letter_element = EL_CHAR_ASCII0 + letter;
@@ -10736,11 +10324,11 @@ static int DrawLevelText(int sx, int sy, char letter, int mode)
   /* map lower case letters to upper case and convert special characters */
   if (letter >= 'a' && letter <= 'z')
     letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
-  else if (letter == 'ä' || letter == 'Ä')
+  else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
     letter_element = EL_CHAR_AUMLAUT;
-  else if (letter == 'ö' || letter == 'Ö')
+  else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
     letter_element = EL_CHAR_OUMLAUT;
-  else if (letter == 'ü' || letter == 'Ü')
+  else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
     letter_element = EL_CHAR_UUMLAUT;
   else if (letter == '^')
     letter_element = EL_CHAR_COPYRIGHT;
@@ -10770,9 +10358,6 @@ static int DrawLevelText(int sx, int sy, char letter, int mode)
 
       typing = TRUE;
       start_sx = sx;
-#if 0
-      start_sy = sy;
-#endif
       last_sx = sx;
       last_sy = sy;
       DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
@@ -10788,6 +10373,10 @@ static int DrawLevelText(int sx, int sy, char letter, int mode)
     case TEXT_WRITECHAR:
       if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
       {
+       if (new_element1 >= EL_STEEL_CHAR_START &&
+           new_element1 <= EL_STEEL_CHAR_END)
+         letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
+
        delete_buffer[sx - start_sx] = Feld[lx][ly];
        Feld[lx][ly] = letter_element;
 
@@ -10904,9 +10493,7 @@ static void RandomPlacement(int new_element)
   int num_percentage, num_elements;
   int x, y;
 
-#if 1
   ResetIntelliDraw();
-#endif
 
   /* determine number of free positions for randomly placing the new element */
   for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
@@ -10931,11 +10518,7 @@ static void RandomPlacement(int new_element)
     for (x = 0; x < lev_fieldx; x++)
       for (y = 0; y < lev_fieldy; y++)
        if (free_position[x][y])
-#if 1
          SetElement(x, y, new_element);
-#else
-         Feld[x][y] = new_element;
-#endif
   }
   else
   {
@@ -10948,11 +10531,7 @@ static void RandomPlacement(int new_element)
       if (free_position[x][y])
       {
        free_position[x][y] = FALSE;
-#if 1
        SetElement(x, y, new_element);
-#else
-       Feld[x][y] = new_element;
-#endif
        num_elements--;
       }
     }
@@ -11071,10 +10650,6 @@ static void HandleDrawingAreas(struct GadgetInfo *gi)
          if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
              !inside_drawing_area)
            DeleteBrushFromCursor();
-
-#if 0
-         ResetIntelliDraw();
-#endif
        }
 
        if (!button || button_release_event)
@@ -11082,50 +10657,20 @@ static void HandleDrawingAreas(struct GadgetInfo *gi)
 
        if (draw_with_brush)
        {
-#if 0
-         if (!button_release_event)
-#endif
-           CopyBrushToLevel(sx, sy, button);
+         CopyBrushToLevel(sx, sy, button);
        }
-#if 1
        else
-#else
-       else if (new_element != Feld[lx][ly])
-#endif
        {
          if (new_element == EL_PLAYER_1)
          {
            /* remove player at old position */
            for (y = 0; y < lev_fieldy; y++)
-           {
              for (x = 0; x < lev_fieldx; x++)
-             {
                if (Feld[x][y] == EL_PLAYER_1)
-               {
-#if 1
                  SetElement(x, y, EL_EMPTY);
-#else
-                 Feld[x][y] = EL_EMPTY;
-#if 1
-                 if (IN_ED_FIELD(x - level_xpos, y - level_ypos))
-                   DrawMiniElement(x - level_xpos, y - level_ypos, EL_EMPTY);
-#else
-                 if (x - level_xpos >= 0 && x - level_xpos < ed_fieldx &&
-                     y - level_ypos >= 0 && y - level_ypos < ed_fieldy)
-                   DrawMiniElement(x - level_xpos, y - level_ypos, EL_EMPTY);
-#endif
-#endif
-               }
-             }
-           }
          }
 
-#if 1
          SetElementButton(lx, ly, new_element, button);
-#else
-         Feld[lx][ly] = new_element;
-         DrawMiniElement(sx, sy, new_element);
-#endif
        }
       }
       else
@@ -11383,14 +10928,9 @@ static void HandleTextAreaGadgets(struct GadgetInfo *gi)
 {
   int type_id = gi->custom_type_id;
 
-#if 1
   strncpy(textarea_info[type_id].value, gi->textarea.value,
          MAX_ENVELOPE_TEXT_LEN);
   textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
-#else
-  /* !!! BUGGY !!! MAX_ENVELOPE_TEXT_LEN != MAX_GADGET_TEXTSIZE !!! */
-  strcpy(textarea_info[type_id].value, gi->textarea.value);
-#endif
 
   level.changed = TRUE;
 }
@@ -11613,7 +11153,6 @@ static void HandleControlButtons(struct GadgetInfo *gi)
 
   if (id < ED_NUM_CTRL1_BUTTONS &&
       id != GADGET_ID_SINGLE_ITEMS &&
-      id != GADGET_ID_PROPERTIES &&
       id != GADGET_ID_PICK_ELEMENT &&
       edit_mode != ED_MODE_DRAWING &&
       drawing_function != GADGET_ID_PICK_ELEMENT &&
@@ -11739,6 +11278,27 @@ static void HandleControlButtons(struct GadgetInfo *gi)
 
       break;
 
+    case GADGET_ID_PROPERTIES:
+      if (edit_mode != ED_MODE_PROPERTIES)
+      {
+       properties_element = new_element;
+       DrawPropertiesWindow();
+       edit_mode = ED_MODE_PROPERTIES;
+
+       last_level_drawing_function = drawing_function;
+       ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
+                     MB_LEFTBUTTON);
+      }
+      else
+      {
+       DrawDrawingWindow();
+       edit_mode = ED_MODE_DRAWING;
+
+       ClickOnGadget(level_editor_gadget[last_level_drawing_function],
+                     MB_LEFTBUTTON);
+      }
+      break;
+
     case GADGET_ID_WRAP_LEFT:
       WrapLevel(-step, 0);
       break;
@@ -11775,25 +11335,8 @@ static void HandleControlButtons(struct GadgetInfo *gi)
       RandomPlacement(new_element);
       break;
 
-    case GADGET_ID_PROPERTIES:
-      if (edit_mode != ED_MODE_PROPERTIES)
-      {
-       properties_element = new_element;
-       DrawPropertiesWindow();
-       edit_mode = ED_MODE_PROPERTIES;
-
-       last_level_drawing_function = drawing_function;
-       ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
-                     MB_LEFTBUTTON);
-      }
-      else
-      {
-       DrawDrawingWindow();
-       edit_mode = ED_MODE_DRAWING;
-
-       ClickOnGadget(level_editor_gadget[last_level_drawing_function],
-                     MB_LEFTBUTTON);
-      }
+    case GADGET_ID_ZOOM:
+      printf("::: zoom button pressed with mouse button %d\n", button);
       break;
 
     case GADGET_ID_CUSTOM_COPY_FROM:
@@ -11934,20 +11477,10 @@ static void HandleControlButtons(struct GadgetInfo *gi)
 
       CloseDoor(DOOR_CLOSE_ALL);
 
-#if 0
-      BackToFront();           /* force redraw of undrawn special door */
-#endif
-
-#if 1
       /* needed before playing if editor playfield area has different size */
       ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
 
-      redraw_mask = REDRAW_ALL;
-#endif
-
-#if 0
-      DrawCompleteVideoDisplay();
-#endif
+      // redraw_mask = REDRAW_ALL;
 
       level_editor_test_game = TRUE;
 
@@ -12159,6 +11692,10 @@ void HandleLevelEditorKeyInput(Key key)
 
     if (id != GADGET_ID_NONE)
       ClickOnGadget(level_editor_gadget[id], button);
+    else if (letter >= '1' && letter <= '3')
+      ClickOnGadget(level_editor_gadget[GADGET_ID_PROPERTIES], letter - '0');
+    else if (letter == '?')
+      ClickOnGadget(level_editor_gadget[GADGET_ID_PROPERTIES], button);
     else if (letter == '.')
       ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
     else if (key == KSYM_Return ||
@@ -12167,7 +11704,7 @@ void HandleLevelEditorKeyInput(Key key)
       ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
     else
       for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
-       if (letter && letter == control_info[i].shortcut)
+       if (letter && letter == controlbutton_info[i].shortcut)
          if (!anyTextGadgetActive())
            ClickOnGadget(level_editor_gadget[i], button);
   }
@@ -12222,7 +11759,7 @@ void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
 
   if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
   {
-    int key = control_info[gi->custom_id].shortcut;
+    int key = controlbutton_info[gi->custom_id].shortcut;
 
     if (key)
     {
@@ -12425,41 +11962,21 @@ void RequestExitLevelEditor(boolean ask_if_level_has_changed,
       Request("Level has changed! Exit without saving?",
              REQ_ASK | REQ_STAY_OPEN))
   {
-#if 1
-    // CloseDoor(DOOR_CLOSE_1);
     SetDoorState(DOOR_CLOSE_2);
-#else
-    CloseDoor(DOOR_CLOSE_1);
-    SetDoorState(DOOR_CLOSE_2);
-#endif
 
-#if 1
     if (quick_quit)
       FadeSkipNextFadeIn();
-#else
-    if (quick_quit)
-      fading = fading_none;
-#endif
 
     game_status = GAME_MODE_MAIN;
-#if 1
+
     DrawAndFadeInMainMenu(playfield_area_changed ? REDRAW_ALL : REDRAW_FIELD);
-#else
-#if 1
-    DrawAndFadeInMainMenu(REDRAW_FIELD);
-#else
-    DrawMainMenu();
-#endif
-#endif
   }
   else
   {
-#if 1
-    // CloseDoor(DOOR_CLOSE_1);
-    OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
-#else
-    CloseDoor(DOOR_CLOSE_1);
-    OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
-#endif
+    if (!global.use_envelope_request)
+    {
+      CloseDoor(DOOR_CLOSE_1);
+      OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
+    }
   }
 }