xref: /haiku/src/apps/icon-o-matic/MainWindow.h (revision 27ae691c1f847b21d12cbfbceb7ed3f06a887e3c)
1 /*
2  * Copyright 2006-2010, Stephan Aßmus <superstippi@gmx.de>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 #ifndef MAIN_WINDOW_H
6 #define MAIN_WINDOW_H
7 
8 
9 #include <Entry.h>
10 #include <Window.h>
11 
12 #include "IconBuild.h"
13 #include "Observer.h"
14 
15 
16 class BMenu;
17 class BMenuBar;
18 class BMenuItem;
19 class CanvasView;
20 class CurrentColor;
21 class Document;
22 class DocumentSaver;
23 class IconObjectListView;
24 class IconEditorApp;
25 class IconView;
26 class PathListView;
27 class ShapeListView;
28 class StyleListView;
29 class StyleView;
30 class SwatchGroup;
31 class TransformerListView;
32 
33 _BEGIN_ICON_NAMESPACE
34 	class Icon;
35 _END_ICON_NAMESPACE
36 
37 _USING_ICON_NAMESPACE
38 
39 
40 class MultipleManipulatorState;
41 
42 enum {
43 	MSG_OPEN						= 'open',
44 	MSG_APPEND						= 'apnd',
45 	MSG_SAVE						= 'save',
46 	MSG_EXPORT						= 'xprt',
47 };
48 
49 
50 class MainWindow : public BWindow, public Observer {
51 public:
52 								MainWindow(BRect frame, IconEditorApp* app,
53 									const BMessage* settings);
54 	virtual						~MainWindow();
55 
56 	// BWindow interface
57 	virtual	void				MessageReceived(BMessage* message);
58 	virtual	void				Show();
59 	virtual	bool				QuitRequested();
60 	virtual	void				WorkspaceActivated(int32 workspace,
61 									bool active);
62 	virtual	void				WorkspacesChanged(uint32 oldWorkspaces,
63 									uint32 newWorkspaces);
64 
65 	// Observer interface
66 	virtual	void				ObjectChanged(const Observable* object);
67 
68 	// MainWindow
69 			void				MakeEmpty();
70 			void				SetIcon(Icon* icon);
71 
72 			void				Open(const entry_ref& ref,
73 									bool append = false);
74 			void				Open(const BMessenger& externalObserver,
75 									const uint8* data, size_t size);
76 
77 			void				StoreSettings(BMessage* archive);
78 			void				RestoreSettings(const BMessage* archive);
79 
80 private:
81 			void				_Init();
82 			void				_CreateGUI();
83 			BMenuBar*			_CreateMenuBar();
84 
85 			void				_ImproveScrollBarLayout(BView* target);
86 
87 			bool				_CheckSaveIcon(const BMessage* currentMessage);
88 			void				_PickUpActionBeforeSave();
89 
90 			void				_MakeIconEmpty();
91 			DocumentSaver*		_CreateSaver(const entry_ref& ref,
92 									uint32 exportMode);
93 
94 			const char*			_FileName(bool preferExporter) const;
95 			void				_UpdateWindowTitle();
96 
97 private:
98 			IconEditorApp*		fApp;
99 			Document*			fDocument;
100 			CurrentColor*		fCurrentColor;
101 			Icon*				fIcon;
102 
103 			BMessage*			fMessageAfterSave;
104 
105 			BMenu*				fPathMenu;
106 			BMenu*				fStyleMenu;
107 			BMenu*				fShapeMenu;
108 			BMenu*				fTransformerMenu;
109 			BMenu*				fPropertyMenu;
110 			BMenu*				fSwatchMenu;
111 
112 			BMenuItem*			fUndoMI;
113 			BMenuItem*			fRedoMI;
114 			BMenuItem*			fMouseFilterOffMI;
115 			BMenuItem*			fMouseFilter64MI;
116 			BMenuItem*			fMouseFilter32MI;
117 			BMenuItem*			fMouseFilter16MI;
118 
119 			CanvasView*			fCanvasView;
120 			SwatchGroup*		fSwatchGroup;
121 			StyleView*			fStyleView;
122 
123 			IconView*			fIconPreview16Folder;
124 			IconView*			fIconPreview16Menu;
125 			IconView*			fIconPreview32Folder;
126 			IconView*			fIconPreview32Desktop;
127 			IconView*			fIconPreview48;
128 			IconView*			fIconPreview64;
129 
130 			PathListView*		fPathListView;
131 			StyleListView*		fStyleListView;
132 
133 			ShapeListView*		fShapeListView;
134 			TransformerListView* fTransformerListView;
135 			IconObjectListView*	fPropertyListView;
136 
137 			// TODO: for testing only...
138 			MultipleManipulatorState* fState;
139 };
140 
141 
142 #endif // MAIN_WINDOW_H
143