#include "container.h"
#include "label.h"
#include "listdata.h"
-#include "vslider.h"
+#include "mspgltk_api.h"
+#include "slider.h"
namespace Msp {
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 &);
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<List, Widget::Loader>
{
public:
};
public:
- class Item: public Container
+ class Item: virtual public Widget, protected Container
{
+ protected:
+ Item();
+
public:
virtual const char *get_class() const { return "listitem"; }
virtual void render_special(const Part &, GL::Renderer &) const;
};
+ class SimpleItem: public Item
+ {
+ protected:
+ SimpleItem() { }
+
+ virtual void on_style_change();
+ };
+
class MultiColumnItem: public Item
{
protected:
+ MultiColumnItem() { }
+
virtual void check_widths(std::vector<unsigned> &) const;
virtual void set_widths(const std::vector<unsigned> &);
- private:
virtual void on_style_change();
};
private:
- class BasicItem: public Item
+ class BasicItem: public SimpleItem
{
private:
Label label;
public:
BasicItem(const std::string &);
-
- private:
- virtual void on_style_change();
};
class ItemFactory
}
};
+ struct Row
+ {
+ unsigned first;
+ unsigned height;
+
+ Row(unsigned f): first(f), height(0) { }
+ };
+
public:
sigc::signal<void, unsigned> signal_item_selected;
sigc::signal<void> signal_selection_cleared;
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;
int drag_start_x;
VSlider slider;
std::vector<Item *> items;
+ std::vector<Row> rows;
public:
List();
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);
virtual void focus_in();
virtual bool navigate(Navigation);
private:
+ virtual void on_style_change();
+
void move_focus(Navigation, bool);
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