1 /*!
2 	@file
3 	@author		Albert Semenov
4 	@date		09/2008
5 */
6 #ifndef COLOUR_PANEL_H_
7 #define COLOUR_PANEL_H_
8 
9 #include <MyGUI.h>
10 #include "BaseLayout/BaseLayout.h"
11 
12 namespace demo
13 {
14 
15 	ATTRIBUTE_CLASS_LAYOUT(ColourPanel, "ColourPanel.layout");
16 	class ColourPanel :
17 		public wraps::BaseLayout
18 	{
19 	public:
20 		ColourPanel();
21 		virtual ~ColourPanel();
22 
23 		void setColour(const MyGUI::Colour& _colour);
24 		const MyGUI::Colour& getColour() const;
25 
26 		MyGUI::delegates::CDelegate1<ColourPanel*> eventColourAccept;
27 
28 	private:
29 		void notifyMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
30 		void notifyMouseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
31 		void notifyScrollChangePosition(MyGUI::ScrollBar* _sender, size_t _position);
32 		void notifyEditTextChange(MyGUI::EditBox* _sender);
33 		void notifyMouseButtonClick(MyGUI::Widget* _sender);
34 
35 		void updateFirst();
36 
37 		void createTexture();
38 		void updateTexture(const MyGUI::Colour& _colour);
39 		void destroyTexture();
40 
41 		void updateFromPoint(const MyGUI::IntPoint& _point);
42 		void updateFromColour(const MyGUI::Colour& _colour);
43 
44 		MyGUI::Colour getSaturate(const MyGUI::Colour& _colour) const;
45 
46 		float& byIndex(MyGUI::Colour& _colour, size_t _index);
47 
48 	private:
49 		ATTRIBUTE_FIELD_WIDGET_NAME(ColourPanel, mColourRect, "widget_ColourRect");
50 		MyGUI::ImageBox* mColourRect;
51 
52 		ATTRIBUTE_FIELD_WIDGET_NAME(ColourPanel, mColourView, "widget_ColourView");
53 		MyGUI::Widget* mColourView;
54 
55 		ATTRIBUTE_FIELD_WIDGET_NAME(ColourPanel, mImageColourPicker, "image_Picker");
56 		MyGUI::ImageBox* mImageColourPicker;
57 
58 		ATTRIBUTE_FIELD_WIDGET_NAME(ColourPanel, mEditRed, "edit_Red");
59 		MyGUI::EditBox* mEditRed;
60 
61 		ATTRIBUTE_FIELD_WIDGET_NAME(ColourPanel, mEditGreen, "edit_Green");
62 		MyGUI::EditBox* mEditGreen;
63 
64 		ATTRIBUTE_FIELD_WIDGET_NAME(ColourPanel, mEditBlue, "edit_Blue");
65 		MyGUI::EditBox* mEditBlue;
66 
67 		ATTRIBUTE_FIELD_WIDGET_NAME(ColourPanel, mScrollRange, "scroll_Range");
68 		MyGUI::ScrollBar* mScrollRange;
69 
70 		ATTRIBUTE_FIELD_WIDGET_NAME(ColourPanel, mOk, "button_OK");
71 		MyGUI::Button* mOk;
72 
73 		MyGUI::Colour mCurrentColour;
74 		MyGUI::Colour mBaseColour;
75 
76 		std::vector<MyGUI::Colour> mColourRange;
77 
78 		MyGUI::ITexture* mTexture;
79 	};
80 
81 } // namespace demo
82 
83 #endif // COLOUR_PANEL_H_
84