gfx::Rect Entry::onGetEntryTextBounds() const { gfx::Rect bounds = clientBounds(); bounds.x += border().left(); bounds.y += bounds.h/2 - textHeight()/2; bounds.w -= border().width(); bounds.h = textHeight(); return bounds; }
int MSToggleButtonBase::computePixmapXCoord(const MSPixmap *pmap_) { int offset=highlightThickness()+shadowThickness()+margin(); int r; if (alignment()&MSLeft) r=offset+textHeight()+spacing(); else if (alignment()&MSRight) r=width()-offset-pmap_->width(); else { int leftOffset=highlightThickness()+shadowThickness()+margin()+textHeight()+spacing(); r=(width()-leftOffset-pmap_->width())/2+leftOffset; } return r; }
void drawText(XPoint position, string message, Color clr){ XGCValues local_gc_vals; local_gc_vals.foreground = clr; local_gc_vals.font = xfs->fid; // Create gc for current drawable GC local_gc = XCreateGC(display, curr_d, GCForeground |GCFont, &local_gc_vals); char *cstr = new char [message.size()+1]; strcpy (cstr, message.c_str()); XTextItem ti; ti.chars = cstr; ti.nchars = strlen(cstr); ti.delta = 0; ti.font = None; XSync(display, false); XDrawText(display, curr_d, local_gc, position.x-textWidth(message)/2, position.y+textHeight()/2 - textDescent(), &ti, 1); XSync(display, false); // Free temporary GC XFreeGC(display, local_gc); }
bool drawText(int x_, int y_, string text_, string size_, Font *font_, int sX_, int sY_, int sWidth_, int sHeight_, int indent_) { // Draw text if(x_ >= sX_ && y_ >= sY_ && x_ + textWidth(text_, size_, font_, indent_) <= sX_ + sWidth_ && y_ + textHeight(text_, size_, font_) <= sY_ + sHeight_) { // Draw int charX = x_; for(size_t f = 0; f < text_.size(); f++) { // Draw font_->image[text_[f]]->draw(charX, y_, size_); // Add character X charX += font_->image[text_[f]]->width(size_) + indent_; } } else { return false; } return true; }
void MSToggleButtonBase::computeSize(void) { int oldW=width(); int oldH=height(); int newW,newH; int offset =(highlightThickness()+shadowThickness()+margin())<<1; if (pixmap()!=0) { newW=pixmap()->width()+textHeight()+spacing()+offset; newH=pixmap()->height()+offset; } else { newW=maxPixelWidth()+textHeight()+spacing()+offset; newH=rows()*textHeight()+offset; } if (oldW==newW&&oldH==newH) redraw(); else resize(newW,newH); }
void Buffer::setupMarginIcons() { QIcon bookmarkIcon = IconDb::instance()->getIcon(IconDb::Bookmark); QImage image = bookmarkIcon.pixmap(16).toImage(); int dim = std::min(textHeight(0), marginWidthN(Icon)); image = image.scaled(dim, dim); rGBAImageSetWidth(dim); rGBAImageSetHeight(dim); markerDefineRGBAImage(Bookmark, reinterpret_cast<const char*>( image.rgbSwapped().bits())); }
bool Label::draw(int scrW, int scrH) { // Draw label // Center coords int lCX = alignX(x + width/2, scrW); int lCY = alignY(y + height/2, scrH); // Try Big size if(!drawText(lCX - textWidth(text, "big", font) / 2, lCY - textHeight(text, "big", font) / 2, animationText(), "big", font, alignX(x, scrW), alignY(y, scrH), alignX(width, scrW), alignY(height, scrH), indent)) { // Try Normal size if(!drawText(lCX - textWidth(text, "normal", font) / 2, lCY - textHeight(text, "normal", font) / 2, animationText(), "normal", font, alignX(x, scrW), alignY(y, scrH), alignX(width, scrW), alignY(height, scrH), indent)) { // Try Small size if(!drawText(lCX - textWidth(text, "small", font) / 2, lCY - textHeight(text, "small", font) / 2, animationText(), "small", font, alignX(x, scrW), alignY(y, scrH), alignX(width, scrW), alignY(height, scrH), indent)) { // Try Natural size return drawText(lCX - textWidth(text, "natural", font) / 2, lCY - textHeight(text, "natural", font) / 2, animationText(), "natural", font, alignX(x, scrW), alignY(y, scrH), alignX(width, scrW), alignY(height, scrH), indent); } } } return true; }
void AnsiWidget::setXY(int x, int y) { if (x != _back->_curX || y != _back->_curY) { int lineHeight = textHeight(); int newLines = (y - _back->_curY) / lineHeight; while (newLines-- > 0) { _back->newLine(lineHeight); } _back->_curX = (x == 0) ? INITXY : x; _back->_curY = y; flush(false, false, MAX_PENDING_GRAPHICS); } }
void UBGraphicsTextItem::contentsChanged() { if (scene()) { scene()->setModified(true); } if (toPlainText().isEmpty()) { resize(textWidth(),textHeight()); } }
void MSToggleButtonBase::configure(void) { int Xoffset=highlightThickness()+shadowThickness()+margin()+textHeight()+spacing(); int Yoffset=highlightThickness()+shadowThickness()+margin(); XRectangle clipRect[1]; clipRect[0].x=0; clipRect[0].y=0; clipRect[0].width=drawWidth(); clipRect[0].height=drawHeight(); XSetClipRectangles(display(),textGC(),Xoffset,Yoffset,&clipRect[0],1,Unsorted); redraw(); }
// update the widget to new dimensions void AnsiWidget::resize(int newWidth, int newHeight) { int lineHeight = textHeight(); for (int i = 0; i < MAX_SCREENS; i++) { Screen *screen = _screens[i]; if (screen) { screen->resize(newWidth, newHeight, _width, _height, lineHeight); if (screen == _front) { screen->drawBase(false); } } } _width = newWidth; _height = newHeight; }
// prints the contents of the given string onto the backbuffer void AnsiWidget::print(const char *str) { int len = strlen(str); if (len) { _back->drawInto(); int lineHeight = textHeight(); const char *p = (char *)str; while (*p) { switch (*p) { case '\a': // beep dev_beep(); break; case '\t': _back->calcTab(); break; case '\003': // end of text flush(true); break; case '\xC': clearScreen(); break; case '\033': // ESC ctrl chars handleEscape(p, lineHeight); break; case '\034': // file separator break; case '\n': // new line _back->newLine(lineHeight); break; case '\r': // return _back->_curX = INITXY; // erasing the line will clear any previous text break; default: p += _back->print(p, lineHeight) - 1; // allow for p++ break; }; if (*p == '\0') { break; } p++; } // cleanup flush(false); } }
scigraphics::wcoord scigraphics::legend::drawGraphLegend( painter &Painter, wcoord y, const graph &Graph, const textStyle &Style ) { const wcoord TextHeight = textHeight( Painter, Graph.legend(), Style ); wcoord x = getRectangle().left() + textHorizontalIndent(); wcoord ExampleWidth = Graph.legendExampleWidth(); wcoord GraphLegendHeight = std::max( Graph.legendExampleHeight(), TextHeight ); Graph.drawLegendExample( Painter, wrectangle( wpoint(x,y-GraphLegendHeight), wpoint(x+ExampleWidth,y) ) ); x += ExampleWidth + textHorizontalIndent(); Painter.drawTextW( Graph.legend(), wpoint(x,y-GraphLegendHeight/2), painter::HLeft|painter::VCenter, Style ); return GraphLegendHeight; }
void Label::onSizeHint(SizeHintEvent& ev) { gfx::Size sz(0, 0); if (hasText()) { // Labels are not UIString sz.w = font()->textLength(text().c_str()); sz.h = textHeight(); } sz.w += border().width(); sz.h += border().height(); ev.setSizeHint(sz); }
int MSToggleButtonBase::computeXCoord(int /*row_*/,int col_,const char *pString_,int len_) { int offset=highlightThickness()+shadowThickness()+margin(); int leftOffset=offset+textHeight()+spacing(); int r=0; if (pString_!=0) { if (alignment()&MSLeft) r=leftOffset+textWidth(pString_,col_); else if (alignment()&MSRight) { int xs=width()-offset-textWidth(pString_,len_); r=xs+textWidth(pString_,col_); } else { int delta=drawWidth()-textWidth(pString_,len_)-leftOffset; delta=(delta>0)?delta>>1:0; r=leftOffset+delta+textWidth(pString_,col_); } } return r; }
/*! \internal */ QFont HbFontSpecPrivate::font() { #ifdef HB_BOOTSTRAPPED return QFont(); #else if (mRole == HbFontSpec::Undefined && mFontName.isEmpty()) { return QFont(); } QString typefaceFamily(mFontName); int weight(QFont::Normal); HbTypefaceInfo *tInfo = HbInstancePrivate::d_ptr()->typefaceInfo(); // Non-owning pointer if (mRole != HbFontSpec::Undefined) { tInfo->roleToTypeface(mRole, typefaceFamily, weight); mFontName = typefaceFamily; } else if (!tInfo->containsFamily(typefaceFamily)) { QString aliasFamily; if (tInfo->tryGetFamilyFromAliasName(typefaceFamily, aliasFamily, weight)) { typefaceFamily = aliasFamily; } } else { weight = tInfo->getWeight(typefaceFamily); } QFont font(typefaceFamily); font.setWeight(weight); // Sets default size if text height is not set explicitly. qreal height = textHeight(); int downSizedSize = tInfo->textHeightToSizeInPixels(typefaceFamily, weight, height); font.setPixelSize(downSizedSize); return font; #endif }
/* Calculates the rects for the popup text and background. Does nothing if the rect is the same as the last time it was called. */ void HbIndexFeedbackPrivate::calculatePopupRects() { Q_Q( HbIndexFeedback ); if (!mItemView) { return; } QRectF contentRect = mItemView->mapToItem(q, mItemView->rect()).boundingRect(); HbScrollBar *verticalScrollBar = mItemView->verticalScrollBar(); HbScrollBar *horizontalScrollBar = mItemView->horizontalScrollBar(); if (verticalScrollBar->isInteractive()) { contentRect.setWidth( contentRect.width() - verticalScrollBar->rect().width() ); if (HbApplication::layoutDirection() == Qt::RightToLeft) { contentRect.setLeft( contentRect.left() + verticalScrollBar->rect().width() ); } } if (horizontalScrollBar->isInteractive()) { contentRect.setHeight( contentRect.height() - horizontalScrollBar->rect().height() ); } if (contentRect == mItemViewContentsRect) { return; } qreal margin = 0; q->style()->parameter(QLatin1String("hb-param-margin-gene-popup"), margin); QSizeF backgroundSize; QSizeF textSize; switch (mIndexFeedbackPolicy) { case HbIndexFeedback::IndexFeedbackSingleCharacter: case HbIndexFeedback::IndexFeedbackThreeCharacter: { textSize.setHeight( textHeight() ); textSize.setWidth ( textWidth() ); backgroundSize.setHeight( textSize.height() + 2 * margin ); backgroundSize.setWidth ( textSize.width() + 2 * margin ); mPopupBackgroundRect.setLeft( contentRect.left() + (contentRect.width() - backgroundSize.width()) / 2.0 ); mPopupBackgroundRect.setTop ( contentRect.top() + (contentRect.height() - backgroundSize.height()) / 2.0 ); mPopupTextRect.setLeft( mPopupBackgroundRect.left() + margin ); mPopupTextRect.setTop ( mPopupBackgroundRect.top() + margin ); mPopupBackgroundRect.setSize(backgroundSize); mPopupTextRect.setSize(textSize); } break; case HbIndexFeedback::IndexFeedbackString: { textSize.setHeight( textHeight() ); backgroundSize.setHeight( textSize.height() + 2 * margin ); backgroundSize.setWidth( contentRect.width() - 2 * mStringOffset ); textSize.setWidth( backgroundSize.width() - 2 * margin ); mPopupBackgroundRect.setLeft( contentRect.left() + mStringOffset ); mPopupBackgroundRect.setTop( contentRect.top() + (contentRect.height() - backgroundSize.height()) / 2.0 ); mPopupTextRect.setLeft( mPopupBackgroundRect.left() + margin ); mPopupTextRect.setTop ( mPopupBackgroundRect.top() + margin ); mPopupBackgroundRect.setSize(backgroundSize); mPopupTextRect.setSize(textSize); } break; case HbIndexFeedback::IndexFeedbackNone: { mPopupTextRect = QRectF(); mPopupBackgroundRect = QRectF(); } break; } }
QSizeF UBGraphicsTextItem::size() const { return QSizeF(textWidth(), textHeight()); }
QRectF UBGraphicsTextItem::boundingRect() const { qreal width = textWidth(); qreal height = textHeight(); return QRectF(QPointF(), QSizeF(width, height)); }
int GUI_Laftfont::textHeight(std::string& text) { std::wstring t(text.begin(), text.end()); return textHeight(t); }
double Terminal::getHorizontalMargin( Cairo::RefPtr< Cairo::Context > ctx ) const { return textHeight( ctx ) + 10; }
QSize MessageEditor::sizeHint() const { QSize sh = QTextEdit::sizeHint(); sh.setHeight(textHeight(!FAutoResize ? FMinimumLines : 0)); return sh; }
QSize MessageEditor::minimumSizeHint() const { QSize sh = QTextEdit::minimumSizeHint(); sh.setHeight(textHeight(FMinimumLines)); return sh; }