void nsScriptPaginator::CalculateFontMetrics () { #ifndef XP_MACOSX switch (mFontSize) { case 10: mLineHeight = 15.3f; break; case 12: mLineHeight = 17.3f; break; case 14: mLineHeight = 19.3f; break; } return; #endif nsCOMPtr<nsIDocShell> docShell; nsresult rv = mEditor->GetDocShell(getter_AddRefs(docShell)); if (NS_FAILED(rv)) return; nsCOMPtr<nsPresContext> presctx; rv = docShell->GetPresContext(getter_AddRefs(presctx)); nsFont monospace("monospace", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, 0, NS_POINTS_TO_TWIPS(10)); nsCOMPtr<nsIFontMetrics> fontMetrics = presctx->GetMetricsFor(monospace); if (! fontMetrics) return; nscoord fontHeight, fontWidth; // float scale = presctx->TwipsToPixels(); rv = fontMetrics->GetHeight(fontHeight); rv = fontMetrics->GetMaxAdvance(fontWidth); // mFontHeight = NSTwipsToFloatPixels(NSCoordToInt(fontHeight), scale); // mFontWidth = NSTwipsToFloatPixels(NSCoordToInt(fontWidth), scale); mFontHeight = NSTwipsToUnits(fontHeight, 1.0f); mFontWidth = NSTwipsToUnits(fontWidth, 1.0f); mLineHeight = mFontHeight; }
SparqlTextEdit::SparqlTextEdit(QWidget *parent) : QPlainTextEdit(parent) { setLineWrapMode(QPlainTextEdit::NoWrap); QFont monospace("monospace"); monospace.setStyleHint(QFont::TypeWriter); document()->setDefaultFont(monospace); new SparqlHighlighter(document()); connect(this, SIGNAL(blockCountChanged(int)), SLOT(repaintLineNumbers())); connect(this, SIGNAL(updateRequest(QRect,int)), SLOT(updateRequested(QRect,int))); connect(this, SIGNAL(cursorPositionChanged()), SLOT(highlightLine())); connect(this, SIGNAL(selectionChanged()), SLOT(highlightLine())); highlightLine(); }
void GeckoCodeWidget::CreateWidgets() { m_warning = new CheatWarningWidget(m_game_id); m_code_list = new QListWidget; m_name_label = new QLabel; m_creator_label = new QLabel; QFont monospace(QFontDatabase::systemFont(QFontDatabase::FixedFont).family()); const auto line_height = QFontMetrics(font()).lineSpacing(); m_code_description = new QTextEdit; m_code_description->setFont(monospace); m_code_description->setReadOnly(true); m_code_description->setFixedHeight(line_height * 5); m_code_view = new QTextEdit; m_code_view->setFont(monospace); m_code_view->setReadOnly(true); m_code_view->setFixedHeight(line_height * 10); m_add_code = new QPushButton(tr("&Add New Code...")); m_edit_code = new QPushButton(tr("&Edit Code...")); m_remove_code = new QPushButton(tr("&Remove Code")); m_download_codes = new QPushButton(tr("Download Codes (WiiRD Database)")); m_download_codes->setEnabled(!m_game_id.empty()); m_edit_code->setEnabled(false); m_remove_code->setEnabled(false); auto* layout = new QVBoxLayout; layout->addWidget(m_warning); layout->addWidget(m_code_list); auto* info_layout = new QFormLayout; info_layout->addRow(tr("Name:"), m_name_label); info_layout->addRow(tr("Creator:"), m_creator_label); info_layout->addRow(tr("Description:"), static_cast<QWidget*>(nullptr)); info_layout->setFormAlignment(Qt::AlignLeft | Qt::AlignTop); for (QLabel* label : {m_name_label, m_creator_label}) { label->setTextInteractionFlags(Qt::TextSelectableByMouse); label->setCursor(Qt::IBeamCursor); } layout->addLayout(info_layout); layout->addWidget(m_code_description); layout->addWidget(m_code_view); QHBoxLayout* btn_layout = new QHBoxLayout; btn_layout->addWidget(m_add_code); btn_layout->addWidget(m_edit_code); btn_layout->addWidget(m_remove_code); btn_layout->addWidget(m_download_codes); layout->addLayout(btn_layout); setLayout(layout); }
void AboutDialog::initializeGUI() { layout = new QGridLayout(this); tabs = new QTabWidget(this); // Create our Qompose tab. qomposeTab = new QWidget(tabs, nullptr); qomposeTabLayout = new QGridLayout(qomposeTab); qomposeIconLabel = new QLabel(qomposeTab, nullptr); qomposeIconLabel->setPixmap(QPixmap(":/icons/qompose.png")); qomposeIconLabel->setScaledContents(true); qomposeIconLabel->resize(32, 32); qomposeLabel = new QLabel(QString("Qompose %1.%2.%3") .arg(QOMPOSE_VERSION_MAJ) .arg(QOMPOSE_VERSION_MIN) .arg(QOMPOSE_VERSION_BUG), qomposeTab, nullptr); QFont largeFont = qomposeLabel->font(); largeFont.setPointSize(24); qomposeLabel->setFont(largeFont); qomposeDescriptionLabel = new QLabel(tr("A simple programmer's " "text editor."), qomposeTab, nullptr); qomposeTextEdit = new QTextEdit(qomposeTab); qomposeTextEdit->setLineWrapMode(QTextEdit::NoWrap); qomposeTextEdit->setReadOnly(true); qomposeTabLayout->addWidget(qomposeIconLabel, 0, 0, 2, 1, nullptr); qomposeTabLayout->addWidget(qomposeLabel, 0, 1, 1, 1, nullptr); qomposeTabLayout->addWidget(qomposeDescriptionLabel, 1, 1, 1, 1, nullptr); qomposeTabLayout->addWidget(qomposeTextEdit, 2, 0, 1, 3, nullptr); qomposeTabLayout->setColumnStretch(1, 1); qomposeTabLayout->setRowStretch(2, 1); qomposeTab->setLayout(qomposeTabLayout); // Create our license tab. QFont monospace("Monospace"); monospace.setPointSize(9); monospace.setStyleHint(QFont::TypeWriter); licenseTextEdit = new QTextEdit(tabs); licenseTextEdit->setLineWrapMode(QTextEdit::NoWrap); licenseTextEdit->setReadOnly(true); licenseTextEdit->setCurrentFont(monospace); loadLicense(); // Add our tabs and our buttons to our layout. tabs->addTab(qomposeTab, tr("Qompose")); tabs->addTab(licenseTextEdit, tr("License")); closeButton = new QPushButton(tr("Clos&e"), this); layout->addWidget(tabs, 0, 0, 1, 1, nullptr); layout->addWidget(closeButton, 1, 0, 1, 1, nullptr); layout->setRowStretch(0, 1); setLayout(layout); QObject::connect(closeButton, SIGNAL(clicked(bool)), this, SLOT(close())); }