1 /* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef TABLE_COLUMNS_H 6 #define TABLE_COLUMNS_H 7 8 #include <ColumnTypes.h> 9 10 #include "table/TableColumn.h" 11 12 13 class DelagateBasedTableColumn : public TableColumn { 14 public: 15 DelagateBasedTableColumn( 16 BColumn* columnDelegate, 17 int32 modelIndex, float width, 18 float minWidth, float maxWidth, 19 alignment align); 20 virtual ~DelagateBasedTableColumn(); 21 22 protected: 23 virtual void DrawTitle(BRect rect, BView* targetView); 24 virtual void GetColumnName(BString* into) const; 25 26 virtual void DrawValue(const BVariant& value, BRect rect, 27 BView* targetView); 28 virtual float GetPreferredWidth(const BVariant& value, 29 BView* parent) const; 30 31 virtual BField* PrepareField(const BVariant& value) const = 0; 32 33 protected: 34 BColumn* fColumnDelegate; 35 }; 36 37 38 class StringTableColumn : public DelagateBasedTableColumn { 39 public: 40 StringTableColumn(int32 modelIndex, 41 const char* title, float width, 42 float minWidth, float maxWidth, 43 uint32 truncate, 44 alignment align = B_ALIGN_LEFT); 45 virtual ~StringTableColumn(); 46 47 protected: 48 virtual BField* PrepareField(const BVariant& value) const; 49 50 virtual int CompareValues(const BVariant& a, 51 const BVariant& b); 52 53 private: 54 BStringColumn fColumn; 55 mutable BStringField fField; 56 }; 57 58 59 class Int32TableColumn : public StringTableColumn { 60 public: 61 Int32TableColumn(int32 modelIndex, 62 const char* title, float width, 63 float minWidth, float maxWidth, 64 uint32 truncate = B_TRUNCATE_MIDDLE, 65 alignment align = B_ALIGN_RIGHT); 66 67 protected: 68 virtual BField* PrepareField(const BVariant& value) const; 69 70 virtual int CompareValues(const BVariant& a, 71 const BVariant& b); 72 }; 73 74 75 class Int64TableColumn : public StringTableColumn { 76 public: 77 Int64TableColumn(int32 modelIndex, 78 const char* title, float width, 79 float minWidth, float maxWidth, 80 uint32 truncate = B_TRUNCATE_MIDDLE, 81 alignment align = B_ALIGN_RIGHT); 82 83 protected: 84 virtual BField* PrepareField(const BVariant& value) const; 85 86 virtual int CompareValues(const BVariant& a, 87 const BVariant& b); 88 }; 89 90 91 class BigtimeTableColumn : public StringTableColumn { 92 public: 93 BigtimeTableColumn(int32 modelIndex, 94 const char* title, float width, 95 float minWidth, float maxWidth, 96 bool invalidFirst, 97 uint32 truncate = B_TRUNCATE_MIDDLE, 98 alignment align = B_ALIGN_RIGHT); 99 100 protected: 101 virtual BField* PrepareField(const BVariant& value) const; 102 103 virtual int CompareValues(const BVariant& a, 104 const BVariant& b); 105 106 private: 107 bool fInvalidFirst; 108 }; 109 110 111 #endif // TABLE_COLUMNS_H 112