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 bool QuitRequested(); 59 virtual void WorkspaceActivated(int32 workspace, 60 bool active); 61 virtual void WorkspacesChanged(uint32 oldWorkspaces, 62 uint32 newWorkspaces); 63 64 // Observer interface 65 virtual void ObjectChanged(const Observable* object); 66 67 // MainWindow 68 void MakeEmpty(); 69 void SetIcon(Icon* icon); 70 71 void Open(const entry_ref& ref, 72 bool append = false); 73 void Open(const BMessenger& externalObserver, 74 const uint8* data, size_t size); 75 76 void StoreSettings(BMessage* archive); 77 void RestoreSettings(const BMessage* archive); 78 79 private: 80 void _Init(); 81 void _CreateGUI(); 82 BMenuBar* _CreateMenuBar(); 83 84 void _ImproveScrollBarLayout(BView* target); 85 86 bool _CheckSaveIcon(const BMessage* currentMessage); 87 void _PickUpActionBeforeSave(); 88 89 void _MakeIconEmpty(); 90 DocumentSaver* _CreateSaver(const entry_ref& ref, 91 uint32 exportMode); 92 93 const char* _FileName(bool preferExporter) const; 94 void _UpdateWindowTitle(); 95 96 private: 97 IconEditorApp* fApp; 98 Document* fDocument; 99 CurrentColor* fCurrentColor; 100 Icon* fIcon; 101 102 BMessage* fMessageAfterSave; 103 104 BMenu* fPathMenu; 105 BMenu* fStyleMenu; 106 BMenu* fShapeMenu; 107 BMenu* fTransformerMenu; 108 BMenu* fPropertyMenu; 109 BMenu* fSwatchMenu; 110 111 BMenuItem* fUndoMI; 112 BMenuItem* fRedoMI; 113 BMenuItem* fMouseFilterOffMI; 114 BMenuItem* fMouseFilter64MI; 115 BMenuItem* fMouseFilter32MI; 116 BMenuItem* fMouseFilter16MI; 117 118 CanvasView* fCanvasView; 119 SwatchGroup* fSwatchGroup; 120 StyleView* fStyleView; 121 122 IconView* fIconPreview16Folder; 123 IconView* fIconPreview16Menu; 124 IconView* fIconPreview32Folder; 125 IconView* fIconPreview32Desktop; 126 IconView* fIconPreview48; 127 IconView* fIconPreview64; 128 129 PathListView* fPathListView; 130 StyleListView* fStyleListView; 131 132 ShapeListView* fShapeListView; 133 TransformerListView* fTransformerListView; 134 IconObjectListView* fPropertyListView; 135 136 // TODO: for testing only... 137 MultipleManipulatorState* fState; 138 }; 139 140 141 #endif // MAIN_WINDOW_H 142