void CUISlider::OnLButtonDown(POINT point) { screenToClient(point); if(PtInRect(&m_rcButton, point)) { // Pressed while inside the control SetPressed(true); //m_nDragX = pt.x; m_ptDragOffset.x = m_rcButton.right - point.x; m_ptDragOffset.y = m_rcButton.bottom - point.y; SetFocus(); return; } if(m_rcRelativeBox.ptInRect(point)) { m_ptDragOffset.x=0; m_ptDragOffset.y=0; //SetPressed(true); SetFocus(); if(m_bH) { if(point.x > m_rcButton.left) { SetValueInternal(m_nValue + __max(m_nPageSize-1,1)); return; } if(point.x < m_rcButton.right) { SetValueInternal(m_nValue - __max(m_nPageSize-1,1)); return; } } else { if(point.y > m_rcButton.top) { SetValueInternal(m_nValue + m_nPageSize - 1); return; } if(point.y < m_rcButton.bottom) { SetValueInternal(m_nValue - m_nPageSize + 1); return; } } } }
void HTMLTextAreaElement::SetValue(const nsAString& aValue, ErrorResult& aError) { // If the value has been set by a script, we basically want to keep the // current change event state. If the element is ready to fire a change // event, we should keep it that way. Otherwise, we should make sure the // element will not fire any event because of the script interaction. // // NOTE: this is currently quite expensive work (too much string // manipulation). We should probably optimize that. nsAutoString currentValue; GetValueInternal(currentValue, true); nsresult rv = SetValueInternal( aValue, nsTextEditorState::eSetValue_ByContent | nsTextEditorState::eSetValue_Notify | nsTextEditorState::eSetValue_MoveCursorToEndIfValueChanged); if (NS_WARN_IF(NS_FAILED(rv))) { aError.Throw(rv); return; } if (mFocusedValue.Equals(currentValue)) { GetValueInternal(mFocusedValue, true); } }
//----------------------------------------------------------------------------- // Name : SetRange() //----------------------------------------------------------------------------- void CSliderUI::SetRange( int nMin, int nMax ) { m_nMin = nMin; m_nMax = nMax; SetValueInternal( m_nValue, false ); }
void HTMLTextAreaElement::SetUserInput(const nsAString& aValue, nsIPrincipal& aSubjectPrincipal) { SetValueInternal( aValue, nsTextEditorState::eSetValue_BySetUserInput | nsTextEditorState::eSetValue_Notify | nsTextEditorState::eSetValue_MoveCursorToEndIfValueChanged); }
void ValueSliderWithLabel::ValueChanged( Base * pControl) { Gwen::Controls::TextBoxNumeric * pTextBox = (Gwen::Controls::TextBoxNumeric *)pControl; SetValueInternal(pTextBox->GetFloatFromText(), true, false); }
// Called when the slider's bar position is set or dragged. float WidgetSliderInput::OnBarChange(float bar_position) { float new_value = min_value + bar_position * (max_value - min_value); int num_steps = Rocket::Core::Math::Round((new_value - value) / step); return SetValueInternal(value + num_steps * step); }
void WidgetSliderInput::SetValue(float value) { float num_steps = (value - min_value) / step; float new_value = min_value + Rocket::Core::Math::Round(num_steps) * step; SetBarPosition(SetValueInternal(new_value)); }
NS_IMETHODIMP HTMLTextAreaElement::SetUserInput(const nsAString& aValue) { if (!nsContentUtils::IsCallerChrome()) { return NS_ERROR_DOM_SECURITY_ERR; } return SetValueInternal(aValue, nsTextEditorState::eSetValue_BySetUserInput); }
void ValueSliderWithLabel::SliderMoved( Base * pControl) { Gwen::Controls::Slider * pSlider = (Gwen::Controls::Slider *)pControl; float rescaled = GetRescaledValue(pSlider->GetValue()); SetValueInternal(rescaled, false, true); }
void CGM_Slider::SetRange( int iMin, int iMax ) { m_iMin = iMin; m_iMax = iMax; SetValueInternal( m_iValue, false ); }
//----------------------------------------------------------------------------- // Name : Dragged() //----------------------------------------------------------------------------- bool CSliderUI::Dragged( POINT pt) { if( m_bPressed ) { SetValueInternal( ValueFromPos( m_x + pt.x + m_nDragOffset ), true ); return true; } return false; }
NS_IMETHODIMP HTMLTextAreaElement::SetUserInput(const nsAString& aValue) { if (!nsContentUtils::IsCallerChrome()) { return NS_ERROR_DOM_SECURITY_ERR; } SetValueInternal(aValue, true); return NS_OK; }
NS_IMETHODIMP nsHTMLTextAreaElement::SetUserInput(const nsAString& aValue) { if (!nsContentUtils::IsCallerTrustedForWrite()) { return NS_ERROR_DOM_SECURITY_ERR; } SetValueInternal(aValue, nsnull, PR_TRUE); return NS_OK; }
bool CGM_Slider::HandleKeyboardInput( CGM_InputData& input ) { if( !IsEnabled() || !IsVisible() ) return false; switch( GetInputCode(input) ) { case CGM_Input::INCREASE_SLIDER_VALUE: if( input.type == CGM_InputData::TYPE_PRESSED ) { SetValueInternal( m_iValue + m_iShiftAmount, true ); return true; } break; case CGM_Input::DECREASE_SLIDER_VALUE: if( input.type == CGM_InputData::TYPE_PRESSED ) { SetValueInternal( m_iValue - m_iShiftAmount, true ); return true; } break; } /* SPoint pt = input.pos; if( input.code == m_aInputCode[ IC_INCREASE ] ) { if( input.type == CGM_InputData::TYPE_PRESSED ) { SetValueInternal( m_iValue + m_iShiftAmount, true ); return true; } } else if( input.code == m_aInputCode[ IC_DECREASE ] ) { if( input.type == CGM_InputData::TYPE_PRESSED ) { SetValueInternal( m_iValue - m_iShiftAmount, true ); return true; } } */ return false; }
void CUISlider::OnMouseMove(POINT pt) { if(IsPressed()) { screenToClient(pt); pt.x+=m_ptDragOffset.x; pt.y+=m_ptDragOffset.y; SetValueInternal(ValueFromPos(pt)); } }
//----------------------------------------------------------------------------- // Name : Pressed() //----------------------------------------------------------------------------- bool CSliderUI::Pressed( HWND hWnd, POINT pt, INPUT_STATE inputState, CTimer* timer) { if( PtInRect( &m_rcButton, pt ) ) { // Pressed while inside the control m_bPressed = true; SetCapture( hWnd ); m_nDragX = pt.x; //m_nDragY = pt.y; m_nDragOffset = m_nButtonX - m_nDragX; //m_nDragValue = m_nValue; if( !m_bHasFocus ) m_pParentDialog->RequestFocus( this ); return true; } if( PtInRect( &m_rcBoundingBox, pt ) ) { m_nDragX = pt.x; m_nDragOffset = 0; m_bPressed = true; if( !m_bHasFocus ) m_pParentDialog->RequestFocus( this ); if( pt.x > m_nButtonX + m_x ) { SetValueInternal( m_nValue + 1, true ); return true; } if( pt.x < m_nButtonX + m_x ) { SetValueInternal( m_nValue - 1, true ); return true; } } return false; }
//----------------------------------------------------------------------------- // Name : Scrolled() //----------------------------------------------------------------------------- bool CSliderUI::Scrolled( int nScrollAmount) { if (m_bMouseOver) { //int nScrollAmount = int( ( short )HIWORD( wParam ) ) / WHEEL_DELTA; SetValueInternal( m_nValue - nScrollAmount, true ); return true; } return false; }
nsresult HTMLTextAreaElement::Reset() { nsAutoString resetVal; GetDefaultValue(resetVal, IgnoreErrors()); SetValueChanged(false); nsresult rv = SetValueInternal(resetVal, nsTextEditorState::eSetValue_Internal); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; }
bool TBInlineSelect::OnEvent(const TBWidgetEvent &ev) { if (ev.type == EVENT_TYPE_KEY_DOWN) { if (ev.special_key == TB_KEY_UP || ev.special_key == TB_KEY_DOWN) { double dv = ev.special_key == TB_KEY_UP ? 1 : -1; SetValueDouble(GetValueDouble() + dv); return true; } } else if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("dec")) { SetValueDouble(GetValueDouble() - 1); if (!ev.target->IsCaptured()) { InvokeModifiedEvent(); } return true; } else if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("inc")) { SetValueDouble(GetValueDouble() + 1); if (!ev.target->IsCaptured()) { InvokeModifiedEvent(); } return true; } else if (ev.type == EVENT_TYPE_CHANGED && ev.target == &m_editfield) { TBStr text; m_editfield.GetText(text); SetValueInternal((double) atof(text), false); } else if (ev.type == EVENT_TYPE_CHANGED && ev.target == this) { return TBWidget::OnEvent(ev); } return false; }
void QtPropertyData::SetValue(const QVariant &value) { QVariant oldValue = curValue; curValue = value; SetValueInternal(curValue); if(curValue != oldValue) { emit ValueChanged(); } // change signal going down to childs ChildNeedUpdate(); // change signal going up to parents ParentUpdate(); }
NS_IMETHODIMP HTMLTextAreaElement::SetValue(const nsAString& aValue) { // If the value has been set by a script, we basically want to keep the // current change event state. If the element is ready to fire a change // event, we should keep it that way. Otherwise, we should make sure the // element will not fire any event because of the script interaction. // // NOTE: this is currently quite expensive work (too much string // manipulation). We should probably optimize that. nsAutoString currentValue; GetValueInternal(currentValue, true); SetValueInternal(aValue, false); if (mFocusedValue.Equals(currentValue)) { GetValueInternal(mFocusedValue, true); } return NS_OK; }
void FieldInfoImpl::SetValue(Value& thisObject, const Value& newValue) { if(thisObject.IsNull()) { throw ArgumentNullException(L"thisObject", this); } else { auto td = thisObject.GetTypeDescriptor(); auto valueType = td->GetValueSerializer() ? Value::Text : Value::RawPtr; if(!thisObject.CanConvertTo(ownerTypeDescriptor, valueType)) { throw ArgumentTypeMismtatchException(L"thisObject", ownerTypeDescriptor, valueType, thisObject); } } if(!newValue.CanConvertTo(returnInfo.Obj())) { throw ArgumentTypeMismtatchException(L"newValue", returnInfo.Obj(), newValue); } SetValueInternal(thisObject, newValue); }
bool CUISlider::HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam) { if(!m_bEnabled || !m_bVisible) return false; switch(uMsg) { case WM_KEYDOWN: { switch(wParam) { case VK_HOME: SetValueInternal(m_nMin); return true; case VK_END: SetValueInternal(m_nMax); return true; case VK_LEFT: case VK_UP: SetValueInternal(m_nValue - 1); return true; case VK_RIGHT: case VK_DOWN: SetValueInternal(m_nValue + 1); return true; case VK_NEXT: SetValueInternal(m_nValue - (10 > (m_nMax - m_nMin) / 10 ? 10 : (m_nMax - m_nMin) / 10)); return true; case VK_PRIOR: SetValueInternal(m_nValue + (10 > (m_nMax - m_nMin) / 10 ? 10 : (m_nMax - m_nMin) / 10)); return true; } break; } } return false; }
void ValueSliderWithLabel::SetValue( float value) { SetValueInternal(value); }
NS_IMETHODIMP nsHTMLTextAreaElement::SetValue(const nsAString& aValue) { return SetValueInternal(aValue, nsnull, PR_FALSE); }
void HTMLTextAreaElement::SetRangeText(const nsAString& aReplacement, uint32_t aStart, uint32_t aEnd, const SelectionMode& aSelectMode, ErrorResult& aRv, int32_t aSelectionStart, int32_t aSelectionEnd) { if (aStart > aEnd) { aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); return; } nsAutoString value; GetValueInternal(value, false); uint32_t inputValueLength = value.Length(); if (aStart > inputValueLength) { aStart = inputValueLength; } if (aEnd > inputValueLength) { aEnd = inputValueLength; } if (aSelectionStart == -1 && aSelectionEnd == -1) { aRv = GetSelectionRange(&aSelectionStart, &aSelectionEnd); if (aRv.Failed()) { if (mState.IsSelectionCached()) { aSelectionStart = mState.GetSelectionProperties().mStart; aSelectionEnd = mState.GetSelectionProperties().mEnd; aRv = NS_OK; } } } if (aStart <= aEnd) { value.Replace(aStart, aEnd - aStart, aReplacement); SetValueInternal(value, false); } uint32_t newEnd = aStart + aReplacement.Length(); int32_t delta = aReplacement.Length() - (aEnd - aStart); switch (aSelectMode) { case mozilla::dom::SelectionMode::Select: { aSelectionStart = aStart; aSelectionEnd = newEnd; } break; case mozilla::dom::SelectionMode::Start: { aSelectionStart = aSelectionEnd = aStart; } break; case mozilla::dom::SelectionMode::End: { aSelectionStart = aSelectionEnd = newEnd; } break; case mozilla::dom::SelectionMode::Preserve: { if ((uint32_t)aSelectionStart > aEnd) { aSelectionStart += delta; } else if ((uint32_t)aSelectionStart > aStart) { aSelectionStart = aStart; } if ((uint32_t)aSelectionEnd > aEnd) { aSelectionEnd += delta; } else if ((uint32_t)aSelectionEnd > aStart) { aSelectionEnd = newEnd; } } break; } Optional<nsAString> direction; SetSelectionRange(aSelectionStart, aSelectionEnd, direction, aRv); }
nsresult HTMLTextAreaElement::SetValueFromSetRangeText( const nsAString& aValue) { return SetValueInternal(aValue, nsTextEditorState::eSetValue_ByContent | nsTextEditorState::eSetValue_Notify); }
NS_IMETHODIMP HTMLTextAreaElement::SetUserInput(const nsAString& aValue) { return SetValueInternal(aValue, nsTextEditorState::eSetValue_BySetUserInput); }
void CUISlider::OnMouseWheel(POINT point,short wheelDelta) { int nScrollAmount = int(wheelDelta) / WHEEL_DELTA; SetValueInternal(m_nValue - nScrollAmount); }
//----------------------------------------------------------------------------- // Name : SetValue() //----------------------------------------------------------------------------- void CSliderUI::SetValue( int nValue ) { SetValueInternal( nValue, false ); }