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 <StringView.h> 16 17 18 class Group { 19 public: 20 Group(); 21 virtual ~Group(); 22 void SetGroupName(const char* group) 23 { strcpy(fGroup, group); } 24 const char* GroupName() const 25 { return fGroup; } 26 private: 27 char fGroup[64]; 28 }; 29 30 31 class Package : public Group { 32 public: 33 Package(const char* folder); 34 virtual ~Package(); 35 36 void SetFolder(const char* folder) 37 { strcpy(fFolder, folder); } 38 void SetName(const char* name) 39 { strcpy(fName, name); } 40 void SetDescription(const char* description) 41 { strcpy(fDescription, description); } 42 void SetSize(const int32 size) 43 { fSize = size; } 44 void SetIcon(BBitmap* icon) 45 { delete fIcon; fIcon = icon; } 46 void SetOnByDefault(bool onByDefault) 47 { fOnByDefault = onByDefault; } 48 void SetAlwaysOn(bool alwaysOn) 49 { fAlwaysOn = alwaysOn; } 50 const char* Folder() const 51 { return fFolder; } 52 const char* Name() const 53 { return fName; } 54 const char* Description() const 55 { return fDescription; } 56 const int32 Size() const 57 { return fSize; } 58 void GetSizeAsString(char* string, 59 size_t stringSize); 60 const BBitmap* Icon() const 61 { return fIcon; } 62 bool OnByDefault() const 63 { return fOnByDefault; } 64 bool AlwaysOn() const 65 { return fAlwaysOn; } 66 67 static Package* PackageFromEntry(BEntry &dir); 68 69 private: 70 char fFolder[64]; 71 char fName[64]; 72 char fDescription[64]; 73 int32 fSize; 74 BBitmap* fIcon; 75 bool fAlwaysOn; 76 bool fOnByDefault; 77 }; 78 79 80 class PackageCheckBox : public BCheckBox { 81 public: 82 PackageCheckBox(BRect rect, Package* item); 83 virtual ~PackageCheckBox(); 84 85 virtual void Draw(BRect updateRect); 86 virtual void MouseMoved(BPoint point, uint32 transit, 87 const BMessage* dragMessage); 88 89 Package* GetPackage() 90 { return fPackage; }; 91 private: 92 Package* fPackage; 93 }; 94 95 96 class GroupView : public BStringView { 97 public: 98 GroupView(BRect rect, Group* group); 99 virtual ~GroupView(); 100 101 private: 102 Group* fGroup; 103 }; 104 105 106 class PackagesView : public BView { 107 public: 108 PackagesView(BRect rect, const char* name); 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 FrameResized(float width, float height); 119 virtual void Draw(BRect updateRect); 120 virtual void GetPreferredSize(float* _width, float* _height); 121 virtual BSize MaxSize(); 122 123 private: 124 BList fViews; 125 }; 126 127 #endif // __PACKAGEVIEWS_H__ 128