Fix gcc 4.0 warnings in src/widgets

This commit is contained in:
Rusty Russell 2006-05-06 13:05:54 +00:00
parent 945e4b8b3c
commit 2281caaa8c
5 changed files with 13 additions and 21 deletions

View file

@ -64,13 +64,7 @@ image_button::image_button(CVideo& video, std::string button_image_name, SPACE_C
void image_button::calculate_size()
{
SDL_Rect const &loc = location();
bool change_size = loc.h == 0 || loc.w == 0;
if (!change_size) {
unsigned w = loc.w - horizontal_padding;
}
if (!change_size)
if (loc.h != 0 && loc.w != 0)
return;
#ifdef USE_TINY_GUI
@ -125,9 +119,7 @@ void image_button::draw_contents()
break;
}
SDL_Rect const &clipArea = screen_area();
SDL_Rect const &loc = location();
const int texty = loc.y + loc.h / 2 - textRect_.h / 2 + offset;
int textx;
textx = loc.x + image_w + checkbox_horizontal_padding / 2;

View file

@ -296,7 +296,7 @@ void menu::update_size()
i < i_end; ++i)
h += get_item_rect(i).h;
h = maximum(h, height());
if (max_height_ > 0 && h > max_height_)
if (max_height_ > 0 && h > (unsigned)max_height_)
h = max_height_;
std::vector<int> const &widths = column_widths();
@ -304,7 +304,7 @@ void menu::update_size()
if (items_.size() > max_items_onscreen())
w += scrollbar_width();
w = maximum(w, width());
if (max_width_ > 0 && w > max_width_)
if (max_width_ > 0 && w > (unsigned)max_width_)
w = max_width_;
update_scrollbar_grip_height();
@ -887,7 +887,7 @@ int menu::hit(int x, int y) const
return -1;
}
int menu::hit_column(int x, int y) const
int menu::hit_column(int x) const
{
std::vector<int> const &widths = column_widths();
x -= location().x;
@ -908,7 +908,7 @@ std::pair<int,int> menu::hit_cell(int x, int y) const
return std::pair<int,int>(-1, -1);
}
const int col = hit_column(x,y);
const int col = hit_column(x);
if(col < 0) {
return std::pair<int,int>(-1, -1);
}
@ -921,7 +921,7 @@ int menu::hit_heading(int x, int y) const
const size_t height = heading_height();
const SDL_Rect& loc = inner_location();
if(y >= loc.y && (size_t)y < loc.y + height) {
return hit_column(x,y);
return hit_column(x);
} else {
return -1;
}

View file

@ -223,7 +223,7 @@ private:
int hit(int x, int y) const;
std::pair<int,int> hit_cell(int x, int y) const;
int hit_column(int x, int y) const;
int hit_column(int x) const;
int hit_heading(int x, int y) const;

View file

@ -93,7 +93,7 @@ void scrollpane::remove_widget(widget* w)
update_content_size();
}
void scrollpane::set_inner_location(const SDL_Rect& rect)
void scrollpane::set_inner_location(const SDL_Rect& /*rect*/)
{
for(widget_map::iterator itor = content_.begin(); itor != content_.end(); ++itor) {
itor->second.w->set_clip_rect(client_area());
@ -158,8 +158,8 @@ SDL_Rect scrollpane::client_area() const
void scrollpane::update_content_size()
{
int maxx = 0;
int maxy = 0;
unsigned int maxx = 0;
unsigned int maxy = 0;
for(widget_map::iterator itor = content_.begin(); itor != content_.end(); ++itor) {
if(itor->second.x + itor->second.w->width() > maxx) {

View file

@ -390,7 +390,7 @@ void textbox::handle_event(const SDL_Event& event)
int distance = x;
for(unsigned int i = 1; i < char_x_.size(); ++i) {
if(yscroll_ + y < char_y_[i]) {
if((int)yscroll_ + y < char_y_[i]) {
break;
}
@ -446,7 +446,7 @@ void textbox::handle_event(const SDL_Event& event)
if(c == SDLK_LEFT && cursor_ > 0)
--cursor_;
if(c == SDLK_RIGHT && cursor_ < text_.size())
if(c == SDLK_RIGHT && cursor_ < (int)text_.size())
++cursor_;
// ctrl-a, ctrl-e and ctrl-u are readline style shortcuts, even on Macs
@ -483,7 +483,7 @@ void textbox::handle_event(const SDL_Event& event)
if(is_selection()) {
erase_selection();
} else {
if(cursor_ == text_.size()) {
if(cursor_ == (int)text_.size()) {
text_.resize(text_.size()-1);
--cursor_;
} else {