/** * Event: OnPaint * * Render the Notification Window */ LRESULT NotificationWindow::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { PAINTSTRUCT ps; BeginPaint(&ps); { MyGdiplusHelper gdi_plus_autostart; { // get draw area RECT clientRect; ::GetClientRect(m_hWnd, &clientRect); // create Gdiplus Graphics object Gdiplus::Graphics graphics(m_hWnd, FALSE); graphics.SetClip(Gdiplus::Rect(clientRect.left, clientRect.top, clientRect.right - clientRect.left, clientRect.bottom - clientRect.top)); // draw a background Gdiplus::SolidBrush backgroundBrush(Gdiplus::Color(DEFAULT_ALPHA, 255, 255, 255)); graphics.FillRectangle(&backgroundBrush, clientRect.left, clientRect.top, clientRect.right - clientRect.left, clientRect.bottom - clientRect.top); // shrink draw area int inset = 4; clientRect.left += inset; clientRect.top += inset; clientRect.right -= inset; clientRect.bottom -= inset; // whack a logo TODO //Bitmap* bitmap = new Bitmap(m_icon.c_str(), FALSE); int bitmapWidth = 0;//bitmap->GetWidth(); int bitmapHeight = 15;//bitmap->GetHeight(); //graphics->DrawImage(bitmap, clientRect.left, clientRect.top, //bitmapWidth, bitmapHeight); // draw a separator Gdiplus::Pen blackPen(Gdiplus::Color(0, 0, 0), 1.0f); graphics.DrawLine(&blackPen, clientRect.left, clientRect.top + bitmapHeight + inset, clientRect.right, clientRect.top + bitmapHeight + inset); // setup text properties Gdiplus::Font titleFont(L"Verdana", 10, Gdiplus::FontStyleBold); Gdiplus::Font textFont(L"Verdana", 10, Gdiplus::FontStyleRegular); Gdiplus::RectF titleRect((float)clientRect.left + inset + bitmapWidth, (float)clientRect.top, (float)clientRect.right, 20.0f); Gdiplus::RectF textRect((float)clientRect.left, (float)clientRect.top + bitmapHeight + (inset * 2), (float)clientRect.right, (float)clientRect.bottom - bitmapHeight - (inset * 2)); Gdiplus::StringFormat format; format.SetTrimming(Gdiplus::StringTrimmingEllipsisCharacter); format.SetFormatFlags(Gdiplus::StringFormatFlagsLineLimit); Gdiplus::SolidBrush blackBrush(Gdiplus::Color(255, 0, 0, 0)); // draw the message graphics.DrawString(m_title.c_str(), (int)m_title.length(), &titleFont, titleRect, &format, &blackBrush); graphics.DrawString(m_message.c_str(), (int)m_message.length(), &textFont, textRect, &format, &blackBrush); } } EndPaint(&ps); bHandled = TRUE; return 0; }
KWizard::KWizard( QWidget *parent, const char *name, bool modal, WFlags f ) : QWizard( parent, name, modal, f ) { bool useIcons = KGlobalSettings::showIconsOnPushButtons(); if ( useIcons ) { KGuiItem back = KStdGuiItem::back( KStdGuiItem::UseRTL ); KGuiItem forward = KStdGuiItem::forward( KStdGuiItem::UseRTL ); backButton()->setIconSet( back.iconSet() ); nextButton()->setIconSet( forward.iconSet() ); finishButton()->setIconSet( SmallIconSet( "apply" ) ); cancelButton()->setIconSet( SmallIconSet( "button_cancel" ) ); helpButton()->setIconSet( SmallIconSet( "help" ) ); backButton()->setText( i18n( "&Back" ) ); nextButton()->setText( i18n( "Opposite to Back","&Next" ) ); } QFont font = titleFont(); font.setBold( true ); setTitleFont( font ); }
void SliderBox::render(QPainter *painter) { QBrush brush(QColor(255, 255, 255, 200)); painter->setBrush(brush); painter->setPen(QPen(QColor(0, 0, 0, 200))); painter->drawRoundedRect(this->x, this->y, this->width, this->height, 5, 5); QFont titleFont("Arial"); titleFont.setPixelSize(this->titleTextR.height()); QFontMetrics fm(titleFont); int textWidthInPixels = fm.width(this->title); if ( textWidthInPixels > (this->titleTextR.width())) { titleFont.setStretch ((100 * this->titleTextR.width()) / textWidthInPixels) ; } painter->setFont(titleFont); painter->drawText(this->titleTextR, Qt::AlignCenter, this->title); for(int i = 0; i < this->items.size(); i++) { this->items[i]->render(painter); } }
void PlayerLyricsText::renderTitle(KaraokePainter &p , qint64 time ) { int screen_10percent = p.textRect().height() / 10; // Artist name starts at 10% and can take the 30% of the screen QFont artistFont( m_renderFont ); artistFont.setPointSize( p.largestFontSize( m_artist, 3 * screen_10percent ) ); // Title starts at 50% and can take the 40% of the screen QFont titleFont( m_renderFont ); titleFont.setPointSize( p.largestFontSize( m_title, 4 * screen_10percent ) ); // Use the smallest size so we can fit for sure int alpha = 255; if ( m_showTitleTime - time < TITLE_FADEOUT_TIME ) { alpha = (m_showTitleTime - time ) * 255 / TITLE_FADEOUT_TIME; m_nextUpdateTime = 0; } // Draw artist and title p.setFont( artistFont ); p.drawCenteredOutlineTextGradient( 10, m_titleAnimationValue, m_artist, alpha ); p.setFont( titleFont ); p.drawCenteredOutlineTextGradient( 50, 1.0 - m_titleAnimationValue, m_title, alpha ); m_titleAnimationValue += 0.025; if ( m_titleAnimationValue >= 1.0 ) m_titleAnimationValue = 0.0; }
bool VCard_LDIFCreator::createImageBig() { QFont normalFont( KGlobalSettings::generalFont() ); QFont titleFont( normalFont ); titleFont.setBold(true); // titleFont.setUnderline(true); titleFont.setItalic(true); QPainter painter(&mPixmap); painter.setFont(titleFont); QFontMetrics fm(painter.fontMetrics()); // draw contact name painter.setClipRect(2, 2, pixmapSize.width()-4, pixmapSize.height()-4); QPoint p(5, fm.height()+2); painter.drawText(p, name); p.setY( 3*p.y()/2 ); // draw contact information painter.setFont(normalFont); fm = painter.fontMetrics(); const QStringList list( text.split('\n', QString::SkipEmptyParts) ); for ( QStringList::ConstIterator it = list.begin(); p.y()<=pixmapSize.height() && it != list.end(); ++it ) { p.setY( p.y() + fm.height() ); painter.drawText(p, *it); } return true; }
StartHerePage::StartHerePage(wxWindow* parent, MainFrame & mainEditor_) : BaseStartHerePage(parent), mainEditor(mainEditor_) { wxFont titleFont(13,wxDEFAULT,wxFONTSTYLE_NORMAL,wxNORMAL,false,wxEmptyString,wxFONTENCODING_DEFAULT); gettingStartedTxt->SetFont(titleFont); communityTxt->SetFont(titleFont); newsTxt->SetFont(titleFont); latestProjectsTxt->SetFont(titleFont); gettingStartedBmp->SetBitmap(gd::SkinHelper::GetIcon("gettingStarted", 24)); communityBmp->SetBitmap(gd::SkinHelper::GetIcon("community", 24)); newsBmp->SetBitmap(gd::SkinHelper::GetIcon("news", 24)); latestProjectsBmp->SetBitmap(gd::SkinHelper::GetIcon("open", 24)); logoBmp->SetBitmap(wxBitmap("res/GD-logo-simple.png", wxBITMAP_TYPE_ANY)); localeBmp->SetBitmap(wxBitmap("res/locale.png", wxBITMAP_TYPE_ANY)); donateBmp->SetBitmap(wxBitmap("res/hearticon.png", wxBITMAP_TYPE_ANY)); githubBmp->SetBitmap(wxBitmap("res/github16.png", wxBITMAP_TYPE_ANY)); wxString donateLink = _("http://www.compilgames.net/donate.php"); if ( !donateLink.StartsWith("http://www.compilgames.net/") ) donateLink = "http://www.compilgames.net/donate.php"; donateLink += "?utm_source=GD&utm_medium=StartPageLink&utm_campaign=donate"; donateLinkBt->SetURL(donateLink); Refresh(); }
K3Wizard::K3Wizard( QWidget *parent, const char *name, bool modal, Qt::WFlags f ) : Q3Wizard( parent, name, modal, f ) { bool useIcons = KGlobalSettings::showIconsOnPushButtons(); if ( useIcons ) { KGuiItem back = KStandardGuiItem::back( KStandardGuiItem::UseRTL ); KGuiItem forward = KStandardGuiItem::forward( KStandardGuiItem::UseRTL ); backButton()->setIcon( back.icon() ); nextButton()->setIcon( forward.icon() ); finishButton()->setIcon( KIcon( "dialog-ok-apply" ) ); cancelButton()->setIcon( KIcon( "dialog-cancel" ) ); helpButton()->setIcon( KIcon( "help-contents" ) ); backButton()->setText( i18n( "&Back" ) ); nextButton()->setText( i18nc( "Opposite to Back","&Next" ) ); } QFont font = titleFont(); font.setBold( true ); setTitleFont( font ); }
SettingsWidget::SettingsWidget(QGraphicsScene *scene, ControlPanelManager *control_panel_manager) : QGraphicsProxyWidget(0, Qt::Widget), internal_widget_(new QWidget()), panel_(control_panel_manager) { setupUi(internal_widget_); setWidget(internal_widget_); QFont titleFont("facetextrabold", 10, 25, false); titleFont.setCapitalization(QFont::AllUppercase); titleFont.setStyleStrategy(QFont::PreferAntialias); titleFont.setLetterSpacing(QFont::AbsoluteSpacing, 1); titleLabel->setFont(titleFont); setZValue(100); visibility_animation_ = new QPropertyAnimation(this, "opacity", this); visibility_animation_->setDuration(500); visibility_animation_->setEasingCurve(QEasingCurve::InOutSine); visibility_animation_->setStartValue(0); visibility_animation_->setEndValue(1); connect(opacitySlider, SIGNAL(valueChanged(int)), SLOT(OpacitySliderChanged(int))); connect(savePushButton, SIGNAL(clicked()), SLOT(SaveSettings())); connect(cancelPushButton, SIGNAL(clicked()), SLOT(Canceled())); connect(visibility_animation_, SIGNAL(finished()), SLOT(AnimationsFinished())); connect(scene, SIGNAL(sceneRectChanged(const QRectF&)), SLOT(SceneRectChanged(const QRectF&))); scene->addItem(this); hide(); }
void MSLayout::updateTitle(void) { undrawShadow(); label()->freeze(); label()->foreground(titleForeground()); int h=label()->height(); int w=label()->width(); label()->font(titleFont()); MSBoolean doPlacement=MSFalse; label()->label(title()); int ml=label()->columns(); if (ml==0&&label()->mapped()==MSTrue) { label()->unmap(); doPlacement=MSTrue; } else if (ml>0&&label()->mapped()==MSFalse) { label()->map(); doPlacement=MSTrue; } positionLabel(); label()->unfreeze(); if (label()->height()!=h||label()->width()!=w||doPlacement==MSTrue) adjustSize(); else if (label()->mapped()==MSTrue) label()->redraw(); drawShadow(); }
ExportInstWizard::ExportInstWizard(wxWindow *parent, Instance *inst) : wxWizard(parent, -1, _("Export Instance")) { this->m_inst = inst; this->SetPageSize(wxSize(400, 300)); wxFont titleFont(12, wxSWISS, wxNORMAL, wxNORMAL); enterInfoPage = new wxWizardPageSimple(this); wxGridBagSizer *infoPageSz = new wxGridBagSizer(); enterInfoPage->SetSizer(infoPageSz); wxStaticText *infoTitleLabel = new wxStaticText(enterInfoPage, -1, _("Config Pack Info"), wxDefaultPosition, wxDefaultSize); infoTitleLabel->SetFont(titleFont); infoPageSz->Add(infoTitleLabel, wxGBPosition(0, 0), wxGBSpan(1, 2), wxALIGN_CENTER | wxALL, 4); wxStaticText *nameLabel = new wxStaticText(enterInfoPage, -1, _("Name: ")); infoPageSz->Add(nameLabel, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALL | wxALIGN_CENTER_VERTICAL, 4); packNameTextbox = new wxTextCtrl(enterInfoPage, -1, inst->GetName()); infoPageSz->Add(packNameTextbox, wxGBPosition(1, 1), wxGBSpan(1, 1), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 4); wxStaticText *notesLabel = new wxStaticText(enterInfoPage, -1, _("Notes: ")); infoPageSz->Add(notesLabel, wxGBPosition(2, 0), wxGBSpan(1, 2), wxALL | wxALIGN_CENTER_VERTICAL, 4); packNotesTextbox = new wxTextCtrl(enterInfoPage, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE); infoPageSz->Add(packNotesTextbox, wxGBPosition(3, 0), wxGBSpan(1, 2), wxEXPAND | wxALL, 4); infoPageSz->AddGrowableCol(1); infoPageSz->AddGrowableRow(3); chooseConfigFilesPage = new wxWizardPageSimple(this, enterInfoPage); enterInfoPage->SetNext(chooseConfigFilesPage); wxGridBagSizer *configPageSz = new wxGridBagSizer(); configPageSz->AddGrowableCol(0, 0); chooseConfigFilesPage->SetSizer(configPageSz); wxStaticText *configTitleLabel = new wxStaticText(chooseConfigFilesPage, -1, _("Choose Included Configs"), wxDefaultPosition, wxDefaultSize); configTitleLabel->SetFont(titleFont); configPageSz->Add(configTitleLabel, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER | wxALL, 4); wxArrayString configList; inst->GetPossibleConfigFiles(&configList); cfgListCtrl = new wxCheckListBox(chooseConfigFilesPage, -1, wxDefaultPosition, wxDefaultSize, configList); for (unsigned i = 0; i < cfgListCtrl->GetCount(); i++) { if (!cfgListCtrl->GetString(i).Contains("options.txt") && !cfgListCtrl->GetString(i).Contains("optionsof.txt")) cfgListCtrl->Check(i, true); } configPageSz->Add(cfgListCtrl, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER | wxALL | wxEXPAND, 4); configPageSz->AddGrowableRow(1, 0); }
void PSV_ChartItem::createTitle(const QString &text) { m_titleItem = new QGraphicsTextItem(text,this); // m_titleItem->setHtml(text);//TTTTTTTTTTTTT QFont font = titleFont(); QColor color = titleColor(); m_titleItem->setFont(font); m_titleItem->setDefaultTextColor(color); adjustTitlePos(); }
QSize ScriptDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const { QFont font = titleFont(option.font); QFontMetrics fm(font); int w = qMax(fm.width(index.model()->data(index, Qt::DisplayRole).toString()), option.fontMetrics.width(index.model()->data(index, ScriptModel::CommentRole).toString())); int h = qMax(KIconLoader::SizeMedium + MARGIN * 2, fm.height() + option.fontMetrics.height() + MARGIN * 2); return QSize(w + KIconLoader::SizeMedium, h); }
QSize PluginListWidgetItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { auto i = 4; auto j = 1; auto font = titleFont(option.font); auto fmTitle = QFontMetrics{font}; return QSize(qMax(fmTitle.width(index.model()->data(index, Qt::DisplayRole).toString()), option.fontMetrics.width(index.model()->data(index, PluginModel::CommentRole).toString())) + + MARGIN * i + m_pushButton->sizeHint().width() * j, qMax(MARGIN * 2, fmTitle.height() * 2 + option.fontMetrics.height() + MARGIN * 2)); }
QRect QCommandLinkButtonPrivate::titleRect() const { Q_Q(const QCommandLinkButton); QRect r = q->rect().adjusted(textOffset(), topMargin(), -rightMargin(), 0); if (description.isEmpty()) { QFontMetrics fm(titleFont()); r.setTop(r.top() + qMax(0, (q->icon().actualSize(q->iconSize()).height() - fm.height()) / 2)); } return r; }
void CStartupView::DrawTitleText(Gdiplus::Graphics &graphics) { Gdiplus::Rect gdipRcLeftButtons; CalculateLeftButtonsRegion(gdipRcLeftButtons); Gdiplus::SolidBrush blackBrush(Gdiplus::Color(255, 0, 0, 0)); Gdiplus::Font titleFont(m_csFontFamily, m_iTitleFontSize, Gdiplus::FontStyleBold, Gdiplus::UnitPixel); Gdiplus::Font subTitleFont(m_csFontFamily, m_iNormalFontSize, Gdiplus::FontStyleBold, Gdiplus::UnitPixel); CString csRecord1; csRecord1.LoadString(IDS_RECORD); INT x = gdipRcLeftButtons.X; INT y = gdipRcLeftButtons.Y + 2*BUTTON_TITLE_HEIGHT; Gdiplus::PointF textOrigin(x/*gdipRcLeftButtons.X*/, y/*(gdipRcLeftButtons.Y + gdipRcLeftButtons.Height)*/ ); graphics.SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAliasGridFit); graphics.DrawString(csRecord1, csRecord1.GetLength(), &titleFont, textOrigin, &blackBrush); x = gdipRcLeftButtons.X; y = gdipRcLeftButtons.Y + BUTTON_TITLE_HEIGHT + 2*BUTTON_SUBTITLE_HEIGHT + 2*(BUTTON_HEIGHT1 + 10) + SEPARATOR_HEIGHT + 5; //Gdiplus::PointF textOrigin(x/*gdipRcLeftButtons.X*/, y/*(gdipRcLeftButtons.Y + gdipRcLeftButtons.Height)*/ ); textOrigin.X = x; textOrigin.Y = y; CString csWelcome; //csWelcome.LoadStringW(IDS_WELCOME); csWelcome.LoadStringW(ID_MENU_NEW); graphics.DrawString(csWelcome, csWelcome.GetLength(), &titleFont, textOrigin, &blackBrush); textOrigin.Y += BUTTON_TITLE_HEIGHT; Gdiplus::Rect gdipRcRightButtons; CalculateRightButtonsRegion(gdipRcRightButtons); textOrigin.X = gdipRcRightButtons.X ; textOrigin.Y = gdipRcRightButtons.Y + BUTTON_TITLE_HEIGHT + BUTTON_HEIGHT;; CString csRecord; //csRecord.LoadStringW(IDS_RECORD); csRecord.LoadStringW(ID_MENU_OPEN); graphics.DrawString(csRecord, csRecord.GetLength(), &titleFont, textOrigin, &blackBrush); /*textOrigin.X = gdipRcRightButtons.X ; textOrigin.Y += 3*BUTTON_HEIGHT; CString csRecent; csRecent.LoadStringW(IDS_RECENTLY_OPENED_PROJECTS); graphics.DrawString(csRecent, csRecent.GetLength(), &titleFont, textOrigin, &blackBrush); */ }
void ScriptDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { if (!index.isValid()) return; int x_offset = check_box->sizeHint().width(); painter->save(); QApplication::style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, 0); int iconSize = option.rect.height() - MARGIN * 2; QString icon = index.model()->data(index, Qt::DecorationRole).toString(); KIconLoader::States state = option.state & QStyle::State_Enabled ? KIconLoader::DefaultState : KIconLoader::DisabledState; QPixmap pixmap = KIconLoader::global()->loadIcon(icon, KIconLoader::Desktop, iconSize, state); int x = MARGIN + option.rect.left() + x_offset; painter->drawPixmap(QRect(x, MARGIN + option.rect.top(), iconSize, iconSize), pixmap, QRect(0, 0, iconSize, iconSize)); x = MARGIN * 2 + iconSize + option.rect.left() + x_offset; QRect contentsRect(x, MARGIN + option.rect.top(), option.rect.width() - MARGIN * 3 - iconSize - x_offset, option.rect.height() - MARGIN * 2); int lessHorizontalSpace = MARGIN * 2 + push_button->sizeHint().width(); contentsRect.setWidth(contentsRect.width() - lessHorizontalSpace); QPalette::ColorGroup cg = QPalette::Active; if (!(option.state & QStyle::State_Enabled)) cg = QPalette::Inactive; if (option.state & QStyle::State_Selected) painter->setPen(option.palette.color(cg, QPalette::HighlightedText)); else painter->setPen(option.palette.color(cg, QPalette::WindowText)); painter->save(); painter->save(); QFont font = titleFont(option.font); QFontMetrics fmTitle(font); painter->setFont(font); QString text = index.model()->data(index, Qt::DisplayRole).toString(); painter->drawText(contentsRect, Qt::AlignLeft | Qt::AlignTop, fmTitle.elidedText(text, Qt::ElideRight, contentsRect.width())); painter->restore(); QString comment = index.model()->data(index, ScriptModel::CommentRole).toString(); painter->drawText(contentsRect, Qt::AlignLeft | Qt::AlignBottom, option.fontMetrics.elidedText(comment, Qt::ElideRight, contentsRect.width())); painter->restore(); painter->restore(); }
void MainMenu::displayMainMenu() { QGraphicsTextItem * titleText = new QGraphicsTextItem(tr("Starlight")); QFont titleFont("calibri", 50); titleText->setFont(titleFont); int titleX = this->width() / 2 - titleText->boundingRect().width() /2; int titleY = 50; titleText->setPos(titleX, titleY); scene_->addItem(titleText); Button * playButton = new Button(tr("Play")); int playX = this->width() / 2 - playButton->boundingRect().width() /2; int playY = 150; playButton->setPos(playX, playY); connect(playButton, &Button::clicked, this, &MainMenu::start); scene_->addItem(playButton); Button * rulesButton = new Button(tr("Rules")); int ruleX = this->width() / 2 - rulesButton->boundingRect().width() / 2; int ruleY = 225; rulesButton->setPos(ruleX, ruleY); connect(rulesButton, &Button::clicked, this, &MainMenu::help); scene_->addItem(rulesButton); Button * editorButton = new Button(tr("Editor")); int editX = this->width() / 2 - editorButton->boundingRect().width() /2; int editY = 300; editorButton->setPos(editX, editY); connect(editorButton, &Button::clicked, this, &MainMenu::editor); scene_->addItem(editorButton); Button * quitButton = new Button(tr("Exit")); int quitX = this->width() / 2 - quitButton->boundingRect().width() /2; int quitY = 375; quitButton->setPos(quitX, quitY); connect(quitButton, &Button::clicked, this, &QGraphicsView::close); scene_->addItem(quitButton); }
int QgsDetailedItemDelegate::height( const QStyleOptionViewItem & theOption, const QgsDetailedItemData theData ) const { QFontMetrics myTitleMetrics( titleFont( theOption ) ); QFontMetrics myDetailMetrics( detailFont( theOption ) ); //we don't word wrap the title so its easy to measure int myHeight = myTitleMetrics.height() + verticalSpacing(); //the detail needs to be measured though QStringList myList = wordWrap( theData.detail(), myDetailMetrics, theOption.rect.width() - ( mpCheckBox->width() + horizontalSpacing() ) ); myHeight += ( myList.count() + 1 ) * ( myDetailMetrics.height() - verticalSpacing() ); return myHeight; }
void GameBackground::draw() { // draw background drawWallpaper(L"rain.bmp"); // draw title SDL_Surface *tile = loadImage(L"title.bmp"); screen.draw(8, 10, tile); SDL_FreeSurface(tile); Font titleFont(L"nova.ttf", 28); titleFont.draw(screen.getSurface(), 20, 20, 255,255,0, true, msg(L"einsteinPuzzle")); screen.addRegionToUpdate(0, 0, screen.getWidth(), screen.getHeight()); }
void PluginListWidgetItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { if (!index.isValid()) return; auto xOffset = m_checkBox->sizeHint().width(); xOffset += QApplication::style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing); painter->save(); QApplication::style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, 0); auto contentsRect = QRect{m_pluginSelector->dependantLayoutValue(option.rect.left() + MARGIN + xOffset, option.rect.width() - MARGIN * 2 - xOffset, option.rect.width()), MARGIN + option.rect.top(), option.rect.width() - MARGIN * 2 - xOffset, option.rect.height() - MARGIN * 2}; auto lessHorizontalSpace = MARGIN * 2 + m_pushButton->sizeHint().width(); contentsRect.setWidth(contentsRect.width() - lessHorizontalSpace); if (option.state & QStyle::State_Selected) painter->setPen(option.palette.highlightedText().color()); if (m_pluginSelector->m_listView->layoutDirection() == Qt::RightToLeft) contentsRect.translate(lessHorizontalSpace, 0); { painter->save(); auto font = titleFont(option.font); auto fmTitle = QFontMetrics{font}; painter->setFont(font); painter->drawText(contentsRect, Qt::AlignLeft | Qt::AlignTop, fmTitle.elidedText(index.model()->data(index, Qt::DisplayRole).toString(), Qt::ElideRight, contentsRect.width())); painter->restore(); } painter->drawText(contentsRect, Qt::AlignLeft | Qt::AlignBottom, option.fontMetrics.elidedText(index.model()->data(index, PluginModel::CommentRole).toString(), Qt::ElideRight, contentsRect.width())); auto subfont = subtitleFont(option.font); auto fmSubtitle = QFontMetrics{subfont}; painter->setFont(subfont); painter->drawText(contentsRect, Qt::AlignLeft | Qt::AlignVCenter, fmSubtitle.elidedText(index.model()->data(index, PluginModel::NameRole).toString(), Qt::ElideRight, contentsRect.width())); painter->restore(); }
void KJanusWidget::slotFontChanged() { if( mTitleLabel ) { mTitleLabel->setFont( TDEGlobalSettings::generalFont() ); TQFont titleFont( mTitleLabel->font() ); titleFont.setBold( true ); mTitleLabel->setFont( titleFont ); } if( mFace == IconList ) { TQFont listFont( mIconList->font() ); listFont.setBold( true ); mIconList->setFont( listFont ); mIconList->invalidateHeight(); mIconList->invalidateWidth(); } }
void LocationsManager::AddLocations(){ sfe::RichText titleFont(font); titleFont.setCharacterSize(BIG_CHARACTER_SIZE); sfe::RichText descriptionFont(font); descriptionFont.setCharacterSize(NORMAL_CHARACTER_SIZE); /*world->addLocation(GameManager::getLocationName(0), "Descrição Local 1", titleFont << sf::Color::Cyan << GameManager::getLocationName(0), descriptionFont << "This Is a Mindfull place... \nGet ready to fullfill your " << sf::Color::Blue << "Dreams" << sf::Color::White << " as you get to sleep!!!");*/ for (size_t i = 0; i < GameManager::locationDatabase.size(); i++){ world->addLocation(GameManager::getLocationName(i), GameManager::getLocationDescription(i), titleFont << GameManager::getLocationName(i), descriptionFont << GameManager::getLocationDescription(i), GameManager::getLocationLevel(i)); titleFont.clear(); descriptionFont.clear(); } }
NotificationBrowserWidget::NotificationBrowserWidget() : QGraphicsProxyWidget(0, Qt::Widget), internal_widget_(new QWidget()), next_bg_color_("white") { setupUi(internal_widget_); setWidget(internal_widget_); QFont titleFont("facetextrabold", 10, 25, false); titleFont.setCapitalization(QFont::AllUppercase); titleFont.setStyleStrategy(QFont::PreferAntialias); titleFont.setLetterSpacing(QFont::AbsoluteSpacing, 1); titleLabel->setFont(titleFont); visibility_animation_ = new QPropertyAnimation(this, "opacity", this); visibility_animation_->setDuration(500); visibility_animation_->setEasingCurve(QEasingCurve::InOutSine); visibility_animation_->setStartValue(0); visibility_animation_->setEndValue(1); connect(visibility_animation_, SIGNAL(finished()), SLOT(AnimationsFinished())); }
int Q3Wizard::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDialog::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 10) qt_static_metacall(this, _c, _id, _a); _id -= 10; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QFont*>(_v) = titleFont(); break; } _id -= 1; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setTitleFont(*reinterpret_cast< QFont*>(_v)); break; } _id -= 1; } else if (_c == QMetaObject::ResetProperty) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 1; } #endif // QT_NO_PROPERTIES return _id; }
void showOptionsWindow(Area *parentArea) { Font titleFont(L"nova.ttf", 26); Font font(L"laudcn2.ttf", 14); bool fullscreen = (getStorage()->get(L"fullscreen", 1) != 0); bool niceCursor = (getStorage()->get(L"niceCursor", 1) != 0); bool hideCursor = (getStorage()->get(L"hideCursor", 0) != 0); bool invertShoulder = (getStorage()->get(L"invertShoulder", 0) != 0); float volume = ((float)getStorage()->get(L"volume", 20)) / 100.0f; Area area; area.add(parentArea); area.add(new Window(250, 170, 300, 260, L"blue.bmp")); area.add(new Label(&titleFont, 250, 175, 300, 40, Label::ALIGN_CENTER, Label::ALIGN_MIDDLE, 255,255,0, msg(L"options"))); OPTION(240, L"fullscreen", fullscreen); #ifndef __APPLE__ OPTION(260, L"niceCursor", niceCursor); OPTION(280, L"hideCursor", hideCursor); #endif OPTION(300, L"invertShoulder", invertShoulder); area.add(new Label(&font, 265, 330, 300, 20, Label::ALIGN_LEFT, Label::ALIGN_MIDDLE, 255,255,255, msg(L"volume"))); area.add(new Slider(360, 332, 160, 16, volume)); ExitCommand exitCmd(area); OptionsChangedCommand okCmd(&area, fullscreen, niceCursor,hideCursor,invertShoulder, volume); area.add(new Button(315, 390, 85, 25, &font, 255,255,0, L"blue.bmp", msg(L"ok"), &okCmd)); area.add(new Button(405, 390, 85, 25, &font, 255,255,0, L"blue.bmp", msg(L"cancel"), &exitCmd)); area.add(new KeyAccel(SDLK_ESCAPE, &exitCmd)); area.add(new KeyAccel(SDLK_RETURN, &okCmd)); area.run(); }
int QgsDetailedItemDelegate::height( const QStyleOptionViewItem &option, const QgsDetailedItemData &data ) const { QFontMetrics myTitleMetrics( titleFont( option ) ); QFontMetrics myDetailMetrics( detailFont( option ) ); QFontMetrics myCategoryMetrics( categoryFont( option ) ); //we don't word wrap the title so its easy to measure int myHeight = myTitleMetrics.height() + verticalSpacing(); //the detail needs to be measured though QStringList myList = wordWrap( data.detail(), myDetailMetrics, option.rect.width() - ( mpCheckBox->width() + horizontalSpacing() ) ); myHeight += ( myList.count() + 1 ) * ( myDetailMetrics.height() - verticalSpacing() ); //we don't word wrap the category so its easy to measure myHeight += myCategoryMetrics.height() + verticalSpacing(); #if 0 // if category should be wrapped use this code myList = wordWrap( data.category(), myCategoryMetrics, option.rect.width() - ( mpCheckBox->width() + horizontalSpacing() ) ); myHeight += ( myList.count() + 1 ) * ( myCategoryMetrics.height() - verticalSpacing() ); #endif return myHeight; }
int QCommandLinkButtonPrivate::descriptionOffset() const { QFontMetrics fm(titleFont()); return topMargin() + fm.height(); }
rkFrame::rkFrame(QWidget *parent, const char *name) //:QWidget(parent, name, Qt::WStyle_Customize | Qt::WStyle_NoBorder) :QDialog(parent, name, false, Qt::WStyle_Customize | Qt::WStyle_NoBorder) { //keyRepeat = false; frameWidth = 800; frameHeight = 480; int pos_x = (QApplication::desktop()->width() - frameWidth) / 2; int pos_y = (QApplication::desktop()->height() - frameHeight) / 2; this->setFixedSize(frameWidth, frameHeight); this->setPaletteForegroundColor(rkClr(255, 255, 255)); this->setPaletteBackgroundColor(rkClr(47, 63, 95)); this->move(pos_x, pos_y); /* title frame */ titleFrame = new QFrame(this, "titleFrame"); titleFrame->setLineWidth(0); titleFrame->setMargin(0); titleFrame->setFrameShape(QFrame::NoFrame); titleFrame->setFrameShadow(QFrame::Plain); titleFrame->setFixedSize(frameWidth, 80); titleFrame->move(0, 0); titleLayout = new QVBoxLayout(titleFrame, 0, 0, "titleLayout"); titleLabel = new QLabel(titleFrame, "titleLabel", 0); titleLabel->setText("Title"); QFont titleFont(titleLabel->font()); #ifdef __ARM__ titleFont.setPointSize(38); #else titleFont.setPointSize(28); #endif titleLabel->setFont(titleFont); titleLabel->setAlignment(Qt::AlignCenter); titleLayout->addWidget(titleLabel); topLine = new QFrame(titleFrame, "topLine"); topLine->setFrameShape(QFrame::HLine); topLine->setFrameShadow(QFrame::Sunken); topLine->setFixedSize(frameWidth, 1); titleLayout->addWidget(topLine); /* middle left frame */ /* middle frame */ /* middle right frame */ /* bottom frame */ bottomFrame = new QFrame(this, "bottomFrame"); QFont bottomFont = bottomFrame->font(); #ifdef __ARM__ bottomFont.setPointSize(20); #else bottomFont.setPointSize(18); #endif bottomFrame->setFont(bottomFont); bottomFrame->setLineWidth(0); bottomFrame->setMargin(0); bottomFrame->setFrameShape(QFrame::NoFrame); bottomFrame->setFrameShadow(QFrame::Plain); bottomFrame->setFixedSize(frameWidth, 30); bottomFrame->move(0, 450); bottomLayout = new QVBoxLayout(bottomFrame, 0, 0, "bottomLayout"); bottomLine = new QFrame(bottomFrame, "bottomLine"); bottomLine->setFrameShape(QFrame::HLine); bottomLine->setFrameShadow(QFrame::Sunken); bottomLine->setFixedSize(frameWidth, 1); bottomLayout->addWidget(bottomLine); bottomChildLayout = new QHBoxLayout(bottomLayout, 0, "childLayout"); bottomChildLayout->addSpacing(5); dateLabel = new QLabel(bottomFrame, "dateLabel"); QString dateTime; dateTime.sprintf("%04d-%02d-%02d", QDate::currentDate().year(), QDate::currentDate().month(), QDate::currentDate().day()); dateLabel->setText(dateTime); dateLabel->setAlignment(Qt::AlignCenter); dateLabel->adjustSize(); bottomChildLayout->addWidget(dateLabel); int size = 400 - 5 - dateLabel->width(); venderLabel = new QLabel(bottomFrame, "venderLabel"); venderLabel->setText("太原罗克佳华工业有限公司"); venderLabel->setAlignment(Qt::AlignCenter); venderLabel->adjustSize(); bottomChildLayout->addWidget(venderLabel); size = size - venderLabel->width() / 2; bottomChildLayout->insertSpacing(2, size); bottomChildLayout->addStretch(5); for(int i = 0; i < 4; i++) { QString labelName = "iconLabel" + QString::number(i + 1); QLabel *iconLabel = new QLabel(bottomFrame, labelName); #if 0 iconLabel->setPixmap(QPixmap::fromMimeSource("icon_none_arm.png")); #endif bottomChildLayout->addWidget(iconLabel); bottomChildLayout->addSpacing(2); iconStat[i] = IconNone; } bottomChildLayout->addSpacing(3); timeLabel = new QLabel(bottomFrame, "timeLabel"); dateTime.sprintf("%02d:%02d:%02d", QTime::currentTime().hour(), QTime::currentTime().minute(), QTime::currentTime().second()); timeLabel->setText(dateTime); timeLabel->setAlignment(Qt::AlignCenter); bottomChildLayout->addWidget(timeLabel); bottomChildLayout->addSpacing(5); /* Keyboard */ keyboard = new rkDlgKb(this, "keyboard"); point1.setX(pos_x); point1.setY(pos_y + 80); point2.setX(pos_x + frameWidth - keyboard->width()); point2.setY(pos_y + 80); point3.setX(pos_x); point3.setY(pos_y + frameHeight - keyboard->height() - 30); point4.setX(pos_x + frameWidth - keyboard->width()); point4.setY(pos_y + frameHeight - keyboard->height() - 30); keyboard->move(point4); connect(keyboard, SIGNAL(sendKeyCode(const QString &)), this, SLOT(recvKeyCode(const QString &))); /* start the timer to update date and time display */ timer1 = startTimer(500); timer2 = 0; }
SettingsPanel::SettingsPanel(const Rectangle<int> &bounds, mlrVSTAudioProcessor * const processorPtr, mlrVSTGUI * const editorPtr) : // Communication //////////////////////////////// processor(processorPtr), pluginUI(editorPtr), // Layout /////////////////////////////////////// defaultFont("ProggyCleanTT", 18.f, Font::plain), panelBounds(bounds), overLF(), // Components /////////////////////////////////// panelLabel("settings panel label", "settings"), tempoSourceLbl("tempo source", "tempo source"), useExternalTempoBtn("Using external tempo"), setNumChannelsLbl("num channels", "num channels"), selNumChannels(), setRampLengthLbl("length of envelope", "length of envelope"), rampLengthSldr(), oscPrefixLbl("OSC prefix", "OSC prefix"), oscPrefixTxtBx("mlrvst"), monitorInputsLbl("monitor inputs", "monitor inputs"), monitorInputsBtn(""), setMonomeSizeLbl("monome size", "monome size"), selMonomeSize(), setNumSampleStrips("num sample strips", "num sample strips"), selNumSampleStrips() { // main panel label addAndMakeVisible(&panelLabel); panelLabel.setBounds(0, 0, panelBounds.getWidth(), 36); panelLabel.setColour(Label::backgroundColourId, Colours::black); panelLabel.setColour(Label::textColourId, Colours::white); Font titleFont("ProggyCleanTT", 36.f, Font::plain); panelLabel.setFont(titleFont); const int labelWidth = 150; const int labelHeight = 25; int yPos = 50; // select tempo source (internal / external) tempoSourceLbl.setBounds(PAD_AMOUNT, yPos, labelWidth, labelHeight); setupLabel(tempoSourceLbl); addAndMakeVisible(&useExternalTempoBtn); useExternalTempoBtn.setBounds(labelWidth + 2 * PAD_AMOUNT, yPos, 150, 20); useExternalTempoBtn.addListener(this); // load current value from PluginProcessor bool useExternalTempo = *static_cast<const bool*> (processor->getGlobalSetting(GlobalSettings::sUseExternalTempo)); useExternalTempoBtn.setToggleState(useExternalTempo, NotificationType::dontSendNotification); String tempoBtnText = (useExternalTempo) ? "external tempo" : "internal tempo"; useExternalTempoBtn.setButtonText(tempoBtnText); yPos += PAD_AMOUNT + labelHeight; // combobox to select the number of channels setupLabel(setNumChannelsLbl); setNumChannelsLbl.setBounds(PAD_AMOUNT, yPos, labelWidth, labelHeight); addAndMakeVisible(&selNumChannels); selNumChannels.addListener(this); for(int i = 1; i <= 8; ++i) selNumChannels.addItem(String(i), i); selNumChannels.setBounds(labelWidth + 2 * PAD_AMOUNT, yPos, 150, labelHeight); const int numChannels = *static_cast<const int*> (processor->getGlobalSetting(GlobalSettings::sNumChannels)); selNumChannels.setSelectedId(numChannels, NotificationType::dontSendNotification); selNumChannels.setLookAndFeel(&overLF); yPos += PAD_AMOUNT + labelHeight; // choose envelope length setupLabel(setRampLengthLbl); setRampLengthLbl.setBounds(PAD_AMOUNT, yPos, labelWidth, labelHeight); const int initialRampLength = *static_cast<const int*>(processor->getGlobalSetting(GlobalSettings::sRampLength)); addAndMakeVisible(&rampLengthSldr); rampLengthSldr.setBounds(2*PAD_AMOUNT + labelWidth , yPos, labelWidth, labelHeight); rampLengthSldr.setRange(0.0, 1000.0, 1.0); rampLengthSldr.setValue(initialRampLength, NotificationType::dontSendNotification); rampLengthSldr.setColour(Slider::textBoxTextColourId, Colours::white); rampLengthSldr.setColour(Slider::thumbColourId, Colours::grey); rampLengthSldr.setColour(Slider::backgroundColourId, Colours::grey.darker()); rampLengthSldr.addListener(this); rampLengthSldr.setLookAndFeel(&overLF); rampLengthSldr.setSliderStyle(Slider::LinearBar); yPos += PAD_AMOUNT + labelHeight; // set the OSC prefix addAndMakeVisible(&oscPrefixLbl); setupLabel(oscPrefixLbl); oscPrefixLbl.setBounds(PAD_AMOUNT, yPos, labelWidth, labelHeight); addAndMakeVisible(&oscPrefixTxtBx); oscPrefixTxtBx.setBounds(labelWidth + 2*PAD_AMOUNT, yPos, 150, labelHeight); oscPrefixTxtBx.addListener(this); oscPrefixTxtBx.setEnabled(true); const String currentPrefix = *static_cast<const String*> (processor->getGlobalSetting(GlobalSettings::sOSCPrefix)); oscPrefixTxtBx.setText(currentPrefix, false); oscPrefixTxtBx.setFont(defaultFont); yPos += PAD_AMOUNT + labelHeight; // are we including sound from host? setupLabel(monitorInputsLbl); monitorInputsLbl.setBounds(PAD_AMOUNT, yPos, labelWidth, labelHeight); addAndMakeVisible(&monitorInputsBtn); monitorInputsBtn.setBounds(labelWidth + 2*PAD_AMOUNT, yPos, 150, labelHeight); monitorInputsBtn.addListener(this); // load current value from PluginProcessor const bool monitorInputs = *static_cast<const bool*> (processor->getGlobalSetting(GlobalSettings::sMonitorInputs)); monitorInputsBtn.setToggleState(monitorInputs, NotificationType::dontSendNotification); String monitorBtnText = (monitorInputs) ? "enabled" : "disabled"; monitorInputsBtn.setButtonText(monitorBtnText); yPos += PAD_AMOUNT + labelHeight; // what dimension device are we using setupLabel(setMonomeSizeLbl); setMonomeSizeLbl.setBounds(PAD_AMOUNT, yPos, labelWidth, labelHeight); addAndMakeVisible(&selMonomeSize); selMonomeSize.addListener(this); selMonomeSize.addItem("8x8", GlobalSettings::eightByEight); selMonomeSize.addItem("8x16", GlobalSettings::eightBySixteen); selMonomeSize.addItem("16x8", GlobalSettings::sixteenByEight); selMonomeSize.addItem("16x16", GlobalSettings::sixteenBySixteen); selMonomeSize.setBounds(labelWidth + 2 * PAD_AMOUNT, yPos, labelWidth, labelHeight); const int monomeSize = *static_cast<const int*> (processor->getGlobalSetting(GlobalSettings::sMonomeSize)); selMonomeSize.setSelectedId(monomeSize, NotificationType::dontSendNotification); yPos += PAD_AMOUNT + labelHeight; setupLabel(setNumSampleStrips); setMonomeSizeLbl.setBounds(PAD_AMOUNT, yPos, labelWidth, labelHeight); addAndMakeVisible(&selNumSampleStrips); selNumSampleStrips.addListener(this); const int numSampleStrips = *static_cast<const int*> (processor->getGlobalSetting(GlobalSettings::sNumSampleStrips)); for (int s = 0; s < 15; ++s) selNumSampleStrips.addItem(String(s), s+1); selNumSampleStrips.setBounds(labelWidth + 2 * PAD_AMOUNT, yPos, labelWidth, labelHeight); selNumSampleStrips.setSelectedId(numSampleStrips+1, NotificationType::dontSendNotification); yPos += PAD_AMOUNT + labelHeight; }
void OSDWidget::renderOSDText( const QString &txt ) { // Escaped text QString text = Konversation::removeIrcMarkup(txt); static QBitmap mask; //This is various spacings and margins, based on the font to look "just right" const uint METRIC = fontMetrics().width( 'x' ); // Set a sensible maximum size, don't cover the whole desktop or cross the screen QSize max = QApplication::desktop()->screen( m_screen )->size() - QSize( MARGIN*2 + METRIC*2, 100 ); QFont titleFont( "Arial", 12, QFont::Bold ); QFontMetrics titleFm( titleFont ); // The title cannnot be taller than one line // AlignAuto = align Arabic to the right, etc. QRect titleRect = titleFm.boundingRect( 0, 0, max.width() - METRIC, titleFm.height(), AlignAuto, m_appName ); // The osd cannot be larger than the screen QRect textRect = fontMetrics().boundingRect( 0, 0, max.width(), max.height(), AlignAuto | WordBreak, text ); if ( textRect.width() < titleRect.width() ) textRect.setWidth( titleRect.width() ); //this should still be within the screen bounds textRect.addCoords( 0, 0, METRIC*2, titleRect.height() + METRIC ); osdBuffer.resize( textRect.size() ); mask.resize( textRect.size() ); // Start painting! QPainter bufferPainter( &osdBuffer ); QPainter maskPainter( &mask ); // Draw backing rectangle const uint xround = (METRIC * 200) / textRect.width(); const uint yround = (METRIC * 200) / textRect.height(); bufferPainter.setPen( Qt::black ); bufferPainter.setBrush( backgroundColor() ); bufferPainter.drawRoundRect( textRect, xround, yround ); bufferPainter.setFont( font() ); const uint w = textRect.width() - 1; const uint h = textRect.height() - 1; // Draw the text shadow if ( m_shadow ) { bufferPainter.setPen( backgroundColor().dark( 175 ) ); bufferPainter.drawText( METRIC + 3, (METRIC/2) + titleFm.height() + 1, w, h, AlignLeft | WordBreak, text ); } // Draw the text bufferPainter.setPen( foregroundColor() ); bufferPainter.drawText( METRIC, (METRIC/2) + titleFm.height() - 1, w, h, AlignLeft | WordBreak, text ); // Draw the title text bufferPainter.setFont( titleFont ); bufferPainter.drawText( METRIC * 2, (METRIC/2), w, h, AlignLeft, m_appName ); // Masking for transparency mask.fill( Qt::black ); maskPainter.setBrush( Qt::white ); maskPainter.drawRoundRect( textRect, xround, yround ); setMask( mask ); //do last to reduce noticeable change when showing multiple OSDs in succession reposition( textRect.size() ); m_currentText = text; m_dirty = false; update(); }