本文整理汇总了C++中FontBoundingBox类的典型用法代码示例。如果您正苦于以下问题:C++ FontBoundingBox类的具体用法?C++ FontBoundingBox怎么用?C++ FontBoundingBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FontBoundingBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: expose
void Text::expose(unsigned line, unsigned column)
{
if (! canvas_)
return;
String string;
if (line < text_->Height())
{
string = text_->getNth(line);
}
FontBoundingBox fbb;
font_->font_bbox(fbb);
Coord x = columnCoord(string, column) - allocation_->left() + curLowerX_;
bool invisibleX = (x < curLowerX_) || ((x + width(' ')) > curUpperX_);
Coord y = line * (fbb.ascent() + fbb.descent());
bool invisibleY = (y < curLowerY_) || ((y + fbb.ascent() +
fbb.descent()) > curUpperY_);
if (invisibleX)
{
scroll_to(Dimension_X, x - (curUpperX_ - curLowerX_) / 2);
}
if (invisibleY)
{
scroll_to(Dimension_Y, height() - y - (curUpperY_ - curLowerY_) / 2);
}
}
示例2: request
void TextLine::request(Requisition& requisition) const
{
FontBoundingBox fbb;
font_->font_bbox(fbb);
Text::request(requisition);
Requirement ry(fbb.ascent() + fbb.descent(), 0, 0, 0);
requisition.require(Dimension_Y, ry);
}
示例3: scroll_backward
void Text::scroll_backward(DimensionName dimension) {
FontBoundingBox fbb;
font_->font_bbox(fbb);
if (dimension == Dimension_X) {
scroll_to(dimension, cur_lower(Dimension_X) - width(' '));
} else {
scroll_to(dimension, cur_lower(Dimension_Y) -
(fbb.ascent() + fbb.descent()));
}
}
示例4: drawRegion
void Text::drawRegion(const TextRegion& region, unsigned i,
Coord x, Coord y, const String& line) const
{
unsigned line1 = region.line1();
unsigned line2 = region.line2();
unsigned column1 = region.column1();
unsigned column2 = region.column2();
FontBoundingBox fbb;
font_->font_bbox(fbb);
if ((line1 == i) && (line1 == line2) && (column1 < column2))
{
canvas_->fill_rect(columnCoord(line, column1), y - fbb.descent(),
columnCoord(line, column2), y + fbb.ascent(), region.color());
}
if ((line1 == i) && (line1 < line2))
{
canvas_->fill_rect(columnCoord(line, column1), y - fbb.descent(),
allocation_->right(), y + fbb.ascent(), region.color());
}
if ((line1 < i) && (i < line2))
{
canvas_->fill_rect(x, y - fbb.descent(), allocation_->right(), y +
fbb.ascent(), region.color());
}
if ((line2 == i) && (line1 < line2))
{
canvas_->fill_rect(0, y - fbb.descent(), columnCoord(line, column2),
y + fbb.ascent(), region.color());
}
}
示例5: damaged
bool Text::damaged(unsigned line) const
{
FontBoundingBox fbb;
font_->font_bbox(fbb);
Coord base = allocation_->top() + curLowerY_;
Coord lineHeight = fbb.ascent() + fbb.descent();
Coord top = base - lineHeight * line;
Coord bottom = base - lineHeight * (line + 1);
return canvas_->damaged(allocation_->left(), Math::max(bottom,
allocation_->bottom()), allocation_->right(), Math::min(top,
allocation_->top()));
}
示例6: drawLocation
void Text::drawLocation(const TextLocation& location, unsigned i,
Coord /* x */, Coord y, const String& line) const
{
FontBoundingBox fbb;
font_->font_bbox(fbb);
if (location.line_ == i)
{
Coord lb = columnCoord(line, location.column_);
canvas_->fill_rect(lb, y - fbb.descent(), lb + location.width_,
y + fbb.ascent(), location.color_);
}
}
示例7: print
void FieldStringEditor::print(Printer* p, const Allocation& a) const {
const Font* f = output_->GetFont();
const Color* fg = output_->GetFgColor();
FontBoundingBox b;
f->font_bbox(b);
Coord x = a.left(), y = a.bottom() + b.font_descent();
FieldStringEditor* e = (FieldStringEditor*)this;
for (const char* s = e->Text(); *s != '\0'; s++) {
Coord w = f->width(*s);
p->character(f, *s, w, fg, x, y);
x += w;
}
}
示例8: Glyph
Strut::Strut(
const Font* font, Coord natural, Coord stretch, Coord shrink
) : Glyph() {
font_ = font;
Resource::ref(font_);
if (font_ != nil) {
FontBoundingBox b;
font_->font_bbox(b);
height_ = b.ascent() + b.descent();
alignment_ = (height_ == 0) ? 0 : b.descent() / height_;
}
natural_ = natural;
stretch_ = stretch;
shrink_ = shrink;
}
示例9: damage
void Text::damage(const TextRegion& region) {
if (! canvas_) {
return;
}
FontBoundingBox fbb;
font_->font_bbox(fbb);
Coord base = allocation_->top() + curLowerY_;
Coord lineHeight = fbb.ascent() + fbb.descent();
Coord top = Math::min(base - lineHeight * region.line1(), allocation_->top());
Coord bottom = Math::max(base - lineHeight * (region.line2() + 1),
allocation_->bottom());
if ((allocation_->left() <= allocation_->right()) && (bottom <= top)) {
canvas_->damage(allocation_->left(), bottom, allocation_->right(), top);
}
}
示例10: draw
void Text::draw(Canvas*, const Allocation&) const
{
canvas_->push_clipping();
canvas_->clip_rect(allocation_->left(), allocation_->bottom(),
allocation_->right(), allocation_->top());
FontBoundingBox fbb;
font_->font_bbox(fbb);
Coord r = curLowerY_ / (fbb.ascent() + fbb.descent());
unsigned i = unsigned(r);
Coord y = allocation_->top() + (r - i) * (fbb.ascent() + fbb.descent());
unsigned max = Math::max(Math::max(selection_.line2(), insertion_.line_),
(unsigned) text_->Height() ? (unsigned) text_->Height() - 1 : 0);
for (; i <= max; ++i)
{
y -= fbb.ascent();
if (damaged(i))
{
Coord x = allocation_->left() - curLowerX_;
if (i < text_->Height())
{
const String line = text_->getNth(i);
drawRegion(selection_, i, x, y, line);
if (! readOnly_)
{
drawLocation(insertion_, i, x, y, line);
}
for (GlyphIndex j = 0; j < annotation_.count(); ++j)
{
drawRegion(*annotation_.item(j), i, x, y, line);
}
drawLine(i, x, y, line);
}
else
{
String line;
drawRegion(selection_, i, x, y, line);
if (! readOnly_)
{
drawLocation(insertion_, i, x, y, line);
}
for (GlyphIndex j = 0; j < annotation_.count(); ++j)
{
drawRegion(*annotation_.item(j), i, x, y, line);
}
drawLine(i, x, y, line);
}
}
y -= fbb.descent();
if (y < (allocation_->bottom() - fbb.ascent()))
break;
}
canvas_->pop_clipping();
}
示例11: snap
bool Text::snap(
const Event& event,
unsigned& line,
unsigned& column) const
{
unsigned originalLine = line;
unsigned originalColumn = column;
Coord x = event.pointer_x() - allocation_->left() + curLowerX_;
Coord y = allocation_->top() + curLowerY_ - event.pointer_y();
FontBoundingBox fbb;
font_->font_bbox(fbb);
line = Math::max(int(y / (fbb.ascent() + fbb.descent())), 0);
if (line < text_->Height())
{
const String& string = text_->getNth(line);
unsigned i;
for (i = 0; i < string.length(); ++i)
{
x -= width(string[i]) / 2.0;
if (x < 0)
break;
x -= width(string[i]) / 2.0;
}
column = i;
if (i > 0 && string[i-1] == '\n') {
--column;
}
// if (i >= string.length())
// column += (unsigned) ((x + width(' ') / 2) / width(' '));
}
else if (text_->Height() > 0) {
line = text_->Height()-1;
column = text_->getNth(line).length();
//column = (unsigned) ((x + width(' ') / 2) / width(' '));
}else{
line = 0;
column = 0;
}
column = Math::max(column, unsigned(0));
return (line != originalLine) || (column != originalColumn);
}
示例12: Glyph
Character::Character(long ch, const Font* f, const Color* c) : Glyph() {
c_ = ch;
font_ = f;
Resource::ref(font_);
color_ = c;
Resource::ref(color_);
if (font_ != nil) {
FontBoundingBox b;
font_->char_bbox(c_, b);
left_bearing_ = b.left_bearing();
right_bearing_ = b.right_bearing();
width_ = b.width();
ascent_ = b.font_ascent();
descent_ = b.font_descent();
height_ = ascent_ + descent_;
alignment_ = (height_ == 0) ? 0 : descent_ / height_;
} else {
left_bearing_ = 0;
right_bearing_ = 0;
ascent_ = 0;
descent_ = 0;
width_ = 0;
height_ = 0;
alignment_ = 0;
}
}
示例13: if
void Text31::init () {
LayoutKit* layout = LayoutKit::instance();
PolyGlyph* col = layout->vbox();
PolyGlyph* line = layout->hbox();
FontBoundingBox bbox;
_font->font_bbox(bbox);
Coord lineheight = bbox.ascent() + bbox.descent();
char ch;
for (int i = 0; (*_text)[i] != '\0'; i++) {
ch = (*_text)[i];
if (ch == '\n') {
line->append(layout->strut(_font));
col->append(layout->fixed_dimension(line, Dimension_Y,lineheight));
line = layout->hbox();
} else if (ch == ' ') {
line->append(new Character(' ', _font, _stroke));
} else if (ch != ')' && ch != '(') {
if (ch == '\\') {
ch = (*_text)[++i];
if (isdigit(ch)) {
ch -= '0';
ch *= 8;
char digit;
digit = (*_text)[i++];
ch = (ch * 8) + digit - '0';
digit = (*_text)[i++];
ch = (ch * 8) + digit - '0';
}
}
line->append(new Character(ch, _font, _stroke));
}
}
Transformer fixtext;
fixtext.translate(0, bbox.descent());
_t->premultiply(fixtext);
_body->append(col);
}
示例14: height
Coord Text::height() const {
FontBoundingBox fbb;
font_->font_bbox(fbb);
return text_->Height() * (fbb.ascent() + fbb.descent());
}
示例15: read_idraw_graphic
Glyph* read_idraw_graphic (
FILE* file, const Brush* pb, const Color* pfg, const Color* pbg,
const Font* pf, Stipple* ps
) {
skip(file);
Transformer tx;
Glyph* glyph = nil;
const LayoutKit& layout = *LayoutKit::instance();
if (fscanf(file, "%s", buffer) != EOF) {
figure& fig = figures[which(figures, buffer)];
if (strcmp(fig.name, "Idraw") == 0) {
fscanf(file, "%d", &drawing_version);
figures = versions[drawing_version];
}
const Brush* b = (fig.brush) ? read_brush(file) : nil;
const Color* fg = (fig.foreground) ? read_color(file) : nil;
const Color* bg = (fig.background) ? read_color(file) : nil;
const Font* f = (fig.font) ? read_font(file) : nil;
Stipple* s = (fig.pattern) ? read_stipple(file) : nil;
if (fig.transformer) {
read_transformer(file, tx);
}
if (pb) b = pb;
if (pfg) fg = pfg;
if (pbg) bg = pbg;
if (pf) f = pf;
if (ps) s = ps;
if (fig.name == nil) {
; // error
} else if (
strcmp(fig.name, "Idraw") == 0 || strcmp(fig.name, "Pict") == 0
) {
Glyph* pic = layout.overlay();
Glyph* g;
do {
g = read_idraw_graphic(file, b, fg, bg, f, s);
if (g != nil) {
pic->append(g);
}
} while (g != nil);
glyph = pic;
} else if (strcmp(fig.name, "eop") == 0) {
glyph = nil;
} else if (strcmp(fig.name, "Text") == 0) {
skip(file);
fscanf(file, "%s", buffer);
getc(file);
PolyGlyph* col = layout.vbox_first_aligned();
PolyGlyph* line = layout.hbox_first_aligned();
FontBoundingBox bbox;
f->font_bbox(bbox);
Coord lineheight = bbox.font_ascent() + bbox.font_descent();
if (_idraw_font_metrics) {
lineheight /= fixtextscale;
}
int c;
while ((c = getc(file)) != ']') {
if (c == '\n') {
line->append(layout.strut(f));
col->append(
layout.v_fixed_span(line, lineheight)
);
line = layout.hbox();
} else if (c == ' ') {
if (_idraw_font_metrics) {
line->append(
layout.shape_of(new Character(' ', f, fg))
);
} else {
line->append(new Character(' ', f, fg));
}
} else if (c != ')' && c != '(') {
if (c == '\\') {
c = getc(file);
if (isdigit(c)) {
c -= '0';
c = (c * 8) + getc(file) - '0';
c = (c * 8) + getc(file) - '0';
}
}
line->append(new Character(c, f, fg));
}
}
Transformer fixtext;
if (_idraw_font_metrics) {
fixtext.scale(fixtextscale, fixtextscale);
}
fixtext.translate(0, bbox.font_descent() - lineheight);
glyph = new TransformSetter(col, fixtext);
} else {
skip(file);
int c = fig.coords;
if (c == -1) {
fscanf(file, "%d", &c);
}
Coord xx, yy;
Coord* x = new Coord[c];
//.........这里部分代码省略.........