コード例 #1
0
void styled_widget::update_canvas()
{
	const int max_width = get_text_maximum_width();
	const int max_height = get_text_maximum_height();

	// set label in canvases
	for(auto & canvas : canvas_)
	{
		canvas.set_variable("text", variant(label_));
		canvas.set_variable("text_markup", variant(use_markup_));
		canvas.set_variable("text_link_aware", variant(get_link_aware()));
		// Possible TODO: Consider making a formula_callable for colours
		color_t link_color = get_link_color();
		std::vector<variant> link_color_as_list{variant(link_color.r), variant(link_color.g), variant(link_color.b), variant(link_color.a)};
		canvas.set_variable("text_link_color", variant(&link_color_as_list));
		canvas.set_variable("text_alignment",
							variant(encode_text_alignment(text_alignment_)));
		canvas.set_variable("text_maximum_width", variant(max_width));
		canvas.set_variable("text_maximum_height", variant(max_height));
		canvas.set_variable("text_wrap_mode",
							variant(can_wrap() ? PANGO_ELLIPSIZE_NONE
											   : PANGO_ELLIPSIZE_END));
		canvas.set_variable("text_characters_per_line",
							variant(get_characters_per_line()));
	}
}
コード例 #2
0
ファイル: control.cpp プロジェクト: ArtBears/wesnoth
void tcontrol::update_canvas()
{
	const int max_width = get_text_maximum_width();
	const int max_height = get_text_maximum_height();

	// set label in canvases
	for(auto & canvas : canvas_)
	{
		canvas.set_variable("text", variant(label_));
		canvas.set_variable("text_markup", variant(use_markup_));
		canvas.set_variable("text_link_aware", variant(get_link_aware()));
		canvas.set_variable("text_link_color", variant(get_link_color()));
		canvas.set_variable("text_alignment",
							variant(encode_text_alignment(text_alignment_)));
		canvas.set_variable("text_maximum_width", variant(max_width));
		canvas.set_variable("text_maximum_height", variant(max_height));
		canvas.set_variable("text_wrap_mode",
							variant(can_wrap() ? PANGO_ELLIPSIZE_NONE
											   : PANGO_ELLIPSIZE_END));
		canvas.set_variable("text_characters_per_line",
							variant(get_characters_per_line()));
	}
}