xref: /haiku/src/apps/resedit/ResFields.h (revision e234c03470695780d2b2cfa3160db1b257d34a5a)
1*e234c034SDarkWyrm /*
2*e234c034SDarkWyrm  * Copyright (c) 2005-2010, Haiku, Inc.
3*e234c034SDarkWyrm  * Distributed under the terms of the MIT license.
4*e234c034SDarkWyrm  *
5*e234c034SDarkWyrm  * Author:
6*e234c034SDarkWyrm  *		DarkWyrm <darkwyrm@gmail.com>
7*e234c034SDarkWyrm  */
822c6ae69SDarkWyrm #ifndef RESFIELDS_H
922c6ae69SDarkWyrm #define RESFIELDS_H
1022c6ae69SDarkWyrm 
1122c6ae69SDarkWyrm #include <ColumnTypes.h>
1222c6ae69SDarkWyrm #include <Resources.h>
1322c6ae69SDarkWyrm 
1422c6ae69SDarkWyrm class ResourceData;
1522c6ae69SDarkWyrm 
1622c6ae69SDarkWyrm class TypeCodeField : public BStringField
1722c6ae69SDarkWyrm {
1822c6ae69SDarkWyrm public:
1922c6ae69SDarkWyrm 					TypeCodeField(const type_code &code, ResourceData *data);
GetTypeCode(void)2022c6ae69SDarkWyrm 	type_code 		GetTypeCode(void) const { return fTypeCode; }
GetResourceData(void)2122c6ae69SDarkWyrm 	ResourceData *	GetResourceData(void) const { return fData; }
2222c6ae69SDarkWyrm 
2322c6ae69SDarkWyrm private:
2422c6ae69SDarkWyrm 	type_code		fTypeCode;
2522c6ae69SDarkWyrm 	ResourceData	*fData;
2622c6ae69SDarkWyrm };
2722c6ae69SDarkWyrm 
2822c6ae69SDarkWyrm // This is the base class for fields displaying the preview in the Data
2922c6ae69SDarkWyrm // column of the main window. Each child class must implement all methods
3022c6ae69SDarkWyrm class PreviewField : public BField
3122c6ae69SDarkWyrm {
3222c6ae69SDarkWyrm public:
3322c6ae69SDarkWyrm 					PreviewField(void);
3422c6ae69SDarkWyrm 	virtual			~PreviewField(void);
3522c6ae69SDarkWyrm 	virtual	void	DrawField(BRect rect, BView* parent) = 0;
3622c6ae69SDarkWyrm 	virtual void	SetData(char *data, const size_t &length) = 0;
3722c6ae69SDarkWyrm };
3822c6ae69SDarkWyrm 
3922c6ae69SDarkWyrm // Unlike the BBitmapField class, this one actually takes ownership of the
4022c6ae69SDarkWyrm // bitmap passed to it. This is good because the bitmap given to it is
4122c6ae69SDarkWyrm // allocated by the Translation Kit.
4222c6ae69SDarkWyrm class BitmapPreviewField : public PreviewField
4322c6ae69SDarkWyrm {
4422c6ae69SDarkWyrm public:
4522c6ae69SDarkWyrm 					BitmapPreviewField(BBitmap *bitmap);
4622c6ae69SDarkWyrm 	virtual			~BitmapPreviewField(void);
4722c6ae69SDarkWyrm 	virtual	void	DrawField(BRect rect, BView* parent);
4822c6ae69SDarkWyrm 	virtual void	SetData(char *data, const size_t &length);
4922c6ae69SDarkWyrm 
5022c6ae69SDarkWyrm private:
5122c6ae69SDarkWyrm 	BBitmap			*fBitmap;
5222c6ae69SDarkWyrm };
5322c6ae69SDarkWyrm 
5422c6ae69SDarkWyrm class IntegerPreviewField : public PreviewField
5522c6ae69SDarkWyrm {
5622c6ae69SDarkWyrm public:
5722c6ae69SDarkWyrm 					IntegerPreviewField(const int64 &value);
5822c6ae69SDarkWyrm 	virtual			~IntegerPreviewField(void);
5922c6ae69SDarkWyrm 	virtual	void	DrawField(BRect rect, BView* parent);
6022c6ae69SDarkWyrm 	virtual void	SetData(char *data, const size_t &length);
6122c6ae69SDarkWyrm 
6222c6ae69SDarkWyrm private:
6322c6ae69SDarkWyrm 	int64			fValue;
6422c6ae69SDarkWyrm };
6522c6ae69SDarkWyrm 
6622c6ae69SDarkWyrm 
6722c6ae69SDarkWyrm class StringPreviewField : public PreviewField
6822c6ae69SDarkWyrm {
6922c6ae69SDarkWyrm public:
7022c6ae69SDarkWyrm 					StringPreviewField(const char *string);
7122c6ae69SDarkWyrm 	virtual			~StringPreviewField(void);
7222c6ae69SDarkWyrm 	virtual	void	DrawField(BRect rect, BView* parent);
7322c6ae69SDarkWyrm 	virtual void	SetData(char *data, const size_t &length);
7422c6ae69SDarkWyrm 
7522c6ae69SDarkWyrm private:
7622c6ae69SDarkWyrm 	BString			fString;
7722c6ae69SDarkWyrm 	BString			fClipped;
7822c6ae69SDarkWyrm };
7922c6ae69SDarkWyrm 
8022c6ae69SDarkWyrm BString MakeTypeString(int32 type);
8122c6ae69SDarkWyrm 
8222c6ae69SDarkWyrm #endif
83