xref: /haiku/src/apps/icon-o-matic/gui/StyleView.h (revision 83b1a68c52ba3e0e8796282759f694b7fdddf06d)
1 /*
2  * Copyright 2006-2011, Haiku.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Stephan Aßmus <superstippi@gmx.de>
7  */
8 #ifndef STYLE_VIEW_H
9 #define STYLE_VIEW_H
10 
11 
12 #include "IconBuild.h"
13 #include "Observer.h"
14 
15 #include <View.h>
16 
17 
18 class BMenu;
19 class BMenuField;
20 class CommandStack;
21 class CurrentColor;
22 class GradientControl;
23 
24 _BEGIN_ICON_NAMESPACE
25 	class Gradient;
26 	class Style;
27 _END_ICON_NAMESPACE
28 
29 _USING_ICON_NAMESPACE
30 
31 
32 // TODO: write lock the document when changing something...
33 
34 enum {
35 	MSG_STYLE_TYPE_CHANGED	= 'stch',
36 };
37 
38 class StyleView : public BView, public Observer {
39 public:
40 								StyleView(BRect frame);
41 	virtual						~StyleView();
42 
43 	// BView interface
44 	virtual	void				AttachedToWindow();
45 	virtual	void				FrameResized(float width, float height);
46 	virtual	void				MessageReceived(BMessage* message);
47 
48 	virtual	BSize				MinSize();
49 
50 	// Observer interface
51 	virtual	void				ObjectChanged(const Observable* object);
52 
53 	// StyleView
54 			void				SetStyle(Style* style);
55 			void				SetCommandStack(CommandStack* stack);
56 			void				SetCurrentColor(CurrentColor* color);
57 
58 private:
59 			void				_SetGradient(Gradient* gradient,
60 									bool forceControlUpdate = false,
61 									bool sendMessage = false);
62 			void				_MarkType(BMenu* menu, int32 type) const;
63 			void				_SetStyleType(int32 type);
64 			void				_SetGradientType(int32 type);
65 			void				_AdoptCurrentColor(rgb_color color);
66 			void				_TransferGradientStopColor();
67 
68 private:
69 			CommandStack*		fCommandStack;
70 			CurrentColor*		fCurrentColor;
71 
72 			Style*				fStyle;
73 			Gradient*			fGradient;
74 			bool				fIgnoreCurrentColorNotifications;
75 			bool				fIgnoreControlGradientNotifications;
76 
77 			GradientControl*	fGradientControl;
78 			BMenuField*			fStyleType;
79 			BMenuField*			fGradientType;
80 
81 			BRect				fPreviousBounds;
82 };
83 
84 
85 #endif // STYLE_VIEW_H
86