X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flist.cpp;h=a886118ed6c98b8341effd74de1d6fc4c6f61018;hb=2accd84fb2f8cc96efea8b3f27e381c2d2749160;hp=f7cc4d73a2e94f6d503aab13cad5447b39838b1e;hpb=b92c878a286036af106e969a29b2689876aa5f65;p=libs%2Fgltk.git diff --git a/source/list.cpp b/source/list.cpp index f7cc4d7..a886118 100644 --- a/source/list.cpp +++ b/source/list.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspgltk -Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include #include #include @@ -47,12 +40,13 @@ void List::autosize_rows(unsigned n) if(items_part) { const Sides &margin = items_part->get_margin(); - float font_size = style->get_font()->get_default_size(); + const GL::Font &font = style->get_font(); + float font_size = style->get_font_size(); unsigned max_w = 0; for(vector::iterator i=items.begin(); i!=items.end(); ++i) { - unsigned w = static_cast(style->get_font()->get_string_width(*i)*font_size); + unsigned w = static_cast(font.get_string_width(*i)*font_size); max_w = max(max_w, w); } @@ -97,7 +91,7 @@ void List::append(const string &v) void List::insert(unsigned i, const string &v) { if(i>items.size()) - throw InvalidParameterValue("Index out of range"); + throw out_of_range("List::insert"); items.insert(items.begin()+i, v); check_view_range(); @@ -107,7 +101,7 @@ void List::insert(unsigned i, const string &v) void List::remove(unsigned i) { if(i>items.size()) - throw InvalidParameterValue("Index out of range"); + throw out_of_range("List::remove"); items.erase(items.begin()+i); if(sel_index>static_cast(i)) @@ -138,13 +132,13 @@ void List::set_selected_index(int i) signal_item_selected.emit(sel_index, items[sel_index]); } else - throw InvalidParameterValue("Index out of range"); + throw out_of_range("List::set_selected_index"); } const string &List::get_selected() const { if(sel_index<0) - throw InvalidState("No selection"); + throw logic_error("sel_index<0"); return items[sel_index]; } @@ -229,8 +223,8 @@ void List::on_style_change() items_part = style->get_part("items"); - const GL::Font &font = *style->get_font(); - row_height = static_cast((font.get_ascent()-font.get_descent())*font.get_default_size()); + const GL::Font &font = style->get_font(); + row_height = static_cast((font.get_ascent()-font.get_descent())*style->get_font_size()); check_view_range(); }