]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/table.h
Add Table widget
[libs/gltk.git] / source / table.h
diff --git a/source/table.h b/source/table.h
new file mode 100644 (file)
index 0000000..190973e
--- /dev/null
@@ -0,0 +1,58 @@
+/* $Id$
+
+This file is part of libmspgltk
+Copyright © 2008  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef MSP_GLTK_TABLE_H_
+#define MSP_GLTK_TABLE_H_
+
+#include <string>
+#include <vector>
+#include "widget.h"
+
+namespace Msp {
+namespace GLtk {
+
+class Table: public Widget
+{
+public:
+       class Loader: public Widget::Loader
+       {
+       public:
+               Loader(Table &);
+       private:
+               void cell_text(unsigned, unsigned, const std::string &);
+               void column_width(unsigned, unsigned);
+               void columns(unsigned);
+               void rows(unsigned);
+       };
+
+private:
+       unsigned rows;
+       unsigned columns;
+       std::vector<std::string> data;
+       std::vector<unsigned> col_w;
+
+public:
+       Table(const Resources &);
+
+       void set_rows(unsigned);
+       void set_columns(unsigned);
+       unsigned get_rows() const { return rows; }
+       unsigned get_columns() const { return columns; }
+
+       void set_column_width(unsigned, unsigned);
+       void set_cell_text(unsigned, unsigned, const std::string &);
+private:
+       virtual const char *get_class() const { return "table"; }
+
+       virtual void render_special(const Part &) const;
+       virtual void on_style_change();
+};
+
+} // namespace GLtk
+} // namespace Msp
+
+#endif