void textui_textblock_place(textblock *tb, region orig_area, const char *header) { const char *text = textblock_text(tb); const byte *attrs = textblock_attrs(tb); /* xxx on resize this should be recalculated */ region area = region_calculate(orig_area); size_t *line_starts = NULL, *line_lengths = NULL; size_t n_lines; n_lines = textblock_calculate_lines(tb, &line_starts, &line_lengths, area.width); area.page_rows--; if (n_lines > (size_t) area.page_rows) n_lines = area.page_rows; c_prt(TERM_L_BLUE, header, area.row, area.col); area.row++; display_area(text, attrs, line_starts, line_lengths, n_lines, area, 0); mem_free(line_starts); mem_free(line_lengths); }
void a_symbol_radio_callback(Widget w, XtPointer client_data, XtPointer call_data) { int *symbol_selected = (int *)client_data; area_symbol = *symbol_selected; area_prev_grey_pixmap(); display_area(0, PREFS_FRAME); area_prev_show_pixmap(); }
void a_line_points_cb(Widget w, XtPointer client_data, XtPointer call_data) { XmToggleButtonCallbackStruct *cbs = (XmToggleButtonCallbackStruct*)call_data; if(cbs->set) { include_points_flag = TRUE; } else { include_points_flag = FALSE; } area_prev_grey_pixmap(); display_area(0, PREFS_FRAME); area_prev_show_pixmap(); }
void textui_textblock_show(textblock *tb, region orig_area, const char *header) { const char *text = textblock_text(tb); const byte *attrs = textblock_attrs(tb); /* xxx on resize this should be recalculated */ region area = region_calculate(orig_area); size_t *line_starts = NULL, *line_lengths = NULL; size_t n_lines; n_lines = textblock_calculate_lines(tb, &line_starts, &line_lengths, area.width); screen_save(); /* make room for the header & footer */ area.page_rows -= 3; c_prt(TERM_L_BLUE, header, area.row, area.col); area.row++; if (n_lines > (size_t) area.page_rows) { int start_line = 0; c_prt(TERM_WHITE, "", area.row + area.page_rows, area.col); c_prt(TERM_L_BLUE, "(Up/down or ESCAPE to exit.)", area.row + area.page_rows + 1, area.col); /* Pager mode */ while (1) { struct keypress ch; display_area(text, attrs, line_starts, line_lengths, n_lines, area, start_line); ch = inkey(); if (ch.code == ARROW_UP) start_line--; else if (ch.code== ESCAPE || ch.code == 'q') break; else if (ch.code == ARROW_DOWN) start_line++; else if (ch.code == ' ') start_line += area.page_rows; if (start_line < 0) start_line = 0; if (start_line + (size_t) area.page_rows > n_lines) start_line = n_lines - area.page_rows; } } else { display_area(text, attrs, line_starts, line_lengths, n_lines, area, 0); c_prt(TERM_WHITE, "", area.row + n_lines, area.col); c_prt(TERM_L_BLUE, "(Press any key to continue.)", area.row + n_lines + 1, area.col); inkey(); } mem_free(line_starts); mem_free(line_lengths); screen_load(); return; }
int display_shape(struct Map_info *Map, int type, struct cat_list *Clist, const struct Cell_head *window, const struct color_rgb *bcolor, const struct color_rgb *fcolor, int chcat, const char *icon, double size, const char *size_column, int sqrt_flag, const char *rot_column, /* lines only */ int id_flag, int cats_colors_flag, char *rgb_column, int default_width, char *width_column, double width_scale, char *z_style) { int open_db, field, i, stat; dbCatValArray cvarr_rgb, cvarr_width, cvarr_size, cvarr_rot; struct field_info *fi; dbDriver *driver; int nrec_rgb, nrec_width, nrec_size, nrec_rot, have_colors; struct Colors colors, zcolors; struct bound_box box; stat = 0; nrec_rgb = nrec_width = nrec_size = nrec_rot = 0; open_db = rgb_column || width_column || size_column || rot_column; if (open_db) { field = Clist->field > 0 ? Clist->field : 1; fi = Vect_get_field(Map, field); if (!fi) { G_fatal_error(_("Database connection not defined for layer %d"), field); } driver = db_start_driver_open_database(fi->driver, fi->database); if (!driver) G_fatal_error(_("Unable to open database <%s> by driver <%s>"), fi->database, fi->driver); db_set_error_handler_driver(driver); } /* fisrt search for color table */ have_colors = Vect_read_colors(Vect_get_name(Map), Vect_get_mapset(Map), &colors); if (have_colors && rgb_column) { G_warning(_("Both color table and <%s> option detected. " "Color table will ignored."), "rgb_column"); have_colors = FALSE; } if (rgb_column) { /* read RRR:GGG:BBB color strings from table */ db_CatValArray_init(&cvarr_rgb); nrec_rgb = db_select_CatValArray(driver, fi->table, fi->key, rgb_column, NULL, &cvarr_rgb); G_debug(3, "nrec_rgb (%s) = %d", rgb_column, nrec_rgb); if (cvarr_rgb.ctype != DB_C_TYPE_STRING) { G_warning(_("Color definition column ('%s') not a string. " "Column must be of form 'RRR:GGG:BBB' where RGB values range 0-255. " "You can use '%s' module to define color rules. " "Unable to colorize features."), rgb_column, "v.colors"); rgb_column = NULL; } else { if (nrec_rgb < 0) G_fatal_error(_("Unable to select data ('%s') from table"), rgb_column); G_debug(2, "\n%d records selected from table", nrec_rgb); } } if (width_column) { if (*width_column == '\0') G_fatal_error(_("Line width column not specified")); db_CatValArray_init(&cvarr_width); nrec_width = db_select_CatValArray(driver, fi->table, fi->key, width_column, NULL, &cvarr_width); G_debug(3, "nrec_width (%s) = %d", width_column, nrec_width); if (cvarr_width.ctype != DB_C_TYPE_INT && cvarr_width.ctype != DB_C_TYPE_DOUBLE) G_fatal_error(_("Line width column ('%s') not a number"), width_column); if (nrec_width < 0) G_fatal_error(_("Unable to select data ('%s') from table"), width_column); G_debug(2, "\n%d records selected from table", nrec_width); for (i = 0; i < cvarr_width.n_values; i++) { G_debug(4, "cat = %d %s = %d", cvarr_width.value[i].cat, width_column, (cvarr_width.ctype == DB_C_TYPE_INT ? cvarr_width.value[i].val. i : (int)cvarr_width.value[i].val.d)); } } if (size_column) { if (*size_column == '\0') G_fatal_error(_("Symbol size column not specified")); db_CatValArray_init(&cvarr_size); nrec_size = db_select_CatValArray(driver, fi->table, fi->key, size_column, NULL, &cvarr_size); G_debug(3, "nrec_size (%s) = %d", size_column, nrec_size); if (cvarr_size.ctype != DB_C_TYPE_INT && cvarr_size.ctype != DB_C_TYPE_DOUBLE) G_fatal_error(_("Symbol size column ('%s') is not numeric"), size_column); if (nrec_size < 0) G_fatal_error(_("Unable to select data ('%s') from table"), size_column); G_debug(2, " %d records selected from table", nrec_size); for (i = 0; i < cvarr_size.n_values; i++) { G_debug(4, "(size) cat = %d %s = %.2f", cvarr_size.value[i].cat, size_column, (cvarr_size.ctype == DB_C_TYPE_INT ? (double)cvarr_size.value[i].val.i : cvarr_size.value[i].val.d)); } } if (rot_column) { if (*rot_column == '\0') G_fatal_error(_("Symbol rotation column not specified")); db_CatValArray_init(&cvarr_rot); nrec_rot = db_select_CatValArray(driver, fi->table, fi->key, rot_column, NULL, &cvarr_rot); G_debug(3, "nrec_rot (%s) = %d", rot_column, nrec_rot); if (cvarr_rot.ctype != DB_C_TYPE_INT && cvarr_rot.ctype != DB_C_TYPE_DOUBLE) G_fatal_error(_("Symbol rotation column ('%s') is not numeric"), rot_column); if (nrec_rot < 0) G_fatal_error(_("Unable to select data ('%s') from table"), rot_column); G_debug(2, " %d records selected from table", nrec_rot); for (i = 0; i < cvarr_rot.n_values; i++) { G_debug(4, "(rot) cat = %d %s = %.2f", cvarr_rot.value[i].cat, rot_column, (cvarr_rot.ctype == DB_C_TYPE_INT ? (double)cvarr_rot.value[i].val.i : cvarr_rot.value[i].val.d)); } } if (open_db) { db_close_database_shutdown_driver(driver); } if (z_style) { if (!Vect_is_3d(Map)) { G_warning(_("Vector map is not 3D. Unable to colorize features based on z-coordinates.")); z_style = NULL; } else if (rgb_column) { G_warning(_("%s= and %s= are mutually exclusive. " "%s= will be ignored."), "zcolor", "rgb_column", "zcolor"); z_style = NULL; } else { Vect_get_map_box(Map, &box); Rast_make_fp_colors(&zcolors, z_style, box.B, box.T); } } stat = 0; if (type & GV_AREA && Vect_get_num_primitives(Map, GV_CENTROID | GV_BOUNDARY) > 0) stat += display_area(Map, Clist, window, bcolor, fcolor, chcat, id_flag, cats_colors_flag, default_width, width_scale, z_style ? &zcolors : NULL, rgb_column ? &cvarr_rgb : NULL, have_colors ? &colors : NULL, &cvarr_width, nrec_width); stat += display_lines(Map, type, Clist, bcolor, fcolor, chcat, icon, size, sqrt_flag, id_flag, cats_colors_flag, default_width, width_scale, z_style ? &zcolors : NULL, rgb_column ? &cvarr_rgb : NULL, have_colors ? &colors : NULL, &cvarr_width, nrec_width, &cvarr_size, nrec_size, &cvarr_rot, nrec_rot); return stat; }