rnd-20050203-1-src
[rocksndiamonds.git] / src / libgame / gadgets.c
index 57de63e72a36c581eb0a818a86fe301794d1817c..a134b04921c77e6367249607564f5e6d071e9918 100644 (file)
@@ -1068,7 +1068,11 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap)
     getFontCharSource(font_nr, FONT_ASCII_CURSOR, &src_bitmap, &src_x, &src_y);
     src_x += font_width / 2;
     src_y += font_height / 2;
-    gi->selectbox.inverse_color = GetPixel(src_bitmap, src_x, src_y);
+
+    /* there may be esoteric cases with missing or too small font bitmap */
+    if (src_bitmap != NULL &&
+       src_x < src_bitmap->width && src_y < src_bitmap->height)
+      gi->selectbox.inverse_color = GetPixel(src_bitmap, src_x, src_y);
 
     /* always start with closed selectbox */
     gi->selectbox.open = FALSE;
@@ -1316,21 +1320,33 @@ void RemapAllGadgets()
   MultiMapGadgets(MULTIMAP_ALL | MULTIMAP_REMAP);
 }
 
-static boolean anyTextInputGadgetActive()
+boolean anyTextInputGadgetActive()
 {
   return (last_gi && (last_gi->type & GD_TYPE_TEXT_INPUT) && last_gi->mapped);
 }
 
-static boolean anyTextAreaGadgetActive()
+boolean anyTextAreaGadgetActive()
 {
   return (last_gi && (last_gi->type & GD_TYPE_TEXT_AREA) && last_gi->mapped);
 }
 
-static boolean anySelectboxGadgetActive()
+boolean anySelectboxGadgetActive()
 {
   return (last_gi && (last_gi->type & GD_TYPE_SELECTBOX) && last_gi->mapped);
 }
 
+boolean anyScrollbarGadgetActive()
+{
+  return (last_gi && (last_gi->type & GD_TYPE_SCROLLBAR) && last_gi->mapped);
+}
+
+boolean anyTextGadgetActive()
+{
+  return (anyTextInputGadgetActive() ||
+         anyTextAreaGadgetActive() ||
+         anySelectboxGadgetActive());
+}
+
 static boolean insideSelectboxLine(struct GadgetInfo *gi, int mx, int my)
 {
   return(gi != NULL &&
@@ -1347,13 +1363,6 @@ static boolean insideSelectboxArea(struct GadgetInfo *gi, int mx, int my)
         my >= gi->selectbox.y && my < gi->selectbox.y + gi->selectbox.height);
 }
 
-boolean anyTextGadgetActive()
-{
-  return (anyTextInputGadgetActive() ||
-         anyTextAreaGadgetActive() ||
-         anySelectboxGadgetActive());
-}
-
 void ClickOnGadget(struct GadgetInfo *gi, int button)
 {
   if (!gi->mapped)