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