3 This file is part of libmspgltk
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
18 Dropdown::Dropdown(const Resources &r):
24 list->signal_item_selected.connect(sigc::mem_fun(this, &Dropdown::list_item_selected));
34 void Dropdown::append(const string &item)
39 void Dropdown::insert(unsigned i, const string &v)
44 void Dropdown::remove(unsigned i)
49 void Dropdown::clear()
54 void Dropdown::set_selected_index(int i)
56 list->set_selected_index(i);
59 const string &Dropdown::get_selected() const
61 return list->get_selected();
64 int Dropdown::get_selected_index() const
66 return list->get_selected_index();
69 void Dropdown::button_press(int x, int y, unsigned btn)
71 if(list->get_geometry().is_inside(x, y))
73 const Geometry &lgeom=list->get_geometry();
74 list->button_press(x-lgeom.x, y-lgeom.y, btn);
81 parent->ungrab_pointer(*this);
91 parent->grab_pointer(*this);
96 void Dropdown::button_release(int x, int y, unsigned btn)
100 const Geometry &lgeom=list->get_geometry();
101 list->button_release(x-lgeom.x, y-lgeom.y, btn);
106 void Dropdown::pointer_motion(int x, int y)
110 const Geometry &lgeom=list->get_geometry();
111 list->pointer_motion(x-lgeom.x, y-lgeom.y);
115 void Dropdown::render_special(const Part &part) const
117 if(part.get_name()=="text")
118 render_text(part, text);
119 else if(part.get_name()=="list" && dropped)
123 void Dropdown::on_geometry_change()
125 list->set_geometry(Geometry(0, -100, geom.w, 100));
128 void Dropdown::list_item_selected(unsigned index, const std::string &item)
138 parent->ungrab_pointer(*this);
141 signal_item_selected.emit(index, item);
145 Dropdown::Loader::Loader(Dropdown &d):
148 add("item", &Loader::item);
151 void Dropdown::Loader::item(const string &str)
153 static_cast<Dropdown &>(wdg).append(str);