xref: /haiku/src/apps/resedit/ResFields.h (revision 2600324b57fa31cdea1627d584d314f2a579c4a8)
1 #ifndef RESFIELDS_H
2 #define RESFIELDS_H
3 
4 #include <ColumnTypes.h>
5 #include <Resources.h>
6 
7 class ResourceData;
8 
9 class TypeCodeField : public BStringField
10 {
11 public:
12 					TypeCodeField(const type_code &code, ResourceData *data);
13 	type_code 		GetTypeCode(void) const { return fTypeCode; }
14 	ResourceData *	GetResourceData(void) const { return fData; }
15 
16 private:
17 	type_code		fTypeCode;
18 	ResourceData	*fData;
19 };
20 
21 // This is the base class for fields displaying the preview in the Data
22 // column of the main window. Each child class must implement all methods
23 class PreviewField : public BField
24 {
25 public:
26 					PreviewField(void);
27 	virtual			~PreviewField(void);
28 	virtual	void	DrawField(BRect rect, BView* parent) = 0;
29 	virtual void	SetData(char *data, const size_t &length) = 0;
30 };
31 
32 // Unlike the BBitmapField class, this one actually takes ownership of the
33 // bitmap passed to it. This is good because the bitmap given to it is
34 // allocated by the Translation Kit.
35 class BitmapPreviewField : public PreviewField
36 {
37 public:
38 					BitmapPreviewField(BBitmap *bitmap);
39 	virtual			~BitmapPreviewField(void);
40 	virtual	void	DrawField(BRect rect, BView* parent);
41 	virtual void	SetData(char *data, const size_t &length);
42 
43 private:
44 	BBitmap			*fBitmap;
45 };
46 
47 class IntegerPreviewField : public PreviewField
48 {
49 public:
50 					IntegerPreviewField(const int64 &value);
51 	virtual			~IntegerPreviewField(void);
52 	virtual	void	DrawField(BRect rect, BView* parent);
53 	virtual void	SetData(char *data, const size_t &length);
54 
55 private:
56 	int64			fValue;
57 };
58 
59 
60 class StringPreviewField : public PreviewField
61 {
62 public:
63 					StringPreviewField(const char *string);
64 	virtual			~StringPreviewField(void);
65 	virtual	void	DrawField(BRect rect, BView* parent);
66 	virtual void	SetData(char *data, const size_t &length);
67 
68 private:
69 	BString			fString;
70 	BString			fClipped;
71 };
72 
73 BString MakeTypeString(int32 type);
74 
75 #endif
76