OSDN Git Service

Merge remote-tracking branch 'remotes/origin/feature/Fix-saved-floor-exceed' into...
[hengband/hengband.git] / src / main-xaw.c
index 234b7f2..fc025cc 100644 (file)
@@ -1,12 +1,13 @@
-/* File: main-xaw.c */
+/* File: main-xaw.c */
 
 /* Purpose: Support for X Athena Widget based Angband */
 /* Most code written by Torbj\vn Lindgren (tl@cd.chalmers.se) */
 
 #ifdef USE_XAW
 
-#include "angband.h"
-
+#include "system/angband.h"
+#include "game-option/runtime-arguments.h"
+#include "util/int-char-converter.h"
 
 #ifndef __MAKEDEPEND__
 #include <X11/Xlib.h>
@@ -302,39 +303,6 @@ static XtResource resources[] =
        { XtNcolor15, XtCColor, XtRPixel, sizeof(Pixel),
        offset(color[15]), XtRString, "#ffcc80" },
 
-#if 0
-
-       { XtNcolor2, XtCColor, XtRPixel, sizeof(Pixel),
-       offset(color[2]), XtRString, "#a6a6a6" },
-       { XtNcolor3, XtCColor, XtRPixel, sizeof(Pixel),
-       offset(color[3]), XtRString, "#ff6302" },
-       { XtNcolor4, XtCColor, XtRPixel, sizeof(Pixel),
-       offset(color[4]), XtRString, "#ca0808" },
-       { XtNcolor5, XtCColor, XtRPixel, sizeof(Pixel),
-       offset(color[5]), XtRString, "#008e18" },
-       { XtNcolor6, XtCColor, XtRPixel, sizeof(Pixel),
-       offset(color[6]), XtRString, "#0000e3" },
-       { XtNcolor7, XtCColor, XtRPixel, sizeof(Pixel),
-       offset(color[7]), XtRString, "#814007" },
-       { XtNcolor8, XtCColor, XtRPixel, sizeof(Pixel),
-       offset(color[8]), XtRString, "#6b6b6b" },
-       { XtNcolor9, XtCColor, XtRPixel, sizeof(Pixel),
-       offset(color[9]), XtRString, "#d6d6d6" },
-       { XtNcolor10, XtCColor, XtRPixel, sizeof(Pixel),
-       offset(color[10]), XtRString, "#5100c2" },
-       { XtNcolor11, XtCColor, XtRPixel, sizeof(Pixel),
-       offset(color[11]), XtRString, "#fdf105" },
-       { XtNcolor12, XtCColor, XtRPixel, sizeof(Pixel),
-       offset(color[12]), XtRString, "#ff9259" },
-       { XtNcolor13, XtCColor, XtRPixel, sizeof(Pixel),
-       offset(color[13]), XtRString, "#26cf17" },
-       { XtNcolor14, XtCColor, XtRPixel, sizeof(Pixel),
-       offset(color[14]), XtRString, "#02b2f2" },
-       { XtNcolor15, XtCColor, XtRPixel, sizeof(Pixel),
-       offset(color[15]), XtRString, "#b28b48" },
-
-#endif
-
        { XtNredrawCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
        offset(redraw_callbacks), XtRCallback, (XtPointer)NULL }
 };
@@ -345,13 +313,13 @@ static XtResource resources[] =
 static void Initialize(AngbandWidget request, AngbandWidget new);
 static void Redisplay(AngbandWidget w, XEvent *event, Region region);
 static Boolean SetValues(AngbandWidget current, AngbandWidget request,
-                         AngbandWidget new, ArgList args, Cardinal *num_args);
+                        AngbandWidget new, ArgList args, Cardinal *num_args);
 static void Destroy(AngbandWidget widget);
 
 /* Forward declaration for internal functions */
 static void calculateSizeHints(AngbandWidget new);
 static XFontStruct *getFont(AngbandWidget widget,
-                            String font, Boolean fallback);
+                           String font, Boolean fallback);
 
 
 /* Class record constanst */
