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