107 lines
3.2 KiB
C++
107 lines
3.2 KiB
C++
/** @file
|
|
* @author Edouard DUPIN
|
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
* @license MPL v2.0 (see license file)
|
|
*/
|
|
#include <ewol/debug.hpp>
|
|
#include <ewol/ewol.hpp>
|
|
#include <ewol/widget/Spin.hpp>
|
|
#include <ewol/widget/ContextMenu.hpp>
|
|
#include <ewol/widget/Label.hpp>
|
|
#include <ewol/widget/Windows.hpp>
|
|
#include <etk/typeInfo.hpp>
|
|
ETK_DECLARE_TYPE(ewol::widget::Spin);
|
|
|
|
ewol::widget::Spin::Spin() :
|
|
signalValue(this, "value",
|
|
"Spin value change"),
|
|
signalValueDouble(this, "valueDouble",
|
|
"Spin value change value in 'double'"),
|
|
propertyValue(this, "value",
|
|
0,
|
|
"Value of the Spin",
|
|
ewol::widget::Spin::onChangePropertyValue),
|
|
propertyMin(this, "min",
|
|
-9999999999,
|
|
"Minimum value of the spin",
|
|
ewol::widget::Spin::onChangePropertyMin),
|
|
propertyMax(this, "max",
|
|
9999999999,
|
|
"Maximum value of the spin",
|
|
ewol::widget::Spin::onChangePropertyMax),
|
|
propertyIncrement(this, "increment",
|
|
1,
|
|
"Increment value at each button event or keybord event",
|
|
ewol::widget::Spin::onChangePropertyIncrement),
|
|
propertyMantis(this, "mantis",
|
|
0,
|
|
"fix-point mantis",
|
|
ewol::widget::Spin::onChangePropertyMantis) {
|
|
addObjectType("ewol::widget::Spin");
|
|
propertyShape.setDirectCheck(etk::Uri("THEME_GUI:///Spin.json?lib=ewol"));
|
|
}
|
|
|
|
ewol::widget::Spin::~Spin() {
|
|
|
|
}
|
|
|
|
void ewol::widget::Spin::onChangePropertyValue() {
|
|
markToRedraw();
|
|
if (this.widgetEntry == null) {
|
|
Log.error("Can not acces at entry ...");
|
|
return;
|
|
}
|
|
checkValue(*propertyValue);
|
|
}
|
|
|
|
void ewol::widget::Spin::onChangePropertyMin() {
|
|
checkValue(*propertyValue);
|
|
}
|
|
|
|
void ewol::widget::Spin::onChangePropertyMax() {
|
|
checkValue(*propertyValue);
|
|
}
|
|
|
|
void ewol::widget::Spin::onChangePropertyIncrement() {
|
|
|
|
}
|
|
|
|
void ewol::widget::Spin::onChangePropertyMantis() {
|
|
|
|
}
|
|
|
|
void ewol::widget::Spin::updateGui() {
|
|
Log.warning("updateGui [START]");
|
|
ewol::widget::SpinBase::updateGui();
|
|
|
|
if ( this.widgetEntry != null
|
|
&& this.connectionEntry.isConnected() == false) {
|
|
|
|
}
|
|
if ( this.widgetButtonUp != null
|
|
&& this.connectionButtonUp.isConnected() == false) {
|
|
this.connectionButtonUp = this.widgetButtonUp.signalPressed.connect(this, ewol::widget::Spin::onCallbackUp);
|
|
}
|
|
if ( this.widgetButtonDown != null
|
|
&& this.connectionButtonDown.isConnected() == false) {
|
|
this.connectionButtonDown = this.widgetButtonDown.signalPressed.connect(this, ewol::widget::Spin::onCallbackDown);
|
|
}
|
|
Log.warning("updateGui [STOP]");
|
|
}
|
|
|
|
void ewol::widget::Spin::checkValue(long _value) {
|
|
_value = etk::avg(propertyMin.get(), _value, propertyMax.get());
|
|
propertyValue.setDirect(_value);
|
|
this.widgetEntry.propertyValue.set(etk::toString(_value));
|
|
}
|
|
|
|
void ewol::widget::Spin::onCallbackUp() {
|
|
long value = propertyValue.get() + propertyIncrement.get();
|
|
checkValue(value);
|
|
}
|
|
|
|
void ewol::widget::Spin::onCallbackDown() {
|
|
long value = propertyValue.get() - propertyIncrement.get();
|
|
checkValue(value);
|
|
}
|