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: Thu, 30 Sep 2004 05:47:09 -0700
Reply-to: RT_CorrespondAddressNotSet@xxxxxxxxxxxxxx

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

> [evyscr - Срд. Сен. 29 21:53:39 2004]: 
> Attached patch: 
> - seems to fix this problem by resizing not viewport but form 
> (except we have zero-height viewport); 
 
New version. 
Changes: 
- fix a case of updating window when new number of messages is 0 
 
Thanks, evyscr. 
diff -urN freeciv-orig/client/gui-xaw/messagewin.c 
freeciv/client/gui-xaw/messagewin.c
--- freeciv-orig/client/gui-xaw/messagewin.c    2004-09-30 10:34:17 +0400
+++ freeciv-devel/client/gui-xaw/messagewin.c   2004-09-30 13:19:35 +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) || (num == 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]