static int dotext(char *text, int top, int bottom, int left, int right, int background) { R_standard_color(background); R_box_abs(left + 1, top + 1, right - 1, bottom - 1); R_standard_color(BLACK); /* center the text */ left = (left + right - Text_width(text)) / 2; Text(text, top, bottom, left, right, 2); return 0; }
int display_title(View * view) { View *title; char left[100], center[100]; int size; *left = 0; *center = 0; if (view->cell.configured) { sprintf(center, "%s (mag %.1f)", view->cell.name, magnification(view)); } if (view == VIEW_MAP1) { sprintf(left, "%s", G_location()); title = VIEW_TITLE1; } else if (view == VIEW_MAP1_ZOOM) { title = VIEW_TITLE1_ZOOM; } if (view == VIEW_MAP2) { sprintf(left, "%s", G_location()); title = VIEW_TITLE2; } else if (view == VIEW_MAP2_ZOOM) { title = VIEW_TITLE2_ZOOM; } Erase_view(title); R_standard_color(WHITE); size = title->nrows - 4; R_text_size(size, size); Text(left, title->top, title->bottom, title->left, title->right, 2); if (*center) { R_standard_color(YELLOW); Text(center, title->top, title->bottom, (title->left + title->right - Text_width(center)) / 2, title->right, 2); } return 0; }
int ask_magnification(int *magnification) { static int use = 1; int x, y; int height; int stat; int width; int top, bottom, left, right; static Objects objects[] = { OTHER(incr, &use), {0} }; Menu_msg(""); mag = *magnification; if (mag < 1) mag = 1; height = VIEW_MENU->nrows; R_text_size(height - 4, height - 4); Get_mouse_xy(&x, &y); top = y - height / 2; if (top < SCREEN_TOP) top = SCREEN_TOP; bottom = top + 4 * height; if (bottom >= VIEW_MENU->top) { top -= bottom - (VIEW_MENU->top - 1); bottom = VIEW_MENU->top - 1; } width = Text_width("MAGNIFICATION") + 4; left = x - width / 2; if (left < SCREEN_LEFT) left = SCREEN_LEFT; right = left + width; if (right > SCREEN_RIGHT) { left -= right - SCREEN_RIGHT; right = SCREEN_RIGHT; } R_panel_save(tempfile1, top, bottom, left, right); R_standard_color(WHITE); R_box_abs(left, top, right, bottom); R_standard_color(BLACK); Outline_box(top, bottom, left, right); plus.top = top + height; plus.bottom = plus.top + height; plus.left = left; plus.right = plus.left + Text_width("++") + 4; Outline_box(plus.top, plus.bottom, plus.left, plus.right); minus.top = top + height; minus.bottom = minus.top + height; minus.right = right; minus.left = minus.right - Text_width("--") - 4; Outline_box(minus.top, minus.bottom, minus.left, minus.right); value.top = top + height; value.bottom = value.top + height; value.left = plus.right; value.right = minus.left; Outline_box(value.top, value.bottom, value.left, value.right); accept.top = value.bottom; accept.bottom = accept.top + height; accept.left = left; accept.right = right; Outline_box(accept.top, accept.bottom, accept.left, accept.right); cancel.top = accept.bottom; cancel.bottom = cancel.top + height; cancel.left = left; cancel.right = right; Outline_box(cancel.top, cancel.bottom, cancel.left, cancel.right); dotext("MAGNIFICATION", top, top + height, left, right, WHITE); dotext("+", plus.top, plus.bottom, plus.left, plus.right, GREY); dotext("-", minus.top, minus.bottom, minus.left, minus.right, GREY); dotext("ACCEPT", accept.top, accept.bottom, accept.left, accept.right, GREY); dotext("CANCEL", cancel.top, cancel.bottom, cancel.left, cancel.right, GREY); draw_mag(); stat = Input_pointer(objects); /* to respond to user */ R_standard_color(WHITE); R_box_abs(left, top, right, bottom); R_flush(); R_panel_restore(tempfile1); R_panel_delete(tempfile1); *magnification = mag; return stat > 0; }
static int draw_objects(Objects * objects) { Objects *obj; int top, bottom, left, right; int size, edge; /* erase the menu window */ Erase_view(VIEW_MENU); R_flush(); /* determine sizes and text indentation */ size = VIEW_MENU->nrows - 4; edge = 2; R_text_size(size, size); left = VIEW_MENU->left; top = VIEW_MENU->top; bottom = VIEW_MENU->bottom; /* put the (boxed) text on the menu view */ for (obj = objects; obj->type; obj++) { if (!visible(obj)) continue; switch (obj->type) { case OPTION_OBJECT: case MENU_OBJECT: right = left + 2 * edge + Text_width(obj->label); obj->left = left; obj->right = right; obj->top = top; obj->bottom = bottom; R_standard_color(FILL_COLOR); R_box_abs(left, top, right, bottom); R_standard_color(TEXT_COLOR); Text(obj->label, top, bottom, left, right, edge); R_standard_color(OUTLINE_COLOR); Outline_box(top, bottom, left, right); left = right; break; case INFO_OBJECT: if (*obj->label == 0) break; if (*obj->status < 0) break; right = left + 2 * edge + Text_width(obj->label); R_standard_color(BLACK); Text(obj->label, top, bottom, left, right, edge); left = right; break; } } draw_option_boxes(objects); R_flush(); return 0; }