void LinkDisplay::setLink(const QString &title, const QString &icon, const QPixmap &preview, LinkLook *look, const QFont &font) { m_title = title; m_icon = icon; m_preview = preview; m_look = look; m_font = font; // "Constants": int BUTTON_MARGIN = kapp->style()->pixelMetric(QStyle::PM_ButtonMargin); int LINK_MARGIN = BUTTON_MARGIN + 2; // Recompute m_minWidth: QRect textRect = QFontMetrics(labelFont(font, false)).boundingRect(0, 0, /*width=*/1, 500000, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, m_title); int iconPreviewWidth = qMax(m_look->iconSize(), (m_look->previewEnabled() ? m_preview.width() : 0)); m_minWidth = BUTTON_MARGIN - 1 + iconPreviewWidth + LINK_MARGIN + textRect.width(); // Recompute m_maxWidth: textRect = QFontMetrics(labelFont(font, false)).boundingRect(0, 0, /*width=*/50000000, 500000, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, m_title); m_maxWidth = BUTTON_MARGIN - 1 + iconPreviewWidth + LINK_MARGIN + textRect.width(); // Adjust m_width: if (m_width < m_minWidth) setWidth(m_minWidth); // Recompute m_height: m_height = heightForWidth(m_width); }
void MFCInstanceView::Draw(Graphics &dc, CRect &clipBox) { // !!!??? need to clip properly for short instances with long names Pen blackPen(AlphaColor(250, rgb_black), 1); Pen redPen(AlphaColor(250, rgb_red), 1); SolidBrush blueBrush(AlphaColor(100, rgb_blue)); SolidBrush blackBrush(AlphaColor(100, rgb_black)); CRect clipBounds = bounds; if (clipBox.left > bounds.left) clipBounds.left = clipBox.left-1; if (clipBox.right < bounds.right) clipBounds.right = clipBox.right+1; cerr << "ondraw instance view " << clipBox.left << ", " << clipBox.right << endl; dc.FillRectangle(&blueBrush, bounds.left, bounds.top, bounds.right-bounds.left, bounds.bottom-bounds.top); dc.DrawRectangle(selected?&redPen:&blackPen, bounds.left, bounds.top, clipBounds.right-bounds.left, bounds.bottom-bounds.top); Font labelFont(L"Arial", 8.0, FontStyleRegular, UnitPoint, NULL); wstring nm; const char *cp = instance->sym->uniqueName(); while (*cp) { nm.push_back(*cp++); } float lbx = bounds.left+2; #define LBLSEP 200 if (clipBox.left > lbx) { int nld = clipBox.left - lbx; nld = nld/LBLSEP; // if (nld > 2) lbx += (nld-2)*LBLSEP; } PointF p(lbx, clipBounds.top); do { dc.DrawString(nm.c_str(), -1, &labelFont, p, &blackBrush); p.X += LBLSEP; } while (p.X < clipBounds.right); }
qreal LinkDisplay::heightForWidth(qreal width) const { qreal BUTTON_MARGIN = kapp->style()->pixelMetric(QStyle::PM_ButtonMargin); qreal LINK_MARGIN = BUTTON_MARGIN + 2; qreal iconPreviewWidth = qMax(m_look->iconSize(), (m_look->previewEnabled() ? m_preview.width() : 0)); qreal iconPreviewHeight = qMax(m_look->iconSize(), (m_look->previewEnabled() ? m_preview.height() : 0)); QRectF textRect = QFontMetrics(labelFont(m_font, false)).boundingRect(0, 0, width - BUTTON_MARGIN + 1 - iconPreviewWidth - LINK_MARGIN, 500000, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, m_title); return qMax(textRect.height(), iconPreviewHeight + 2*BUTTON_MARGIN - 2); }
// // // CButDlg Class // // Provide a dialog to add/edit a filter button to the MsgDialog // CButDlg::CButDlg(QWidget *parent, QString name, MyButton *but) : QDialog(parent, name, TRUE) { QBoxLayout *topLayout = new QVBoxLayout(this); QBoxLayout *row1Layout = new QHBoxLayout(topLayout); QBoxLayout *row2Layout = new QHBoxLayout(topLayout); QFont labelFont(font()); labelFont.setBold(true); QLabel *nameLabel = new QLabel ("Name", this); nameLabel->setFont(labelFont); nameLabel->setFixedHeight(nameLabel->sizeHint().height()); nameLabel->setFixedWidth(80); nameLabel->setAlignment(QLabel::AlignLeft|QLabel::AlignVCenter); row1Layout->addWidget(nameLabel); QLineEdit *nameEdit = new QLineEdit (this, "Name"); nameEdit->setText(but->text()); nameEdit->setFont(labelFont); nameEdit->setFixedHeight(nameEdit->sizeHint().height()); nameEdit->setFixedWidth(150); row1Layout->addWidget(nameEdit); QLabel *filterLabel = new QLabel ("Filter", this); filterLabel->setFont(labelFont); filterLabel->setFixedHeight(filterLabel->sizeHint().height()); filterLabel->setFixedWidth(80); filterLabel->setAlignment(QLabel::AlignLeft|QLabel::AlignVCenter); row2Layout->addWidget(filterLabel); QLineEdit *filterEdit = new QLineEdit (this, "Filter"); filterEdit->setText(but->filter()); filterEdit->setFont(labelFont); filterEdit->setFixedHeight(filterEdit->sizeHint().height()); filterEdit->setFixedWidth(150); row2Layout->addWidget(filterEdit); QPushButton *ok = new QPushButton("OK", this); ok->setFixedWidth(30); ok->setFixedHeight(30); topLayout->addWidget(ok, 0, AlignCenter); // connect sigs connect(nameEdit, SIGNAL(textChanged(const QString &)), but, SLOT(setText(const QString &))); connect(filterEdit, SIGNAL(textChanged(const QString &)), but, SLOT(setFilter(const QString &))); connect(ok, SIGNAL(clicked()), SLOT(accept())); setMaximumSize(QSize(sizeHint())); }
void TipPanel::OnPaint(wxPaintEvent& event) { wxPaintDC dc(this); int width, height, textWidth, textHeight; wxFont labelFont(sliderFontSize, wxSWISS, wxNORMAL, wxNORMAL); dc.SetFont(labelFont); GetClientSize(&width, &height); dc.SetPen(*wxBLACK_PEN); dc.SetBrush(*wxWHITE_BRUSH); dc.DrawRectangle(0, 0, width, height); dc.GetTextExtent(label, &textWidth, &textHeight); dc.DrawText(label, (width-textWidth)/2, (height-textHeight)/2); }
void TipPanel::SetPos(const wxPoint& pos) { wxClientDC dc(this); wxFont labelFont(sliderFontSize, wxSWISS, wxNORMAL, wxNORMAL); dc.SetFont(labelFont); int width, height; dc.GetTextExtent(origLabel, &width, &height); width += 4; height += 4; int left = pos.x - width/2; if (left < 0) left = 0; SetSize(left, pos.y, width, height); }
VotePanel::VotePanel(wxWindow* parentWindow) : wxPanel(parentWindow) , chatPanel(0) , parentWnd(parentWindow) , player(0) { mainSizer = new wxBoxSizer(wxHORIZONTAL); voteTextLabel = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize); wxFont labelFont(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); voteTextLabel->SetFont(labelFont); mainSizer->Add(voteTextLabel, 0, wxALIGN_CENTER, 0); wxFont buttonFont(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); yesButton = new wxButton(this, VotePanel::ID_YES_BUTTON, "yes", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); yesButton->SetFont(buttonFont); yesButton->SetForegroundColour(*wxGREEN); yesButton->SetToolTip(_("Vote for YES, (Ctrl-Y)")); mainSizer->Add(yesButton); dontCareButton = new wxButton(this, VotePanel::ID_DONTCARE_BUTTON, "don't care", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); dontCareButton->SetFont(buttonFont); dontCareButton->SetToolTip(_("Vote for DON'T CARE, (Ctrl-B)")); mainSizer->Add(dontCareButton); noButton = new wxButton(this, VotePanel::ID_NO_BUTTON, "no", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); noButton->SetFont(buttonFont); noButton->SetForegroundColour(*wxRED); noButton->SetToolTip(_("Vote for NO, (Ctrl-N)")); mainSizer->Add(noButton); SetSizer(mainSizer); //Set up acceleration table for hotkeys const int ENTRIES_COUNT = 3; wxAcceleratorEntry accelEntries[ENTRIES_COUNT]; accelEntries[0].Set(wxACCEL_CTRL, (int)'Y', ID_YES_BUTTON); accelEntries[1].Set(wxACCEL_CTRL, (int)'B', ID_DONTCARE_BUTTON); accelEntries[2].Set(wxACCEL_CTRL, (int)'N', ID_NO_BUTTON); wxAcceleratorTable accelTable(ENTRIES_COUNT, accelEntries); //TODO: this line overrides parent's window acceleration table! parentWindow->SetAcceleratorTable(accelTable); //Reset vote panel to "no vote" state ResetState(); }
void TipPanel::SetPos(const wxPoint& pos, wxString maxLabel) { int x = pos.x; int y = pos.y; // if (mParent) // mParent->ClientToScreen(&x,&y); wxClientDC dc(this); wxFont labelFont(sliderFontSize, wxSWISS, wxNORMAL, wxNORMAL); dc.SetFont(labelFont); int width, height; dc.GetTextExtent(maxLabel, &width, &height); height += 4; SetSize(x - width/2, y, width, height); }
void TDEAboutContainer::addTitle( const TQString &title, int alignment, bool showFrame, bool showBold ) { TQLabel* const label = new TQLabel( title, this, "title" ); if( showBold ) { TQFont labelFont( font() ); labelFont.setBold( true ); label->setFont( labelFont ); } if( showFrame ) { label->setFrameStyle(TQFrame::Panel | TQFrame::Raised); } label->setAlignment( alignment ); }
/** Paint on @p painter * in (@p x, @p y, @p width, @p height) * using @p palette for the button drawing (if @p isHovered) * and the LinkLook color() for the text, * unless [the LinkLook !color.isValid() and it does not useLinkColor()] or [@p isDefaultColor is false]: in this case it will use @p palette's active text color. * It will draw the button if @p isIconButtonHovered. */ void LinkDisplay::paint(QPainter *painter, qreal x, qreal y, qreal width, qreal height, const QPalette &palette, bool isDefaultColor, bool isSelected, bool isHovered, bool isIconButtonHovered) const { qreal BUTTON_MARGIN = kapp->style()->pixelMetric(QStyle::PM_ButtonMargin); qreal LINK_MARGIN = BUTTON_MARGIN + 2; QPixmap pixmap; // Load the preview...: if (!isHovered && m_look->previewEnabled() && !m_preview.isNull()) pixmap = m_preview; // ... Or the icon (if no preview or if the "Open" icon should be shown): else { qreal iconSize = m_look->iconSize(); QString iconName = (isHovered ? Global::openNoteIcon() : m_icon); KIconLoader::States iconState = (isIconButtonHovered ? KIconLoader::ActiveState : KIconLoader::DefaultState); pixmap = KIconLoader::global()->loadIcon( iconName, KIconLoader::Desktop, iconSize, iconState, QStringList(), 0L, /*canReturnNull=*/false ); } qreal iconPreviewWidth = qMax(m_look->iconSize(), (m_look->previewEnabled() ? m_preview.width() : 0)); qreal pixmapX = (iconPreviewWidth - pixmap.width()) / 2; qreal pixmapY = (height - pixmap.height()) / 2; // Draw the button (if any) and the icon: if (isHovered) { QStyleOption opt; opt.rect = QRect(-1, -1, iconPreviewWidth + 2 * BUTTON_MARGIN, height + 2); opt.state = isIconButtonHovered ? (QStyle::State_MouseOver | QStyle::State_Enabled) : QStyle::State_Enabled; kapp->style()->drawPrimitive(QStyle::PE_PanelButtonCommand, &opt, painter); } painter->drawPixmap(x + BUTTON_MARGIN - 1 + pixmapX, y + pixmapY, pixmap); // Figure out the text color: if (isSelected) { painter->setPen(kapp->palette().color(QPalette::HighlightedText)); } else if (isIconButtonHovered) painter->setPen(m_look->effectiveHoverColor()); else if (!isDefaultColor || (!m_look->color().isValid() && !m_look->useLinkColor())) // If the color is FORCED or if the link color default to the text color: painter->setPen(palette.color(QPalette::Active, QPalette::WindowText)); else painter->setPen(m_look->effectiveColor()); // Draw the text: painter->setFont(labelFont(m_font, isIconButtonHovered)); painter->drawText(x + BUTTON_MARGIN - 1 + iconPreviewWidth + LINK_MARGIN, y, width - BUTTON_MARGIN + 1 - iconPreviewWidth - LINK_MARGIN, height, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextWordWrap, m_title); }
void TipPanel::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); int width, height, textWidth, textHeight; wxFont labelFont(sliderFontSize, wxSWISS, wxNORMAL, wxNORMAL); dc.SetFont(labelFont); GetClientSize(&width, &height); #if defined(__WXMAC__) dc.SetPen(AColor::tooltipBrush.GetColour()); #else dc.SetPen(*wxBLACK_PEN); #endif dc.SetBrush(AColor::tooltipBrush); dc.DrawRectangle(0, 0, width, height); dc.GetTextExtent(label, &textWidth, &textHeight); dc.DrawText(label, (width-textWidth)/2, (height-textHeight)/2); }
void GUI::PreviewControlPanel::createUi() { QHBoxLayout *h_layout=new QHBoxLayout; button_nextFrame=new QPushButton; button_previousFrame=new QPushButton; label_position=new QLabel("0/0"); button_nextFrame->setFlat(true); button_previousFrame->setFlat(true); button_nextFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); button_previousFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); label_position->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); button_nextFrame->setIcon(QIcon(":/icons/resources/icons/next.png")); button_previousFrame->setIcon(QIcon(":/icons/resources/icons/prev.png")); label_position->setAlignment(Qt::AlignCenter); QFont labelFont("Arial",15); label_position->setFont(labelFont); h_layout->addWidget(button_previousFrame); h_layout->addWidget(label_position); h_layout->addWidget(button_nextFrame); setLayout(h_layout); setFixedHeight(60); setObjectName("playerPanel"); setStyleSheet("QFrame#playerPanel {" "border-width:1px;" "border-radius:4px;" "border-color:rgb(0,0,0);" "border-style:outset;" "background: rgb(200, 200, 200);" "}" ""); }
KAstTopLevel::KAstTopLevel( QWidget *parent, const char *name ) : Q3MainWindow( parent, name, 0 ) { QWidget *border = new QWidget( this ); border->setBackgroundColor( Qt::black ); setCentralWidget( border ); Q3VBoxLayout *borderLayout = new Q3VBoxLayout( border ); borderLayout->addStretch( 1 ); QWidget *mainWin = new QWidget( border ); mainWin->setFixedSize(640, 480); borderLayout->addWidget( mainWin, 0, Qt::AlignHCenter ); borderLayout->addStretch( 1 ); view = new KAsteroidsView( mainWin ); view->setFocusPolicy( Qt::StrongFocus ); connect( view, SIGNAL( shipKilled() ), SLOT( slotShipKilled() ) ); connect( view, SIGNAL( rockHit(int) ), SLOT( slotRockHit(int) ) ); connect( view, SIGNAL( rocksRemoved() ), SLOT( slotRocksRemoved() ) ); connect( view, SIGNAL( updateVitals() ), SLOT( slotUpdateVitals() ) ); Q3VBoxLayout *vb = new Q3VBoxLayout( mainWin ); Q3HBoxLayout *hb = new Q3HBoxLayout; Q3HBoxLayout *hbd = new Q3HBoxLayout; vb->addLayout( hb ); QFont labelFont( "helvetica", 24 ); QColorGroup grp( Qt::darkGreen, Qt::black, QColor( 128, 128, 128 ), QColor( 64, 64, 64 ), Qt::black, Qt::darkGreen, Qt::black ); QPalette pal( grp, grp, grp ); mainWin->setPalette( pal ); hb->addSpacing( 10 ); QLabel *label; label = new QLabel( tr("Score"), mainWin ); label->setFont( labelFont ); label->setPalette( pal ); label->setFixedWidth( label->sizeHint().width() ); hb->addWidget( label ); scoreLCD = new QLCDNumber( 6, mainWin ); scoreLCD->setFrameStyle( Q3Frame::NoFrame ); scoreLCD->setSegmentStyle( QLCDNumber::Flat ); scoreLCD->setFixedWidth( 150 ); scoreLCD->setPalette( pal ); hb->addWidget( scoreLCD ); hb->addStretch( 10 ); label = new QLabel( tr("Level"), mainWin ); label->setFont( labelFont ); label->setPalette( pal ); label->setFixedWidth( label->sizeHint().width() ); hb->addWidget( label ); levelLCD = new QLCDNumber( 2, mainWin ); levelLCD->setFrameStyle( Q3Frame::NoFrame ); levelLCD->setSegmentStyle( QLCDNumber::Flat ); levelLCD->setFixedWidth( 70 ); levelLCD->setPalette( pal ); hb->addWidget( levelLCD ); hb->addStretch( 10 ); label = new QLabel( tr("Ships"), mainWin ); label->setFont( labelFont ); label->setFixedWidth( label->sizeHint().width() ); label->setPalette( pal ); hb->addWidget( label ); shipsLCD = new QLCDNumber( 1, mainWin ); shipsLCD->setFrameStyle( Q3Frame::NoFrame ); shipsLCD->setSegmentStyle( QLCDNumber::Flat ); shipsLCD->setFixedWidth( 40 ); shipsLCD->setPalette( pal ); hb->addWidget( shipsLCD ); hb->addStrut( 30 ); vb->addWidget( view, 10 ); // -- bottom layout: vb->addLayout( hbd ); QFont smallFont( "helvetica", 14 ); hbd->addSpacing( 10 ); QString sprites_prefix = ":/trolltech/examples/graphicsview/portedasteroids/sprites/"; /* label = new QLabel( tr( "T" ), mainWin ); label->setFont( smallFont ); label->setFixedWidth( label->sizeHint().width() ); label->setPalette( pal ); hbd->addWidget( label ); teleportsLCD = new QLCDNumber( 1, mainWin ); teleportsLCD->setFrameStyle( QFrame::NoFrame ); teleportsLCD->setSegmentStyle( QLCDNumber::Flat ); teleportsLCD->setPalette( pal ); teleportsLCD->setFixedHeight( 20 ); hbd->addWidget( teleportsLCD ); hbd->addSpacing( 10 ); */ QPixmap pm( sprites_prefix + "powerups/brake.png" ); label = new QLabel( mainWin ); label->setPixmap( pm ); label->setFixedWidth( label->sizeHint().width() ); label->setPalette( pal ); hbd->addWidget( label ); brakesLCD = new QLCDNumber( 1, mainWin ); brakesLCD->setFrameStyle( Q3Frame::NoFrame ); brakesLCD->setSegmentStyle( QLCDNumber::Flat ); brakesLCD->setPalette( pal ); brakesLCD->setFixedHeight( 20 ); hbd->addWidget( brakesLCD ); hbd->addSpacing( 10 ); pm.load( sprites_prefix + "powerups/shield.png" ); label = new QLabel( mainWin ); label->setPixmap( pm ); label->setFixedWidth( label->sizeHint().width() ); label->setPalette( pal ); hbd->addWidget( label ); shieldLCD = new QLCDNumber( 1, mainWin ); shieldLCD->setFrameStyle( Q3Frame::NoFrame ); shieldLCD->setSegmentStyle( QLCDNumber::Flat ); shieldLCD->setPalette( pal ); shieldLCD->setFixedHeight( 20 ); hbd->addWidget( shieldLCD ); hbd->addSpacing( 10 ); pm.load( sprites_prefix + "powerups/shoot.png" ); label = new QLabel( mainWin ); label->setPixmap( pm ); label->setFixedWidth( label->sizeHint().width() ); label->setPalette( pal ); hbd->addWidget( label ); shootLCD = new QLCDNumber( 1, mainWin ); shootLCD->setFrameStyle( Q3Frame::NoFrame ); shootLCD->setSegmentStyle( QLCDNumber::Flat ); shootLCD->setPalette( pal ); shootLCD->setFixedHeight( 20 ); hbd->addWidget( shootLCD ); hbd->addStretch( 1 ); label = new QLabel( tr( "Fuel" ), mainWin ); label->setFont( smallFont ); label->setFixedWidth( label->sizeHint().width() + 10 ); label->setPalette( pal ); hbd->addWidget( label ); powerMeter = new KALedMeter( mainWin ); powerMeter->setFrameStyle( Q3Frame::Box | Q3Frame::Plain ); powerMeter->setRange( MAX_POWER_LEVEL ); powerMeter->addColorRange( 10, Qt::darkRed ); powerMeter->addColorRange( 20, QColor(160, 96, 0) ); powerMeter->addColorRange( 70, Qt::darkGreen ); powerMeter->setCount( 40 ); powerMeter->setPalette( pal ); powerMeter->setFixedSize( 200, 12 ); hbd->addWidget( powerMeter ); shipsRemain = 3; showHiscores = FALSE; actions.insert( Qt::Key_Up, Thrust ); actions.insert( Qt::Key_Left, RotateLeft ); actions.insert( Qt::Key_Right, RotateRight ); actions.insert( Qt::Key_Space, Shoot ); actions.insert( Qt::Key_Z, Teleport ); actions.insert( Qt::Key_X, Brake ); actions.insert( Qt::Key_S, Shield ); actions.insert( Qt::Key_P, Pause ); actions.insert( Qt::Key_L, Launch ); actions.insert( Qt::Key_N, NewGame ); view->showText( tr( "Press N to start playing" ), Qt::yellow ); }
YigMainWindow::YigMainWindow(QWidget *parent) : QWidget(parent), graphicsView(this), optionsWindow(0) { setGeometry(QApplication::desktop()->rect()); setWindowTitle( "Yig, the Father of Serpents" ); setAcceptDrops(false); //setWindowFlags(Qt::WindowStaysOnBottomHint); toolBar = new QWidget(this); toolBar->setGeometry(30, QApplication::desktop()->rect().height()-50, 574, 30); toolBar->setWindowFlags( Qt::Tool | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint); bootStatus = new QLabel(toolBar); numberOfSynths = new QLabel(toolBar); avgCPU = new QLabel(toolBar); peakCPU = new QLabel(toolBar); recordButton = new QToolButton(toolBar); connectButton = new QToolButton(toolBar); optionsButton = new QToolButton(toolBar); // QPlastiqueStyle yigStyle; /* QLinearGradient gradient(0, 0, 0, 100); gradient.setColorAt(0.0, QColor(80, 80, 80)); gradient.setColorAt(0.05, QColor(80, 80, 80)); gradient.setColorAt(0.2, QColor(44, 44, 44)); gradient.setInterpolationMode(QGradient::ColorInterpolation); QBrush backgroundBrush(gradient);*/ //backgroundBrush.setStyle(Qt::LinearGradientPattern); backgroundBrush = YigColorKit::background2; toolBar->setWindowOpacity(0.8); QPalette windowPalette = toolBar->palette(); windowPalette.setBrush(QPalette::Window, backgroundBrush); windowPalette.setColor(QPalette::WindowText, YigColorKit::focus1); toolBar->setPalette(windowPalette); // toolBar->setStyle(&yigStyle); windowPalette = palette(); windowPalette.setBrush(QPalette::Window, YigColorKit::focus1); windowPalette.setColor(QPalette::WindowText, YigColorKit::focus1); setPalette(windowPalette); // setStyle(&yigStyle); QPalette dockPalette = dock.palette(); dockPalette.setBrush(QPalette::Window, backgroundBrush); dockPalette.setColor(QPalette::WindowText, YigColorKit::focus1); dock.setPalette(dockPalette); /* #ifdef __APPLE__ dock.setStyle(new QMacStyle); #else dock.setStyle(new QGtkStyle); #endif */ QPalette labelPalette; QFont serverFont("monaco", 12); labelPalette = bootStatus->palette(); labelPalette.setColor(QPalette::WindowText, YigColorKit::focus1); labelPalette.setColor(QPalette::Text, YigColorKit::focus1); labelPalette.setColor(QPalette::Background, YigColorKit::focus2Highlight); bootStatus->setPalette(labelPalette); // bootStatus->setStyle(&yigStyle); bootStatus->setFont(serverFont); bootStatus->setGeometry(QRect(5, 2, 110, 25)); //bootStatus->setFrameStyle(QFrame::StyledPanel); bootStatus->setTextFormat(Qt::RichText); bootStatus->setText("server inactive"); QFont labelFont("monaco", 10); labelPalette.setColor(QPalette::WindowText, YigColorKit::background2); labelPalette = numberOfSynths->palette(); labelPalette.setColor(QPalette::Text, YigColorKit::focus1); numberOfSynths->setPalette(labelPalette); numberOfSynths->setGeometry(QRect(120, 2, 90, 25)); // numberOfSynths->setStyle(&yigStyle); numberOfSynths->setFont(labelFont); numberOfSynths->setText(" synths: "); //numberOfSynths->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); labelPalette = avgCPU->palette(); labelPalette.setColor(QPalette::Text, YigColorKit::focus1); avgCPU->setPalette(labelPalette); avgCPU->setGeometry(QRect(215, 2, 100, 25)); // avgCPU->setStyle(&yigStyle); avgCPU->setFont(labelFont); avgCPU->setText(" avg cpu: "); //avgCPU->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); labelPalette = peakCPU->palette(); labelPalette.setColor(QPalette::Text, YigColorKit::focus1); peakCPU->setPalette(labelPalette); peakCPU->setGeometry(QRect(320, 2, 105, 25)); // peakCPU->setStyle(&yigStyle); peakCPU->setFont(labelFont); peakCPU->setText(" peak cpu: "); //peakCPU->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); recordButton->setGeometry(430, 2, 50, 25); recordButton->setText("record"); recordButton->setStyleSheet("QToolButton{ background: #222; color: #ddd; border-radius: 0px}" "QToolButton::checked{ background: #bbb; color: #000; }" "QToolButton::hover{ background: #bbb; color: #000; }"); recordButton->setCheckable(true); QObject::connect(recordButton, SIGNAL(clicked()), this, SLOT(record())); connectButton->setGeometry(482, 2, 62, 25); connectButton->setText("connect"); connectButton->setStyleSheet("QToolButton{ background: #222; color: #ddd; border-radius: 0px}" "QToolButton::checked{ background: #bbb; color: #000; }" "QToolButton::hover{ background: #bbb; color: #000; }"); connectButton->setCheckable(true); QObject::connect(connectButton, SIGNAL(clicked()), this, SLOT(networkConnection())); optionsButton->setGeometry(546, 2, 25, 25); optionsButton->setText("+"); optionsButton->setStyleSheet("QToolButton{ background: #222; color: #ddd; border-radius: 0px}" "QToolButton::checked{ background: #bbb; color: #000; }" "QToolButton::hover{ background: #bbb; color: #000; }"); optionsButton->setCheckable(true); QObject::connect(optionsButton, SIGNAL(clicked()), this, SLOT(toggleOptionsWindow())); /* // Populate the channelArray with initialized YigNetworkChannels for(int i = 0; i < Yig::NUMBER_OF_NETWORK_CHANNELS; i++) { YigNetworkChannelView* channelView = new YigNetworkChannelView(&glWidget, this); channelView->setGeometry(QRect(0, 0,this->width(),this->height())); setCentralWidget(channelView); channelViewList.append(channelView); }*/ graphicsView.setGeometry(0, 0, width(), height() - 45); //setCentralWidget(&graphicsView); //setOnline(online); //addToolBar(Qt::TopToolBarArea, toolBar); //toolBar->setAllowedAreas(Qt::TopToolBarArea); //toolBar->setFloatable(false); //toolBar->setMovable(false); //dock.setFeatures(QDockWidget::NoDockWidgetFeatures); //dock.setWidget(toolBar); //dock.setFixedHeight(30); //addDockWidget(Qt::TopDockWidgetArea, &dock); showMaximized(); mOnline = false; networkConnection(); toolBar->show(); toolBar->raise(); //show(); }
void LWSlider::Init(wxWindow * parent, wxString name, const wxPoint &pos, const wxSize &size, float minValue, float maxValue, float stepValue, bool canUseShift, int style, bool heavyweight /* = false */ ) { mName = name; mStyle = style; mIsDragging = false; mWidth = size.x; mHeight = size.y; mParent = parent; mHW = heavyweight; mID = -1; mMinValue = minValue; mMaxValue = maxValue; mStepValue = stepValue; mCanUseShift = canUseShift; mCurrentValue = 0.0f; if (!(mWidth & 0)) mWidth--; mCenterY = mHeight - 9; wxMemoryDC *dc = new wxMemoryDC(); wxBitmap *bitmap = new wxBitmap(8, 8); dc->SelectObject(*bitmap); AColor::Medium(dc, false); wxColour bkgnd = dc->GetPen().GetColour(); AColor::Medium(dc, true); wxColour selBkgnd = dc->GetPen().GetColour(); wxImage *backgroundImage = CreateSysBackground(mWidth, mHeight, 3, bkgnd); wxBitmap backgroundBitmap = backgroundImage->ConvertToBitmap(); wxImage *thumbImage = new wxImage(wxBitmap(SliderThumb).ConvertToImage()); wxImage *thumb1 = ChangeImageColour(thumbImage, bkgnd); wxImage *thumb2 = ChangeImageColour(thumbImage, selBkgnd); mThumbBitmap = new wxBitmap(thumb1); mSelThumbBitmap = new wxBitmap(thumb2); delete thumb1; delete thumb2; delete thumbImage; delete dc; delete bitmap; mThumbWidth = mThumbBitmap->GetWidth(); mThumbHeight = mThumbBitmap->GetHeight(); mLeftX = mThumbWidth/2; mRightX = mWidth - mThumbWidth/2 - 1; mWidthX = mRightX - mLeftX; int i; for(i=0; i<2; i++) { wxBitmap *bitmap; bitmap = new wxBitmap(mWidth, mHeight); wxMemoryDC *dc = new wxMemoryDC(); dc->SelectObject(*bitmap); if (mHW) { dc->DrawBitmap(backgroundBitmap, 0, 0); } else { AColor::Medium(dc, i==1); dc->DrawRectangle(0, 0, mWidth, mHeight); } AColor::Light(dc, i==1); dc->DrawLine(mLeftX, mCenterY, mRightX+1, mCenterY); AColor::Dark(dc, i==1); dc->DrawLine(mLeftX, mCenterY+1, mRightX+1, mCenterY+1); int divs = 10; double upp = divs / (double)(mWidthX-1); double d = 0; int int_d = -1; for(int p=0; p<=mWidthX; p++) { if (((int)d) > int_d) { int_d = (int)d; int ht = (int_d==0 || int_d==divs? 5: 3); AColor::Light(dc, false); dc->DrawLine(mLeftX+p, mCenterY-ht, mLeftX+p, mCenterY); AColor::Dark(dc, false); dc->DrawLine(mLeftX+p+1, mCenterY-ht+1, mLeftX+p+1, mCenterY); } d += upp; } if (style == PAN_SLIDER) { wxFont labelFont(sliderFontSize, wxSWISS, wxNORMAL, wxNORMAL); dc->SetFont(labelFont); dc->DrawText(_T("L"), mLeftX, 1); dc->DrawText(_T("R"), mRightX-7, 1); } else { dc->SetPen(*wxBLACK_PEN); dc->DrawLine(mLeftX, mCenterY-10, mLeftX+5, mCenterY-10); dc->DrawLine(mRightX-7, mCenterY-10, mRightX-2, mCenterY-10); dc->DrawLine(mRightX-5, mCenterY-12, mRightX-5, mCenterY-7); } delete dc; if (i==0) mBitmap = bitmap; else mSelBitmap = bitmap; } delete backgroundImage; int x=mWidth/2, y=mHeight, wx, wy; wxWindow *top = mParent; while(top && !top->IsTopLevel()) { top->GetPosition(&wx, &wy); x += wx; y += wy; top = top->GetParent(); } mPopWin = NULL; Move(pos); CreatePopWin(); }
void MFCClipItemView::Draw(Graphics &dc, CRect &clipBox) { // !!!??? need to clip properly for short instances with long names cerr << "clip item draw " << item->sym->name << endl; Pen blackPen(Color(250, 0, 0, 0), 1); Pen redPen(Color(250, 238, 100, 100), 1); Pen orangePen(Color(200, 250, 150, 10), 1); SolidBrush blueBrush(Color(100, 100, 100, 238)); SolidBrush blackBrush(Color(200, 0, 0, 0)); SolidBrush orangeBrush(Color(190, 250, 150, 10)); dc.DrawLine( &orangePen, bounds.left, 0, bounds.left, bounds.bottom); bool isMarker = false; if (item != NULL && item->duration.ticks <= 0) { isMarker = true; } if (!isMarker) { dc.DrawLine( &orangePen, bounds.right, 0, bounds.right, bounds.bottom); } PointF tri[3]; Font labelFont(L"Arial", 8.0, FontStyleRegular, UnitPoint, NULL); wstring nm; const char *cp = item->sym->uniqueName(); while (*cp) { nm.push_back(*cp++); } PointF p; UINT py = 0; do { if (!isMarker) { // a triangle bit tri[0].X = bounds.left; tri[0].Y = py; tri[1].X = bounds.left+6; tri[1].Y = py+3; tri[2].X = bounds.left; tri[2].Y = py+6; dc.FillPolygon(&orangeBrush, tri, 3); } p.X = bounds.left-1; p.Y = py+5; RectF box; StringFormat sff = StringFormatFlagsDirectionVertical; dc.MeasureString(nm.c_str(), -1, &labelFont, p, &sff, &box); dc.DrawString(nm.c_str(), -1, &labelFont, box, &sff, &blackBrush); if (!isMarker) { // a nother triangle bit tri[0].X = bounds.right; tri[1].X = bounds.right-6; tri[2].X = bounds.right; dc.FillPolygon(&orangeBrush, tri, 3); p.X = bounds.right-10; p.Y = py+5; dc.MeasureString(nm.c_str(), -1, &labelFont, p, &sff, &box); dc.DrawString(nm.c_str(), -1, &labelFont, box, &sff, &blackBrush); } py += editor->bounds.bottom; } while (py < bounds.bottom); }
YigSynthGraphic::YigSynthGraphic(QString synthType, QString mapKey, const QPointF &point, float param1, float param2, int outBus, QGraphicsScene *scene) : mMapKey(mapKey), audioOutBus(outBus), selectingUser(" "), QGraphicsEllipseItem(0, 0, ELLIPSE_SIZE, ELLIPSE_SIZE, 0) { mSynthType = synthType; autoCableCounter = 0; moveBy(point.x(), point.y()); setFlag( QGraphicsItem::ItemIsSelectable, true ); setFlag( QGraphicsItem::ItemIsMovable, true ); setFlag(QGraphicsItem::ItemSendsGeometryChanges); setZValue(10); //setCacheMode(QGraphicsItem::DeviceCoordinateCache); //setAcceptsHoverEvents(true); // MOD FIELD 1 modField1 = new YigModField(this, param1, 0, 0, MOD_FIELD_SIZE, MOD_FIELD_SIZE, this); modField1->moveBy((-MOD_FIELD_SIZE/2) + (ELLIPSE_SIZE/2), (-MOD_FIELD_SIZE/2) + (ELLIPSE_SIZE/2)); modField1->setFlag( QGraphicsItem::ItemIsSelectable, true ); modField1->setFlag( QGraphicsItem::ItemIsMovable, false ); QColor outlineColor = YigColorKit::background2; pen.setColor(QColor(0, 0, 0, 25)); pen.setColor( outlineColor ); modField1->setPen( pen ); //modField1->setCacheMode(QGraphicsItem::DeviceCoordinateCache); /* QRadialGradient gradient(QPointF(MOD_FIELD_SIZE/2, MOD_FIELD_SIZE/2), MOD_FIELD_SIZE/2, QPointF(MOD_FIELD_SIZE/2, MOD_FIELD_SIZE/2)); gradient.setColorAt(0, QColor(0, 0, 0, 0)); gradient.setColorAt(0.3, QColor(0, 0, 0, 100)); gradient.setColorAt(0.75, QColor(0, 0, 0, 170)); gradient.setColorAt(1, QColor(0, 0, 0, 50)); QBrush radialBrush(gradient);*/ //modField1->setBrush( QColor(0, 0, 0, 160) ); modField1->setBrush(Qt::NoBrush); QColor modColor = YigColorKit::background2; modColor.setAlpha(150); //brush.setColor(modColor); //modField1->setBrush(QBrush(modColor)); modField1->setFlag(QGraphicsItem::ItemStacksBehindParent, true); modField1->setZValue(0); //modField1->setCacheMode( QGraphicsItem::DeviceCoordinateCache ); // MOD FIELD 2 modField2 = new YigModField2(this, param2, 0, 0, MOD_FIELD_2_SIZE, MOD_FIELD_2_SIZE, this); modField2->moveBy(((-MOD_FIELD_2_SIZE/2) + (ELLIPSE_SIZE/2)), ((-MOD_FIELD_2_SIZE/2) + (ELLIPSE_SIZE/2))); modField2->setFlag( QGraphicsItem::ItemIsSelectable, true ); modField2->setFlag( QGraphicsItem::ItemIsMovable, false ); //modField2->setPen( pen ); modField2->setPen(Qt::NoPen); /* QRadialGradient gradient2(QPointF(MOD_FIELD_2_SIZE/2, MOD_FIELD_2_SIZE/2), MOD_FIELD_2_SIZE/2, QPointF(MOD_FIELD_2_SIZE/2, MOD_FIELD_2_SIZE/2)); gradient2.setColorAt(0, QColor(255, 255, 255, 0)); gradient2.setColorAt(0.5, QColor(0, 0, 0, 0)); gradient2.setColorAt(0.7, QColor(255, 255, 255, 160)); gradient2.setColorAt(0.8, QColor(255, 255, 255, 160)); gradient2.setColorAt(0.95, QColor(255, 255, 255, 100)); gradient2.setColorAt(1, QColor(0, 0, 0, 100)); QBrush radialBrush2(gradient2); modField2->setBrush( radialBrush2 );*/ modField2->setBrush(Qt::NoBrush); //modColor = YigColorKit::focus1Highlight; //modColor.setAlpha(100); //modField2->setBrush(modColor); //modField2->setCacheMode(QGraphicsItem::DeviceCoordinateCache);; modField2->setFlag(QGraphicsItem::ItemStacksBehindParent); //modField2->setZValue(3); //modField2->setCacheMode( QGraphicsItem::DeviceCoordinateCache ); // AUDIO OUTPUT /* audioOutput = new YigEllipseItem( this, 0, 0, SMALL_ELLIPSE_SIZE, SMALL_ELLIPSE_SIZE, this ); //audioOutput->moveBy((ELLIPSE_SIZE/2) - (SMALL_ELLIPSE_SIZE/2), ELLIPSE_SIZE - SMALL_ELLIPSE_SIZE); audioOutput->moveBy(7.5 + TRI_OFFSET_X, 7.5*SQRT_THREE + TRI_OFFSET_Y); audioOutput->setFlag( QGraphicsItem::ItemIsSelectable, false ); audioOutput->setFlag( QGraphicsItem::ItemIsMovable, false ); audioOutput->setCacheMode(QGraphicsItem::DeviceCoordinateCache);*/ // AUDIO INPUT /* audioInput = new YigEllipseItem( this, 0, 0, SMALL_ELLIPSE_SIZE, SMALL_ELLIPSE_SIZE, this ); //audioInput->moveBy((ELLIPSE_SIZE/2) - (SMALL_ELLIPSE_SIZE/2), 0); audioInput->moveBy(0 + TRI_OFFSET_X, 0 + TRI_OFFSET_Y);*/ audioInput = new QGraphicsEllipseItem(0, 0, AUDIO_ELLIPSE_SIZE, AUDIO_ELLIPSE_SIZE, this); audioInput->moveBy((ELLIPSE_SIZE/2) - (AUDIO_ELLIPSE_SIZE/2), (ELLIPSE_SIZE/2) - (AUDIO_ELLIPSE_SIZE/2)); audioInput->setFlag( QGraphicsItem::ItemIsSelectable, false ); audioInput->setFlag( QGraphicsItem::ItemIsMovable, false ); //audioInput->setCacheMode(QGraphicsItem::DeviceCoordinateCache); audioInput->setZValue(20); // MOD INPUT /* modInput = new YigEllipseItem( this, 0, 0, SMALL_ELLIPSE_SIZE, SMALL_ELLIPSE_SIZE, this ); //modInput->moveBy(0, (ELLIPSE_SIZE/2) - (SMALL_ELLIPSE_SIZE/2)); modInput->moveBy(15 + TRI_OFFSET_X, 0 + TRI_OFFSET_Y);*/ modInput = new QGraphicsEllipseItem(0, 0, MOD_ELLIPSE_SIZE, MOD_ELLIPSE_SIZE, this); modInput->moveBy((ELLIPSE_SIZE/2) - (MOD_ELLIPSE_SIZE/2), (ELLIPSE_SIZE/2) - (MOD_ELLIPSE_SIZE/2)); modInput->setFlag( QGraphicsItem::ItemIsSelectable, false ); modInput->setFlag( QGraphicsItem::ItemIsMovable, false ); //modInput->setCacheMode(QGraphicsItem::DeviceCoordinateCache); modInput->setZValue(20); // Synth Label synthLabel = new QGraphicsSimpleTextItem(this); synthLabel->moveBy( ELLIPSE_SIZE + 5, ELLIPSE_SIZE/2 - 4); synthLabel->setText(synthType); //QFont labelFont("Helvetica [Cronyx]", 11); QFont labelFont("monaco", 10); synthLabel->setFont(labelFont); synthLabel->setFlag( QGraphicsItem::ItemIsSelectable, false ); synthLabel->setFlag( QGraphicsItem::ItemIsMovable, false ); //synthLabel->setPen(YigColorKit::accent); //synthLabel->setCacheMode(QGraphicsItem::DeviceCoordinateCache); synthLabel->setCacheMode(QGraphicsItem::DeviceCoordinateCache); outlineColor = QColor( 0, 0, 0, 255 ); pen.setColor( outlineColor ); audioInput->setPen(Qt::NoPen); //audioOutput->setPen(pen); modInput->setPen(Qt::NoPen); /* QRadialGradient gradient3(QPointF(ELLIPSE_SIZE/2, ELLIPSE_SIZE/2), ELLIPSE_SIZE/2, QPointF(ELLIPSE_SIZE/2, ELLIPSE_SIZE/2)); gradient3.setColorAt(0, QColor(0, 0, 0, 255)); gradient3.setColorAt(0.8, QColor(0, 0, 0, 255)); gradient3.setColorAt(1, QColor(0, 0, 0, 0));*/ //setCacheMode( QGraphicsItem::DeviceCoordinateCache ); /* QRadialGradient gradient4(QPointF(AUDIO_ELLIPSE_SIZE/2, AUDIO_ELLIPSE_SIZE/2), AUDIO_ELLIPSE_SIZE/2, QPointF(AUDIO_ELLIPSE_SIZE/2, AUDIO_ELLIPSE_SIZE/2)); gradient4.setColorAt(0, QColor(0, 0, 0, 255)); gradient4.setColorAt(0.9, QColor(33, 33, 33, 255)); gradient4.setColorAt(1, QColor(0, 0, 0, 255)); audioInput->setBrush( QBrush(gradient4) );*/ audioInput->setBrush(Qt::NoBrush); audioInput->setPen(Qt::NoPen); /* QRadialGradient gradient5(QPointF(MOD_ELLIPSE_SIZE/2, MOD_ELLIPSE_SIZE/2), MOD_ELLIPSE_SIZE/2, QPointF(MOD_ELLIPSE_SIZE/2, MOD_ELLIPSE_SIZE/2)); gradient5.setColorAt(0, YigColorKit::accent); gradient5.setColorAt(0.85, YigColorKit::accent); gradient5.setColorAt(1, QColor(0, 0, 0)); modInput->setBrush( gradient5 ); modInput->setPen(Qt::NoPen);*/ // Arrows audioInArrow = new YigSignalArrow(AUDIO_INPUT, this); //audioOutArrow = new YigSignalArrow(AUDIO_OUTPUT, this); modInArrow = new YigSignalArrow(MOD_INPUT, this); //audioInput->setCacheMode( QGraphicsItem::DeviceCoordinateCache ); //modInput->setCacheMode( QGraphicsItem::DeviceCoordinateCache ); //setCacheMode( QGraphicsItem::DeviceCoordinateCache ); audioInput->setFlag(QGraphicsItem::ItemHasNoContents); modInput->setFlag(QGraphicsItem::ItemHasNoContents); //setFlag(QGraphicsItem::ItemHasNoContents); modField1->setFlag(QGraphicsItem::ItemHasNoContents); modField2->setFlag(QGraphicsItem::ItemHasNoContents); /* audioInput->setZValue(25); QColor penColor = YigColorKit::background2; penColor.setAlpha(200); pen = QPen(penColor); pen.setWidth(2);*/ //setBrush(gradient3); setBrush(Qt::NoBrush); setPen(Qt::NoPen); scene->addItem(this); }
void LWSlider::Draw() { // // Get the thumb slider bitmap // // AD: Setting the mThumbBitmap pointer requires caution, because // ownership of the object pointed to varies. If we've allocated // mThumbBitmap we must delete it first, and we must set // mThumbBitmapAllocated according to whether we have. // if (mEnabled && mOrientation == wxHORIZONTAL) { if (mThumbBitmapAllocated) delete mThumbBitmap; mThumbBitmap = &theTheme.Bitmap( bmpSliderThumb ); mThumbBitmapAllocated = false; } //v \todo Convert this to an image in AllThemeResources, as bmpSliderThumb. Make an alpha also, as for horizontal slider thumb? else if (mOrientation == wxHORIZONTAL) { wxImage thumbImage(wxBitmap(SliderThumbDisabled).ConvertToImage()); if (mThumbBitmapAllocated) delete mThumbBitmap; mThumbBitmap = new wxBitmap(thumbImage); mThumbBitmapAllocated = true; mThumbBitmap->SetMask(new wxMask(wxBitmap(SliderThumbAlpha), *wxBLACK)); } else if (mEnabled) { wxImage thumbImage(wxBitmap(SliderThumb_Vertical).ConvertToImage()); if (mThumbBitmapAllocated) delete mThumbBitmap; mThumbBitmap = new wxBitmap(thumbImage); mThumbBitmapAllocated = true; mThumbBitmap->SetMask( new wxMask(wxBitmap(SliderThumb_VerticalAlpha), *wxBLACK)); } else { wxImage thumbImage(wxBitmap( SliderThumb_VerticalDisabled).ConvertToImage()); if (mThumbBitmapAllocated) delete mThumbBitmap; mThumbBitmap = new wxBitmap(thumbImage); mThumbBitmapAllocated = true; mThumbBitmap->SetMask( new wxMask(wxBitmap(SliderThumb_VerticalAlpha), *wxBLACK)); } // // Now the background bitmap // if( mBitmap ) { delete mBitmap; mBitmap = NULL; } if (mOrientation == wxHORIZONTAL) mCenterY = mHeight - 9; else mCenterX = mWidth - 9; mThumbWidth = mThumbBitmap->GetWidth(); mThumbHeight = mThumbBitmap->GetHeight(); if (mOrientation == wxHORIZONTAL) { mLeftX = mThumbWidth/2; mRightX = mWidth - mThumbWidth/2 - 1; mWidthX = mRightX - mLeftX; } else { mTopY = mThumbWidth/2; mBottomY = mHeight - mThumbWidth/2 - 1; mHeightY = mBottomY - mTopY; } wxMemoryDC *dc = new wxMemoryDC(); mBitmap = new wxBitmap(mWidth, mHeight); // Set background to an unused color. This allows for easy // mask creation. And garbage can be displayed if it isn't // cleared. dc->SelectObject(*mBitmap); wxColour TransparentColour = wxColour( 255, 254, 255 ); // DO-THEME Mask colour!! JC-Aug-2007 // Needed with experimental theming! // ... because windows blends against this colour. #ifdef EXPERIMENTAL_THEMING TransparentColour = theTheme.Colour( clrTrackInfo ); #endif dc->SetBackground( wxBrush( TransparentColour ) ); dc->Clear(); // Draw the line along which the thumb moves. AColor::Dark(dc, false); if (mOrientation == wxHORIZONTAL) AColor::Line(*dc, mLeftX, mCenterY+1, mRightX+2, mCenterY+1); else //v if (mStyle != DB_SLIDER) // Let the ruler do it for vertical DB_SLIDER. AColor::Line(*dc, mCenterX+1, mTopY, mCenterX+1, mBottomY+2); // Draw +/- or L/R first. We need to draw these before the tick marks. if (mStyle == PAN_SLIDER) { //v Vertical PAN_SLIDER currently not handled, forced to horizontal. // sliderFontSize is for the tooltip. // we need something smaller here... wxFont labelFont(sliderFontSize-3, wxSWISS, wxNORMAL, wxNORMAL); dc->SetFont(labelFont); // Colors #ifdef EXPERIMENTAL_THEMING dc->SetTextForeground( theTheme.Colour( clrTrackPanelText )); // TransparentColour should be same as clrTrackInfo. dc->SetTextBackground( theTheme.Colour( clrTrackInfo ) ); dc->SetBackground( theTheme.Colour( clrTrackInfo ) ); // HAVE to use solid and not transparent here, // otherwise windows will do it's clever font optimisation trick, // but against a default colour of white, which is not OK on a dark // background. dc->SetBackgroundMode( wxSOLID ); #else if (mEnabled) dc->SetTextForeground( wxColour( 0,0,0) ); else dc->SetTextForeground( wxColour(128, 128, 128)); dc->SetTextBackground( wxColour( 255,255,255)); #endif /* i18n-hint: One-letter abbreviation for Left, in the Pan slider */ dc->DrawText(_("L"), mLeftX, 0); /* i18n-hint: One-letter abbreviation for Right, in the Pan slider */ dc->DrawText(_("R"), mRightX-6,0); } else { // draw the '-' and the '+' #ifdef EXPERIMENTAL_THEMING wxPen pen( theTheme.Colour( clrTrackPanelText )); dc->SetPen( pen ); #else if (mEnabled) dc->SetPen(*wxBLACK_PEN); else dc->SetPen(wxColour(128, 128, 128)); #endif if (mOrientation == wxHORIZONTAL) { AColor::Line(*dc, mLeftX, mCenterY-10, mLeftX+4, mCenterY-10); AColor::Line(*dc, mRightX-5, mCenterY-10, mRightX-1, mCenterY-10); AColor::Line(*dc, mRightX-3, mCenterY-12, mRightX-3, mCenterY-8); } else { // Vertical DB_SLIDER is for gain slider in MixerBoard. // We use a Ruler instead of marks & ticks. // Draw '+' and '-' only for other vertical sliders. if (mStyle != DB_SLIDER) { AColor::Line(*dc, mCenterX-12, mBottomY-3, mCenterX-8, mBottomY-3); AColor::Line(*dc, mCenterX-12, mTopY+3, mCenterX-8, mTopY+3); AColor::Line(*dc, mCenterX-10, mTopY, mCenterX-10, mTopY+5); } } } //v 20090820: Ruler doesn't align with slider correctly -- yet. //if ((mOrientation == wxVERTICAL) && (mStyle == DB_SLIDER)) //{ // if (!mpRuler) // { // mpRuler = new Ruler(); // mpRuler->mbTicksOnly = false; // mpRuler->mbTicksAtExtremes = true; // #ifdef __WXMSW__ // const int kFontSize = 8; // #else // const int kFontSize = 10; // #endif // wxFont rulerFont(kFontSize, wxSWISS, wxNORMAL, wxNORMAL); // mpRuler->SetFonts(rulerFont, rulerFont, rulerFont); // mpRuler->SetFlip(false); // mpRuler->SetLabelEdges(true); // mpRuler->SetOrientation(wxVERTICAL); // mpRuler->SetRange(mMaxValue, mMinValue); // mpRuler->SetFormat(Ruler::LinearDBFormat); // } // mpRuler->SetBounds(mLeft, mTop, mWidth, mHeightY); //v Why the magic number reqd on height to get it to line up? + 9); // mpRuler->Draw(*dc); //} //else { // tick marks int divs = 10; double upp; if (mOrientation == wxHORIZONTAL) upp = divs / (double)(mWidthX-1); else { if (mStyle == DB_SLIDER) divs = mMaxValue - mMinValue + 1; upp = divs / (double)(mHeightY-1); } double d = 0.0; int int_d = -1; const int kMax = (mOrientation == wxHORIZONTAL) ? mWidthX : mHeightY; for(int p = 0; p <= kMax; p++) { if (((int)d) > int_d) { int_d = (int)d; int tickLength = ((int_d == 0) || (int_d == divs)) ? 5: 3; // longer ticks at extremes AColor::Light(dc, false); if (mOrientation == wxHORIZONTAL) AColor::Line(*dc, mLeftX+p, mCenterY-tickLength, mLeftX+p, mCenterY-1); // ticks above else AColor::Line(*dc, mCenterX-tickLength, mTopY+p, mCenterX-1, mTopY+p); // ticks at left AColor::Dark(dc, false); if (mOrientation == wxHORIZONTAL) AColor::Line(*dc, mLeftX+p+1, mCenterY-tickLength+1, mLeftX+p+1, mCenterY-1); // ticks above else AColor::Line(*dc, mCenterX-tickLength+1, mTopY+p+1, mCenterX-1, mTopY+p+1); // ticks at left } d += upp; } } // Must preceed creating the mask as that will attempt to // select the bitmap into another DC. delete dc; mBitmap->SetMask( new wxMask( *mBitmap, TransparentColour ) ); }
void LuminanceRangeWidget::paintEvent( QPaintEvent *pe ) { { QPainter p( this ); QRect fRect = getPaintRect(); if( fRect.width() < 50 ) // Does not make sense to paint anything return; // Paint range window { int x1, x2; x1 = getWindowX( draggedMin() ); x2 = getWindowX( draggedMax() ); QColor selectionColor = mouseDragStart == DRAGNOTSTARTED ? QColor( 0, 100, 255 ) : QColor( 0, 150, 255 ); p.fillRect( x1, fRect.top(), x2-x1, fRect.height(), QBrush( selectionColor ) ); } // Paint histogram if( histogramImage != NULL ) { if( histogram == NULL || histogram->getBins() != fRect.width() ) { delete histogram; // Build histogram from at least 5000 pixels int accuracy = histogramImage->getRows()*histogramImage->getCols()/5000; if( accuracy < 1 ) accuracy = 1; histogram = new Histogram( fRect.width(), accuracy ); histogram->computeLog( histogramImage, minValue, maxValue ); } float maxP = histogram->getMaxP(); int i = 0; p.setPen( Qt::green ); for( int x = fRect.left(); i < histogram->getBins(); x++, i++ ) { if( histogram->getP(i) > 0 ) { int barSize = (int)((float)fRect.height() * histogram->getP(i)/maxP); p.drawLine( x, fRect.bottom(), x, fRect.bottom() - barSize ); } } } // Paint scale QFont labelFont( "SansSerif", 8 ); p.setFont( labelFont ); p.setPen( Qt::black ); QRect textBounding = p.boundingRect( fRect, Qt::AlignHCenter|Qt::AlignBottom, "-8" ); for( float x = ceil( minValue ); x <= floor( maxValue ); x++ ) { int rx = getWindowX(x); p.drawLine( rx, fRect.top(), rx, textBounding.top() ); char str[10]; sprintf( str, "%g", x ); p.drawText( rx-20, textBounding.top(), 40, textBounding.height(), Qt::AlignHCenter|Qt::AlignBottom, str ); } // Paint value pointer if( showVP ) { int x = getWindowX( valuePointer ); if( fRect.contains( x, fRect.y() ) ) { p.setPen( Qt::yellow ); p.drawLine( x, fRect.top(), x, fRect.bottom() ); } } } QFrame::paintEvent(pe); }