1 /*******************************************************************************
5 / Description: Experimental classes that implement particular column/field
6 / data types for use in BColumnListView.
8 / Copyright 2000+, Be Incorporated, All Rights Reserved
10 *******************************************************************************/
13 #ifndef _COLUMN_TYPES_H
14 #define _COLUMN_TYPES_H
17 #include "ColumnListView.h"
24 //=====================================================================
25 // Common base-class: a column that draws a standard title at its top.
27 class BTitledColumn
: public BColumn
30 BTitledColumn(const char* title
, float width
, float minWidth
,
31 float maxWidth
, alignment align
= B_ALIGN_LEFT
);
32 virtual void DrawTitle(BRect rect
, BView
* parent
);
33 virtual void GetColumnName(BString
* into
) const;
35 void DrawString(const char*, BView
*, BRect
);
36 void SetTitle(const char* title
);
37 void Title(BString
* forTitle
) const;
38 // sets the BString arg to be the title
39 float FontHeight() const;
41 virtual float GetPreferredWidth(BField
* field
, BView
* parent
) const;
49 //=====================================================================
50 // Field and column classes for strings.
52 class BStringField
: public BField
55 BStringField(const char* string
);
57 void SetString(const char* string
);
58 const char* String() const;
59 void SetClippedString(const char* string
);
60 bool HasClippedString() const;
61 const char* ClippedString();
68 BString fClippedString
;
72 //--------------------------------------------------------------------
74 class BStringColumn
: public BTitledColumn
77 BStringColumn(const char* title
, float width
,
78 float minWidth
, float maxWidth
, uint32 truncate
,
79 alignment align
= B_ALIGN_LEFT
);
80 virtual void DrawField(BField
* field
, BRect rect
, BView
* parent
);
81 virtual int CompareFields(BField
* field1
, BField
* field2
);
82 virtual float GetPreferredWidth(BField
* field
, BView
* parent
) const;
83 virtual bool AcceptsField(const BField
* field
) const;
90 //=====================================================================
91 // Field and column classes for dates.
93 class BDateField
: public BField
96 BDateField(time_t* t
);
99 void SetClippedString(const char*);
100 const char* ClippedString();
108 BString fClippedString
;
113 //--------------------------------------------------------------------
115 class BDateColumn
: public BTitledColumn
118 BDateColumn(const char* title
, float width
,
119 float minWidth
, float maxWidth
,
120 alignment align
= B_ALIGN_LEFT
);
121 virtual void DrawField(BField
* field
, BRect rect
, BView
* parent
);
122 virtual int CompareFields(BField
* field1
, BField
* field2
);
129 //=====================================================================
130 // Field and column classes for numeric sizes.
132 class BSizeField
: public BField
135 BSizeField(off_t size
);
144 //--------------------------------------------------------------------
146 class BSizeColumn
: public BTitledColumn
149 BSizeColumn(const char* title
, float width
,
150 float minWidth
, float maxWidth
,
151 alignment align
= B_ALIGN_LEFT
);
152 virtual void DrawField(BField
* field
, BRect rect
, BView
* parent
);
153 virtual int CompareFields(BField
* field1
, BField
* field2
);
157 //=====================================================================
158 // Field and column classes for integers.
160 class BIntegerField
: public BField
163 BIntegerField(int32 number
);
164 void SetValue(int32
);
172 //--------------------------------------------------------------------
174 class BIntegerColumn
: public BTitledColumn
177 BIntegerColumn(const char* title
, float width
,
178 float minWidth
, float maxWidth
,
179 alignment align
= B_ALIGN_LEFT
);
180 virtual void DrawField(BField
* field
, BRect rect
, BView
* parent
);
181 virtual int CompareFields(BField
* field1
, BField
* field2
);
185 //=====================================================================
186 // Field and column classes for bitmaps
188 class BBitmapField
: public BField
191 BBitmapField(BBitmap
* bitmap
);
192 const BBitmap
* Bitmap();
193 void SetBitmap(BBitmap
* bitmap
);
200 //--------------------------------------------------------------------
202 class BBitmapColumn
: public BTitledColumn
205 BBitmapColumn(const char* title
, float width
,
206 float minWidth
, float maxWidth
,
207 alignment align
= B_ALIGN_LEFT
);
208 virtual void DrawField(BField
* field
, BRect rect
, BView
* parent
);
209 virtual int CompareFields(BField
* field1
, BField
* field2
);
210 virtual bool AcceptsField(const BField
* field
) const;
214 //=====================================================================
215 // Column to display BIntegerField objects as a graph.
217 class GraphColumn
: public BIntegerColumn
220 GraphColumn(const char* name
, float width
,
221 float minWidth
, float maxWidth
,
222 alignment align
= B_ALIGN_LEFT
);
223 virtual void DrawField(BField
* field
, BRect rect
, BView
* parent
);
227 #endif // _COLUMN_TYPES_H