X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flist.h;h=1c7a65dc161e0eae62011cbad1a50a14b06014d7;hb=43a75e4e9be56c58be5e224f19016bb14b56a7ef;hp=77d7e9f49166ac53e62c5a06785e0e14bd12ed28;hpb=95210598ff214bbc8d05657aeffc4ce7801f211a;p=libs%2Fgltk.git diff --git a/source/list.h b/source/list.h index 77d7e9f..1c7a65d 100644 --- a/source/list.h +++ b/source/list.h @@ -1,26 +1,18 @@ -/* $Id$ - -This file is part of libmspgltk -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #ifndef MSP_GLTK_LIST_H_ #define MSP_GLTK_LIST_H_ #include -#include "widget.h" +#include "container.h" +#include "vslider.h" namespace Msp { namespace GLtk { -class VSlider; - /** Shows a list of items, allowing the user to select one. A slider is included to allow scrolling through a long list. */ -class List: public Widget +class List: virtual public Widget, private Container { public: class Loader: public Widget::Loader @@ -31,43 +23,53 @@ public: void item(const std::string &); }; + sigc::signal signal_item_selected; + private: std::vector items; int sel_index; unsigned first; unsigned n_visible; + unsigned row_height; const Part *items_part; - VSlider *slider; - bool slider_active; + VSlider slider; public: - sigc::signal signal_item_selected; + List(); + + virtual const char *get_class() const { return "list"; } - List(const Resources &); - ~List(); + virtual void autosize(); + void autosize_rows(unsigned); + void autosize_all(); void append(const std::string &); void insert(unsigned, const std::string &); void remove(unsigned); void clear(); +private: + void items_changed(); +public: + unsigned get_n_items() const { return items.size(); } + void set_selected_index(int); const std::string &get_selected() const; int get_selected_index() const { return sel_index; } - virtual void button_press(int, int, unsigned); - virtual void button_release(int, int, unsigned); - virtual void pointer_motion(int, int); - private: - virtual const char *get_class() const { return "list"; } - virtual void render_special(const Part &) const; + virtual void rebuild_special(const Part &, CachedPart &); + 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 reposition_slider(); - void recalculate_parameters(); + void check_view_range(); void slider_value_changed(double); };