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 20class BMenu; 21class BMenuBar; 22class BMenuItem; 23class CanvasView; 24class CurrentColor; 25class Document; 26class DocumentSaver; 27class IconObjectListView; 28class IconEditorApp; 29class IconView; 30class PathListView; 31class ShapeListView; 32class StyleListView; 33class StyleView; 34class SwatchGroup; 35class TransformerListView; 36 37_BEGIN_ICON_NAMESPACE 38 class Icon; 39_END_ICON_NAMESPACE 40 41_USING_ICON_NAMESPACE 42 43 44class MultipleManipulatorState; 45 46enum { 47 MSG_OPEN = 'open', 48 MSG_APPEND = 'apnd', 49 MSG_SAVE = 'save', 50 MSG_EXPORT = 'xprt', 51}; 52 53 54class MainWindow : public BWindow, public Observer { 55public: 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 87private: 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 char* _FileName(bool preferExporter) const; 104 void _UpdateWindowTitle(); 105 106private: 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