Пример #1
0
void menu::update_scrollbar_grip_height()
{
	//set_full_size(items_.size());
	int h = heading_height();
	for(int i = 0; i < items_.size(); i++)
		h += get_item_height(i);	
	set_full_size(h);
	size_t max_height = (max_height_ == -1 ? (video().gety()*88)/100 : max_height_) - heading_height();
	if (max_height > h)
		max_height = h;
	set_shown_size(max_height);
}
void scrollpane::update_content_size()
{
	unsigned int maxx = 0;
	unsigned int maxy = 0;

	for(widget_map::iterator itor = content_.begin(); itor != content_.end(); ++itor) {
		if(itor->second.x + itor->second.w->width() > maxx) {
			maxx = itor->second.x + itor->second.w->width();
		}
		if(itor->second.y + itor->second.w->height() > maxy) {
			maxy = itor->second.y + itor->second.w->height();
		}
	}

	content_pos_.w = maxx;
	content_pos_.h = maxy;

	set_full_size(maxy);
	set_shown_size(client_area().h);

	set_dirty();
}
Пример #3
0
void textbox::update_text_cache(bool changed, const SDL_Color& color)
{
	if(changed) {
		char_x_.clear();
		char_y_.clear();

		text_image_.assign(add_text_line(text_, color));
	}

	int cursor_x = char_x_[cursor_];

	if(cursor_x - text_pos_ > location().w) {
		text_pos_ = cursor_x - location().w;
	} else if(cursor_x - text_pos_ < 0) {
		text_pos_ = cursor_x;
	}
	cursor_pos_ = cursor_x - text_pos_;

	if (!text_image_.null()) {
		set_full_size(text_image_->h);
		set_shown_size(location().h);
	}
}
Пример #4
0
void menu::update_scrollbar_grip_height()
{
	set_full_size(items_.size());
	set_shown_size(max_items_onscreen());
}
Пример #5
0
void help_text_area::set_items()
{
	last_row_.clear();
	items_.clear();
	curr_loc_.first = 0;
	curr_loc_.second = 0;
	curr_row_height_ = min_row_height_;
	// Add the title item.
	const std::string show_title =
		font::make_text_ellipsis(shown_topic_->title, title_size, inner_location().w);
	surface surf(font::get_rendered_text(show_title, title_size,
					     font::NORMAL_COLOR, TTF_STYLE_BOLD));
	if (surf != NULL) {
		add_item(item(surf, 0, 0, show_title));
		curr_loc_.second = title_spacing_;
		contents_height_ = title_spacing_;
		down_one_line();
	}
	// Parse and add the text.
	std::vector<std::string> const &parsed_items = shown_topic_->text.parsed_text();
	std::vector<std::string>::const_iterator it;
	for (it = parsed_items.begin(); it != parsed_items.end(); ++it) {
		if (*it != "" && (*it)[0] == '[') {
			// Should be parsed as WML.
			try {
				config cfg;
				std::istringstream stream(*it);
				read(cfg, stream);

#define TRY(name) do { \
				if (config &child = cfg.child(#name)) \
					handle_##name##_cfg(child); \
				} while (0)

				TRY(ref);
				TRY(img);
				TRY(bold);
				TRY(italic);
				TRY(header);
				TRY(jump);
				TRY(format);

#undef TRY

			}
			catch (config::error& e) {
				std::stringstream msg;
				msg << "Error when parsing help markup as WML: '" << e.message << "'";
				throw parse_error(msg.str());
			}
		}
		else {
			add_text_item(*it);
		}
	}
	down_one_line(); // End the last line.
	int h = height();
	set_position(0);
	set_full_size(contents_height_);
	set_shown_size(h);
}