[GRASS-SVN] r58917 - in grass/branches/releasebranch_6_4: display/d.barscale display/d.menu lib/display

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Feb 6 18:17:09 PST 2014


Author: hamish
Date: 2014-02-06 18:17:09 -0800 (Thu, 06 Feb 2014)
New Revision: 58917

Modified:
   grass/branches/releasebranch_6_4/display/d.barscale/mouse.c
   grass/branches/releasebranch_6_4/display/d.menu/main.c
   grass/branches/releasebranch_6_4/lib/display/popup.c
Log:
backport some minor whitespace, comment spelling, and display rendering tweaks from devbr6

Modified: grass/branches/releasebranch_6_4/display/d.barscale/mouse.c
===================================================================
--- grass/branches/releasebranch_6_4/display/d.barscale/mouse.c	2014-02-07 00:48:59 UTC (rev 58916)
+++ grass/branches/releasebranch_6_4/display/d.barscale/mouse.c	2014-02-07 02:17:09 UTC (rev 58917)
@@ -28,7 +28,8 @@
 	fprintf(stderr,
 		"\n"
 		"Left: choose location\n"
-		"Middle: cancel\n" "Right: confirm location\n");
+		"Middle: cancel\n"
+		"Right: confirm location\n");
 
 	R_get_location_with_pointer(&x_pos, &y_pos, &button);
 

Modified: grass/branches/releasebranch_6_4/display/d.menu/main.c
===================================================================
--- grass/branches/releasebranch_6_4/display/d.menu/main.c	2014-02-07 00:48:59 UTC (rev 58916)
+++ grass/branches/releasebranch_6_4/display/d.menu/main.c	2014-02-07 02:17:09 UTC (rev 58917)
@@ -23,7 +23,7 @@
  *    .C     contains the text color
  *    .D     contains the line divider color
  *    .F     contains the font name
- *    .S     contains the text size (in pixles)
+ *    .S     contains the text size (in pixels)
  *    .T     contains the panel's top edge
  *    .L     contains the panel's left edge
  *
@@ -186,9 +186,10 @@
 	G_fatal_error(_("Menu must contain a title and at least one option"));
     }
 
-    i = D_popup(backcolor, textcolor, dividercolor, top,	/* The col of the top left corner */
+    i = D_popup(backcolor, textcolor, dividercolor,
+		top,		/* The col of the top left corner */
 		left,		/* The row of the top left corner */
-		size,		/* The size of the characters in pixles */
+		size,		/* The size of the characters in pixels */
 		options);	/* The text */
 
     R_close_driver();

Modified: grass/branches/releasebranch_6_4/lib/display/popup.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/display/popup.c	2014-02-07 00:48:59 UTC (rev 58916)
+++ grass/branches/releasebranch_6_4/lib/display/popup.c	2014-02-07 02:17:09 UTC (rev 58917)
@@ -92,7 +92,7 @@
     char *panel;
     int dots_per_line, dots_per_char, height, width;
 
-    /* Figure the number of options and the max length of options */
+    /* Figure the number of options and the max string length of options */
     max_len = 0;
     for (n_options = 0; options[n_options] != NULL; n_options++) {
 	len = strlen(options[n_options]);
@@ -103,24 +103,25 @@
     /* Figure the dots per line and dots_per_char */
     height = R_screen_bot() - R_screen_top();
     width = R_screen_rite() - R_screen_left();
-    dots_per_line = height * percent_per_line / 100;
-    dots_per_char = width / (max_len + 2);
+    dots_per_line = height * percent_per_line / 100.;
+    dots_per_char = width / (max_len + 2.);
+
     /* we want the box to fit into window horizontally */
+    t = R_screen_bot() - (R_screen_bot() - R_screen_top()) * top / 100.;
+    l = R_screen_left() + (R_screen_rite() - R_screen_left()) * left / 100.;
 
-    t = R_screen_bot() - (R_screen_bot() - R_screen_top()) * top / 100;
-    l = R_screen_left() + (R_screen_rite() - R_screen_left()) * left / 100;
-
     /* Figure the bottom and right of the window */
-    text_size = (int)(.8 * (float)dots_per_line);
+    text_size = (int)(.8 * dots_per_line);
     if (text_size > dots_per_char)
 	text_size = dots_per_char;
 
     text_raise = (dots_per_line - text_size + 1) / 2;
     if (text_raise == 0)
 	text_raise = 1;
-    b = Y_BORDER + t + dots_per_line * n_options;
-    r = 2 * X_BORDER + l + text_size * max_len;
 
+    b = Y_BORDER + t + (dots_per_line * n_options) + 1;
+    r = 2 * X_BORDER + l + (text_size * 0.8) * max_len;
+
     /* Adjust, if necessary, to make sure window is all on screen */
     if (t < R_screen_top()) {
 	b = b + (R_screen_top() - t);
@@ -164,11 +165,11 @@
 
     /* Draw border */
     R_standard_color(text_colr);
-    R_move_abs(l + 1, t + 1);
-    R_cont_abs(r - 1, t + 1);
+    R_move_abs(l + 0, t + 0);
+    R_cont_abs(r - 1, t + 0);
     R_cont_abs(r - 1, b - 1);
-    R_cont_abs(l + 1, b - 1);
-    R_cont_abs(l + 1, t + 1);
+    R_cont_abs(l + 0, b - 1);
+    R_cont_abs(l + 0, t + 0);
 
     /* Prepare for text */
     R_text_size(text_size, text_size);
@@ -195,16 +196,18 @@
 	int n;
 
 	R_get_location_with_pointer(&x, &y, &button);
-	if (x > r
-	    || x < l || y < t + Y_BORDER + dots_per_line || y > b - Y_BORDER)
+	if (x > r || x < l
+	    || y < t + Y_BORDER + dots_per_line || y > b - Y_BORDER)
 	    continue;
 
 	n = y - t - Y_BORDER;
 	if (n % dots_per_line == 0)
 	    continue;
 
+	/* cleanup */
 	R_panel_restore(panel);
 	R_panel_delete(panel);
+
 	return (n / dots_per_line);
     }
 }



More information about the grass-commit mailing list