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 const BBitmap* Icon() const 60 { return fIcon; } 61 bool OnByDefault() const 62 { return fOnByDefault; } 63 bool AlwaysOn() const 64 { return fAlwaysOn; } 65 66 static Package* PackageFromEntry(BEntry &dir); 67 68 private: 69 char fFolder[64]; 70 char fName[64]; 71 char fDescription[64]; 72 int32 fSize; 73 BBitmap* fIcon; 74 bool fAlwaysOn; 75 bool fOnByDefault; 76 }; 77 78 79 class PackageCheckBox : public BCheckBox { 80 public: 81 PackageCheckBox(BRect rect, Package* item); 82 virtual ~PackageCheckBox(); 83 84 virtual void Draw(BRect updateRect); 85 virtual void MouseMoved(BPoint point, uint32 transit, 86 const BMessage* dragMessage); 87 88 Package* GetPackage() 89 { return fPackage; }; 90 private: 91 Package* fPackage; 92 }; 93 94 95 class GroupView : public BStringView { 96 public: 97 GroupView(BRect rect, Group* group); 98 virtual ~GroupView(); 99 100 private: 101 Group* fGroup; 102 }; 103 104 105 class PackagesView : public BView { 106 public: 107 PackagesView(BRect rect, const char* name); 108 PackagesView(const char* name); 109 virtual ~PackagesView(); 110 111 void Clean(); 112 void AddPackages(BList& list, BMessage* message); 113 void GetTotalSizeAsString(char* string); 114 void GetPackagesToInstall(BList* list, int32* size); 115 116 virtual void FrameResized(float width, float height); 117 virtual void Draw(BRect updateRect); 118 virtual void GetPreferredSize(float* _width, float* _height); 119 virtual BSize MaxSize(); 120 121 private: 122 BList fViews; 123 }; 124 125 #endif // __PACKAGEVIEWS_H__ 126