diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8/tools/GUIEditor/CGUIColorAttribute.h | 358 |
1 files changed, 179 insertions, 179 deletions
diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIColorAttribute.h b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIColorAttribute.h index e0c5212..d14b7a1 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIColorAttribute.h +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIColorAttribute.h | |||
@@ -1,179 +1,179 @@ | |||
1 | #ifndef __C_GUI_COLOR_ATTRIBUTE_H_INCLUDED__ | 1 | #ifndef __C_GUI_COLOR_ATTRIBUTE_H_INCLUDED__ |
2 | #define __C_GUI_COLOR_ATTRIBUTE_H_INCLUDED__ | 2 | #define __C_GUI_COLOR_ATTRIBUTE_H_INCLUDED__ |
3 | 3 | ||
4 | #include "CGUIAttribute.h" | 4 | #include "CGUIAttribute.h" |
5 | #include "IGUIStaticText.h" | 5 | #include "IGUIStaticText.h" |
6 | #include "IGUIScrollBar.h" | 6 | #include "IGUIScrollBar.h" |
7 | #include "IGUITabControl.h" | 7 | #include "IGUITabControl.h" |
8 | #include "EGUIEditTypes.h" | 8 | #include "EGUIEditTypes.h" |
9 | 9 | ||
10 | namespace irr | 10 | namespace irr |
11 | { | 11 | { |
12 | namespace gui | 12 | namespace gui |
13 | { | 13 | { |
14 | class CGUIColorAttribute : public CGUIAttribute | 14 | class CGUIColorAttribute : public CGUIAttribute |
15 | { | 15 | { |
16 | public: | 16 | public: |
17 | // | 17 | // |
18 | CGUIColorAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) : | 18 | CGUIColorAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) : |
19 | CGUIAttribute(environment, parent, myParentID), | 19 | CGUIAttribute(environment, parent, myParentID), |
20 | AttribSliderA(0), AttribSliderR(0), AttribSliderG(0), AttribSliderB(0), | 20 | AttribSliderA(0), AttribSliderR(0), AttribSliderG(0), AttribSliderB(0), |
21 | AttribEditBox(0), AttribColor(0) | 21 | AttribEditBox(0), AttribColor(0) |
22 | { | 22 | { |
23 | s32 fh = Environment->getSkin()->getFont()->getDimension(L"A").Height; | 23 | s32 fh = Environment->getSkin()->getFont()->getDimension(L"A").Height; |
24 | 24 | ||
25 | core::rect<s32> r0(getAbsolutePosition()), | 25 | core::rect<s32> r0(getAbsolutePosition()), |
26 | r2(0, fh + 5, r0.getWidth() - 5, fh*2 + 10 ), | 26 | r2(0, fh + 5, r0.getWidth() - 5, fh*2 + 10 ), |
27 | r3(r2), | 27 | r3(r2), |
28 | r4(r2.getWidth() - 20, 3, r2.getWidth() - 3, r2.getHeight()-3); | 28 | r4(r2.getWidth() - 20, 3, r2.getWidth() - 3, r2.getHeight()-3); |
29 | 29 | ||
30 | AttribColor = Environment->addTab(r4, this, 0); | 30 | AttribColor = Environment->addTab(r4, this, 0); |
31 | AttribColor->grab(); | 31 | AttribColor->grab(); |
32 | AttribColor->setDrawBackground(true); | 32 | AttribColor->setDrawBackground(true); |
33 | AttribColor->setSubElement(true); | 33 | AttribColor->setSubElement(true); |
34 | AttribColor->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); | 34 | AttribColor->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); |
35 | 35 | ||
36 | s32 h=2; | 36 | s32 h=2; |
37 | r2 += core::position2di(0, h*4 + Environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH)*2); | 37 | r2 += core::position2di(0, h*4 + Environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH)*2); |
38 | r3.LowerRightCorner.Y = r3.UpperLeftCorner.Y + Environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH)/2; | 38 | r3.LowerRightCorner.Y = r3.UpperLeftCorner.Y + Environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH)/2; |
39 | 39 | ||
40 | AttribSliderA = environment->addScrollBar(true, r3, this, -1); | 40 | AttribSliderA = environment->addScrollBar(true, r3, this, -1); |
41 | AttribSliderA->setMax(255); | 41 | AttribSliderA->setMax(255); |
42 | AttribSliderA->grab(); | 42 | AttribSliderA->grab(); |
43 | AttribSliderA->setSubElement(true); | 43 | AttribSliderA->setSubElement(true); |
44 | AttribSliderA->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); | 44 | AttribSliderA->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); |
45 | r3 += core::position2di(0, r3.getHeight()+h); | 45 | r3 += core::position2di(0, r3.getHeight()+h); |
46 | AttribSliderR = environment->addScrollBar(true, r3, this, -1); | 46 | AttribSliderR = environment->addScrollBar(true, r3, this, -1); |
47 | AttribSliderR->setMax(255); | 47 | AttribSliderR->setMax(255); |
48 | AttribSliderR->grab(); | 48 | AttribSliderR->grab(); |
49 | AttribSliderR->setSubElement(true); | 49 | AttribSliderR->setSubElement(true); |
50 | AttribSliderR->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); | 50 | AttribSliderR->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); |
51 | r3 += core::position2di(0, r3.getHeight()+h); | 51 | r3 += core::position2di(0, r3.getHeight()+h); |
52 | AttribSliderG = environment->addScrollBar(true, r3, this, -1); | 52 | AttribSliderG = environment->addScrollBar(true, r3, this, -1); |
53 | AttribSliderG->setMax(255); | 53 | AttribSliderG->setMax(255); |
54 | AttribSliderG->grab(); | 54 | AttribSliderG->grab(); |
55 | AttribSliderG->setSubElement(true); | 55 | AttribSliderG->setSubElement(true); |
56 | AttribSliderG->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); | 56 | AttribSliderG->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); |
57 | r3 += core::position2di(0, r3.getHeight()+h); | 57 | r3 += core::position2di(0, r3.getHeight()+h); |
58 | AttribSliderB = environment->addScrollBar(true, r3, this, -1); | 58 | AttribSliderB = environment->addScrollBar(true, r3, this, -1); |
59 | AttribSliderB->setMax(255); | 59 | AttribSliderB->setMax(255); |
60 | AttribSliderB->grab(); | 60 | AttribSliderB->grab(); |
61 | AttribSliderB->setSubElement(true); | 61 | AttribSliderB->setSubElement(true); |
62 | AttribSliderB->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); | 62 | AttribSliderB->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); |
63 | 63 | ||
64 | // add editbox | 64 | // add editbox |
65 | AttribEditBox = environment->addEditBox( | 65 | AttribEditBox = environment->addEditBox( |
66 | L"", | 66 | L"", |
67 | r2, | 67 | r2, |
68 | true, this, -1); | 68 | true, this, -1); |
69 | AttribEditBox->grab(); | 69 | AttribEditBox->grab(); |
70 | AttribEditBox->setSubElement(true); | 70 | AttribEditBox->setSubElement(true); |
71 | AttribEditBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); | 71 | AttribEditBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); |
72 | } | 72 | } |
73 | 73 | ||
74 | virtual ~CGUIColorAttribute() | 74 | virtual ~CGUIColorAttribute() |
75 | { | 75 | { |
76 | if (AttribSliderA) | 76 | if (AttribSliderA) |
77 | AttribSliderA->drop(); | 77 | AttribSliderA->drop(); |
78 | if (AttribSliderR) | 78 | if (AttribSliderR) |
79 | AttribSliderR->drop(); | 79 | AttribSliderR->drop(); |
80 | if (AttribSliderG) | 80 | if (AttribSliderG) |
81 | AttribSliderG->drop(); | 81 | AttribSliderG->drop(); |
82 | if (AttribSliderB) | 82 | if (AttribSliderB) |
83 | AttribSliderB->drop(); | 83 | AttribSliderB->drop(); |
84 | if (AttribEditBox) | 84 | if (AttribEditBox) |
85 | AttribEditBox->drop(); | 85 | AttribEditBox->drop(); |
86 | if (AttribColor) | 86 | if (AttribColor) |
87 | AttribColor->drop(); | 87 | AttribColor->drop(); |
88 | } | 88 | } |
89 | 89 | ||
90 | virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex) | 90 | virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex) |
91 | { | 91 | { |
92 | video::SColor col = attribs->getAttributeAsColor(attribIndex); | 92 | video::SColor col = attribs->getAttributeAsColor(attribIndex); |
93 | 93 | ||
94 | AttribSliderA->setPos(col.getAlpha()); | 94 | AttribSliderA->setPos(col.getAlpha()); |
95 | AttribSliderR->setPos(col.getRed()); | 95 | AttribSliderR->setPos(col.getRed()); |
96 | AttribSliderG->setPos(col.getGreen()); | 96 | AttribSliderG->setPos(col.getGreen()); |
97 | AttribSliderB->setPos(col.getBlue()); | 97 | AttribSliderB->setPos(col.getBlue()); |
98 | AttribEditBox->setText( attribs->getAttributeAsStringW(attribIndex).c_str() ); | 98 | AttribEditBox->setText( attribs->getAttributeAsStringW(attribIndex).c_str() ); |
99 | AttribColor->setBackgroundColor(col); | 99 | AttribColor->setBackgroundColor(col); |
100 | 100 | ||
101 | CGUIAttribute::setAttrib(attribs, attribIndex); | 101 | CGUIAttribute::setAttrib(attribs, attribIndex); |
102 | } | 102 | } |
103 | 103 | ||
104 | virtual bool OnEvent(const SEvent &e) | 104 | virtual bool OnEvent(const SEvent &e) |
105 | { | 105 | { |
106 | switch (e.EventType) | 106 | switch (e.EventType) |
107 | { | 107 | { |
108 | 108 | ||
109 | case EET_GUI_EVENT: | 109 | case EET_GUI_EVENT: |
110 | switch (e.GUIEvent.EventType) | 110 | switch (e.GUIEvent.EventType) |
111 | { | 111 | { |
112 | case EGET_EDITBOX_ENTER: | 112 | case EGET_EDITBOX_ENTER: |
113 | case EGET_ELEMENT_FOCUS_LOST: | 113 | case EGET_ELEMENT_FOCUS_LOST: |
114 | if (e.GUIEvent.Caller == AttribEditBox) | 114 | if (e.GUIEvent.Caller == AttribEditBox) |
115 | { | 115 | { |
116 | // update scrollbars from textbox | 116 | // update scrollbars from textbox |
117 | Attribs->setAttribute(Index, AttribEditBox->getText()); | 117 | Attribs->setAttribute(Index, AttribEditBox->getText()); |
118 | video::SColor col = Attribs->getAttributeAsColor(Index); | 118 | video::SColor col = Attribs->getAttributeAsColor(Index); |
119 | AttribSliderA->setPos(col.getAlpha()); | 119 | AttribSliderA->setPos(col.getAlpha()); |
120 | AttribSliderR->setPos(col.getRed()); | 120 | AttribSliderR->setPos(col.getRed()); |
121 | AttribSliderG->setPos(col.getGreen()); | 121 | AttribSliderG->setPos(col.getGreen()); |
122 | AttribSliderB->setPos(col.getBlue()); | 122 | AttribSliderB->setPos(col.getBlue()); |
123 | // update colour | 123 | // update colour |
124 | AttribColor->setBackgroundColor(col); | 124 | AttribColor->setBackgroundColor(col); |
125 | } | 125 | } |
126 | break; | 126 | break; |
127 | case EGET_SCROLL_BAR_CHANGED: | 127 | case EGET_SCROLL_BAR_CHANGED: |
128 | { | 128 | { |
129 | // update editbox from scrollbars | 129 | // update editbox from scrollbars |
130 | video::SColor col( AttribSliderA->getPos(), AttribSliderR->getPos(), | 130 | video::SColor col( AttribSliderA->getPos(), AttribSliderR->getPos(), |
131 | AttribSliderG->getPos(), AttribSliderB->getPos()); | 131 | AttribSliderG->getPos(), AttribSliderB->getPos()); |
132 | 132 | ||
133 | Attribs->setAttribute(Index, col); | 133 | Attribs->setAttribute(Index, col); |
134 | AttribEditBox->setText( Attribs->getAttributeAsStringW(Index).c_str()); | 134 | AttribEditBox->setText( Attribs->getAttributeAsStringW(Index).c_str()); |
135 | // update colour | 135 | // update colour |
136 | AttribColor->setBackgroundColor(col); | 136 | AttribColor->setBackgroundColor(col); |
137 | } | 137 | } |
138 | return updateAttrib(); | 138 | return updateAttrib(); |
139 | default: | 139 | default: |
140 | break; | 140 | break; |
141 | } | 141 | } |
142 | break; | 142 | break; |
143 | default: | 143 | default: |
144 | break; | 144 | break; |
145 | } | 145 | } |
146 | return CGUIAttribute::OnEvent(e); | 146 | return CGUIAttribute::OnEvent(e); |
147 | } | 147 | } |
148 | 148 | ||
149 | // save the attribute and possibly post the event to its parent | 149 | // save the attribute and possibly post the event to its parent |
150 | virtual bool updateAttrib(bool sendEvent=true) | 150 | virtual bool updateAttrib(bool sendEvent=true) |
151 | { | 151 | { |
152 | if (!Attribs) | 152 | if (!Attribs) |
153 | return true; | 153 | return true; |
154 | 154 | ||
155 | Attribs->setAttribute(Index, AttribEditBox->getText()); | 155 | Attribs->setAttribute(Index, AttribEditBox->getText()); |
156 | AttribEditBox->setText(Attribs->getAttributeAsStringW(Index).c_str()); | 156 | AttribEditBox->setText(Attribs->getAttributeAsStringW(Index).c_str()); |
157 | return CGUIAttribute::updateAttrib(sendEvent); | 157 | return CGUIAttribute::updateAttrib(sendEvent); |
158 | } | 158 | } |
159 | 159 | ||
160 | //! Returns the type name of the gui element. | 160 | //! Returns the type name of the gui element. |
161 | virtual const c8* getTypeName() const | 161 | virtual const c8* getTypeName() const |
162 | { | 162 | { |
163 | return GUIEditElementTypeNames[EGUIEDIT_COLORATTRIBUTE]; | 163 | return GUIEditElementTypeNames[EGUIEDIT_COLORATTRIBUTE]; |
164 | } | 164 | } |
165 | 165 | ||
166 | private: | 166 | private: |
167 | IGUIScrollBar* AttribSliderA; | 167 | IGUIScrollBar* AttribSliderA; |
168 | IGUIScrollBar* AttribSliderR; | 168 | IGUIScrollBar* AttribSliderR; |
169 | IGUIScrollBar* AttribSliderG; | 169 | IGUIScrollBar* AttribSliderG; |
170 | IGUIScrollBar* AttribSliderB; | 170 | IGUIScrollBar* AttribSliderB; |
171 | IGUIEditBox* AttribEditBox; | 171 | IGUIEditBox* AttribEditBox; |
172 | IGUITab* AttribColor; | 172 | IGUITab* AttribColor; |
173 | }; | 173 | }; |
174 | 174 | ||
175 | } // namespace gui | 175 | } // namespace gui |
176 | } // namespace irr | 176 | } // namespace irr |
177 | 177 | ||
178 | #endif | 178 | #endif |
179 | 179 | ||