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