1 /* 2 * Copyright (c) 2001-2005, Haiku, Inc. 3 * Distributed under the terms of the MIT license. 4 * 5 * Author: 6 * DarkWyrm <bpmagic@columbus.rr.com> 7 * Clemens Zeidler <haiku@clemens-zeidler.de> 8 */ 9 #ifndef DECOR_MANAGER_H 10 #define DECOR_MANAGER_H 11 12 13 #include <image.h> 14 #include <String.h> 15 #include <Locker.h> 16 #include <ObjectList.h> 17 #include <Entry.h> 18 #include <DecorInfo.h> 19 20 #include "Decorator.h" 21 22 class Desktop; 23 class DesktopListener; 24 class DrawingEngine; 25 class Window; 26 class WindowBehaviour; 27 28 29 typedef BObjectList<DesktopListener> DesktopListenerList; 30 31 32 // special name to test for use of non-fs-tied default decorator 33 // this just keeps things clean and simple is all 34 35 class DecorAddOn { 36 public: 37 DecorAddOn(image_id id, const char* name); 38 virtual ~DecorAddOn(); 39 40 virtual status_t InitCheck() const; 41 42 image_id ImageID() const { return fImageID; } 43 44 Decorator* AllocateDecorator(Desktop* desktop, 45 DrawingEngine* engine, BRect rect, 46 const char* title, window_look look, 47 uint32 flags); 48 49 virtual WindowBehaviour* AllocateWindowBehaviour(Window* window); 50 51 virtual const DesktopListenerList& GetDesktopListeners(); 52 53 protected: 54 virtual Decorator* _AllocateDecorator(DesktopSettings& settings, 55 BRect rect, window_look look, uint32 flags); 56 57 DesktopListenerList fDesktopListeners; 58 59 private: 60 image_id fImageID; 61 BString fName; 62 }; 63 64 65 class DecorManager { 66 public: 67 DecorManager(); 68 ~DecorManager(); 69 70 Decorator* AllocateDecorator(Window *window); 71 WindowBehaviour* AllocateWindowBehaviour(Window *window); 72 void CleanupForWindow(Window *window); 73 74 status_t PreviewDecorator(BString path, Window *window); 75 76 const DesktopListenerList& GetDesktopListeners(); 77 78 BString GetCurrentDecorator() const; 79 status_t SetDecorator(BString path, Desktop *desktop); 80 81 private: 82 DecorAddOn* _LoadDecor(BString path, status_t &error); 83 bool _LoadSettingsFromDisk(); 84 bool _SaveSettingsToDisk(); 85 86 private: 87 DecorAddOn fDefaultDecor; 88 DecorAddOn* fCurrentDecor; 89 DecorAddOn* fPreviewDecor; 90 91 Window* fPreviewWindow; 92 BString fCurrentDecorPath; 93 }; 94 95 extern DecorManager gDecorManager; 96 97 #endif /* DECOR_MANAGER_H */ 98