Exemple #1
0
void InsetPreview::metrics(MetricsInfo & mi, Dimension & dim) const
{
	if (previewState(mi.base.bv)) {
		preview_->metrics(mi, dim);
		mi.base.textwidth += 2 * TEXT_TO_INSET_OFFSET;
		
		dim.wid = max(dim.wid, 4);
		dim.asc = max(dim.asc, 4);
		
		dim.asc += TEXT_TO_INSET_OFFSET;
		dim.des += TEXT_TO_INSET_OFFSET;
		dim.wid += TEXT_TO_INSET_OFFSET;
		dim_ = dim;
		dim.wid += TEXT_TO_INSET_OFFSET;
		// insert a one pixel gap
		dim.wid += 1;
		// Cache the inset dimension.
		setDimCache(mi, dim);
		Dimension dim_dummy;
		MetricsInfo mi_dummy = mi;
		InsetText::metrics(mi_dummy, dim_dummy);
		return;
	}
	InsetText::metrics(mi, dim);
}
Exemple #2
0
void CommandInset::metrics(MetricsInfo & mi, Dimension & dim) const
{
	if (!set_label_) {
		set_label_ = true;
		button_.update(screenLabel(), true);
	}
	button_.metrics(mi, dim);
	// Cache the inset dimension. 
	setDimCache(mi, dim);
}
void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
{
	frontend::FontMetrics const & fm =
		theFontMetrics(mi.base.font);
	dim.asc = fm.maxAscent();
	dim.des = fm.maxDescent();

	string s;
	switch (kind_) {
		case LIGATURE_BREAK:
			s = "|";
			break;
		case END_OF_SENTENCE:
			s = ".";
			break;
		case LDOTS:
			s = ". . .";
			break;
		case MENU_SEPARATOR:
			s = " x ";
			break;
		case HYPHENATION:
			s = "-";
			break;
		case SLASH:
			s = "/";
			break;
		case NOBREAKDASH:
			s = "-";
			break;
	}
	docstring ds(s.begin(), s.end());
	dim.wid = fm.width(ds);
	if (kind_ == HYPHENATION && dim.wid > 5)
		dim.wid -= 2; // to make it look shorter
	
	setDimCache(mi, dim);
}