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