vfs: check userland buffers before reading them.
[haiku.git] / headers / private / interface / ColumnTypes.h
blobe7c701748334a1336770f9aa86dafdf0224d4585
1 /*******************************************************************************
3 / File: ColumnTypes.h
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"
19 #include <String.h>
20 #include <Font.h>
21 #include <Bitmap.h>
24 //=====================================================================
25 // Common base-class: a column that draws a standard title at its top.
27 class BTitledColumn : public BColumn
29 public:
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;
43 private:
44 float fFontHeight;
45 BString fTitle;
49 //=====================================================================
50 // Field and column classes for strings.
52 class BStringField : public BField
54 public:
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();
62 void SetWidth(float);
63 float Width();
65 private:
66 float fWidth;
67 BString fString;
68 BString fClippedString;
72 //--------------------------------------------------------------------
74 class BStringColumn : public BTitledColumn
76 public:
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;
85 private:
86 uint32 fTruncate;
90 //=====================================================================
91 // Field and column classes for dates.
93 class BDateField : public BField
95 public:
96 BDateField(time_t* t);
97 void SetWidth(float);
98 float Width();
99 void SetClippedString(const char*);
100 const char* ClippedString();
101 time_t Seconds();
102 time_t UnixTime();
104 private:
105 struct tm fTime;
106 time_t fUnixTime;
107 time_t fSeconds;
108 BString fClippedString;
109 float fWidth;
113 //--------------------------------------------------------------------
115 class BDateColumn : public BTitledColumn
117 public:
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);
124 private:
125 BString fTitle;
129 //=====================================================================
130 // Field and column classes for numeric sizes.
132 class BSizeField : public BField
134 public:
135 BSizeField(off_t size);
136 void SetSize(off_t);
137 off_t Size();
139 private:
140 off_t fSize;
144 //--------------------------------------------------------------------
146 class BSizeColumn : public BTitledColumn
148 public:
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
162 public:
163 BIntegerField(int32 number);
164 void SetValue(int32);
165 int32 Value();
167 private:
168 int32 fInteger;
172 //--------------------------------------------------------------------
174 class BIntegerColumn : public BTitledColumn
176 public:
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
190 public:
191 BBitmapField(BBitmap* bitmap);
192 const BBitmap* Bitmap();
193 void SetBitmap(BBitmap* bitmap);
195 private:
196 BBitmap* fBitmap;
200 //--------------------------------------------------------------------
202 class BBitmapColumn : public BTitledColumn
204 public:
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
219 public:
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