fixed bug where scrolling to the bottom of a textbox wouldn't work properly

This commit is contained in:
Dave White 2005-01-23 00:28:34 +00:00
parent 773fe062cc
commit a39ade36c9
5 changed files with 18 additions and 5 deletions

View file

@ -76,6 +76,11 @@ unsigned scrollarea::get_position() const
return scrollbar_.get_position();
}
unsigned scrollarea::get_max_position() const
{
return scrollbar_.get_max_position();
}
void scrollarea::set_position(unsigned pos)
{
scrollbar_.set_position(pos);

View file

@ -42,6 +42,7 @@ protected:
unsigned scrollbar_width() const;
unsigned get_position() const;
unsigned get_max_position() const;
void set_position(unsigned pos);
void adjust_position(unsigned pos);
void move_position(int dep);

View file

@ -78,9 +78,14 @@ unsigned scrollbar::get_position() const
return grip_position_;
}
unsigned scrollbar::get_max_position() const
{
return full_height_ - grip_height_;
}
void scrollbar::set_position(unsigned pos)
{
if (pos > full_height_ - grip_height_)
if (int(pos) > full_height_ - grip_height_)
pos = full_height_ - grip_height_;
if (pos == grip_position_)
return;
@ -92,9 +97,9 @@ void scrollbar::set_position(unsigned pos)
void scrollbar::adjust_position(unsigned pos)
{
if (pos < grip_position_)
if (int(pos) < grip_position_)
set_position(pos);
else if (pos >= grip_position_ + grip_height_)
else if (int(pos) >= grip_position_ + grip_height_)
set_position(pos - (grip_height_ - 1));
}
@ -109,7 +114,7 @@ void scrollbar::move_position(int dep)
void scrollbar::set_shown_size(unsigned h)
{
if (h > full_height_)
if (int(h) > full_height_)
h = full_height_;
if (h == grip_height_)
return;

View file

@ -40,6 +40,8 @@ public:
/// is at the top, and (full_size - shown_size) if it is at the bottom.
unsigned get_position() const;
unsigned get_max_position() const;
/// Used to manually update the scrollbar.
void set_position(unsigned pos);

View file

@ -202,7 +202,7 @@ bool textbox::editable() const
void textbox::scroll_to_bottom()
{
set_position((unsigned)-1);
set_position(get_max_position());
}
void textbox::set_wrap(bool val)