xref: /haiku/headers/private/shared/TextTable.h (revision 5df58b522b52d5914bf8b49fc47ff46fde56877f)
1*5df58b52SIngo Weinhold /*
2*5df58b52SIngo Weinhold  * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
3*5df58b52SIngo Weinhold  * Distributed under the terms of the MIT License.
4*5df58b52SIngo Weinhold  */
5*5df58b52SIngo Weinhold #ifndef TEXT_TABLE_H
6*5df58b52SIngo Weinhold #define TEXT_TABLE_H
7*5df58b52SIngo Weinhold 
8*5df58b52SIngo Weinhold 
9*5df58b52SIngo Weinhold #include <InterfaceDefs.h>
10*5df58b52SIngo Weinhold #include <ObjectList.h>
11*5df58b52SIngo Weinhold #include <StringList.h>
12*5df58b52SIngo Weinhold 
13*5df58b52SIngo Weinhold 
14*5df58b52SIngo Weinhold namespace BPrivate {
15*5df58b52SIngo Weinhold 
16*5df58b52SIngo Weinhold 
17*5df58b52SIngo Weinhold class TextTable {
18*5df58b52SIngo Weinhold public:
19*5df58b52SIngo Weinhold 								TextTable();
20*5df58b52SIngo Weinhold 								~TextTable();
21*5df58b52SIngo Weinhold 
22*5df58b52SIngo Weinhold 			int32				CountColumns() const;
23*5df58b52SIngo Weinhold 			void				AddColumn(const BString& title,
24*5df58b52SIngo Weinhold 									enum alignment align = B_ALIGN_LEFT,
25*5df58b52SIngo Weinhold 									bool canTruncate = false);
26*5df58b52SIngo Weinhold 
27*5df58b52SIngo Weinhold 			int32				CountRows() const;
28*5df58b52SIngo Weinhold 			BString				TextAt(int32 rowIndex, int32 columnIndex) const;
29*5df58b52SIngo Weinhold 			void				SetTextAt(int32 rowIndex, int32 columnIndex,
30*5df58b52SIngo Weinhold 									const BString& text);
31*5df58b52SIngo Weinhold 
32*5df58b52SIngo Weinhold 			void				Print(int32 maxWidth);
33*5df58b52SIngo Weinhold 
34*5df58b52SIngo Weinhold private:
35*5df58b52SIngo Weinhold 			struct Column;
36*5df58b52SIngo Weinhold 			typedef BObjectList<Column> ColumnList;
37*5df58b52SIngo Weinhold 			typedef BObjectList<BStringList> RowList;
38*5df58b52SIngo Weinhold 
39*5df58b52SIngo Weinhold private:
40*5df58b52SIngo Weinhold 			ColumnList			fColumns;
41*5df58b52SIngo Weinhold 			RowList				fRows;
42*5df58b52SIngo Weinhold };
43*5df58b52SIngo Weinhold 
44*5df58b52SIngo Weinhold 
45*5df58b52SIngo Weinhold } // namespace BPrivate
46*5df58b52SIngo Weinhold 
47*5df58b52SIngo Weinhold 
48*5df58b52SIngo Weinhold using ::BPrivate::TextTable;
49*5df58b52SIngo Weinhold 
50*5df58b52SIngo Weinhold 
51*5df58b52SIngo Weinhold #endif	// TEXT_TABLE_H
52