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