]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/dropdown.h
Use a different approach for custom item widgets
[libs/gltk.git] / source / dropdown.h
index d1a2609772fbe85047664f33a599c9c9d008d009..06aefa5af96d32cc0b6b3cc0d590bb092298164b 100644 (file)
@@ -1,14 +1,9 @@
-/* $Id$
-
-This file is part of libmspgltk
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #ifndef MSP_GLTK_DROPDOWN_H_
 #define MSP_GLTK_DROPDOWN_H_
 
 #include <sigc++/signal.h>
+#include "list.h"
+#include "text.h"
 #include "widget.h"
 
 namespace Msp {
@@ -16,10 +11,10 @@ namespace GLtk {
 
 class List;
 
-class Dropdown: public Widget
+class Dropdown: virtual public Widget, private Container
 {
 public:
-       class Loader: public Widget::Loader
+       class Loader: public DataFile::DerivedObjectLoader<Dropdown, Widget::Loader>
        {
        public:
                Loader(Dropdown &);
@@ -27,31 +22,49 @@ public:
                void item(const std::string &);
        };
 
+       sigc::signal<void, unsigned> signal_item_selected;
+
 private:
-       List *list;
-       std::string text;
-       bool list_active;
+       List list;
+       bool dropped;
+       Text text;
 
 public:
-       sigc::signal<void, int, const std::string &> signal_item_selected;
+       Dropdown();
+       Dropdown(ListData &);
+private:
+       void init();
 
-       Dropdown(const Resources &);
-       ~Dropdown();
+public:
+       virtual const char *get_class() const { return "dropdown"; }
 
-       void append(const std::string &);
+private:
+       virtual void autosize_special(const Part &, Geometry &);
+
+public:
+       void set_data(ListData &d) { list.set_data(d); }
+       ListData &get_data() { return list.get_data(); }
+       const ListData &get_data() const { return list.get_data(); }
+
+       template<typename T>
+       void set_item_type() { list.set_item_type<T>(); }
+
+       void set_selected_index(int);
+       int get_selected_index() const { return list.get_selected_index(); }
 
-       virtual void button_press(int, int, unsigned);
-       virtual void button_release(int, int, unsigned);
-       virtual void pointer_motion(int, int);
-       virtual void pointer_enter();
-       virtual void pointer_leave();
 private:
-       virtual const char *get_class() const { return "dropdown"; }
-       virtual void render_special(const Part &) const;
+       virtual void rebuild_special(const Part &);
+       virtual void render_special(const Part &, GL::Renderer &) const;
 
+public:
+       virtual void button_press(int, int, unsigned);
+private:
        virtual void on_geometry_change();
+       virtual void on_style_change();
 
-       void list_item_selected(unsigned, const std::string &);
+       void list_autosize_changed();
+       void resize_list();
+       void list_item_selected(unsigned);
 };
 
 } // namespace GLtk