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::button_press(int x, int y, unsigned btn)
41 if(list->get_geometry().is_inside(x, y))
43 const Geometry &lgeom=list->get_geometry();
44 list->button_press(x-lgeom.x, y-lgeom.y, btn);
51 parent->ungrab_pointer(*this);
61 parent->grab_pointer(*this);
66 void Dropdown::button_release(int x, int y, unsigned btn)
70 const Geometry &lgeom=list->get_geometry();
71 list->button_release(x-lgeom.x, y-lgeom.y, btn);
76 void Dropdown::pointer_motion(int x, int y)
80 const Geometry &lgeom=list->get_geometry();
81 list->pointer_motion(x-lgeom.x, y-lgeom.y);
85 void Dropdown::render_special(const Part &part) const
87 if(part.get_name()=="text")
88 render_text(part, text);
89 else if(part.get_name()=="list" && dropped)
93 void Dropdown::on_geometry_change()
95 list->set_geometry(Geometry(0, -100, geom.w, 100));
98 void Dropdown::list_item_selected(unsigned index, const std::string &item)
106 parent->ungrab_pointer(*this);
108 signal_item_selected.emit(index, item);
112 Dropdown::Loader::Loader(Dropdown &d):
115 add("item", &Loader::item);
118 void Dropdown::Loader::item(const string &str)
120 static_cast<Dropdown &>(wdg).append(str);