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