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