rnd-20030218-3-src
[rocksndiamonds.git] / src / libgame / gadgets.c
index 9dfea83896e25a33d61c3a90899d8e28e40a158d..2405c137aeab6bb16af471e140241587677b784b 100644 (file)
@@ -136,7 +136,7 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct)
        char cursor_string[3];
        char text[MAX_GADGET_TEXTSIZE + 1];
        int font_type = gi->text.font_type;
-       int font_width = getFontWidth(FS_SMALL, font_type);
+       int font_width = getFontWidth(font_type);
        int border = gi->border.size;
        strcpy(text, gi->text.value);
        strcat(text, " ");
@@ -159,7 +159,7 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct)
        /* gadget text value */
        DrawTextExt(drawto,
                    gi->x + border, gi->y + border, text,
-                   FS_SMALL, font_type, FONT_OPAQUE);
+                   font_type, FONT_OPAQUE);
 
        cursor_letter = gi->text.value[gi->text.cursor_position];
        cursor_string[0] = '~';
@@ -171,7 +171,7 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct)
          DrawTextExt(drawto,
                      gi->x + border + gi->text.cursor_position * font_width,
                      gi->y + border, cursor_string,
-                     FS_SMALL, font_type, FONT_OPAQUE);
+                     font_type, FONT_OPAQUE);
       }
       break;
 
@@ -202,15 +202,16 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct)
          BlitBitmapOnBackground(gd->bitmap, drawto,
                                 gd->x, gd->y + gi->border.size,
                                 gi->width, design_body,
-                                xpos, ypos + gi->border.size
-                                + i * design_body);
+                                xpos,
+                                ypos + gi->border.size + i * design_body);
 
        /* remaining middle part of gadget */
        if (step_size_remain > 0)
          BlitBitmapOnBackground(gd->bitmap, drawto,
                                 gd->x,  gd->y + gi->border.size,
                                 gi->width, step_size_remain,
-                                xpos, ypos + gi->border.size
+                                xpos,
+                                ypos + gi->border.size
                                 + num_steps * design_body);
 
        /* lower part of gadget */
@@ -234,33 +235,37 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct)
        int step_size_remain = size_body - num_steps * design_body;
 
        /* clear scrollbar area */
-       ClearRectangle(backbuffer, gi->x, gi->y, gi->width, gi->height);
+       ClearRectangleOnBackground(backbuffer, gi->x, gi->y,
+                                  gi->width, gi->height);
 
        /* left part of gadget */
-       BlitBitmap(gd->bitmap, drawto,
-                  gd->x, gd->y,
-                  gi->border.size, gi->height,
-                  xpos, ypos);
+       BlitBitmapOnBackground(gd->bitmap, drawto,
+                              gd->x, gd->y,
+                              gi->border.size, gi->height,
+                              xpos, ypos);
 
        /* middle part of gadget */
        for (i=0; i<num_steps; i++)
-         BlitBitmap(gd->bitmap, drawto,
-                    gd->x + gi->border.size, gd->y,
-                    design_body, gi->height,
-                    xpos + gi->border.size + i * design_body, ypos);
+         BlitBitmapOnBackground(gd->bitmap, drawto,
+                                gd->x + gi->border.size, gd->y,
+                                design_body, gi->height,
+                                xpos + gi->border.size + i * design_body,
+                                ypos);
 
        /* remaining middle part of gadget */
        if (step_size_remain > 0)
-         BlitBitmap(gd->bitmap, drawto,
-                    gd->x + gi->border.size, gd->y,
-                    step_size_remain, gi->height,
-                    xpos + gi->border.size + num_steps * design_body, ypos);
+         BlitBitmapOnBackground(gd->bitmap, drawto,
+                                gd->x + gi->border.size, gd->y,
+                                step_size_remain, gi->height,
+                                xpos + gi->border.size
+                                + num_steps * design_body,
+                                ypos);
 
        /* right part of gadget */
-       BlitBitmap(gd->bitmap, drawto,
-                  gd->x + design_full - gi->border.size, gd->y,
-                  gi->border.size, gi->height,
-                  xpos + size_full - gi->border.size, ypos);
+       BlitBitmapOnBackground(gd->bitmap, drawto,
+                              gd->x + design_full - gi->border.size, gd->y,
+                              gi->border.size, gi->height,
+                              xpos + size_full - gi->border.size, ypos);
       }
       break;
 
@@ -524,8 +529,8 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap)
 
   if (gi->type & GD_TYPE_TEXTINPUT)
   {
-    int font_width = getFontWidth(FS_SMALL, gi->text.font_type);
-    int font_height = getFontHeight(FS_SMALL, gi->text.font_type);
+    int font_width = getFontWidth(gi->text.font_type);
+    int font_height = getFontHeight(gi->text.font_type);
 
     gi->width = 2 * gi->border.size + (gi->text.size + 1) * font_width;
     gi->height = 2 * gi->border.size + font_height;
@@ -613,7 +618,7 @@ void FreeGadget(struct GadgetInfo *gi)
 {
   struct GadgetInfo *gi_previous = gadget_list_first_entry;
 
-  while (gi_previous && gi_previous->next != gi)
+  while (gi_previous != NULL && gi_previous->next != gi)
     gi_previous = gi_previous->next;
 
   if (gi == gadget_list_first_entry)
@@ -622,7 +627,7 @@ void FreeGadget(struct GadgetInfo *gi)
   if (gi == gadget_list_last_entry)
     gadget_list_last_entry = gi_previous;
 
-  if (gi_previous)
+  if (gi_previous != NULL)
     gi_previous->next = gi->next;
 
   free(gi);
@@ -797,7 +802,7 @@ void HandleGadgets(int mx, int my, int button)
       /* if mouse button pressed inside activated text gadget, set cursor */
       gi->text.cursor_position =
        (mx - gi->x - gi->border.size) /
-       getFontWidth(FS_SMALL, gi->text.font_type);
+       getFontWidth(gi->text.font_type);
 
       if (gi->text.cursor_position < 0)
        gi->text.cursor_position = 0;