1 /**********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
15 #include <fc_config.h>
20 #include <X11/Intrinsic.h>
21 #include <X11/StringDefs.h>
22 #include <X11/Xaw/Form.h>
23 #include <X11/Xaw/Label.h>
24 #include <X11/Xaw/SimpleMenu.h>
25 #include <X11/Xaw/Command.h>
26 #include <X11/Xaw/AsciiText.h>
30 #include "gui_stuff.h"
34 /****************************************************************
36 *****************************************************************/
37 char *input_dialog_get_input(Widget button
)
42 winput
=XtNameToWidget(XtParent(button
), "iinput");
44 XtVaGetValues(winput
, XtNstring
, &dp
, NULL
);
50 /****************************************************************
52 *****************************************************************/
53 void input_dialog_destroy(Widget button
)
55 XtSetSensitive(XtParent(XtParent(XtParent(button
))), TRUE
);
57 XtDestroyWidget(XtParent(XtParent(button
)));
60 /****************************************************************
62 *****************************************************************/
63 void inputdlg_key_ok(Widget w
)
65 x_simulate_button_click(XtNameToWidget(XtParent(w
), "iokcommand"));
69 /****************************************************************
71 *****************************************************************/
72 Widget
input_dialog_create(Widget parent
, const char *dialogname
,
73 const char *text
, const char *postinputtest
,
74 XtCallbackProc ok_callback
,
75 XtPointer ok_cli_data
,
76 XtCallbackProc cancel_callback
,
77 XtPointer cancel_cli_data
)
79 Widget shell
, form
, label
, input
, ok
, cancel
;
81 XtSetSensitive(parent
, FALSE
);
83 I_T(shell
=XtCreatePopupShell(dialogname
, transientShellWidgetClass
,
86 form
=XtVaCreateManagedWidget("iform", formWidgetClass
, shell
, NULL
);
88 /* Caller should i18n the text passed in as desired */
89 label
=XtVaCreateManagedWidget("ilabel", labelWidgetClass
, form
,
90 XtNlabel
, (XtArgVal
)text
, NULL
);
92 input
=XtVaCreateManagedWidget("iinput",
95 XtNfromVert
, (XtArgVal
)label
,
96 XtNeditType
, XawtextEdit
,
97 XtNstring
, postinputtest
,
100 ok
=XtVaCreateManagedWidget("iokcommand",
103 XtNlabel
, (XtArgVal
)_("Ok"),
107 cancel
=XtVaCreateManagedWidget("icancelcommand",
110 XtNlabel
, (XtArgVal
)_("Cancel"),
115 xaw_set_relative_position(parent
, shell
, 10, 10);
116 XtPopup(shell
, XtGrabNone
);
118 XtAddCallback(ok
, XtNcallback
, ok_callback
, ok_cli_data
);
119 XtAddCallback(cancel
, XtNcallback
, cancel_callback
,
122 XtSetKeyboardFocus(parent
, input
);