void MainWindow::setUiDefults() { #ifdef Q_OS_MAC this->setWindowIcon(QIcon(":/cat_builder.icns")); #endif //Apply objects into tools setLevelSectionData(); setLvlItemBoxes(); setWldItemBoxes(); setSoundList(); applyTheme(Themes::currentTheme().isEmpty() ? ConfStatus::defaultTheme : Themes::currentTheme()); WldLvlExitTypeListReset(); //MainWindow Geometry; QRect mwg = this->geometry(); int GOffset=240; //Define the default geometry for toolboxes ui->DoorsToolbox->setGeometry( mwg.x()+mwg.width()-ui->DoorsToolbox->width()-GOffset, mwg.y()+120, ui->DoorsToolbox->width(), ui->DoorsToolbox->height() ); ui->LevelSectionSettings->setGeometry( mwg.x()+mwg.width()-ui->LevelSectionSettings->width()-GOffset, mwg.y()+120, ui->LevelSectionSettings->width(), ui->LevelSectionSettings->height() ); ui->LevelLayers->setGeometry( mwg.x()+mwg.width()-ui->LevelLayers->width()-GOffset, mwg.y()+120, ui->LevelLayers->width(), ui->LevelLayers->height() ); ui->LevelEventsToolBox->setGeometry( mwg.x()+mwg.width()-ui->LevelEventsToolBox->width()-GOffset, mwg.y()+120, ui->LevelEventsToolBox->width(), ui->LevelEventsToolBox->height() ); ui->ItemProperties->setGeometry( mwg.x()+mwg.width()-ui->ItemProperties->width()-GOffset, mwg.y()+120, ui->ItemProperties->width(), ui->ItemProperties->height() ); ui->FindDock->setGeometry( mwg.x()+mwg.width()-ui->FindDock->width()-GOffset, mwg.y()+120, ui->FindDock->width(), ui->FindDock->height() ); ui->WLD_ItemProps->setGeometry( mwg.x()+mwg.width()-ui->WLD_ItemProps->width()-GOffset, mwg.y()+120, ui->WLD_ItemProps->width(), ui->WLD_ItemProps->height() ); ui->WorldSettings->setGeometry( mwg.x()+mwg.width()-ui->WorldSettings->width()-GOffset-200, mwg.y()+120, ui->WorldSettings->width(), ui->WorldSettings->height() ); ui->WorldFindDock->setGeometry( mwg.x()+mwg.width()-ui->WorldFindDock->width()-GOffset, mwg.y()+120, ui->WorldFindDock->width(), ui->WorldFindDock->height() ); ui->Tileset_Item_Box->setGeometry( mwg.x()+GOffset, mwg.y()+mwg.height()-600, 800, 300 ); ui->debuggerBox->setGeometry( mwg.x()+mwg.width()-ui->debuggerBox->width()-GOffset, mwg.y()+120, ui->debuggerBox->width(), ui->debuggerBox->height() ); ui->bookmarkBox->setGeometry( mwg.x()+mwg.width()-ui->bookmarkBox->width()-GOffset, mwg.y()+120, ui->bookmarkBox->width(), ui->bookmarkBox->height() ); QFont font("Monospace"); font.setStyleHint(QFont::TypeWriter); font.setWeight(8); ui->DEBUG_Items->setFont(font); loadSettings(); connect(ui->centralWidget, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(updateMenus())); windowMapper = new QSignalMapper(this); connect(windowMapper, SIGNAL(mapped(QWidget*)), this, SLOT(setActiveSubWindow(QWidget*))); ui->actionPlayMusic->setChecked(GlobalSettings::autoPlayMusic); ui->actionExport_to_image_section->setVisible(false); ui->actionVBAlphaEmulate->setChecked(GraphicsHelps::EnableVBEmulate); ui->centralWidget->cascadeSubWindows(); ui->applyResize->setVisible(false); ui->cancelResize->setVisible(false); ui->ResizingToolbar->setVisible(false); ui->PlacingToolbar->setVisible(false); ui->LevelToolBox->hide(); ui->DoorsToolbox->hide(); ui->LevelLayers->hide(); ui->LevelEventsToolBox->hide(); ui->LevelSectionSettings->hide(); ui->ItemProperties->hide(); ui->FindDock->hide(); ui->WorldToolBox->hide(); ui->WorldSettings->hide(); ui->WLD_ItemProps->hide(); ui->WorldFindDock->hide(); ui->Tileset_Item_Box->hide(); ui->debuggerBox->hide(); ui->bookmarkBox->hide(); ui->menuView->setEnabled(false); ui->menuWindow->setEnabled(true); ui->menuLevel->setEnabled(false); ui->menuWorld->setEnabled(false); ui->menuTest->setEnabled(false); ui->LevelObjectToolbar->setVisible(false); ui->WorldObjectToolbar->setVisible(false); ui->actionLVLToolBox->setVisible(false); ui->actionWarpsAndDoors->setVisible(false); ui->actionSection_Settings->setVisible(false); ui->actionWarpsAndDoors->setVisible(false); ui->actionWLDToolBox->setVisible(false); ui->actionGridEn->setChecked(true); ui->actionTilesetBox->setVisible(false); ui->actionBookmarkBox->setVisible(false); ui->actionDebugger->setVisible(false); ui->actionZoomReset->setEnabled(false); ui->actionZoomIn->setEnabled(false); ui->actionZoomOut->setEnabled(false); setAcceptDrops(true); ui->centralWidget->cascadeSubWindows(); ui->centralWidget->setViewMode(GlobalSettings::MainWindowView); ui->LevelToolBoxTabs->setTabPosition(GlobalSettings::LVLToolboxPos); ui->WorldToolBoxTabs->setTabPosition(GlobalSettings::WLDToolboxPos); ui->TileSetsCategories->setTabPosition(GlobalSettings::TSTToolboxPos); ui->centralWidget->setTabsClosable(true); muVol = new QSlider(Qt::Horizontal); muVol->setMaximumWidth(70); muVol->setMinimumWidth(70); muVol->setMinimum(0); muVol->setMaximum(MIX_MAX_VOLUME); muVol->setValue(GlobalSettings::musicVolume); MusPlayer.setVolume(muVol->value()); ui->EditionToolBar->insertWidget(ui->actionAnimation, muVol); ui->EditionToolBar->insertSeparator(ui->actionAnimation); zoom = new QLineEdit(); zoom->setValidator(new QIntValidator(0,2001)); zoom->setText("100"); zoom->setMaximumWidth(50); zoom->setEnabled(false); ui->LevelSectionsToolBar->insertWidget(ui->actionZoomReset,zoom); connect(zoom, SIGNAL(editingFinished()), this, SLOT(applyTextZoom())); connect(muVol, SIGNAL(valueChanged(int)), &MusPlayer, SLOT(setVolume(int))); curSearchBlock.id = 0; curSearchBlock.index = 0; curSearchBlock.npc_id = 0; curSearchBGO.id = 0; curSearchBGO.index = 0; curSearchNPC.id = 0; curSearchNPC.index = 0; curSearchTile.id = 0; curSearchTile.index = 0; curSearchScenery.id = 0; curSearchScenery.index = 0; curSearchPath.id = 0; curSearchPath.index = 0; curSearchLevel.id = 0; curSearchLevel.index = 0; curSearchMusic.id = 0; curSearchMusic.index = 0; connect(ui->LvlLayerList->model(), SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(DragAndDroppedLayer(QModelIndex,int,int,QModelIndex,int))); connect(ui->LVLEvents_List->model(), SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(DragAndDroppedEvent(QModelIndex,int,int,QModelIndex,int))); connect(ui->bookmarkList->model(), SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(DragAndDroppedBookmark(QModelIndex,int,int,QModelIndex,int))); //enable & disable connect(ui->Find_Check_TypeBlock, SIGNAL(toggled(bool)), ui->Find_Button_TypeBlock, SLOT(setEnabled(bool))); connect(ui->Find_Check_TypeBGO, SIGNAL(toggled(bool)), ui->Find_Button_TypeBGO, SLOT(setEnabled(bool))); connect(ui->Find_Check_TypeNPC, SIGNAL(toggled(bool)), ui->Find_Button_TypeNPC, SLOT(setEnabled(bool))); connect(ui->Find_Check_PriorityBGO, SIGNAL(toggled(bool)), ui->Find_Spin_PriorityBGO, SLOT(setEnabled(bool))); connect(ui->Find_Check_LayerBlock, SIGNAL(toggled(bool)), ui->Find_Combo_LayerBlock, SLOT(setEnabled(bool))); connect(ui->Find_Check_LayerBGO, SIGNAL(toggled(bool)), ui->Find_Combo_LayerBGO, SLOT(setEnabled(bool))); connect(ui->Find_Check_LayerNPC, SIGNAL(toggled(bool)), ui->Find_Combo_LayerNPC, SLOT(setEnabled(bool))); connect(ui->Find_Check_InvisibleBlock, SIGNAL(toggled(bool)), ui->Find_Check_InvisibleActiveBlock, SLOT(setEnabled(bool))); connect(ui->Find_Check_SlipperyBlock, SIGNAL(toggled(bool)), ui->Find_Check_SlipperyActiveBlock, SLOT(setEnabled(bool))); connect(ui->Find_Check_ContainsNPCBlock, SIGNAL(toggled(bool)), ui->Find_Button_ContainsNPCBlock, SLOT(setEnabled(bool))); connect(ui->Find_Check_EventDestoryedBlock, SIGNAL(toggled(bool)), ui->Find_Combo_EventDestoryedBlock, SLOT(setEnabled(bool))); connect(ui->Find_Check_EventHitedBlock, SIGNAL(toggled(bool)), ui->Find_Combo_EventHitedBlock, SLOT(setEnabled(bool))); connect(ui->Find_Check_EventLayerEmptyBlock, SIGNAL(toggled(bool)), ui->Find_Combo_EventLayerEmptyBlock, SLOT(setEnabled(bool))); connect(ui->Find_Check_DirNPC, SIGNAL(toggled(bool)), ui->Find_Radio_DirLeftNPC, SLOT(setEnabled(bool))); connect(ui->Find_Check_DirNPC, SIGNAL(toggled(bool)), ui->Find_Radio_DirRandomNPC, SLOT(setEnabled(bool))); connect(ui->Find_Check_DirNPC, SIGNAL(toggled(bool)), ui->Find_Radio_DirRightNPC, SLOT(setEnabled(bool))); connect(ui->Find_Check_FriendlyNPC, SIGNAL(toggled(bool)), ui->Find_Check_FriendlyActiveNPC, SLOT(setEnabled(bool))); connect(ui->Find_Check_NotMoveNPC, SIGNAL(toggled(bool)), ui->Find_Check_NotMoveActiveNPC, SLOT(setEnabled(bool))); connect(ui->Find_Check_BossNPC, SIGNAL(toggled(bool)), ui->Find_Check_BossActiveNPC, SLOT(setEnabled(bool))); connect(ui->Find_Check_MsgNPC, SIGNAL(toggled(bool)), ui->Find_Edit_MsgNPC, SLOT(setEnabled(bool))); connect(ui->Find_Check_MsgNPC, SIGNAL(toggled(bool)), ui->Find_Check_MsgSensitiveNPC, SLOT(setEnabled(bool))); //for world search connect(ui->Find_Check_TypeLevel, SIGNAL(toggled(bool)), ui->Find_Button_TypeLevel, SLOT(setEnabled(bool))); connect(ui->Find_Check_TypeTile, SIGNAL(toggled(bool)), ui->Find_Button_TypeTile, SLOT(setEnabled(bool))); connect(ui->Find_Check_TypeScenery, SIGNAL(toggled(bool)), ui->Find_Button_TypeScenery, SLOT(setEnabled(bool))); connect(ui->Find_Check_TypePath, SIGNAL(toggled(bool)), ui->Find_Button_TypePath, SLOT(setEnabled(bool))); connect(ui->Find_Check_TypeMusic, SIGNAL(toggled(bool)), ui->Find_Button_TypeMusic, SLOT(setEnabled(bool))); connect(ui->Find_Check_PathBackground, SIGNAL(toggled(bool)), ui->Find_Check_PathBackgroundActive, SLOT(setEnabled(bool))); connect(ui->Find_Check_BigPathBackground, SIGNAL(toggled(bool)), ui->Find_Check_BigPathBackgroundActive, SLOT(setEnabled(bool))); connect(ui->Find_Check_AlwaysVisible, SIGNAL(toggled(bool)), ui->Find_Check_AlwaysVisibleActive, SLOT(setEnabled(bool))); connect(ui->Find_Check_GameStartPoint, SIGNAL(toggled(bool)), ui->Find_Check_GameStartPointActive, SLOT(setEnabled(bool))); connect(ui->Find_Check_LevelFile, SIGNAL(toggled(bool)), ui->Find_Edit_LevelFile, SLOT(setEnabled(bool))); connect(ui->Find_Check_LevelFile, SIGNAL(toggled(bool)), ui->Find_Button_LevelFile, SLOT(setEnabled(bool))); connect(ui->Find_Check_ContainsTitle, SIGNAL(toggled(bool)), ui->Find_Edit_ContainsTitle, SLOT(setEnabled(bool))); //reset if modify connect(ui->Find_Button_TypeBlock, SIGNAL(clicked()), this, SLOT(resetBlockSearch())); connect(ui->Find_Button_TypeBGO, SIGNAL(clicked()), this, SLOT(resetBGOSearch())); connect(ui->Find_Button_TypeNPC, SIGNAL(clicked()), this, SLOT(resetNPCSearch())); connect(ui->Find_Spin_PriorityBGO, SIGNAL(valueChanged(int)), this, SLOT(resetBGOSearch())); connect(ui->Find_Combo_LayerBlock, SIGNAL(activated(int)), this, SLOT(resetBlockSearch())); connect(ui->Find_Combo_LayerBGO, SIGNAL(activated(int)), this, SLOT(resetBGOSearch())); connect(ui->Find_Combo_LayerNPC, SIGNAL(activated(int)), this, SLOT(resetNPCSearch())); connect(ui->Find_Check_InvisibleActiveBlock, SIGNAL(clicked()), this, SLOT(resetBlockSearch())); connect(ui->Find_Check_SlipperyActiveBlock, SIGNAL(clicked()), this, SLOT(resetBlockSearch())); connect(ui->Find_Button_ContainsNPCBlock, SIGNAL(clicked()), this, SLOT(resetBlockSearch())); connect(ui->Find_Combo_EventDestoryedBlock, SIGNAL(activated(int)), this, SLOT(resetBlockSearch())); connect(ui->Find_Combo_EventHitedBlock, SIGNAL(activated(int)), this, SLOT(resetBlockSearch())); connect(ui->Find_Combo_EventLayerEmptyBlock, SIGNAL(activated(int)), this, SLOT(resetBlockSearch())); connect(ui->Find_Radio_DirLeftNPC, SIGNAL(clicked()), this, SLOT(resetNPCSearch())); connect(ui->Find_Radio_DirRandomNPC, SIGNAL(clicked()), this, SLOT(resetNPCSearch())); connect(ui->Find_Radio_DirRightNPC, SIGNAL(clicked()), this, SLOT(resetNPCSearch())); connect(ui->Find_Check_FriendlyActiveNPC, SIGNAL(clicked()), this, SLOT(resetNPCSearch())); connect(ui->Find_Check_NotMoveActiveNPC, SIGNAL(clicked()), this, SLOT(resetNPCSearch())); connect(ui->Find_Check_BossActiveNPC, SIGNAL(clicked()), this, SLOT(resetNPCSearch())); connect(ui->Find_Edit_MsgNPC, SIGNAL(textEdited(QString)), this, SLOT(resetNPCSearch())); connect(ui->Find_Check_MsgSensitiveNPC, SIGNAL(clicked()), this, SLOT(resetNPCSearch())); //for world connect(ui->Find_Button_TypeTile, SIGNAL(clicked()), this, SLOT(resetTileSearch())); connect(ui->Find_Button_TypeScenery, SIGNAL(clicked()), this, SLOT(resetScenerySearch())); connect(ui->Find_Button_TypePath, SIGNAL(clicked()), this, SLOT(resetPathSearch())); connect(ui->Find_Button_TypeLevel, SIGNAL(clicked()), this, SLOT(resetLevelSearch())); connect(ui->Find_Button_TypeMusic, SIGNAL(clicked()), this, SLOT(resetMusicSearch())); connect(ui->Find_Check_PathBackgroundActive, SIGNAL(clicked()), this, SLOT(resetLevelSearch())); connect(ui->Find_Check_BigPathBackgroundActive, SIGNAL(clicked()), this, SLOT(resetLevelSearch())); connect(ui->Find_Check_AlwaysVisibleActive, SIGNAL(clicked()), this, SLOT(resetLevelSearch())); connect(ui->Find_Check_GameStartPointActive, SIGNAL(clicked()), this, SLOT(resetLevelSearch())); connect(ui->Find_Edit_LevelFile, SIGNAL(textEdited(QString)), this, SLOT(resetLevelSearch())); connect(ui->Find_Button_LevelFile, SIGNAL(clicked()), this, SLOT(resetLevelSearch())); connect(ui->Find_Edit_ContainsTitle, SIGNAL(textEdited(QString)), this, SLOT(resetLevelSearch())); //also checkboxes connect(ui->Find_Check_TypeBlock, SIGNAL(clicked()), this, SLOT(resetBlockSearch())); connect(ui->Find_Check_LayerBlock, SIGNAL(clicked()), this, SLOT(resetBlockSearch())); connect(ui->Find_Check_InvisibleBlock, SIGNAL(clicked()), this, SLOT(resetBlockSearch())); connect(ui->Find_Check_SlipperyBlock, SIGNAL(clicked()), this, SLOT(resetBlockSearch())); connect(ui->Find_Check_ContainsNPCBlock, SIGNAL(clicked()), this, SLOT(resetBlockSearch())); connect(ui->Find_Check_EventDestoryedBlock, SIGNAL(clicked()), this, SLOT(resetBlockSearch())); connect(ui->Find_Check_EventLayerEmptyBlock, SIGNAL(clicked()), this, SLOT(resetBlockSearch())); connect(ui->Find_Check_TypeBGO, SIGNAL(clicked()), this, SLOT(resetBGOSearch())); connect(ui->Find_Check_LayerBGO, SIGNAL(clicked()), this, SLOT(resetBGOSearch())); connect(ui->Find_Check_PriorityBGO, SIGNAL(clicked()), this, SLOT(resetBGOSearch())); connect(ui->Find_Check_TypeNPC, SIGNAL(clicked()), this, SLOT(resetNPCSearch())); connect(ui->Find_Check_LayerNPC, SIGNAL(clicked()), this, SLOT(resetNPCSearch())); connect(ui->Find_Check_DirNPC, SIGNAL(clicked()), this, SLOT(resetNPCSearch())); connect(ui->Find_Check_FriendlyNPC, SIGNAL(clicked()), this, SLOT(resetNPCSearch())); connect(ui->Find_Check_NotMoveNPC, SIGNAL(clicked()), this, SLOT(resetNPCSearch())); connect(ui->Find_Check_BossNPC, SIGNAL(clicked()), this, SLOT(resetNPCSearch())); connect(ui->Find_Check_MsgNPC, SIGNAL(clicked()), this, SLOT(resetNPCSearch())); //for world connect(ui->Find_Check_TypeTile, SIGNAL(clicked()), this, SLOT(resetTileSearch())); connect(ui->Find_Check_TypeScenery, SIGNAL(clicked()), this, SLOT(resetScenerySearch())); connect(ui->Find_Check_TypePath, SIGNAL(clicked()), this, SLOT(resetPathSearch())); connect(ui->Find_Check_TypeLevel, SIGNAL(clicked()), this, SLOT(resetLevelSearch())); connect(ui->Find_Check_TypeMusic, SIGNAL(clicked()), this, SLOT(resetMusicSearch())); connect(ui->Find_Check_PathBackground, SIGNAL(clicked()), this, SLOT(resetLevelSearch())); connect(ui->Find_Check_BigPathBackground, SIGNAL(clicked()), this, SLOT(resetLevelSearch())); connect(ui->Find_Check_AlwaysVisible, SIGNAL(clicked()), this, SLOT(resetLevelSearch())); connect(ui->Find_Check_GameStartPoint, SIGNAL(clicked()), this, SLOT(resetLevelSearch())); connect(ui->Find_Check_LevelFile, SIGNAL(clicked()), this, SLOT(resetLevelSearch())); connect(ui->Find_Check_ContainsTitle, SIGNAL(clicked()), this, SLOT(resetLevelSearch())); connect(ui->Find_Button_LevelFile, SIGNAL(clicked()), this, SLOT(selectLevelForSearch())); connect(ui->centralWidget, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(toggleNewWindowLVL(QMdiSubWindow*))); connect(ui->centralWidget, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(toggleNewWindowWLD(QMdiSubWindow*))); //for tileset dock //connect(ui->TileSetsCategories, SIGNAL(currentChanged(int)), this, SLOT(makeCurrentTileset())); //for tileset connect(ui->customTilesetSearchEdit, SIGNAL(textChanged(QString)), this, SLOT(makeCurrentTileset())); updateWindowMenu(); }
/** Draws the label using the specificed painter & x/y-offsets */ void MLabelObject::draw(QPainter* p, int xoffset, int yoffset){ QFont font(fontFamily, fontSize, fontWeight, fontItalic); QPen textPen(foregroundColor, 0, QPen::NoPen); int tf; // Set the offsets int xcalc = xpos + xoffset; int ycalc = ypos + yoffset; // Draw the base drawBase(p, xoffset, yoffset); // Set the font p->setFont(font); QFontMetrics fm = p->fontMetrics(); // Set the text alignment flags // Horizontal switch(hAlignment){ case MLabelObject::Left: tf = QPainter::AlignLeft; break; case MLabelObject::Center: tf = QPainter::AlignHCenter; break; case MLabelObject::Right: tf = QPainter::AlignRight; } // Vertical switch(vAlignment){ case MLabelObject::Top: tf = tf | QPainter::AlignTop; break; case MLabelObject::Bottom: tf = tf | QPainter::AlignBottom; break; case MLabelObject::Middle: tf = tf | QPainter::AlignVCenter; } // Word wrap if(wordWrap) tf = tf | QPainter::WordBreak; // Draw the text p->setPen(textPen); QString newtext = text; newtext.replace( QRegExp( "<br>", false ), QString( "\n" ) ); p->drawText(xcalc + xMargin, ycalc + yMargin, width - xMargin, height - yMargin, tf, newtext); // leave this in place - possible use for other tags // // // ---------------------------------------- // // look for line breaks (<br>) // // ---------------------------------------- // int idx = 0; // int ysub = ycalc; // int line_height = height; // int len = text.length(); // int line_len = len; // QString sep = "<br>"; // int len_sep = sep.length(); // while ( idx < len ) // { // int eol = text.find( sep, idx, FALSE ); // if ( eol < 0 ) // eol = len; // line_len = eol - idx; // // draw the line and determine the space used. // QRect brect = p->boundingRect(xcalc + xMargin, ysub + yMargin, // width - xMargin, line_height - yMargin, // tf, text.mid( idx, line_len ), line_len); // p->drawText( xcalc + xMargin, ysub + yMargin, // width - xMargin, line_height - yMargin, // tf, text.mid( idx, line_len ), line_len ); // // substract the vert space used. // ysub += brect.height(); // line_height -= brect.height(); // // nothing more // if ( eol == len ) // break; // else // idx = eol + len_sep; // } }
void FadePedal::paintEvent(QPaintEvent* /*event*/) { float lastValue = (m_Ticks.empty() ? 0 : m_Ticks.back().value); float angle = (35 * lastValue); QRectF r( rect() ); r.adjust(1, 1, -1, -1); QPainter painter; m_Canvas.fill(0); if( painter.begin(&m_Canvas) ) { painter.setRenderHints(QPainter::Antialiasing); float brightness = m_Click; if(m_Hover > 0) brightness += (m_Hover*0.2f); if( !m_Image.isNull() ) { painter.setOpacity(1.0-(brightness*0.5)); painter.drawPixmap( r.x() + qRound((r.width()-m_Image.width())*0.5), r.y() + qRound((r.height()-m_Image.height())*0.5), m_Image ); painter.setOpacity(1.0); } QColor brushColor( palette().color(QPalette::Button) ); if(m_Hover > 0) { qreal t = (brightness * BUTTON_BRIGHTESS); brushColor.setRedF( qMin(brushColor.redF()+t,1.0) ); brushColor.setGreenF( qMin(brushColor.greenF()+t,1.0) ); brushColor.setBlueF( qMin(brushColor.blueF()+t,1.0) ); } QColor lineColor(brushColor); Utils::MakeContrastingColor(1.0f, lineColor); if( !m_Image.isNull() ) { QPainterPath clip; clip.addRoundedRect(r, ROUNDED, ROUNDED); painter.setClipPath(clip); painter.drawPixmap( r.x() + qRound((r.width()-m_Image.width())*0.5), r.y() + qRound((r.height()-m_Image.height())*0.5), m_Image ); painter.setClipping(false); } painter.setBrush(brushColor); painter.setPen( QPen(lineColor,BORDER) ); painter.drawRoundedRect(r, ROUNDED, ROUNDED); if( m_Ticks.empty() ) m_Points.clear(); else m_Points.resize(m_Ticks.size() + 1); // end point if( !m_Points.empty() ) { float lineHeight = (r.height() * 0.8f); float lineX = (r.right() + HALF_BORDER); float lineY = (r.bottom() - 0.5f*(r.height()-lineHeight)); float lineWidth = (r.width() + BORDER); float toPercent = 1.0f/PEDAL_TIMEFRAME; for(size_t i=0; i<m_Ticks.size(); i++) { const sTick &t = m_Ticks[i]; QPointF &p = m_Points[i]; // end point float percent = (t.elapsed * toPercent); p.setX(lineX - lineWidth*percent); p.setY(lineY - lineHeight*t.value); } // end point m_Points[m_Points.size()-1] = QPointF(lineX, m_Points[m_Points.size()-2].y()); painter.drawPolyline(m_Points); } if(m_Hover > 0) { qreal dy = (-m_Hover * BUTTON_RAISE); if(dy != 0) r.adjust(0, 0, 0, dy); } QColor textColor( palette().color(QPalette::ButtonText) ); if( !isEnabled() ) textColor = textColor.darker(150); if( !text().isEmpty() ) { if( m_Label.isEmpty() ) { // just text centered painter.setFont( font() ); painter.setPen(textColor); painter.drawText(r, Qt::AlignCenter|Qt::TextWordWrap, text()); } else { // both text and label text QRectF textRect; painter.setFont( font() ); painter.setPen(textColor); painter.drawText(r, Qt::AlignCenter|Qt::TextWordWrap|Qt::TextDontPrint, text(), &textRect); QRectF labelRect; painter.drawText(r, Qt::AlignCenter|Qt::TextWordWrap|Qt::TextDontPrint, m_Label, &labelRect); qreal h = (r.height() * 0.5 * (textRect.height()/labelRect.height())); painter.drawText(QRectF(r.x(),r.y(),r.width(),h), Qt::AlignCenter|Qt::TextWordWrap, text()); painter.drawText(QRectF(r.x(),r.y()+h,r.width(),r.height()-h), Qt::AlignCenter|Qt::TextWordWrap, m_Label); } } else if( !m_Label.isEmpty() ) { // just label text centered painter.setFont( font() ); painter.setPen(textColor); painter.drawText(r, Qt::AlignCenter|Qt::TextWordWrap, m_Label); } painter.end(); } if( painter.begin(this) ) { if(angle > 0.00001) { qreal center = (m_Canvas.width() * 0.5); QMatrix4x4 matrix; matrix.translate(-center, m_Canvas.height()); matrix.rotate(angle, 1.0, 0, 0); painter.translate(center, 0); painter.setTransform(matrix.toTransform(300.0), /*combine*/true); painter.setRenderHint(QPainter::SmoothPixmapTransform); painter.drawImage(0, -m_Canvas.height(), m_Canvas); } else painter.drawImage(0, 0, m_Canvas); painter.end(); } }
void scrolText::setBold(bool b) { QFont f=font(); f.setBold(b); setFont(f); }
double UtilObject::textWidth(const QString &text, int size, const QString &family) { QFont font(family); font.setPixelSize(size); QFontMetricsF metrics(font); return metrics.width(text); }
void tGraph::draw(QPainter & paint) { //QPainter paint(this); paint.save(); int gx1 = hPadding() + _rect.x(); int gy1 = vPadding() + _rect.y(); int gx2 = _rect.x() + width() - hPadding(); int gy2 = _rect.y() + height() - vPadding(); //paint.drawRect(gx1, gy1, gx2 - gx1, gy2 - gy1); QFontMetrics fm(font()); //QRect brect; // get the dimensions of the title label and then draw it if(title().length() > 0) { fm = QFontMetrics(titleFont()); //brect = fm.boundingRect(title()); paint.setFont(titleFont()); paint.drawText(gx1, gy1, gx2 - gx1, fm.height(), titleAlignment(), title()); gy1 += fm.height(); } // we need to do some drawing that depends on some other elements having // already been placed... since those require that these have already been // placed we will just save the old value of gy2 and then calculate the // value that we should have after the other code runs without actually // drawing anything right now int gy2_old = gy2; if(dataLabel().length() > 0) { fm = QFontMetrics(dataLabelFont()); gy2 -= fm.height(); } fm = QFontMetrics(dataFont()); double tlh = 0.0; QMapIterator<int, GReference> dlit(_data); while(dlit.hasNext()) { dlit.next(); tlh = QMAX(sin45deg * fm.width(dlit.value().first), tlh); } // don't change this variable as we use it later int th = (tlh == 0.0 ? 0 : (int)(tlh + (fm.height() * sin45deg)) + 2); gy2 -= th; // get the dimensions of the value label then draw it if(valueLabel().length() > 0) { fm = QFontMetrics(valueLabelFont()); //brect = fm.boundingRect(valueLabel()); paint.setFont(valueLabelFont()); paint.save(); paint.rotate(-90); paint.drawText(-gy2, gx1, gy2 - gy1, fm.height(), valueLabelAlignment(), valueLabel()); paint.restore(); gx1 += fm.height(); } fm = QFontMetrics(valueFont()); QString min_str = QString().sprintf("%-.0f",minValue()); QString org_str = ( minValue() == 0.0 ? QString::null : QString("0") ); QString max_str = QString().sprintf("%-.0f",maxValue()); int width = QMAX(fm.width(min_str), fm.width(max_str)); if(org_str.length() > 0) width = QMAX(width, fm.width(org_str)); gx1 += width; int gy_max = gy1; int gy_min = gy2 - 1; int gy_org = gy_min; paint.setFont(valueFont()); int tfa = Qt::AlignTop | Qt::AlignRight; paint.drawText(gx1 - fm.width(min_str), gy_min, fm.width(min_str), fm.height(), tfa, min_str); paint.drawLine(gx1 - 3, gy_min, gx1 + 2, gy_min); paint.drawText(gx1 - fm.width(max_str), gy_max, fm.width(max_str), fm.height(), tfa, max_str); paint.drawLine(gx1 - 3, gy_max, gx1 + 2, gy_max); int gheight = gy2 - gy1; double grng = maxValue() - minValue(); if(org_str.length() > 0) { double perc = (0 - minValue()) / grng; gy_org = gy2 - (int)(perc * (double)gheight); paint.drawText(gx1 - fm.width(org_str), gy_org, fm.width(org_str), fm.height(), tfa, org_str); paint.drawLine(gx1 - 3, gy_org, gx1 + 2, gy_org); } gx1 += 3; // put the old value back so all the code to come draw correctly! gy2 = gy2_old; // get the dimensions of the data label then draw it if(dataLabel().length() > 0) { fm = QFontMetrics(dataLabelFont()); //brect = fm.boundingRect(dataLabel()); paint.setFont(dataLabelFont()); gy2 -= fm.height(); paint.drawText(gx1, gy2, gx2 - gx1, fm.height(), dataLabelAlignment(), dataLabel()); } gy2 -= th; int ref_cnt = _data.count(); int gwidth = gx2 - gx1; gheight = gy2 - gy1; if(ref_cnt > 0) { paint.save(); fm = QFontMetrics(dataFont()); paint.setFont(dataFont()); int refwidth = QMAX(1, gwidth / ref_cnt); int buf = (int)(refwidth / 5); int buf2 = buf * 2; int pos = gx1 + (int)((gwidth - (refwidth * ref_cnt)) / 2); int bar_height; int fmheight = fm.height(); int fmheight_div_2 = fmheight / 2; int refwidth_div_2 = refwidth / 2; int label_offset = (int)(fmheight_div_2 * cos45deg); int last_label_at = -1000; QMap<int, double> last_map; QMap<int, double> this_map; QMapIterator<int, GReference> rit(_data); while(rit.hasNext()) { rit.next(); GReference ref = rit.value(); QString label = ref.first; if(label.length() > 0 && ((pos + refwidth_div_2) - last_label_at) > ((label_offset * 2) + 1)) { last_label_at = pos + refwidth_div_2; int lx = (int)(((pos + refwidth_div_2) * cos45deg) - ((gy2 + label_offset) * sin45deg)); int ly = (int)(((pos + refwidth_div_2) * sin45deg) + ((gy2 + label_offset) * cos45deg)); int fmwidth = fm.width(label); paint.save(); paint.rotate(-45); paint.drawText(lx - fmwidth, ly - fmheight_div_2, fmwidth, fmheight, Qt::AlignRight | Qt::AlignTop, label); paint.restore(); } QMapIterator<int, double> sit(ref.second); paint.save(); if(drawBars() == TRUE) { TSetValue tval; QMap<double, TSetValue> sort_map; sit = ref.second; while(sit.hasNext()) { sit.next(); if(sit.value() != 0.0 && _setStyle[sit.key()].bar == TRUE) { tval.first = sit.key(); tval.second = sit.value(); sort_map[(tval.second < 0.0 ? minValue() : maxValue()) - (tval.second < 0.0 ? -tval.second : tval.second)] = tval; } } QMapIterator<double, TSetValue> it(sort_map); while(it.hasNext()) { it.next(); tval = it.value(); if(tval.second != 0.0) { if(tval.second < 0) { bar_height = (int)((tval.second / minValue()) * (gy_org - gy_min)); } else { bar_height = (int)((tval.second / maxValue()) * (gy_org - gy_max)); } paint.fillRect(pos + buf, gy_org - bar_height, refwidth - buf2, bar_height, getSetColor(tval.first)); } } } if(drawLines() == TRUE) { this_map.clear(); sit = ref.second; while(sit.hasNext()) { sit.next(); if(_setStyle[sit.key()].line == TRUE) { this_map[sit.key()] = sit.value(); if(last_map.contains(sit.key())) { paint.setPen(getSetColor(sit.key())); double old_val = last_map[sit.key()]; double new_val = sit.value(); int ly1; if(old_val < 0.0) ly1 = (int)((old_val / minValue()) * (gy_org - gy_min)); else ly1 = (int)((old_val / maxValue()) * (gy_org - gy_max)); ly1 = gy_org - ly1; int lx1 = pos - refwidth_div_2; int ly2; if(new_val < 0.0) ly2 = (int)((new_val / minValue()) * (gy_org - gy_min)); else ly2 = (int)((new_val / maxValue()) * (gy_org - gy_max)); ly2 = gy_org - ly2; int lx2 = pos + refwidth_div_2; paint.drawLine(lx1, ly1, lx2, ly2); } } } last_map = this_map; } if(drawPoints() == TRUE) { sit = ref.second; while(sit.hasNext()) { sit.next(); if(_setStyle[sit.key()].point == TRUE) { paint.setBrush(getSetColor(sit.key())); paint.setPen(QColor(0,0,0)); int ly1; if(sit.value() < 0.0) ly1 = (int)((sit.value() / minValue()) * (gy_org - gy_min)); else ly1 = (int)((sit.value() / maxValue()) * (gy_org - gy_max)); ly1 = gy_org - ly1; int lx1 = pos + refwidth_div_2; paint.drawEllipse(lx1 - 2, ly1 - 2, 5, 5); } } } paint.restore(); pos += refwidth; } paint.restore(); } paint.drawLine(gx1, gy_org, gx2 - 1, gy_org); paint.drawRect(gx1, gy1, gx2 - gx1, gy2 - gy1); // Now that we are done return the paint device back to the state // it was when we started to mess with it paint.restore(); }
void scrolText::setTextSize(int s) { QFont f=font(); f.setPixelSize(s); setFont(f); }
int ViewItemPaintParams::text_height() { return QFontMetrics(font()).height(); }
void FormText::setCfg( const Cfg::Text & c ) { setPlainText( QString() ); QFont f = font(); QTextCharFormat fmt = textCursor().charFormat(); QTextBlockFormat b = textCursor().blockFormat(); foreach( const Cfg::TextStyle & s, c.text() ) { if( s.style().contains( Cfg::c_normalStyle ) ) { f.setWeight( QFont::Normal ); f.setItalic( false ); f.setUnderline( false ); fmt.setFontWeight( QFont::Normal ); fmt.setFontItalic( false ); fmt.setFontUnderline( false ); } else { if( s.style().contains( Cfg::c_boldStyle ) ) { f.setWeight( QFont::Bold ); fmt.setFontWeight( QFont::Bold ); } else { f.setWeight( QFont::Normal ); fmt.setFontWeight( QFont::Normal ); } if( s.style().contains( Cfg::c_italicStyle ) ) { f.setItalic( true ); fmt.setFontItalic( true ); } else { f.setItalic( false ); fmt.setFontItalic( false ); } if( s.style().contains( Cfg::c_underlineStyle ) ) { f.setUnderline( true ); fmt.setFontUnderline( true ); } else { f.setUnderline( false ); fmt.setFontUnderline( false ); } } Cfg::initBlockFormat( b, s ); f.setPointSize( s.fontSize() ); fmt.setFontPointSize( s.fontSize() ); setFont( f ); QTextCursor cursor = textCursor(); cursor.movePosition( QTextCursor::End ); cursor.setCharFormat( fmt ); cursor.setBlockFormat( b ); cursor.insertText( s.text() ); setTextCursor( cursor ); } document()->clearUndoRedoStacks(); setObjectId( c.objectId() ); setTextWidth( c.textWidth() ); setPos( QPointF( c.pos().x(), c.pos().y() ) ); setLink( c.link() ); QRectF r = boundingRect(); r.moveTo( pos() ); d->m_proxy->setRect( r ); }
void ledCheckBox::onTextUpdated() { setFixedSize( m_ledOffPixmap->width() + 5 + QFontMetrics( font() ).width( text() ), m_ledOffPixmap->height() ); }
/*! Constructs a new WheelBrowserScreen instance with the given \a parent and widget \a flags. */ WheelBrowserScreen::WheelBrowserScreen(QWidget *parent, Qt::WFlags flags) : QAbstractBrowserScreen(parent, flags), m_fillAlpha(0), m_hiding(false), m_wheel(0), m_fillTimeline(0) { QPalette pal = palette(); pal.setColor(QPalette::Window, QColor(100, 100, 100, 0)); setPalette(pal); QVBoxLayout * layout = new QVBoxLayout(this); setLayout(layout); m_wheel = new QPixmapWheel(this); QFont f = font(); f.setBold(true); m_wheel->setFont(f); m_wheel->setMaximumVisibleIcons(7); QObject::connect(m_wheel, SIGNAL(moveToCompleted()), this, SLOT(moveToCompleted())); QObject::connect(m_wheel, SIGNAL(itemSelected(QString)), this, SLOT(clicked(QString))); setFocusProxy(m_wheel); layout->addStretch(1); layout->addWidget(m_wheel, 5); layout->addStretch(1); m_data = new QPixmapWheelData; // Load apps QSettings cfg(Qtopia::defaultButtonsFile(), QSettings::IniFormat); cfg.beginGroup("Menu"); // No tr const int menur = cfg.value("Rows",3).toInt(); const int menuc = cfg.value("Columns",3).toInt(); QString menuKeyMap = cfg.value("Map","123456789").toString(); for (int i = 0; i < menur*menuc; i++) { QChar key = menuKeyMap[i]; QStringList entries = cfg.value(QString(key)).toStringList(); if(!entries.isEmpty()) { QContent *app = readLauncherMenuItem(entries.first()); if(app) { QString file = app->fileName(); QString name = app->name(); if(app->type().startsWith("Folder/") ) file = app->type(); QPixmap pix = app->icon().pixmap(QSize(48, 48)); if(file.isEmpty()) file = app->type(); if(!file.isEmpty() && !name.isEmpty() && !pix.isNull()) { m_data->appendItem(file, pix, name); } delete app; } } } m_fillTimeline = new QTimeLine(2000, this); QObject::connect(m_fillTimeline, SIGNAL(valueChanged(qreal)), this, SLOT(timelineStep(qreal))); }
/*! Recalculate the slider's geometry and layout based on the current rect and fonts. \param update_geometry notify the layout system and call update to redraw the scale */ void QwtSlider::layoutSlider( bool update_geometry ) { int sliderWidth = d_data->thumbWidth; int sld1 = d_data->thumbLength / 2 - 1; int sld2 = d_data->thumbLength / 2 + d_data->thumbLength % 2; if ( d_data->bgStyle & BgTrough ) { sliderWidth += 2 * d_data->borderWidth; sld1 += d_data->borderWidth; sld2 += d_data->borderWidth; } int scd = 0; if ( d_data->scalePos != NoScale ) { int d1, d2; scaleDraw()->getBorderDistHint(font(), d1, d2); scd = qwtMax(d1, d2); } int slo = scd - sld1; if ( slo < 0 ) slo = 0; int x, y, length; const QRect r = rect(); if (orientation() == Qt::Horizontal) { switch (d_data->scalePos) { case TopScale: { d_data->sliderRect.setRect( r.x() + d_data->xMargin + slo, r.y() + r.height() - d_data->yMargin - sliderWidth, r.width() - 2 * d_data->xMargin - 2 * slo, sliderWidth); x = d_data->sliderRect.x() + sld1; y = d_data->sliderRect.y() - d_data->scaleDist; break; } case BottomScale: { d_data->sliderRect.setRect( r.x() + d_data->xMargin + slo, r.y() + d_data->yMargin, r.width() - 2 * d_data->xMargin - 2 * slo, sliderWidth); x = d_data->sliderRect.x() + sld1; y = d_data->sliderRect.y() + d_data->sliderRect.height() + d_data->scaleDist; break; } case NoScale: // like Bottom, but no scale. See QwtSlider(). default: // inconsistent orientation and scale position { d_data->sliderRect.setRect( r.x() + d_data->xMargin + slo, r.y() + d_data->yMargin, r.width() - 2 * d_data->xMargin - 2 * slo, sliderWidth); x = d_data->sliderRect.x() + sld1; y = 0; break; } } length = d_data->sliderRect.width() - (sld1 + sld2); } else // if (orientation() == Qt::Vertical { switch (d_data->scalePos) { case RightScale: d_data->sliderRect.setRect( r.x() + d_data->xMargin, r.y() + d_data->yMargin + slo, sliderWidth, r.height() - 2 * d_data->yMargin - 2 * slo); x = d_data->sliderRect.x() + d_data->sliderRect.width() + d_data->scaleDist; y = d_data->sliderRect.y() + sld1; break; case LeftScale: d_data->sliderRect.setRect( r.x() + r.width() - sliderWidth - d_data->xMargin, r.y() + d_data->yMargin + slo, sliderWidth, r.height() - 2 * d_data->yMargin - 2 * slo); x = d_data->sliderRect.x() - d_data->scaleDist; y = d_data->sliderRect.y() + sld1; break; case NoScale: // like Left, but no scale. See QwtSlider(). default: // inconsistent orientation and scale position d_data->sliderRect.setRect( r.x() + r.width() - sliderWidth - d_data->xMargin, r.y() + d_data->yMargin + slo, sliderWidth, r.height() - 2 * d_data->yMargin - 2 * slo); x = 0; y = d_data->sliderRect.y() + sld1; break; } length = d_data->sliderRect.height() - (sld1 + sld2); } scaleDraw()->move(x, y); scaleDraw()->setLength(length); d_data->map.setPaintXInterval(scaleDraw()->map().p1(), scaleDraw()->map().p2()); if ( update_geometry ) { d_data->sizeHintCache = QSize(); // invalidate updateGeometry(); update(); } }
osg:: Node* createTextLeft(const osg::BoundingBox& bb, const std::string& label, const std::string& subscript) { osg::Geode* geode = new osg::Geode(); osg::StateSet* stateset = geode->getOrCreateStateSet(); stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF); //std::string font("fonts/times.ttf"); std::string font("fonts/arial.ttf"); osgText::Text* text = new osgText::Text; text->setFont(font); text->setFontResolution(110,120); text->setAlignment(osgText::Text::RIGHT_CENTER); text->setAxisAlignment(osgText::Text::XZ_PLANE); text->setCharacterSize((bb.zMax()-bb.zMin())*1.0f); text->setPosition(bb.center()-osg::Vec3((bb.xMax()-bb.xMin()),-(bb.yMax()-bb.yMin())*0.5f,(bb.zMax()-bb.zMin())*0.1f)); //text->setColor(osg::Vec4(0.37f,0.48f,0.67f,1.0f)); // Neil's original OSG colour text->setColor(osg::Vec4(0.20f,0.45f,0.60f,1.0f)); // OGL logo colour text->setText(label); #if 1 text->setBackdropType(osgText::Text::OUTLINE); // text->setBackdropType(osgText::Text::DROP_SHADOW_BOTTOM_RIGHT); text->setBackdropImplementation(osgText::Text::POLYGON_OFFSET); // text->setBackdropImplementation(osgText::Text::NO_DEPTH_BUFFER); // text->setBackdropImplementation(osgText::Text::DEPTH_RANGE); // text->setBackdropImplementation(osgText::Text::STENCIL_BUFFER); text->setBackdropOffset(0.05f); text->setBackdropColor(osg::Vec4(0.0f, 0.0f, 0.5f, 1.0f)); #endif #if 1 text->setColorGradientMode(osgText::Text::OVERALL); osg::Vec4 lightblue(0.30f,0.6f,0.90f,1.0f); osg::Vec4 blue(0.10f,0.30f,0.40f,1.0f); text->setColorGradientCorners(lightblue, blue, blue, lightblue); #else text->setColorGradientMode(osgText::Text::OVERALL); osg::Vec4 light = osg::Vec4(0.0f, 1.0f, 1.0f, 1.0f); osg::Vec4 dark = osg::Vec4(0.0f, 0.0f, 0.5f, 1.0f); text->setColorGradientCorners(light, dark, dark, light); // text->setColorGradientCorners(dark, light, light, dark); #endif geode->addDrawable( text ); if (!subscript.empty()) { //osgText::Text* subscript = new osgText::Text(new osgText::TextureFont(font,45)); osgText::Text* subscriptText = new osgText::Text; subscriptText->setFont(font); subscriptText->setText(subscript); subscriptText->setAlignment(osgText::Text::RIGHT_CENTER); subscriptText->setAxisAlignment(osgText::Text::XZ_PLANE); subscriptText->setPosition(bb.center()-osg::Vec3((bb.xMax()-bb.xMin())*4.3f,-(bb.yMax()-bb.yMin())*0.5f,(bb.zMax()-bb.zMin())*0.6f)); subscriptText->setColor(osg::Vec4(0.0f,0.0f,0.0f,1.0f)); // black geode->addDrawable( subscriptText ); } return geode; }
void QgsLegendLayer::setupFont() //private method { QFont myFont = font( 0 ); myFont.setBold( true ); //visually differentiate layer labels from the rest setFont( 0, myFont ); }
QFont tGraph::dataFont() { return (_dataFont ? *_dataFont : font()); }
Edit::Edit (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style) : wxStyledTextCtrl (parent, id, pos, size, style) { m_findReplace = NULL; m_filename = wxEmptyString; m_LineNrID = 0; m_DividerID = 1; m_FoldingID = 2; // initialize language m_language = NULL; // Use all the bits in the style byte as styles, not indicators. SetStyleBits(8); #ifdef __WXOSX_COCOA__ SetZoom(4); #endif m_modified = false; SetModEventMask(wxSTC_MOD_INSERTTEXT | wxSTC_MOD_DELETETEXT); // setup unicode support SetKeysUnicode(true); SetCodePage(wxSTC_CP_UTF8); wxConvCurrent = &wxConvUTF8; // default font for all styles SetViewEOL (g_CommonPrefs.displayEOLEnable); SetIndentationGuides (g_CommonPrefs.indentGuideEnable); SetEdgeMode (g_CommonPrefs.longLineOnEnable? wxSTC_EDGE_LINE: wxSTC_EDGE_NONE); SetViewWhiteSpace (g_CommonPrefs.whiteSpaceEnable? wxSTC_WS_VISIBLEALWAYS: wxSTC_WS_INVISIBLE); SetOvertype (g_CommonPrefs.overTypeInitial); SetReadOnly (g_CommonPrefs.readOnlyInitial); SetWrapMode (g_CommonPrefs.wrapModeInitial? wxSTC_WRAP_WORD: wxSTC_WRAP_NONE); wxFont font (10, wxMODERN, wxNORMAL, wxNORMAL); StyleSetFont (wxSTC_STYLE_DEFAULT, font); StyleSetForeground (wxSTC_STYLE_DEFAULT, *wxBLACK); StyleSetBackground (wxSTC_STYLE_DEFAULT, *wxWHITE); StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (wxT("DARK GREY"))); StyleSetBackground (wxSTC_STYLE_LINENUMBER, *wxWHITE); StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColour (wxT("DARK GREY"))); InitializePrefs (DEFAULT_LANGUAGE); // set visibility SetVisiblePolicy (wxSTC_VISIBLE_STRICT|wxSTC_VISIBLE_SLOP, 1); SetXCaretPolicy (wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1); SetYCaretPolicy (wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1); // markers // ---- Enable code folding SetMarginType(MARGIN_FOLD, wxSTC_MARGIN_SYMBOL); SetMarginWidth(MARGIN_FOLD, 15); SetMarginMask(MARGIN_FOLD, wxSTC_MASK_FOLDERS); SetMarginSensitive(MARGIN_FOLD, true); // Properties found from http://www.scintilla.org/SciTEDoc.html SetProperty(wxT("fold"), wxT("1")); SetProperty(wxT("fold.comment"), wxT("1")); SetProperty(wxT("fold.compact"), wxT("1")); SetProperty(wxT("fold"), wxT("1")); SetProperty(wxT("fold.comment"), wxT("1")); SetProperty(wxT("fold.compact"), wxT("1")); SetProperty(wxT("fold.preprocessor"), wxT("1")); MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS, wxT("WHITE"), wxT("GREY")); MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS, wxT("WHITE"), wxT("GREY")); MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, wxT("WHITE"), wxT("GREY")); MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUSCONNECTED, wxT("WHITE"), wxT("GREY")); MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUSCONNECTED, wxT("WHITE"), wxT("GREY")); MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, wxT("WHITE"), wxT("GREY")); MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, wxT("WHITE"), wxT("GREY")); SetFoldFlags(wxSTC_FOLDFLAG_LINEBEFORE_CONTRACTED | wxSTC_FOLDFLAG_LINEAFTER_CONTRACTED); // miscellaneous m_LineNrMargin = TextWidth (wxSTC_STYLE_LINENUMBER, wxT("_999999")); m_FoldingMargin = 16; SetLayoutCache (wxSTC_CACHE_PAGE); }
QFont tGraph::valueFont() { return (_valueFont ? *_valueFont : font()); }
bool Edit::InitializePrefs(const wxString &name) { // initialize styles StyleClearAll(); LanguageInfo const* curInfo = NULL; // determine language bool found = false; int languageNr; for (languageNr = 0; languageNr < g_LanguagePrefsSize; languageNr++) { curInfo = &g_LanguagePrefs[languageNr]; if (curInfo->name == name) { found = true; break; } } if (!found) return false; // set lexer and language SetLexer(curInfo->lexer); m_language = curInfo; // set margin for line numbers SetMarginType(m_LineNrID, wxSTC_MARGIN_NUMBER); StyleSetForeground(wxSTC_STYLE_LINENUMBER, wxColour(wxT("DARK GREY"))); StyleSetBackground(wxSTC_STYLE_LINENUMBER, *wxWHITE); SetMarginWidth(m_LineNrID, 0); // start out not visible // annotations style StyleSetBackground(ANNOTATION_STYLE, wxColour(244, 220, 220)); StyleSetForeground(ANNOTATION_STYLE, *wxBLACK); StyleSetSizeFractional(ANNOTATION_STYLE, (StyleGetSizeFractional(wxSTC_STYLE_DEFAULT) * 4) / 5); // default fonts for all styles! int Nr; for (Nr = 0; Nr < wxSTC_STYLE_LASTPREDEFINED; Nr++) { wxFont font(10, wxMODERN, wxNORMAL, wxNORMAL); StyleSetFont(Nr, font); } // set common styles StyleSetForeground(wxSTC_STYLE_DEFAULT, wxColour(wxT("DARK GREY"))); StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColour(wxT("DARK GREY"))); // initialize settings if (g_CommonPrefs.syntaxEnable) { int keywordnr = 0; for (Nr = 0; Nr < STYLE_TYPES_COUNT; Nr++) { if (curInfo->styles[Nr].type == -1) continue; const StyleInfo &curType = g_StylePrefs[curInfo->styles[Nr].type]; wxFont font(curType.fontsize, wxMODERN, wxNORMAL, wxNORMAL, false, curType.fontname); StyleSetFont(Nr, font); if (curType.foreground) { StyleSetForeground(Nr, wxColour(curType.foreground)); } if (curType.background) { StyleSetBackground(Nr, wxColour(curType.background)); } StyleSetBold(Nr, (curType.fontstyle & mySTC_STYLE_BOLD) > 0); StyleSetItalic(Nr, (curType.fontstyle & mySTC_STYLE_ITALIC) > 0); StyleSetUnderline(Nr, (curType.fontstyle & mySTC_STYLE_UNDERL) > 0); StyleSetVisible(Nr, (curType.fontstyle & mySTC_STYLE_HIDDEN) == 0); StyleSetCase(Nr, curType.lettercase); const char *pwords = curInfo->styles[Nr].words; if (pwords) { SetKeyWords(keywordnr, pwords); keywordnr += 1; } } } // set margin as unused SetMarginType(m_DividerID, wxSTC_MARGIN_SYMBOL); SetMarginWidth(m_DividerID, 0); SetMarginSensitive(m_DividerID, false); // folding SetMarginType(m_FoldingID, wxSTC_MARGIN_SYMBOL); SetMarginMask(m_FoldingID, wxSTC_MASK_FOLDERS); StyleSetBackground(m_FoldingID, *wxWHITE); SetMarginWidth(m_FoldingID, 0); SetMarginSensitive(m_FoldingID, false); if (g_CommonPrefs.foldEnable) { SetMarginWidth(m_FoldingID, curInfo->folds != 0 ? m_FoldingMargin : 0); SetMarginSensitive(m_FoldingID, curInfo->folds != 0); SetProperty(wxT("fold"), curInfo->folds != 0 ? wxT("1") : wxT("0")); SetProperty(wxT("fold.comment"), (curInfo->folds & mySTC_FOLD_COMMENT) > 0 ? wxT("1") : wxT("0")); SetProperty(wxT("fold.compact"), (curInfo->folds & mySTC_FOLD_COMPACT) > 0 ? wxT("1") : wxT("0")); SetProperty(wxT("fold.preprocessor"), (curInfo->folds & mySTC_FOLD_PREPROC) > 0 ? wxT("1") : wxT("0")); } SetFoldFlags(wxSTC_FOLDFLAG_LINEBEFORE_CONTRACTED | wxSTC_FOLDFLAG_LINEAFTER_CONTRACTED); // set spaces and indention SetTabWidth(3); SetUseTabs(true); SetTabIndents(true); SetBackSpaceUnIndents(true); SetIndent(g_CommonPrefs.indentEnable ? 3 : 0); // others SetViewEOL(g_CommonPrefs.displayEOLEnable); SetIndentationGuides(g_CommonPrefs.indentGuideEnable); SetEdgeColumn(80); SetEdgeMode(g_CommonPrefs.longLineOnEnable ? wxSTC_EDGE_LINE : wxSTC_EDGE_NONE); SetViewWhiteSpace(g_CommonPrefs.whiteSpaceEnable ? wxSTC_WS_VISIBLEALWAYS : wxSTC_WS_INVISIBLE); SetOvertype(g_CommonPrefs.overTypeInitial); SetReadOnly(g_CommonPrefs.readOnlyInitial); SetWrapMode(g_CommonPrefs.wrapModeInitial ? wxSTC_WRAP_WORD : wxSTC_WRAP_NONE); return true; }
void ProgressBar::paintEvent( QPaintEvent* e ) { QFrame::paintEvent( e ); QPainter p( this ); StopWatch* sw = ScrobbleService::instance().stopWatch(); if ( m_track != Track() ) { QFont timeFont = font(); timeFont.setPixelSize( 10 ); setFont( timeFont ); p.setPen( QColor( 0x333333 ) ); if ( m_track.extra( "playerId" ) != "spt" ) { if ( m_track.duration() >= 30 ) { QString format( "m:ss" ); QTime duration( 0, 0 ); duration = duration.addMSecs( m_track.duration() * 1000 ); QTime progress( 0, 0 ); progress = progress.addMSecs( m_frame ); if ( duration.hour() > 0 ) format = "h:mm:ss"; QTextOption timeTextOption; timeTextOption.setAlignment( Qt::AlignVCenter | Qt::AlignLeft ); QString timeText; if ( m_track.source() == Track::LastFmRadio ) timeText = QString( "%1 / %2" ).arg( progress.toString( format ), duration.toString( format ) ); else timeText = QString( "%1" ).arg( progress.toString( format ) ); p.setPen( QColor( 0x333333 ) ); p.drawText( rect().adjusted( 6, 0, 0, 0 ), timeText, timeTextOption ); QFontMetrics fm( font() ); int indent = fm.width( timeText ) + ( 2 * 6 ) + 2; int width = this->width() - indent; p.setPen( QColor( 0xbdbdbd )); p.drawLine( QPoint( indent - 2, rect().top() ), QPoint( indent - 2, rect().bottom() - 1 ) ); p.setPen( QColor( 0xe6e6e6 ) ); p.drawLine( QPoint( indent - 1, rect().top() ), QPoint( indent - 1, rect().bottom() - 1 ) ); // draw the chunk p.setPen( Qt::transparent ); p.setBrush( m_chunk ); p.drawRect( rect().adjusted( indent, 0, ((m_frame * width) / (m_track.duration() * 1000)) - width, -1) ); //bool scrobblingOn = unicorn::UserSettings().value( "scrobblingOn", true ).toBool(); bool scrobblingOn = ScrobbleService::instance().scrobblableTrack( m_track ); if ( scrobblingOn || !scrobblingOn && m_track.scrobbleStatus() != Track::Null ) { if ( !scrobblingOn && m_track.scrobbleStatus() != Track::Null ) { QTextOption textOption; textOption.setAlignment( Qt::AlignVCenter | Qt::AlignRight ); p.drawText( rect().adjusted( 0, 0, -6, 0 ), tr( "Scrobbling off" ), textOption ); } uint scrobblePoint = sw->scrobblePoint() * 1000; int scrobbleMarker = indent + (scrobblePoint * width) / ( m_track.duration() * 1000 ); p.setPen( QPen( QColor( 0xbdbdbd ), 1, Qt::DotLine) ); p.drawLine( QPoint( scrobbleMarker - 1, rect().top() ), QPoint( scrobbleMarker - 1, rect().bottom() ) ); p.setPen( QPen( QColor( 0xe6e6e6 ), 1, Qt::DotLine) ); p.drawLine( QPoint( scrobbleMarker, rect().top() ), QPoint( scrobbleMarker, rect().bottom() ) ); // Draw the 'as'! // if the scrobble marker is too close to the left draw the 'as' on the right hand side QPoint asPoint; QImage as( m_track.scrobbleStatus() != Track::Null ? m_scrobbleMarkerOn : m_scrobbleMarkerOff ); if ( ( as.width() + 10 ) > scrobbleMarker - indent ) asPoint = QPoint ( scrobbleMarker + 5 , (rect().height() / 2) - (as.height() / 2) ); else asPoint = QPoint ( scrobbleMarker - as.width() - 5, (rect().height() / 2) - (as.height() / 2) ); p.drawImage( asPoint, as ); } else { QString offMessage = tr( "Not scrobbling" ); if ( unicorn::UserSettings().value( "scrobblingOn", true ).toBool() ) { if ( m_track.isVideo() ) offMessage = tr( "Not scrobbling - not a music video" ); else if ( !unicorn::UserSettings().value( "podcasts", true ).toBool() && m_track.isPodcast() ) offMessage = tr( "Not scrobbling - podcasts disabled" ); else if ( m_track.artist().isNull() ) offMessage = tr( "Not scrobbling - missing artist" ); } else { offMessage = tr( "Not scrobbling - scrobbling disabled" ); } p.setPen( QColor( 0x333333 ) ); QTextOption textOption; textOption.setAlignment( Qt::AlignVCenter | Qt::AlignRight ); p.drawText( rect().adjusted( 0, 0, -6, 0 ), offMessage, textOption ); } } else { QTextOption textOption; textOption.setAlignment( Qt::AlignVCenter | Qt::AlignRight ); p.drawText( rect().adjusted( 0, 0, -6, 0 ), tr( "Not scrobbling - track too short" ), textOption ); } } else { QTextOption textOption; textOption.setAlignment( Qt::AlignVCenter | Qt::AlignRight ); p.drawText( rect().adjusted( 0, 0, -6, 0 ), tr("Enable scrobbling in Spotify's preferences!"), textOption ); } } }
int QHexEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QScrollArea::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: currentAddressChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 1: currentSizeChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 2: dataChanged(); break; case 3: overwriteModeChanged((*reinterpret_cast< bool(*)>(_a[1]))); break; case 4: setAddressWidth((*reinterpret_cast< int(*)>(_a[1]))); break; case 5: setAddressArea((*reinterpret_cast< bool(*)>(_a[1]))); break; case 6: setAsciiArea((*reinterpret_cast< bool(*)>(_a[1]))); break; case 7: setHighlighting((*reinterpret_cast< bool(*)>(_a[1]))); break; default: ; } _id -= 8; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QByteArray*>(_v) = data(); break; case 1: *reinterpret_cast< int*>(_v) = addressOffset(); break; case 2: *reinterpret_cast< QColor*>(_v) = addressAreaColor(); break; case 3: *reinterpret_cast< QColor*>(_v) = highlightingColor(); break; case 4: *reinterpret_cast< QColor*>(_v) = selectionColor(); break; case 5: *reinterpret_cast< bool*>(_v) = overwriteMode(); break; case 6: *reinterpret_cast< bool*>(_v) = isReadOnly(); break; case 7: *reinterpret_cast< QFont*>(_v) = font(); break; } _id -= 8; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setData(*reinterpret_cast< QByteArray*>(_v)); break; case 1: setAddressOffset(*reinterpret_cast< int*>(_v)); break; case 2: setAddressAreaColor(*reinterpret_cast< QColor*>(_v)); break; case 3: setHighlightingColor(*reinterpret_cast< QColor*>(_v)); break; case 4: setSelectionColor(*reinterpret_cast< QColor*>(_v)); break; case 5: setOverwriteMode(*reinterpret_cast< bool*>(_v)); break; case 6: setReadOnly(*reinterpret_cast< bool*>(_v)); break; case 7: setFont(*reinterpret_cast< QFont*>(_v)); break; } _id -= 8; } else if (_c == QMetaObject::ResetProperty) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 8; } #endif // QT_NO_PROPERTIES return _id; }
int scrolText::textSize() { return font().pixelSize(); }
void FretCanvas::paintEvent(QPaintEvent* ev) { double mag = 1.5; double _spatium = 20.0 * mag; double lw1 = _spatium * 0.08; int fretOffset = diagram->fretOffset(); double lw2 = fretOffset ? lw1 : _spatium * 0.2; double stringDist = _spatium * .7; double fretDist = _spatium * .8; int _strings = diagram->strings(); int _frets = diagram->frets(); char* _dots = diagram->dots(); char* _marker = diagram->marker(); double w = (_strings - 1) * stringDist; double xo = (width() - w) * .5; double h = (_frets * fretDist) + fretDist * .5; double yo = (height() - h) * .5; QFont font("FreeSans"); int size = lrint(18.0 * mag); font.setPixelSize(size); QPainter p(this); p.setRenderHint(QPainter::Antialiasing, preferences.antialiasedDrawing); p.setRenderHint(QPainter::TextAntialiasing, true); p.translate(xo, yo); QPen pen(p.pen()); pen.setWidthF(lw2); pen.setCapStyle(Qt::FlatCap); p.setPen(pen); p.setBrush(pen.color()); double x2 = (_strings-1) * stringDist; p.drawLine(QLineF(-lw1 * .5, 0.0, x2+lw1*.5, 0.0)); pen.setWidthF(lw1); p.setPen(pen); double y2 = (_frets+1) * fretDist - fretDist*.5; for (int i = 0; i < _strings; ++i) { double x = stringDist * i; p.drawLine(QLineF(x, fretOffset ? -_spatium*.2 : 0.0, x, y2)); } for (int i = 1; i <= _frets; ++i) { double y = fretDist * i; p.drawLine(QLineF(0.0, y, x2, y)); } for (int i = 0; i < _strings; ++i) { p.setPen(Qt::NoPen); if (_dots && _dots[i]) { double dotd = stringDist * .6 + lw1; int fret = _dots[i] - 1; double x = stringDist * i - dotd * .5; double y = fretDist * fret + fretDist * .5 - dotd * .5; p.drawEllipse(QRectF(x, y, dotd, dotd)); } p.setPen(pen); if (_marker && _marker[i]) { p.setFont(font); double x = stringDist * i; double y = -fretDist * .1; p.drawText(QRectF(x, y, 0.0, 0.0), Qt::AlignHCenter | Qt::AlignBottom | Qt::TextDontClip, QChar(_marker[i])); } } if (cfret > 0 && cfret <= _frets && cstring >= 0 && cstring < _strings) { double dotd; if (_dots[cstring] != cfret) { p.setPen(Qt::NoPen); dotd = stringDist * .6 + lw1; } else { p.setPen(pen); dotd = stringDist * .6; } double x = stringDist * cstring - dotd * .5; double y = fretDist * (cfret-1) + fretDist * .5 - dotd * .5; p.setBrush(Qt::lightGray); p.drawEllipse(QRectF(x, y, dotd, dotd)); } if (fretOffset > 0) { qreal fretNumMag = 2.0; // TODO: get the value from StyleIdx::fretNumMag QFont scaledFont(font); scaledFont.setPixelSize(font.pixelSize() * fretNumMag); p.setFont(scaledFont); p.setPen(pen); // Todo: make dependant from StyleIdx::fretNumPos p.drawText(QRectF(-stringDist * .4, 0.0, 0.0, fretDist), Qt::AlignVCenter|Qt::AlignRight|Qt::TextDontClip, QString("%1").arg(fretOffset+1)); p.setFont(font); } QFrame::paintEvent(ev); }
bool scrolText::isBold() { return font().bold(); }
void QwtScaleWidget::drawTitle( QPainter *painter, QwtScaleDraw::Alignment align, const QRectF &rect ) const { QRectF r = rect; double angle; int flags = d_data->title.renderFlags() & ~( Qt::AlignTop | Qt::AlignBottom | Qt::AlignVCenter ); switch ( align ) { case QwtScaleDraw::LeftScale: angle = -90.0; flags |= Qt::AlignTop; r.setRect( r.left(), r.bottom(), r.height(), r.width() - d_data->titleOffset ); break; case QwtScaleDraw::RightScale: angle = -90.0; flags |= Qt::AlignTop; r.setRect( r.left() + d_data->titleOffset, r.bottom(), r.height(), r.width() - d_data->titleOffset ); break; case QwtScaleDraw::BottomScale: angle = 0.0; flags |= Qt::AlignBottom; r.setTop( r.top() + d_data->titleOffset ); break; case QwtScaleDraw::TopScale: default: angle = 0.0; flags |= Qt::AlignTop; r.setBottom( r.bottom() - d_data->titleOffset ); break; } if ( d_data->layoutFlags & TitleInverted ) { if ( align == QwtScaleDraw::LeftScale || align == QwtScaleDraw::RightScale ) { angle = -angle; r.setRect( r.x() + r.height(), r.y() - r.width(), r.width(), r.height() ); } } painter->save(); painter->setFont( font() ); painter->setPen( palette().color( QPalette::Text ) ); painter->translate( r.x(), r.y() ); if ( angle != 0.0 ) painter->rotate( angle ); QwtText title = d_data->title; title.setRenderFlags( flags ); title.draw( painter, QRectF( 0.0, 0.0, r.width(), r.height() ) ); painter->restore(); }
QFont bitcoinAddressFont() { QFont font("Monospace"); font.setStyleHint(QFont::TypeWriter); return font; }
int QwtScaleWidget::titleHeightForWidth( int width ) const { return qCeil( d_data->title.heightForWidth( width, font() ) ); }
STDMETHODIMP CTextOverlay::Render(LONG hdc) { PointF zero(0.0, 0.0); // Get the text we want to draw! BSTR text; IMeter *iMeter = 0; get_meter(&iMeter); if (!iMeter) { text = format.copy(); } else { _bstr_t tmp(""); BSTR tCopy = tmp.copy(); text = tCopy; iMeter->GetAsString(format, selector, &text); if (text != tCopy) ::SysFreeString(tCopy); } // Create graphics object Graphics graphics((HDC)hdc); graphics.SetInterpolationMode(InterpolationModeHighQuality); graphics.SetPixelOffsetMode(PixelOffsetModeHalf); graphics.SetSmoothingMode(SmoothingModeAntiAlias); graphics.SetTextRenderingHint(getDefaultRenderingHint(textRenderingHint)); graphics.SetCompositingMode(CompositingModeSourceOver); graphics.SetTextContrast(textContrast); // Calculate world transformation REAL el[6]; CumulativeTransform(el); Matrix matrix(el[0], el[1], el[2], el[3], el[4], el[5]); // matrix.Invert(); graphics.SetTransform(&matrix); // Create fontFamily for path-based font rendering BSTR fName; get_FontName(&fName); FontFamily fontFamily(fName); ::SysFreeString(fName); // Get some extra stuff for path-based rendering int fStyle; get_FontStyle(&fStyle); float fSize; get_FontSize(&fSize); // Set font for alternate rendering // Font font((HDC)hdc, &logFont); Font font(&fontFamily, fSize, fStyle, UnitPixel); // Set font color SolidBrush fg(color); // Set up string format StringFormat format(vertical ? StringFormatFlagsDirectionVertical : 0, LANG_NEUTRAL); if (!wrap) format.SetFormatFlags(format.GetFormatFlags() | StringFormatFlagsNoWrap); format.SetAlignment((StringAlignment)hAlign); format.SetLineAlignment((StringAlignment)vAlign); // Calculate clipping rectangle RectF clipRect(0.0, 0.0, (float)width, (float)height); if (hAlign == 1) // Center clipRect.X = (float)-width/2; else if (hAlign == 2) // Right clipRect.X = (float)-width; if (vAlign == 1) // Center clipRect.Y = (float)-height/2; else if (vAlign == 2) // Right clipRect.Y = (float)-height; // Draw blur if (radius > 0) { GraphicsPath blurPath; if (width > -1 && height > -1) { blurPath.AddString(text, -1, &fontFamily, fStyle, fSize, clipRect, &format); } else { blurPath.AddString(text, -1, &fontFamily, fStyle, fSize, zero, &format); } BYTE alpha; get_Alpha(&alpha); for (int i=radius; i>0; i--) { Color _blurColor((BYTE)(alpha/radius), (BYTE)(blurColor >> Color::BlueShift), (BYTE)(blurColor >> Color::GreenShift), (BYTE)(blurColor >> Color::RedShift)); if (blurColor == -1) { _blurColor = Color(alpha/radius, color.GetRed(), color.GetGreen(), color.GetBlue()); } Pen blurPen(_blurColor, (float)2*i); blurPen.SetEndCap(LineCapRound); blurPen.SetMiterLimit(1); graphics.DrawPath(&blurPen, &blurPath); } GraphicsState state = graphics.Save(); graphics.SetClip(&blurPath); Color trans(0, 0, 0, 0); SolidBrush brush(trans); graphics.FillPath(&brush, &blurPath); graphics.Restore(state); }
QFont tGraph::titleFont() { return (_titleFont ? *_titleFont : font()); }
void SMRadioButton::setFont(bool wantBold) { QFont f(font()); f.setBold(wantBold); QRadioButton::setFont(f); }
void FixedWidthTableView::setSecondColumnLongestContent(const QString& content) { Q_ASSERT((model ()->columnCount() == 2) || (model ()->columnCount() == 3)); QFontMetrics fm(font()); col1Width = fm.width(content); }