예제 #1
0
void tslider::set_value(const int value)
{
	if(value == get_value()) {
		return;
	}

	if(value < minimum_value_) {
		set_value(minimum_value_);
	} else if(value > get_maximum_value()) {
		set_value(get_maximum_value());
	} else {
		set_item_position(distance(minimum_value_, value));
	}
}
예제 #2
0
void slider::set_maximum_value(const int maximum_value)
{
    if(maximum_value == get_maximum_value()) {
        return;
    }

    /** @todo maybe make it a VALIDATE. */
    assert(minimum_value_ <= maximum_value);

    const int value = get_value();

    // The number of items needs to include the begin and end so distance + step
    // size.
    set_item_count(maximum_value - minimum_value_ + get_step_size());

    if(value > maximum_value) {
        set_item_position(get_maximum_value());
    }
}
예제 #3
0
파일: slider.cpp 프로젝트: suxinde2009/Rose
void tslider::set_maximum_value(const int maximum_value)
{
	if(maximum_value == get_maximum_value()) {
		return;
	}

	/** @todo maybe make it a VALIDATE. */
	VALIDATE(minimum_value_ < maximum_value, null_str);

	const int value = get_value();

	// The number of items needs to include the begin and end so distance + 1.
	set_item_count(distance(minimum_value_, maximum_value) + 1);

	if(value > maximum_value) {
		set_item_position(get_maximum_value());
	} else {
		set_item_position(minimum_value_ + value);
	}
}
예제 #4
0
void tslider::set_minimum_value(const int minimum_value)
{
	if(minimum_value == minimum_value_) {
		return;
	}

	/** @todo maybe make it a VALIDATE. */
	assert(minimum_value <= get_maximum_value());

	const int value = get_value();
	const int maximum_value = get_maximum_value();
	minimum_value_ = minimum_value;

	// The number of items needs to include the begin and end so distance + 1.
	set_item_count(distance(minimum_value_, maximum_value) + 1);

	if(value < minimum_value_) {
		set_item_position(0);
	} else {
		set_item_position(minimum_value_ + value);
	}
}
예제 #5
0
파일: slider.cpp 프로젝트: Heark/wesnoth
t_string tslider::get_value_label() const
{
	if(value_labels_) {
		return value_labels_(get_item_position(), get_item_count());
	} else if(!minimum_value_label_.empty() && get_value()
											   == get_minimum_value()) {
		return minimum_value_label_;
	} else if(!maximum_value_label_.empty() && get_value()
											   == get_maximum_value()) {
		return maximum_value_label_;
	} else {
		return t_string((formatter() << get_value()).str());
	}
}
예제 #6
0
파일: slider.cpp 프로젝트: suxinde2009/Rose
t_string tslider::get_value_label() const
{
	if(!value_labels_.empty()) {
		VALIDATE(value_labels_.size() == get_item_count(), null_str);
		return value_labels_[get_item_position()];
	} else if(!minimum_value_label_.empty()
			&& get_value() == get_minimum_value()) {
		return minimum_value_label_;
	} else if(!maximum_value_label_.empty()
			&& get_value() == get_maximum_value()) {
		return maximum_value_label_;
	} else {
		return t_string((formatter() << get_value()).str());
	}
}
t_string tslider::get_value_label() const
{
	if(!value_labels_.empty()) {
		assert(value_labels_.size() == get_item_count());
		return value_labels_[get_item_position()];
	} else if(!minimum_value_label_.empty()
			&& get_value() == get_minimum_value()) {
		return minimum_value_label_;
	} else if(!maximum_value_label_.empty()
			&& get_value() == get_maximum_value()) {
		return maximum_value_label_;
	} else {
		return t_string(formatter_(get_value()));
	}
}