void Tab::paintEvent(QPaintEvent *event) { Q_UNUSED(event) QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); QBrush brush; brush.setStyle(Qt::SolidPattern); brush.setColor(backgroundColor()); painter.setOpacity(1); painter.setBrush(brush); painter.setPen(Qt::NoPen); painter.drawRect(rect()); paintHalo(&painter); QStylePainter style(this); if (!icon().isNull()) { style.translate(0, 12); } QStyleOptionButton option; initStyleOption(&option); option.features |= QStyleOptionButton::Flat; option.iconSize = QSize(-1, -1); // Prevent icon from being drawn twice style.drawControl(QStyle::CE_PushButtonLabel, option); if (!icon().isNull()) { const QSize &size = iconSize(); QRect iconRect(QPoint((width()-size.width())/2, 0), size); icon().paint(&painter, iconRect, Qt::AlignCenter, QIcon::Normal); } if (!_active) { QColor overlayColor = backgroundColor(); overlayColor.setAlphaF(0.36); QBrush overlay; overlay.setStyle(Qt::SolidPattern); overlay.setColor(overlayColor); painter.fillRect(rect(), overlay); } #ifdef DEBUG_LAYOUT QPainter debug(this); QPen pen; pen.setColor(Qt::red); pen.setWidth(2); debug.setPen(pen); debug.setBrush(Qt::NoBrush); debug.drawRect(rect()); #endif }
void MainWindow::saveSettings(){ if(fullScreen()) this->showNormal(); QSettings settingsNative; settingsNative.setValue("pos", pos()); settingsNative.setValue("size", size()); settingsNative.setValue("backgroundRed", backgroundColor().red()); settingsNative.setValue("backgroundGreen", backgroundColor().green()); settingsNative.setValue("backgroundBlue", backgroundColor().blue()); settingsNative.setValue("canvasRed", canvasColor().red()); settingsNative.setValue("canvasGreen", canvasColor().green()); settingsNative.setValue("canvasBlue", canvasColor().blue()); settingsNative.setValue("infoRed", infoColor().red()); settingsNative.setValue("infoGreen", infoColor().green()); settingsNative.setValue("infoBlue", infoColor().blue()); QSettings settings(Constants::SETTINGS_FOLDER + "/" + Constants::PLAYER_SETTINGS_FILE, QSettings::IniFormat); settings.setValue("orientation", orientation()); settings.setValue("alwaysOnTop", alwaysOnTop()); settings.setValue("autoScale", autoScale()); settings.setValue("width", width()); settings.setValue("height", height()); settings.setValue("fps", fps()); settings.setValue("scale", scale()); settings.setValue("drawInfos", drawInfos()); if(fullScreen()) this->showFullScreen(); }
PostCounter::PostCounter(QWidget *parent,const char *name) : QPushButton(parent,name) { post_running=false; post_time_format="hh:mm:ss"; post_time=QTime(); post_offset=0; post_offset_valid=false; // // Generate Fonts // post_small_font=QFont("Helvetica",12,QFont::Normal); post_small_font.setPixelSize(12); post_large_font=QFont("Helvetica",26,QFont::Normal); post_large_font.setPixelSize(26); // // Generate Palettes // post_idle_palette=palette(); post_early_palette= QPalette(QColor(POSTPOINT_EARLY_COLOR),backgroundColor()); post_ontime_palette= QPalette(QColor(POSTPOINT_ONTIME_COLOR),backgroundColor()); post_late_palette= QPalette(QColor(POSTPOINT_LATE_COLOR),backgroundColor()); post_offset = 0; UpdateDisplay(); }
void ColorPicker::associate() { PopupButton::associate(); ref<Popup> popup = this->popup(); popup->setLayout(makeref<GroupLayout>()); mColorWheel = makewidget<ColorWheel>(popup); mPickButton = makewidget<Button>(popup, "Pick"); mPickButton->setFixedSize(Vector2i(100, 25)); PopupButton::setChangeCallback([&](bool) { setColor(backgroundColor()); mCallback(backgroundColor()); }); mColorWheel->setCallback([&](const Color &value) { mPickButton->setBackgroundColor(value); mPickButton->setTextColor(value.contrastingColor()); mCallback(value); }); mPickButton->setCallback([&]() { Color value = mColorWheel->color(); setPushed(false); setColor(value); mCallback(value); }); }
// Reimplemented void QmvItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ) { QListView *listview = listView(); QColorGroup g( cg ); g.setColor( QColorGroup::Base, backgroundColor() ); g.setColor( QColorGroup::Foreground, Qt::black ); g.setColor( QColorGroup::Text, Qt::black ); int indent = 0; if ( column == 0 ) { indent = 20 + (shuttletupleattribute ? 20 : 0 ); p->fillRect( 0, 0, width, height(), backgroundColor() ); p->save(); p->translate( indent, 0 ); } if ( isChanged() && column == 0 ) { p->save(); QFont f = p->font(); f.setBold( TRUE ); p->setFont( f ); } if ( !hasCustomContents() || column != 1 ) { QListViewItem::paintCell( p, g, column, width - indent, alignment ); } else { p->fillRect( 0, 0, width, height(), backgroundColor() ); drawCustomContents( p, QRect( 0, 0, width, height() ) ); } if ( isChanged() && column == 0 ) p->restore(); if ( column == 0 ) p->restore(); // Draw +/- open/close control icon on tuple items if ( !shuttletupleattribute && column == 0 ) { p->save(); p->setPen( cg.foreground() ); p->setBrush( cg.base() ); p->drawRect( 5, height() / 2 - 4, 9, 9 ); p->drawLine( 7, height() / 2, 11, height() / 2 ); if ( !isOpen() ) p->drawLine( 9, height() / 2 - 2, 9, height() / 2 + 2 ); p->restore(); } p->save(); p->setPen( QPen( cg.dark(), 1 ) ); p->drawLine( 0, height() - 1, width, height() - 1 ); p->drawLine( width - 1, 0, width - 1, height() ); p->restore(); if ( listview->currentItem() == this && column == 0 && !listview->hasFocus() && !listview->viewport()->hasFocus() ) paintFocus( p, cg, QRect( 0, 0, width, height() ) ); }
void RDButtonDialog::clearCartData() { edit_cart=0; edit_color=backgroundColor(); edit_color_button->setPalette(QPalette(edit_color,backgroundColor())); edit_label_edit->setText(""); edit_cart_edit->setText(""); }
void RDPushButton::setFlashColor(QColor color) { int h=0; int s=0; int v=0; flash_color=color; flash_palette=QPalette(QColor(flash_color),backgroundColor()); color.getHsv(&h,&s,&v); if((h>180)&&(h<300)) { v=255; } else { if(v<168) { v=255; } else { v=0; } } s=0; color.setHsv(h,s,v); flash_palette.setColor(QPalette::Active,QColorGroup::ButtonText,color); flash_palette.setColor(QPalette::Inactive,QColorGroup::ButtonText,color); }
void WallClock::tickClock() { static QString date; QString accum; QColor system_button_text_color = palette().active().buttonText(); static QPixmap *pix=new QPixmap(sizeHint().width(),sizeHint().height()); static bool synced=true; if(check_sync) { if(RDTimeSynced()!=synced) { synced=RDTimeSynced(); } } current_time=QTime::currentTime().addMSecs(time_offset); current_date=QDate::currentDate(); if((current_time.second()==previous_time.second()) && (previous_time_mode == time_mode)) { return; } previous_time_mode = time_mode; previous_time=current_time; // // Clock Display // if(time_mode==RDAirPlayConf::TwelveHour) { accum=current_time.toString("h:mm:ss ap"); } else { accum=current_time.toString("hh:mm:ss"); } if(time_string==accum) { return; } time_string=accum; if(synced) { flash_state=false; } else { flash_state=!flash_state; } if(previous_date!=current_date) { previous_date=current_date; date=current_date.toString("dddd, MMMM d, yyyy"); } QPainter p(pix); if(flash_state) { p.fillRect(0,0,width(),height(),BUTTON_TIME_SYNC_LOST_COLOR); p.setPen(QColor(color1)); } else { p.fillRect(0,0,width(),height(),backgroundColor()); p.setPen(QColor(system_button_text_color)); } p.setFont(label_font); p.drawText((sizeHint().width()-p.fontMetrics().width(date))/2,22,date); p.setFont(time_font); p.drawText((sizeHint().width()-p.fontMetrics().width(accum))/2,48,accum); p.end(); setPixmap(*pix); }
void VCWidget::chooseBackgroundColor() { QColor color; color = QColorDialog::getColor(backgroundColor()); if (color.isValid()) setBackgroundColor(color); }
// Reimplemented void QmvItem::paintBranches( QPainter * p, const QColorGroup & cg, int w, int y, int h, GUIStyle s ) { QColorGroup g( cg ); g.setColor( QColorGroup::Base, backgroundColor() ); QListViewItem::paintBranches( p, g, w, y, h, s ); }
void KstViewLabel::paintSelf(KstPainter& p, const QRegion& bounds) { p.save(); if (p.type() == KstPainter::P_PRINT || p.type() == KstPainter::P_EXPORT) { int absFontSizeOld = _absFontSize; QRect cr(contentsRectForPainter(p)); cr.setSize(sizeForText(_parent->geometry())); setContentsRectForPainter(p, cr); KstBorderedViewObject::paintSelf(p, bounds); p.translate(cr.left(), cr.top()); if (!_transparent) { p.fillRect(0, 0, cr.width(), cr.height(), backgroundColor()); } drawToPainter(_parsed, p); _absFontSize = absFontSizeOld; } else { if (p.makingMask()) { p.setCompositionMode(QPainter::CompositionMode_Source); } else { const QRegion clip(clipRegion()); KstBorderedViewObject::paintSelf(p, bounds - _myClipMask); p.setClipRegion(bounds & clip); } _backBuffer.paintInto(p, contentsRect()); } p.restore(); }
void ArrayButton::clear() { button_length=-1; button_label=""; setColor(backgroundColor()); SetKeycap(); }
void SimpleText::drawFrame(QPainter* painter) const { if (!textStyle().hasFrame()) return; QColor color(frameColor()); if (!visible()) color = Qt::gray; else if (selected()) color = Qt::blue; if (frameWidth().val() != 0.0) { QPen pen(color, frameWidth().val() * spatium()); painter->setPen(pen); } else painter->setPen(Qt::NoPen); QColor bg(backgroundColor()); painter->setBrush(bg.alpha() ? QBrush(bg) : Qt::NoBrush); if (circle()) painter->drawArc(frame, 0, 5760); else { int r2 = frameRound() * lrint((frame.width() / frame.height())); if (r2 > 99) r2 = 99; painter->drawRoundRect(frame, frameRound(), r2); } }
void KColorButton::drawButtonLabel(QPainter *painter) { int x, y, w, h; QRect r = style().subRect(QStyle::SR_PushButtonContents, this); r.rect(&x, &y, &w, &h); int margin = style().pixelMetric(QStyle::PM_ButtonMargin, this); x += margin; y += margin; w -= 2 * margin; h -= 2 * margin; if(isOn() || isDown()) { x += style().pixelMetric(QStyle::PM_ButtonShiftHorizontal, this); y += style().pixelMetric(QStyle::PM_ButtonShiftVertical, this); } QColor fillCol = isEnabled() ? col : backgroundColor(); qDrawShadePanel(painter, x, y, w, h, colorGroup(), true, 1, NULL); if(fillCol.isValid()) painter->fillRect(x + 1, y + 1, w - 2, h - 2, fillCol); if(hasFocus()) { QRect focusRect = style().subRect(QStyle::SR_PushButtonFocusRect, this); style().drawPrimitive(QStyle::PE_FocusRect, painter, focusRect, colorGroup()); } }
void ToolSettings::selectTool(tools::Type tool) { tools::ToolSettings *ts = getToolSettingsPage(tool); if(!ts) { qWarning("selectTool: invalid tool %d", tool); return; } _currenttool = ts; // Deselect annotation on tool change if(tool != tools::ANNOTATION) { int a = _textsettings->selected(); if(a) _textsettings->setSelection(0); } setWindowTitle(_currenttool->getTitle()); _widgets->setCurrentWidget(_currenttool->getUi()); _currenttool->setForeground(foregroundColor()); _currenttool->setBackground(backgroundColor()); _currenttool->restoreToolSettings(_toolprops[currentToolSlot()].tool(_currenttool->getName())); _toolprops[_currentQuickslot].setCurrentTool(tool); updateToolSlot(currentToolSlot(), true); emit toolChanged(tool); emit sizeChanged(_currenttool->getSize()); updateSubpixelMode(); }
bool KstViewLabel::fillConfigWidget(QWidget *w, bool isNew) const { ViewLabelWidget *widget = dynamic_cast<ViewLabelWidget*>(w); if (!widget) { return false; } if (!isNew) { widget->_text->setText(text()); } widget->_precision->setValue(int(dataPrecision())); widget->_rotation->setValue(double(rotation())); widget->_fontSize->setValue(int(fontSize())); widget->_horizontal->setCurrentItem(horizJustifyWrap()); widget->_fontColor->setColor(foregroundColor()); widget->_font->setCurrentFont(fontName()); widget->_transparent->setChecked(transparent()); widget->_border->setValue(borderWidth()); widget->_boxColors->setForeground(borderColor()); widget->_boxColors->setBackground(backgroundColor()); widget->_margin->setValue(labelMargin()); widget->_text->setFocus(); return true; }
void HierarchyItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) { QColorGroup g( cg ); g.setColor( QColorGroup::Base, backgroundColor() ); g.setColor( QColorGroup::Foreground, Qt::black ); g.setColor( QColorGroup::Text, Qt::black ); QString txt = text( 0 ); if ( rtti() == Slot && ( txt == "init()" || txt == "destroy()" ) ) { listView()->setUpdatesEnabled( false ); if ( txt == "init()" ) setText( 0, txt + " " + i18n( "(Constructor)" ) ); else setText( 0, txt + " " + i18n( "(Destructor)" ) ); QListViewItem::paintCell( p, g, column, width, align ); setText( 0, txt ); listView()->setUpdatesEnabled( true ); } else { QListViewItem::paintCell( p, g, column, width, align ); } p->save(); p->setPen( QPen( cg.dark(), 1 ) ); if ( column == 0 ) p->drawLine( 0, 0, 0, height() - 1 ); if ( listView()->firstChild() != this ) { if ( nextSibling() != itemBelow() && itemBelow()->depth() < depth() ) { int d = depth() - itemBelow()->depth(); p->drawLine( -listView()->treeStepSize() * d, height() - 1, 0, height() - 1 ); } } p->drawLine( 0, height() - 1, width, height() - 1 ); p->drawLine( width - 1, 0, width - 1, height() ); p->restore(); }
void KstViewLabel::paintSelf(KstPainter& p, const QRegion& bounds) { p.save(); if (p.type() == KstPainter::P_PRINT || p.type() == KstPainter::P_EXPORT) { int absFontSizeOld = _absFontSize; QRect cr(contentsRectForPainter(p)); cr.setSize(sizeForText(_parent->geometry())); setContentsRectForPainter(p, cr); KstBorderedViewObject::paintSelf(p, bounds); p.translate(cr.left(), cr.top()); if (!_transparent) { p.fillRect(0, 0, cr.width(), cr.height(), backgroundColor()); } drawToPainter(_parsed, p); _absFontSize = absFontSizeOld; } else { if (p.makingMask()) { KstBorderedViewObject::paintSelf(p, bounds); p.setRasterOp(Qt::SetROP); const QRect cr(contentsRect()); // slow but preserves antialiasing... QBitmap bm = _backBuffer.buffer().createHeuristicMask(false); bm.setMask(bm); p.drawPixmap(cr.left(), cr.top(), bm, 0, 0, cr.width(), cr.height()); } else { const QRegion clip(clipRegion()); KstBorderedViewObject::paintSelf(p, bounds); p.setClipRegion(bounds & clip); _backBuffer.paintInto(p, contentsRect()); } } p.restore(); }
RDMarkerWidget::RDMarkerWidget(const QString &caption,const QColor &color, unsigned samprate,QWidget *parent) : QWidget(parent) { mark_delete_mode=false; mark_value=0; mark_sample_rate=samprate; mark_lo_limit=-1; mark_hi_limit=-1; mark_lo_marker=NULL; mark_hi_marker=NULL; QFont button_font=QFont("Hevetica",12,QFont::Bold); button_font.setPixelSize(12); QFont label_font=QFont("Hevetica",12,QFont::Normal); label_font.setPixelSize(12); mark_edit=new RDMarkerEdit(this); mark_edit->setGeometry(68,11,95,21); mark_edit->setReadOnly(true); mark_edit->setDragEnabled(false); mark_edit->setFont(label_font); connect(mark_edit,SIGNAL(returnPressed()),this,SLOT(returnPressedData())); connect(mark_edit,SIGNAL(escapePressed()),this,SLOT(escapePressedData())); mark_button=new RDMarkerButton(this); mark_button->setToggleButton(true); mark_button->setGeometry(0,0,66,45); mark_button->setFlashColor(backgroundColor()); mark_button->setFlashPeriod(RDMARKERWIDGET_BUTTON_FLASH_PERIOD); mark_button->setPalette(QPalette(color,parent->backgroundColor())); mark_button->setFont(button_font); mark_button->setText(caption); connect(mark_button,SIGNAL(clicked()),this,SLOT(buttonClickedData())); }
void OnDraw(HDC hdc) { Gdiplus::Graphics graphics(hdc); RECT rect; GetClientRect(g_hWnd, &rect); Gdiplus::Color backgroundColor(OriginalBackgroundColor); if (!g_useOriginalColor) { backgroundColor = OtherBackgroundColor; } Gdiplus::SolidBrush backgroundBrush(backgroundColor); graphics.FillRectangle(&backgroundBrush, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); const TCHAR* message = _T("Click the buttons with your eyes! Look at a button and use the Direct Click key -- ") _T("typically the Applications key, the one next to the right Ctrl key, with a picture of a menu on it."); Gdiplus::Font font(_T("Arial"), 10); Gdiplus::SolidBrush textBrush(Gdiplus::Color::Black); Gdiplus::RectF textRect((Gdiplus::REAL)10, (Gdiplus::REAL)(ButtonTop + ButtonHeight + 20), (Gdiplus::REAL)(rect.right - 20), (Gdiplus::REAL)(rect.bottom - rect.top)); Gdiplus::StringFormat textFormat; graphics.DrawString(message, _tcslen(message), &font, textRect, &textFormat, &textBrush); }
void SourceDirTreeNode::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) { QColorGroup myCg(cg); if (!m_sourceDir->found()) { myCg.setColor(QColorGroup::Text, cg.mid()); } switch (column) { case SourceDirTree::COLUMN_TEXT: { KListViewItem::paintCell(p, myCg, column, width, alignment); break; } case SourceDirTree::COLUMN_SELECTED: { QFont oldFont = p->font(); if (m_selectedFilesCount > 0) { QFont font = QFont(oldFont); font.setBold(true); p->setFont(font); } KListViewItem::paintCell(p, myCg, column, width, alignment); p->setFont(oldFont); break; } case SourceDirTree::COLUMN_INCLUDED: { TreeHelper::drawCheckBox(p, cg, backgroundColor(SourceDirTree::COLUMN_INCLUDED), width, this->height(), true, m_sourceDir->include() ? TreeHelper::CHECKED : TreeHelper::NOT_CHECKED); break; } } }
HourSelector::HourSelector(QWidget *parent,const char *name) : QWidget(parent,name) { // // Fonts // QFont font("helvetica",16,QFont::Bold); font.setPixelSize(16); // // Palettes // hour_active_palette= QPalette(QColor(BUTTON_STOPPED_BACKGROUND_COLOR),backgroundColor()); // // Buttons // QSignalMapper *mapper=new QSignalMapper(this); connect(mapper,SIGNAL(mapped(int)),this,SLOT(hourClicked(int))); for(unsigned i=0;i<24;i++) { hour_button[i]=new QPushButton(this); hour_button[i]->setFont(font); hour_button[i]->setDisabled(true); mapper->setMapping(hour_button[i],i); connect(hour_button[i],SIGNAL(clicked()),mapper,SLOT(map())); } // // Update Timer // hour_update_timer=new QTimer(this); connect(hour_update_timer,SIGNAL(timeout()),this,SLOT(updateTimeData())); updateTimeData(); }
bool ThemePainterDefault::paintMenuList(const LayoutObject& o, const PaintInfo& i, const IntRect& rect) { if (!o.isBox()) return false; WebThemeEngine::ExtraParams extraParams; const LayoutBox& box = toLayoutBox(o); // Match Chromium Win behaviour of showing all borders if any are shown. extraParams.menuList.hasBorder = box.borderRight() || box.borderLeft() || box.borderTop() || box.borderBottom(); extraParams.menuList.hasBorderRadius = o.styleRef().hasBorderRadius(); // Fallback to transparent if the specified color object is invalid. Color backgroundColor(Color::transparent); if (o.styleRef().hasBackground()) backgroundColor = o.resolveColor(CSSPropertyBackgroundColor); extraParams.menuList.backgroundColor = backgroundColor.rgb(); // If we have a background image, don't fill the content area to expose the // parent's background. Also, we shouldn't fill the content area if the // alpha of the color is 0. The API of Windows GDI ignores the alpha. // FIXME: the normal Aura theme doesn't care about this, so we should // investigate if we really need fillContentArea. extraParams.menuList.fillContentArea = !o.styleRef().hasBackgroundImage() && backgroundColor.alpha(); setupMenuListArrow(box, rect, extraParams); WebCanvas* canvas = i.context.canvas(); Platform::current()->themeEngine()->paint( canvas, WebThemeEngine::PartMenuList, getWebThemeState(o), WebRect(rect), &extraParams); return false; }
void StatusBarMessageLabel::paintEvent(QPaintEvent* /* event */) { QPixmap buffer(size()); QPainter painter(&buffer); // draw background QColor backgroundColor(colorGroup().background()); QColor foregroundColor(KGlobalSettings::textColor()); if (m_illumination > 0) { backgroundColor = mixColors(backgroundColor, QColor(255, 255, 64), m_illumination); foregroundColor = mixColors(foregroundColor, QColor(0, 0, 0), m_illumination); } painter.setBrush(backgroundColor); painter.setPen(backgroundColor); painter.drawRect(QRect(0, 0, width(), height())); // draw pixmap int x = pixmapGap(); int y = (height() - m_pixmap.height()) / 2; if (!m_pixmap.isNull()) { painter.drawPixmap(x, y, m_pixmap); x += m_pixmap.width() + pixmapGap(); } // draw text painter.setPen(foregroundColor); painter.drawText(QRect(x, 0, width() - x, height()), Qt::AlignVCenter | Qt::WordBreak, m_text); painter.end(); bitBlt(this, 0, 0, &buffer); }
void OverlayAnimator::setActiveAppearance( bool active ) { QColor color = mEditor->palette().color(QPalette::Base); if(color.lightness() >= 128) color = color.darker(60); else color = color.lighter(50); if (active) color.setAlpha(0); else color.setAlpha(mEditor->inactiveFadeAlpha()); mBackgroundAnimation.stop(); if (mEditor->isVisible()) { mBackgroundAnimation.setDuration(500); mBackgroundAnimation.setEasingCurve( QEasingCurve::OutCubic ); mBackgroundAnimation.setStartValue( backgroundColor() ); mBackgroundAnimation.setEndValue( color ); mBackgroundAnimation.start(); } else { setBackgroundColor(color); } }
void QColorButton::drawButtonLabel( QPainter *painter ) { #if COMPAT_QT_VERSION < 0x030000 QRect r = style().pushButtonContentsRect(this); #else QRect r = style().subRect( QStyle::SR_PushButtonContents, this ); #endif int l = r.x(); int t = r.y(); int w = r.width(); int h = r.height(); int b = 5; QColor lnCol = colorGroup().text(); QColor fillCol = isEnabled() ? col : backgroundColor(); if ( isDown() ) { qDrawPlainRect( painter, l+b+1, t+b+1, w-b*2, h-b*2, lnCol, 1, 0 ); b++; if ( fillCol.isValid() ) painter->fillRect( l+b+1, t+b+1, w-b*2, h-b*2, fillCol ); } else { qDrawPlainRect( painter, l+b, t+b, w-b*2, h-b*2, lnCol, 1, 0 ); b++; if ( fillCol.isValid() ) painter->fillRect( l+b, t+b, w-b*2, h-b*2, fillCol ); } }
void OnDraw(HDC hdc) { Gdiplus::Graphics graphics(hdc); RECT rect; GetClientRect(g_hWnd, &rect); Gdiplus::Color backgroundColor(OriginalBackgroundColor); if (!g_useOriginalColor) { backgroundColor = OtherBackgroundColor; } Gdiplus::SolidBrush backgroundBrush(backgroundColor); graphics.FillRectangle(&backgroundBrush, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); const TCHAR* message = _T("Click the buttons with your eyes! Look at a button and press the space bar to click. ") _T("(Make sure the window has input focus.)"); Gdiplus::Font font(_T("Arial"), 10); Gdiplus::SolidBrush textBrush(Gdiplus::Color::Black); Gdiplus::RectF textRect((Gdiplus::REAL)10, (Gdiplus::REAL)(ButtonTop + ButtonHeight + 20), (Gdiplus::REAL)(rect.right - 20), (Gdiplus::REAL)(rect.bottom - rect.top)); Gdiplus::StringFormat textFormat; graphics.DrawString(message, (INT)_tcslen(message), &font, textRect, &textFormat, &textBrush); }
void InputTreeView::paintEvent(QPaintEvent *event) { QPainter painter(this); //Selected or not selected if(selected()) { painter.fillRect( this->rect(), QBrush( selectedColor() )); painter.setPen(QPen( QBrush( QColor(160,0,0) ), 2, Qt::SolidLine)); } else { painter.fillRect( this->rect(), QBrush( backgroundColor() )); painter.setPen(QPen(Qt::black,1, Qt::SolidLine)); } if(isVisible()) { QPolygon points(4); int w = width() / 2; points[0] = QPoint(1,2); points[1] = QPoint(w,2); points[2] = QPoint(w,height()-2); points[3] = QPoint(1,height()-2); painter.drawPolyline(points); QWidget::paintEvent(event); } }
void timerEvent(QTimerEvent*) { QPainter p(this); QPen pn=p.pen(); pn.setWidth(2); pn.setColor(backgroundColor()); p.setPen(pn); step = (step + 1) % nqix; p.drawLine(ox[0][step], oy[0][step], ox[1][step], oy[1][step]); inc(x0, dx0, width()); inc(y0, dy0, height()); inc(x1, dx1, width()); inc(y1, dy1, height()); ox[0][step] = x0; oy[0][step] = y0; ox[1][step] = x1; oy[1][step] = y1; QColor c; c.setHsv( (step*255)/nqix, 255, 255 ); // rainbow effect pn.setColor(c); p.setPen(pn); p.drawLine(ox[0][step], oy[0][step], ox[1][step], oy[1][step]); p.setPen(colorGroup().text()); p.drawText(rect(), AlignCenter, label); }
void LinearGauge::saveSettings( QSettings& pSettings ) { // Range pSettings.setValue("orientation", orientation()); pSettings.setValue("scalePosition", scalePosition()); pSettings.setValue("minValue", minValue()); pSettings.setValue("maxValue", maxValue()); // Ticks pSettings.setValue("scaleMaxMajor", scaleMaxMajor()); pSettings.setValue("scaleMaxMinor", scaleMaxMinor()); pSettings.setValue("labels", scaleDraw()->hasComponent( QwtAbstractScaleDraw::Labels )); pSettings.setValue("font", font().family()); pSettings.setValue("fontSize", font().pointSize()); // Pipe pSettings.setValue("value", value()); pSettings.setValue("pipeWidth", pipeWidth()); pSettings.setValue("pipeColor", fillBrush().color().rgb()); // Alarm pSettings.setValue("alarmEnabled", alarmEnabled()); pSettings.setValue("alarmLevel", alarmLevel()); pSettings.setValue("alarmBrush", alarmBrush().color().rgb()); // Color pSettings.setValue("textColor", textColor().rgb()); pSettings.setValue("backgroundColor", backgroundColor().rgb()); AbstractGauge::saveSettings( pSettings ); }