bool TextEdit::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: fileNew(); break; case 1: fileOpen(); break; case 2: fileSave(); break; case 3: fileSaveAs(); break; case 4: filePrint(); break; case 5: fileClose(); break; case 6: fileExit(); break; case 7: editUndo(); break; case 8: editRedo(); break; case 9: editCut(); break; case 10: editCopy(); break; case 11: editPaste(); break; case 12: textBold(); break; case 13: textUnderline(); break; case 14: textItalic(); break; case 15: textFamily((const QString&)static_QUType_QString.get(_o+1)); break; case 16: textSize((const QString&)static_QUType_QString.get(_o+1)); break; case 17: textColor(); break; case 18: textAlign((QAction*)static_QUType_ptr.get(_o+1)); break; case 19: fontChanged((const QFont&)*((const QFont*)static_QUType_ptr.get(_o+1))); break; case 20: colorChanged((const QColor&)*((const QColor*)static_QUType_ptr.get(_o+1))); break; case 21: alignmentChanged((int)static_QUType_int.get(_o+1)); break; case 22: editorChanged((QWidget*)static_QUType_ptr.get(_o+1)); break; default: return QMainWindow::qt_invoke( _id, _o ); } return TRUE; }
void BookTextView::PositionIndicatorWithLabels::draw() { PositionIndicator::draw(); const BookTextView& bookTextView = (const BookTextView&)textView(); if (bookTextView.ShowTOCMarksOption.value()) { fb::shared_ptr<ZLTextModel> contentsModelPtr = bookTextView.myContentsModel; if (!contentsModelPtr.isNull()) { ContentsModel &contentsModel = (ContentsModel&)*contentsModelPtr; const int marksNumber = contentsModel.paragraphsNumber(); const size_t startIndex = startTextIndex(); const size_t endIndex = endTextIndex(); const std::vector<size_t> &textSizeVector = textSize(); const int fullWidth = right() - left() - 1; const size_t startPosition = textSizeVector[startIndex]; const size_t fullTextSize = textSizeVector[endIndex] - startPosition; const int bottom = this->bottom(); const int top = this->top(); for (int i = 0; i < marksNumber; ++i) { size_t reference = contentsModel.reference((ZLTextTreeParagraph*)contentsModel[i]); if ((startIndex < reference) && (reference < endIndex)) { int position = left() + 2 + (int) (1.0 * fullWidth * (textSizeVector[reference] - startPosition) / fullTextSize); context().drawLine(position, bottom, position, top); } } } } }
LONG CSkinText::GettextHeight(void) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CSize textSize(Getwidth(), Getheight()); GetTextSize(textSize); return textSize.cy; }
void Tooltip::sizeSelf(void) { Size textSize(getTextSize()); setSize( UVector2(cegui_absdim(textSize.d_width), cegui_absdim(textSize.d_height))); }
void SVGInlineTextBox::paintTextWithShadows(GraphicsContext* context, RenderStyle* style, TextRun& textRun, const SVGTextFragment& fragment, int startPosition, int endPosition) { RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer()); ASSERT(textRenderer); float scalingFactor = textRenderer->scalingFactor(); ASSERT(scalingFactor); const Font& scaledFont = textRenderer->scaledFont(); const ShadowData* shadow = style->textShadow(); FloatPoint textOrigin(fragment.x, fragment.y); FloatSize textSize(fragment.width, fragment.height); if (scalingFactor != 1) { textOrigin.scale(scalingFactor, scalingFactor); textSize.scale(scalingFactor); } FloatRect shadowRect(FloatPoint(textOrigin.x(), textOrigin.y() - scaledFont.fontMetrics().floatAscent()), textSize); do { if (!prepareGraphicsContextForTextPainting(context, scalingFactor, textRun, style)) break; FloatSize extraOffset; if (shadow) extraOffset = applyShadowToGraphicsContext(context, shadow, shadowRect, false /* stroked */, true /* opaque */, true /* horizontal */); AffineTransform originalTransform; if (scalingFactor != 1) { originalTransform = context->getCTM(); AffineTransform newTransform = originalTransform; newTransform.scale(1 / scalingFactor); normalizeTransform(newTransform); context->setCTM(newTransform); } scaledFont.drawText(context, textRun, textOrigin + extraOffset, startPosition, endPosition); if (scalingFactor != 1) context->setCTM(originalTransform); restoreGraphicsContextAfterTextPainting(context, textRun); if (!shadow) break; if (shadow->next()) context->restore(); else context->clearShadow(); shadow = shadow->next(); } while (shadow); }
void draw() { // Show debut output window showDebugOutput(); // Little instructions textSize(20); text("Mouse click will print output of some string operations on the console", 10, height/2); }
void TextWidget::recalculateText() { // perform text initialization. loadTextFont(); myText.setColor(isEnabled() ? getTextColor() : fadeColor(getTextColor(), 0.6f)); sf::FloatRect boundingBox = getTextMaxBoundingBox(); sf::Vector2f pos(boundingBox.left, boundingBox.top); myText.setMaxSize(sf::Vector2f(boundingBox.width, boundingBox.height)); sf::Vector2f textSize(getTextSize()); pos.x += (boundingBox.width - textSize.x) * getTextPreciseAlignment().x; pos.y += (boundingBox.height - textSize.y) * getTextPreciseAlignment().y; /* switch (convertAlignmentHorizontal(getTextAlignment())) { case AlignLeft: default: break; case AlignCenter: pos.x += (boundingBox.width - textSize.x) / 2.f; break; case AlignRight: pos.x += boundingBox.width - textSize.x; break; } switch (convertAlignmentVertical(getTextAlignment())) { case AlignTop: default: break; case AlignCenter: pos.y += (boundingBox.height - textSize.y) / 2.f; break; case AlignBottom: pos.y += boundingBox.height - textSize.y; break; } */ if (isTextPixelPerfect()) pos = sf::Vector2f(sf::Vector2i(pos + sf::Vector2f(0.5f, 0.5f))); if (pos != myText.getPosition()) { myText.setPosition(pos); myText.updateMinor(); } }
void Credits::init() { if (_initialized) return; State::init(); setModal(true); setFullscreen(true); Game::getInstance()->mouse()->pushState(Input::Mouse::Cursor::NONE); auto renderer = Game::getInstance()->renderer(); setPosition(Point((renderer->size().width() - 640) / 2, renderer->size().height())); auto credits = ResourceManager::getInstance()->datFileItem("text/english/credits.txt"); std::stringstream ss; credits->setPosition(0); ss << credits; std::string line; auto font_default = ResourceManager::getInstance()->font("font4.aaf", 0x907824ff); auto font_at = ResourceManager::getInstance()->font("font3.aaf", 0x706050ff); auto font_hash = ResourceManager::getInstance()->font("font4.aaf", 0x8c8c84ff); int y = 0; while (std::getline(ss, line)) { Font* cur_font = font_default; int additionalGap = 0; if (line.find('\r') != std::string::npos) { line.erase(line.find('\r')); } if (line[0] == '#') { line.erase(line.begin()); cur_font = font_hash; } else if (line[0] == '@') { line.erase(line.begin()); cur_font = font_at; additionalGap = 6; } else if (line.empty()) { line = " "; } auto tx = new UI::TextArea(line, 0, y); tx->setFont(cur_font); tx->setSize({640, 0}); tx->setHorizontalAlign(UI::TextArea::HorizontalAlign::CENTER); addUI(tx); _lines.push_back(tx); y += tx->textSize().height() + cur_font->verticalGap() + additionalGap; } _lastTicks=SDL_GetTicks(); }
void CaretInterface::insertCaret(QTextCursor* cursor, const QString& text, const QColor& color, const QString& owner) { QTextCharFormat charFormat; charFormat.setObjectType(CaretFormat); charFormat.setProperty(Text, text); charFormat.setProperty(Owner, owner); charFormat.setProperty(Size, textSize(text)); charFormat.setProperty(Color, color.red() + color.green() * 0x100 + color.blue() * 0x10000); cursor->insertText(QString(QChar::ObjectReplacementCharacter), charFormat); }
void drawTitle() { setFont(verdana18_bold); // draw title of current plot fill(0); textSize(20); textAlign(TX_LEFT, TX_BOTTOM); const char * title = getColumnName(currentColumn); text(title, plotX1, plotY1 - 20); }
void SVGInlineTextBox::paintTextWithShadows(GraphicsContext* context, RenderStyle* style, TextRun& textRun, const SVGTextFragment& fragment, int startPosition, int endPosition) { RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer()); ASSERT(textRenderer); float scalingFactor = textRenderer->scalingFactor(); ASSERT(scalingFactor); const Font& scaledFont = textRenderer->scaledFont(); const ShadowList* shadowList = style->textShadow(); // Text shadows are disabled when printing. http://crbug.com/258321 bool hasShadow = shadowList && !context->printing(); FloatPoint textOrigin(fragment.x, fragment.y); FloatSize textSize(fragment.width, fragment.height); if (scalingFactor != 1) { textOrigin.scale(scalingFactor, scalingFactor); textSize.scale(scalingFactor); context->save(); context->scale(FloatSize(1 / scalingFactor, 1 / scalingFactor)); } if (hasShadow) { DrawLooper drawLooper; for (size_t i = shadowList->shadows().size(); i--; ) { const ShadowData& shadow = shadowList->shadows()[i]; FloatSize offset(shadow.x(), shadow.y()); drawLooper.addShadow(offset, shadow.blur(), shadow.color(), DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowRespectsAlpha); } drawLooper.addUnmodifiedContent(); context->setDrawLooper(drawLooper); } if (prepareGraphicsContextForTextPainting(context, scalingFactor, textRun, style)) { TextRunPaintInfo textRunPaintInfo(textRun); textRunPaintInfo.from = startPosition; textRunPaintInfo.to = endPosition; textRunPaintInfo.bounds = FloatRect(textOrigin, textSize); scaledFont.drawText(context, textRunPaintInfo, textOrigin); restoreGraphicsContextAfterTextPainting(context, textRun); } if (scalingFactor != 1) context->restore(); else if (hasShadow) context->clearShadow(); }
void SVGInlineTextBox::paintTextWithShadows(GraphicsContext* context, RenderStyle* style, TextRun& textRun, const SVGTextFragment& fragment, int startPosition, int endPosition) { float scalingFactor = renderer().scalingFactor(); ASSERT(scalingFactor); const Font& scaledFont = renderer().scaledFont(); const ShadowData* shadow = style->textShadow(); FloatPoint textOrigin(fragment.x, fragment.y); FloatSize textSize(fragment.width, fragment.height); if (scalingFactor != 1) { textOrigin.scale(scalingFactor, scalingFactor); textSize.scale(scalingFactor); } FloatRect shadowRect(FloatPoint(textOrigin.x(), textOrigin.y() - scaledFont.fontMetrics().floatAscent()), textSize); do { if (!prepareGraphicsContextForTextPainting(context, scalingFactor, textRun, style)) break; FloatSize extraOffset; bool didSaveContext = false; if (shadow) extraOffset = applyShadowToGraphicsContext(context, shadow, shadowRect, false /* stroked */, true /* opaque */, true /* horizontal */, didSaveContext); context->save(); context->scale(FloatSize(1 / scalingFactor, 1 / scalingFactor)); scaledFont.drawText(context, textRun, textOrigin + extraOffset, startPosition, endPosition); context->restore(); if (shadow) { if (didSaveContext) context->restore(); else context->clearShadow(); } restoreGraphicsContextAfterTextPainting(context, textRun); if (!shadow) break; shadow = shadow->next(); } while (shadow); }
void drawAxisLabels() { fill(0); textSize(13); //textLeading(15); int yLabel = (plotY1 + plotY2) / 2; textAlign(TX_CENTER, TX_CENTER); text("Gallons", labelX, yLabel ); text("consumed", labelX, yLabel+12); text("per capita", labelX, yLabel+24); textAlign(TX_CENTER, TX_BOTTOM); text("Year", (plotX1 + plotX2) / 2, labelY); }
QSize tSidebarControlVolts::GetTextSize(const QSize& contentSize) { QSize textSize(0, contentSize.height() / 2); if( m_Count >= 3 ) { textSize.setWidth(contentSize.width() / 3); } else if( m_Count == 2 ) { textSize.setWidth(contentSize.width() / 2); } else if( m_Count == 1 ) { textSize.setWidth(contentSize.width()); } return textSize; }
// ------------------------------------------------------- // Boundings including the component text. void Component::entireBounds(int& _x1, int& _y1, int& _x2, int& _y2, float Corr) { _x1 = x1+cx; _y1 = y1+cy; _x2 = x2+cx; _y2 = y2+cy; // text boundings if(tx < x1) _x1 = tx+cx; if(ty < y1) _y1 = ty+cy; int dx, dy, ny; ny = textSize(dx, dy); dy = int(float(ny) / Corr); // correction for unproportional font scaling if((tx+dx) > x2) _x2 = tx+dx+cx; if((ty+dy) > y2) _y2 = ty+dy+cy; }
void SVGInlineTextBox::paintTextWithShadows(GraphicsContext& context, RenderStyle* style, TextRun& textRun, const SVGTextFragment& fragment, int startPosition, int endPosition) { float scalingFactor = renderer().scalingFactor(); ASSERT(scalingFactor); const FontCascade& scaledFont = renderer().scaledFont(); const ShadowData* shadow = style->textShadow(); FloatPoint textOrigin(fragment.x, fragment.y); FloatSize textSize(fragment.width, fragment.height); if (scalingFactor != 1) { textOrigin.scale(scalingFactor, scalingFactor); textSize.scale(scalingFactor); } FloatRect shadowRect(FloatPoint(textOrigin.x(), textOrigin.y() - scaledFont.fontMetrics().floatAscent()), textSize); GraphicsContext* usedContext = &context; do { if (!prepareGraphicsContextForTextPainting(usedContext, scalingFactor, textRun, style)) break; { ShadowApplier shadowApplier(*usedContext, shadow, shadowRect); if (!shadowApplier.didSaveContext()) usedContext->save(); usedContext->scale(FloatSize(1 / scalingFactor, 1 / scalingFactor)); scaledFont.drawText(*usedContext, textRun, textOrigin + shadowApplier.extraOffset(), startPosition, endPosition); if (!shadowApplier.didSaveContext()) usedContext->restore(); } restoreGraphicsContextAfterTextPainting(usedContext, textRun); if (!shadow) break; shadow = shadow->next(); } while (shadow); }
void draw() { background(gray(122)); if (mousePressed) { image(img1, mouseX, mouseY, img1.width, img1.height); } else { image(img2, mouseX, mouseY, img2.width, img2.height); } textFont(font); textAlign(NVG_ALIGN_CENTER); textSize(30); textLeading(5); text("test everything here", width/2, height/2); }
int dMessageEditor::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: clickedSendButton(); break; case 1: splitterMoved(*(int*)_a[1],*(int*)_a[2]); break; case 2: textBold(); break; case 3: textUnderline(); break; case 4: textItalic(); break; case 5: textAlign(*(QAction**)_a[1]); break; case 6: textFamily(*(QString*)_a[1]); break; case 7: textSize(*(QString*)_a[1]); break; case 8: textColor(); break; case 9: saveMessage(); break; } _id -= 10; } return _id; }
void initTrophiesDisplay(void) { int w, h; Trophy *t; boxWidth = total = awarded = 0; for (t = game.trophyHead.next ; t != NULL ; t = t->next) { total++; if (t->awarded) { awarded++; STRNCPY(t->awardDateStr, timeToDate(t->awardDate), MAX_NAME_LENGTH); } textSize(t->description, 18, &w, &h); boxWidth = MAX(boxWidth, w); } boxWidth += 125; page = 0; maxPages = total; maxPages /= TROPHIES_PER_PAGE; maxPages = ceil(maxPages); prev = getWidget("prev", "trophies"); prev->action = prevPage; prev->visible = 0; next = getWidget("next", "trophies"); next->action = nextPage; next->visible = 1; }
void SearchView::paintEvent(QPaintEvent *event) { QListView::paintEvent(event); if (model()->rowCount() == 0) { event->accept(); QString emptyMessage = tr("Your search had no results."); QPainter painter(this->viewport()); QPen textPen; textPen.setBrush(palette().mid()); painter.setPen(textPen); painter.setFont(FontUtils::big()); QSize textSize(QFontMetrics(painter.font()).size(Qt::TextSingleLine, emptyMessage)); QPoint centerPoint((this->width() - textSize.width()) / 2, ((this->height() - textSize.height()) / 2)); QRect centerRect(centerPoint, textSize); QRect boundRect; painter.drawText(centerRect, Qt::AlignCenter, emptyMessage, &boundRect); } }
CCSize CCtrlEdit::GetTextSize(const char * text) { CCSize textSize(0.0f,0.0f); if (NULL == text) { return textSize; } do { CCTexture2D *tex = new CCTexture2D(); CC_BREAK_IF(!tex); float fContentScaleFactor= CCDirector::sharedDirector()->getContentScaleFactor(); bool bRet = tex->initWithString( text, m_strFontName.c_str(), m_nFontSize * fContentScaleFactor, CCSizeZero, m_pTextField->getHorizontalAlignment(), m_pTextField->getVerticalAlignment()); if (bRet) { float fOffsetX = tex->getPixelsWide(); fOffsetX /= fContentScaleFactor; textSize.width += fOffsetX; float fOffsetY = tex->getPixelsHigh(); fOffsetY /= fContentScaleFactor; textSize.height += fOffsetY; } tex->release(); }while(false); return textSize; }
EXPORT_C TSize THuiFont::LineExtentsL(const TDesC& aTextString) { if (aTextString.Length() == 0) { // Zero length strings have extents of zero. return TSize(0, 0); } // Retrieve the CFont object used when rasterizing this text mesh. CFont* font = NearestFontL(); TSize textSize( MeasureBidiTextBoundsWidth(*font, aTextString, CFont::TMeasureTextInput::EFVisualOrder), font->FontMaxHeight()); const CAknLayoutFont* layoutFont = 0; if (CCoeEnv::Static()) { layoutFont = CAknLayoutFont::AsCAknLayoutFontOrNull( font ); } if ( layoutFont ) { textSize.iHeight = font->HeightInPixels(); TInt textPaneHeight = layoutFont->TextPaneHeight(); TInt textPaneTopToBaseline = layoutFont->TextPaneTopToBaseline(); textSize.iHeight += textPaneHeight - textPaneTopToBaseline; textSize.iHeight += KHuiFontVerticalShiftInPixels; } else { textSize.iHeight = Max(textSize.iHeight, font->HeightInPixels()); textSize.iHeight += 3; // the best approximation - fails on big (>=72) fonts } // Return the calculated text size. return textSize; }
TaskProgressDialog::TaskProgressDialog ( wxWindow* parent) : wxDialog ( parent, -1, _("Please wait..."), wxDefaultPosition, wxDefaultSize , wxCAPTION) { wxClientDC dc(this); dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); long widthText = 0; long heightText = 0; long lineHeight = 0; dc.GetTextExtent(initial_text, &widthText, &heightText, NULL, NULL, NULL); dc.GetTextExtent("ABEND", NULL, &lineHeight, NULL, NULL, NULL); auto wrapsizer = new wxBoxSizer(wxVERTICAL); auto centerizer = new wxGridBagSizer( 0, 0 ); centerizer->AddGrowableCol( 0 ); centerizer->AddGrowableRow( 0 ); centerizer->SetFlexibleDirection( wxBOTH ); centerizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_ALL ); wrapsizer->Add( centerizer, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL); wxSize textSize(widthText, heightText); message = new wxGenericStaticText(this, -1, "" ,wxDefaultPosition, textSize,wxALIGN_CENTRE_HORIZONTAL); message->SetMinSize(textSize); centerizer->Add(message,wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, lineHeight/2); gauge = new wxGauge(this,-1,100,wxDefaultPosition,wxDefaultSize,wxGA_HORIZONTAL | wxGA_SMOOTH); wrapsizer->Add(gauge,wxSizerFlags().Expand().Border(wxBOTTOM|wxLEFT|wxRIGHT,lineHeight/2).Proportion(0)); EnableCloseButton(false); SetSizerAndFit(wrapsizer); CenterOnParent(); #ifdef __WXGTK__ pulse_timer = new wxTimer(this,ID_PulseTimer); #endif }
QSize ComboBoxDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const { if (m_sizes.contains(index.row())) { return m_sizes.value(index.row()); } QSize sz; QVariant fontData = index.data(Qt::FontRole); QFont fnt = qvariant_cast<QFont>(fontData).resolve(option.font); for ( int i = 0; i < sizeof sTypes / sizeof *sTypes; ++i) { QString text = *(sTypes + i); QSize s = textSize(fnt, text); sz = sz.expandedTo(s); } QStyleOptionComboBox opt; opt.editable = true; opt.frame = true; opt.currentText = index.data().toString(); sz = qApp->style()->sizeFromContents(QStyle::CT_ComboBox, &opt, sz); m_sizes.insert(index.row(), sz); return sz; }
void TextEdit::setupTextActions() { QToolBar *tb = new QToolBar(this); tb->setWindowTitle(tr("Format Actions")); addToolBar(tb); QMenu *menu = new QMenu(tr("F&ormat"), this); menuBar()->addMenu(menu); actionTextBold = new QAction(QIcon::fromTheme("format-text-bold", QIcon(rsrcPath + "/textbold.png")), tr("&Bold"), this); actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B); actionTextBold->setPriority(QAction::LowPriority); QFont bold; bold.setBold(true); actionTextBold->setFont(bold); connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold())); tb->addAction(actionTextBold); menu->addAction(actionTextBold); actionTextBold->setCheckable(true); actionTextItalic = new QAction(QIcon::fromTheme("format-text-italic", QIcon(rsrcPath + "/textitalic.png")), tr("&Italic"), this); actionTextItalic->setPriority(QAction::LowPriority); actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); QFont italic; italic.setItalic(true); actionTextItalic->setFont(italic); connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic())); tb->addAction(actionTextItalic); menu->addAction(actionTextItalic); actionTextItalic->setCheckable(true); actionTextUnderline = new QAction(QIcon::fromTheme("format-text-underline", QIcon(rsrcPath + "/textunder.png")), tr("&Underline"), this); actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U); actionTextUnderline->setPriority(QAction::LowPriority); QFont underline; underline.setUnderline(true); actionTextUnderline->setFont(underline); connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline())); tb->addAction(actionTextUnderline); menu->addAction(actionTextUnderline); actionTextUnderline->setCheckable(true); menu->addSeparator(); QActionGroup *grp = new QActionGroup(this); connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(textAlign(QAction*))); // Make sure the alignLeft is always left of the alignRight if (QApplication::isLeftToRight()) { actionAlignLeft = new QAction(QIcon::fromTheme("format-justify-left", QIcon(rsrcPath + "/textleft.png")), tr("&Left"), grp); actionAlignCenter = new QAction(QIcon::fromTheme("format-justify-center", QIcon(rsrcPath + "/textcenter.png")), tr("C&enter"), grp); actionAlignRight = new QAction(QIcon::fromTheme("format-justify-right", QIcon(rsrcPath + "/textright.png")), tr("&Right"), grp); } else { actionAlignRight = new QAction(QIcon::fromTheme("format-justify-right", QIcon(rsrcPath + "/textright.png")), tr("&Right"), grp); actionAlignCenter = new QAction(QIcon::fromTheme("format-justify-center", QIcon(rsrcPath + "/textcenter.png")), tr("C&enter"), grp); actionAlignLeft = new QAction(QIcon::fromTheme("format-justify-left", QIcon(rsrcPath + "/textleft.png")), tr("&Left"), grp); } actionAlignJustify = new QAction(QIcon::fromTheme("format-justify-fill", QIcon(rsrcPath + "/textjustify.png")), tr("&Justify"), grp); actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L); actionAlignLeft->setCheckable(true); actionAlignLeft->setPriority(QAction::LowPriority); actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E); actionAlignCenter->setCheckable(true); actionAlignCenter->setPriority(QAction::LowPriority); actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R); actionAlignRight->setCheckable(true); actionAlignRight->setPriority(QAction::LowPriority); actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J); actionAlignJustify->setCheckable(true); actionAlignJustify->setPriority(QAction::LowPriority); tb->addActions(grp->actions()); menu->addActions(grp->actions()); menu->addSeparator(); QPixmap pix(24, 24); pix.fill(Qt::black); actionTextColor = new QAction(QIcon::fromTheme("text-color", QIcon(rsrcPath + "/textcolor.png")), tr("&Text Color..."), this); connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor())); tb->addAction(actionTextColor); menu->addAction(actionTextColor); pix.fill(Qt::green); actionHighlightedTextColor = new QAction(QIcon::fromTheme("text-highlight-color", QIcon(rsrcPath + "/texthighlight.png")), tr("&Text Highlight Color..."), this); connect(actionHighlightedTextColor, SIGNAL(triggered()), this, SLOT(HighlightedText())); tb->addAction(actionHighlightedTextColor); menu->addAction(actionHighlightedTextColor); //pix.fill(Qt::white); actionBackgroundColor = new QAction(QIcon::fromTheme("bg-color", QIcon(rsrcPath + "/bgfill.png")), tr("&Background Color..."), this); connect(actionBackgroundColor, SIGNAL(triggered()), this, SLOT(backgroundColor())); tb->addAction(actionBackgroundColor); menu->addAction(actionBackgroundColor); tb = new QToolBar(this); tb->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea); tb->setWindowTitle(tr("Format Actions")); addToolBarBreak(Qt::TopToolBarArea); addToolBar(tb); comboStyle = new QComboBox(tb); tb->addWidget(comboStyle); comboStyle->addItem("Standard"); comboStyle->addItem("Bullet List (Disc)"); comboStyle->addItem("Bullet List (Circle)"); comboStyle->addItem("Bullet List (Square)"); comboStyle->addItem("Ordered List (Decimal)"); comboStyle->addItem("Ordered List (Alpha lower)"); comboStyle->addItem("Ordered List (Alpha upper)"); comboStyle->addItem("Ordered List (Roman lower)"); comboStyle->addItem("Ordered List (Roman upper)"); connect(comboStyle, SIGNAL(activated(int)), this, SLOT(textStyle(int))); comboFont = new QFontComboBox(tb); tb->addWidget(comboFont); connect(comboFont, SIGNAL(activated(QString)), this, SLOT(textFamily(QString))); comboSize = new QComboBox(tb); comboSize->setObjectName("comboSize"); tb->addWidget(comboSize); comboSize->setEditable(true); QFontDatabase db; foreach(int size, db.standardSizes()) comboSize->addItem(QString::number(size)); connect(comboSize, SIGNAL(activated(QString)), this, SLOT(textSize(QString))); comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font() .pointSize()))); }
void CreateBlogMsg::setupTextActions() { QMenu *menu = new QMenu(tr("F&ormat"), this); menuBar()->addMenu(menu); actionTextBold = new QAction(QIcon(":/images/textedit/textbold.png"),tr("&Bold"), this); actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B); //actionTextBold->setPriority(QAction::LowPriority); QFont bold; bold.setBold(true); actionTextBold->setFont(bold); connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold())); ui.toolBar_2->addAction(actionTextBold); menu->addAction(actionTextBold); actionTextBold->setCheckable(true); actionTextItalic = new QAction(QIcon(":/images/textedit/textitalic.png"),tr("&Italic"), this); //actionTextItalic->setPriority(QAction::LowPriority); actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); QFont italic; italic.setItalic(true); actionTextItalic->setFont(italic); connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic())); ui.toolBar_2->addAction(actionTextItalic); menu->addAction(actionTextItalic); actionTextItalic->setCheckable(true); actionTextUnderline = new QAction(QIcon(":/images/textedit/textunder.png"),tr("&Underline"), this); actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U); //actionTextUnderline->setPriority(QAction::LowPriority); QFont underline; underline.setUnderline(true); actionTextUnderline->setFont(underline); connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline())); ui.toolBar_2->addAction(actionTextUnderline); menu->addAction(actionTextUnderline); actionTextUnderline->setCheckable(true); menu->addSeparator(); QActionGroup *grp = new QActionGroup(this); connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(textAlign(QAction*))); // Make sure the alignLeft is always left of the alignRight if (QApplication::isLeftToRight()) { actionAlignLeft = new QAction(QIcon(":/images/textedit/textleft.png"),tr("&Left"), grp); actionAlignCenter = new QAction(QIcon(":/images/textedit/textcenter.png"), tr("C&enter"), grp); actionAlignRight = new QAction(QIcon(":/images/textedit/textright.png"), tr("&Right"), grp); } else { actionAlignRight = new QAction(QIcon(":/images/textedit/textright.png"), tr("&Right"), grp); actionAlignCenter = new QAction(QIcon(":/images/textedit/textcenter.png"), tr("C&enter"), grp); actionAlignLeft = new QAction(QIcon(":/images/textedit/textleft.png"), tr("&Left"), grp); } actionAlignJustify = new QAction(QIcon(":/images/textedit/textjustify.png"), tr("&Justify"), grp); actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L); actionAlignLeft->setCheckable(true); //actionAlignLeft->setPriority(QAction::LowPriority); actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E); actionAlignCenter->setCheckable(true); //actionAlignCenter->setPriority(QAction::LowPriority); actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R); actionAlignRight->setCheckable(true); //actionAlignRight->setPriority(QAction::LowPriority); actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J); actionAlignJustify->setCheckable(true); //actionAlignJustify->setPriority(QAction::LowPriority); ui.toolBar_2->addActions(grp->actions()); menu->addActions(grp->actions()); menu->addSeparator(); QPixmap pix(16, 16); pix.fill(Qt::black); actionTextColor = new QAction(pix, tr("&Text Color..."), this); connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor())); ui.toolBar_2->addAction(actionTextColor); menu->addAction(actionTextColor); menu->addAction(ui.actionOrderedlist); menu->addAction(ui.actionUnorderedlist); menu->addAction(ui.actionBlockquoute); /*comboStyle = new QComboBox(ui.toolBar_2); ui.toolBar_2->addWidget(comboStyle); comboStyle->addItem("Paragraph"); comboStyle->addItem("Heading 1"); comboStyle->addItem("Heading 2"); comboStyle->addItem("Heading 3"); comboStyle->addItem("Heading 4"); comboStyle->addItem("Heading 5"); comboStyle->addItem("Heading 6"); connect(comboStyle, SIGNAL(activated(int)), this, SLOT(changeFormatType(int)));*/ comboFont = new QFontComboBox(ui.toolBar_2); ui.toolBar_2->addWidget(comboFont); connect(comboFont, SIGNAL(activated(QString)), this, SLOT(textFamily(QString))); comboSize = new QComboBox(ui.toolBar_2); comboSize->setObjectName("comboSize"); ui.toolBar_2->addWidget(comboSize); comboSize->setEditable(true); QFontDatabase db; foreach(int size, db.standardSizes()) comboSize->addItem(QString::number(size)); connect(comboSize, SIGNAL(activated(QString)), this, SLOT(textSize(QString))); comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font() .pointSize()))); }
void LCVText::draw(LcPainter* painter, LcDrawOptions* options, const lc::geo::Area& rect) const { bool modified = false; modified = true; painter->save(); if (this->selected()) { painter->source_rgba( options->selectedColor().red(), options->selectedColor().green(), options->selectedColor().blue(), options->selectedColor().alpha() ); } else { painter->source_rgba( layers().front()->color().red(), layers().front()->color().green(), layers().front()->color().blue(), layers().front()->color().alpha() ); } // double letterSpacing = 3.0; // double wordSpacing = 6.75; // double lineSpacingFactor = 1.0; // lc::geo::Coordinate letterPos = lc::geo::Coordinate(0.0, -9.0); // lc::geo::Coordinate letterSpace = lc::geo::Coordinate(letterSpacing, 0.0); // lc::geo::Coordinate space = lc::geo::Coordinate(wordSpacing, 0.0); lc::geo::Coordinate textSize(Text::boundingBox().maxP() - Text::boundingBox().minP()); // Vertical Align: double vSize = 9.0; double alignX = insertion_point().x(); double alignY = insertion_point().y(); // double alignX, alignY; switch (valign()) { case Text::VAMiddle: alignX += 0.0; alignY += vSize / 2.0; break; case Text::VABottom: alignX += 0.0; alignY += vSize + 3; break; case Text::VABaseline: alignX += 0.0; alignY += vSize; break; default: break; } // Horizontal Align: switch (halign()) { case Text::HAMiddle: alignX += (0. - textSize.x() / 2.0); alignY += (0. - (vSize + textSize.y() / 2.0 + Text::boundingBox().minP().y())); break; case Text::HACenter: alignX += (0. - textSize.x() / 2.0); alignY += alignY + (0.0); break; case Text::HARight: alignX += alignX + (0. - textSize.x()); alignY += alignY + (0.0); break; default: break; } double angle_; // Rotate: if (halign() == Text::HAAligned || halign() == Text::HAFit) { angle_ = insertion_point().angleTo(second_point()); } else { angle_ = angle(); } const char* str = text_value().c_str(); painter->text(alignX, alignY, str, angle_, height()); painter->stroke(); if (modified) { painter->restore(); } }
/*! Find the height for a given width \param font Font of the text \param flags Bitwise OR of the flags used like in QPainter::drawText \param text Text to be rendered \param width Width \return Calculated height */ double QwtMathMLTextEngine::heightForWidth(const QFont& font, int flags, const QString& text, double) const { return textSize(font, flags, text).height(); }
void DialogEditModuleText::OnOkClick( wxCommandEvent& event ) { wxString msg; if ( m_module) m_parent->SaveCopyInUndoList( m_module, UR_CHANGED ); #ifndef USE_WX_OVERLAY if( m_dc ) //Erase old text on screen { m_currentText->Draw( m_parent->GetCanvas(), m_dc, GR_XOR, (m_currentText->IsMoving()) ? MoveVector : wxPoint( 0, 0 ) ); } #endif m_currentText->SetText( m_Name->GetValue() ); m_currentText->SetItalic( m_Style->GetSelection() == 1 ); wxPoint tmp; msg = m_TxtPosCtrlX->GetValue(); tmp.x = ValueFromString( g_UserUnit, msg ); msg = m_TxtPosCtrlY->GetValue(); tmp.y = ValueFromString( g_UserUnit, msg ); m_currentText->SetPos0( tmp ); wxSize textSize( wxSize( ValueFromString( g_UserUnit, m_TxtSizeCtrlX->GetValue() ), ValueFromString( g_UserUnit, m_TxtSizeCtrlY->GetValue() ) ) ); // Test for a reasonnable size: if( textSize.x < TEXTS_MIN_SIZE ) textSize.x = TEXTS_MIN_SIZE; if( textSize.y < TEXTS_MIN_SIZE ) textSize.y = TEXTS_MIN_SIZE; m_currentText->SetSize( textSize ), msg = m_TxtWidthCtlr->GetValue(); int width = ValueFromString( g_UserUnit, msg ); // Test for a reasonnable width: if( width <= 1 ) width = 1; int maxthickness = Clamp_Text_PenSize(width, m_currentText->GetSize() ); if( width > maxthickness ) { DisplayError( NULL, _( "The text thickness is too large for the text size. It will be clamped" ) ); width = maxthickness; } m_currentText->SetThickness( width ); m_currentText->SetVisible( m_Show->GetSelection() == 0 ); int text_orient = (m_Orient->GetSelection() == 0) ? 0 : 900; m_currentText->SetOrientation( text_orient ); m_currentText->SetDrawCoord(); #ifndef USE_WX_OVERLAY if( m_dc ) // Display new text { m_currentText->Draw( m_parent->GetCanvas(), m_dc, GR_XOR, (m_currentText->IsMoving()) ? MoveVector : wxPoint( 0, 0 ) ); } #else m_parent->Refresh(); #endif m_parent->OnModify(); if( m_module ) m_module->SetLastEditTime(); EndModal(1); }
void MButtonViewPrivate::calcIconTextRects() { Q_Q(const MButtonView); const MButtonStyle *s = static_cast<const MButtonStyle *>(q->style().operator ->()); //total horizontal and vertical text margins int hTextMargin = s->textMarginLeft() + s->textMarginRight(); int vTextMargin = s->textMarginTop() + s->textMarginBottom(); //total horizontal and vertical padding int hPadding = s->paddingLeft() + s->paddingRight(); int vPadding = s->paddingTop() + s->paddingBottom(); //area for the content (icon and text) QRectF contentRect(s->paddingLeft(), s->paddingTop(), q->size().width() - hPadding, q->size().height() - vPadding); //text rect when there is no icon QRectF textRect(contentRect.left() + s->textMarginLeft(), contentRect.top() + s->textMarginTop(), contentRect.width() - hTextMargin, contentRect.height() - vTextMargin); QSizeF textSize(0,0); if (label) textSize = label->sizeHint(Qt::PreferredSize); //icon visible and valid? if (q->model()->iconVisible() && (icon || toggledIcon)) { int iconWidth = s->iconSize().width(); int iconHeight = s->iconSize().height(); QSizeF iconSize(iconWidth, iconHeight); QPointF iconPosition(0, 0); //text visible and valid? if (q->model()->textVisible() && !q->model()->text().isEmpty()) { textSize.setWidth(qMin(textSize.width(), contentRect.width() - iconWidth - hTextMargin)); switch (q->style()->iconAlign()) { //icon on left and text on right case Qt::AlignLeft: { if (s->horizontalTextAlign() == Qt::AlignHCenter) iconPosition.setX(contentRect.center().x() - iconWidth - (textSize.width() / 2)); else if (s->horizontalTextAlign() == Qt::AlignRight) iconPosition.setX(contentRect.right() - textSize.width() - iconWidth - hTextMargin); else if (s->horizontalTextAlign() == Qt::AlignLeft) iconPosition.setX(contentRect.left()); iconPosition.setY(contentRect.center().y() - (iconHeight / 2)); textRect.setX(contentRect.left() + s->textMarginLeft() + iconWidth); textRect.setWidth(contentRect.width() - iconWidth - hTextMargin); break; } //icon on right and text on left case Qt::AlignRight: { if (s->horizontalTextAlign() == Qt::AlignHCenter) iconPosition.setX(contentRect.center().x() + (textSize.width() / 2)); else if (s->horizontalTextAlign() == Qt::AlignRight) iconPosition.setX(contentRect.right() - iconWidth); else if (s->horizontalTextAlign() == Qt::AlignLeft) iconPosition.setX(contentRect.left() + textSize.width() + hTextMargin); iconPosition.setY(contentRect.center().y() - (iconHeight / 2)); textRect.setWidth(contentRect.width() - iconWidth - hTextMargin); break; } //icon on bottom and text on top case Qt::AlignBottom: { iconPosition = QPointF(contentRect.center().x() - (iconWidth / 2), contentRect.bottom() - iconHeight); textRect.setHeight(contentRect.height() - iconHeight - vTextMargin); break; } //icon on top and text on bottom default: { iconPosition = QPointF(contentRect.center().x() - (iconWidth / 2), contentRect.top()); textRect.setY(iconRect.bottom() + q->style()->textMarginTop()); textRect.setHeight(contentRect.height() - iconHeight - vTextMargin); break; } } } // no text else { //icon on center iconPosition = QPointF(contentRect.center().x() - (iconWidth / 2), contentRect.center().y() - (iconHeight / 2)); } iconRect = QRectF(iconPosition, iconSize); } //adjust label with button margins if (label) { if (controller->layoutDirection() == Qt::LeftToRight) label->setGeometry(textRect.translated(q->marginLeft(), q->marginTop())); else label->setGeometry(textRect.translated(q->marginRight(), q->marginTop())); } }