@@ -411,7 +379,7 @@ WidgetClass angbandWidgetClass = (WidgetClass) &angbandClassRec;
  * Public procedures
  */
 static void AngbandOutputText(AngbandWidget widget, int x, int y,
-                              String txt, int len, int color)
+                             String txt, int len, int color)
 {
        /* Do nothing if the string is null */
        if (!txt || !*txt)
@@ -428,11 +396,11 @@ static void AngbandOutputText(AngbandWidget widget, int x, int y,
 
        /* Place the string */
        XDrawImageString (XtDisplay(widget), XtWindow(widget),
-                         widget->angband.gc[color], x, y, txt, len);
+                         widget->angband.gc[color], x, y, txt, len);
 }
 
 static void AngbandClearArea(AngbandWidget widget,
-                             int x, int y, int w, int h, int color)
+                            int x, int y, int w, int h, int color)
 {
        /* Figure out which area to clear */
        y = y * widget->angband.fontheight + widget->angband.internal_border;
@@ -440,9 +408,9 @@ static void AngbandClearArea(AngbandWidget widget,
 
        /* Clear the area */
        XFillRectangle(XtDisplay(widget), XtWindow(widget),
-                      widget->angband.gc[color],
-                      x, y, widget->angband.fontwidth*w,
-                      widget->angband.fontheight*h);
+                      widget->angband.gc[color],
+                      x, y, widget->angband.fontwidth*w,
+                      widget->angband.fontheight*h);
 }
 
 /*
@@ -485,8 +453,8 @@ static void Initialize(AngbandWidget request, AngbandWidget new)
                else
                        gcv.foreground = new->angband.color[n];
                new->angband.gc[n] = XtGetGC((Widget)new, GCFont | GCForeground |
-                                            GCBackground | GCGraphicsExposures,
-                                            &gcv);
+                                            GCBackground | GCGraphicsExposures,
+                                            &gcv);
        }
 
        /* Create a special GC for highlighting */
@@ -494,8 +462,8 @@ static void Initialize(AngbandWidget request, AngbandWidget new)
        WhitePixelOfScreen(XtScreen((Widget)new));
        gcv.function = GXxor;
        new->angband.gc[NUM_COLORS] = XtGetGC((Widget)new, GCFunction |
-                                             GCGraphicsExposures |
-                                             GCForeground, &gcv);
+                                             GCGraphicsExposures |
+                                             GCForeground, &gcv);
 
        /* Calculate window geometry */
        new->core.height = new->angband.start_rows * new->angband.fontheight +
@@ -544,8 +512,8 @@ static void Redisplay(AngbandWidget widget, XEvent *event, Region region)
  * can potentially have effects that spans the whole widget).
  */
 static Boolean SetValues(AngbandWidget current, AngbandWidget request,
-                         AngbandWidget new, ArgList args,
-                         Cardinal *num_args)
+                        AngbandWidget new, ArgList args,
+                        Cardinal *num_args)
 {
        int depth = DefaultDepthOfScreen(XtScreen((Widget) new));
        Boolean font_changed = FALSE;
@@ -604,8 +572,8 @@ static Boolean SetValues(AngbandWidget current, AngbandWidget request,
                        XtReleaseGC((Widget)current, current->angband.gc[n]);
                        /* Get the new GC */
                        new->angband.gc[n] = XtGetGC((Widget)new, GCFont | GCForeground |
-                                                    GCBackground | GCGraphicsExposures,
-                                                    &gcv);
+                                                    GCBackground | GCGraphicsExposures,
+                                                    &gcv);
                }
 
                /* Replace the old XOR/highlighting GC */
@@ -614,8 +582,8 @@ static Boolean SetValues(AngbandWidget current, AngbandWidget request,
                gcv.function = GXxor;
                XtReleaseGC((Widget)current, current->angband.gc[NUM_COLORS]);
                new->angband.gc[NUM_COLORS] = XtGetGC((Widget)new, GCFunction |
-                                                     GCGraphicsExposures |
-                                                     GCForeground, &gcv);
+                                                     GCGraphicsExposures |
+                                                     GCForeground, &gcv);
                /* Fix the background color */
                new->core.background_pixel = new->angband.color[0];
        }
