// $Id$
//
// SuperTux
-// Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
#include <config.h>
#include <sys/types.h>
void
Menu::draw_item(DrawingContext& context, int index)
{
- int menu_height = get_height();
- int menu_width = get_width();
+ float menu_height = get_height();
+ float menu_width = get_width();
MenuItem& pitem = *(items[index]);
}
}
-int Menu::get_width() const
+float Menu::get_width() const
+{
+ /* The width of the menu has to be more than the width of the text
+ with the most characters */
+ float menu_width = 0;
+ for(unsigned int i = 0; i < items.size(); ++i)
{
- /* The width of the menu has to be more than the width of the text
- with the most characters */
- int menu_width = 0;
- for(unsigned int i = 0; i < items.size(); ++i)
- {
- int w = items[i]->text.size() + items[i]->input.size() + 1;
- if(w > menu_width)
- {
- menu_width = w;
- if( items[i]->kind == MN_TOGGLE)
- menu_width += 2;
- }
- }
-
- return (menu_width * 16 + 24);
+ Font* font = default_font;
+ if(items[i]->kind == MN_LABEL)
+ font = label_font;
+
+ float w = font->get_text_width(items[i]->text) +
+ label_font->get_text_width(items[i]->input) + 16;
+ if(items[i]->kind == MN_TOGGLE)
+ w += 32;
+
+ if(w > menu_width)
+ menu_width = w;
}
+
+ return menu_width + 24;
+}
-int Menu::get_height() const
- {
- return items.size() * 24;
- }
+float Menu::get_height() const
+{
+ return items.size() * 24;
+}
/* Draw the current menu. */
void
MouseCursor::current()->draw(context);
}
- int menu_height = get_height();
- int menu_width = get_width();
+ float menu_height = get_height();
+ float menu_width = get_width();
/* Draw a transparent background */
context.draw_filled_rect(