xref: /haiku/src/apps/debuganalyzer/gui/table/Table.h (revision a1163de83ea633463a79de234b8742ee106531b2)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef TABLE_H
6 #define TABLE_H
7 
8 #include <ColumnTypes.h>
9 
10 #include "table/AbstractTable.h"
11 #include "table/TableColumn.h"
12 
13 #include "Variant.h"
14 
15 
16 class Table;
17 
18 
19 class TableModel : public AbstractTableModel {
20 public:
21 	virtual						~TableModel();
22 
23 	virtual	int32				CountRows() const = 0;
24 
25 	virtual	bool				GetValueAt(int32 rowIndex, int32 columnIndex,
26 									Variant& value) = 0;
27 };
28 
29 
30 class TableListener {
31 public:
32 	virtual						~TableListener();
33 
34 	virtual	void				TableRowInvoked(Table* table, int32 rowIndex);
35 };
36 
37 
38 class Table : public AbstractTable {
39 public:
40 								Table(const char* name, uint32 flags,
41 									border_style borderStyle = B_NO_BORDER,
42 									bool showHorizontalScrollbar = true);
43 								Table(TableModel* model, const char* name,
44 									uint32 flags,
45 									border_style borderStyle = B_NO_BORDER,
46 									bool showHorizontalScrollbar = true);
47 	virtual						~Table();
48 
49 			void				SetTableModel(TableModel* model);
50 			TableModel*			GetTableModel() const	{ return fModel; }
51 
52 			bool				AddTableListener(TableListener* listener);
53 			void				RemoveTableListener(TableListener* listener);
54 
55 protected:
56 	virtual	AbstractColumn*		CreateColumn(TableColumn* column);
57 
58 private:
59 			class Column;
60 
61 			typedef BObjectList<TableListener>	ListenerList;
62 
63 private:
64 	virtual	void				ItemInvoked();
65 
66 private:
67 			TableModel*			fModel;
68 			ListenerList		fListeners;
69 };
70 
71 
72 #endif	// TABLE_H
73