SCV  4.2.1
Simple Components for Visual
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Table.h
Go to the documentation of this file.
1 
7 #ifndef __SCV_TABLE_H__
8 #define __SCV_TABLE_H__
9 
10 #include "MatrixTemplate.h"
11 #include "Panel.h"
12 #include "TextBox.h"
13 #include "Button.h"
14 #include "GroupLayout.h"
15 
16 namespace scv {
17 
18 class Table : public Panel {
19 public:
20  Table(const scv::Point &p, int nRows = 4, int nColumns = 4, int nCellLines = 1, int CellWidth = 1);
21  virtual void display(void);
22 
23  void addRow(void);
24  void addRow(int number);
25 
26  void addColumn(void);
27  void addColumn(int number);
28 
29  void align(int column);
30 
31  void remakeLayout(void);
32 
33  void setString(int row, int column, std::string str);
34  std::string getString(int row, int column);
35 
36  std::vector<std::string> getRow(int row);
37  std::vector<std::string> getColumn(int column);
38 
39  void clear(void);
40  //void removeRow(int begin, int end); not implemented
41  //void removeColumn(int begin, int end); not implemented
42 
43  int getNumberOfRows(void);
44  int getNumberOfColumns(void);
45 
46  int getNumberOfLinesPerCell(void);
47 
48  int getCellWidth(void);
49 
50  virtual void setDraggable(bool state);
51  virtual void setResizable(bool state);
52 
53  inline void setEditable(bool edit);
54  inline bool isEditable();
55 
56  void processMouse(const scv::MouseEvent &evt);
57  void processKey(const scv::KeyEvent &evt);
58 
59 private:
60  class TableButton : public Button {
61  public:
62  TableButton(Table *table, const scv::Point &p, unsigned int width, const std::string &str, int column);
63  void onMouseUp(const scv::MouseEvent &evt);
64  Table *_table;
65  int _column;
66  };
67  void setAlign(bool state);
68  bool alphabetical(std::string str1, std::string str2);
69 
70  int _nRows, _nColumns;
71  int _nCellLines, _cellWidth;
72  int character;
73  bool _align;
74  std::deque<Button *> _buttons;
75 
76  GroupLayout *_layout;
77  scv::Group *hGroupLayout, *vGroupLayout;
78  bool isTableModified;
79 
80 protected:
81  bool _editable;
82  std::deque<std::deque< TextBox *> > _table;
83 };
84 
85 void Table::setEditable(bool edit)
86 {
87  _editable = edit;
88 }
89 
91 {
92  return _editable;
93 }
94 
95 } // namespace scv
96 
97 #endif // __SCV_TABLE_H__