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