bool RenderThemeWin::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { // Get the correct theme data for a button ThemeData themeData = getThemeData(o); // Now paint the button. HDC hdc = prepareForDrawing(i.context); RECT widgetRect = r; if (m_themeDLL && !m_buttonTheme) m_buttonTheme = openTheme(0, L"Button"); if (m_buttonTheme && drawThemeBG) { drawThemeBG(m_buttonTheme, hdc, themeData.m_part, themeData.m_state, &widgetRect, NULL); } else { if ((themeData.m_part == BP_BUTTON) && isFocused(o)) { // Draw black focus rect around button outer edge HBRUSH brush = GetSysColorBrush(COLOR_3DDKSHADOW); if (brush) { FrameRect(hdc, &widgetRect, brush); InflateRect(&widgetRect, -1, -1); } } DrawFrameControl(hdc, &widgetRect, DFC_BUTTON, themeData.m_classicState); if ((themeData.m_part != BP_BUTTON) && isFocused(o)) { DrawFocusRect(hdc, &widgetRect); } } doneDrawing(i.context, hdc); return false; }
bool RenderThemeQtMobile::paintTextField(RenderObject* o, const PaintInfo& i, const IntRect& r) { StylePainterMobile p(this, i); if (!p.isValid()) return true; ControlPart appearance = o->style()->appearance(); if (appearance != TextFieldPart && appearance != SearchFieldPart && appearance != TextAreaPart) return true; // Now paint the text field. if (appearance == TextAreaPart) { const bool previousAntialiasing = p.painter->testRenderHint(QPainter::Antialiasing); p.painter->setRenderHint(QPainter::Antialiasing); p.painter->setPen(borderPen()); p.painter->setBrush(Qt::white); const int radius = checkBoxWidth * radiusFactor; p.painter->drawRoundedRect(r, radius, radius); if (isFocused(o)) { QPen focusPen(highlightColor, 1.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); p.painter->setPen(focusPen); p.painter->setBrush(Qt::NoBrush); p.painter->drawRoundedRect(r, radius, radius); } p.painter->setRenderHint(QPainter::Antialiasing, previousAntialiasing); } else p.drawLineEdit(r, isFocused(o), isEnabled(o)); return false; }
void TextField::paintComponent( const PaintEvent &paintEvent ) { int caretLoc = getCaretLocation(); int textLoc = getTextOffset(); Rectangle sideclip = getInnerRectangle(); sideclip = Rectangle(sideclip.getX() + getLeftPadding() , sideclip.getY() + 2,sideclip.getSize().getWidth() - getLeftPadding() - getRightPadding() + 1, sideclip.getHeight() - 4); if(isReadOnly()) { paintEvent.graphics()->drawFilledRectangle( getSizeRectangle(),frameColor); } else { paintEvent.graphics()->drawFilledRectangle( getSizeRectangle(),getBackColor()); } paintEvent.graphics()->pushClippingRect(sideclip); if(getSelectionStart() != getSelectionEnd() && (isFocused() || !isHidingSelection()) ) { Rectangle selRect = Rectangle( getSelectionLocation(), (getInnerHeight() / 2) - (getFont()->getLineHeight() / 2), getSelectionWidth(), getFont()->getLineHeight()); paintEvent.graphics()->drawFilledRectangle( selRect,getSelectionBackColor()); } paintEvent.graphics()->drawText(Point(textLoc, + ((getInnerSize().getHeight() - getFont()->getLineHeight()) / 2)),getText().c_str(), getFontColor(),getFont()); if(isFocused()) { if(isBlinking()) paintEvent.graphics()->drawLine(Point(caretLoc + 1, ((getInnerSize().getHeight() / 2) + (getFont()->getLineHeight() / 2))), Point(caretLoc + 1, ((getInnerSize().getHeight() / 2) - (getFont()->getLineHeight() / 2))), Color(0,0,0)); } paintEvent.graphics()->popClippingRect(); }
void Slider::draw(gcn::Graphics *graphics) { int w = getWidth(); int h = getHeight(); int x = 0; int y = (h - hStart->getHeight()) / 2; if (isFocused()) static_cast<Graphics*>(graphics)->drawImage(hStartHi, x, y); else static_cast<Graphics*>(graphics)->drawImage(hStart, x, y); w -= hStart->getWidth() + hEnd->getWidth(); x += hStart->getWidth(); if (isFocused()) static_cast<Graphics*>(graphics)->drawImagePattern(hMidHi, x, y, w, hMidHi->getHeight()); else static_cast<Graphics*>(graphics)->drawImagePattern(hMid, x, y, w, hMid->getHeight()); x += w; if (isFocused()) static_cast<Graphics*>(graphics)->drawImage(hEndHi, x, y); else static_cast<Graphics*>(graphics)->drawImage(hEnd, x, y); drawMarker(graphics); }
void NumericTextField::handleEvents(SDL_Event &event) { switch (event.type) { case SDL_QUIT: GameConfig::getInstance()->gameIsRunning = false; break; case SDL_TEXTINPUT: if (isFocused()) { char * c = event.text.text; switch (*c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if(text.length() < maxLength) { text += event.text.text; } break; default: break; } c = nullptr; } break; case SDL_KEYDOWN: // Handle backspace if (isFocused() && text.length() > 0 && event.key.keysym.sym == SDLK_BACKSPACE) { text.pop_back(); } else if (event.key.keysym.sym == SDLK_RETURN) { focus = false; } break; case SDL_MOUSEBUTTONDOWN: focus = intersect(event.button.x, event.button.y); break; case SDL_MOUSEMOTION: hover = intersect(event.motion.x, event.motion.y); break; default: break; } }
bool Editbox::handleEvent( const WM_Base &wm ) { if(wm.type==WMT_KeyChar) { if(isFocused()) { const WM_Keyboard &m = WM_Keyboard::cast(wm); wchar_t c = (wchar_t)m.key; String text = getText(); bool changed = false; if(isprint(c)) { text.insert(text.begin()+m_cursor, &c, &c+1); ++m_cursor; changed = true; } if(changed) { setText(text); } return true; } } else if(wm.type==WMT_KeyDown) { if(isFocused()) { const WM_Keyboard &m = WM_Keyboard::cast(wm); wchar_t c = (wchar_t)m.key; String text = getText(); bool changed = false; if(c==ist::KEY_ENTER) { callIfValid(m_on_chnage); setFocus(false); } else if(c==ist::KEY_DELETE) { if(m_cursor<(int32)text.size()) { text.erase(text.begin()+m_cursor, text.begin()+m_cursor+1); changed = true; } } else if(c==ist::KEY_BACK) { if(m_cursor>0) { text.erase(text.begin()+m_cursor-1, text.begin()+m_cursor); --m_cursor; changed = true; } } else if(c==ist::KEY_RIGHT) { m_cursor = ist::clamp<int32>(m_cursor+1, 0, text.size()); } else if(c==ist::KEY_LEFT) { m_cursor = ist::clamp<int32>(m_cursor-1, 0, text.size()); } if(changed) { setText(text); } } } return super::handleEvent(wm); }
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; }
void Button::draw(gcn::Graphics *graphics) { int mode; if (!isEnabled()) mode = BUTTON_DISABLED; else if (isPressed()) mode = BUTTON_PRESSED; else if (mHasMouse || isFocused()) mode = BUTTON_HIGHLIGHTED; else mode = BUTTON_STANDARD; updateAlpha(); static_cast<Graphics*>(graphics)-> drawImageRect(0, 0, getWidth(), getHeight(), button[mode]); if (mode == BUTTON_DISABLED) graphics->setColor(guiPalette->getColor(Palette::BUTTON_DISABLED)); else graphics->setColor(guiPalette->getColor(Palette::BUTTON)); int textX; int textY = getHeight() / 2 - getFont()->getHeight() / 2; switch (getAlignment()) { case gcn::Graphics::LEFT: textX = 4; break; case gcn::Graphics::CENTER: textX = getWidth() / 2; break; case gcn::Graphics::RIGHT: textX = getWidth() - 4; break; default: throw GCN_EXCEPTION("Button::draw. Unknown alignment."); } if (isFocused()) graphics->setFont(boldFont); else graphics->setFont(getFont()); if (isPressed()) graphics->drawText(getCaption(), textX + 1, textY + 1, getAlignment()); else graphics->drawText(getCaption(), textX, textY, getAlignment()); }
void MultiSelector::draw(gcn::Graphics* graphics) { if (mSelections.empty()) { return; } if (isFocused() || (!isFocused() && (mFrameCounter % 20 < 10))) { Selection selection = mSelections[mCurrentSelection]; graphics->drawImage(mSelectorImage, selection.x, selection.y); } }
void HTMLTextAreaElement::handleBeforeTextInsertedEvent( BeforeTextInsertedEvent* event) const { DCHECK(event); DCHECK(layoutObject()); int signedMaxLength = maxLength(); if (signedMaxLength < 0) return; unsigned unsignedMaxLength = static_cast<unsigned>(signedMaxLength); const String& currentValue = innerEditorValue(); unsigned currentLength = computeLengthForAPIValue(currentValue); if (currentLength + computeLengthForAPIValue(event->text()) < unsignedMaxLength) return; // selectionLength represents the selection length of this text field to be // removed by this insertion. // If the text field has no focus, we don't need to take account of the // selection length. The selection is the source of text drag-and-drop in // that case, and nothing in the text field will be removed. unsigned selectionLength = 0; if (isFocused()) { // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets // needs to be audited. See http://crbug.com/590369 for more details. document().updateStyleAndLayoutIgnorePendingStylesheets(); selectionLength = computeLengthForAPIValue( document().frame()->selection().selectedText()); } DCHECK_GE(currentLength, selectionLength); unsigned baseLength = currentLength - selectionLength; unsigned appendableLength = unsignedMaxLength > baseLength ? unsignedMaxLength - baseLength : 0; event->setText(sanitizeUserInputValue(event->text(), appendableLength)); }
bool RenderThemeGtk::paintRenderObject(GtkThemeWidgetType type, RenderObject* renderObject, GraphicsContext* context, const IntRect& rect, int flags) { // Painting is disabled so just claim to have succeeded if (context->paintingDisabled()) return false; GtkWidgetState widgetState; widgetState.active = isPressed(renderObject); widgetState.focused = isFocused(renderObject); // https://bugs.webkit.org/show_bug.cgi?id=18364 // The Mozilla theme drawing code, only paints a button as pressed when it's pressed // while hovered. Until we move away from the Mozila code, work-around the issue by // forcing a pressed button into the hovered state. This ensures that buttons activated // via the keyboard have the proper rendering. widgetState.inHover = isHovered(renderObject) || (type == MOZ_GTK_BUTTON && isPressed(renderObject)); // FIXME: Disabled does not always give the correct appearance for ReadOnly widgetState.disabled = !isEnabled(renderObject) || isReadOnlyControl(renderObject); widgetState.isDefault = false; widgetState.canDefault = false; widgetState.depressed = false; WidgetRenderingContext widgetContext(context, rect); return !widgetContext.paintMozillaWidget(type, &widgetState, flags, gtkTextDirection(renderObject->style()->direction())); }
void RenderTheme::updateControlStatesForRenderer(const RenderBox& box, ControlStates& controlStates) const { ControlStates newStates = extractControlStatesForRenderer(box); controlStates.setStates(newStates.states()); if (isFocused(box)) controlStates.setTimeSinceControlWasFocused(box.document().page()->focusController().timeSinceFocusWasSet()); }
void TabbedArea::keyPressed(gcn::KeyEvent& keyEvent) { if (keyEvent.isConsumed() || !isFocused()) return; if (keyEvent.getKey().getValue() == Key::LEFT) { TabContainer::iterator index = getTabIterator(mSelectedTab); if (index != mTabs.begin()) setSelectedTab((--index)->first); else setSelectedTab((--mTabs.end())->first); keyEvent.consume(); } else if (keyEvent.getKey().getValue() == Key::RIGHT) { TabContainer::iterator index = getTabIterator(mSelectedTab); if (index != (--mTabs.end())) setSelectedTab((++index)->first); else setSelectedTab(mTabs.begin()->first); keyEvent.consume(); } }
void TabbedPane::processKey(const scv::KeyEvent &evt) { static Kernel *kernel = Kernel::getInstance(); if (getCurrTabIndex() == -1) return; if(!_receivingCallbacks) return; if (isFocused() && evt.state == KeyEvent::DOWN) { Point currPosition = getAbsolutePosition(); if (evt.getKeyString() == "Left") { _currecOverTab = -1; if (getCurrTabIndex() == 0) { setCurrTabIndex(_children.size() - 1); configPanel(); } else { setCurrTabIndex(getCurrTabIndex() - 1); configPanel(); } } else if (evt.getKeyString() == "Right") { _currecOverTab = -1; setCurrTabIndex((getCurrTabIndex() + 1) % _children.size()); configPanel(); } } else if (getCurrTabIndex() != -1) { getChild(getCurrTabIndex())->processKey(evt); } }
bool RenderThemeWx::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { wxScrolledWindow* window = o->view()->frameView()->nativeWindow(); wxPaintDC dc((wxWindow*)window); window->DoPrepareDC(dc); int flags = 0; if (!isEnabled(o)) flags |= wxCONTROL_DISABLED; EAppearance appearance = o->style()->appearance(); if (supportsFocus(o->style()->appearance()) && isFocused(o)) flags |= wxCONTROL_FOCUSED; if (isPressed(o)) flags |= wxCONTROL_PRESSED; if(appearance == PushButtonAppearance || appearance == ButtonAppearance) wxRendererNative::Get().DrawPushButton(window, dc, r, flags); // TODO: add a radio button rendering API to wx //else if(appearance == RadioAppearance) // wxRendererNative::Get(). else if(appearance == CheckboxAppearance) wxRendererNative::Get().DrawCheckBox(window, dc, r, flags); return false; }
void AirButton::draw(ofPoint orig) { ofPoint m = ofPoint(ofGetAppPtr()->mouseX-ofGetWidth()/2,ofGetHeight()/2-ofGetAppPtr()->mouseY); _orig = orig; ofSetColor(255,255,255); _img.draw(ofPoint(_orig.x+IMG_GAP, _orig.y+IMG_GAP)); if (isFocused(m)) { if (isSelected()) ofSetColor(0,255,0); else ofSetColor(0,0,255); ofNoFill(); ofDrawRectangle(_orig, _width, _height); } else if (isSelected()) { ofSetColor(0,255,0); ofNoFill(); ofDrawRectangle(_orig, _width, _height); } }
void VerticalListLayout::onEvent(const Event &e) { Layouter::onEvent(e); if(e.type == EventType::Focus) { if(!e.focus.wasHandled() && (memberInFocus() || isFocused())) { if(e.focus.direction == UP) { if(m_currentlyFocused != 0) { m_currentlyFocused -= 1; e.focus.setHandled(); getGlobalConfig()->getFocusManager()->setFocused(getCurrentlyFocusedWidget(), e.playerID); } } else if(e.focus.direction == DOWN) { if((m_currentlyFocused + 1) < m_widgets->size()) { m_currentlyFocused += 1; e.focus.setHandled(); getGlobalConfig()->getFocusManager()->setFocused(getCurrentlyFocusedWidget(), e.playerID); } } } } }
void ckvdSingleColorGrabber::draw() { ofPushStyle(); ofSetColor(_color); ofFill(); ofRect(x-width/2, y-height/2, width, height); if (isFocused()) { ofSetColor(255, 255, 100); drawCrosshair(x, y, width, height, 5); ofSetColor(60, 60, 60); drawCrosshair(x, y, width, height, 1); ofSetColor(255, 255, 100); } else { ofSetColor(255, 255, 255); drawCrosshair(x, y, width, height, 1); } if (theApp()->getGrabberFont()) { theApp()->getGrabberFont()->drawString(_fixture.getName(), x+width/2+3, y-height/2+3); } ofPopStyle(); }
ControlStates::States RenderTheme::extractControlStatesForRenderer(const RenderObject& o) const { ControlStates::States states = 0; if (isHovered(o)) { states |= ControlStates::HoverState; if (isSpinUpButtonPartHovered(o)) states |= ControlStates::SpinUpState; } if (isPressed(o)) { states |= ControlStates::PressedState; if (isSpinUpButtonPartPressed(o)) states |= ControlStates::SpinUpState; } if (isFocused(o) && o.style().outlineStyleIsAuto()) states |= ControlStates::FocusState; if (isEnabled(o)) states |= ControlStates::EnabledState; if (isChecked(o)) states |= ControlStates::CheckedState; if (isDefault(o)) states |= ControlStates::DefaultState; if (!isActive(o)) states |= ControlStates::WindowInactiveState; if (isIndeterminate(o)) states |= ControlStates::IndeterminateState; return states; }
void ckvdTileGrabber::draw() { ofPushStyle(); if (isFocused()) { ofSetColor(255, 255, 100); drawCornerTickBox(x - width/2, y - height/2, width, height, 5); ofSetColor(60, 60, 60); drawCornerTickBox(x - width/2, y - height/2, width, height, 1); ofSetColor(255, 255, 100); } else { ofSetColor(255, 255, 255); drawCornerTickBox(x - width/2, y - height/2, width, height, 1); } int r = (width + height) / 5; int d = 10; float c = cos((270 + _fixture.getRotation()) * pi/180.0); float s = sin((270 + _fixture.getRotation()) * pi/180.0); ofLine((int)floor(x + r * c), int(floor(y + r * s)), int(floor(x + (r + d) * c)), int(floor(y + (r + d) * s))); if (theApp()->getGrabberFont()) { ostringstream ss; ss << "#" << getParameterInt("SUPPLY") << " " << _fixture.getName(); ofTrueTypeFont* pFont = theApp()->getGrabberFont(); pFont->drawString(ss.str(), x - pFont->stringWidth(ss.str())/2, y + pFont->stringHeight(ss.str())/2); } ofPopStyle(); }
bool RenderThemeGtk::paintSliderTrack(RenderObject* object, const PaintInfo& info, const IntRect& rect) { if (info.context->paintingDisabled()) return false; ControlPart part = object->style()->appearance(); ASSERT(part == SliderHorizontalPart || part == SliderVerticalPart); // We shrink the trough rect slightly to make room for the focus indicator. IntRect troughRect(IntPoint(), rect.size()); // This is relative to rect. GtkWidget* widget = 0; if (part == SliderVerticalPart) { widget = gtkVScale(); troughRect.inflateY(-gtk_widget_get_style(widget)->ythickness); } else { widget = gtkHScale(); troughRect.inflateX(-gtk_widget_get_style(widget)->xthickness); } gtk_widget_set_direction(widget, gtkTextDirection(object->style()->direction())); WidgetRenderingContext widgetContext(info.context, rect); widgetContext.gtkPaintBox(troughRect, widget, GTK_STATE_ACTIVE, GTK_SHADOW_OUT, "trough"); if (isFocused(object)) widgetContext.gtkPaintFocus(IntRect(IntPoint(), rect.size()), widget, getGtkStateType(object), "trough"); return false; }
//------------------------------------------------------------------ bool textInput::mouseReleased(ofMouseEventArgs &e) { if (hit) { if (isFocused()) { if (getTextString() != "midi device") { this->dropdownList->setVisible(true); } else if (midiList != NULL){ this->midiList->setVisible(true); } } else { dropdownList->clearSelected(); if (getTextString() != "midi device") { this->dropdownList->setVisible(false); } else if (midiList != NULL) { this->midiList->setVisible(false); midiList->clearSelected(); } } } return ofxUITextInput::mouseReleased(e); }
void HTMLTextAreaElement::subtreeHasChanged() { #if DCHECK_IS_ON() // The innerEditor should have either Text nodes or a placeholder break // element. If we see other nodes, it's a bug in editing code and we should // fix it. Element* innerEditor = innerEditorElement(); for (Node& node : NodeTraversal::descendantsOf(*innerEditor)) { if (node.isTextNode()) continue; DCHECK(isHTMLBRElement(node)); DCHECK_EQ(&node, innerEditor->lastChild()); } #endif addPlaceholderBreakElementIfNecessary(); setChangedSinceLastFormControlChangeEvent(true); m_valueIsUpToDate = false; setNeedsValidityCheck(); setAutofilled(false); updatePlaceholderVisibility(); if (!isFocused()) return; // When typing in a textarea, childrenChanged is not called, so we need to // force the directionality check. calculateAndAdjustDirectionality(); DCHECK(document().isActive()); document().frameHost()->chromeClient().didChangeValueInTextField(*this); }
void TabbedArea::keyPressed(gcn::KeyEvent& keyEvent) { if (keyEvent.isConsumed() || !isFocused()) return; if (keyEvent.getKey().getValue() == Key::LEFT) { int index = getSelectedTabIndex(); index--; if (index < 0) setSelectedTab(mTabs[mTabs.size() - 1].first); else setSelectedTab(mTabs[index].first); keyEvent.consume(); } else if (keyEvent.getKey().getValue() == Key::RIGHT) { int index = getSelectedTabIndex(); index++; if (index >= (int) mTabs.size()) setSelectedTab(mTabs[0].first); else setSelectedTab(mTabs[index].first); keyEvent.consume(); } }
void HTMLTextAreaElement::setValueCommon(const String& newValue, TextFieldEventBehavior eventBehavior, SetValueCommonOption setValueOption) { // Code elsewhere normalizes line endings added by the user via the keyboard // or pasting. We normalize line endings coming from JavaScript here. String normalizedValue = newValue.isNull() ? "" : newValue; normalizedValue.replace("\r\n", "\n"); normalizedValue.replace('\r', '\n'); // Return early because we don't want to trigger other side effects // when the value isn't changing. // FIXME: Simple early return doesn't match the Firefox ever. // Remove these lines. if (normalizedValue == value()) { if (setValueOption == SetSeletion) { setNeedsValidityCheck(); if (isFinishedParsingChildren()) { // Set the caret to the end of the text value except for initialize. unsigned endOfString = m_value.length(); setSelectionRange(endOfString, endOfString); } } return; } m_value = normalizedValue; setInnerEditorValue(m_value); if (eventBehavior == DispatchNoEvent) setLastChangeWasNotUserEdit(); updatePlaceholderVisibility(); setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create( StyleChangeReason::ControlValue)); m_suggestedValue = String(); setNeedsValidityCheck(); if (isFinishedParsingChildren()) { // Set the caret to the end of the text value except for initialize. unsigned endOfString = m_value.length(); setSelectionRange(endOfString, endOfString); } notifyFormStateChanged(); switch (eventBehavior) { case DispatchChangeEvent: dispatchFormControlChangeEvent(); break; case DispatchInputAndChangeEvent: dispatchFormControlInputEvent(); dispatchFormControlChangeEvent(); break; case DispatchNoEvent: // We need to update textAsOfLastFormControlChangeEvent for |value| IDL // setter without focus because input-assist features use setValue("...", // DispatchChangeEvent) without setting focus. if (!isFocused()) setTextAsOfLastFormControlChangeEvent(normalizedValue); break; } }
bool RenderThemeWx::paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& r) { wxWindow* window = nativeWindowForRenderObject(o); wxDC* dc = static_cast<wxDC*>(i.context->platformContext()); LocalDC localDC(dc, r); IntRect rect = r; int flags = 0; if (!isEnabled(o)) flags |= wxCONTROL_DISABLED; if (supportsFocus(o->style()->appearance()) && isFocused(o)) flags |= wxCONTROL_FOCUSED; if (isPressed(o)) flags |= wxCONTROL_PRESSED; #if wxCHECK_VERSION(2,9,0) wxRendererNative::Get().DrawChoice(window, *localDC.context(), rect, flags); #else wxRenderer_DrawChoice(window, *localDC.context(), rect, flags); #endif return false; }
void DBListBox::draw(gcn::Graphics* graphics) { gcn::AllegroGraphics* allegroGraphics = static_cast<gcn::AllegroGraphics*>(graphics); if (mListModel == NULL) { return; } allegroGraphics->setColor(getForegroundColor()); allegroGraphics->setFont(getFont()); int i, fontHeight; int y = 0; fontHeight = getFont()->getHeight(); for (i = 0; i < mListModel->getNumberOfElements(); ++i) { allegroGraphics->drawText(mListModel->getElementAt(i), 10, y); if (i == mSelected) { if (isFocused()) { allegroGraphics->drawBitmap(mSelectedImage, 0, y + 1); } } y += fontHeight; } }
unsigned RenderThemeChromiumWin::determineState(RenderObject* o, ControlSubPart subPart) { unsigned result = TS_NORMAL; ControlPart appearance = o->style()->appearance(); if (!isEnabled(o)) result = TS_DISABLED; else if (isReadOnlyControl(o)) result = (appearance == TextFieldPart || appearance == TextAreaPart || appearance == SearchFieldPart) ? ETS_READONLY : TS_DISABLED; // Active overrides hover and focused. else if (isPressed(o) && (subPart == SpinButtonUp) == isSpinUpButtonPartPressed(o)) result = TS_PRESSED; else if (supportsFocus(appearance) && isFocused(o)) result = ETS_FOCUSED; else if (isHovered(o) && (subPart == SpinButtonUp) == isSpinUpButtonPartHovered(o)) result = TS_HOT; // CBS_UNCHECKED*: 1-4 // CBS_CHECKED*: 5-8 // CBS_MIXED*: 9-12 if (isIndeterminate(o)) result += 8; else if (isChecked(o)) result += 4; return result; }
ControlStates RenderTheme::controlStatesForRenderer(const RenderObject* o) const { ControlStates result = 0; if (isHovered(o)) { result |= HoverState; if (isSpinUpButtonPartHovered(o)) result |= SpinUpState; } if (isPressed(o)) { result |= PressedState; if (isSpinUpButtonPartPressed(o)) result |= SpinUpState; } if (isFocused(o) && o->style()->outlineStyleIsAuto()) result |= FocusState; if (isEnabled(o)) result |= EnabledState; if (isChecked(o)) result |= CheckedState; if (isReadOnlyControl(o)) result |= ReadOnlyState; if (isDefault(o)) result |= DefaultState; if (!isActive(o)) result |= WindowInactiveState; if (isIndeterminate(o)) result |= IndeterminateState; return result; }
bool RenderThemeWx::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { wxWindow* window = o->view()->frameView()->nativeWindow(); wxDC* dc = static_cast<wxDC*>(i.context->platformContext()); wxASSERT(dc->IsOk()); int flags = 0; if (!isEnabled(o)) flags |= wxCONTROL_DISABLED; EAppearance appearance = o->style()->appearance(); if (supportsFocus(o->style()->appearance()) && isFocused(o)) flags |= wxCONTROL_FOCUSED; if (isPressed(o)) flags |= wxCONTROL_PRESSED; if (appearance == PushButtonAppearance || appearance == ButtonAppearance) wxRendererNative::Get().DrawPushButton(window, *dc, r, flags); // TODO: add a radio button rendering API to wx //else if(appearance == RadioAppearance) else if(appearance == CheckboxAppearance) { if (isChecked(o)) flags |= wxCONTROL_CHECKED; wxRendererNative::Get().DrawCheckBox(window, *dc, r, flags); } return false; }