コード例 #1
0
/******************************************************************************
* Connects this spinner with the given textbox control.
******************************************************************************/
void SpinnerWidget::setTextBox(QLineEdit* box)
{
	if(box == textBox()) return;
	if(_textBox.isNull() == false) {
		disconnect(_textBox.data(), &QLineEdit::editingFinished, this, &SpinnerWidget::onTextChanged);
	}
	_textBox = box;
	if(_textBox.isNull() == false) {
		connect(box, &QLineEdit::editingFinished, this, &SpinnerWidget::onTextChanged);
		box->setEnabled(isEnabled());
		updateTextBox();
	}
}
コード例 #2
0
/******************************************************************************
* Sets the current value of the spinner.
******************************************************************************/
void SpinnerWidget::setFloatValue(FloatType newVal, bool emitChangeSignal)
{
	// Clamp value.
	if(newVal == _value) return;
	newVal = std::max(minValue(), newVal);
	newVal = std::min(maxValue(), newVal);
	if(_value != newVal) {
		_value = newVal;
		if(emitChangeSignal)
			Q_EMIT spinnerValueChanged();
	}
	updateTextBox();
}
コード例 #3
0
ファイル: chatBox.c プロジェクト: djeck/SixPrend
void pushChatBox(ChatBox* ptr)
{
  int i;
  for(i=0;i<NB_MSG-1;i++)
  {
    strcpy(ptr->text[i],ptr->text[i+1]);
    updateText(&ptr->messages[i],ptr->text[i]);
  }
  strcpy(ptr->text[NB_MSG-1],ptr->input.text);
  updateText(&ptr->messages[NB_MSG-1],ptr->text[NB_MSG-1]);
  ptr->input.text[0]='\0';
  updateTextBox(&ptr->input);
  ptr->update = false;
}
コード例 #4
0
/******************************************************************************
* Sets the units of this spinner's value.
******************************************************************************/
void SpinnerWidget::setUnit(ParameterUnit* unit) 
{ 
	if(unit == _unit)
		return;

	if(_unit)
		disconnect(_unit, &ParameterUnit::formatChanged, this, &SpinnerWidget::updateTextBox);
	
	_unit = unit; 
	
	if(_unit)
		connect(_unit, &ParameterUnit::formatChanged, this, &SpinnerWidget::updateTextBox);

	updateTextBox(); 
}
コード例 #5
0
/******************************************************************************
* Sets the current integer value of the spinner.
******************************************************************************/
void SpinnerWidget::setIntValue(int newValInt, bool emitChangeSignal)
{
	FloatType newVal = (FloatType)newValInt;

	if(newVal == _value) return;
	// Clamp value.
	newVal = std::max((FloatType)ceil(minValue()), newVal);
	newVal = std::min((FloatType)floor(maxValue()), newVal);
	if(_value != newVal) {
		_value = newVal;
		if(emitChangeSignal)
			Q_EMIT spinnerValueChanged();
	}
	updateTextBox();
}
コード例 #6
0
/******************************************************************************
* Will be called when the user has entered a new text into the text box.
* The text will be parsed and taken as the new value of the spinner.
******************************************************************************/
void SpinnerWidget::onTextChanged()
{
	OVITO_CHECK_POINTER(textBox());
    
	FloatType newValue;
	try {
		if(textBox()->text() == _originalText) return;
		if(unit()) {
			newValue = unit()->parseString(textBox()->text());
			setFloatValue(unit()->userToNative(newValue), true);
		}
		else {
			bool ok;
			newValue = textBox()->text().toDouble(&ok);
			if(!ok)
				throw Exception(tr("Invalid floating-point value: %1").arg(textBox()->text()));
			setFloatValue(newValue, true);
		}
	}
	catch(const Exception&) {
		// Ignore invalid value and restore old text content.
		updateTextBox();
	}	
}
コード例 #7
0
void SFMLCursesTextBox::setAlignment(SFMLCursesTextBox::Alignment::E alignment)
{
	m_alignment = alignment;
	updateTextBox();
}
コード例 #8
0
void SFMLCursesTextBox::setText(const std::string& text)
{
	m_text = text;
	updateTextBox();
}
コード例 #9
0
void SFMLCursesTextBox::setBackgroundColor(const sf::Color& color)
{
	m_backColor = color;
	updateTextBox();
}
コード例 #10
0
void SFMLCursesTextBox::setTextColor(const sf::Color& color)
{
	m_textColor = color;
	updateTextBox();
}