Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2004:
[Freeciv-Dev] (PR#10280) Xaw: buttons in messages window are moved out o
Home

[Freeciv-Dev] (PR#10280) Xaw: buttons in messages window are moved out o

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#10280) Xaw: buttons in messages window are moved out of window
From: "Egor Vyscrebentsov via RT" <evyscr@xxxxxxxxx>
Date: Wed, 29 Sep 2004 14:53:41 -0700
Reply-to: RT_CorrespondAddressNotSet@xxxxxxxxxxxxxx

<URL: http://RT::WebBaseURL.not.configured:80/Ticket/Display.html?id=10280 >

> [evyscr - Sep 23 19:09:04 2004]:
>
> CVS 2004 09 22, Xaw client.
>
> If Messages window is updated, buttons are moved down, so
> they are semiinvisible.

Attached patch:
- seems to fix this problem by resizing not viewport but form
(except we have zero-height viewport) [*];
- reduce number of calls to get_num_messages to one (number of
messages is const inside real_update_meswin_dialog);
- move meswin_scroll_down() into condition !(num <= N_MSG_VIEW)
(cause meswin_scroll_down() do nothing in another case)

Thanks, evyscr

[*]
All cases, when (num <= N_MSG_VIEW), are tested and work well.
Case, when (num > N_MSG_VIEW) and (height == oldheight), is tested and
works.
Other cases are not tested.
diff -urN freeciv-orig/client/gui-xaw/messagewin.c 
freeciv/client/gui-xaw/messagewin.c
--- freeciv-orig/client/gui-xaw/messagewin.c    2004-09-29 20:23:30 +0400
+++ freeciv-devel/client/gui-xaw/messagewin.c   2004-09-30 01:30:49 +0400
@@ -221,17 +221,18 @@
 **************************************************************************/
 void real_update_meswin_dialog(void)
 {
-  Dimension height, iheight, width;
-  int i;
+  Dimension height, iheight, width, oldheight, newheight;
+  int i, num = get_num_messages();
 
   XawFormDoLayout(meswin_form, False);
 
-  if (get_num_messages() == 0) {
+  XtVaGetValues(meswin_viewport, XtNheight, &oldheight, NULL);
+
+  if (num == 0) {
     XawListChange(meswin_list, dummy_message_list, 1, 0, True);
   } else {
     /* strings will not be freed */
     static char **strings = NULL;
-    int i, num = get_num_messages();
 
     strings = fc_realloc(strings, num * sizeof(char *));
 
@@ -239,7 +240,7 @@
       strings[i] = get_message(i)->descr;
     }
 
-    XawListChange(meswin_list, strings, get_num_messages(), 0, True);
+    XawListChange(meswin_list, strings, num, 0, True);
   }
 
   /* Much of the following copied from city_report_dialog_update() */
@@ -253,19 +254,33 @@
   /* Seems have to do this here so we get the correct height below. */
   XawFormDoLayout(meswin_form, True);
 
-  if (get_num_messages() <= N_MSG_VIEW) {
+  if (num <= N_MSG_VIEW) {
     XtVaGetValues(meswin_list, XtNheight, &height, NULL);
-    XtVaSetValues(meswin_viewport, XtNheight, height, NULL);
+    if (oldheight == 0) {
+      XtVaSetValues(meswin_viewport, XtNheight, height, NULL);
+    } else {
+      XtVaGetValues(meswin_form, XtNheight, &newheight, NULL);
+      newheight = newheight + height - oldheight;
+      XtVaSetValues(meswin_form, XtNheight, newheight, NULL);
+    }
   } else {
     XtVaGetValues(meswin_list, XtNheight, &height, NULL);
     XtVaGetValues(meswin_list, XtNinternalHeight, &iheight, NULL);
     height -= (iheight * 2);
-    height /= get_num_messages();
+    height /= num;
     height *= N_MSG_VIEW;
     height += (iheight * 2);
-    XtVaSetValues(meswin_viewport, XtNheight, height, NULL);
+    if (height != oldheight) {
+      if (oldheight == 0) {
+       XtVaSetValues(meswin_viewport, XtNheight, height, NULL);
+      } else {
+       XtVaGetValues(meswin_form, XtNheight, &newheight, NULL);
+       newheight = newheight + height - oldheight;
+       XtVaSetValues(meswin_form, XtNheight, newheight, NULL);
+      }
+    }
+    meswin_scroll_down();
   }
-  meswin_scroll_down();
 
   XtSetSensitive(meswin_goto_command, FALSE);
   XtSetSensitive(meswin_popcity_command, FALSE);

[Prev in Thread] Current Thread [Next in Thread]