Exemplo n.º 1
0
		void CGUISpinBox::setValue(f32 val)
		{
			wchar_t str[100];

			swprintf(str, 99, FormatString.c_str(), val);
			EditBox->setText(str);
			verifyValueRange();
		}
Exemplo n.º 2
0
bool CGUISpinBox::OnEvent(const SEvent& event)
{
	if (IsEnabled)
	{
		bool changeEvent = false;
		switch(event.EventType)
		{
		case EET_GUI_EVENT:
			if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED)
			{
				if (event.GUIEvent.Caller == ButtonSpinUp)
				{
					f32 val = getValue();
					val += StepSize;
					setValue(val);
					changeEvent = true;
				}
				else if ( event.GUIEvent.Caller == ButtonSpinDown)
				{
					f32 val = getValue();
					val -= StepSize;
					setValue(val);
					changeEvent = true;
				}
			}
			if ( event.GUIEvent.EventType == EGET_EDITBOX_ENTER )
			{
				if (event.GUIEvent.Caller == EditBox)
				{
					verifyValueRange();
					changeEvent = true;
				}
			}
			break;
		default:
		break;
		}

		if ( changeEvent )
		{
			SEvent e;
			e.EventType = EET_GUI_EVENT;
			e.GUIEvent.Caller = this;
			e.GUIEvent.Element = 0;

			e.GUIEvent.EventType = EGET_SPINBOX_CHANGED;
			if ( Parent )
				Parent->OnEvent(e);
			return true;
		}
	}

	return IGUIElement::OnEvent(event);
}
Exemplo n.º 3
0
		void CGUISpinBox::setRange(f32 min, f32 max)
		{
			if (max < min)
			{ core::swap(min, max); }
			RangeMin = min;
			RangeMax = max;

			// we have to round the range - otherwise we can get into an infinte setValue/verifyValueRange cycle.
			wchar_t str[100];
			swprintf(str, 99, FormatString.c_str(), RangeMin);
			RangeMin = core::fast_atof(core::stringc(str).c_str());
			swprintf(str, 99, FormatString.c_str(), RangeMax);
			RangeMax = core::fast_atof(core::stringc(str).c_str());

			verifyValueRange();
		}
Exemplo n.º 4
0
		//! Sets the new caption of the element
		void CGUISpinBox::setText(const wchar_t * text)
		{
			EditBox->setText(text);
			setValue(getValue());
			verifyValueRange();
		}
Exemplo n.º 5
0
void CGUISpinBox::setRange(f32 min, f32 max)
{
	RangeMin = min;
	RangeMax = max;
	verifyValueRange();
}
Exemplo n.º 6
0
bool CGUISpinBox::OnEvent(const SEvent& event)
{
	if (IsEnabled)
	{
		bool changeEvent = false;
		bool eatEvent = false;
		switch(event.EventType)
		{
		case EET_MOUSE_INPUT_EVENT:
			switch(event.MouseInput.Event)
			{
			case EMIE_MOUSE_WHEEL:
				{
					f32 val = getValue() + (StepSize * (event.MouseInput.Wheel < 0 ? -1.f : 1.f));
					setValue(val);
					changeEvent = true;
					eatEvent = true;
				}
				break;
			default:
				break;
			}
			break;

		case EET_GUI_EVENT:

			if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED)
			{
				if (event.GUIEvent.Caller == ButtonSpinUp)
				{
					f32 val = getValue();
					val += StepSize;
					setValue(val);
					changeEvent = true;
				}
				else if ( event.GUIEvent.Caller == ButtonSpinDown)
				{
					f32 val = getValue();
					val -= StepSize;
					setValue(val);
					changeEvent = true;
				}
			}
			if (event.GUIEvent.Caller == EditBox)
			{
				if (	(event.GUIEvent.EventType == EGET_EDITBOX_CHANGED && ValidateOn & EGUI_SBV_CHANGE)
					||	(event.GUIEvent.EventType == EGET_EDITBOX_ENTER && ValidateOn & EGUI_SBV_ENTER)
					||	(event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST && ValidateOn & EGUI_SBV_LOSE_FOCUS)
					)
				{
					verifyValueRange();
					changeEvent = true;
				}
			}
			break;
		default:
		break;
		}

		if ( changeEvent )
		{
			SEvent e;
			e.EventType = EET_GUI_EVENT;
			e.GUIEvent.Caller = this;
			e.GUIEvent.Element = 0;

			e.GUIEvent.EventType = EGET_SPINBOX_CHANGED;
			if ( Parent )
				Parent->OnEvent(e);
			if ( eatEvent )
				return true;
		}
	}

	return IGUIElement::OnEvent(event);
}