1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2014 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2010 Winch Gate Property Limited
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "nel/gui/group_editbox_decor.h"
22 #include "nel/gui/view_bitmap.h"
23 #include "nel/gui/view_text.h"
50 for(sint i
= 0; i
< TCOUNT
; ++i
)
52 _Textures
.push_back(new CViewBitmap( CViewBase::TCtorParam()));
58 for(uint i
= 0; i
< _Textures
.size(); ++i
)
65 for(uint i
= 0; i
< _Textures
.size(); ++i
)
67 CViewBitmap
*bm
= _Textures
[i
];
74 for(uint i
= 0; i
< _Textures
.size(); ++i
)
76 CViewBitmap
*bm
= _Textures
[i
];
80 // W and H parameters depend on the sizes of the other textures
81 // Negative sizes mean that the sizes are that much smaller than the parent
83 h
= _Textures
[ TL
]->getHReal() + _Textures
[ BL
]->getHReal();
85 _Textures
[ L
]->setH( h
);
87 h
= _Textures
[ TR
]->getHReal() + _Textures
[ BR
]->getHReal();
89 _Textures
[ R
]->setH( h
);
91 w
= _Textures
[ TL
]->getWReal() + _Textures
[ TR
]->getWReal();
93 _Textures
[ TM
]->setW( w
);
95 w
= _Textures
[ BL
]->getWReal() + _Textures
[ BR
]->getWReal();
97 _Textures
[ BM
]->setW( w
);
99 h
= _Textures
[ TM
]->getHReal() + _Textures
[ BM
]->getHReal();
101 w
= _Textures
[ L
]->getWReal() + _Textures
[ R
]->getWReal();
103 _Textures
[ BG
]->setW( w
);
104 _Textures
[ BG
]->setH( h
);
106 for(uint i
= 0; i
< _Textures
.size(); ++i
)
108 CViewBitmap
*bm
= _Textures
[i
];
113 void setup( CInterfaceGroup
*parent
)
115 for(uint i
= 0; i
< _Textures
.size(); ++i
)
117 CViewBitmap
*bm
= _Textures
[i
];
118 bm
->setParent(parent
);
119 bm
->setParentPos(parent
);
120 bm
->setParentSize(parent
);
121 bm
->setEditorSelectable(false);
124 _Textures
[ TL
]->setPosRef( Hotspot_TL
);
125 _Textures
[ TL
]->setParentPosRef( Hotspot_TL
);
127 _Textures
[ TM
]->setPosRef( Hotspot_TM
);
128 _Textures
[ TM
]->setParentPosRef( Hotspot_TM
);
129 _Textures
[ TM
]->setScale( true );
130 _Textures
[ TM
]->setSizeRef( "w" );
132 _Textures
[ TR
]->setPosRef( Hotspot_TR
);
133 _Textures
[ TR
]->setParentPosRef( Hotspot_TR
);
135 _Textures
[ BL
]->setPosRef( Hotspot_BL
);
136 _Textures
[ BL
]->setParentPosRef( Hotspot_BL
);
138 _Textures
[ BM
]->setPosRef( Hotspot_BM
);
139 _Textures
[ BM
]->setParentPosRef( Hotspot_BM
);
140 _Textures
[ BM
]->setScale( true );
141 _Textures
[ BM
]->setSizeRef( "w" );
143 _Textures
[ BR
]->setPosRef( Hotspot_BR
);
144 _Textures
[ BR
]->setParentPosRef( Hotspot_BR
);
146 _Textures
[ L
]->setPosRef( Hotspot_ML
);
147 _Textures
[ L
]->setParentPosRef( Hotspot_ML
);
148 _Textures
[ L
]->setScale( true );
149 _Textures
[ L
]->setSizeRef( "h" );
151 _Textures
[ R
]->setPosRef( Hotspot_MR
);
152 _Textures
[ R
]->setParentPosRef( Hotspot_MR
);
153 _Textures
[ R
]->setScale( true );
154 _Textures
[ R
]->setSizeRef( "h" );
156 _Textures
[ BG
]->setPosRef( Hotspot_MM
);
157 _Textures
[ BG
]->setParentPosRef( Hotspot_MM
);
158 _Textures
[ BG
]->setScale( true );
159 _Textures
[ BG
]->setSizeRef( "wh" );
162 std::vector
< CViewBitmap
* > _Textures
;
165 NLMISC_REGISTER_OBJECT( CViewBase
, CGroupEditBoxDecor
, std::string
, "edit_box_decor" );
167 CGroupEditBoxDecor::CGroupEditBoxDecor( const TCtorParam
¶m
) :
168 CGroupEditBox( param
)
170 _Pvt
= new EBDPrivate();
174 getVT()->setSerializable( false );
175 getVT()->setEditorSelectable( false );
178 CGroupEditBoxDecor::~CGroupEditBoxDecor()
184 void CGroupEditBoxDecor::moveBy( sint32 x
, sint32 y
)
186 CInterfaceElement::moveBy( x
, y
);
188 _Pvt
->updateCoords();
191 void CGroupEditBoxDecor::setIdRecurse( const std::string
&newID
)
193 CInterfaceElement::setIdRecurse( newID
);
194 _ViewText
->setIdRecurse( _ViewText
->getShortId() );
197 std::string
CGroupEditBoxDecor::getProperty( const std::string
&name
) const
199 if( name
== "tx_tl" )
201 return _Pvt
->_Textures
[ EBDPrivate::TL
]->getTexture();
204 if( name
== "tx_tm" )
206 return _Pvt
->_Textures
[ EBDPrivate::TM
]->getTexture();
209 if( name
== "tx_tr" )
211 return _Pvt
->_Textures
[ EBDPrivate::TR
]->getTexture();
214 if( name
== "tx_bl" )
216 return _Pvt
->_Textures
[ EBDPrivate::BL
]->getTexture();
219 if( name
== "tx_bm" )
221 return _Pvt
->_Textures
[ EBDPrivate::BM
]->getTexture();
224 if( name
== "tx_br" )
226 return _Pvt
->_Textures
[ EBDPrivate::BR
]->getTexture();
231 return _Pvt
->_Textures
[ EBDPrivate::L
]->getTexture();
236 return _Pvt
->_Textures
[ EBDPrivate::R
]->getTexture();
239 if( name
== "tx_bg" )
241 return _Pvt
->_Textures
[ EBDPrivate::BG
]->getTexture();
244 return CGroupEditBox::getProperty( name
);
247 void CGroupEditBoxDecor::setProperty( const std::string
&name
, const std::string
&value
)
249 if( name
== "tx_tl" )
251 _Pvt
->_Textures
[ EBDPrivate::TL
]->setTexture( value
);
254 if( name
== "tx_tm" )
256 _Pvt
->_Textures
[ EBDPrivate::TM
]->setTexture( value
);
259 if( name
== "tx_tr" )
261 _Pvt
->_Textures
[ EBDPrivate::TR
]->setTexture( value
);
264 if( name
== "tx_bl" )
266 _Pvt
->_Textures
[ EBDPrivate::BL
]->setTexture( value
);
269 if( name
== "tx_bm" )
271 _Pvt
->_Textures
[ EBDPrivate::BM
]->setTexture( value
);
274 if( name
== "tx_br" )
276 _Pvt
->_Textures
[ EBDPrivate::BR
]->setTexture( value
);
281 _Pvt
->_Textures
[ EBDPrivate::L
]->setTexture( value
);
286 _Pvt
->_Textures
[ EBDPrivate::R
]->setTexture( value
);
289 if( name
== "tx_bg" )
291 _Pvt
->_Textures
[ EBDPrivate::BG
]->setTexture( value
);
294 CGroupEditBox::setProperty( name
, value
);
297 xmlNodePtr
CGroupEditBoxDecor::serialize( xmlNodePtr parentNode
, const char *type
) const
299 xmlNodePtr node
= CGroupEditBox::serialize( parentNode
, type
);
303 xmlSetProp( node
, BAD_CAST
"type", BAD_CAST
"edit_box_decor" );
304 xmlSetProp( node
, BAD_CAST
"tx_tl", BAD_CAST _Pvt
->_Textures
[ EBDPrivate::TL
]->getTexture().c_str() );
305 xmlSetProp( node
, BAD_CAST
"tx_tr", BAD_CAST _Pvt
->_Textures
[ EBDPrivate::TR
]->getTexture().c_str() );
306 xmlSetProp( node
, BAD_CAST
"tx_tm", BAD_CAST _Pvt
->_Textures
[ EBDPrivate::TM
]->getTexture().c_str() );
307 xmlSetProp( node
, BAD_CAST
"tx_bl", BAD_CAST _Pvt
->_Textures
[ EBDPrivate::BL
]->getTexture().c_str() );
308 xmlSetProp( node
, BAD_CAST
"tx_bm", BAD_CAST _Pvt
->_Textures
[ EBDPrivate::BM
]->getTexture().c_str() );
309 xmlSetProp( node
, BAD_CAST
"tx_br", BAD_CAST _Pvt
->_Textures
[ EBDPrivate::BR
]->getTexture().c_str() );
310 xmlSetProp( node
, BAD_CAST
"tx_l", BAD_CAST _Pvt
->_Textures
[ EBDPrivate::L
]->getTexture().c_str() );
311 xmlSetProp( node
, BAD_CAST
"tx_r", BAD_CAST _Pvt
->_Textures
[ EBDPrivate::R
]->getTexture().c_str() );
312 xmlSetProp( node
, BAD_CAST
"tx_bg", BAD_CAST _Pvt
->_Textures
[ EBDPrivate::BG
]->getTexture().c_str() );
317 bool CGroupEditBoxDecor::parse( xmlNodePtr cur
, CInterfaceGroup
*parent
)
319 if( !CGroupEditBox::parse( cur
, parent
) )
324 prop
= ( char* ) xmlGetProp( cur
, BAD_CAST
"tx_tl" );
326 _Pvt
->_Textures
[ EBDPrivate::TL
]->setTexture( ( const char* )prop
);
328 prop
= ( char* ) xmlGetProp( cur
, BAD_CAST
"tx_tm" );
330 _Pvt
->_Textures
[ EBDPrivate::TM
]->setTexture( ( const char* )prop
);
332 prop
= ( char* ) xmlGetProp( cur
, BAD_CAST
"tx_tr" );
334 _Pvt
->_Textures
[ EBDPrivate::TR
]->setTexture( ( const char* )prop
);
336 prop
= ( char* ) xmlGetProp( cur
, BAD_CAST
"tx_bl" );
338 _Pvt
->_Textures
[ EBDPrivate::BL
]->setTexture( ( const char* )prop
);
340 prop
= ( char* ) xmlGetProp( cur
, BAD_CAST
"tx_bm" );
342 _Pvt
->_Textures
[ EBDPrivate::BM
]->setTexture( ( const char* )prop
);
344 prop
= ( char* ) xmlGetProp( cur
, BAD_CAST
"tx_br" );
346 _Pvt
->_Textures
[ EBDPrivate::BR
]->setTexture( ( const char* )prop
);
348 prop
= ( char* ) xmlGetProp( cur
, BAD_CAST
"tx_l" );
350 _Pvt
->_Textures
[ EBDPrivate::L
]->setTexture( ( const char* )prop
);
352 prop
= ( char* ) xmlGetProp( cur
, BAD_CAST
"tx_r" );
354 _Pvt
->_Textures
[ EBDPrivate::R
]->setTexture( ( const char* )prop
);
356 prop
= ( char* ) xmlGetProp( cur
, BAD_CAST
"tx_bg" );
358 _Pvt
->_Textures
[ EBDPrivate::BG
]->setTexture( ( const char* )prop
);
360 getVT()->setIdRecurse( "edit_text" );
365 void CGroupEditBoxDecor::draw()
367 CGroupEditBox::draw();
372 void CGroupEditBoxDecor::updateCoords()
374 sint32 tw
= _Pvt
->_Textures
[ EBDPrivate::L
]->getWReal();
375 getVT()->setX( tw
+ 1 );
377 CGroupEditBox::updateCoords();
378 _Pvt
->updateCoords();
381 void CGroupEditBoxDecor::forceLink()