X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flist.h;h=68a96bf36cb65fb0c9361a0b1a156984cc1cd12f;hb=56c41b294aa47a38ac3e1be70d4868f260cb4274;hp=43a24576a1ecf1904d29d1a58eb104c61a790d00;hpb=9faf932be00ba7ec7ed8c81f1e7971dcfa2b2085;p=libs%2Fgltk.git diff --git a/source/list.h b/source/list.h index 43a2457..68a96bf 100644 --- a/source/list.h +++ b/source/list.h @@ -7,7 +7,8 @@ #include "container.h" #include "label.h" #include "listdata.h" -#include "vslider.h" +#include "mspgltk_api.h" +#include "slider.h" namespace Msp { namespace GLtk { @@ -15,7 +16,7 @@ namespace GLtk { /** Thrown if a list's item type is incompatible with its data. */ -class incompatible_data: public std::logic_error +class MSPGLTK_API incompatible_data: public std::logic_error { public: incompatible_data(const std::type_info &); @@ -27,9 +28,15 @@ public: Shows a list of items, allowing the user to select one. A slider is included to allow scrolling through a long list. */ -class List: virtual public Widget, private Container +class MSPGLTK_API List: virtual public Widget, private Container { public: + enum ViewMode + { + LIST, + GRID + }; + class Loader: public DataFile::DerivedObjectLoader { public: @@ -55,8 +62,11 @@ private: }; public: - class Item: public Container + class Item: virtual public Widget, protected Container { + protected: + Item(); + public: virtual const char *get_class() const { return "listitem"; } @@ -70,17 +80,20 @@ public: class SimpleItem: public Item { - private: + protected: + SimpleItem() { } + virtual void on_style_change(); }; class MultiColumnItem: public Item { protected: + MultiColumnItem() { } + virtual void check_widths(std::vector &) const; virtual void set_widths(const std::vector &); - private: virtual void on_style_change(); }; @@ -131,6 +144,14 @@ private: } }; + struct Row + { + unsigned first; + unsigned height; + + Row(unsigned f): first(f), height(0) { } + }; + public: sigc::signal signal_item_selected; sigc::signal signal_selection_cleared; @@ -140,11 +161,13 @@ private: bool own_data; DataObserver *observer; ItemFactory *item_factory; + ViewMode view_mode; int sel_index; int focus_index; - unsigned first; + unsigned first_row; unsigned max_scroll; - unsigned view_size; + unsigned view_rows; + unsigned view_columns; const Part *items_part; bool ignore_slider_change; bool dragging; @@ -153,6 +176,7 @@ private: VSlider slider; std::vector items; + std::vector rows; public: List(); @@ -186,7 +210,9 @@ private: Item *create_item(unsigned); public: + void set_view_mode(ViewMode); void set_view_size(unsigned); + void set_view_size(unsigned, unsigned); void set_view_all(); void set_selected_index(int); @@ -212,13 +238,17 @@ private: void set_focus_index(int); void item_autosize_changed(Item *); - unsigned last_to_first(unsigned) const; + void reposition_items(bool); + unsigned last_to_first_row(unsigned) const; + unsigned item_index_to_row(unsigned) const; void check_view_range(); void scroll_to_focus(); void slider_value_changed(double); static void adjust_index(int &, int, int); }; +MSPGLTK_API void operator>>(const LexicalConverter &, List::ViewMode &); + } // namespace GLtk } // namespace Msp