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