aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureAttribute.h
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureAttribute.h')
-rw-r--r--libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureAttribute.h280
1 files changed, 140 insertions, 140 deletions
diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureAttribute.h b/libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureAttribute.h
index 6a4fef2..bee43a9 100644
--- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureAttribute.h
+++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureAttribute.h
@@ -1,140 +1,140 @@
1#ifndef __C_GUI_TEXTURE_ATTRIBUTE_H_INCLUDED__ 1#ifndef __C_GUI_TEXTURE_ATTRIBUTE_H_INCLUDED__
2#define __C_GUI_TEXTURE_ATTRIBUTE_H_INCLUDED__ 2#define __C_GUI_TEXTURE_ATTRIBUTE_H_INCLUDED__
3 3
4#include "CGUIAttribute.h" 4#include "CGUIAttribute.h"
5#include "IGUIEditBox.h" 5#include "IGUIEditBox.h"
6#include "IGUIImage.h" 6#include "IGUIImage.h"
7#include "IGUIButton.h" 7#include "IGUIButton.h"
8#include "EGUIEditTypes.h" 8#include "EGUIEditTypes.h"
9 9
10namespace irr 10namespace irr
11{ 11{
12namespace gui 12namespace gui
13{ 13{
14 14
15 class CGUITextureAttribute : public CGUIAttribute 15 class CGUITextureAttribute : public CGUIAttribute
16 { 16 {
17 public: 17 public:
18 // 18 //
19 CGUITextureAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) : 19 CGUITextureAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) :
20 CGUIAttribute(environment, parent, myParentID), 20 CGUIAttribute(environment, parent, myParentID),
21 AttribEditBox(0), AttribImage(0), AttribButton(0) 21 AttribEditBox(0), AttribImage(0), AttribButton(0)
22 { 22 {
23 IGUISkin* skin = Environment->getSkin(); 23 IGUISkin* skin = Environment->getSkin();
24 24
25 core::rect<s32> r = getAbsolutePosition(); 25 core::rect<s32> r = getAbsolutePosition();
26 s32 topy = skin->getFont()->getDimension(L"A").Height + 10; 26 s32 topy = skin->getFont()->getDimension(L"A").Height + 10;
27 s32 h = skin->getFont()->getDimension(L"A").Height + 5; 27 s32 h = skin->getFont()->getDimension(L"A").Height + 5;
28 28
29 AttribImage = environment->addImage(0, core::position2di(0, topy), false, this); 29 AttribImage = environment->addImage(0, core::position2di(0, topy), false, this);
30 AttribImage->setRelativePosition( core::rect<s32>(0,topy, r.getWidth() - 5, 100+topy)); 30 AttribImage->setRelativePosition( core::rect<s32>(0,topy, r.getWidth() - 5, 100+topy));
31 AttribImage->grab(); 31 AttribImage->grab();
32 AttribImage->setSubElement(true); 32 AttribImage->setSubElement(true);
33 AttribImage->setScaleImage(true); 33 AttribImage->setScaleImage(true);
34 AttribImage->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); 34 AttribImage->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
35 35
36 topy += 105; 36 topy += 105;
37 37
38 core::rect<s32> r2(0, topy, r.getWidth() - 15 - skin->getSize(EGDS_CHECK_BOX_WIDTH), topy + h); 38 core::rect<s32> r2(0, topy, r.getWidth() - 15 - skin->getSize(EGDS_CHECK_BOX_WIDTH), topy + h);
39 core::rect<s32> br(r.getWidth() - 10 - skin->getSize(EGDS_CHECK_BOX_WIDTH), topy, r.getWidth(), topy + h); 39 core::rect<s32> br(r.getWidth() - 10 - skin->getSize(EGDS_CHECK_BOX_WIDTH), topy, r.getWidth(), topy + h);
40 40
41 AttribEditBox = environment->addEditBox(0, r2, true, this, -1); 41 AttribEditBox = environment->addEditBox(0, r2, true, this, -1);
42 AttribEditBox->grab(); 42 AttribEditBox->grab();
43 AttribEditBox->setSubElement(true); 43 AttribEditBox->setSubElement(true);
44 AttribEditBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); 44 AttribEditBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
45 45
46 AttribButton = environment->addButton(br, this, -1, L"..."); 46 AttribButton = environment->addButton(br, this, -1, L"...");
47 AttribButton->grab(); 47 AttribButton->grab();
48 AttribButton->setSubElement(true); 48 AttribButton->setSubElement(true);
49 AttribButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); 49 AttribButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
50 //AttribButton->setSpriteBank(skin->getSpriteBank()); 50 //AttribButton->setSpriteBank(skin->getSpriteBank());
51 //AttribButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_FILE), skin->getColor(EGDC_WINDOW_SYMBOL)); 51 //AttribButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_FILE), skin->getColor(EGDC_WINDOW_SYMBOL));
52 //AttribButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_FILE), skin->getColor(EGDC_WINDOW_SYMBOL), true); 52 //AttribButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_FILE), skin->getColor(EGDC_WINDOW_SYMBOL), true);
53 } 53 }
54 54
55 virtual ~CGUITextureAttribute() 55 virtual ~CGUITextureAttribute()
56 { 56 {
57 if (AttribEditBox) 57 if (AttribEditBox)
58 AttribEditBox->drop(); 58 AttribEditBox->drop();
59 if (AttribImage) 59 if (AttribImage)
60 AttribImage->drop(); 60 AttribImage->drop();
61 if (AttribButton) 61 if (AttribButton)
62 AttribButton->drop(); 62 AttribButton->drop();
63 } 63 }
64 64
65 virtual bool OnEvent(const SEvent &e) 65 virtual bool OnEvent(const SEvent &e)
66 { 66 {
67 67
68 if (IsEnabled) 68 if (IsEnabled)
69 { 69 {
70 switch (e.EventType) 70 switch (e.EventType)
71 { 71 {
72 case EET_GUI_EVENT: 72 case EET_GUI_EVENT:
73 switch (e.GUIEvent.EventType) 73 switch (e.GUIEvent.EventType)
74 { 74 {
75 case EGET_BUTTON_CLICKED: 75 case EGET_BUTTON_CLICKED:
76 // button click: open file dialog 76 // button click: open file dialog
77 if (e.GUIEvent.Caller == AttribButton) 77 if (e.GUIEvent.Caller == AttribButton)
78 { 78 {
79 //Environment->addGUIElement("textureBrowser", Environment->getRootGUIElement()); 79 //Environment->addGUIElement("textureBrowser", Environment->getRootGUIElement());
80 return true; 80 return true;
81 } 81 }
82 break; 82 break;
83 case EGET_FILE_SELECTED: 83 case EGET_FILE_SELECTED:
84 // file selected: change editbox value and set event 84 // file selected: change editbox value and set event
85 85
86 return true; 86 return true;
87 case EGET_FILE_CHOOSE_DIALOG_CANCELLED: 87 case EGET_FILE_CHOOSE_DIALOG_CANCELLED:
88 88
89 return true; 89 return true;
90 default: 90 default:
91 break; 91 break;
92 } 92 }
93 break; 93 break;
94 case EET_KEY_INPUT_EVENT: 94 case EET_KEY_INPUT_EVENT:
95 return true; 95 return true;
96 default: 96 default:
97 break; 97 break;
98 } 98 }
99 } 99 }
100 return CGUIAttribute::OnEvent(e); 100 return CGUIAttribute::OnEvent(e);
101 } 101 }
102 102
103 virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex) 103 virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex)
104 { 104 {
105 AttribEditBox->setText(attribs->getAttributeAsStringW(attribIndex).c_str()); 105 AttribEditBox->setText(attribs->getAttributeAsStringW(attribIndex).c_str());
106 AttribImage->setImage(attribs->getAttributeAsTexture(Index)); 106 AttribImage->setImage(attribs->getAttributeAsTexture(Index));
107 107
108 CGUIAttribute::setAttrib(attribs, attribIndex); 108 CGUIAttribute::setAttrib(attribs, attribIndex);
109 } 109 }
110 110
111 //! save the attribute and possibly post the event to its parent 111 //! save the attribute and possibly post the event to its parent
112 virtual bool updateAttrib(bool sendEvent=true) 112 virtual bool updateAttrib(bool sendEvent=true)
113 { 113 {
114 if (!Attribs) 114 if (!Attribs)
115 return true; 115 return true;
116 116
117 Attribs->setAttribute(Index, AttribEditBox->getText()); 117 Attribs->setAttribute(Index, AttribEditBox->getText());
118 core::stringw tmp = Attribs->getAttributeAsStringW(Index); 118 core::stringw tmp = Attribs->getAttributeAsStringW(Index);
119 AttribEditBox->setText(Attribs->getAttributeAsStringW(Index).c_str()); 119 AttribEditBox->setText(Attribs->getAttributeAsStringW(Index).c_str());
120 AttribImage->setImage(Attribs->getAttributeAsTexture(Index)); 120 AttribImage->setImage(Attribs->getAttributeAsTexture(Index));
121 121
122 return CGUIAttribute::updateAttrib(sendEvent); 122 return CGUIAttribute::updateAttrib(sendEvent);
123 } 123 }
124 124
125 //! Returns the type name of the gui element. 125 //! Returns the type name of the gui element.
126 virtual const c8* getTypeName() const 126 virtual const c8* getTypeName() const
127 { 127 {
128 return GUIEditElementTypeNames[EGUIEDIT_TEXTUREATTRIBUTE]; 128 return GUIEditElementTypeNames[EGUIEDIT_TEXTUREATTRIBUTE];
129 } 129 }
130 130
131 private: 131 private:
132 IGUIEditBox* AttribEditBox; 132 IGUIEditBox* AttribEditBox;
133 IGUIImage* AttribImage; 133 IGUIImage* AttribImage;
134 IGUIButton* AttribButton; 134 IGUIButton* AttribButton;
135 }; 135 };
136 136
137} // namespace gui 137} // namespace gui
138} // namespace irr 138} // namespace irr
139 139
140#endif 140#endif