IntRect LayoutScrollbar::buttonRect(ScrollbarPart partType) const { LayoutScrollbarPart* partLayoutObject = m_parts.get(partType); if (!partLayoutObject) return IntRect(); partLayoutObject->layout(); bool isHorizontal = orientation() == HorizontalScrollbar; if (partType == BackButtonStartPart) return IntRect(location(), IntSize(isHorizontal ? partLayoutObject->pixelSnappedWidth() : width(), isHorizontal ? height() : partLayoutObject->pixelSnappedHeight())); if (partType == ForwardButtonEndPart) { return IntRect(isHorizontal ? x() + width() - partLayoutObject->pixelSnappedWidth() : x(), isHorizontal ? y() : y() + height() - partLayoutObject->pixelSnappedHeight(), isHorizontal ? partLayoutObject->pixelSnappedWidth() : width(), isHorizontal ? height() : partLayoutObject->pixelSnappedHeight()); } if (partType == ForwardButtonStartPart) { IntRect previousButton = buttonRect(BackButtonStartPart); return IntRect(isHorizontal ? x() + previousButton.width() : x(), isHorizontal ? y() : y() + previousButton.height(), isHorizontal ? partLayoutObject->pixelSnappedWidth() : width(), isHorizontal ? height() : partLayoutObject->pixelSnappedHeight()); } IntRect followingButton = buttonRect(ForwardButtonEndPart); return IntRect(isHorizontal ? x() + width() - followingButton.width() - partLayoutObject->pixelSnappedWidth() : x(), isHorizontal ? y() : y() + height() - followingButton.height() - partLayoutObject->pixelSnappedHeight(), isHorizontal ? partLayoutObject->pixelSnappedWidth() : width(), isHorizontal ? height() : partLayoutObject->pixelSnappedHeight()); }
IntRect RenderScrollbar::buttonRect(ScrollbarPart partType) { RenderScrollbarPart* partRenderer = m_parts.get(partType); if (!partRenderer) return IntRect(); partRenderer->layout(); bool isHorizontal = orientation() == HorizontalScrollbar; if (partType == BackButtonStartPart) return IntRect(x(), y(), isHorizontal ? partRenderer->width() : width(), isHorizontal ? height() : partRenderer->height()); if (partType == ForwardButtonEndPart) return IntRect(isHorizontal ? x() + width() - partRenderer->width() : x(), isHorizontal ? y() : y() + height() - partRenderer->height(), isHorizontal ? partRenderer->width() : width(), isHorizontal ? height() : partRenderer->height()); if (partType == ForwardButtonStartPart) { IntRect previousButton = buttonRect(BackButtonStartPart); return IntRect(isHorizontal ? x() + previousButton.width() : x(), isHorizontal ? y() : y() + previousButton.height(), isHorizontal ? partRenderer->width() : width(), isHorizontal ? height() : partRenderer->height()); } IntRect followingButton = buttonRect(ForwardButtonEndPart); return IntRect(isHorizontal ? x() + width() - followingButton.width() - partRenderer->width() : x(), isHorizontal ? y() : y() + height() - followingButton.height() - partRenderer->height(), isHorizontal ? partRenderer->width() : width(), isHorizontal ? height() : partRenderer->height()); }
IntRect RenderScrollbar::buttonRect(ScrollbarPart partType) { RenderScrollbarPart* partRenderer = m_parts.get(partType); if (!partRenderer) return IntRect(); partRenderer->layout(); bool isHorizontal = orientation() == HorizontalScrollbar; IntSize pixelSnappedIntSize = snappedIntRect(partRenderer->frameRect()).size(); if (partType == BackButtonStartPart) return IntRect(location(), IntSize(isHorizontal ? pixelSnappedIntSize.width() : width(), isHorizontal ? height() : pixelSnappedIntSize.height())); if (partType == ForwardButtonEndPart) return IntRect(isHorizontal ? x() + width() - pixelSnappedIntSize.width() : x(), isHorizontal ? y() : y() + height() - pixelSnappedIntSize.height(), isHorizontal ? pixelSnappedIntSize.width() : width(), isHorizontal ? height() : pixelSnappedIntSize.height()); if (partType == ForwardButtonStartPart) { IntRect previousButton = buttonRect(BackButtonStartPart); return IntRect(isHorizontal ? x() + previousButton.width() : x(), isHorizontal ? y() : y() + previousButton.height(), isHorizontal ? pixelSnappedIntSize.width() : width(), isHorizontal ? height() : pixelSnappedIntSize.height()); } IntRect followingButton = buttonRect(ForwardButtonEndPart); return IntRect(isHorizontal ? x() + width() - followingButton.width() - pixelSnappedIntSize.width() : x(), isHorizontal ? y() : y() + height() - followingButton.height() - pixelSnappedIntSize.height(), isHorizontal ? pixelSnappedIntSize.width() : width(), isHorizontal ? height() : pixelSnappedIntSize.height()); }
/*! \internal \overload Overload paint event to render the SVG graphics. */ void QtSvgToggleSwitch::paintEvent(QPaintEvent * event) { Q_UNUSED(event); QPainter painter(this); if (!isChecked()) { m_rendererButtonOff->render(&painter, buttonRect()); } else { m_rendererButtonOn->render(&painter, buttonRect()); } }
void MSEntryFieldCombo::buttonPress(const XEvent *pEvent_) { if (sensitive()==MSTrue) { if(pEvent_->xbutton.x<_fieldValue->x()+_fieldValue->width()) { MSEntryField::buttonPress(pEvent_); } else { activate(); if (_editor->mapped()==MSFalse) { MSBoolean focusOK=MSTrue; if (acceptFocus()==MSTrue) focusOK=traverseFocus(this); if (focusOK==MSTrue) { if (pEvent_->xbutton.button==Button1&&_buttonFlags!=0) { if (comboOrTextButton()==MSTrue&& pEvent_->xbutton.x>=buttonRect().x()&& pEvent_->xbutton.y>=buttonRect().y()) { if(buttonState(ComboButton) == MSTrue) { buttonActivate(); } else { drawTextButton(MSTrue); _buttonSelected = MSTrue; } } else if(buttonState(UpDownArrows) == MSTrue) { if (isProtected()==MSFalse) { if(pEvent_->xbutton.y <_fieldValue->y() +_fieldValue->height()/2) armUpArrow(); else armDownArrow(); } } } } } } } }
bool MediaControlsPainter::paintMediaOverlayPlayButton(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { const HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; if (!hasSource(mediaElement) || !mediaElement->paused()) return false; static Image* mediaOverlayPlay = platformResource("mediaplayerOverlayPlay", "mediaplayerOverlayPlayNew"); IntRect buttonRect(rect); if (RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) { // Overlay play button covers the entire player, so center and draw a // smaller button. Center in the entire element. const LayoutBox* box = mediaElement->layoutObject()->enclosingBox(); if (!box) return false; int mediaHeight = box->pixelSnappedHeight(); buttonRect.setX(rect.center().x() - mediaOverlayPlayButtonWidthNew / 2); buttonRect.setY(rect.center().y() - mediaOverlayPlayButtonHeightNew / 2 + (mediaHeight - rect.height()) / 2); buttonRect.setWidth(mediaOverlayPlayButtonWidthNew); buttonRect.setHeight(mediaOverlayPlayButtonHeightNew); } return paintMediaButton(paintInfo.context, buttonRect, mediaOverlayPlay); }
FogControl::FogControl(const Rect & rect, FogControlDelegate *newDelegate) : UIControl(rect) { ControlsFactory::CustomizeDialog(this); delegate = newDelegate; Rect propertyRect(0, 0, rect.dx, rect.dy - ControlsFactory::BUTTON_HEIGHT); fogProperties = new PropertyList(propertyRect, NULL); AddControl(fogProperties); ControlsFactory::AddFogSubsection(fogProperties, true, 0.006f, Color::White()); Rect buttonRect(0, rect.dy - ControlsFactory::BUTTON_HEIGHT, rect.dx / 2, ControlsFactory::BUTTON_HEIGHT); UIButton *btnCancel = ControlsFactory::CreateButton(buttonRect, LocalizedString(L"dialog.cancel")); btnCancel->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &FogControl::OnCancel)); AddControl(btnCancel); SafeRelease(btnCancel); buttonRect.x = rect.dx - buttonRect.dx; UIButton *btnCreate = ControlsFactory::CreateButton(buttonRect, LocalizedString(L"dialog.set")); btnCreate->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &FogControl::OnSet)); AddControl(btnCreate); SafeRelease(btnCreate); }
bool RenderThemeWinCE::paintMenuListButton(RenderObject* o, const PaintInfo& i, const IntRect& r) { IntRect buttonRect(r.maxX() - dropDownButtonWidth - 1, r.y(), dropDownButtonWidth, r.height()); buttonRect.inflateY(-1); i.context->drawFrameControl(buttonRect, DFC_SCROLL, DFCS_SCROLLCOMBOBOX | determineClassicState(o)); return true; }
void AppGroupView::_DrawCloseButton(const BRect& updateRect) { PushState(); BRect closeRect = fCloseRect; rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); float tint = B_DARKEN_2_TINT; if (fCloseClicked) { BRect buttonRect(closeRect.InsetByCopy(-4, -4)); be_control_look->DrawButtonFrame(this, buttonRect, updateRect, base, base, BControlLook::B_ACTIVATED | BControlLook::B_BLEND_FRAME); be_control_look->DrawButtonBackground(this, buttonRect, updateRect, base, BControlLook::B_ACTIVATED); tint *= 1.2; closeRect.OffsetBy(1, 1); } base = tint_color(base, tint); SetHighColor(base); SetPenSize(2); StrokeLine(closeRect.LeftTop(), closeRect.RightBottom()); StrokeLine(closeRect.LeftBottom(), closeRect.RightTop()); PopState(); }
/** Intializes the PartResizerWidget @param d the Device the Partition is on @param p the Partition to show and/or resize @param minFirst the minimum value for the first sector @param maxLast the maximum value for the last sector */ void PartResizerWidget::init(Device& d, Partition& p, qint64 minFirst, qint64 maxLast, bool read_only, bool move_allowed) { setDevice(d); setPartition(p); setMinimumFirstSector(minFirst); setMaximumLastSector(maxLast); setReadOnly(read_only); setMoveAllowed(move_allowed); setMinimumLength(qMax(partition().sectorsUsed(), partition().minimumSectors())); setMaximumLength(qMin(totalSectors(), partition().maximumSectors())); // set margins to accommodate to top/bottom button asymmetric layouts QStyleOptionButton bOpt; bOpt.initFrom(this); QRect buttonRect(style()->subElementRect(QStyle::SE_PushButtonContents, &bOpt)); int asym = (rect().bottom() - buttonRect.bottom()) - (buttonRect.top() - rect().top()); if (asym > 0) setContentsMargins(0, asym, 0, 0); else setContentsMargins(0, 0, 0, asym); if (!readOnly()) { QPixmap pixmap(handleWidth(), handleHeight()); pixmap.fill(Qt::transparent); QPainter p(&pixmap); QStyleOption opt; opt.state |= QStyle::State_Horizontal; opt.rect = pixmap.rect().adjusted(0, 2, 0, -2); style()->drawControl(QStyle::CE_Splitter, &opt, &p, this); leftHandle().setPixmap(pixmap); rightHandle().setPixmap(pixmap); leftHandle().setFixedSize(handleWidth(), handleHeight()); rightHandle().setFixedSize(handleWidth(), handleHeight()); } delete m_PartWidget; m_PartWidget = new PartWidget(this, &partition()); if (!readOnly()) { leftHandle().setCursor(Qt::SizeHorCursor); rightHandle().setCursor(Qt::SizeHorCursor); } if (moveAllowed()) partWidget().setCursor(Qt::SizeAllCursor); partWidget().setToolTip(QString()); updatePositions(); }
void Button::update(const sf::RenderWindow& screen, const float time, const sf::Vector2i& mouseOffset) { auto position = getPosition(); auto offset = getOffset(); sf::IntRect buttonRect(static_cast<int>(position.x + offset.x + m_style.mouseRect.left - getSize().x / 2), static_cast<int>(position.y + offset.y + m_style.mouseRect.top), m_style.mouseRect.width, m_style.mouseRect.height); auto mousePosition = getCursorPosition(screen); if(buttonRect.contains(mousePosition + mouseOffset) && isVisible()) { if(!m_playHoverSound && m_style.hoverStyle.sound) { m_playHoverSound = true; m_style.hoverStyle.sound->play(); } m_showToolTip = true; m_toolTip.setPosition(static_cast<const sf::Vector2f>(mousePosition), screen); if(utility::Mouse.leftButtonPressed()) { m_sprite = &m_style.pressedStyle.sprite; m_label = &m_style.pressedStyle.label; onPositionChanged(); if(!m_playPressedSound && m_style.pressedStyle.sound) { m_playPressedSound = true; m_style.pressedStyle.sound->play(); } } else { m_playPressedSound = false; m_sprite = &m_style.hoverStyle.sprite; m_label = &m_style.hoverStyle.label; onPositionChanged(); if(m_isTriggering && utility::Mouse.leftButtonReleased() && m_callback != nullptr) m_callback(*this); } } else { m_playHoverSound = false; m_playPressedSound = false; m_sprite = &m_style.idleStyle.sprite; m_label = &m_style.idleStyle.label; onPositionChanged(); m_showToolTip = false; } }
CreatePropertyControl::CreatePropertyControl(const Rect & rect, CreatePropertyControlDelegate *newDelegate) : UIControl(rect) { ControlsFactory::CustomizeDialog(this); delegate = newDelegate; Vector<String> types; types.push_back("String"); types.push_back("Integer"); types.push_back("Float"); types.push_back("Bool"); Rect buttonRect(0, rect.dy - ControlsFactory::BUTTON_HEIGHT, rect.dx / 2, ControlsFactory::BUTTON_HEIGHT); UIButton *btnCancel = ControlsFactory::CreateButton(buttonRect, LocalizedString(L"dialog.cancel")); btnCancel->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &CreatePropertyControl::OnCancel)); AddControl(btnCancel); SafeRelease(btnCancel); buttonRect.x = rect.dx - buttonRect.dx; UIButton *btnCreate = ControlsFactory::CreateButton(buttonRect, LocalizedString(L"dialog.create")); btnCreate->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &CreatePropertyControl::OnCreate)); AddControl(btnCreate); SafeRelease(btnCreate); Rect textRect(0, 0, rect.dx / 3, (rect.dy - buttonRect.dy) / 2); Rect controlRect(textRect.dx, 0, rect.dx - textRect.dx, textRect.dy); UIStaticText *t = new UIStaticText(textRect); t->SetText(LocalizedString(L"createproperty.type")); t->SetFont(ControlsFactory::GetFontLight()); AddControl(t); SafeRelease(t); typeCombo = new ComboBox(controlRect, NULL, types); AddControl(typeCombo); textRect.y = textRect.dy; controlRect.y = controlRect.dy; t = new UIStaticText(textRect); t->SetText(LocalizedString(L"createproperty.name")); t->SetFont(ControlsFactory::GetFontLight()); AddControl(t); SafeRelease(t); nameField = new UITextField(controlRect); ControlsFactory::CustomizeEditablePropertyCell(nameField); nameField->SetDelegate(this); nameField->SetFont(ControlsFactory::GetFontLight()); AddControl(nameField); }
bool RenderThemeGtk::paintButton(RenderObject* object, const PaintInfo& info, const IntRect& rect) { if (info.context->paintingDisabled()) return false; GtkWidget* widget = gtkButton(); IntRect buttonRect(IntPoint(), rect.size()); IntRect focusRect(buttonRect); GtkStateType state = getGtkStateType(object); gtk_widget_set_state(widget, state); gtk_widget_set_direction(widget, gtkTextDirection(object->style()->direction())); if (isFocused(object)) { if (isEnabled(object)) { #if !GTK_CHECK_VERSION(2, 22, 0) GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS); #endif g_object_set(widget, "has-focus", TRUE, NULL); } gboolean interiorFocus = 0, focusWidth = 0, focusPadding = 0; gtk_widget_style_get(widget, "interior-focus", &interiorFocus, "focus-line-width", &focusWidth, "focus-padding", &focusPadding, NULL); // If we are using exterior focus, we shrink the button rect down before // drawing. If we are using interior focus we shrink the focus rect. This // approach originates from the Mozilla theme drawing code (gtk2drawing.c). if (interiorFocus) { GtkStyle* style = gtk_widget_get_style(widget); focusRect.inflateX(-style->xthickness - focusPadding); focusRect.inflateY(-style->ythickness - focusPadding); } else { buttonRect.inflateX(-focusWidth - focusPadding); buttonRect.inflateY(-focusPadding - focusPadding); } } WidgetRenderingContext widgetContext(info.context, rect); GtkShadowType shadowType = state == GTK_STATE_ACTIVE ? GTK_SHADOW_IN : GTK_SHADOW_OUT; widgetContext.gtkPaintBox(buttonRect, widget, state, shadowType, "button"); if (isFocused(object)) widgetContext.gtkPaintFocus(focusRect, widget, state, "button"); #if !GTK_CHECK_VERSION(2, 22, 0) GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS); #endif g_object_set(widget, "has-focus", FALSE, NULL); return false; }
bool RenderThemeWin::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { // FIXME: All these inflate() calls are bogus, causing painting problems, // as well as sizing wackiness in Classic mode IntRect editRect(r); paintTextField(o, i, editRect); const int buttonWidth = GetSystemMetrics(SM_CXVSCROLL); IntRect buttonRect(r.right() - buttonWidth - 1, r.y(), buttonWidth, r.height()); buttonRect.inflateY(-1); paintMenuListButton(o, i, buttonRect); return false; }
IntRect ScrollbarThemeHaiku::backButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool) { if (part == BackButtonEndPart) return IntRect(); int thickness = scrollbarThickness(); IntPoint buttonOrigin(scrollbar->x(), scrollbar->y()); IntSize buttonSize = scrollbar->orientation() == HorizontalScrollbar ? IntSize(buttonWidth(scrollbar->width(), thickness), thickness) : IntSize(thickness, buttonWidth(scrollbar->height(), thickness)); IntRect buttonRect(buttonOrigin, buttonSize); return buttonRect; }
void MSEntryFieldCombo::drawComboButton(MSBoolean armed_) { if (frozen()==MSFalse&&mapped()==MSTrue) { drawBevel(buttonRect(),(armed_==MSTrue)?MSSunken:MSRaised,2); XFillRectangle(display(),window(), (armed_==MSTrue)?selectShadowGC():backgroundShadowGC(), buttonRect().x()+2,buttonRect().y()+2, buttonRect().width()-4,buttonRect().height()-4); int mw=buttonRect().width()>>1; // x midpoint of button int mh=buttonRect().height()>>1; // y midpoint of button int xoff=buttonRect().x(); int yoff=buttonRect().y(); int ah = _fieldValue->height()/2; int aw = _fieldValue->textHeight(); _comboArrow->configure(xoff+mw-aw/2, yoff+mh-ah/2, aw, ah); _comboArrow->select(armed_); _comboArrow->draw(); }
/** Draws the column 1 (Status) of ScriptRepositoryView. * * This function is called every time the ScriptRepository needs to *draw the widget for the Status of the file/folder inside the *ScriptRepository. Instead of displaying the status (REMOTE_ONLY, *LOCAL_ONLY, and so on), it will draw an Icon that 'hoppefully' will *better indicate to the user the condition of the entry as well as *encourage him to act. The action will be dealt with through the *editorEvent. * * When this method is called, it will get the index in order to *retrieve the information about the status of the entry *(folder/file). * * It will them decide which icon better describes the current status *of the entry, and will draw it using the option and the painter *given. * * @param painter: Required to draw the widget * @param option: Provided by the framework and has information *displaying the widget. * @param index: Identifies the entry inside the RepoModel (indirectly * the file/folder). */ void ScriptRepositoryView::RepoDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { if (!index.isValid()) return; if (painter->device() == 0) return; QIcon icon; // get the state and chose the best fit icon QString state = index.model()->data(index, Qt::DisplayRole).toString(); if (state == RepoModel::remoteOnlySt()) icon = QIcon::fromTheme("system-software-install", QIcon(QPixmap(":/win/download"))); else if (state == RepoModel::remoteChangedSt() || state == RepoModel::bothChangedSt()) icon = QIcon::fromTheme("bottom", QIcon(QPixmap(":win/system-software-update"))); else if (state == RepoModel::updatedSt()) icon = QIcon::fromTheme("dialog-ok", QIcon(QPixmap(":/win/dialog-ok"))); else if (state == RepoModel::localOnlySt() || state == RepoModel::localChangedSt()) icon = QIcon::fromTheme("add-files-to-archive", QIcon(QPixmap(":win/upload"))); else if (state == RepoModel::downloadSt() || state == RepoModel::uploadSt()) icon = QIcon(QPixmap(":win/running_process")); // define the region to draw the icon QRect buttonRect(option.rect); int min_val = buttonRect.width() < buttonRect.height() ? buttonRect.width() : buttonRect.height(); // make it square buttonRect.setWidth(min_val); buttonRect.setHeight(min_val); buttonRect.moveCenter(option.rect.center()); // define the options to draw a push button with the icon displayed QStyleOptionButton button; button.rect = buttonRect; button.icon = icon; int icon_size = (int)(min_val * .8); button.iconSize = QSize(icon_size, icon_size); button.state = QStyle::State_Enabled; // draw a push button QApplication::style()->drawControl(QStyle::CE_PushButton, &button, painter); }
void CQDividedAreaTitle:: paintEvent(QPaintEvent *) { QPainter painter(this); painter.fillRect(rect(), QBrush(bg_)); int x = 2; int h = height(); int iw = 0; if (! icon_.isNull()) { iw = iconSize().width() + 2; painter.drawPixmap(x, (h - iconSize().height())/2, icon().pixmap(iconSize())); x += iw; } int bw = collapseButton_->width(); if (title_.length()) { QFontMetrics fm(font()); QString title = fm.elidedText(title_, Qt::ElideRight, width() - iw - bw - 6); // if just an ellipsis keep first letter if (title.length() == 0 || title.utf16()[0] == 8230) title = title_[0] + ".."; painter.drawText(x, (h - fm.height())/2 + fm.ascent(), title); } QRect buttonRect(collapseButton_->x() - 2, 0, bw + 4, height()); painter.fillRect(buttonRect, QBrush(bg_)); QColor c = widget_->palette().window().color().darker(200); painter.setPen(c); painter.drawLine(0, height() - 1, width() - 1, height() - 1); }
bool RenderInputSpeech::paintInputFieldSpeechButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { Element* element = object->node()->isElementNode() ? toElement(object->node()) : 0; if (!element || !element->isInputFieldSpeechButtonElement()) return false; // Get the renderer of <input> element. Node* input = object->node()->shadowHost(); if (!input->renderer()->isBox()) return false; RenderBox* inputRenderBox = toRenderBox(input->renderer()); LayoutRect inputContentBox = inputRenderBox->contentBoxRect(); // Make sure the scaled button stays square and will fit in its parent's box. LayoutUnit buttonSize = std::min(inputContentBox.width(), std::min<LayoutUnit>(inputContentBox.height(), rect.height())); // Calculate button's coordinates relative to the input element. // Center the button vertically. Round up though, so if it has to be one pixel off-center, it will // be one pixel closer to the bottom of the field. This tends to look better with the text. LayoutRect buttonRect(object->offsetFromAncestorContainer(inputRenderBox).width(), inputContentBox.y() + (inputContentBox.height() - buttonSize + 1) / 2, buttonSize, buttonSize); // Compute an offset between the part renderer and the input renderer. LayoutSize offsetFromInputRenderer = -(object->offsetFromAncestorContainer(inputRenderBox)); // Move the rect into partRenderer's coords. buttonRect.move(offsetFromInputRenderer); // Account for the local drawing offset. buttonRect.moveBy(rect.location()); DEFINE_STATIC_LOCAL(RefPtr<Image>, imageStateNormal, (Image::loadPlatformResource("inputSpeech"))); DEFINE_STATIC_LOCAL(RefPtr<Image>, imageStateRecording, (Image::loadPlatformResource("inputSpeechRecording"))); DEFINE_STATIC_LOCAL(RefPtr<Image>, imageStateWaiting, (Image::loadPlatformResource("inputSpeechWaiting"))); InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(element); Image* image = imageStateNormal.get(); if (speechButton->state() == InputFieldSpeechButtonElement::Recording) image = imageStateRecording.get(); else if (speechButton->state() == InputFieldSpeechButtonElement::Recognizing) image = imageStateWaiting.get(); paintInfo.context->drawImage(image, object->style()->colorSpace(), pixelSnappedIntRect(buttonRect)); return false; }
void WebTabView::_DrawCloseButton(BView* owner, BRect& frame, const BRect& updateRect, bool isFirst, bool isLast, bool isFront) { BRect closeRect = _CloseRectFrame(frame); frame.right = closeRect.left - be_control_look->DefaultLabelSpacing(); closeRect.left = (closeRect.left + closeRect.right) / 2 - 3; closeRect.right = closeRect.left + 6; closeRect.top = (closeRect.top + closeRect.bottom) / 2 - 3; closeRect.bottom = closeRect.top + 6; rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); float tint = B_DARKEN_1_TINT; if (!IsFront()) { base = tint_color(base, tint); tint *= 1.02; } if (fOverCloseRect) tint *= 1.4; else tint *= 1.2; if (fClicked && fOverCloseRect) { // Draw the button frame BRect buttonRect(closeRect.InsetByCopy(-4, -4)); be_control_look->DrawButtonFrame(owner, buttonRect, updateRect, base, base, BControlLook::B_ACTIVATED | BControlLook::B_BLEND_FRAME); be_control_look->DrawButtonBackground(owner, buttonRect, updateRect, base, BControlLook::B_ACTIVATED); closeRect.OffsetBy(1, 1); tint *= 1.2; } // Draw the × base = tint_color(base, tint); owner->SetHighColor(base); owner->SetPenSize(2); owner->StrokeLine(closeRect.LeftTop(), closeRect.RightBottom()); owner->StrokeLine(closeRect.LeftBottom(), closeRect.RightTop()); owner->SetPenSize(1); }
static void initStyleOption(const TabBarButton *widget, QStyleOption &option) { Q_ASSERT(widget); option.initFrom(widget); if (option.state & QStyle::State_MouseOver) { if (qApp->mouseButtons()) option.state |= QStyle::State_Sunken; } if (QStyleOptionTabBarBase *optionBase = qstyleoption_cast<QStyleOptionTabBarBase *>(&option)) { optionBase->shape = widget->shape(); } if (QStyleOptionTabBarBaseV2 *optionV2 = qstyleoption_cast<QStyleOptionTabBarBaseV2 *>(&option)) { // hardcoded document Mode optionV2->documentMode = true; } option.rect = buttonRect(widget, option); }
void CIATestMainWindow::AddScenario(ITestScenario *piScenario) { SGameRect buttonRect(2,2,100,20); buttonRect.y=m_rRealRect.h-(buttonRect.h+2); buttonRect.x+=(buttonRect.w+5.0/2)*m_mScenarios.size(); std::string sName=piScenario->GetName(); CButtonWrapper *pButton=new CButtonWrapper; pButton->Create("GameGUI","CGameGUIButton",sName); pButton->m_piButton->InitWindow(this,false); pButton->m_piButton->SetText(sName); pButton->m_piButton->SetHorizontalAlignment(eTextAlignment_Center); pButton->m_piButton->SetVerticalAlignment(eTextAlignment_Center); pButton->m_piButton->SetTextColor(CVector(0,0,0),1); pButton->m_piButton->SetBackgroundColor(CVector(0.5,0.5,0.5),1); pButton->m_piButton->SetReferenceSystem(eGameGUIReferenceSystem_Absolute); pButton->m_piButton->SetRect(&buttonRect); pButton->m_piButton->Activate(true); SUBSCRIBE_TO_CAST(pButton->m_piButton,IGameGUIButtonEvents); m_mScenarios[piScenario]=pButton; }
void CIATestMainWindow::AddEntityButton(std::string sName,bool bSelect) { SGameRect buttonRect(2,2,100,20); buttonRect.y+=(buttonRect.h+5.0)*m_mEntityButtons.size(); CButtonWrapper *pButton=new CButtonWrapper; pButton->Create("GameGUI","CGameGUIButton",sName); pButton->m_piButton->InitWindow(this,false); pButton->m_piButton->SetText(sName); pButton->m_piButton->SetHorizontalAlignment(eTextAlignment_Center); pButton->m_piButton->SetVerticalAlignment(eTextAlignment_Center); pButton->m_piButton->SetTextColor(CVector(0,0,0),1); pButton->m_piButton->SetBackgroundColor(CVector(0.5,0.5,0.5),1); pButton->m_piButton->SetReferenceSystem(eGameGUIReferenceSystem_Absolute); pButton->m_piButton->SetRect(&buttonRect); pButton->m_piButton->Activate(true); SUBSCRIBE_TO_CAST(pButton->m_piButton,IGameGUIButtonEvents); m_mEntityButtons[sName]=pButton; if(bSelect){OnButtonClicked(pButton->m_piButton);} }
/** Draws the column 3 (delete) of ScriptRepositoryView. * * This function is called every time the ScriptRepository needs to draw the widget * for the delete column of the file/folder inside the ScriptRepository. * It displays a trash icon to indicate user that it is used to remove entries. * * @param painter: Required to draw the widget * @param option: Provided by the framework and has information displaying the widget. * @param index: Identifies the entry inside the RepoModel (indirectly the file / folder). */ void ScriptRepositoryView::RemoveEntryDelegate::paint( QPainter* painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const { if (!index.isValid()) return; if (painter->device() ==0) return; QIcon icon ; // get the state and chose the best fit icon QString entry_type = index.model()->data(index, Qt::DisplayRole).toString(); if (entry_type == "protected") return; icon = QIcon::fromTheme("emptytrash", QIcon(QPixmap(":/win/emptytrash"))); // define the region to draw the icon QRect buttonRect( option.rect); int min_val = buttonRect.width()<buttonRect.height() ? buttonRect.width() : buttonRect.height(); // make it square buttonRect.setWidth(min_val); buttonRect.setHeight(min_val); buttonRect.moveCenter(option.rect.center()); // define the options to draw a push button with the icon displayed QStyleOptionButton button; button.rect = buttonRect; button.icon = icon; int icon_size =(int) (min_val*.8); button.iconSize = QSize(icon_size,icon_size); button.state = QStyle::State_Enabled; // draw a push button QApplication::style()->drawControl (QStyle::CE_PushButton, &button, painter); }
void MSEntryFieldCombo::drawTextButton(MSBoolean armed_) { if(frozen()==MSFalse&&mapped()==MSTrue) { drawBevel(buttonRect(),(armed_==MSTrue)?MSSunken:MSRaised,2); XFillRectangle(display(),window(), (armed_==MSTrue)?selectShadowGC():backgroundShadowGC(), buttonRect().x()+2,buttonRect().y()+2, buttonRect().width()-4,buttonRect().height()-4); int offset = 2 + 1; int x = buttonRect().x() + offset; int y = buttonRect().y() + 2; XDrawString(display(), window(), fieldValue()->textGC(), fieldValue()->textFontStruct(), x, y + fieldValue()->textAscent(), comboButtonLabel().string(), comboButtonLabel().length()); } }
Button *EventManager::checkButtonHit(ButtonList *buttonList, Common::Point pos) { for (ButtonList::iterator buttonItr = buttonList->begin(); buttonItr != buttonList->end(); ++buttonItr) { Button *button = *buttonItr; Common::Rect buttonRect(button->_x, button->_y, button->_x + button->_image->_width - 1, button->_y + button->_image->_height - 1); if (buttonRect.contains(pos) && button->_isEnabled) { if (_vm->_isHiRes) { _hitButton = button; } else { button->_altImage->drawImage(button->_x, button->_y); for (int i = 0; i < 3; i++) _vm->waitTOF(); button->_image->drawImage(button->_x, button->_y); } return button; } } return nullptr; }
void QvisElementSelectionWidget::mouseReleaseEvent(QMouseEvent *e) { QRect standardRect(periodicTable->x(), periodicTable->y(), periodicTable->width(), periodicTable->height()); QRect buttonRect(matchAnyElementButton->x(), matchAnyElementButton->y(), matchAnyElementButton->width(), matchAnyElementButton->height()); // If the mouse is in the grid, forward the event if (standardRect.contains(e->pos())) { QApplication::sendEvent(periodicTable, e); } else if (buttonRect.contains(e->pos())) { // Pretend that the button was clicked. matchAnyElementClicked(); } }
bool RosterItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *, const QStyleOptionViewItem &option, const QModelIndex &index) { if( event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease ) { } else { return false; } QRect buttonRect( option.rect); buttonRect.setY(option.rect.y() + 20); buttonRect.setX(option.rect.x() + 330); buttonRect.setHeight(30); QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event); if( !buttonRect.contains( mouseEvent->pos()) ) { return false; } if( event->type() == QEvent::MouseButtonPress) { } else if( event->type() == QEvent::MouseButtonRelease) { emit buttonClicked(index); } return false; }
static void paintToggle(RenderThemeGtk* theme, RenderObject* renderObject, const PaintInfo& info, const IntRect& rect, GtkWidget* widget) { // We do not call gtk_toggle_button_set_active here, because some themes begin a series of // animation frames in a "toggled" signal handler. This puts some checkboxes in a half-way // checked state. Every GTK+ theme I tested merely looks at the shadow type (and not the // 'active' property) to determine whether or not to draw the check. gtk_widget_set_sensitive(widget, theme->isEnabled(renderObject) && !theme->isReadOnlyControl(renderObject)); gtk_widget_set_direction(widget, gtkTextDirection(renderObject->style().direction())); bool indeterminate = theme->isIndeterminate(renderObject); gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(widget), indeterminate); GtkShadowType shadowType = GTK_SHADOW_OUT; if (indeterminate) // This originates from the Mozilla code. shadowType = GTK_SHADOW_ETCHED_IN; else if (theme->isChecked(renderObject)) shadowType = GTK_SHADOW_IN; WidgetRenderingContext widgetContext(info.context, rect); IntRect buttonRect(IntPoint(), rect.size()); GtkStateType toggleState = getGtkStateType(theme, renderObject); const char* detail = 0; if (GTK_IS_RADIO_BUTTON(widget)) { detail = "radiobutton"; widgetContext.gtkPaintOption(buttonRect, widget, toggleState, shadowType, detail); } else { detail = "checkbutton"; widgetContext.gtkPaintCheck(buttonRect, widget, toggleState, shadowType, detail); } if (theme->isFocused(renderObject)) { IntRect focusRect(buttonRect); adjustRectForFocus(widget, focusRect, true); widgetContext.gtkPaintFocus(focusRect, widget, toggleState, detail); } }
void MSEntryFieldCombo::buttonRelease(const XEvent *pEvent_) { if (buttonState(UpDownArrows)==MSTrue&& (_upArrow->selected()==MSTrue||_downArrow->selected()==MSTrue)) { if (_upArrow->selected()) _upArrow->select(MSFalse); else if (_downArrow->selected()) _downArrow->select(MSFalse); stopTimers(); } else if(comboOrTextButton()==MSTrue&&_buttonSelected==MSTrue) { _buttonSelected=MSFalse; drawTextButton(MSFalse); if(pEvent_->xbutton.x >= buttonRect().x()&& pEvent_->xbutton.x <= buttonRect().x() + buttonRect().width()&& pEvent_->xbutton.y >= buttonRect().y() && pEvent_->xbutton.y <= buttonRect().y() + buttonRect().height()) { textButtonActivate(); } } else MSEntryField::buttonRelease(pEvent_); }