bool ScrollView::_scroll(const boo::SScrollDelta& scroll) { if (m_contentView.m_view) { float ratioX = subRect().size[0] / float(m_contentView.m_view->nominalWidth()); float ratioY = subRect().size[1] / float(m_contentView.m_view->nominalHeight()); float pf = rootView().viewRes().pixelFactor(); double mult = 20.0 * pf; if (scroll.isFine) mult = 1.0 * pf; bool ret = false; if (ratioX >= 1.f) { m_scroll[0] = 0; m_targetScroll[0] = 0; m_drawSideButtons = false; ret = true; } else { m_drawSideButtons = true; m_targetScroll[0] += scroll.delta[0] * mult; m_targetScroll[0] = std::min(m_targetScroll[0], 0); int scrollWidth = m_contentView.m_view->nominalWidth() - scrollAreaWidth(); m_targetScroll[0] = std::max(m_targetScroll[0], -scrollWidth); } if (ratioY >= 1.f) { m_scroll[1] = 0; m_targetScroll[1] = 0; ret = true; } else { m_targetScroll[1] -= scroll.delta[1] * mult; m_targetScroll[1] = std::max(m_targetScroll[1], 0); int scrollHeight = m_contentView.m_view->nominalHeight() - subRect().size[1]; m_targetScroll[1] = std::min(m_targetScroll[1], scrollHeight); } if (scroll.isFine) { m_scroll[0] = m_targetScroll[0]; m_scroll[1] = m_targetScroll[1]; ret = true; } return ret; } else { m_scroll[0] = 0; m_scroll[1] = 0; m_targetScroll[0] = 0; m_targetScroll[1] = 0; m_drawSideButtons = false; return true; } return false; }
void ClipBitmapStyleEditor::UpdateSubBitmapRect() { wxRect subRect(0, 0, 0, 0); m_TotalSize.x = 0; m_TotalSize.y = 0; wxSize defaultPieceSize(Config::DEFAULT_PIECE_SIZE, Config::DEFAULT_PIECE_SIZE); for (int i = 0; i < IStyle::SS_NUM; ++i) { wxSize pieceSize = defaultPieceSize; if (m_pClipBitmapStyle) { const PieceInfo* pPieceInfo = m_pClipBitmapStyle->GetStatePiece((IStyle::STYLE_STATE)i); if (!pPieceInfo) pPieceInfo = m_pClipBitmapStyle->GetStatePiece(IStyle::SS_NORMAL); if (pPieceInfo) pieceSize = pPieceInfo->GetRect().GetSize(); } subRect.width = pieceSize.x; subRect.height = pieceSize.y; m_rectState[i] = subRect; subRect.y += pieceSize.y; if (m_TotalSize.x < pieceSize.x) m_TotalSize.x = pieceSize.x; m_TotalSize.y += pieceSize.y; } }
void adoptRightClickMenu(std::unique_ptr<View>&& menu, const boo::SWindowCoord& coord) { m_rightClickMenu.m_view = std::move(menu); m_rightClickMenuRootAndLoc = subRect(); m_rightClickMenuRootAndLoc.location[0] = coord.pixel[0]; m_rightClickMenuRootAndLoc.location[1] = coord.pixel[1]; updateSize(); }
int ScrollView::scrollAreaWidth() const { int ret = subRect().size[0]; if (m_style == Style::SideButtons && m_drawSideButtons) { ret -= m_sideButtons[0].m_view->nominalWidth(); ret -= m_sideButtons[1].m_view->nominalWidth(); } return std::max(0, ret); }
void Animation::RecomputeSubRect() { assert(GetImage()); float width = GetImage()->GetWidth() / column_; float height = GetImage()->GetHeight() / row_; float x = width * (curFrame_ % column_); float y = height * (curFrame_ % row_); IntRect subRect(x, y, x + width, y + height); SetSubRect(subRect); }
// static ImageArray ImageRoll::SplitH(const wxImage &src, wxColour magicColor) { ImageArray result; int width = src.GetWidth(); int height = src.GetHeight(); unsigned char *data = src.GetData(); unsigned char *ptr = data; unsigned char magicRed = magicColor.Red(); unsigned char magicGreen = magicColor.Green(); unsigned char magicBlue = magicColor.Blue(); bool cur, prev; int i, j, start; // Sanity check... if (width<=0 || height<=0 || data==NULL) return result; prev = false; start = 0; for(i=0; i<width+1; i++) { if (i < width) { unsigned char *ptr2 = ptr; cur = true; for(j=0; j<height && cur; j++) { if (!(ptr2[0] == magicRed && ptr2[1] == magicGreen && ptr2[2] == magicBlue)) cur = false; ptr2 += 3 * width; } } else cur = !prev; if ((cur && !prev)) { wxRect subRect(start, 0, i-start, height); wxImage subImage; if (subRect.width > 0) subImage = src.GetSubImage(subRect); else subImage = wxImage(subRect.width, subRect.height); result.Add(subImage); } else if (!cur && prev) { start = i; } prev = cur; ptr += 3; } return result; }
QModelIndex PartitionBarsView::indexAt( const QPoint &point, const QRect &rect, const QModelIndex& parent ) const { PartitionModel* modl = qobject_cast< PartitionModel* >( model() ); if ( !modl ) return QModelIndex(); const int totalWidth = rect.width(); auto pair = computeItemsVector( parent ); QVector< PartitionBarsView::Item >& items = pair.first; qreal& total = pair.second; int x = rect.x(); for ( int row = 0; row < items.count(); ++row ) { const auto& item = items[ row ]; int width; if ( row < items.count() - 1 ) width = totalWidth * ( item.size / total ); else // Make sure we fill the last pixel column width = rect.right() - x + 1; QRect thisItemRect( x, rect.y(), width, rect.height() ); if ( thisItemRect.contains( point ) ) { if ( m_nestedPartitionsMode == DrawNestedPartitions && modl->hasChildren( item.index ) ) { QRect subRect( x + EXTENDED_PARTITION_MARGIN, rect.y() + EXTENDED_PARTITION_MARGIN, width - 2 * EXTENDED_PARTITION_MARGIN, rect.height() - 2 * EXTENDED_PARTITION_MARGIN ); if ( subRect.contains( point ) ) { return indexAt( point, subRect, item.index ); } return item.index; } else // contains but no children, we win { return item.index; } } x += width; } return QModelIndex(); }
void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap) { int16 subRectX = 0; int16 subRectY = 0; // Take care of negative destinations if (destinationX < 0) { subRectX = -destinationX; destinationX = 0; } else if (destinationX >= surface.w) { // Take care of extreme positive destinations destinationX -= surface.w; } // Take care of negative destinations if (destinationY < 0) { subRectY = -destinationY; destinationY = 0; } else if (destinationY >= surface.h) { // Take care of extreme positive destinations destinationY -= surface.h; } if (wrap) { _backgroundWidth = surface.w; _backgroundHeight = surface.h; if (destinationX > 0) { // Move destinationX to 0 subRectX = surface.w - destinationX; destinationX = 0; } if (destinationY > 0) { // Move destinationY to 0 subRectY = surface.h - destinationY; destinationY = 0; } } // Clip subRect to working window bounds Common::Rect subRect(subRectX, subRectY, subRectX + _workingWidth, subRectY + _workingHeight); if (!wrap) { // Clip to image bounds subRect.clip(surface.w, surface.h); } // Check destRect for validity if (!subRect.isValidRect() || subRect.isEmpty()) return; copyRectToWorkingWindow((const uint16 *)surface.getBasePtr(subRect.left, subRect.top), destinationX, destinationY, surface.w, subRect.width(), subRect.height()); }
QRect PartitionBarsView::visualRect( const QModelIndex& index, const QRect& rect, const QModelIndex& parent ) const { PartitionModel* modl = qobject_cast< PartitionModel* >( model() ); if ( !modl ) return QRect(); const int totalWidth = rect.width(); auto pair = computeItemsVector( parent ); QVector< PartitionBarsView::Item >& items = pair.first; qreal& total = pair.second; int x = rect.x(); for ( int row = 0; row < items.count(); ++row ) { const auto& item = items[ row ]; int width; if ( row < items.count() - 1 ) width = totalWidth * ( item.size / total ); else // Make sure we fill the last pixel column width = rect.right() - x + 1; QRect thisItemRect( x, rect.y(), width, rect.height() ); if ( item.index == index ) return thisItemRect; if ( m_nestedPartitionsMode == DrawNestedPartitions && modl->hasChildren( item.index ) && index.parent() == item.index ) { QRect subRect( x + EXTENDED_PARTITION_MARGIN, rect.y() + EXTENDED_PARTITION_MARGIN, width - 2 * EXTENDED_PARTITION_MARGIN, rect.height() - 2 * EXTENDED_PARTITION_MARGIN ); QRect candidateVisualRect = visualRect( index, subRect, item.index ); if ( !candidateVisualRect.isNull() ) return candidateVisualRect; } x += width; } return QRect(); }
void PartitionBarsView::drawPartitions( QPainter* painter, const QRect& rect, const QModelIndex& parent ) { PartitionModel* modl = qobject_cast< PartitionModel* >( model() ); if ( !modl ) return; const int totalWidth = rect.width(); auto pair = computeItemsVector( parent ); QVector< PartitionBarsView::Item >& items = pair.first; qreal& total = pair.second; int x = rect.x(); for ( int row = 0; row < items.count(); ++row ) { const auto& item = items[ row ]; int width; if ( row < items.count() - 1 ) width = totalWidth * ( item.size / total ); else // Make sure we fill the last pixel column width = rect.right() - x + 1; drawSection( painter, rect, x, width, item.index ); if ( m_nestedPartitionsMode == DrawNestedPartitions && modl->hasChildren( item.index ) ) { QRect subRect( x + EXTENDED_PARTITION_MARGIN, rect.y() + EXTENDED_PARTITION_MARGIN, width - 2 * EXTENDED_PARTITION_MARGIN, rect.height() - 2 * EXTENDED_PARTITION_MARGIN ); drawPartitions( painter, subRect, item.index ); } x += width; } if ( !items.count() && !modl->device()->partitionTable() ) // No disklabel or unknown { int width = rect.right() - rect.x() + 1; drawSection( painter, rect, rect.x(), width, QModelIndex() ); } }
void SplashScreen::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub) { ModalWindow::resized(root, sub); float pf = rootView().viewRes().pixelFactor(); boo::SWindowRect centerRect = subRect(); centerRect.location[0] = root.size[0] / 2 - (SPLASH_WIDTH * pf / 2.0); centerRect.location[1] = root.size[1] / 2 - (SPLASH_HEIGHT * pf / 2.0); boo::SWindowRect textRect = centerRect; textRect.location[0] += TEXT_MARGIN * pf; textRect.location[1] += (SPLASH_HEIGHT - 36) * pf; if (m_title) { m_title->resized(root, textRect); textRect.location[0] = centerRect.location[0] + (SPLASH_WIDTH - TEXT_MARGIN) * pf; textRect.location[1] -= 5 * pf; m_buildInfo->resized(root, textRect); textRect.size[0] = m_newButt.m_view->nominalWidth(); textRect.size[1] = m_newButt.m_view->nominalHeight(); textRect.location[1] = centerRect.location[1] + 20 * pf; textRect.location[0] = centerRect.location[0] + SPLASH_WIDTH / 4 * pf - m_newButt.m_view->nominalWidth() / 2; m_newButt.m_view->resized(root, textRect); textRect.size[0] = m_openButt.m_view->nominalWidth(); textRect.size[1] = m_openButt.m_view->nominalHeight(); textRect.location[1] = centerRect.location[1] + 20 * pf; textRect.location[0] = centerRect.location[0] + SPLASH_WIDTH * 2 / 4 * pf - m_openButt.m_view->nominalWidth() / 2; m_openButt.m_view->resized(root, textRect); textRect.size[0] = m_extractButt.m_view->nominalWidth(); textRect.size[1] = m_extractButt.m_view->nominalHeight(); textRect.location[1] = centerRect.location[1] + 20 * pf; textRect.location[0] = centerRect.location[0] + SPLASH_WIDTH * 3 / 4 * pf - m_extractButt.m_view->nominalWidth() / 2; m_extractButt.m_view->resized(root, textRect); } if (m_fileBrowser.m_view) m_fileBrowser.m_view->resized(root, root); }
void Menu::ContentView::setHighlightedItem(size_t idx) { if (idx == -1) { m_highlightedItem = -1; return; } ViewChild<std::unique_ptr<ItemView>>& vc = m_menu.m_items[idx]; if (!vc.m_view) { m_highlightedItem = -1; return; } m_highlightedItem = idx; const boo::SWindowRect& bgRect = subRect(); const boo::SWindowRect& itemRect = vc.m_view->subRect(); int y = itemRect.location[1] - bgRect.location[1]; m_hlVerts[0].m_pos.assign(0, y + itemRect.size[1], 0); m_hlVerts[1].m_pos.assign(0, y, 0); m_hlVerts[2].m_pos.assign(itemRect.size[0], y + itemRect.size[1], 0); m_hlVerts[3].m_pos.assign(itemRect.size[0], y, 0); m_hlVertsBinding.load<decltype(m_hlVerts)>(m_hlVerts); }
void HexTileDecoder::decode(RfbInputGate *input, FrameBuffer *framebuffer, const Rect *dstRect) { // shorcut const int bytesPerPixel = framebuffer->getBytesPerPixel(); UINT32 background = 0; UINT32 foreground = 0; bool backgroundAccepted = false; for (int y = dstRect->top; y < dstRect->bottom; y += TILE_SIZE) for (int x = dstRect->left; x < dstRect->right; x += TILE_SIZE) { Rect tileRect(x, y, min(x + TILE_SIZE, dstRect->right), min(y + TILE_SIZE, dstRect->bottom)); if (!framebuffer->getDimension().getRect().intersection(&tileRect).isEqualTo(&tileRect)) throw Exception(_T("Error in protocol: incorrect size of tile in hextile-decoder")); UINT8 flags = input->readUInt8(); if (flags & 0x1) { for (int y = tileRect.top; y < tileRect.bottom; y++) input->readFully(framebuffer->getBufferPtr(tileRect.left, y), tileRect.getWidth() * bytesPerPixel); } else { if (flags & 0x2) { input->readFully(&background, bytesPerPixel); backgroundAccepted = true; } if (backgroundAccepted) framebuffer->fillRect(&tileRect, background); if (flags & 0x4) input->readFully(&foreground, bytesPerPixel); if (flags & 0x8) { UINT8 numberOfSubrectangles = input->readUInt8(); for (int i = 0; i < numberOfSubrectangles; i++) { if (flags & 0x10 && !(flags & 0x4)) input->readFully(&foreground, bytesPerPixel); UINT8 xy = input->readUInt8(); UINT8 wh = input->readUInt8(); int x = (xy >> 4) & 0xF; int y = xy & 0xF; int w = ((wh >> 4) & 0xF) + 1; int h = (wh & 0xF) + 1; Rect subRect(x, y, x + w, y + h); subRect.move(tileRect.left, tileRect.top); framebuffer->fillRect(&subRect, foreground); } } else { // exist subrect if (!backgroundAccepted) throw Exception(_T("Server error in HexTile encoding: background color not accepted")); } } // not raw
void ColorStepView::Draw(BRect updateRect) { BView *view = NULL; if(fOffScreenView){ view = fOffScreenView; } else{ view = this; } if (!fOffScreenBitmap || !fOffScreenBitmap->Lock()) return; view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); view->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); view->FillRect(updateRect); BRect colorBarRect = fSlider->BarFrame(); colorBarRect.top = 0; colorBarRect.bottom = kColorBarHeight; colorBarRect.OffsetTo(colorBarRect.left, fSlider->Frame().bottom); float pos = 0.0; for (int i = fPerformanceList->CountItems() - 1; i >= 0 ; i--) { performance_step* perfState = fPerformanceList->ItemAt(i); float nextPos = perfState->cpu_usage; float width = colorBarRect.Width(); BRect subRect(colorBarRect); subRect.left += pos * width; subRect.right = colorBarRect.left + nextPos * width; view->SetHighColor(perfState->color); view->FillRect(subRect); pos = nextPos; } // draw label if (IsEnabled()) { view->SetHighColor(0, 0, 0); } else { view->SetHighColor(tint_color(LowColor(), B_DISABLED_LABEL_TINT)); } font_height fontHeight; GetFontHeight(&fontHeight); float totalFontHeight = fontHeight.descent + fontHeight.ascent; view->DrawString(fMinFrequencyLabel.String(), BPoint(0.0, colorBarRect.bottom + totalFontHeight + 5)); view->DrawString(fMaxFrequencyLabel.String(), BPoint(Bounds().right - StringWidth(fMaxFrequencyLabel.String()), colorBarRect.bottom + totalFontHeight + 5)); // blit bitmap view->Sync(); fOffScreenBitmap->Unlock(); DrawBitmap(fOffScreenBitmap, B_ORIGIN); BView::Draw(updateRect); }
/*!\reimp */ void QPlatinumStyle::drawControl( ControlElement element, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags how, const QStyleOption& opt ) const { switch( element ) { case CE_PushButton: { #ifndef QT_NO_PUSHBUTTON QColorGroup myCg( cg ); const QPushButton *btn; int x1, y1, x2, y2; bool useBevelButton; SFlags flags; flags = Style_Default; btn = (const QPushButton*)widget; p->setBrushOrigin( -widget->backgroundOffset().x(), -widget->backgroundOffset().y() ); // take care of the flags based on what we know... if ( btn->isDown() ) flags |= Style_Down; if ( btn->isOn() ) flags |= Style_On; if ( btn->isEnabled() ) flags |= Style_Enabled; if ( btn->isDefault() ) flags |= Style_Default; if (! btn->isFlat() && !(flags & Style_Down)) flags |= Style_Raised; r.coords( &x1, &y1, &x2, &y2 ); p->setPen( cg.foreground() ); p->setBrush( QBrush(cg.button(), NoBrush) ); QBrush fill; if ( btn->isDown() ) { fill = cg.brush( QColorGroup::Dark ); // this could be done differently, but this // makes a down Bezel drawn correctly... myCg.setBrush( QColorGroup::Mid, fill ); } else if ( btn->isOn() ) { fill = QBrush( cg.mid(), Dense4Pattern ); myCg.setBrush( QColorGroup::Mid, fill ); } // to quote the old QPlatinumStlye drawPushButton... // small or square image buttons as well as toggle buttons are // bevel buttons (what a heuristic....) if ( btn->isToggleButton() || ( btn->pixmap() && (btn->width() * btn->height() < 1600 || QABS( btn->width() - btn->height()) < 10 )) ) useBevelButton = TRUE; else useBevelButton = FALSE; int diw = pixelMetric( PM_ButtonDefaultIndicator, widget ); if ( btn->isDefault() ) { x1 += 1; y1 += 1; x2 -= 1; y2 -= 1; QColorGroup cg2( myCg ); SFlags myFlags = flags; // don't draw the default button sunken, unless it's necessary. if ( myFlags & Style_Down ) myFlags ^= Style_Down; if ( myFlags & Style_Sunken ) myFlags ^= Style_Sunken; cg2.setColor( QColorGroup::Button, cg.mid() ); if ( useBevelButton ) { drawPrimitive( PE_ButtonBevel, p, QRect( x1, y1, x2 - x1 + 1, y2 - y1 + 1 ), myCg, myFlags, opt ); } else { drawPrimitive( PE_ButtonCommand, p, QRect( x1, y1, x2 - x1 + 1, y2 - y1 + 1 ), cg2, myFlags, opt ); } } if ( btn->isDefault() || btn->autoDefault() ) { x1 += diw; y1 += diw; x2 -= diw; y2 -= diw; } if ( !btn->isFlat() || btn->isOn() || btn->isDown() ) { if ( useBevelButton ) { // fix for toggle buttons... if ( flags & (Style_Down | Style_On) ) flags |= Style_Sunken; drawPrimitive( PE_ButtonBevel, p, QRect( x1, y1, x2 - x1 + 1, y2 - y1 + 1 ), myCg, flags, opt ); } else { drawPrimitive( PE_ButtonCommand, p, QRect( x1, y1, x2 - x1 + 1, y2 - y1 + 1 ), myCg, flags, opt ); } } if ( p->brush().style() != NoBrush ) p->setBrush( NoBrush ); break; #endif } case CE_PushButtonLabel: { #ifndef QT_NO_PUSHBUTTON const QPushButton *btn; bool on; int x, y, w, h; SFlags flags; flags = Style_Default; btn = (const QPushButton*)widget; on = btn->isDown() || btn->isOn(); r.rect( &x, &y, &w, &h ); if ( btn->isMenuButton() ) { int dx = pixelMetric( PM_MenuButtonIndicator, widget ); QColorGroup g = cg; int xx = x + w - dx - 4; int yy = y - 3; int hh = h + 6; if ( !on ) { p->setPen( g.mid() ); p->drawLine( xx, yy + 2, xx, yy + hh - 3 ); p->setPen( g.button() ); p->drawLine( xx + 1, yy + 1, xx + 1, yy + hh - 2 ); p->setPen( g.light() ); p->drawLine( xx + 2, yy + 2, xx + 2, yy + hh - 2 ); } if ( btn->isEnabled() ) flags |= Style_Enabled; drawPrimitive( PE_ArrowDown, p, QRect(x + w - dx - 1, y + 2, dx, h - 4), g, flags, opt ); w -= dx; } #ifndef QT_NO_ICONSET if ( btn->iconSet() && !btn->iconSet()->isNull() ) { QIconSet::Mode mode = btn->isEnabled() ? QIconSet::Normal : QIconSet::Disabled; if ( mode == QIconSet::Normal && btn->hasFocus() ) mode = QIconSet::Active; QIconSet::State state = QIconSet::Off; if ( btn->isToggleButton() && btn->isOn() ) state = QIconSet::On; QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode, state ); int pixw = pixmap.width(); int pixh = pixmap.height(); p->drawPixmap( x + 2, y + h / 2 - pixh / 2, pixmap ); x += pixw + 4; w -= pixw + 4; } #endif drawItem( p, QRect( x, y, w, h ), AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), btn->pixmap(), btn->text(), -1, on ? &btn->colorGroup().brightText() : &btn->colorGroup().buttonText() ); if ( btn->hasFocus() ) drawPrimitive( PE_FocusRect, p, subRect(SR_PushButtonFocusRect, widget), cg, flags ); break; #endif } default: QWindowsStyle::drawControl( element, p, widget, r, cg, how, opt ); break; } }
void CGUIContextMenu::recalculateSize() { IGUIFont* font = Environment->getSkin()->getFont(EGDF_MENU); if (!font) return; core::rect<s32> rect; rect.UpperLeftCorner = RelativeRect.UpperLeftCorner; u32 width = 100; u32 height = 3; u32 i; for (i=0; i<Items.size(); ++i) { if (Items[i].IsSeparator) { Items[i].Dim.Width = 100; Items[i].Dim.Height = 10; } else { Items[i].Dim = font->getDimension(Items[i].Text.c_str()); Items[i].Dim.Width += 40; if (Items[i].Dim.Width > width) width = Items[i].Dim.Width; } Items[i].PosY = height; height += Items[i].Dim.Height; } height += 5; if (height < 10) height = 10; rect.LowerRightCorner.X = RelativeRect.UpperLeftCorner.X + width; rect.LowerRightCorner.Y = RelativeRect.UpperLeftCorner.Y + height; setRelativePosition(rect); // recalculate submenus for (i=0; i<Items.size(); ++i) { if (Items[i].SubMenu) { // move submenu const s32 w = Items[i].SubMenu->getAbsolutePosition().getWidth(); const s32 h = Items[i].SubMenu->getAbsolutePosition().getHeight(); core::rect<s32> subRect(width-5, Items[i].PosY, width+w-5, Items[i].PosY+h); // if it would be drawn beyond the right border, then add it to the left side gui::IGUIElement * root = Environment->getRootGUIElement(); if ( root ) { core::rect<s32> rectRoot( root->getAbsolutePosition() ); if ( getAbsolutePosition().UpperLeftCorner.X+subRect.LowerRightCorner.X > rectRoot.LowerRightCorner.X ) { subRect.UpperLeftCorner.X = -w; subRect.LowerRightCorner.X = 0; } } Items[i].SubMenu->setRelativePosition(subRect); } } }
/*!\reimp */ void QPlatinumStyle::drawComplexControl( ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags how, SCFlags sub, SCFlags subActive, const QStyleOption& opt ) const { switch ( control ) { case CC_ComboBox: { int x, y, w, h; r.rect( &x, &y, &w, &h ); p->fillRect( x + 2, y + 2, w - 4, h - 4, cg.brush(QColorGroup::Button) ); // the bright side p->setPen(cg.shadow()); p->drawLine( x, y, x + w - 1, y ); p->drawLine( x, y, x, y + h - 1 ); p->setPen( cg.light() ); p->drawLine( x + 1, y + 1, x + w - 2, y + 1 ); p->drawLine( x + 1, y + 1, x + 1, y + h - 2 ); // the dark side! p->setPen( cg.mid() ); p->drawLine( x + 2, y + h - 2, x + w - 2, y + h - 2 ); p->drawLine( x + w - 2, y + 2, x + w - 2, y + h - 2 ); p->setPen (cg.shadow() ); p->drawLine( x + 1, y + h - 1, x + w - 1, y + h - 1 ); p->drawLine( x + w - 1, y, x + w - 1, y + h - 1 ); // top left corner: p->setPen( cg.background() ); p->drawPoint( x, y ); p->drawPoint( x + 1, y ); p->drawPoint( x, y + 1 ); p->setPen( cg.shadow() ); p->drawPoint( x + 1, y + 1 ); p->setPen( white ); p->drawPoint( x + 3, y + 3 ); // bottom left corner: p->setPen( cg.background() ); p->drawPoint( x, y + h - 1 ); p->drawPoint( x + 1, y + h - 1 ); p->drawPoint( x, y + h - 2 ); p->setPen( cg.shadow() ); p->drawPoint( x + 1, y + h - 2 ); // top right corner: p->setPen( cg.background() ); p->drawPoint( x + w - 1, y ); p->drawPoint( x + w - 2, y ); p->drawPoint( x + w - 1, y + 1 ); p->setPen( cg.shadow() ); p->drawPoint( x + w - 2, y + 1 ); // bottom right corner: p->setPen( cg.background() ); p->drawPoint( x + w - 1, y + h - 1 ); p->drawPoint( x + w - 2, y + h - 1 ); p->drawPoint( x + w - 1, y + h - 2 ); p->setPen( cg.shadow() ); p->drawPoint( x + w - 2, y + h - 2 ); p->setPen( cg.dark() ); p->drawPoint( x + w - 3, y + h - 3 ); if ( sub & SC_ComboBoxArrow ) { QRect rTmp = querySubControlMetrics( CC_ComboBox, widget, SC_ComboBoxArrow, opt ); int xx = rTmp.x(), yy = rTmp.y(), ww = rTmp.width(), hh = rTmp.height(); // the bright side p->setPen( cg.mid() ); p->drawLine( xx, yy+2, xx, yy+hh-3 ); p->setPen( cg.button() ); p->drawLine( xx+1, yy+1, xx+ww-2, yy+1 ); p->drawLine( xx+1, yy+1, xx+1, yy+hh-2 ); p->setPen( cg.light() ); p->drawLine( xx+2, yy+2, xx+2, yy+hh-2 ); p->drawLine( xx+2, yy+2, xx+ww-2, yy+2 ); // the dark side! p->setPen( cg.mid() ); p->drawLine( xx+3, yy+hh-3 ,xx+ww-3, yy+hh-3 ); p->drawLine( xx+ww-3, yy+3, xx+ww-3, yy+hh-3 ); p->setPen( cg.dark() ); p->drawLine( xx+2, yy+hh-2 ,xx+ww-2, yy+hh-2 ); p->drawLine( xx+ww-2, yy+2, xx+ww-2, yy+hh-2 ); p->setPen( cg.shadow() ); p->drawLine( xx+1, yy+hh-1,xx+ww-1, yy+hh-1 ); p->drawLine( xx+ww-1, yy, xx+ww-1, yy+hh-1 ); // top right corner: p->setPen( cg.background() ); p->drawPoint( xx + ww - 1, yy ); p->drawPoint( xx + ww - 2, yy ); p->drawPoint( xx + ww - 1, yy + 1 ); p->setPen( cg.shadow() ); p->drawPoint( xx + ww - 2, yy + 1 ); // bottom right corner: p->setPen( cg.background() ); p->drawPoint( xx + ww - 1, yy + hh - 1 ); p->drawPoint( xx + ww - 2, yy + hh - 1 ); p->drawPoint( xx + ww - 1, yy + hh - 2 ); p->setPen( cg.shadow() ); p->drawPoint( xx + ww - 2, yy + hh - 2 ); p->setPen( cg.dark() ); p->drawPoint( xx + ww - 3, yy + hh - 3 ); p->setPen( cg.mid() ); p->drawPoint( xx + ww - 4, yy + hh - 4 ); // and the arrows p->setPen( cg.foreground() ); QPointArray a ; a.setPoints( 7, -3,1, 3,1, -2,0, 2,0, -1,-1, 1,-1, 0,-2 ); a.translate( xx + ww / 2, yy + hh / 2 - 3 ); p->drawLineSegments( a, 0, 3 ); // draw arrow p->drawPoint( a[6] ); a.setPoints( 7, -3,-1, 3,-1, -2,0, 2,0, -1,1, 1,1, 0,2 ); a.translate( xx + ww / 2, yy + hh / 2 + 2 ); p->drawLineSegments( a, 0, 3 ); // draw arrow p->drawPoint( a[6] ); } #ifndef QT_NO_COMBOBOX if ( sub & SC_ComboBoxEditField ) { const QComboBox *cmb; cmb = (const QComboBox*)widget; // sadly this is pretty much the windows code, except // for the first fillRect call... QRect re = QStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget, SC_ComboBoxEditField ), widget ); if ( cmb->hasFocus() && !cmb->editable() ) p->fillRect( re.x() + 1, re.y() + 1, re.width() - 2, re.height() - 2, cg.brush( QColorGroup::Highlight ) ); if ( cmb->hasFocus() ) { p->setPen( cg.highlightedText() ); p->setBackgroundColor( cg.highlight() ); } else { p->setPen( cg.text() ); p->setBackgroundColor( cg.background() ); } if ( cmb->hasFocus() && !cmb->editable() ) { QRect re = QStyle::visualRect( subRect( SR_ComboBoxFocusRect, cmb ), widget ); drawPrimitive( PE_FocusRect, p, re, cg, Style_FocusAtBorder, QStyleOption(cg.highlight())); } if ( cmb->editable() ) { // need this for the moment... // was the code in comboButton rect QRect ir( x + 3, y + 3, w - 6 - 16, h - 6 ); if ( QApplication::reverseLayout() ) ir.moveBy( 16, 0 ); // end comboButtonRect... ir.setRect( ir.left() - 1, ir.top() - 1, ir.width() + 2, ir.height() + 2 ); qDrawShadePanel( p, ir, cg, TRUE, 2, 0 ); } } #endif break; } case CC_Slider: { #ifndef QT_NO_SLIDER const QSlider *slider = (const QSlider *) widget; int thickness = pixelMetric( PM_SliderControlThickness, widget ); int len = pixelMetric( PM_SliderLength, widget ); int ticks = slider->tickmarks(); QRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove, opt), handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle, opt); if ((sub & SC_SliderGroove) && groove.isValid()) { p->fillRect( groove, cg.brush(QColorGroup::Background) ); int x, y, w, h; int mid = thickness / 2; if ( ticks & QSlider::Above ) mid += len / 8; if ( ticks & QSlider::Below ) mid -= len / 8; if ( slider->orientation() == Horizontal ) { x = 0; y = groove.y() + mid - 3; w = slider->width(); h = 7; } else { x = groove.x() + mid - 3; y = 0; w = 7; h = slider->height(); } p->fillRect( x, y, w, h, cg.brush( QColorGroup::Dark )); // the dark side p->setPen( cg.dark() ); p->drawLine( x, y, x + w - 1, y ); p->drawLine( x, y, x, y + h - 1); p->setPen( cg.shadow() ); p->drawLine( x + 1, y + 1, x + w - 2, y + 1 ); p->drawLine( x + 1, y + 1, x + 1, y + h - 2 ); // the bright side! p->setPen(cg.shadow()); p->drawLine( x + 1, y + h - 2, x + w - 2, y + h - 2 ); p->drawLine( x + w - 2, y + 1, x + w - 2, y + h - 2 ); p->setPen( cg.light() ); p->drawLine( x, y + h - 1, x + w - 1, y + h - 1 ); p->drawLine( x + w - 1, y, x + w - 1, y + h - 1 ); // top left corner: p->setPen(cg.background()); p->drawPoint( x, y ); p->drawPoint( x + 1, y ); p->drawPoint( x, y + 1 ); p->setPen(cg.shadow()); p->drawPoint( x + 1, y + 1 ); // bottom left corner: p->setPen( cg.background() ); p->drawPoint( x, y + h - 1 ); p->drawPoint( x + 1, y + h - 1 ); p->drawPoint( x, y + h - 2 ); p->setPen( cg.light() ); p->drawPoint( x + 1, y + h - 2 ); // top right corner: p->setPen( cg.background() ); p->drawPoint( x + w - 1, y ); p->drawPoint( x + w - 2, y ); p->drawPoint( x + w - 1, y + 1 ); p->setPen( cg.dark() ); p->drawPoint( x + w - 2, y + 1 ); // bottom right corner: p->setPen( cg.background() ); p->drawPoint( x + w - 1, y + h - 1 ); p->drawPoint( x + w - 2, y + h - 1 ); p->drawPoint( x + w - 1, y + h - 2 ); p->setPen( cg.light() ); p->drawPoint( x + w - 2, y + h - 2 ); p->setPen( cg.dark() ); p->drawPoint( x + w - 3, y + h - 3 ); // ### end slider groove if ( how & Style_HasFocus ) drawPrimitive( PE_FocusRect, p, groove, cg ); } if ((sub & SC_SliderHandle) && handle.isValid()) { const QColor c0 = cg.shadow(); const QColor c1 = cg.dark(); const QColor c3 = cg.light(); int x1 = handle.x(); int x2 = handle.x() + handle.width() - 1; int y1 = handle.y(); int y2 = handle.y() + handle.height() - 1; int mx = handle.width() / 2; int my = handle.height() / 2; if ( slider->orientation() == Vertical ) { // Background QBrush oldBrush = p->brush(); p->setBrush( cg.brush( QColorGroup::Button ) ); p->setPen( NoPen ); QPointArray a(6); a.setPoint( 0, x1 + 1, y1 + 1 ); a.setPoint( 1, x2 - my + 2, y1 + 1 ); a.setPoint( 2, x2 - 1, y1 + my - 1 ); a.setPoint( 3, x2 - 1, y2 - my + 1 ); a.setPoint( 4, x2 - my + 2, y2 - 1 ); a.setPoint( 5, x1 + 1, y2 - 1 ); p->drawPolygon( a ); p->setBrush( oldBrush ); // shadow border p->setPen( c0 ); p->drawLine( x1, y1 + 1, x1,y2 - 1 ); p->drawLine( x2 - my + 2, y1, x2, y1 + my - 2 ); p->drawLine( x2 - my + 2, y2, x2, y1 + my + 2 ); p->drawLine( x2, y1 + my - 2, x2, y1 + my + 2 ); p->drawLine( x1 + 1, y1, x2 - my + 2, y1 ); p->drawLine( x1 + 1, y2, x2 - my + 2, y2 ); // light shadow p->setPen( c3 ); p->drawLine( x1 + 1, y1 + 2, x1 + 1, y2 - 2 ); p->drawLine( x1 + 1, y1 + 1, x2 - my + 2, y1 + 1 ); p->drawLine( x2 - my + 2, y1 + 1, x2 - 1, y1 + my - 2 ); // dark shadow p->setPen(c1); p->drawLine( x2 - 1, y1 + my - 2, x2 - 1, y1 + my + 2 ); p->drawLine( x2 - my + 2, y2 - 1, x2 - 1, y1 + my + 2 ); p->drawLine( x1 + 1, y2 - 1, x2 -my + 2, y2 - 1 ); drawRiffles( p, handle.x(), handle.y() + 2, handle.width() - 3, handle.height() - 4, cg, TRUE ); } else { // Horizontal QBrush oldBrush = p->brush(); p->setBrush( cg.brush( QColorGroup::Button ) ); p->setPen( NoPen ); QPointArray a(6); a.setPoint( 0, x2 - 1, y1 + 1 ); a.setPoint( 1, x2 - 1, y2 - mx + 2 ); a.setPoint( 2, x2 - mx + 1, y2 - 1 ); a.setPoint( 3, x1 + mx - 1, y2 - 1 ); a.setPoint( 4, x1 + 1, y2 - mx + 2 ); a.setPoint( 5, x1 + 1, y1 + 1 ); p->drawPolygon( a ); p->setBrush( oldBrush ); // shadow border p->setPen( c0 ); p->drawLine( x1 + 1, y1, x2 - 1, y1 ); p->drawLine( x1, y2 - mx + 2, x1 + mx - 2, y2 ); p->drawLine( x2, y2 - mx + 2, x1 + mx + 2, y2 ); p->drawLine( x1 + mx - 2, y2, x1 + mx + 2, y2 ); p->drawLine( x1, y1 + 1, x1, y2 - mx + 2 ); p->drawLine( x2, y1 + 1, x2, y2 - mx + 2 ); // light shadow p->setPen(c3); p->drawLine( x1 + 1, y1 + 1, x2 - 1, y1 + 1 ); p->drawLine( x1 + 1, y1 + 1, x1 + 1, y2 - mx + 2 ); // dark shadow p->setPen(c1); p->drawLine( x2 - 1, y1 + 1, x2 - 1, y2 - mx + 2 ); p->drawLine( x1 + 1, y2 - mx + 2, x1 + mx - 2, y2 - 1 ); p->drawLine( x2 - 1, y2 - mx + 2, x1 + mx + 2, y2 - 1 ); p->drawLine( x1 + mx - 2, y2 - 1, x1 + mx + 2, y2 - 1 ); drawRiffles( p, handle.x() + 2, handle.y(), handle.width() - 4, handle.height() - 5, cg, FALSE ); } } if ( sub & SC_SliderTickmarks ) QCommonStyle::drawComplexControl( control, p, widget, r, cg, how, SC_SliderTickmarks, subActive, opt ); #endif break; } default: QWindowsStyle::drawComplexControl( control, p, widget, r, cg, how, sub, subActive, opt ); break; } }