xref: /haiku/src/apps/resedit/ResView.h (revision 83b1a68c52ba3e0e8796282759f694b7fdddf06d)
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 
22 class BMenuBar;
23 class ResListView;
24 
25 enum {
26 	FILE_CLEAN = 0,
27 	FILE_DIRTY,
28 	FILE_INIT,
29 	FILE_QUIT_AFTER_SAVE
30 };
31 
32 class ResView : public BView
33 {
34 public:
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 
50 private:
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 
70 class ResDataRow : public BRow
71 {
72 public:
73 					ResDataRow(ResourceData *data);
74 	ResourceData *	GetData(void) const;
75 
76 private:
77 	ResourceData	*fResData;
78 };
79 
80 extern ResourceRoster gResRoster;
81 
82 #endif
83