xref: /haiku/src/apps/icon-o-matic/MainWindow.h (revision ed24eb5ff12640d052171c6a7feba37fab8a75d1)
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 			void				_WorkspaceEntered();
88 
89 			bool				_CheckSaveIcon(const BMessage* currentMessage);
90 			void				_PickUpActionBeforeSave();
91 
92 			void				_MakeIconEmpty();
93 			DocumentSaver*		_CreateSaver(const entry_ref& ref,
94 									uint32 exportMode);
95 
96 			const char*			_FileName(bool preferExporter) const;
97 			void				_UpdateWindowTitle();
98 
99 private:
100 			IconEditorApp*		fApp;
101 			Document*			fDocument;
102 			CurrentColor*		fCurrentColor;
103 			Icon*				fIcon;
104 
105 			BMessage*			fMessageAfterSave;
106 
107 			BMenu*				fPathMenu;
108 			BMenu*				fStyleMenu;
109 			BMenu*				fShapeMenu;
110 			BMenu*				fTransformerMenu;
111 			BMenu*				fPropertyMenu;
112 			BMenu*				fSwatchMenu;
113 
114 			BMenuItem*			fUndoMI;
115 			BMenuItem*			fRedoMI;
116 			BMenuItem*			fMouseFilterOffMI;
117 			BMenuItem*			fMouseFilter64MI;
118 			BMenuItem*			fMouseFilter32MI;
119 			BMenuItem*			fMouseFilter16MI;
120 
121 			CanvasView*			fCanvasView;
122 			SwatchGroup*		fSwatchGroup;
123 			StyleView*			fStyleView;
124 
125 			IconView*			fIconPreview16Folder;
126 			IconView*			fIconPreview16Menu;
127 			IconView*			fIconPreview32Folder;
128 			IconView*			fIconPreview32Desktop;
129 			IconView*			fIconPreview48;
130 			IconView*			fIconPreview64;
131 
132 			PathListView*		fPathListView;
133 			StyleListView*		fStyleListView;
134 
135 			ShapeListView*		fShapeListView;
136 			TransformerListView* fTransformerListView;
137 			IconObjectListView*	fPropertyListView;
138 
139 			// TODO: for testing only...
140 			MultipleManipulatorState* fState;
141 };
142 
143 
144 #endif // MAIN_WINDOW_H
145