Exemplo n.º 1
0
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);
	}
}
Exemplo n.º 2
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);
	}
}
Exemplo n.º 3
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));
	}
}
Exemplo n.º 4
0
void tscrollbar_::scroll(const tscroll scroll)
{
	switch(scroll) {
		case BEGIN:
			set_item_position(0);
			break;

		case ITEM_BACKWARDS:
			if(item_position_) {
				set_item_position(item_position_ - 1);
			}
			break;

		case HALF_JUMP_BACKWARDS:
			set_item_position(item_position_ > (visible_items_ / 2)
									  ? item_position_ - (visible_items_ / 2)
									  : 0);
			break;

		case JUMP_BACKWARDS:
			set_item_position(item_position_ > visible_items_
									  ? item_position_ - visible_items_
									  : 0);
			break;

		case END:
			set_item_position(item_count_ - 1);
			break;

		case ITEM_FORWARD:
			set_item_position(item_position_ + 1);
			break;

		case HALF_JUMP_FORWARD:
			set_item_position(item_position_ + (visible_items_ / 2));
			break;

		case JUMP_FORWARD:
			set_item_position(item_position_ + visible_items_);
			break;

		default:
			assert(false);
	}

	fire(event::NOTIFY_MODIFIED, *this, NULL);
}
Exemplo n.º 5
0
void tscrollbar_::scroll(const tscroll scroll)
{
	switch(scroll) {
		case BEGIN :
			set_item_position(0);
			break;

		case ITEM_BACKWARDS :
			if(item_position_) {
				set_item_position(item_position_ - 1);
			}
			break;

		case HALF_JUMP_BACKWARDS :
			set_item_position(item_position_ > (visible_items_ / 3) ?
				item_position_ - (visible_items_ / 3) : 0);
			break;

		case JUMP_BACKWARDS :
			set_item_position(item_position_ > visible_items_ ?
				item_position_ - visible_items_  : 0);
			break;

		case END :
			set_item_position(item_count_ - 1);
			break;

		case ITEM_FORWARD :
			set_item_position(item_position_ + 1);
			break;

		case HALF_JUMP_FORWARD :
			set_item_position(item_position_ +  (visible_items_ / 3));
			break;

		case JUMP_FORWARD :
			set_item_position(item_position_ +  visible_items_ );
			break;

		default :
			VALIDATE(false, null_str);
		}
}
Exemplo n.º 6
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());
    }
}