]> git.tdb.fi Git - libs/gltk.git/blob - source/table.h
Add Table widget
[libs/gltk.git] / source / table.h
1 /* $Id$
2
3 This file is part of libmspgltk
4 Copyright © 2008  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GLTK_TABLE_H_
9 #define MSP_GLTK_TABLE_H_
10
11 #include <string>
12 #include <vector>
13 #include "widget.h"
14
15 namespace Msp {
16 namespace GLtk {
17
18 class Table: public Widget
19 {
20 public:
21         class Loader: public Widget::Loader
22         {
23         public:
24                 Loader(Table &);
25         private:
26                 void cell_text(unsigned, unsigned, const std::string &);
27                 void column_width(unsigned, unsigned);
28                 void columns(unsigned);
29                 void rows(unsigned);
30         };
31
32 private:
33         unsigned rows;
34         unsigned columns;
35         std::vector<std::string> data;
36         std::vector<unsigned> col_w;
37
38 public:
39         Table(const Resources &);
40
41         void set_rows(unsigned);
42         void set_columns(unsigned);
43         unsigned get_rows() const { return rows; }
44         unsigned get_columns() const { return columns; }
45
46         void set_column_width(unsigned, unsigned);
47         void set_cell_text(unsigned, unsigned, const std::string &);
48 private:
49         virtual const char *get_class() const { return "table"; }
50
51         virtual void render_special(const Part &) const;
52         virtual void on_style_change();
53 };
54
55 } // namespace GLtk
56 } // namespace Msp
57
58 #endif