|
@@ -5,6 +5,9 @@
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
#include <string.h>
|
|
|
+#include <grass/colors.h>
|
|
|
+#include <grass/glocale.h>
|
|
|
+#include "clr.h"
|
|
|
#include "local_proto.h"
|
|
|
|
|
|
#define KEY(x) (strcmp(x,key)==0)
|
|
@@ -29,28 +32,35 @@ static char *help2[] = {
|
|
|
int getgrid(void)
|
|
|
{
|
|
|
int spacing;
|
|
|
- int color = 0, fontsize = PS_FONT_DEFAULT_SIZE;
|
|
|
+ int fontsize = PS_FONT_DEFAULT_SIZE;
|
|
|
+ int ret, r, g, b;
|
|
|
char temp[30];
|
|
|
char buf[1024];
|
|
|
char ch, *key, *data;
|
|
|
+ PSCOLOR color, text_color;
|
|
|
|
|
|
PS.grid_font = G_store("Helvetica");
|
|
|
PS.grid_fontsize = 0;
|
|
|
- PS.grid_color = BLACK;
|
|
|
PS.grid_numbers = 0;
|
|
|
PS.grid_cross = 0.;
|
|
|
PS.grid_width = 0.25;
|
|
|
+ set_color(&color, 0, 0, 0);
|
|
|
+ set_color(&text_color, 0, 0, 0);
|
|
|
|
|
|
while (input(2, buf, help)) {
|
|
|
if (!key_data(buf, &key, &data))
|
|
|
continue;
|
|
|
|
|
|
if (KEY("color")) {
|
|
|
- color = get_color_number(data);
|
|
|
- if (color < 0)
|
|
|
- error(key, data, "illegal color request");
|
|
|
+ ret = G_str_to_color(data, &r, &g, &b);
|
|
|
+ if (ret == 1)
|
|
|
+ set_color(&color, r, g, b);
|
|
|
+ else if (ret == 2) /* i.e. "none" */
|
|
|
+ /* unset_color(&color); */
|
|
|
+ error(key, data, _("Unsupported color request"));
|
|
|
else
|
|
|
- PS.grid_color = color;
|
|
|
+ error(key, data, _("illegal color request"));
|
|
|
+
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -59,24 +69,32 @@ int getgrid(void)
|
|
|
|
|
|
if (strlen(data) == 0) {
|
|
|
spacing = 1;
|
|
|
- color = BLACK;
|
|
|
+ set_color(&text_color, 0, 0, 0);
|
|
|
}
|
|
|
|
|
|
switch (sscanf(data, "%d %[^\n]", &spacing, temp)) {
|
|
|
case 1:
|
|
|
- color = BLACK;
|
|
|
+ set_color(&text_color, 0, 0, 0);
|
|
|
break;
|
|
|
case 2:
|
|
|
- color = get_color_number(temp);
|
|
|
- if (color < 0)
|
|
|
+ ret = G_str_to_color(temp, &r, &g, &b);
|
|
|
+ if (ret == 1)
|
|
|
+ set_color(&text_color, r, g, b);
|
|
|
+ else if (ret == 2) /* i.e. "none" */
|
|
|
+ error(key, data, _("Unsupported color request"));
|
|
|
+ else
|
|
|
+ error(key, data, _("illegal color request"));
|
|
|
+
|
|
|
+ if (ret < 1)
|
|
|
spacing = -1;
|
|
|
+
|
|
|
break;
|
|
|
}
|
|
|
if (spacing < 0)
|
|
|
- error(key, data, "illegal numbers request");
|
|
|
+ error(key, data, _("illegal numbers request"));
|
|
|
else {
|
|
|
PS.grid_numbers = spacing;
|
|
|
- PS.grid_numbers_color = color;
|
|
|
+ PS.grid_numbers_color = text_color;
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
@@ -104,16 +122,17 @@ int getgrid(void)
|
|
|
if ((sscanf(data, "%lf%c", &PS.grid_width, &ch) < 1) ||
|
|
|
(PS.grid_width < 0.)) {
|
|
|
PS.grid_width = 1.;
|
|
|
- error(key, data, "illegal grid width request");
|
|
|
+ error(key, data, _("illegal grid width request"));
|
|
|
}
|
|
|
if (ch == 'i')
|
|
|
PS.grid_width = PS.grid_width / 72.0;
|
|
|
continue;
|
|
|
}
|
|
|
- error(key, data, "illegal request (getgrid)");
|
|
|
+ error(key, data, _("illegal request (grid)"));
|
|
|
}
|
|
|
|
|
|
PS.grid_fontsize = fontsize;
|
|
|
+ PS.grid_color = color;
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
@@ -124,27 +143,34 @@ int getgrid(void)
|
|
|
int getgeogrid(void)
|
|
|
{
|
|
|
int spacing;
|
|
|
- int color = 0, fontsize = PS_FONT_DEFAULT_SIZE;
|
|
|
+ int fontsize = PS_FONT_DEFAULT_SIZE;
|
|
|
+ int ret, r, g, b;
|
|
|
char temp[30];
|
|
|
char buf[1024];
|
|
|
char ch, *key, *data;
|
|
|
+ PSCOLOR color, text_color;
|
|
|
|
|
|
PS.geogrid_font = G_store("Helvetica");
|
|
|
PS.geogrid_fontsize = 0;
|
|
|
- PS.geogrid_color = BLACK;
|
|
|
PS.geogrid_numbers = 0;
|
|
|
PS.geogrid_width = 0.25;
|
|
|
+ set_color(&color, 0, 0, 0);
|
|
|
+ set_color(&text_color, 0, 0, 0);
|
|
|
|
|
|
while (input(2, buf, help2)) {
|
|
|
if (!key_data(buf, &key, &data))
|
|
|
continue;
|
|
|
|
|
|
if (KEY("color")) {
|
|
|
- color = get_color_number(data);
|
|
|
- if (color < 0)
|
|
|
- error(key, data, "illegal color request");
|
|
|
+ ret = G_str_to_color(data, &r, &g, &b);
|
|
|
+ if (ret == 1)
|
|
|
+ set_color(&color, r, g, b);
|
|
|
+ else if (ret == 2) /* i.e. "none" */
|
|
|
+ /* unset_color(&color); */
|
|
|
+ error(key, data, _("Unsupported color request"));
|
|
|
else
|
|
|
- PS.geogrid_color = color;
|
|
|
+ error(key, data, _("illegal color request"));
|
|
|
+
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -153,25 +179,33 @@ int getgeogrid(void)
|
|
|
|
|
|
if (strlen(data) == 0) {
|
|
|
spacing = 1;
|
|
|
- color = BLACK;
|
|
|
+ set_color(&text_color, 0, 0, 0);
|
|
|
}
|
|
|
|
|
|
switch (sscanf(data, "%d %[^\n]", &spacing, temp)) {
|
|
|
case 1:
|
|
|
- color = BLACK;
|
|
|
+ set_color(&text_color, 0, 0, 0);
|
|
|
break;
|
|
|
case 2:
|
|
|
- color = get_color_number(temp);
|
|
|
- if (color < 0)
|
|
|
+ ret = G_str_to_color(temp, &r, &g, &b);
|
|
|
+ if (ret == 1)
|
|
|
+ set_color(&text_color, r, g, b);
|
|
|
+ else if (ret == 2) /* i.e. "none" */
|
|
|
+ error(key, data, _("Unsupported color request"));
|
|
|
+ else
|
|
|
+ error(key, data, _("illegal color request"));
|
|
|
+
|
|
|
+ if (ret < 1)
|
|
|
spacing = -1;
|
|
|
+
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if (spacing < 0)
|
|
|
- error(key, data, "illegal numbers request");
|
|
|
+ error(key, data, _("illegal numbers request"));
|
|
|
else {
|
|
|
PS.geogrid_numbers = spacing;
|
|
|
- PS.geogrid_numbers_color = color;
|
|
|
+ PS.geogrid_numbers_color = text_color;
|
|
|
}
|
|
|
|
|
|
continue;
|
|
@@ -196,16 +230,17 @@ int getgeogrid(void)
|
|
|
if ((sscanf(data, "%lf%c", &PS.geogrid_width, &ch) < 1) ||
|
|
|
(PS.geogrid_width < 0.)) {
|
|
|
PS.geogrid_width = 1.;
|
|
|
- error(key, data, "illegal grid width request");
|
|
|
+ error(key, data, _("illegal grid width request"));
|
|
|
}
|
|
|
if (ch == 'i')
|
|
|
PS.geogrid_width = PS.geogrid_width / 72.0;
|
|
|
continue;
|
|
|
}
|
|
|
- error(key, data, "illegal request (getgrid)");
|
|
|
+ error(key, data, _("illegal request (geogrid)"));
|
|
|
}
|
|
|
|
|
|
PS.geogrid_fontsize = fontsize;
|
|
|
+ PS.geogrid_color = color;
|
|
|
|
|
|
return 0;
|
|
|
}
|