Fix textbox background refresh.

This commit is contained in:
Guillaume Melquiond 2004-10-31 23:12:07 +00:00
parent bb4b6cece4
commit 8757fccecf
2 changed files with 12 additions and 5 deletions

View file

@ -36,14 +36,19 @@ textbox::textbox(display& d, int width, const std::string& text, bool editable,
scrollbar_(d, *this, this),
scroll_bottom_(false), wrap_(false), line_height_(0), yscroll_(0)
{
static const SDL_Rect area = d.screen_area();
// static const SDL_Rect area = d.screen_area();
// const int height = font::draw_text(NULL,area,font_size,font::NORMAL_COLOUR,"ABCD",0,0).h;
const int height = font::get_max_height(font_size);
const SDL_Rect starting_rect = {0,0,width,height};
set_location(starting_rect);
set_height(font::get_max_height(font_size));
set_width(width);
update_text_cache(true);
}
void textbox::set_location(SDL_Rect const &rect)
{
widget::set_location(rect);
register_rectangle(rect);
}
const std::string textbox::text() const
{
const std::string &ret = wstring_to_string(text_);
@ -112,7 +117,7 @@ void textbox::draw_cursor(int pos, display &disp) const
void textbox::draw()
{
if (location().x == 0 || !dirty())
if (hidden() || !dirty())
return;
bg_restore();

View file

@ -46,6 +46,8 @@ public:
void set_wrap(bool val);
void draw();
virtual void set_location(SDL_Rect const &);
using widget::set_location;
private:
size_t max_size_;