CannonField::CannonField( QWidget *parent, const char *name ) : QWidget( parent, name ) { ang = 45; setPalette( QPalette( QColor( 250, 250, 200) ) ); }
QColor Loader::getLineColor(quint32 line) { QSettings settings(settingsFileName(), QSettings::IniFormat); QString colorName = settings.value(QString("line_colors/%1").arg(line), QString("gray")).toString(); return QColor(colorName); }
void KeyWidget::paintEvent(QPaintEvent*){ const QColor bgColor(68, 64, 64); const QColor keyColor(112, 110, 110); const QColor highlightColor(136, 176, 240); const QColor highlightAnimColor(136, 200, 240); const QColor animColor(112, 200, 110); // Determine which keys to highlight QBitArray highlight; switch(mouseDownMode){ case SET: highlight = newSelection; break; case ADD: highlight = selection | newSelection; break; case SUBTRACT: highlight = selection & ~newSelection; break; case TOGGLE: highlight = selection ^ newSelection; break; default: highlight = selection; } QPainter painter(this); #if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0) int ratio = painter.device()->devicePixelRatio(); #else int ratio = 1; #endif float xScale = (float)width() / (keyMap.width() + KEY_SIZE) * ratio; float yScale = (float)height() / (keyMap.height() + KEY_SIZE) * ratio; // Draw background painter.setPen(Qt::NoPen); painter.setRenderHint(QPainter::Antialiasing, true); painter.setBrush(QBrush(bgColor)); painter.drawRect(0, 0, width(), height()); // Draw mouse highlight (if any) if(mouseDownMode != NONE && (mouseDownX != mouseCurrentX || mouseDownY != mouseCurrentY)){ int x1 = (mouseDownX > mouseCurrentX) ? mouseCurrentX : mouseDownX; int x2 = (mouseDownX > mouseCurrentX) ? mouseDownX : mouseCurrentX; int y1 = (mouseDownY > mouseCurrentY) ? mouseCurrentY : mouseDownY; int y2 = (mouseDownY > mouseCurrentY) ? mouseDownY : mouseCurrentY; painter.setPen(QPen(highlightColor, 0.5)); QColor bColor = highlightColor; bColor.setAlpha(128); painter.setBrush(QBrush(bColor)); painter.drawRect(x1, y1, x2 - x1, y2 - y1); } // Draw key backgrounds on a separate pixmap so that a drop shadow can be applied to them. int wWidth = width(), wHeight = height(); KeyMap::Model model = keyMap.model(); QPixmap keyBG(wWidth * ratio, wHeight * ratio); keyBG.fill(QColor(0, 0, 0, 0)); QPainter bgPainter(&keyBG); bgPainter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); bgPainter.setPen(Qt::NoPen); QHashIterator<QString, Key> k(keyMap); uint i = -1; while(k.hasNext()){ k.next(); i++; const Key& key = k.value(); float x = key.x + 6.f - key.width / 2.f + 1.f; float y = key.y + 6.f - key.height / 2.f + 1.f; float w = key.width - 2.f; float h = key.height - 2.f; // In RGB mode, ignore keys without LEDs if(_rgbMode && !key.hasLed) continue; // Set color based on key highlight if(highlight.testBit(i)){ if(animation.testBit(i)) bgPainter.setBrush(QBrush(highlightAnimColor)); else bgPainter.setBrush(QBrush(highlightColor)); } else if(animation.testBit(i)) bgPainter.setBrush(QBrush(animColor)); else bgPainter.setBrush(QBrush(keyColor)); if(!strcmp(key.name, "mr") || !strcmp(key.name, "m1") || !strcmp(key.name, "m2") || !strcmp(key.name, "m3") || !strcmp(key.name, "light") || !strcmp(key.name, "lock") || (model == KeyMap::K65 && !strcmp(key.name, "mute"))){ // Switch keys are circular x += w / 8.f; y += h / 8.f; w *= 0.75f; h *= 0.75f; bgPainter.drawEllipse(QRectF(x * xScale, y * yScale, w * xScale, h * yScale)); } else { if(!strcmp(key.name, "enter")){ if(key.height == 24){ // ISO enter key isn't rectangular y = key.y + 1.f; h = 10.f; bgPainter.drawRect(QRectF((x + w - 13.f) * xScale, y * yScale, 13.f * xScale, 22.f * yScale)); } else { // US enter key isn't perfectly centered, needs an extra pixel on the left to appear correctly x -= 1.f; w += 1.f; } } else if(!strcmp(key.name, "rshift") || !strcmp(key.name, "stop")){ // A few other keys also need extra pixels x -= 1.f; w += 1.f; } else if(!strcmp(key.name, "caps") || !strcmp(key.name, "lshift") || !strcmp(key.name, "next")){ w += 1.f; } bgPainter.drawRect(QRectF(x * xScale, y * yScale, w * xScale, h * yScale)); } } // Render the key decorations (RGB -> light circles, binding -> key names) on yet another layer QPixmap decoration(wWidth * ratio, wHeight * ratio); decoration.fill(QColor(0, 0, 0, 0)); QPainter decPainter(&decoration); decPainter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); if(_rgbMode){ // Draw key colors (RGB mode) decPainter.setPen(QPen(QColor(255, 255, 255), 1.5)); QHashIterator<QString, Key> k(keyMap); uint i = -1; while(k.hasNext()){ k.next(); i++; const Key& key = k.value(); if(!key.hasLed) continue; float x = key.x + 6.f - 1.8f; float y = key.y + 6.f - 1.8f; float w = 3.6f; float h = 3.6f; if(_displayColorMap.contains(key.name)) decPainter.setBrush(QBrush(_displayColorMap.value(key.name))); else decPainter.setBrush(QBrush(_colorMap.value(key.name))); decPainter.drawEllipse(QRectF(x * xScale, y * yScale, w * xScale, h * yScale)); } } else { // Draw key names decPainter.setBrush(Qt::NoBrush); QFont font = painter.font(); font.setBold(true); font.setPixelSize(5.25f * yScale); QFont font0 = font; QHashIterator<QString, Key> k(keyMap); uint i = -1; while(k.hasNext()){ k.next(); i++; const Key& key = k.value(); float x = key.x + 6.f - key.width / 2.f + 1.f; float y = key.y + 6.f - key.height / 2.f; float w = key.width - 2.f; float h = key.height; // Print the key's friendly name (with some exceptions) QString keyName = KbBind::globalRemap(key.name); QString name = key.friendlyName(false); name = name.split(" ").last(); struct { const char* keyName, *displayName; } names[] = { {"light", "☼"}, {"lock", "☒"}, {"mute", "◖⊘"}, {"volup", keyMap.model() == KeyMap::K65 ? "◖))" : "▲"}, {"voldn", keyMap.model() == KeyMap::K65 ? "◖)" : "▼"}, {"prtscn", "PrtScn\nSysRq"}, {"scroll", "Scroll\nLock"}, {"pause", "Pause\nBreak"}, {"stop", "▪"}, {"prev", "|◂◂"}, {"play", "▸||"}, {"next", "▸▸|"}, {"pgup", "Page\nUp"}, {"pgdn", "Page\nDown"}, {"numlock", "Num\nLock"}, {"caps", "Caps"}, {"lshift", "Shift"}, {"rshift", "Shift"}, #ifdef Q_OS_MACX {"lctrl", "⌃"}, {"rctrl", "⌃"}, {"lwin", "⌘"}, {"rwin", "⌘"}, {"lalt", "⌥"}, {"ralt", "⌥"}, #else {"lctrl", "Ctrl"}, {"rctrl", "Ctrl"}, {"lwin", "❖"}, {"rwin", "❖"}, {"lalt", "Alt"}, {"ralt", "Alt"}, #endif {"rmenu", "▤"}, {"up", "▲"}, {"left", "◀"}, {"down", "▼"}, {"right", "▶"}, {"mousel", ""}, {"mouser", ""}, {"mousem", "-"}, {"dpiup", "▲"}, {"dpidn", "▼"}, {"dpi", "◉"}, {"mouses1", "▲"}, {"mouses2", "▼"}, {"sniper", "☀"} }; for(uint k = 0; k < sizeof(names) / sizeof(names[0]); k++){ if(keyName == names[k].keyName){ name = names[k].displayName; break; } } if(keyName == "mr" || keyName == "m1" || keyName == "m2" || keyName == "m3" || keyName == "up" || keyName == "down" || keyName == "left" || keyName == "right") // Use a smaller size for MR, M1 - M3, and arrow keys font.setPixelSize(font.pixelSize() * 0.75); else if(keyName == "end") // Use a smaller size for "End" to match everything else in that area font.setPixelSize(font.pixelSize() * 0.65); else if(keyName == "light" #ifndef Q_OS_MACX || keyName == "lwin" || keyName == "rwin" #endif ) // Use a larger font size for Super (Linux only) and Brightness to compensate for the unicode symbols looking smaller font.setPixelSize(font.pixelSize() * 1.3); // Determine the appropriate size to draw the text at decPainter.setFont(font); QRectF rect(x * xScale, y * yScale - 1, w * xScale, h * yScale); int flags = Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextWordWrap; QRectF bounds = decPainter.boundingRect(rect, flags, name); while((bounds.height() >= rect.height() - 8. || bounds.width() >= rect.width() - 2.) && font.pixelSize() >= 5){ // Scale font size down until it fits inside the key font.setPixelSize(font.pixelSize() - 2); decPainter.setFont(font); bounds = decPainter.boundingRect(rect, flags, name); } // Pick color based on key function QString bind = _bindMap.value(key.name); QString def = KbBind::defaultAction(key.name); if(bind.isEmpty()) // Unbound - red decPainter.setPen(QColor(255, 136, 136)); else if(KbBind::isProgram(bind)) // Custom program - orange decPainter.setPen(QColor(255, 224, 192)); else if(KbBind::isSpecial(bind) && (bind == def || !KbBind::isSpecial(def))) // Special function - blue (only if not mapped to a different function - if a special function is remapped, color it yellow) decPainter.setPen(QColor(128, 224, 255)); else if(KbBind::isMedia(bind) && (bind == def || !KbBind::isMedia(def))) // Media key - green decPainter.setPen(QColor(160, 255, 168)); else if(bind == def) // Standard key - white decPainter.setPen(QColor(255, 255, 255)); else // Remapped key - yellow decPainter.setPen(QColor(255, 248, 128)); decPainter.drawText(rect, flags, name); font = font0; } } // Create drop shadow effects QGraphicsDropShadowEffect* bgEffect = new QGraphicsDropShadowEffect; // Have to use "new", creating these on the stack causes a crash... bgEffect->setBlurRadius(2.); bgEffect->setColor(QColor(0, 0, 0, 32)); bgEffect->setOffset(0, 1); QGraphicsDropShadowEffect* decEffect = new QGraphicsDropShadowEffect; decEffect->setBlurRadius(4.); decEffect->setColor(QColor(0, 0, 0, 104)); decEffect->setOffset(0, 1); // Apply them to the pixmaps QGraphicsPixmapItem* bgItem = new QGraphicsPixmapItem(keyBG); bgItem->setGraphicsEffect(bgEffect); QGraphicsPixmapItem* decItem = new QGraphicsPixmapItem(decoration); decItem->setGraphicsEffect(decEffect); // Render everything QGraphicsScene* scene = new QGraphicsScene; scene->addItem(bgItem); scene->addItem(decItem); // It has to be rendered onto yet another pixmap or else DPI scaling will look terrible... QPixmap final(wWidth * ratio, wHeight * ratio); final.fill(QColor(0, 0, 0, 0));
void EraserTool::drawStroke() { StrokeTool::drawStroke(); QList<QPointF> p = m_pStrokeManager->interpolateStroke(); Layer* layer = mEditor->layers()->currentLayer(); if ( layer->type() == Layer::BITMAP ) { for ( int i = 0; i < p.size(); i++ ) { p[ i ] = mEditor->view()->mapScreenToCanvas( p[ i ] ); } qreal opacity = 1.0; mCurrentWidth = properties.width; qreal brushWidth = (mCurrentWidth + (mCurrentPressure * mCurrentWidth)) * 0.5; qreal brushStep = (0.5 * brushWidth) - ((properties.feather/100.0) * brushWidth * 0.5); brushStep = qMax( 1.0, brushStep ); BlitRect rect; QPointF a = lastBrushPoint; QPointF b = getCurrentPoint(); qreal distance = 4 * QLineF( b, a ).length(); int steps = qRound( distance ) / brushStep; for ( int i = 0; i < steps; i++ ) { QPointF point = lastBrushPoint + ( i + 1 ) * ( brushStep )* ( b - lastBrushPoint ) / distance; rect.extend( point.toPoint() ); mScribbleArea->drawBrush( point, brushWidth, properties.feather, QColor(255, 255, 255, 255), opacity ); if ( i == ( steps - 1 ) ) { lastBrushPoint = point; } } int rad = qRound( brushWidth ) / 2 + 2; mScribbleArea->refreshBitmap( rect, rad ); } else if ( layer->type() == Layer::VECTOR ) { QPen pen( Qt::white, mCurrentWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ); int rad = qRound( ( mCurrentWidth / 2 + 2 ) * mEditor->view()->scaling() ); if ( p.size() == 4 ) { QSizeF size( 2, 2 ); QPainterPath path( p[ 0 ] ); path.cubicTo( p[ 1 ], p[ 2 ], p[ 3 ] ); mScribbleArea->drawPath( path, pen, Qt::NoBrush, QPainter::CompositionMode_Source ); mScribbleArea->refreshVector( path.boundingRect().toRect(), rad ); } } }
const Glyph& TextRenderer::getGlyph(char c) { Glyph& glyph = _glyphs[c]; if (glyph.isValid()) { return glyph; } // we use 'J' as a representative size for the solid block character QChar ch = (c == SOLID_BLOCK_CHAR) ? QChar('J') : QChar(c); QRect bounds = _metrics.boundingRect(ch); if (bounds.isEmpty()) { glyph = Glyph(0, QPoint(), QRect(), _metrics.width(ch)); return glyph; } // grow the bounds to account for effect, if any if (_effectType == SHADOW_EFFECT) { bounds.adjust(-_effectThickness, 0, 0, _effectThickness); } else if (_effectType == OUTLINE_EFFECT) { bounds.adjust(-_effectThickness, -_effectThickness, _effectThickness, _effectThickness); } // grow the bounds to account for antialiasing bounds.adjust(-1, -1, 1, 1); if (_x + bounds.width() > IMAGE_SIZE) { // we can't fit it on the current row; move to next _y += _rowHeight; _x = _rowHeight = 0; } if (_y + bounds.height() > IMAGE_SIZE) { // can't fit it on current texture; make a new one glGenTextures(1, &_currentTextureID); _x = _y = _rowHeight = 0; glBindTexture(GL_TEXTURE_2D, _currentTextureID); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, IMAGE_SIZE, IMAGE_SIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); _allTextureIDs.append(_currentTextureID); } else { glBindTexture(GL_TEXTURE_2D, _currentTextureID); } // render the glyph into an image and copy it into the texture QImage image(bounds.width(), bounds.height(), QImage::Format_ARGB32); if (c == SOLID_BLOCK_CHAR) { image.fill(QColor(255, 255, 255)); } else { image.fill(0); QPainter painter(&image); painter.setFont(_font); if (_effectType == SHADOW_EFFECT) { for (int i = 0; i < _effectThickness; i++) { painter.drawText(-bounds.x() - 1 - i, -bounds.y() + 1 + i, ch); } } else if (_effectType == OUTLINE_EFFECT) { QPainterPath path; QFont font = _font; font.setStyleStrategy(QFont::ForceOutline); path.addText(-bounds.x() - 0.5, -bounds.y() + 0.5, font, ch); QPen pen; pen.setWidth(_effectThickness); pen.setJoinStyle(Qt::RoundJoin); pen.setCapStyle(Qt::RoundCap); painter.setPen(pen); painter.setRenderHint(QPainter::Antialiasing); painter.drawPath(path); } painter.setPen(QColor(255, 255, 255)); painter.drawText(-bounds.x(), -bounds.y(), ch); } glTexSubImage2D(GL_TEXTURE_2D, 0, _x, _y, bounds.width(), bounds.height(), GL_RGBA, GL_UNSIGNED_BYTE, image.constBits()); glyph = Glyph(_currentTextureID, QPoint(_x, _y), bounds, _metrics.width(ch)); _x += bounds.width(); _rowHeight = qMax(_rowHeight, bounds.height()); glBindTexture(GL_TEXTURE_2D, 0); return glyph; }
void LLCCEP_exec::softcore::emulated_swi(LLCCEP::instruction data) { SOFTCORE_OK; auto getFmtString = [](char c) -> ::std::string { switch (c) { case 'x': return "%x"; break; case 'b': return "%b"; break; case 'o': return "%o"; break; default: throw RUNTIME_EXCEPTION(CONSTRUCT_MSG( "Error!\n" "Invalid format!\n")); } }; auto getWindow = [this]() { size_t id = static_cast<size_t>(regs[1]); if (id >= windows.size()) { throw RUNTIME_EXCEPTION(CONSTRUCT_MSG( "Error!\n" "Overbounding while access to windows: " "no window with " size_t_pf " ID!\n", id)); } return windows[id]; }; auto checkf = [](FILE *fd, size_t function) { if (!fd) { throw RUNTIME_EXCEPTION(CONSTRUCT_MSG( "Error!\n" "File pointer at &01 register is 0.\n" "Interrupt 0:" size_t_pf "!\n", function)); } }; auto noFunction = [this](size_t interrupt) { throw RUNTIME_EXCEPTION(CONSTRUCT_MSG( "Error!\n" "No function " size_t_pf " of " size_t_pf " interrupt.\n", static_cast<size_t>(regs[1]), interrupt)); }; switch (static_cast<size_t>(get(data.args[0]))) { /************************************************** * Files stuff *************************************************/ case 0: { /************************************************** * Function selection *************************************************/ switch (static_cast<size_t>(regs[0])) { /************************************************** * Load standard file ptr to r02 * * r01 -- id of standard file * |-- 0 - stdin * |-- 1 - stdout * |-- 2 - stderr *************************************************/ case 0: { FILE *stdf[] = { stdin, stdout, stderr }; if (static_cast<size_t>(regs[1]) > 2) { throw RUNTIME_EXCEPTION(CONSTRUCT_MSG( "Error!\n" "In interrupt 0,0:\n" "not admitted id of standard file.\n" "Only values between 0 and 2 are allowed!\n")); } regs[2] = *reinterpret_cast<double *>(&(stdf[static_cast<size_t>(regs[1])])); break; } /************************************************** * Output to file. * * r01 -- pointer to file. * r02 -- output format. * r03 -- output value. * * Output formats: * - n -- number * - c -- character * - s -- string * - x -- hexadecimal number * - b -- binary number * - o -- octal number * * Output values by formats: * - n -- number * - c -- ASCII character id * - s -- string pointer * - x -- number * - b -- number * - o -- octal number *************************************************/ case 1: { FILE *out = *reinterpret_cast<FILE **>(®s[1]); char fmt = static_cast<char>(regs[2]); checkf(out, 1); switch (fmt) { case 'n': { ::std::fprintf(out, "%lg", regs[3]); break; } case 'c': { ::std::fprintf(out, "%c", static_cast<uint8_t>(regs[3])); break; } case 's': { ::std::fprintf(out, "%s", mm->getString(static_cast<size_t>(regs[3])).c_str()); break; } case 'x': case 'o': { ::std::fprintf(out, getFmtString(static_cast<char>(regs[2])).c_str(), *reinterpret_cast<size_t *>(®s[3])); break; } default: throw RUNTIME_EXCEPTION(CONSTRUCT_MSG( "Error!\n" "Forbidden format for 0,1 interrupt.")) } break; } /************************************************** * Input from file * * r01 -- pointer to file * r02 -- input format * r03 -- input place *************************************************/ case 2: { FILE *in = reinterpret_cast<FILE *>(*reinterpret_cast<void **>(®s[1])); checkf(in, 2); switch (static_cast<char>(regs[2])) { case 'n': { ::std::fscanf(in, "%lg", ®s[3]); break; } case 'c': { char tmp = 0; ::std::fscanf(in, "%c", &tmp); regs[3] = tmp; break; } case 's': { ::std::string str; char tmp = 0; bool beg = true; do { if (beg) beg = false; else str += tmp; tmp = fgetc(in); } while (tmp && !isspace(tmp)); mm->writeString(static_cast<size_t>(regs[3]), str); break; } case 'x': case 'o': { int64_t res; ::std::fscanf(in, getFmtString(static_cast<char>(regs[2])).c_str(), &res); break; } default: { throw RUNTIME_EXCEPTION(CONSTRUCT_MSG( "Error!\n" "Forbidden format for 0,2 interrupt.")) } } } /************************************************** * Open file. * * r01 will be pointer to opened file. * * r02 -- pointer to path's string * r03 -- pointer to format's string * * In case of fail, an exception will be thrown. *************************************************/ case 3: { ::std::string path = mm->getString(static_cast<size_t>(regs[2])); ::std::string fmt = mm->getString(static_cast<size_t>(regs[3])); FILE *res = fopen(path.c_str(), fmt.c_str()); if (!res) { throw RUNTIME_EXCEPTION(CONSTRUCT_MSG( "Error!\n" "Can't open '%s' file with '%s' mode: %s!\n", path.c_str(), fmt.c_str(), ::std::strerror(errno))); } regs[1] = *reinterpret_cast<double *>(&res); break; } /************************************************* * Close file. * * r01 -- pointer to file being closed. ************************************************/ case 4: { FILE *fd = reinterpret_cast<FILE *>(*reinterpret_cast<void **>(®s[1])); checkf(fd, 4); fclose(fd); break; } default: { noFunction(0); } } break; } /************************************************** * Windows stuff *************************************************/ case 1: { /************************************************** * Function selection *************************************************/ switch (static_cast<size_t>(regs[0])) { /************************************************** * Create window * * r01 -- width of new window * r02 -- height of new window * r03 -- pointer to window title string * r04 -- window flags * * r05 will be window's id. *************************************************/ case 0: { LLCCEP_exec::window *wnd = new (::std::nothrow) LLCCEP_exec::window; if (!wnd) { throw RUNTIME_EXCEPTION(CONSTRUCT_MSG( "Error!\n" "Can't allocate memory for window: %s", ::std::strerror(errno))); } int width = static_cast<int>(regs[1]), height = static_cast<int>(regs[2]); wnd->resize(width, height); wnd->show(); wnd->setWindowTitle(QApplication::translate( "emulator", mm->getString(static_cast<size_t>(regs[3])).c_str())); wnd->begin(width, height); wnd->setAntialiased(true); regs[4] = windows.size(); windows.push_back(wnd); break; } case 1: { LLCCEP_exec::window *wnd = getWindow(); wnd->painter().drawPoint(static_cast<int>(regs[2]), static_cast<size_t>(regs[3])); break; } case 2: { LLCCEP_exec::window *wnd = getWindow(); wnd->painter().setPen(QColor(static_cast<QRgb>(regs[2]))); break; } case 3: { LLCCEP_exec::window *wnd = getWindow(); wnd->close(); delete wnd; windows.erase(windows.begin() + static_cast<size_t>(regs[1])); break; } case 4: { LLCCEP_exec::window *wnd = getWindow(); regs[3] = wnd->getKeyboardButtonState((static_cast<size_t>(regs[2]) > 0xFF)? (0): (static_cast<size_t>(regs[2]))); regs[4] = wnd->getMousePos().x(); regs[5] = wnd->getMousePos().y(); regs[6] = wnd->getMouseButtons(); break; } case 5: { LLCCEP_exec::window *wnd = getWindow(); regs[2] = wnd->pos().x(); regs[3] = wnd->pos().y(); regs[4] = wnd->size().width(); regs[5] = wnd->size().height(); break; } case 6: { LLCCEP_exec::window *wnd = getWindow(); wnd->resize(static_cast<int>(regs[2]), static_cast<int>(regs[3])); break; } case 7: { LLCCEP_exec::window *wnd = getWindow(); wnd->move(static_cast<int>(regs[2]), static_cast<int>(regs[3])); break; } case 8: { LLCCEP_exec::window *wnd = getWindow(); wnd->setWindowTitle(mm->getString(static_cast<size_t>(regs[2])).c_str()); break; } case 9: { LLCCEP_exec::window *wnd = getWindow(); wnd->setWindowFlags(Qt::WindowFlags(static_cast<int>(regs[2]))); break; } default: { noFunction(1); } } break; } default: { throw RUNTIME_EXCEPTION(CONSTRUCT_MSG( "Error!\n" "No swi #" size_t_pf, static_cast<size_t>(get(data.args[0])))); } } SOFTCORE_OK; }
QVariant MProductos::data(const QModelIndex& item, int role) const { if( !item.isValid() ) { qDebug( QString( "Indice invalido Productos: col=%1, row=%2, role=%3").arg( item.column() ).arg( item.row() ).arg( role ).toLocal8Bit() ); return( QVariant() ); } switch( role ) { case Qt::DisplayRole: { switch( item.column() ) { case 4: case 5: { return QString( "$ %1" ).arg( QString::number( QSqlRelationalTableModel::data(item, role).toDouble(), 'f', 3 ) ); break; } case 9: { if( QSqlRelationalTableModel::data( item, role ).toBool() ) { return "Si"; } else { return "No"; } break; } case 7: { return QString::number( QSqlRelationalTableModel::data( item, role ).toDouble(), 'f', 2 ); break; } default: { return QSqlRelationalTableModel::data( item, role ); break; } } break; } case Qt::TextColorRole: { switch ( item.column() ) { case 5: case 4: { return QColor(Qt::blue); break; } default: { return QColor(Qt::black); break; } } break; } case Qt::EditRole: { switch( item.column() ) { case 5: case 4: { return QSqlRelationalTableModel::data( item, role ).toDouble(); break; } default: { return QSqlRelationalTableModel::data( item, role ); break; } } break; } case Qt::TextAlignmentRole: { switch( item.column() ) { case 5: case 4: case 6: case 7: case 8: { return int( Qt::AlignHCenter | Qt::AlignVCenter ); break; } default: { return int( Qt::AlignLeft | Qt::AlignVCenter ); break; } } break; } case Qt::ToolTipRole: case Qt::StatusTipRole: { return QVariant( "Haga doble click o seleccione y F2 para editar" ); break; } default: { return QSqlRelationalTableModel::data( item, role ); break; } } }
void QScriptEdit::extraAreaPaintEvent(QPaintEvent *e) { QRect rect = e->rect(); QPalette pal = palette(); pal.setCurrentColorGroup(QPalette::Active); QPainter painter(m_extraArea); painter.fillRect(rect, Qt::lightGray); const QFontMetrics fm(fontMetrics()); int markWidth = fm.lineSpacing(); int extraAreaWidth = m_extraArea->width(); QLinearGradient gradient(QPointF(extraAreaWidth - 10, 0), QPointF(extraAreaWidth, 0)); gradient.setColorAt(0, pal.color(QPalette::Background)); gradient.setColorAt(1, pal.color(QPalette::Base)); painter.fillRect(rect, gradient); QLinearGradient gradient2(QPointF(0, 0), QPointF(markWidth, 0)); gradient2.setColorAt(0, pal.color(QPalette::Dark)); gradient2.setColorAt(1, pal.color(QPalette::Background)); painter.fillRect(rect.intersected(QRect(rect.x(), rect.y(), markWidth, rect.height())), gradient2); painter.setPen(QPen(pal.color(QPalette::Background), 2)); if (isLeftToRight()) painter.drawLine(rect.x() + extraAreaWidth-1, rect.top(), rect.x() + extraAreaWidth-1, rect.bottom()); else painter.drawLine(rect.x(), rect.top(), rect.x(), rect.bottom()); painter.setRenderHint(QPainter::Antialiasing); #ifndef QT_NO_SYNTAXHIGHLIGHTER QTextBlock block = firstVisibleBlock(); int blockNumber = block.blockNumber(); qreal top = blockBoundingGeometry(block).translated(contentOffset()).top(); qreal bottom = top + blockBoundingRect(block).height(); QString imagesPath = QString::fromLatin1(":/qt/scripttools/debugging/images"); QString imageExt; // SVGs don't work on all platforms, even when QT_NO_SVG is not defined, so disable SVG usage for now. // #ifndef QT_NO_SVG #if 0 imageExt = QString::fromLatin1("svg"); #else imageExt = QString::fromLatin1("png"); #endif while (block.isValid() && top <= rect.bottom()) { if (block.isVisible() && bottom >= rect.top()) { int lineNumber = blockNumber + m_baseLineNumber; if (m_breakpoints.contains(lineNumber)) { int radius = fm.lineSpacing() - 1; QRect r(rect.x(), (int)top, radius, radius); QIcon icon(m_breakpoints[lineNumber].enabled ? QString::fromLatin1("%0/breakpoint.%1").arg(imagesPath).arg(imageExt) : QString::fromLatin1("%0/d_breakpoint.%1").arg(imagesPath).arg(imageExt)); icon.paint(&painter, r, Qt::AlignCenter); } if (m_executionLineNumber == lineNumber) { int radius = fm.lineSpacing() - 1; QRect r(rect.x(), (int)top, radius, radius); QIcon icon(QString::fromLatin1("%0/location.%1").arg(imagesPath).arg(imageExt)); icon.paint(&painter, r, Qt::AlignCenter); } if (!isExecutableLine(lineNumber)) painter.setPen(pal.color(QPalette::Mid)); else painter.setPen(QColor(Qt::darkCyan)); QString number = QString::number(lineNumber); painter.drawText(rect.x() + markWidth, (int)top, rect.x() + extraAreaWidth - markWidth - 4, fm.height(), Qt::AlignRight, number); } block = block.next(); top = bottom; bottom = top + blockBoundingRect(block).height(); ++blockNumber; } #endif }
SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) : QWidget(0, f), curAlignment(0) { // set reference point, paddings int paddingLeft = 14; int paddingTop = 470; int titleVersionVSpace = 17; int titleCopyrightVSpace = 32; float fontFactor = 1.0; // define text to place QString titleText = tr("Owncoin Core"); QString versionText = QString(tr("Version %1")).arg(QString::fromStdString(FormatFullVersion())); QString copyrightTextBtc = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin Core developers")); QString copyrightTextOwncoin = QChar(0xA9)+QString(" 2014-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Owncoin Core developers")); QString titleAddText = networkStyle->getTitleAddText(); QString font = QApplication::font().toString(); // load the bitmap for writing some text over it pixmap = networkStyle->getSplashImage(); QPainter pixPaint(&pixmap); pixPaint.setPen(QColor(100,100,100)); // check font size and drawing with pixPaint.setFont(QFont(font, 28*fontFactor)); QFontMetrics fm = pixPaint.fontMetrics(); int titleTextWidth = fm.width(titleText); if(titleTextWidth > 160) { // strange font rendering, Arial probably not found fontFactor = 0.75; } pixPaint.setFont(QFont(font, 28*fontFactor)); fm = pixPaint.fontMetrics(); titleTextWidth = fm.width(titleText); pixPaint.drawText(paddingLeft,paddingTop,titleText); pixPaint.setFont(QFont(font, 15*fontFactor)); pixPaint.drawText(paddingLeft,paddingTop+titleVersionVSpace,versionText); // draw copyright stuff pixPaint.setFont(QFont(font, 10*fontFactor)); pixPaint.drawText(paddingLeft,paddingTop+titleCopyrightVSpace,copyrightTextBtc); pixPaint.drawText(paddingLeft,paddingTop+titleCopyrightVSpace+12,copyrightTextOwncoin); // draw additional text if special network if(!titleAddText.isEmpty()) { QFont boldFont = QFont(font, 10*fontFactor); boldFont.setWeight(QFont::Bold); pixPaint.setFont(boldFont); fm = pixPaint.fontMetrics(); int titleAddTextWidth = fm.width(titleAddText); pixPaint.drawText(pixmap.width()-titleAddTextWidth-10,pixmap.height()-25,titleAddText); } pixPaint.end(); // Set window title setWindowTitle(titleText + " " + titleAddText); // Resize window and move to center of desktop, disallow resizing QRect r(QPoint(), pixmap.size()); resize(r.size()); setFixedSize(r.size()); move(QApplication::desktop()->screenGeometry().center() - r.center()); subscribeToCoreSignals(); }
void QgsSvgCache::containsElemParams( const QDomElement& elem, bool& hasFillParam, QColor& defaultFill, bool& hasOutlineParam, QColor& defaultOutline, bool& hasOutlineWidthParam, double& defaultOutlineWidth ) const { if ( elem.isNull() ) { return; } //we already have all the information, no need to go deeper if ( hasFillParam && hasOutlineParam && hasOutlineWidthParam ) { return; } //check this elements attribute QDomNamedNodeMap attributes = elem.attributes(); int nAttributes = attributes.count(); QStringList valueSplit; for ( int i = 0; i < nAttributes; ++i ) { QDomAttr attribute = attributes.item( i ).toAttr(); if ( attribute.name().compare( "style", Qt::CaseInsensitive ) == 0 ) { //entries separated by ';' QStringList entryList = attribute.value().split( ';' ); QStringList::const_iterator entryIt = entryList.constBegin(); for ( ; entryIt != entryList.constEnd(); ++entryIt ) { QStringList keyValueSplit = entryIt->split( ':' ); if ( keyValueSplit.size() < 2 ) { continue; } QString key = keyValueSplit.at( 0 ); QString value = keyValueSplit.at( 1 ); valueSplit = value.split( " " ); if ( !hasFillParam && value.startsWith( "param(fill)" ) ) { hasFillParam = true; if ( valueSplit.size() > 1 ) { defaultFill = QColor( valueSplit.at( 1 ) ); } } else if ( !hasOutlineParam && value.startsWith( "param(outline)" ) ) { hasOutlineParam = true; if ( valueSplit.size() > 1 ) { defaultOutline = QColor( valueSplit.at( 1 ) ); } } else if ( !hasOutlineWidthParam && value.startsWith( "param(outline-width)" ) ) { hasOutlineWidthParam = true; if ( valueSplit.size() > 1 ) { defaultOutlineWidth = valueSplit.at( 1 ).toDouble(); } } } } else { QString value = attribute.value(); valueSplit = value.split( " " ); if ( !hasFillParam && value.startsWith( "param(fill)" ) ) { hasFillParam = true; if ( valueSplit.size() > 1 ) { defaultFill = QColor( valueSplit.at( 1 ) ); } } else if ( !hasOutlineParam && value.startsWith( "param(outline)" ) ) { hasOutlineParam = true; if ( valueSplit.size() > 1 ) { defaultOutline = QColor( valueSplit.at( 1 ) ); } } else if ( !hasOutlineWidthParam && value.startsWith( "param(outline-width)" ) ) { hasOutlineWidthParam = true; if ( valueSplit.size() > 1 ) { defaultOutlineWidth = valueSplit.at( 1 ).toDouble(); } } } } //pass it further to child items QDomNodeList childList = elem.childNodes(); int nChildren = childList.count(); for ( int i = 0; i < nChildren; ++i ) { QDomElement childElem = childList.at( i ).toElement(); containsElemParams( childElem, hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth ); } }
void PerformanceScoring::prepareDataPlot( DataPlot *plot) { // Return now if plot empty if (mMainWindow->dataSize() == 0) return; DataPoint dpStart = mMainWindow->interpolateDataT(mStartTime); DataPoint dpEnd = mMainWindow->interpolateDataT(mEndTime); // Add shading for scoring window if (plot->yValue(DataPlot::Elevation)->visible()) { DataPoint dpLower = mMainWindow->interpolateDataT(mMainWindow->rangeLower()); DataPoint dpUpper = mMainWindow->interpolateDataT(mMainWindow->rangeUpper()); const double xMin = plot->xValue()->value(dpLower, mMainWindow->units()); const double xMax = plot->xValue()->value(dpUpper, mMainWindow->units()); QVector< double > xElev, yElev; xElev << xMin << xMax; yElev << plot->yValue(DataPlot::Elevation)->value(dpStart, mMainWindow->units()) << plot->yValue(DataPlot::Elevation)->value(dpStart, mMainWindow->units()); QCPGraph *graph = plot->addGraph( plot->axisRect()->axis(QCPAxis::atBottom), plot->yValue(DataPlot::Elevation)->axis()); graph->setData(xElev, yElev); graph->setPen(QPen(QBrush(Qt::lightGray), mMainWindow->lineThickness(), Qt::DashLine)); yElev.clear(); yElev << plot->yValue(DataPlot::Elevation)->value(dpEnd, mMainWindow->units()) << plot->yValue(DataPlot::Elevation)->value(dpEnd, mMainWindow->units()); graph = plot->addGraph( plot->axisRect()->axis(QCPAxis::atBottom), plot->yValue(DataPlot::Elevation)->axis()); graph->setData(xElev, yElev); graph->setPen(QPen(QBrush(Qt::lightGray), mMainWindow->lineThickness(), Qt::DashLine)); QCPItemRect *rect = new QCPItemRect(plot); rect->setPen(QPen(QBrush(Qt::lightGray), mMainWindow->lineThickness(), Qt::DashLine)); rect->setBrush(QColor(0, 0, 0, 8)); rect->topLeft->setType(QCPItemPosition::ptAxisRectRatio); rect->topLeft->setAxes(plot->xAxis, plot->yValue(DataPlot::Elevation)->axis()); rect->topLeft->setCoords(-0.1, -0.1); rect->bottomRight->setType(QCPItemPosition::ptAxisRectRatio); rect->bottomRight->setAxes(plot->xAxis, plot->yValue(DataPlot::Elevation)->axis()); rect->bottomRight->setCoords( (plot->xValue()->value(dpStart, mMainWindow->units()) - xMin) / (xMax - xMin), 1.1); rect = new QCPItemRect(plot); rect->setPen(QPen(QBrush(Qt::lightGray), mMainWindow->lineThickness(), Qt::DashLine)); rect->setBrush(QColor(0, 0, 0, 8)); rect->topLeft->setType(QCPItemPosition::ptAxisRectRatio); rect->topLeft->setAxes(plot->xAxis, plot->yValue(DataPlot::Elevation)->axis()); rect->topLeft->setCoords( (plot->xValue()->value(dpEnd, mMainWindow->units()) - xMin) / (xMax - xMin), -0.1); rect->bottomRight->setType(QCPItemPosition::ptAxisRectRatio); rect->bottomRight->setAxes(plot->xAxis, plot->yValue(DataPlot::Elevation)->axis()); rect->bottomRight->setCoords(1.1, 1.1); } }
void FileView::paint(QPainter* painter, const QRect& rect, const QPalette& palette, DisplayMode displayMode) const { painter->save(); painter->setRenderHint(QPainter::Antialiasing, true); painter->translate(rect.x(), rect.y()); if(displayMode == DM_Selected) painter->setBrush(palette.highlightedText()); else painter->setBrush(palette.foreground()); painter->setPen(QPen(painter->brush(), 1)); int textFlags = Qt::AlignLeft | Qt::AlignVCenter; QFont font(painter->font()); font.setBold(true); painter->setFont(font); QString nameDisplay = (mode == TM_Send) ? tr("To: ") : tr("From: "); nameDisplay.append(userName); QRect textRect = QRect(54, 0, rect.width() - 58, 18); QString text = painter->fontMetrics().elidedText(nameDisplay, Qt::ElideRight, textRect.width()); painter->drawText(textRect, textFlags, text); font.setBold(false); painter->setFont(font); textRect = QRect(54, 18, rect.width() - 58, 18); text = painter->fontMetrics().elidedText(fileDisplay, Qt::ElideMiddle, textRect.width()); painter->drawText(textRect, textFlags, text); bool drawProgress = false; QString stateDisplay; switch(state) { case TS_Send: stateDisplay = timeDisplay + " left - " + posDisplay + " of " + sizeDisplay + " (" + speedDisplay + ")"; drawProgress = true; break; case TS_Receive: stateDisplay = timeDisplay + " left - " + posDisplay + " of " + sizeDisplay + " (" + speedDisplay + ")"; drawProgress = true; break; case TS_Complete: stateDisplay = tr("Completed"); break; case TS_Cancel: stateDisplay = tr("Canceled"); break; case TS_Abort: stateDisplay = tr("Interrupted"); break; default: break; } textRect = QRect(54, 36, rect.width() - 58, 18); text = painter->fontMetrics().elidedText(stateDisplay, Qt::ElideRight, textRect.width()); painter->drawText(textRect, textFlags, text); if(drawProgress) { int spanAngle = ((double)position / (double)fileSize) * 360; painter->setBrush(QBrush(QColor(230, 230, 230))); painter->setPen(QPen(QColor(230, 230, 230))); painter->drawPie(4, 4, 46, 46, (90 - spanAngle) * 16, -(360 - spanAngle) * 16); painter->setBrush(QBrush(QColor(150, 225, 110))); painter->setPen(QPen(QColor(150, 225, 110))); painter->drawPie(4, 4, 46, 46, 90 * 16, -spanAngle * 16); painter->setBrush(QBrush(QColor(255, 255, 255))); painter->setPen(QPen(QColor(255, 255, 255), 2)); painter->drawLine(27, 5, 27, 49); painter->drawLine(5, 27, 49, 27); painter->drawLine(11, 11, 42, 42); painter->drawLine(42, 11, 11, 42); } QRect imageRect(11, 11, 32, 32); painter->drawPixmap(imageRect, icon); painter->restore(); }
PluginUniform::PluginUniform() { mColor = QColor(220,204,173); }
QSizeF QgsSymbolV2LegendNode::drawSymbol( const QgsLegendSettings& settings, ItemContext* ctx, double itemHeight ) const { QgsSymbolV2* s = mItem.symbol(); if ( !s ) { return QSizeF(); } // setup temporary render context QgsRenderContext context; context.setScaleFactor( settings.dpi() / 25.4 ); context.setRendererScale( settings.mapScale() ); context.setMapToPixel( QgsMapToPixel( 1 / ( settings.mmPerMapUnit() * context.scaleFactor() ) ) ); // hope it's ok to leave out other params context.setForceVectorOutput( true ); context.setPainter( ctx ? ctx->painter : 0 ); //Consider symbol size for point markers double height = settings.symbolSize().height(); double width = settings.symbolSize().width(); double size = 0; //Center small marker symbols double widthOffset = 0; double heightOffset = 0; if ( QgsMarkerSymbolV2* markerSymbol = dynamic_cast<QgsMarkerSymbolV2*>( s ) ) { // allow marker symbol to occupy bigger area if necessary size = markerSymbol->size() * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context, s->outputUnit(), s->mapUnitScale() ) / context.scaleFactor(); height = size; width = size; if ( width < settings.symbolSize().width() ) { widthOffset = ( settings.symbolSize().width() - width ) / 2.0; } if ( height < settings.symbolSize().height() ) { heightOffset = ( settings.symbolSize().height() - height ) / 2.0; } } if ( ctx ) { double currentXPosition = ctx->point.x(); double currentYCoord = ctx->point.y() + ( itemHeight - settings.symbolSize().height() ) / 2; QPainter* p = ctx->painter; //setup painter scaling to dots so that raster symbology is drawn to scale double dotsPerMM = context.scaleFactor(); int opacity = 255; if ( QgsVectorLayer* vectorLayer = dynamic_cast<QgsVectorLayer*>( parent()->layer() ) ) opacity = 255 - ( 255 * vectorLayer->layerTransparency() / 100 ); p->save(); p->setRenderHint( QPainter::Antialiasing ); if ( opacity != 255 && settings.useAdvancedEffects() ) { //semi transparent layer, so need to draw symbol to an image (to flatten it first) //create image which is same size as legend rect, in case symbol bleeds outside its alloted space QImage tempImage = QImage( QSize( width * dotsPerMM, height * dotsPerMM ), QImage::Format_ARGB32 ); QPainter imagePainter( &tempImage ); tempImage.fill( Qt::transparent ); imagePainter.translate( dotsPerMM * ( currentXPosition + widthOffset ), dotsPerMM * ( currentYCoord + heightOffset ) ); s->drawPreviewIcon( &imagePainter, QSize( width * dotsPerMM, height * dotsPerMM ), &context ); //reduce opacity of image imagePainter.setCompositionMode( QPainter::CompositionMode_DestinationIn ); imagePainter.fillRect( tempImage.rect(), QColor( 0, 0, 0, opacity ) ); //draw rendered symbol image p->scale( 1.0 / dotsPerMM, 1.0 / dotsPerMM ); p->drawImage( 0, 0, tempImage ); } else { p->translate( currentXPosition + widthOffset, currentYCoord + heightOffset ); p->scale( 1.0 / dotsPerMM, 1.0 / dotsPerMM ); s->drawPreviewIcon( p, QSize( width * dotsPerMM, height * dotsPerMM ), &context ); } p->restore(); } return QSizeF( qMax( width + 2 * widthOffset, settings.symbolSize().width() ), qMax( height + 2 * heightOffset, settings.symbolSize().height() ) ); }
void ArthurFrame::paintEvent(QPaintEvent *e) { #ifdef Q_WS_QWS static QPixmap *static_image = 0; #else static QImage *static_image = 0; #endif QPainter painter; if (preferImage() #ifdef QT_OPENGL_SUPPORT && !m_use_opengl #endif ) { if (!static_image || static_image->size() != size()) { delete static_image; #ifdef Q_WS_QWS static_image = new QPixmap(size()); #else static_image = new QImage(size(), QImage::Format_RGB32); #endif } painter.begin(static_image); int o = 10; QBrush bg = palette().brush(QPalette::Background); painter.fillRect(0, 0, o, o, bg); painter.fillRect(width() - o, 0, o, o, bg); painter.fillRect(0, height() - o, o, o, bg); painter.fillRect(width() - o, height() - o, o, o, bg); } else { #ifdef QT_OPENGL_SUPPORT if (m_use_opengl) { painter.begin(glw); painter.fillRect(QRectF(0, 0, glw->width(), glw->height()), palette().color(backgroundRole())); } else { painter.begin(this); } #else painter.begin(this); #endif } painter.setClipRect(e->rect()); painter.setRenderHint(QPainter::Antialiasing); QPainterPath clipPath; QRect r = rect(); qreal left = r.x() + 1; qreal top = r.y() + 1; qreal right = r.right(); qreal bottom = r.bottom(); qreal radius2 = 8 * 2; clipPath.moveTo(right - radius2, top); clipPath.arcTo(right - radius2, top, radius2, radius2, 90, -90); clipPath.arcTo(right - radius2, bottom - radius2, radius2, radius2, 0, -90); clipPath.arcTo(left, bottom - radius2, radius2, radius2, 270, -90); clipPath.arcTo(left, top, radius2, radius2, 180, -90); clipPath.closeSubpath(); painter.save(); painter.setClipPath(clipPath, Qt::IntersectClip); painter.drawTiledPixmap(rect(), m_tile); // client painting paint(&painter); painter.restore(); painter.save(); if (m_show_doc) paintDescription(&painter); painter.restore(); int level = 180; painter.setPen(QPen(QColor(level, level, level), 2)); painter.setBrush(Qt::NoBrush); painter.drawPath(clipPath); if (preferImage() #ifdef QT_OPENGL_SUPPORT && !m_use_opengl #endif ) { painter.end(); painter.begin(this); #ifdef Q_WS_QWS painter.drawPixmap(e->rect(), *static_image, e->rect()); #else painter.drawImage(e->rect(), *static_image, e->rect()); #endif } #ifdef QT_OPENGL_SUPPORT if (m_use_opengl && (inherits("PathDeformRenderer") || inherits("PathStrokeRenderer") || inherits("CompositionRenderer") || m_show_doc)) glw->swapBuffers(); #endif }
QColor PlotEntitySettingsDialog::toQColor(tgt::Color color) { return QColor(static_cast<int>(color.r * 255), static_cast<int>(color.g * 255), static_cast<int>(color.b * 255), static_cast<int>(color.a * 255)); }
void OSDWidget::showOSD(const QString &str, OSDUserData *data) { if (isScreenSaverActive()){ hide(); return; } setFont(FontEdit::str2font(data->Font.ptr, baseFont)); QPainter p(this); p.setFont(font()); unsigned nScreen = data->Screen.value; unsigned nScreens = screens(); if (nScreen >= nScreens) nScreen = 0; int SHADOW_OFFS = SHADOW_DEF; QRect rcScreen = screenGeometry(nScreen); rcScreen = QRect(0, 0, rcScreen.width() - SHADOW_OFFS - XOSD_MARGIN * 2 - data->Offset.value, rcScreen.height() - SHADOW_OFFS - XOSD_MARGIN * 2 - data->Offset.value); QRect rc = p.boundingRect(rcScreen, AlignLeft | AlignTop | WordBreak, str); if (rc.height() >= rcScreen.height() / 2){ rcScreen = QRect(0, 0, rcScreen.width() - SHADOW_OFFS - XOSD_MARGIN * 2 - data->Offset.value, rcScreen.height() - SHADOW_OFFS - XOSD_MARGIN * 2 - data->Offset.value); rc = p.boundingRect(rcScreen, AlignLeft | AlignTop | WordBreak, str); } p.end(); if (data->EnableMessageShowContent.bValue && data->ContentLines.value){ QFontMetrics fm(font()); int maxHeight = fm.height() * (data->ContentLines.value + 1); if (rc.height() > maxHeight) rc.setHeight(maxHeight); } int x = rcScreen.left(); int y = rcScreen.top(); int w = rc.width() + 1; int h = rc.height() + 1; int text_y = 0; if (data->Background.bValue){ w += XOSD_MARGIN * 2; h += XOSD_MARGIN * 2; if (m_button == NULL){ m_button = new QPushButton("", this); m_button->setPixmap(QPixmap((const char **)close_h_xpm)); connect(m_button, SIGNAL(clicked()), this, SLOT(slotCloseClick())); } QSize s = m_button->sizeHint(); m_button->resize(s.height() - 4, s.height() - 4); m_button->move(w - m_button->width() - 3, 2); text_y = m_button->height() + 4; h += text_y; m_button->show(); }else{ if (m_button){ delete m_button; m_button = NULL; } } if (data->Shadow.bValue){ w += SHADOW_OFFS; h += SHADOW_OFFS; } resize(QSize(w, h)); switch (data->Position.value){ case 1: move(x + data->Offset.value, y + data->Offset.value); break; case 2: move(x + rcScreen.width() - data->Offset.value - w, y + rcScreen.height() - data->Offset.value - h); break; case 3: move(x + rcScreen.width() - data->Offset.value - w, y + data->Offset.value); break; case 4: move(x + (rcScreen.width() - w) / 2, y + rcScreen.height() - data->Offset.value - h); break; case 5: move(x + (rcScreen.width() - w) / 2, y + data->Offset.value); break; case 6: move(x + (rcScreen.width() - w) / 2, y + (rcScreen.height() - h) /2); break; default: move(x + data->Offset.value, y + rcScreen.height() - data->Offset.value - h); } if (!data->Background.bValue || data->Shadow.bValue){ QBitmap mask(w, h); p.begin(&mask); #ifdef WIN32 QColor bg(255, 255, 255); QColor fg(0, 0, 0); #else QColor bg(0, 0, 0); QColor fg(255, 255, 255); #endif p.fillRect(0, 0, w, h, bg); if (data->Background.bValue){ p.fillRect(0, 0, w - SHADOW_OFFS, h - SHADOW_OFFS, fg); p.fillRect(SHADOW_OFFS, SHADOW_OFFS, w - SHADOW_OFFS, h - SHADOW_OFFS, fg); }else{ p.setPen(fg); p.setFont(font()); if (data->Shadow.bValue){ rc = QRect(SHADOW_OFFS, SHADOW_OFFS, w - SHADOW_OFFS, h - SHADOW_OFFS); p.drawText(rc, AlignLeft | AlignTop | WordBreak, str); rc = QRect(0, 0, w - SHADOW_OFFS, h - SHADOW_OFFS); p.drawText(rc, AlignLeft | AlignTop | WordBreak, str); }else{ rc = QRect(0, 0, w, h); p.drawText(rc, AlignLeft | AlignTop | WordBreak, str); } } p.end(); setMask(mask); } qApp->syncX(); QPixmap pict = QPixmap::grabWindow(QApplication::desktop()->winId(), this->x(), this->y(), width(), height()); intensity(pict, -0.50f); p.begin(&pict); rc = QRect(0, 0, w, h); if (data->Background.bValue){ if (data->Shadow.bValue){ w -= SHADOW_OFFS; h -= SHADOW_OFFS; rc = QRect(0, 0, w, h); } QBrush bg(data->BgColor.value); p.fillRect(rc, bg); #if COMPAT_QT_VERSION < 0x030000 style().drawPopupPanel(&p, 0, 0, w, h, colorGroup(), 2, &bg); #else style().drawPrimitive(QStyle::PE_PanelPopup, &p, rc, colorGroup()); #endif rc = QRect(XOSD_MARGIN, XOSD_MARGIN, w - XOSD_MARGIN * 2, h - XOSD_MARGIN * 2); } p.setFont(font()); p.setPen(QColor(data->Color.value)); rc.setTop(text_y); p.drawText(rc, AlignLeft | AlignTop | WordBreak, str); p.end(); bgPict = pict; QWidget::show(); raise(); }
unsubscribeFromCoreSignals(); } void SplashScreen::slotFinish(QWidget *mainWin) { Q_UNUSED(mainWin); hide(); } static void InitMessage(SplashScreen *splash, const std::string &message) { QMetaObject::invokeMethod(splash, "showMessage", Qt::QueuedConnection, Q_ARG(QString, QString::fromStdString(message)), Q_ARG(int, Qt::AlignBottom|Qt::AlignHCenter), Q_ARG(QColor, QColor(55,55,55))); } static void ShowProgress(SplashScreen *splash, const std::string &title, int nProgress) { InitMessage(splash, title + strprintf("%d", nProgress) + "%"); } #ifdef ENABLE_WALLET static void ConnectWallet(SplashScreen *splash, CWallet* wallet) { wallet->ShowProgress.connect(boost::bind(ShowProgress, splash, _1, _2)); } #endif void SplashScreen::subscribeToCoreSignals()
confMode::confMode(QWidget * parent) : QDialog(parent), settings(QSettings::IniFormat, QSettings::UserScope,"QtLog", "qtlog") { setupUi(this); n = settings.value("FontSize").toString().toInt(); QFont font; font.setPointSize(n); setFont(font); connect(pushButtonExit, SIGNAL(clicked()), this, SLOT(goExit())); connect(bandList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(bandListCb(QTreeWidgetItem*,int))); connect(modeList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(modeListCb(QTreeWidgetItem*,int))); connect(pwrList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(pwrListCb(QTreeWidgetItem*,int))); connect(lineList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(lineListCb(QTreeWidgetItem*,int))); connect(awdList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(awdListCb(QTreeWidgetItem*,int))); connect(customsList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(customsListCb(QTreeWidgetItem*,int))); connect(rigList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(rigListCb(QTreeWidgetItem*,int))); connect(ButtonHilfe, SIGNAL(clicked()), this, SLOT(getHilfeModeCb())); connect(SavePushButton, SIGNAL(clicked()), this, SLOT(SaveConfValues())); connect(NewPushButton, SIGNAL(clicked()), this, SLOT(NewAwdValues())); connect(RigSavePushButton, SIGNAL(clicked()), this, SLOT(RigSaveButton())); connect(RigClearPushButton, SIGNAL(clicked()), this, SLOT(RigClearButton())); // Band bandList->setColumnWidth(0,70); // Band bandList->setColumnWidth(1,40); // Set bandList->setColumnWidth(2,80); // myBand bandList->setColumnWidth(3,70); // Frequenz bandList->setColumnWidth(4,60); // Band>Rig // Mode modeList->setColumnWidth(0,30); // Set modeList->setColumnWidth(1,40); // Mode // PWR pwrList->setColumnWidth(0,30); // Set pwrList->setColumnWidth(1,40); // Wort pwrList->setColumnWidth(2,60); // PWR // Verbindungs_Arten lineList->setColumnWidth(0,30); // set lineList->setColumnWidth(1,80); // Mode // AWD_Typen awdList->setColumnWidth(0,40); // aset awdList->setColumnWidth(1,80); // atyp // customs_Felder customsList->setColumnWidth(0,80); // custom_db_feld customsList->setColumnWidth(1,140); // user_feld_name // Rig_List rigList->setColumnWidth(0,80); // trans rigList->setColumnWidth(1,250); // trans rigList->setColumnWidth(2,250); // ant rigList->setColumnWidth(3,200); // Linux QSqlQuery query; // Band qy = "SELECT band,work,mband,freq,brig FROM wband"; query.exec(qy); while(query.next()) { n = 0; i = 0; QTreeWidgetItem *item = new QTreeWidgetItem(bandList); item->setText(i++,query.value(n++).toString()); // band item->setText(i++,query.value(n++).toString()); // work item->setText(i++,query.value(n++).toString()); // myband item->setText(i++,query.value(n++).toString()); // freq item->setText(i++,query.value(n++).toString()); // Band -> Rig } // Mode qy = "SELECT * FROM wmode ORDER BY work DESC"; query.exec(qy); while(query.next()) { n = 0; i = 0; QTreeWidgetItem *item = new QTreeWidgetItem(modeList); item->setText(i++,query.value(n++).toString()); // work item->setText(i++,query.value(n++).toString()); // mode } // PWR qy = "SELECT * FROM wpwr"; query.exec(qy); while(query.next()) { n = 0; i = 0; QTreeWidgetItem *item = new QTreeWidgetItem(pwrList); item->setText(i++,query.value(n++).toString()); // pwr item->setText(i++,query.value(n++).toString()); // work item->setText(i++,query.value(n++).toString()); // watt } // qy = "SELECT * FROM wline "; query.exec(qy); while(query.next()) { n = 0; i = 0; QTreeWidgetItem *item = new QTreeWidgetItem(lineList); item->setText(i++,query.value(n++).toString()); // id item->setText(i++,query.value(n++).toString()); // line } // AWD qy = "SELECT aset,atype FROM wawdlist ORDER BY id"; query.exec(qy); while(query.next()) { n = 0; i = 0; QTreeWidgetItem *item = new QTreeWidgetItem(awdList); item->setText(i++,query.value(n++).toString()); // aset item->setText(i++,query.value(n++).toString()); // atype } // customs qy = "SELECT dbfield,refnam FROM refnamen WHERE dbfield LIKE 'custom%'"; query.exec(qy); while(query.next()) { n = 0; i = 0; QTreeWidgetItem *item = new QTreeWidgetItem(customsList); item->setText(i++,query.value(n++).toString()); // db_feld item->setText(i++,query.value(n++).toString()); // user_name } // Rig qy = "SELECT * FROM wrig"; query.exec(qy); while(query.next()) { n = 0; i = 0; QTreeWidgetItem *item = new QTreeWidgetItem(rigList); item->setText(i++,query.value(n++).toString()); // rigtype item->setText(i++,query.value(n++).toString()); // trans item->setText(i++,query.value(n++).toString()); // ant item->setText(i++,query.value(n++).toString()); // op item->setText(i++,query.value(n++).toString()); // spez } NewPushButton->hide(); rtreeWidget = bandList; customId1 = 0; customId2 = 0; BandSetLineEdit->setFocus(); LineNameEdit->setEnabled(FALSE); // sperren AwdSetLineEdit->setEnabled(FALSE); // sperren NameTypeLineEdit->setEnabled(FALSE); // sperren tabWidget->setCurrentIndex(settings.value("Val").toInt()); if(settings.value("Val").toInt() == 1) { QPalette palette7; QBrush brush8(QColor(237, 255, 183, 255)); // GELB/grün palette7.setBrush(QPalette::Active, QPalette::Base, brush8); awdList->setPalette(palette7); } connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentIndexchangedCb(int))); }
SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) : QWidget(0, f), curAlignment(0) { // set reference point, paddings int paddingRight = 50; int paddingTop = 50; int titleVersionVSpace = 17; int titleCopyrightVSpace = 40; float fontFactor = 1.0; float devicePixelRatio = 1.0; #if QT_VERSION > 0x050100 devicePixelRatio = ((QGuiApplication*)QCoreApplication::instance())->devicePixelRatio(); #endif // define text to place QString titleText = tr("Bitcoin8m Core"); QString versionText = QString("Version %1").arg(QString::fromStdString(FormatFullVersion())); QString copyrightText = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin8m Core developers")); QString titleAddText = networkStyle->getTitleAddText(); QString font = QApplication::font().toString(); // create a bitmap according to device pixelratio QSize splashSize(480*devicePixelRatio,320*devicePixelRatio); pixmap = QPixmap(splashSize); #if QT_VERSION > 0x050100 // change to HiDPI if it makes sense pixmap.setDevicePixelRatio(devicePixelRatio); #endif QPainter pixPaint(&pixmap); pixPaint.setPen(QColor(100,100,100)); // draw a slightly radial gradient QRadialGradient gradient(QPoint(0,0), splashSize.width()/devicePixelRatio); gradient.setColorAt(0, Qt::white); gradient.setColorAt(1, QColor(247,247,247)); QRect rGradient(QPoint(0,0), splashSize); pixPaint.fillRect(rGradient, gradient); // draw the bitcoin8m icon, expected size of PNG: 1024x1024 QRect rectIcon(QPoint(-150,-122), QSize(430,430)); const QSize requiredSize(1024,1024); QPixmap icon(networkStyle->getAppIcon().pixmap(requiredSize)); pixPaint.drawPixmap(rectIcon, icon); // check font size and drawing with pixPaint.setFont(QFont(font, 33*fontFactor)); QFontMetrics fm = pixPaint.fontMetrics(); int titleTextWidth = fm.width(titleText); if(titleTextWidth > 160) { // strange font rendering, Arial probably not found fontFactor = 0.75; } pixPaint.setFont(QFont(font, 33*fontFactor)); fm = pixPaint.fontMetrics(); titleTextWidth = fm.width(titleText); pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddingTop,titleText); pixPaint.setFont(QFont(font, 15*fontFactor)); // if the version string is to long, reduce size fm = pixPaint.fontMetrics(); int versionTextWidth = fm.width(versionText); if(versionTextWidth > titleTextWidth+paddingRight-10) { pixPaint.setFont(QFont(font, 10*fontFactor)); titleVersionVSpace -= 5; } pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText); // draw copyright stuff pixPaint.setFont(QFont(font, 10*fontFactor)); pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText); // draw additional text if special network if(!titleAddText.isEmpty()) { QFont boldFont = QFont(font, 10*fontFactor); boldFont.setWeight(QFont::Bold); pixPaint.setFont(boldFont); fm = pixPaint.fontMetrics(); int titleAddTextWidth = fm.width(titleAddText); pixPaint.drawText(pixmap.width()/devicePixelRatio-titleAddTextWidth-10,15,titleAddText); } pixPaint.end(); // Set window title setWindowTitle(titleText + " " + titleAddText); // Resize window and move to center of desktop, disallow resizing QRect r(QPoint(), QSize(pixmap.size().width()/devicePixelRatio,pixmap.size().height()/devicePixelRatio)); resize(r.size()); setFixedSize(r.size()); move(QApplication::desktop()->screenGeometry().center() - r.center()); subscribeToCoreSignals(); }
void GridVert1::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0) { QPen pen(QColor(255, 0, 0)); pen.setWidthF(0.1); painter->setPen(pen); painter->drawPath(this->path); }
void LightMaps::paintEvent(QPaintEvent *event) { QPainter p; p.begin(this); m_normalMap->render(&p, event->rect()); p.setPen(Qt::black); p.drawText(rect(), Qt::AlignBottom | Qt::TextWordWrap, "Map data CCBYSA 2009 OpenStreetMap.org contributors"); p.end(); if (zoomed) { int dim = qMin(width(), height()); int magnifierSize = qMin(MAX_MAGNIFIER, dim * 2 / 3); int radius = magnifierSize / 2; int ring = radius - 15; QSize box = QSize(magnifierSize, magnifierSize); // reupdate our mask if (maskPixmap.size() != box) { maskPixmap = QPixmap(box); maskPixmap.fill(Qt::transparent); QRadialGradient g; g.setCenter(radius, radius); g.setFocalPoint(radius, radius); g.setRadius(radius); g.setColorAt(1.0, QColor(255, 255, 255, 0)); g.setColorAt(0.5, QColor(128, 128, 128, 255)); QPainter mask(&maskPixmap); mask.setRenderHint(QPainter::Antialiasing); mask.setCompositionMode(QPainter::CompositionMode_Source); mask.setBrush(g); mask.setPen(Qt::NoPen); mask.drawRect(maskPixmap.rect()); mask.setBrush(QColor(Qt::transparent)); mask.drawEllipse(g.center(), ring, ring); mask.end(); } QPoint center = dragPos - QPoint(0, radius); center = center + QPoint(0, radius / 2); QPoint corner = center - QPoint(radius, radius); QPoint xy = center * 2 - QPoint(radius, radius); // only set the dimension to the magnified portion if (zoomPixmap.size() != box) { zoomPixmap = QPixmap(box); zoomPixmap.fill(Qt::lightGray); } if (true) { QPainter p(&zoomPixmap); p.translate(-xy); m_largeMap->render(&p, QRect(xy, box)); p.end(); } QPainterPath clipPath; clipPath.addEllipse(center, ring, ring); QPainter p(this); p.setRenderHint(QPainter::Antialiasing); p.setClipPath(clipPath); p.drawPixmap(corner, zoomPixmap); p.setClipping(false); p.drawPixmap(corner, maskPixmap); p.setPen(Qt::gray); p.drawPath(clipPath); } if (invert) { QPainter p(this); p.setCompositionMode(QPainter::CompositionMode_Difference); p.fillRect(event->rect(), Qt::white); p.end(); } }
* GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * ***************************************************************************/ #include "ColorBox.h" #include <QPixmap> #include <QPainter> #include <algorithm> const QColor ColorBox::colors[] = { QColor(Qt::black), QColor(Qt::red), QColor(Qt::green), QColor(Qt::blue), QColor(Qt::cyan), QColor(Qt::magenta), QColor(Qt::yellow), QColor(Qt::darkYellow), QColor(Qt::darkBlue), QColor(Qt::darkMagenta), QColor(Qt::darkRed), QColor(Qt::darkGreen), QColor(Qt::darkCyan), QColor("#0000A0"), QColor("#FF8000"), QColor("#8000FF"),
void GLWidget::draw() { QPainter p(this); // used for text overlay // save the GL state set for QPainter p.beginNativePainting(); saveGLState(); // render the 'bubbles.svg' file into our pbuffer QPainter pbuffer_painter(pbuffer); svg_renderer->render(&pbuffer_painter); pbuffer_painter.end(); glFlush(); if (!hasDynamicTextureUpdate) pbuffer->updateDynamicTexture(dynamicTexture); makeCurrent(); // draw into the GL widget glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1, 1, -1, 1, 10, 100); glTranslatef(0.0f, 0.0f, -15.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glViewport(0, 0, width() * devicePixelRatio(), height() * devicePixelRatio()); glBindTexture(GL_TEXTURE_2D, dynamicTexture); glEnable(GL_TEXTURE_2D); glEnable(GL_MULTISAMPLE); glEnable(GL_CULL_FACE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // draw background glPushMatrix(); glScalef(1.7f, 1.7f, 1.7f); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glCallList(tile_list); glPopMatrix(); const int w = logo.width(); const int h = logo.height(); glRotatef(rot_x, 1.0f, 0.0f, 0.0f); glRotatef(rot_y, 0.0f, 1.0f, 0.0f); glRotatef(rot_z, 0.0f, 0.0f, 1.0f); glScalef(scale/w, scale/w, scale/w); glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); // draw the Qt icon glTranslatef(-w+1, -h+1, 0.0f); for (int y=h-1; y>=0; --y) { uint *p = (uint*) logo.scanLine(y); uint *end = p + w; int x = 0; while (p < end) { glColor4ub(qRed(*p), qGreen(*p), qBlue(*p), uchar(qAlpha(*p)*.9)); glTranslatef(0.0f, 0.0f, wave[y*w+x]); if (qAlpha(*p) > 128) glCallList(tile_list); glTranslatef(0.0f, 0.0f, -wave[y*w+x]); glTranslatef(2.0f, 0.0f, 0.0f); ++x; ++p; } glTranslatef(-w*2.0f, 2.0f, 0.0f); } // restore the GL state that QPainter expects restoreGLState(); p.endNativePainting(); // draw the overlayed text using QPainter p.setPen(QColor(197, 197, 197, 157)); p.setBrush(QColor(197, 197, 197, 127)); p.drawRect(QRect(0, 0, width(), 50)); p.setPen(Qt::black); p.setBrush(Qt::NoBrush); const QString str1(tr("A simple OpenGL pbuffer example.")); const QString str2(tr("Use the mouse wheel to zoom, press buttons and move mouse to rotate, double-click to flip.")); QFontMetrics fm(p.font()); p.drawText(width()/2 - fm.width(str1)/2, 20, str1); p.drawText(width()/2 - fm.width(str2)/2, 20 + fm.lineSpacing(), str2); }
US_RunDetails2::US_RunDetails2( const QVector< US_DataIO::RawData >& data, const QString& runID, const QString& dataDir, const QStringList& cell_ch_wl ) : US_WidgetsDialog( 0, 0 ), dataList( data ), triples( cell_ch_wl ) { setWindowTitle( tr( "Details for Raw Data" ) ); setPalette( US_GuiSettings::frameColor() ); QGridLayout* main = new QGridLayout( this ); main->setSpacing ( 2 ); main->setContentsMargins( 2, 2, 2, 2 ); plotType = TEMPERATURE; temp_warn = true; int row = 0; // Plot Rows QBoxLayout* plot = new US_Plot( data_plot, tr( "Parameter Variation Throughout Run" ), tr( "Scan Number" ), tr( "RPM * 1000 / Temperature " ) + DEGC ); data_plot->setMinimumSize( 400, 200 ); data_plot->enableAxis( QwtPlot::yRight ); // Copy font for right axis from left axis QwtText axisTitle = data_plot->axisTitle( QwtPlot::yLeft ); axisTitle.setText( tr( "Time between Scans (min)" ) ); data_plot->setAxisTitle( QwtPlot::yRight, axisTitle ); QwtPlotGrid* grid = us_grid( data_plot ); grid->enableXMin( false ); main->addLayout( plot, row, 0, 5, 6 ); row += 6; // Row QLabel* lb_dir = us_label( tr( "Data Directory:" ) ); main->addWidget( lb_dir, row, 0 ); QLineEdit* le_dir = us_lineedit(); le_dir->setReadOnly( true ); le_dir->setText( dataDir ); main->addWidget( le_dir, row++, 1, 1, 5 ); // Row QLabel* lb_desc = us_label( tr( "Description:" ) ); main->addWidget( lb_desc, row, 0 ); le_desc = us_lineedit(); le_desc->setReadOnly( true ); le_desc->setText( dataDir ); main->addWidget( le_desc, row++, 1, 1, 5 ); // Row QLabel* lb_runID = us_label( tr( "Run Identification:" ) ); main->addWidget( lb_runID, row, 0 ); lw_rpm = us_listwidget(); lw_rpm->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ); lw_rpm->setMinimumSize( 100, 50 ); main->addWidget( lw_rpm, row, 2, 5, 2 ); lw_triples = us_listwidget(); lw_triples->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ); lw_triples->setMinimumSize( 100, 50 ); main->addWidget( lw_triples, row, 4, 5, 2 ); le_runID = us_lineedit(); le_runID->setReadOnly( true ); le_runID->setText( runID ); main->addWidget( le_runID, row++, 1 ); // Row QLabel* lb_runLen = us_label( tr( "Length of Run:" ) ); main->addWidget( lb_runLen, row, 0 ); le_runLen = us_lineedit(); le_runLen->setReadOnly( true ); main->addWidget( le_runLen, row++, 1 ); // Row QLabel* lb_timeCorr = us_label( tr( "Time Correction:" ) ); main->addWidget( lb_timeCorr, row, 0 ); le_timeCorr = us_lineedit(); le_timeCorr->setReadOnly( true ); main->addWidget( le_timeCorr, row++, 1 ); // Row QLabel* lb_rotorSpeed = us_label( tr( "Avg. Rotor Speed:" ) ); main->addWidget( lb_rotorSpeed, row, 0 ); le_rotorSpeed = us_lineedit(); le_rotorSpeed->setReadOnly( true ); main->addWidget( le_rotorSpeed, row++, 1 ); // Row QLabel* lb_avgTemp = us_label( tr( "Avg. Temperature:" ) ); main->addWidget( lb_avgTemp, row, 0 ); le_avgTemp = us_lineedit(); le_avgTemp->setReadOnly( true ); main->addWidget( le_avgTemp, row++, 1 ); // Row QLabel* lb_tempCheck = us_label( tr( "Temperature Check:" ) ); main->addWidget( lb_tempCheck, row, 0 ); QHBoxLayout* box1 = new QHBoxLayout; box1->setAlignment( Qt::AlignCenter ); QHBoxLayout* box2 = new QHBoxLayout; box2->setAlignment( Qt::AlignCenter ); box2->setSpacing( 10 ); lb_green = new QLabel(); lb_green->setFixedSize(20, 16); lb_green->setPalette( QPalette( QColor( 0, 0x44, 0 ) ) ); // Dark Green lb_green->setAutoFillBackground( true ); lb_green->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); lb_red = new QLabel(); lb_red->setFixedSize(20, 16); lb_red->setPalette( QPalette( QColor( 0x55, 0, 0 ) ) ); // Dark Red lb_red->setAutoFillBackground( true ); lb_red->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); box2->addWidget( lb_green ); box2->addWidget( lb_red ); box1->addLayout( box2 ); main->addLayout( box1, row, 1 ); QHBoxLayout* buttons = new QHBoxLayout(); QPushButton* pb_temp = us_pushbutton( tr( "Temperature" ) ); connect( pb_temp, SIGNAL( clicked() ), SLOT( plot_temp() ) ); buttons->addWidget( pb_temp ); QPushButton* pb_rpm = us_pushbutton( tr( "RPM" ) ); connect( pb_rpm, SIGNAL( clicked() ), SLOT( plot_rpm() ) ); buttons->addWidget( pb_rpm ); QPushButton* pb_interval = us_pushbutton( tr( "Interval" ) ); connect( pb_interval, SIGNAL( clicked() ), SLOT( plot_interval() ) ); buttons->addWidget( pb_interval ); QPushButton* pb_all = us_pushbutton( tr( "Combined" ) ); connect( pb_all, SIGNAL( clicked() ), SLOT( plot_combined() ) ); buttons->addWidget( pb_all ); QPushButton* pb_close = us_pushbutton( tr( "Close" ) ); connect( pb_close, SIGNAL( clicked() ), SLOT( close() ) ); buttons->addWidget( pb_close ); main->addLayout( buttons, row++, 2, 1, 4 ); timer = new QTimer(); connect( timer, SIGNAL( timeout() ), SLOT( update_timer() ) ); setup(); connect( lw_triples, SIGNAL( currentRowChanged( int ) ), SLOT ( update ( int ) ) ); connect( lw_rpm, SIGNAL( itemClicked ( QListWidgetItem* ) ), this, SLOT ( show_rpm_details( QListWidgetItem* ) ) ); }
void LvlScene::setRectDrawer() { if(cursor) {delete cursor; cursor=NULL;} QPen pen; QBrush brush; switch(placingItem) { case PLC_Water: if(LvlPlacingItems::waterType==1) { pen = QPen(Qt::yellow, 2); brush = QBrush(Qt::darkYellow); } else { pen = QPen(Qt::green, 2); brush = QBrush(Qt::darkGreen); } break; case PLC_Block: case PLC_BGO: default: pen = QPen(Qt::gray, 2); brush = QBrush(Qt::darkGray); break; } //Align width and height to fit into item aligning long addW=LvlPlacingItems::gridSz-LvlPlacingItems::itemW%LvlPlacingItems::gridSz; long addH=LvlPlacingItems::gridSz-LvlPlacingItems::itemH%LvlPlacingItems::gridSz; if(addW==LvlPlacingItems::gridSz) addW=0; if(addH==LvlPlacingItems::gridSz) addH=0; LvlPlacingItems::itemW = LvlPlacingItems::itemW+addW; LvlPlacingItems::itemH = LvlPlacingItems::itemH+addH; if((placingItem != PLC_Water) && (!LvlPlacingItems::sizableBlock)) { QPixmap oneCell(LvlPlacingItems::itemW, LvlPlacingItems::itemH); oneCell.fill(QColor(0xFF, 0xFF, 0x00, 128)); QPainter p(&oneCell); p.setBrush(Qt::NoBrush); p.setPen(QPen(Qt::yellow, 2, Qt::SolidLine)); p.drawRect(0,0, LvlPlacingItems::itemW, LvlPlacingItems::itemH); brush.setTexture(oneCell); } cursor = addRect(0,0,1,1, pen, brush); //set data flags foreach(dataFlag flag, LvlPlacingItems::flags) cursor->setData(flag.first, flag.second); cursor->setData(ITEM_TYPE, "Square"); cursor->setData(ITEM_IS_CURSOR, "CURSOR"); cursor->setZValue(7000); cursor->setOpacity( 0.5 ); cursor->setVisible(false); cursor->setEnabled(true); SwitchEditingMode(MODE_DrawRect); DrawMode=true; }
QGraphicsDropShadowEffect* decEffect = new QGraphicsDropShadowEffect; decEffect->setBlurRadius(4.); decEffect->setColor(QColor(0, 0, 0, 104)); decEffect->setOffset(0, 1); // Apply them to the pixmaps QGraphicsPixmapItem* bgItem = new QGraphicsPixmapItem(keyBG); bgItem->setGraphicsEffect(bgEffect); QGraphicsPixmapItem* decItem = new QGraphicsPixmapItem(decoration); decItem->setGraphicsEffect(decEffect); // Render everything QGraphicsScene* scene = new QGraphicsScene; scene->addItem(bgItem); scene->addItem(decItem); // It has to be rendered onto yet another pixmap or else DPI scaling will look terrible... QPixmap final(wWidth * ratio, wHeight * ratio); final.fill(QColor(0, 0, 0, 0)); QPainter finalPainter(&final); scene->render(&finalPainter, QRectF(0, 0, wWidth * ratio, wHeight * ratio), QRectF(0, 0, wWidth * ratio, wHeight * ratio)); delete scene; // <- Automatically cleans up the rest of the objects #if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0) final.setDevicePixelRatio(ratio); #endif painter.drawPixmap(QPointF(0., 0.), final); } void KeyWidget::mousePressEvent(QMouseEvent* event){ event->accept(); mouseDownMode = (event->modifiers() & Qt::AltModifier) ? SUBTRACT : (event->modifiers() & Qt::ShiftModifier) ? ADD : (event->modifiers() & Qt::ControlModifier) ? TOGGLE : SET; mouseDownX = mouseCurrentX = event->x(); mouseDownY = mouseCurrentY = event->y(); // See if the event hit a key
void LvlScene::setItemPlacer(int itemType, unsigned long itemID, int dType) { if(cursor) {delete cursor; cursor=NULL;} LogDebug(QString("ItemPlacer -> set to type-%1 for ID-%2").arg(itemType).arg(itemID)); LvlPlacingItems::sizableBlock=false; switch(itemType) { case 0: //blocks { obj_block &blockC = uBlocks[itemID]; Items::getItemGFX(&blockC, tImg, false); if(tImg.isNull()) { tImg = uBlockImg; } if(!blockC.isValid) { blockC = pConfigs->main_block[1]; blockC.image = uBlockImg; } LvlPlacingItems::gridSz=blockC.grid; LvlPlacingItems::gridOffset = QPoint(0, 0); if( (itemID != LvlPlacingItems::blockSet.id) || (placingItem!=PLC_Block) ) LvlPlacingItems::blockSet.layer = "Default"; LvlPlacingItems::layer = LvlPlacingItems::blockSet.layer; LvlPlacingItems::blockSet.id = itemID; LvlPlacingItems::blockSet.w = tImg.width(); LvlPlacingItems::blockSet.h = tImg.height(); placingItem=PLC_Block; //Place sizable blocks in the square fill mode if(blockC.sizable) { LvlPlacingItems::sizableBlock=true; LvlPlacingItems::placingMode = LvlPlacingItems::PMODE_Brush; setRectDrawer(); return; } LvlPlacingItems::itemW = LvlPlacingItems::blockSet.w; LvlPlacingItems::itemH = LvlPlacingItems::blockSet.h; LvlPlacingItems::flags.clear(); QPair<int, QVariant > flag; flag.first=ITEM_TYPE; flag.second="Block"; LvlPlacingItems::flags.push_back(flag); flag.first=ITEM_ID; flag.second=QString::number(LvlPlacingItems::blockSet.id); LvlPlacingItems::flags.push_back(flag); if(blockC.sizable) { flag.first=ITEM_BLOCK_IS_SIZABLE; flag.second = "sizable"; LvlPlacingItems::flags.push_back(flag); } flag.first = ITEM_BLOCK_SHAPE; flag.second = QString::number(blockC.phys_shape); LvlPlacingItems::flags.push_back(flag); flag.first = ITEM_WIDTH; flag.second = QString::number(LvlPlacingItems::blockSet.w); LvlPlacingItems::flags.push_back(flag); flag.first = ITEM_HEIGHT; flag.second = QString::number(LvlPlacingItems::blockSet.h); LvlPlacingItems::flags.push_back(flag); flag.first = ITEM_IS_CURSOR; flag.second = "CURSOR"; LvlPlacingItems::flags.push_back(flag); //Rectangular fill mode (uses own cursor item) if(LvlPlacingItems::placingMode == LvlPlacingItems::PMODE_Rect) { setRectDrawer(); return; } //Rectangular fill mode (uses own cursor item) if(LvlPlacingItems::placingMode == LvlPlacingItems::PMODE_Circle) { setCircleDrawer(); return; } //Offset relative to item center LvlPlacingItems::c_offset_x= qRound(qreal(LvlPlacingItems::blockSet.w) / 2); LvlPlacingItems::c_offset_y= qRound(qreal(LvlPlacingItems::blockSet.h) / 2); //Line mode (uses own cursor item) if(LvlPlacingItems::placingMode == LvlPlacingItems::PMODE_Line) { setLineDrawer(); return; } //Single item placing cursor = addPixmap(tImg); //set data flags foreach(dataFlag flag, LvlPlacingItems::flags) cursor->setData(flag.first, flag.second); cursor->setZValue(7000); cursor->setOpacity( 0.8 ); cursor->setVisible(false); cursor->setEnabled(true); //flood fill uses 'item' cursor //if(LvlPlacingItems::floodFillingMode) if(LvlPlacingItems::placingMode == LvlPlacingItems::PMODE_FloodFill) { setFloodFiller(); return; } SwitchEditingMode(MODE_PlacingNew); break; } case 1: //bgos { obj_bgo& bgoC = uBGOs[itemID]; Items::getItemGFX(&bgoC, tImg, false); if(tImg.isNull()) { tImg=uBgoImg; } if(!bgoC.isValid) { bgoC = pConfigs->main_bgo[1]; bgoC.image = uBgoImg; } LvlPlacingItems::gridSz=bgoC.grid; LvlPlacingItems::gridOffset = QPoint(bgoC.offsetX, bgoC.offsetY); if( (itemID != LvlPlacingItems::bgoSet.id) || (placingItem!=PLC_BGO) ) LvlPlacingItems::bgoSet.layer = "Default"; LvlPlacingItems::layer = LvlPlacingItems::bgoSet.layer; LvlPlacingItems::bgoSet.id = itemID; long w = tImg.width(); long h = tImg.height();//( (bgoC.animated)?bgoC.frames:1); LvlPlacingItems::itemW = w; LvlPlacingItems::itemH = h; placingItem=PLC_BGO; LvlPlacingItems::flags.clear(); QPair<int, QVariant > flag; flag.first=0; flag.second="BGO"; LvlPlacingItems::flags.push_back(flag); flag.first=1; flag.second=QString::number(itemID); LvlPlacingItems::flags.push_back(flag); flag.first = 9; flag.second = QString::number(w); LvlPlacingItems::flags.push_back(flag); flag.first = 10; flag.second = QString::number(h); LvlPlacingItems::flags.push_back(flag); flag.first = 25; flag.second = "CURSOR"; LvlPlacingItems::flags.push_back(flag); //Square fill mode if(LvlPlacingItems::placingMode==LvlPlacingItems::PMODE_Rect) { setRectDrawer(); return; } //Rectangular fill mode (uses own cursor item) if(LvlPlacingItems::placingMode == LvlPlacingItems::PMODE_Circle) { setCircleDrawer(); return; } LvlPlacingItems::c_offset_x= qRound(qreal(w) / 2); LvlPlacingItems::c_offset_y= qRound(qreal(h) / 2); //Line mode if(LvlPlacingItems::placingMode==LvlPlacingItems::PMODE_Line) { setLineDrawer(); return; } //Single item placing cursor = addPixmap( tImg ); //set data flags foreach(dataFlag flag, LvlPlacingItems::flags) cursor->setData(flag.first, flag.second); cursor->setZValue(7000); cursor->setOpacity( 0.8 ); cursor->setVisible(false); cursor->setEnabled(true); //flood fill uses 'item' cursor if(LvlPlacingItems::placingMode==LvlPlacingItems::PMODE_FloodFill) { setFloodFiller(); return; } SwitchEditingMode(MODE_PlacingNew); break; } case 2: //npcs { obj_npc &mergedSet = uNPCs[itemID]; tImg = getNPCimg(itemID, LvlPlacingItems::npcSet.direct); if(!mergedSet.isValid) { mergedSet = pConfigs->main_npc[1]; mergedSet.image = uNpcImg; } if( (itemID != LvlPlacingItems::npcSet.id) || (placingItem!=PLC_NPC) ) LvlPlacingItems::npcSet.layer = "Default"; LvlPlacingItems::layer = LvlPlacingItems::npcSet.layer; LvlPlacingItems::npcSet.id = itemID; if(LvlPlacingItems::npcSet.generator) LvlPlacingItems::gridSz=(pConfigs->default_grid/2); else LvlPlacingItems::gridSz=mergedSet.grid; LvlPlacingItems::npcSet.is_star = mergedSet.is_star; LvlPlacingItems::npcGrid=mergedSet.grid; LvlPlacingItems::gridOffset = QPoint(mergedSet.grid_offset_x, mergedSet.grid_offset_y); LvlPlacingItems::flags.clear(); QPair<int, QVariant > flag; long imgOffsetX = (int)round( - ( ( (double)mergedSet.gfx_w - (double)mergedSet.width ) / 2 ) ); long imgOffsetY = (int)round( - (double)mergedSet.gfx_h + (double)mergedSet.height + (double)mergedSet.gfx_offset_y ); LvlPlacingItems::npcGfxOffsetX1 = imgOffsetX; LvlPlacingItems::npcGfxOffsetX2 = (-((double)mergedSet.gfx_offset_x)); LvlPlacingItems::npcGfxOffsetY = imgOffsetY; LvlPlacingItems::itemW = mergedSet.width; LvlPlacingItems::itemH = mergedSet.height; LvlPlacingItems::c_offset_x= qRound(qreal(mergedSet.width) / 2); LvlPlacingItems::c_offset_y= qRound(qreal(mergedSet.height) / 2); placingItem = PLC_NPC; flag.first=ITEM_TYPE; flag.second="NPC"; LvlPlacingItems::flags.push_back(flag); flag.first=ITEM_ID; flag.second=QString::number(itemID); LvlPlacingItems::flags.push_back(flag); flag.first=ITEM_NPC_BLOCK_COLLISION; flag.second=QString::number((int)mergedSet.collision_with_blocks); LvlPlacingItems::flags.push_back(flag); flag.first=ITEM_NPC_NO_NPC_COLLISION; flag.second=QString::number((int)mergedSet.no_npc_collions); LvlPlacingItems::flags.push_back(flag); flag.first=ITEM_WIDTH; flag.second=QString::number(mergedSet.width); LvlPlacingItems::flags.push_back(flag); flag.first=ITEM_HEIGHT; flag.second=QString::number(mergedSet.height); LvlPlacingItems::flags.push_back(flag); flag.first=ITEM_IS_CURSOR; flag.second="CURSOR"; LvlPlacingItems::flags.push_back(flag); //Line mode if(LvlPlacingItems::placingMode==LvlPlacingItems::PMODE_Line) { setLineDrawer(); return; } cursor = addPixmap(tImg); //set data flags foreach(dataFlag flag, LvlPlacingItems::flags) cursor->setData(flag.first, flag.second); ((QGraphicsPixmapItem *)cursor)->setOffset( ( LvlPlacingItems::npcGfxOffsetX1 + ( LvlPlacingItems::npcGfxOffsetX2 * ((LvlPlacingItems::npcSet.direct==0)?-1:LvlPlacingItems::npcSet.direct))), LvlPlacingItems::npcGfxOffsetY ); cursor->setZValue(7000); cursor->setOpacity( 0.8 ); cursor->setVisible(false); cursor->setEnabled(true); break; } case 3: //water placingItem=PLC_Water; LvlPlacingItems::waterType = itemID; LvlPlacingItems::gridSz = 16; LvlPlacingItems::gridOffset = QPoint(0,0); LvlPlacingItems::c_offset_x= 0; LvlPlacingItems::c_offset_y= 0; LvlPlacingItems::waterSet.layer = LvlPlacingItems::layer.isEmpty()? "Default" : LvlPlacingItems::layer; setRectDrawer(); return; break; case 4: //doorPoint placingItem=PLC_Door; LvlPlacingItems::doorType = dType; LvlPlacingItems::doorArrayId = itemID; LvlPlacingItems::gridSz=16; LvlPlacingItems::gridOffset = QPoint(0,0); LvlPlacingItems::c_offset_x = 16; LvlPlacingItems::c_offset_y = 16; LvlPlacingItems::layer = ""; cursor = addRect(0,0, 32, 32); ((QGraphicsRectItem *)cursor)->setBrush(QBrush(QColor(qRgb(0xff,0x00,0x7f)))); ((QGraphicsRectItem *)cursor)->setPen(QPen(QColor(qRgb(0xff,0x00,0x7f)), 2,Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin)); cursor->setData(ITEM_IS_CURSOR, "CURSOR"); cursor->setZValue(7000); cursor->setOpacity( 0.8 ); cursor->setVisible(false); cursor->setEnabled(true); break; case 5: //PlayerPoint { placingItem=PLC_PlayerPoint; LvlPlacingItems::playerID = itemID; LvlPlacingItems::gridSz=2; LvlPlacingItems::gridOffset = QPoint(0,2); LvlPlacingItems::c_offset_x = 16; LvlPlacingItems::c_offset_y = 16; LvlPlacingItems::layer = ""; QPixmap playerPixmap; switch(itemID+1) { case 1: playerPixmap = Themes::Image(Themes::player1); break; case 2: playerPixmap = Themes::Image(Themes::player2); break; default: playerPixmap = Themes::Image(Themes::player_point); break; } PlayerPoint x = FileFormats::CreateLvlPlayerPoint(itemID+1); cursor = addPixmap(playerPixmap); dynamic_cast<QGraphicsPixmapItem *>(cursor)->setOffset(qRound(qreal(x.w-playerPixmap.width())/2.0), x.h-playerPixmap.height() ); cursor->setData(ITEM_IS_CURSOR, "CURSOR"); cursor->setZValue(7000); cursor->setOpacity( 0.8 ); cursor->setVisible(true); cursor->setEnabled(true); break; } default: break; } SwitchEditingMode(MODE_PlacingNew); DrawMode=true; contextMenuOpened=false; }
TreeRingViewItem::TreeRingViewItem(QGLContext* ctx, QGraphicsItem* p) : QVTKGraphicsItem(ctx, p) { QPalette pal = this->palette(); pal.setColor(QPalette::Window, QColor(255,255,255,250)); this->setPalette(pal); TreeRingView.TakeReference(vtkTreeRingView::New()); TreeRingView->SetRenderWindow(this->GetRenderWindow()); QFile f1(":/Data/vtkclasses.xml"); f1.open(QIODevice::ReadOnly); QByteArray f1_data = f1.readAll(); QFile f2(":/Data/vtklibrary.xml"); f2.open(QIODevice::ReadOnly); QByteArray f2_data = f2.readAll(); vtkSmartPointer<vtkXMLTreeReader> reader1 = vtkSmartPointer<vtkXMLTreeReader>::New(); reader1->SetXMLString(f1_data.data()); reader1->SetEdgePedigreeIdArrayName("graph edge"); reader1->GenerateVertexPedigreeIdsOff(); reader1->SetVertexPedigreeIdArrayName("id"); vtkSmartPointer<vtkXMLTreeReader> reader2 = vtkSmartPointer<vtkXMLTreeReader>::New(); reader2->SetXMLString(f2_data.data()); reader2->SetEdgePedigreeIdArrayName("tree edge"); reader2->GenerateVertexPedigreeIdsOff(); reader2->SetVertexPedigreeIdArrayName("id"); reader1->Update(); reader2->Update(); TreeRingView->DisplayHoverTextOn(); TreeRingView->SetTreeFromInputConnection(reader2->GetOutputPort()); TreeRingView->SetGraphFromInputConnection(reader1->GetOutputPort()); TreeRingView->SetAreaColorArrayName("VertexDegree"); // Uncomment for edge colors //TreeRingView->SetEdgeColorArrayName("graph edge"); //TreeRingView->SetColorEdges(true); // Uncomment for edge labels //TreeRingView->SetEdgeLabelArrayName("graph edge"); //TreeRingView->SetEdgeLabelVisibility(true); TreeRingView->SetAreaLabelArrayName("id"); TreeRingView->SetAreaLabelVisibility(true); TreeRingView->SetAreaHoverArrayName("id"); TreeRingView->SetAreaSizeArrayName("VertexDegree"); vtkRenderedTreeAreaRepresentation::SafeDownCast(TreeRingView->GetRepresentation())->SetGraphHoverArrayName("graph edge"); vtkViewTheme* const theme = vtkViewTheme::CreateMellowTheme(); theme->SetLineWidth(1); theme->GetPointTextProperty()->ShadowOn(); TreeRingView->ApplyViewTheme(theme); theme->Delete(); this->TreeRingView->GetRenderer()->SetGradientBackground(0); this->TreeRingView->GetRenderer()->SetBackground(0.1,0.1,0.1); TreeRingView->ResetCamera(); }
// Returns the foreground colour of the text for a style. QColor QsciLexerRuby::defaultColor(int style) const { switch (style) { case Default: return QColor(0x80,0x80,0x80); case Comment: return QColor(0x00,0x7f,0x00); case POD: return QColor(0x00,0x40,0x00); case Number: case FunctionMethodName: return QColor(0x00,0x7f,0x7f); case Keyword: case DemotedKeyword: return QColor(0x00,0x00,0x7f); case DoubleQuotedString: case SingleQuotedString: case HereDocument: case PercentStringq: case PercentStringQ: return QColor(0x7f,0x00,0x7f); case ClassName: return QColor(0x00,0x00,0xff); case Regex: case HereDocumentDelimiter: case PercentStringr: case PercentStringw: return QColor(0x00,0x00,0x00); case Global: return QColor(0x80,0x00,0x80); case Symbol: return QColor(0xc0,0xa0,0x30); case ModuleName: return QColor(0xa0,0x00,0xa0); case InstanceVariable: return QColor(0xb0,0x00,0x80); case ClassVariable: return QColor(0x80,0x00,0xb0); case Backticks: case PercentStringx: return QColor(0xff,0xff,0x00); case DataSection: return QColor(0x60,0x00,0x00); } return QsciLexer::defaultColor(style); }