1 /* 2 * Copyright 2005, Jérôme DUVAL. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef __PACKAGEVIEWS_H__ 6 #define __PACKAGEVIEWS_H__ 7 8 #include <stdlib.h> 9 #include <string.h> 10 11 #include <Bitmap.h> 12 #include <CheckBox.h> 13 #include <Entry.h> 14 #include <List.h> 15 #include <String.h> 16 #include <StringView.h> 17 18 19 class Group { 20 public: 21 Group(); 22 virtual ~Group(); 23 void SetGroupName(const char* group) 24 { strcpy(fGroup, group); } 25 const char* GroupName() const 26 { return fGroup; } 27 private: 28 char fGroup[64]; 29 }; 30 31 32 class Package : public Group { 33 public: 34 Package(const char* folder); 35 virtual ~Package(); 36 37 void SetFolder(BString folder) 38 { fFolder = folder; } 39 void SetName(const BString name) 40 { fName = name; } 41 void SetDescription(const BString description) 42 { fDescription = description; } 43 void SetSize(const int32 size) 44 { fSize = size; } 45 void SetIcon(BBitmap* icon) 46 { delete fIcon; fIcon = icon; } 47 void SetOnByDefault(bool onByDefault) 48 { fOnByDefault = onByDefault; } 49 void SetAlwaysOn(bool alwaysOn) 50 { fAlwaysOn = alwaysOn; } 51 BString Folder() const 52 { return fFolder; } 53 BString Name() const 54 { return fName; } 55 BString Description() const 56 { return fDescription; } 57 const int32 Size() const 58 { return fSize; } 59 void GetSizeAsString(char* string, 60 size_t stringSize); 61 const BBitmap* Icon() const 62 { return fIcon; } 63 bool OnByDefault() const 64 { return fOnByDefault; } 65 bool AlwaysOn() const 66 { return fAlwaysOn; } 67 68 static Package* PackageFromEntry(BEntry &dir); 69 70 private: 71 BString fFolder; 72 BString fName; 73 BString fDescription; 74 int32 fSize; 75 BBitmap* fIcon; 76 bool fAlwaysOn; 77 bool fOnByDefault; 78 }; 79 80 81 class PackageCheckBox : public BCheckBox { 82 public: 83 PackageCheckBox(Package* item); 84 virtual ~PackageCheckBox(); 85 86 virtual void Draw(BRect updateRect); 87 virtual void MouseMoved(BPoint point, uint32 transit, 88 const BMessage* dragMessage); 89 90 Package* GetPackage() 91 { return fPackage; }; 92 private: 93 Package* fPackage; 94 }; 95 96 97 class GroupView : public BStringView { 98 public: 99 GroupView(Group* group); 100 virtual ~GroupView(); 101 102 private: 103 Group* fGroup; 104 }; 105 106 107 class PackagesView : public BView { 108 public: 109 PackagesView(const char* name); 110 virtual ~PackagesView(); 111 112 void Clean(); 113 void AddPackages(BList& list, BMessage* message); 114 void GetTotalSizeAsString(char* string, 115 size_t stringSize); 116 void GetPackagesToInstall(BList* list, int32* size); 117 118 virtual void Draw(BRect updateRect); 119 }; 120 121 #endif // __PACKAGEVIEWS_H__ 122