[Freeciv-Dev] (PR#13737) gui-xaw: make option dialog to be scrolled
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#13737) gui-xaw: make option dialog to be scrolled |
From: |
"Egor Vyscrebentsov" <evyscr@xxxxxxxxx> |
Date: |
Mon, 22 Aug 2005 03:45:44 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13737 >
Good daytime!
Attached is a patch that makes option dialog to use Viewport
so it can use scrollbars.
Thanks, evyscr.
Index: client/gui-xaw/optiondlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/optiondlg.c,v
retrieving revision 1.25
diff -u -r1.25 optiondlg.c
--- client/gui-xaw/optiondlg.c 6 Feb 2004 01:01:11 -0000 1.25
+++ client/gui-xaw/optiondlg.c 22 Aug 2005 10:35:59 -0000
@@ -28,8 +28,9 @@
#include <X11/Xaw/SimpleMenu.h>
#include <X11/Xaw/Scrollbar.h>
#include <X11/Xaw/SmeBSB.h>
-#include <X11/Xaw/AsciiText.h>
-#include <X11/Xaw/Toggle.h>
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/Toggle.h>
+#include <X11/Xaw/Viewport.h>
#include "events.h"
#include "fcintl.h"
@@ -112,9 +113,11 @@
void create_option_dialog(void)
{
Widget option_form, option_label;
+ Widget option_viewport, option_scrollform;
Widget option_ok_command, option_cancel_command;
Widget prev_widget, longest_label = 0;
size_t longest_len = 0;
+ Dimension width;
option_dialog_shell =
I_T(XtCreatePopupShell("optionpopup", transientShellWidgetClass,
@@ -128,7 +131,15 @@
I_L(XtVaCreateManagedWidget("optionlabel", labelWidgetClass,
option_form, NULL));
- prev_widget = option_label; /* init the prev-Widget */
+ option_viewport =
+ XtVaCreateManagedWidget("optionviewport", viewportWidgetClass,
+ option_form, NULL);
+
+ option_scrollform =
+ XtVaCreateManagedWidget("optionscrollform", formWidgetClass,
+ option_viewport, NULL);
+
+ prev_widget = NULL; /* init the prev-Widget */
client_options_iterate(o) {
const char *descr = _(o->description);
size_t len = strlen(descr);
@@ -139,17 +150,35 @@
*/
o->p_gui_data = (void *) prev_widget;
- prev_widget =
- XtVaCreateManagedWidget("label", labelWidgetClass, option_form,
- XtNlabel, descr,
- XtNfromVert, prev_widget,
- NULL);
+ if (prev_widget) {
+ prev_widget =
+ XtVaCreateManagedWidget("label", labelWidgetClass, option_scrollform,
+ XtNlabel, descr,
+ XtNfromVert, prev_widget,
+ NULL);
+ } else {
+ prev_widget =
+ XtVaCreateManagedWidget("label", labelWidgetClass, option_scrollform,
+ XtNlabel, descr,
+ NULL);
+ }
+
+ /*
+ * The addition of a scrollbar screws things up. There must be a
+ * better way to do this.
+ */
+ XtVaGetValues(prev_widget, XtNwidth, &width, NULL);
+ XtVaSetValues(prev_widget, XtNwidth, width + 15, NULL);
+
if (len > longest_len) {
longest_len = len;
longest_label = prev_widget;
}
} client_options_iterate_end;
+ XtVaGetValues(longest_label, XtNwidth, &width, NULL);
+ XtVaSetValues(option_label, XtNwidth, width + 15, NULL);
+
client_options_iterate(o) {
/*
* At the start of the loop o->p_gui_data will contain the widget
@@ -158,11 +187,20 @@
*/
switch (o->type) {
case COT_BOOL:
- prev_widget =
- XtVaCreateManagedWidget("toggle", toggleWidgetClass, option_form,
- XtNfromHoriz, longest_label,
- XtNfromVert, o->p_gui_data,
- NULL);
+ if (o->p_gui_data) {
+ prev_widget =
+ XtVaCreateManagedWidget("toggle", toggleWidgetClass,
+ option_scrollform,
+ XtNfromHoriz, option_label,
+ XtNfromVert, o->p_gui_data,
+ NULL);
+ } else {
+ prev_widget =
+ XtVaCreateManagedWidget("toggle", toggleWidgetClass,
+ option_scrollform,
+ XtNfromHoriz, option_label,
+ NULL);
+ }
XtAddCallback(prev_widget, XtNcallback, toggle_callback, NULL);
break;
case COT_STR:
@@ -171,12 +209,20 @@
const char **vals = (*o->p_string_vals)();
Widget popupmenu;
- prev_widget = XtVaCreateManagedWidget(o->name,
- menuButtonWidgetClass,
- option_form,
- XtNfromHoriz, longest_label,
- XtNfromVert, o->p_gui_data,
- NULL);
+ if (o->p_gui_data) {
+ prev_widget =
+ XtVaCreateManagedWidget(o->name, menuButtonWidgetClass,
+ option_scrollform,
+ XtNfromHoriz, option_label,
+ XtNfromVert, o->p_gui_data,
+ NULL);
+ } else {
+ prev_widget =
+ XtVaCreateManagedWidget(o->name, menuButtonWidgetClass,
+ option_scrollform,
+ XtNfromHoriz, option_label,
+ NULL);
+ }
popupmenu = XtVaCreatePopupShell("menu",
simpleMenuWidgetClass,
@@ -197,15 +243,27 @@
XtSetSensitive(prev_widget, FALSE);
}
+ /* There should be another way to set width of menu button */
+ XtVaSetValues(prev_widget, XtNwidth, 120 ,NULL);
+
break;
}
/* else fall through */
case COT_INT:
- prev_widget =
- XtVaCreateManagedWidget("input", asciiTextWidgetClass, option_form,
- XtNfromHoriz, longest_label,
- XtNfromVert, o->p_gui_data,
- NULL);
+ if (o->p_gui_data) {
+ prev_widget =
+ XtVaCreateManagedWidget("input", asciiTextWidgetClass,
+ option_scrollform,
+ XtNfromHoriz, option_label,
+ XtNfromVert, o->p_gui_data,
+ NULL);
+ } else {
+ prev_widget =
+ XtVaCreateManagedWidget("input", asciiTextWidgetClass,
+ option_scrollform,
+ XtNfromHoriz, option_label,
+ NULL);
+ }
break;
}
@@ -215,12 +273,12 @@
option_ok_command =
I_L(XtVaCreateManagedWidget("optionokcommand", commandWidgetClass,
- option_form, XtNfromVert, prev_widget,
+ option_form, XtNfromVert, option_viewport,
NULL));
option_cancel_command =
I_L(XtVaCreateManagedWidget("optioncancelcommand", commandWidgetClass,
- option_form, XtNfromVert, prev_widget,
+ option_form, XtNfromVert, option_viewport,
NULL));
XtAddCallback(option_ok_command, XtNcallback,
Index: data/Freeciv.in
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/Freeciv.in,v
retrieving revision 1.9
diff -u -r1.9 Freeciv.in
--- data/Freeciv.in 29 May 2005 10:40:44 -0000 1.9
+++ data/Freeciv.in 22 Aug 2005 10:35:59 -0000
@@ -1260,13 +1260,18 @@
Freeciv*optionlabel.label: _("Set local options")
Freeciv*optionlabel.borderWidth: 0
+Freeciv*optionviewport.fromVert: optionlabel
+Freeciv*optionviewport.height: 510
+Freeciv*optionviewport.useRight: True
+Freeciv*optionviewport.allowVert: True
+
! dummy labels:
Freeciv*optionpopup*label.label: XXXXXXXXXXXXXXXXXXXXXXXXXXX
Freeciv*optionpopup*label.borderWidth: 0
Freeciv*optionpopup*input.*.foreground: black
Freeciv*optionpopup*input.*.background: white
-Freeciv*optionpopup*input.width: 50
+Freeciv*optionpopup*input.width: 120
Freeciv*optionpopup*input.*.editType: edit
Freeciv*optionokcommand.label: _("Ok")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#13737) gui-xaw: make option dialog to be scrolled,
Egor Vyscrebentsov <=
|
|