3 This file is part of libmspgltk
4 Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/gl/font.h>
25 list.signal_item_selected.connect(sigc::mem_fun(this, &Dropdown::list_item_selected));
28 void Dropdown::append(const string &item)
34 void Dropdown::insert(unsigned i, const string &v)
40 void Dropdown::remove(unsigned i)
46 void Dropdown::clear()
52 unsigned Dropdown::get_n_items() const
54 return list.get_n_items();
57 void Dropdown::set_selected_index(int i)
59 list.set_selected_index(i);
62 const string &Dropdown::get_selected() const
64 return list.get_selected();
67 int Dropdown::get_selected_index() const
69 return list.get_selected_index();
72 void Dropdown::button_press(int x, int y, unsigned btn)
76 Container::button_press(x, y, btn);
81 signal_ungrab_pointer.emit();
88 signal_grab_pointer.emit();
92 void Dropdown::render_special(const Part &part) const
94 if(part.get_name()=="text")
96 if(list.get_selected_index()>=0)
97 Text(*style, list.get_selected()).render(part, geom);
99 else if(part.get_name()=="list" && dropped)
103 void Dropdown::on_geometry_change()
108 void Dropdown::on_style_change()
113 void Dropdown::resize_list()
116 const Geometry &lgeom = list.get_geometry();
117 list.set_geometry(Geometry(0, -lgeom.h, max(geom.w, lgeom.w), lgeom.h));
120 void Dropdown::list_item_selected(unsigned index, const std::string &item)
126 signal_ungrab_pointer.emit();
129 signal_item_selected.emit(index, item);
133 Dropdown::Loader::Loader(Dropdown &d):
136 add("item", &Loader::item);
139 void Dropdown::Loader::item(const string &str)
141 dynamic_cast<Dropdown &>(wdg).append(str);