1/*
2 * Copyright (c) 2005-2010, Haiku, Inc.
3 * Distributed under the terms of the MIT license.
4 *
5 * Author:
6 *		DarkWyrm <darkwyrm@gmail.com>
7 */
8#ifndef RESVIEW_H
9#define RESVIEW_H
10
11#include <Entry.h>
12#include <FilePanel.h>
13#include <List.h>
14#include <ListItem.h>
15#include <MenuBar.h>
16#include <Resources.h>
17#include <String.h>
18#include <View.h>
19
20#include "ResourceRoster.h"
21
22class BMenuBar;
23class ResListView;
24
25enum {
26	FILE_CLEAN = 0,
27	FILE_DIRTY,
28	FILE_INIT,
29	FILE_QUIT_AFTER_SAVE
30};
31
32class ResView : public BView
33{
34public:
35					ResView(const BRect &frame, const char *name,
36							const int32 &resize, const int32 &flags,
37							const entry_ref *ref = NULL);
38					~ResView(void);
39	void			AttachedToWindow(void);
40	void			MessageReceived(BMessage *msg);
41
42	const char *	Filename(void) const { return fFileName.String(); }
43	uint8			GetSaveStatus(void) const { return fSaveStatus; }
44
45	status_t		SetTo(const entry_ref &dir, const BString &name);
46	void			OpenFile(const entry_ref &ref);
47	void			SaveFile(void);
48	void			SaveAndQuit(void);
49
50private:
51	void			BuildMenus(BMenuBar *menuBar);
52	void			EmptyDataList(void);
53	void			UpdateRow(BRow *row);
54	void			HandleDrop(BMessage *msg);
55	void			AddResource(const entry_ref &ref);
56	void			DeleteSelectedResources(void);
57	void			SetSaveStatus(uint8 value);
58
59	ResListView		*fListView;
60	entry_ref		*fRef;
61	BString			fFileName;
62	BMenuBar		*fBar;
63	uint8			fSaveStatus;
64	BList			fDataList;
65	BFilePanel		*fOpenPanel,
66					*fSavePanel;
67};
68
69
70class ResDataRow : public BRow
71{
72public:
73					ResDataRow(ResourceData *data);
74	ResourceData *	GetData(void) const;
75
76private:
77	ResourceData	*fResData;
78};
79
80extern ResourceRoster gResRoster;
81
82#endif
83