@@ -696,7 +664,7 @@ static void calculateSizeHints(AngbandWidget new)
  * Load a font
  */
 static XFontStruct *getFont(AngbandWidget widget,
-                            String font, Boolean fallback)
+                           String font, Boolean fallback)
 {
        Display *dpy = XtDisplay((Widget) widget);
        char buf[256];
@@ -880,7 +848,7 @@ static String fallback[] =
  * Do a redraw
  */
 static void react_redraw(Widget widget,
-                         XtPointer client_data, XtPointer call_data)
+                        XtPointer client_data, XtPointer call_data)
 {
        term_data *old_td = (term_data*)(Term->data);
        term_data *td = (term_data*)client_data;
@@ -954,18 +922,18 @@ static void react_keypress(XKeyEvent *ev)
        if (ks)
        {
                sprintf(msg, "%c%s%s%s%s_%lX%c", 31,
-                       mc ? "N" : "", ms ? "S" : "",
-                       mo ? "O" : "", mx ? "M" : "",
-                       (unsigned long)(ks), 13);
+                       mc ? "N" : "", ms ? "S" : "",
+                       mo ? "O" : "", mx ? "M" : "",
+                       (unsigned long)(ks), 13);
        }
 
        /* Hack -- Use the Keycode */
        else
        {
                sprintf(msg, "%c%s%s%s%sK_%X%c", 31,
-                       mc ? "N" : "", ms ? "S" : "",
-                       mo ? "O" : "", mx ? "M" : "",
-                       ev->keycode, 13);
+                       mc ? "N" : "", ms ? "S" : "",
+                       mo ? "O" : "", mx ? "M" : "",
+                       ev->keycode, 13);
        }
 
        /* Enqueue the "fake" string */
@@ -989,7 +957,7 @@ static void react_keypress(XKeyEvent *ev)
 
 
 static void handle_event (Widget widget, XtPointer client_data, XEvent *event,
-                          Boolean *continue_to_dispatch)
+                         Boolean *continue_to_dispatch)
 {
        term_data *old_td = (term_data*)(Term->data);
        term_data *td = (term_data *)client_data;
@@ -1085,7 +1053,7 @@ static errr Term_xtra_xaw(int n, int v)
                for (i=0; i<MAX_TERM_DATA; i++) {
                    if (Term == &data[i].t)
                        XClearWindow(XtDisplay((Widget)data[i].widget),
-                                    XtWindow((Widget)data[i].widget));
+                                    XtWindow((Widget)data[i].widget));
                }
                return (0);
        }
@@ -1130,7 +1098,7 @@ static errr Term_curs_xaw(int x, int y)
 /*
  * Draw a number of characters
  */
-static errr Term_text_xaw(int x, int y, int n, byte a, cptr s)
+static errr Term_text_xaw(int x, int y, int n, byte a, concptr s)
 {
        term_data *td = (term_data*)(Term->data);
 
@@ -1157,20 +1125,20 @@ static void term_raise(term_data win)
  * Initialize a term_data
  */
 static errr term_data_init(term_data *td, Widget topLevel,
-                           int key_buf, String name,
-                           ArgList widget_arg, Cardinal widget_arg_no)
+                          int key_buf, String name,
+                          ArgList widget_arg, Cardinal widget_arg_no)
 {
        Widget parent;
        term *t = &td->t;
 
        /* Create the shell widget */
        parent = XtCreatePopupShell(name, topLevelShellWidgetClass, topLevel,
-                                   NULL, 0);
+                                   NULL, 0);
 
        /* Create the interior widget */
        td->widget = (AngbandWidget)
        XtCreateManagedWidget (name, angbandWidgetClass,
-                              parent, widget_arg, widget_arg_no);
+                              parent, widget_arg, widget_arg_no);
 
        /* Initialize the term (full size) */
        term_init(t, 80, 24, key_buf);
@@ -1193,11 +1161,11 @@ static errr term_data_init(term_data *td, Widget topLevel,
 
        /* Register the keypress event handler */
        XtAddEventHandler((Widget)td->widget, KeyPressMask,
-                         False, (XtEventHandler) handle_event, td);
+                         False, (XtEventHandler) handle_event, td);
 
        /* Redraw callback */
        XtAddCallback((Widget)td->widget, XtNredrawCallback,
-                     react_redraw, td);
+                     react_redraw, td);
 
        /* Realize the widget */
        XtRealizeWidget(parent);
@@ -1255,7 +1223,7 @@ errr init_xaw(void)
 
        /* Initialize the toolkit */
        topLevel = XtAppInitialize (&appcon, "Angband", NULL, 0, &argc, argv,
-                                   fallback, NULL, 0);
+                                   fallback, NULL, 0);
 
        /* Initialize the windows */
        for (i=0; i<MAX_TERM_DATA; i++) {