2
#include "local_proto.h"
3
#include <grass/display.h>
4
#include <grass/raster.h>
6
static View *makeview(double bottom, double top, double left, double right)
10
view = (View *) G_malloc(sizeof(View));
13
bottom = 100 - bottom;
15
view->top = SCREEN_TOP + (SCREEN_BOTTOM - SCREEN_TOP) * top / 100.0;
16
view->bottom = SCREEN_TOP + (SCREEN_BOTTOM - SCREEN_TOP) * bottom / 100.0;
17
view->left = SCREEN_LEFT + (SCREEN_RIGHT - SCREEN_LEFT) * left / 100.0;
18
view->right = SCREEN_LEFT + (SCREEN_RIGHT - SCREEN_LEFT) * right / 100.0;
20
if (view->top < SCREEN_TOP)
21
view->top = SCREEN_TOP;
22
if (view->bottom > SCREEN_BOTTOM)
23
view->bottom = SCREEN_BOTTOM;
24
if (view->left < SCREEN_LEFT)
25
view->left = SCREEN_LEFT;
26
if (view->right > SCREEN_RIGHT)
27
view->right = SCREEN_RIGHT;
29
Outline_box(view->top, view->bottom, view->left, view->right);
36
view->nrows = view->bottom - view->top + 1;
37
view->ncols = view->right - view->left + 1;
38
view->cell.configured = 0;
43
int Init_graphics(void)
48
SCREEN_TOP = R_screen_top();
49
SCREEN_BOTTOM = R_screen_bot();
50
SCREEN_LEFT = R_screen_left();
51
SCREEN_RIGHT = R_screen_rite();
54
BLACK = D_translate_color("black");
55
BLUE = D_translate_color("blue");
56
BROWN = D_translate_color("brown");
57
GREEN = D_translate_color("green");
58
GREY = D_translate_color("grey");
59
ORANGE = D_translate_color("orange");
60
PURPLE = D_translate_color("purple");
61
RED = D_translate_color("red");
62
WHITE = D_translate_color("white");
63
YELLOW = D_translate_color("yellow");
65
R_standard_color(WHITE);
67
VIEW_TITLE1 = makeview(97.5, 100.0, 0.0, 50.0);
68
VIEW_TITLE2 = makeview(97.5, 100.0, 50.0, 100.0);
69
VIEW_MAP1 = makeview(51.0, 97.5, 0.0, 50.0);
70
VIEW_MAP2 = makeview(51.0, 97.5, 50.0, 100.0);
71
VIEW_TITLE1_ZOOM = makeview(47.5, 51.0, 0.0, 50.0);
72
VIEW_TITLE2_ZOOM = makeview(47.5, 51.0, 50.0, 100.0);
73
VIEW_MAP1_ZOOM = makeview(2.5, 47.5, 0.0, 50.0);
74
VIEW_MAP2_ZOOM = makeview(2.5, 47.5, 50.0, 100.0);
75
VIEW_MENU = makeview(0.0, 2.5, 0.0, 100.0);
77
G_init_colors(&VIEW_MAP1->cell.colors);
78
G_init_colors(&VIEW_MAP2->cell.colors);
83
int Outline_box(int top, int bottom, int left, int right)
85
R_move_abs(left, top);
86
R_cont_abs(left, bottom);
87
R_cont_abs(right, bottom);
88
R_cont_abs(right, top);
89
R_cont_abs(left, top);
95
int Text_width(char *text)
97
int top, bottom, left, right;
99
R_get_text_box(text, &top, &bottom, &left, &right);
102
return right - left + 1;
104
return left - right + 1;
107
int Text(char *text, int top, int bottom, int left, int right, int edge)
109
R_set_window(top, bottom, left, right);
110
R_move_abs(left + edge, bottom - edge);
112
R_set_window(SCREEN_TOP, SCREEN_BOTTOM, SCREEN_LEFT, SCREEN_RIGHT);
117
int Uparrow(int top, int bottom, int left, int right)
119
R_move_abs((left + right) / 2, bottom);
120
R_cont_abs((left + right) / 2, top);
121
R_cont_rel((left - right) / 2, (bottom - top) / 2);
122
R_move_abs((left + right) / 2, top);
123
R_cont_rel((right - left) / 2, (bottom - top) / 2);
128
int Downarrow(int top, int bottom, int left, int right)
130
R_move_abs((left + right) / 2, top);
131
R_cont_abs((left + right) / 2, bottom);
132
R_cont_rel((left - right) / 2, (top - bottom) / 2);
133
R_move_abs((left + right) / 2, bottom);
134
R_cont_rel((right - left) / 2, (top - bottom) / 2);