unsigned long gt_layout_get_height(const GtLayout *layout) { GtTracklineInfo lines; double tmp, head_track_space = HEAD_TRACK_SPACE_DEFAULT; bool show_track_captions; unsigned long height, line_height, i; gt_assert(layout); /* get dynamic heights from tracks */ lines.style = layout->style; lines.height = 0; (void) gt_hashmap_foreach(layout->tracks, add_tracklines, &lines, NULL); height = lines.height; /* obtain line height and spacer from style */ if (gt_style_get_num(layout->style, "format", "bar_height", &tmp, NULL)) line_height = tmp; else line_height = BAR_HEIGHT_DEFAULT; if (gt_style_get_num(layout->style, "format", "bar_vspace", &tmp, NULL)) line_height += tmp; else line_height += BAR_VSPACE_DEFAULT; if (!(gt_style_get_bool(layout->style, "format","show_track_captions", &show_track_captions, NULL))) show_track_captions = true; /* add custom track space allotment */ if (show_track_captions) { double theight = TOY_TEXT_HEIGHT, captionspace = CAPTION_BAR_SPACE_DEFAULT; (void) gt_style_get_num(layout->style, "format", "track_caption_font_size", &theight, NULL); (void) gt_style_get_num(layout->style, "format", "track_caption_space", &captionspace, NULL); height += gt_array_size(layout->custom_tracks) * (theight + captionspace); } for (i=0;i<gt_array_size(layout->custom_tracks);i++) { GtCustomTrack *ct = *(GtCustomTrack**) gt_array_get(layout->custom_tracks, i); height += gt_custom_track_get_height(ct); (void) gt_style_get_num(layout->style, "format", "track_vspace", &tmp, NULL); height += tmp; } /* add header space and footer */ (void) gt_style_get_num(layout->style, "format", "ruler_space", &head_track_space, NULL); height += HEADER_SPACE + head_track_space + FOOTER_SPACE; return height; }
int gt_layout_get_height(GtLayout *layout, unsigned long *result, GtError *err) { int had_err = 0; GtTracklineInfo lines; double tmp, head_track_space = HEAD_TRACK_SPACE_DEFAULT; bool show_track_captions = true; unsigned long height, i; gt_assert(layout); had_err = layout_all_tracks(layout, err); if (!had_err) { /* get dynamic heights from tracks */ lines.style = layout->style; lines.height = 0; if (gt_hashmap_foreach(layout->tracks, add_tracklines, &lines, err) < 0) { return -1; } height = lines.height; if (gt_style_get_bool(layout->style, "format","show_track_captions", &show_track_captions, NULL, err) == GT_STYLE_QUERY_ERROR) { return -1; } /* add custom track space allotment */ if (show_track_captions) { double theight = TEXT_SIZE_DEFAULT, captionspace = CAPTION_BAR_SPACE_DEFAULT; if (gt_style_get_num(layout->style, "format", "track_caption_font_size", &theight, NULL, err) == GT_STYLE_QUERY_ERROR) { return -1; } if (gt_style_get_num(layout->style, "format", "track_caption_space", &captionspace, NULL, err) == GT_STYLE_QUERY_ERROR) { return -1; } height += gt_array_size(layout->custom_tracks) * (theight + captionspace); } for (i=0;i<gt_array_size(layout->custom_tracks);i++) { GtCustomTrack *ct = *(GtCustomTrack**) gt_array_get(layout->custom_tracks, i); height += gt_custom_track_get_height(ct); if (gt_style_get_num(layout->style, "format", "track_vspace", &tmp, NULL, err) == GT_STYLE_QUERY_ERROR) { return -1; } height += tmp; } /* add header space and footer */ if (gt_style_get_num(layout->style, "format", "ruler_space", &head_track_space, NULL, err) == GT_STYLE_QUERY_ERROR) { return -1; } height += HEADER_SPACE + head_track_space + FOOTER_SPACE; *result = height; return 0; } return had_err; }
int gt_canvas_cairo_visit_custom_track(GtCanvas *canvas, GtCustomTrack *ct, GtError *err) { bool show_track_captions = true; double space; int had_err = 0; GtColor color; gt_assert(canvas && ct); if (gt_style_get_bool(canvas->pvt->sty, "format", "show_track_captions", &show_track_captions, NULL, err) == GT_STYLE_QUERY_ERROR) { return -1; } if (gt_style_get_color(canvas->pvt->sty, "format", "track_title_color", &color, NULL, err) == GT_STYLE_QUERY_ERROR) { return -1; } if (show_track_captions) { double theight = gt_graphics_get_text_height(canvas->pvt->g), captionspace = CAPTION_BAR_SPACE_DEFAULT; if (gt_style_get_num(canvas->pvt->sty, "format", "track_caption_font_size", &theight, NULL, err) == GT_STYLE_QUERY_ERROR) { return -1; } /* draw track title */ gt_graphics_set_font(canvas->pvt->g, "Sans", SLANT_NORMAL, WEIGHT_NORMAL, theight); gt_graphics_draw_colored_text(canvas->pvt->g, canvas->pvt->margins, canvas->pvt->y, color, gt_custom_track_get_title(ct)); if (gt_style_get_num(canvas->pvt->sty, "format", "track_caption_space", &captionspace, NULL, err) == GT_STYLE_QUERY_ERROR) { return -1; } canvas->pvt->y += theight + captionspace; } /* call rendering function */ had_err = gt_custom_track_render(ct, canvas->pvt->g, canvas->pvt->y, canvas->pvt->viewrange, canvas->pvt->sty, err); canvas->pvt->y += gt_custom_track_get_height(ct); /* put spacers after track */ space = TRACK_VSPACE_DEFAULT; if (gt_style_get_num(canvas->pvt->sty, "format", "track_vspace", &space, NULL, err) == GT_STYLE_QUERY_ERROR) { return -1; } canvas->pvt->y += space; return had_err; }