X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdropdown.cpp;h=5d8a547bebae925083fb40222e8dde20f8178ab2;hb=30780ba31be92c977a68a2a9103eeba87747d530;hp=4d18187a7fb28642934dd5a5aeb0adb0038e85b6;hpb=50bf1ef2e2c3c38de20f6996a6c5ed0066111177;p=libs%2Fgltk.git diff --git a/source/dropdown.cpp b/source/dropdown.cpp index 4d18187..5d8a547 100644 --- a/source/dropdown.cpp +++ b/source/dropdown.cpp @@ -36,6 +36,36 @@ void Dropdown::append(const string &item) list->append(item); } +void Dropdown::insert(unsigned i, const string &v) +{ + list->insert(i, v); +} + +void Dropdown::remove(unsigned i) +{ + list->remove(i); +} + +void Dropdown::clear() +{ + list->clear(); +} + +void Dropdown::set_selected_index(int i) +{ + list->set_selected_index(i); +} + +const string &Dropdown::get_selected() const +{ + return list->get_selected(); +} + +int Dropdown::get_selected_index() const +{ + return list->get_selected_index(); +} + void Dropdown::button_press(int x, int y, unsigned btn) { if(list->get_geometry().is_inside(x, y)) @@ -85,7 +115,10 @@ void Dropdown::pointer_motion(int x, int y) void Dropdown::render_special(const Part &part) const { if(part.get_name()=="text") - render_text(part, text); + { + if(list->get_selected_index()>=0) + render_text(part, list->get_selected()); + } else if(part.get_name()=="list" && dropped) list->render(); } @@ -97,13 +130,14 @@ void Dropdown::on_geometry_change() void Dropdown::list_item_selected(unsigned index, const std::string &item) { - text=item; - - list_active=false; - dropped=false; - state&=~ACTIVE; - if(parent) - parent->ungrab_pointer(*this); + if(dropped) + { + list_active=false; + dropped=false; + state&=~ACTIVE; + if(parent) + parent->ungrab_pointer(*this); + } signal_item_selected.emit(index, item); }