xref: /haiku/src/apps/debuganalyzer/gui/table/TableColumns.h (revision 17889a8c70dbb3d59c1412f6431968753c767bab)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef TABLE_COLUMNS_H
6 #define TABLE_COLUMNS_H
7 
8 
9 #include <ColumnTypes.h>
10 
11 #include "table/TableColumn.h"
12 
13 
14 class DelegateBasedTableColumn : public TableColumn {
15 public:
16 								DelegateBasedTableColumn(
17 									BColumn* columnDelegate,
18 									int32 modelIndex, float width,
19 									float minWidth, float maxWidth,
20 									alignment align);
21 	virtual						~DelegateBasedTableColumn();
22 
23 protected:
24 	virtual	void				DrawTitle(BRect rect, BView* targetView);
25 	virtual	void				GetColumnName(BString* into) const;
26 
27 	virtual	void				DrawValue(const BVariant& value, BRect rect,
28 									BView* targetView);
29 	virtual	float				GetPreferredWidth(const BVariant& value,
30 									BView* parent) const;
31 
32 	virtual	BField*				PrepareField(const BVariant& value) const = 0;
33 
34 protected:
35 			BColumn*			fColumnDelegate;
36 };
37 
38 
39 class StringTableColumn : public DelegateBasedTableColumn {
40 public:
41 								StringTableColumn(int32 modelIndex,
42 									const char* title, float width,
43 									float minWidth, float maxWidth,
44 									uint32 truncate,
45 									alignment align = B_ALIGN_LEFT);
46 	virtual						~StringTableColumn();
47 
48 protected:
49 	virtual	BField*				PrepareField(const BVariant& value) const;
50 
51 	virtual	int					CompareValues(const BVariant& a,
52 									const BVariant& b);
53 
54 protected:
55 			BStringColumn		fColumn;
56 	mutable	BStringField		fField;
57 };
58 
59 
60 class BoolStringTableColumn : public StringTableColumn {
61 public:
62 								BoolStringTableColumn(int32 modelIndex,
63 									const char* title, float width,
64 									float minWidth, float maxWidth,
65 									const BString& trueString = "true",
66 									const BString& falseString = "false",
67 									uint32 truncate = B_TRUNCATE_MIDDLE,
68 									alignment align = B_ALIGN_LEFT);
69 
70 protected:
71 	virtual	BField*				PrepareField(const BVariant& value) const;
72 
73 	virtual	int					CompareValues(const BVariant& a,
74 									const BVariant& b);
75 
76 private:
77 			BString				fTrueString;
78 			BString				fFalseString;
79 };
80 
81 
82 class Int32TableColumn : public StringTableColumn {
83 public:
84 								Int32TableColumn(int32 modelIndex,
85 									const char* title, float width,
86 									float minWidth, float maxWidth,
87 									uint32 truncate = B_TRUNCATE_MIDDLE,
88 									alignment align = B_ALIGN_RIGHT);
89 
90 protected:
91 	virtual	BField*				PrepareField(const BVariant& value) const;
92 
93 	virtual	int					CompareValues(const BVariant& a,
94 									const BVariant& b);
95 };
96 
97 
98 class Int64TableColumn : public StringTableColumn {
99 public:
100 								Int64TableColumn(int32 modelIndex,
101 									const char* title, float width,
102 									float minWidth, float maxWidth,
103 									uint32 truncate = B_TRUNCATE_MIDDLE,
104 									alignment align = B_ALIGN_RIGHT);
105 
106 protected:
107 	virtual	BField*				PrepareField(const BVariant& value) const;
108 
109 	virtual	int					CompareValues(const BVariant& a,
110 									const BVariant& b);
111 };
112 
113 
114 class BigtimeTableColumn : public StringTableColumn {
115 public:
116 								BigtimeTableColumn(int32 modelIndex,
117 									const char* title, float width,
118 									float minWidth, float maxWidth,
119 									bool invalidFirst,
120 									uint32 truncate = B_TRUNCATE_MIDDLE,
121 									alignment align = B_ALIGN_RIGHT);
122 
123 protected:
124 	virtual	BField*				PrepareField(const BVariant& value) const;
125 
126 	virtual	int					CompareValues(const BVariant& a,
127 									const BVariant& b);
128 
129 private:
130 			bool				fInvalidFirst;
131 };
132 
133 
134 class NanotimeTableColumn : public StringTableColumn {
135 public:
136 								NanotimeTableColumn(int32 modelIndex,
137 									const char* title, float width,
138 									float minWidth, float maxWidth,
139 									bool invalidFirst,
140 									uint32 truncate = B_TRUNCATE_MIDDLE,
141 									alignment align = B_ALIGN_RIGHT);
142 
143 protected:
144 	virtual	BField*				PrepareField(const BVariant& value) const;
145 
146 	virtual	int					CompareValues(const BVariant& a,
147 									const BVariant& b);
148 
149 private:
150 			bool				fInvalidFirst;
151 };
152 
153 
154 #endif	// TABLE_COLUMNS_H
155