1/*
2 * Copyright 2007-2014, Haiku, Inc.
3 * Distributed under the terms of the MIT license.
4 *
5 * Author:
6 *		��ukasz 'Sil2100' Zemczak <sil2100@vexillium.org>
7 */
8#ifndef PACKAGE_VIEW_H
9#define PACKAGE_VIEW_H
10
11
12#include "PackageInfo.h"
13#include "PackageInstall.h"
14#include "PackageStatus.h"
15
16#include <View.h>
17
18class BBox;
19class BButton;
20class BFilePanel;
21class BMenu;
22class BMenuField;
23class BPopUpMenu;
24class BTextView;
25
26
27enum {
28	P_MSG_INSTALL_TYPE_CHANGED = 'gpch',
29	P_MSG_PATH_CHANGED,
30	P_MSG_OPEN_PANEL,
31	P_MSG_INSTALL
32};
33
34class PackageView : public BView {
35public:
36								PackageView(const entry_ref* ref);
37	virtual						~PackageView();
38
39	virtual	void				AttachedToWindow();
40	virtual	void				MessageReceived(BMessage* message);
41
42			int32				ItemExists(PackageItem& item,
43									BPath& path, int32& policy);
44
45			BPath*				CurrentPath()
46									{ return &fCurrentPath; }
47			PackageInfo*		GetPackageInfo()
48									{ return &fInfo; }
49			uint32				CurrentType() const
50									{ return fCurrentType; }
51			PackageStatus*		StatusWindow()
52									{ return fStatusWindow; }
53
54private:
55			void				_InitView();
56			void				_InitProfiles();
57
58			status_t			_InstallTypeChanged(int32 index);
59
60			BString				_NamePlusSizeString(BString name,
61									size_t size, const char* format) const;
62			BMenuItem*			_AddInstallTypeMenuItem(BString baseName,
63									size_t size, int32 index) const;
64			BMenuItem*			_AddDestinationMenuItem(BString baseName,
65									size_t size, const char* path) const;
66			BMenuItem*			_AddMenuItem(const char* name,
67									BMessage* message, BMenu* menu) const;
68
69			bool				_ValidateFilePanelMessage(BMessage* message);
70
71private:
72			BPopUpMenu*			fInstallTypes;
73			BTextView*			fInstallTypeDescriptionView;
74			BPopUpMenu*			fDestination;
75			BMenuField*			fDestField;
76			BButton*			fBeginButton;
77
78			BFilePanel*			fOpenPanel;
79			bool				fExpectingOpenPanelResult;
80
81			BPath				fCurrentPath;
82			uint32				fCurrentType;
83
84			PackageInfo			fInfo;
85			PackageStatus*		fStatusWindow;
86			PackageInstall		fInstallProcess;
87};
88
89#endif	// PACKAGE_VIEW_H
90
91