]> git.sesse.net Git - vlc/blob - modules/gui/skins2/parser/builder.cpp
skins2: implement a new 'focus' attribute for text control
[vlc] / modules / gui / skins2 / parser / builder.cpp
1 /*****************************************************************************
2  * builder.cpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teulière <ipkiss@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #include "builder.hpp"
26 #include "builder_data.hpp"
27 #include "interpreter.hpp"
28 #include "skin_parser.hpp"
29 #include "../src/file_bitmap.hpp"
30 #include "../src/os_factory.hpp"
31 #include "../src/generic_bitmap.hpp"
32 #include "../src/top_window.hpp"
33 #include "../src/fsc_window.hpp"
34 #include "../src/anchor.hpp"
35 #include "../src/bitmap_font.hpp"
36 #include "../src/ft2_font.hpp"
37 #include "../src/ini_file.hpp"
38 #include "../src/generic_layout.hpp"
39 #include "../src/popup.hpp"
40 #include "../src/theme.hpp"
41 #include "../src/window_manager.hpp"
42 #include "../src/vout_manager.hpp"
43 #include "../commands/cmd_generic.hpp"
44 #include "../controls/ctrl_button.hpp"
45 #include "../controls/ctrl_checkbox.hpp"
46 #include "../controls/ctrl_image.hpp"
47 #include "../controls/ctrl_list.hpp"
48 #include "../controls/ctrl_move.hpp"
49 #include "../controls/ctrl_resize.hpp"
50 #include "../controls/ctrl_slider.hpp"
51 #include "../controls/ctrl_radialslider.hpp"
52 #include "../controls/ctrl_text.hpp"
53 #include "../controls/ctrl_tree.hpp"
54 #include "../controls/ctrl_video.hpp"
55 #include "../utils/bezier.hpp"
56 #include "../utils/position.hpp"
57 #include "../utils/var_bool.hpp"
58 #include "../utils/var_text.hpp"
59
60 #include <vlc_image.h>
61 #include <fstream>
62
63
64 Builder::Builder( intf_thread_t *pIntf, const BuilderData &rData,
65                   const string &rPath ):
66     SkinObject( pIntf ), m_rData( rData ), m_path( rPath ), m_pTheme( NULL )
67 {
68     m_pImageHandler = image_HandlerCreate( pIntf );
69 }
70
71 Builder::~Builder()
72 {
73     if( m_pImageHandler ) image_HandlerDelete( m_pImageHandler );
74 }
75
76 CmdGeneric *Builder::parseAction( const string &rAction )
77 {
78     return Interpreter::instance( getIntf() )->parseAction( rAction, m_pTheme );
79 }
80
81 template<class T> inline
82 void Builder::add_objects(const std::list<T> &list,
83                           void (Builder::*addfn)(const T &))
84 {
85     typename std::list<T>::const_iterator i;
86     for( i = list.begin(); i != list.end(); ++i )
87         (this->*addfn)( *i );
88 }
89
90 Theme *Builder::build()
91 {
92 #define ADD_OBJECTS( type ) \
93     add_objects(m_rData.m_list##type,&Builder::add##type)
94
95     m_pTheme = new (std::nothrow) Theme( getIntf() );
96     if( m_pTheme == NULL )
97         return NULL;
98
99     // Create everything from the data in the XML
100     ADD_OBJECTS( Theme );
101     ADD_OBJECTS( IniFile );
102     ADD_OBJECTS( Bitmap );
103     ADD_OBJECTS( SubBitmap );
104     ADD_OBJECTS( BitmapFont );
105     ADD_OBJECTS( Font );
106     ADD_OBJECTS( Window );
107     // XXX: PopupMenus are created after the windows, so that the Win32Factory
108     // (at least) can give a valid window handle to the OSPopup objects
109     ADD_OBJECTS( PopupMenu );
110     ADD_OBJECTS( Layout );
111     ADD_OBJECTS( Panel );
112     ADD_OBJECTS( Anchor );
113     ADD_OBJECTS( Button );
114     ADD_OBJECTS( Checkbox );
115     ADD_OBJECTS( Image );
116     ADD_OBJECTS( Text );
117     ADD_OBJECTS( RadialSlider );
118     ADD_OBJECTS( Slider );
119     ADD_OBJECTS( List );
120     ADD_OBJECTS( Tree );
121     ADD_OBJECTS( Video );
122     // MenuItems must be created after all the rest, so that the IDs of the
123     // other elements exist and can be parsed in the actions
124     ADD_OBJECTS( MenuItem );
125     ADD_OBJECTS( MenuSeparator );
126
127     return m_pTheme;
128
129 #undef  ADD_OBJECTS
130 }
131
132
133 // Macro to get a bitmap by its ID in the builder
134 #define GET_BMP( pBmp, id ) \
135     if( id != "none" ) \
136     { \
137         pBmp = m_pTheme->getBitmapById(id); \
138         if( pBmp == NULL ) \
139         { \
140             msg_Err( getIntf(), "unknown bitmap id: %s", id.c_str() ); \
141             return; \
142         } \
143     }
144
145
146 // Macro to get the parent box of a control, given the panel ID
147 #define GET_BOX( pRect, id, pLayout ) \
148     if( id == "none" ) \
149         pRect = &pLayout->getRect(); \
150     else \
151     { \
152         const Position *pParent = \
153             m_pTheme->getPositionById( rData.m_panelId ); \
154         if( pParent == NULL ) \
155         { \
156             msg_Err( getIntf(), "parent panel could not be found: %s", \
157                      rData.m_panelId.c_str() ); \
158             return; \
159         } \
160         pRect = pParent; \
161     }
162
163
164 void Builder::addTheme( const BuilderData::Theme &rData )
165 {
166     WindowManager &rManager = m_pTheme->getWindowManager();
167     rManager.setMagnetValue( rData.m_magnet );
168     rManager.setAlphaValue( rData.m_alpha );
169     rManager.setMoveAlphaValue( rData.m_moveAlpha );
170     GenericFont *pFont = getFont( rData.m_tooltipfont );
171     if( pFont )
172     {
173         rManager.createTooltip( *pFont );
174     }
175     else
176     {
177         msg_Warn( getIntf(), "invalid tooltip font: %s",
178                   rData.m_tooltipfont.c_str() );
179     }
180 }
181
182
183 void Builder::addIniFile( const BuilderData::IniFile &rData )
184 {
185     // Parse the INI file
186     string full_path = getFilePath( rData.m_file );
187     if( !full_path.size() )
188         return;
189
190     IniFile iniFile( getIntf(), rData.m_id, full_path );
191     iniFile.parseFile();
192 }
193
194
195 void Builder::addBitmap( const BuilderData::Bitmap &rData )
196 {
197     string full_path = getFilePath( rData.m_fileName );
198     if( !full_path.size() )
199         return;
200
201     GenericBitmap *pBmp =
202         new FileBitmap( getIntf(), m_pImageHandler,
203                         full_path, rData.m_alphaColor,
204                         rData.m_nbFrames, rData.m_fps, rData.m_nbLoops );
205     if( !pBmp->getData() )
206     {
207         // Invalid bitmap
208         delete pBmp;
209         return;
210     }
211     m_pTheme->m_bitmaps[rData.m_id] = GenericBitmapPtr( pBmp );
212 }
213
214
215 void Builder::addSubBitmap( const BuilderData::SubBitmap &rData )
216 {
217     if( m_pTheme->m_bitmaps.find( rData.m_id ) != m_pTheme->m_bitmaps.end() )
218     {
219         msg_Dbg( getIntf(), "bitmap %s already exists", rData.m_id.c_str() );
220         return;
221     }
222
223     // Get the parent bitmap
224     GenericBitmap *pParentBmp = NULL;
225     GET_BMP( pParentBmp, rData.m_parent );
226
227     // Copy a region of the parent bitmap to the new one
228     BitmapImpl *pBmp =
229         new BitmapImpl( getIntf(), rData.m_width, rData.m_height,
230                         rData.m_nbFrames, rData.m_fps, rData.m_nbLoops );
231     bool res = pBmp->drawBitmap( *pParentBmp, rData.m_x, rData.m_y, 0, 0,
232                                  rData.m_width, rData.m_height );
233     if( !res )
234     {
235         // Invalid sub-bitmap
236         delete pBmp;
237         msg_Warn( getIntf(), "sub-bitmap %s ignored", rData.m_id.c_str() );
238         return;
239     }
240     m_pTheme->m_bitmaps[rData.m_id] = GenericBitmapPtr( pBmp );
241 }
242
243
244 void Builder::addBitmapFont( const BuilderData::BitmapFont &rData )
245 {
246     if( m_pTheme->m_fonts.find( rData.m_id ) != m_pTheme->m_fonts.end() )
247     {
248         msg_Dbg( getIntf(), "font %s already exists", rData.m_id.c_str() );
249         return;
250     }
251
252     string full_path = getFilePath( rData.m_file );
253     if( !full_path.size() )
254         return;
255
256     GenericBitmap *pBmp =
257         new FileBitmap( getIntf(), m_pImageHandler, full_path, 0 );
258     if( !pBmp->getData() )
259     {
260         // Invalid bitmap
261         delete pBmp;
262         return;
263     }
264
265     m_pTheme->m_bitmaps[rData.m_id] = GenericBitmapPtr( pBmp );
266
267     GenericFont *pFont = new BitmapFont( getIntf(), *pBmp, rData.m_type );
268     if( pFont->init() )
269     {
270         m_pTheme->m_fonts[rData.m_id] = GenericFontPtr( pFont );
271     }
272     else
273     {
274         delete pFont;
275     }
276 }
277
278
279 void Builder::addFont( const BuilderData::Font &rData )
280 {
281     string full_path = getFilePath( rData.m_fontFile );
282     if( !full_path.size() )
283         return;
284
285     // Try to load the font from the theme directory
286     GenericFont *pFont = new FT2Font( getIntf(), full_path, rData.m_size );
287     if( pFont->init() )
288     {
289         m_pTheme->m_fonts[rData.m_id] = GenericFontPtr( pFont );
290     }
291     else
292     {
293         delete pFont;
294
295         // Font not found; try in the resource path
296         OSFactory *pOSFactory = OSFactory::instance( getIntf() );
297         const list<string> &resPath = pOSFactory->getResourcePath();
298         const string &sep = pOSFactory->getDirSeparator();
299
300         list<string>::const_iterator it;
301         for( it = resPath.begin(); it != resPath.end(); ++it )
302         {
303             string path = (*it) + sep + "fonts" + sep + rData.m_fontFile;
304             pFont = new FT2Font( getIntf(), path, rData.m_size );
305             if( pFont->init() )
306             {
307                 // Font loaded successfully
308                 m_pTheme->m_fonts[rData.m_id] = GenericFontPtr( pFont );
309                 break;
310             }
311             else
312             {
313                 delete pFont;
314             }
315         }
316     }
317 }
318
319
320 void Builder::addPopupMenu( const BuilderData::PopupMenu &rData )
321 {
322     Popup *pPopup = new Popup( getIntf(), m_pTheme->getWindowManager() );
323
324     m_pTheme->m_popups[rData.m_id] = PopupPtr( pPopup );
325 }
326
327
328 void Builder::addMenuItem( const BuilderData::MenuItem &rData )
329 {
330     Popup *pPopup = m_pTheme->getPopupById( rData.m_popupId );
331     if( pPopup == NULL )
332     {
333         msg_Err( getIntf(), "unknown popup id: %s", rData.m_popupId.c_str() );
334         return;
335     }
336
337     CmdGeneric *pCommand = parseAction( rData.m_action );
338     if( pCommand == NULL )
339     {
340         msg_Err( getIntf(), "invalid action: %s", rData.m_action.c_str() );
341         return;
342     }
343
344     pPopup->addItem( rData.m_label, *pCommand, rData.m_pos );
345 }
346
347
348 void Builder::addMenuSeparator( const BuilderData::MenuSeparator &rData )
349 {
350     Popup *pPopup = m_pTheme->getPopupById( rData.m_popupId );
351     if( pPopup == NULL )
352     {
353         msg_Err( getIntf(), "unknown popup id: %s", rData.m_popupId.c_str() );
354         return;
355     }
356
357     pPopup->addSeparator( rData.m_pos );
358 }
359
360
361 void Builder::addWindow( const BuilderData::Window &rData )
362 {
363     TopWindow *pWin;
364     if( rData.m_id == "fullscreenController" )
365     {
366         pWin = new FscWindow( getIntf(), rData.m_xPos, rData.m_yPos,
367                        m_pTheme->getWindowManager(),
368                        rData.m_dragDrop, rData.m_playOnDrop,
369                        rData.m_visible );
370     }
371     else
372     {
373         pWin = new TopWindow( getIntf(), rData.m_xPos, rData.m_yPos,
374                        m_pTheme->getWindowManager(),
375                        rData.m_dragDrop, rData.m_playOnDrop,
376                        rData.m_visible );
377     }
378     m_pTheme->m_windows[rData.m_id] = TopWindowPtr( pWin );
379 }
380
381
382 void Builder::addLayout( const BuilderData::Layout &rData )
383 {
384     TopWindow *pWin = m_pTheme->getWindowById( rData.m_windowId );
385     if( pWin == NULL )
386     {
387         msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
388         return;
389     }
390
391     int minWidth = rData.m_minWidth != -1 ? rData.m_minWidth : rData.m_width;
392     int maxWidth = rData.m_maxWidth != -1 ? rData.m_maxWidth : rData.m_width;
393     int minHeight = rData.m_minHeight != -1 ? rData.m_minHeight :
394                     rData.m_height;
395     int maxHeight = rData.m_maxHeight != -1 ? rData.m_maxHeight :
396                     rData.m_height;
397     GenericLayout *pLayout = new GenericLayout( getIntf(), rData.m_width,
398                                                 rData.m_height,
399                                                 minWidth, maxWidth, minHeight,
400                                                 maxHeight );
401     m_pTheme->m_layouts[rData.m_id] = GenericLayoutPtr( pLayout );
402
403     // Attach the layout to its window
404     m_pTheme->getWindowManager().addLayout( *pWin, *pLayout );
405 }
406
407
408 void Builder::addAnchor( const BuilderData::Anchor &rData )
409 {
410     GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
411     if( pLayout == NULL )
412     {
413         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
414         return;
415     }
416
417     Bezier *pCurve = getPoints( rData.m_points.c_str() );
418     if( pCurve == NULL )
419     {
420         msg_Err( getIntf(), "invalid format in tag points=\"%s\"",
421                  rData.m_points.c_str() );
422         return;
423     }
424     m_pTheme->m_curves.push_back( BezierPtr( pCurve ) );
425
426     // Compute the position of the anchor
427     const Position pos = makePosition( rData.m_leftTop, rData.m_leftTop,
428                                        rData.m_xPos, rData.m_yPos,
429                                        pCurve->getWidth(),
430                                        pCurve->getHeight(),
431                                        pLayout->getRect() );
432
433     Anchor *pAnc = new Anchor( getIntf(), pos, rData.m_range, rData.m_priority,
434                                *pCurve, *pLayout );
435     pLayout->addAnchor( pAnc );
436 }
437
438
439 void Builder::addButton( const BuilderData::Button &rData )
440 {
441     // Get the bitmaps of the button
442     GenericBitmap *pBmpUp = NULL;
443     GET_BMP( pBmpUp, rData.m_upId );
444
445     GenericBitmap *pBmpDown = pBmpUp;
446     GET_BMP( pBmpDown, rData.m_downId );
447
448     GenericBitmap *pBmpOver = pBmpUp;
449     GET_BMP( pBmpOver, rData.m_overId );
450
451     GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
452     if( pLayout == NULL )
453     {
454         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
455         return;
456     }
457
458     CmdGeneric *pCommand = parseAction( rData.m_actionId );
459     if( pCommand == NULL )
460     {
461         msg_Err( getIntf(), "invalid action: %s", rData.m_actionId.c_str() );
462         return;
463     }
464
465     // Get the visibility variable
466     // XXX check when it is null
467     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
468     VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
469
470     CtrlButton *pButton = new CtrlButton( getIntf(), *pBmpUp, *pBmpOver,
471         *pBmpDown, *pCommand, UString( getIntf(), rData.m_tooltip.c_str() ),
472         UString( getIntf(), rData.m_help.c_str() ), pVisible );
473     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pButton );
474
475     // Compute the position of the control
476     // XXX (we suppose all the images have the same size...)
477     const GenericRect *pRect;
478     GET_BOX( pRect, rData.m_panelId , pLayout);
479     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
480                              rData.m_xPos, rData.m_yPos,
481                              pBmpUp->getWidth(),
482                              pBmpUp->getHeight() / pBmpUp->getNbFrames(),
483                              *pRect, rData.m_xKeepRatio, rData.m_yKeepRatio );
484
485     pLayout->addControl( pButton, pos, rData.m_layer );
486 }
487
488
489 void Builder::addCheckbox( const BuilderData::Checkbox &rData )
490 {
491     // Get the bitmaps of the checkbox
492     GenericBitmap *pBmpUp1 = NULL;
493     GET_BMP( pBmpUp1, rData.m_up1Id );
494
495     GenericBitmap *pBmpDown1 = pBmpUp1;
496     GET_BMP( pBmpDown1, rData.m_down1Id );
497
498     GenericBitmap *pBmpOver1 = pBmpUp1;
499     GET_BMP( pBmpOver1, rData.m_over1Id );
500
501     GenericBitmap *pBmpUp2 = NULL;
502     GET_BMP( pBmpUp2, rData.m_up2Id );
503
504     GenericBitmap *pBmpDown2 = pBmpUp2;
505     GET_BMP( pBmpDown2, rData.m_down2Id );
506
507     GenericBitmap *pBmpOver2 = pBmpUp2;
508     GET_BMP( pBmpOver2, rData.m_over2Id );
509
510     GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
511     if( pLayout == NULL )
512     {
513         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
514         return;
515     }
516
517     CmdGeneric *pCommand1 = parseAction( rData.m_action1 );
518     if( pCommand1 == NULL )
519     {
520         msg_Err( getIntf(), "invalid action: %s", rData.m_action1.c_str() );
521         return;
522     }
523
524     CmdGeneric *pCommand2 = parseAction( rData.m_action2 );
525     if( pCommand2 == NULL )
526     {
527         msg_Err( getIntf(), "invalid action: %s", rData.m_action2.c_str() );
528         return;
529     }
530
531     // Get the state variable
532     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
533     VarBool *pVar = pInterpreter->getVarBool( rData.m_state, m_pTheme );
534     if( pVar == NULL )
535     {
536         // TODO: default state
537         return;
538     }
539
540     // Get the visibility variable
541     // XXX check when it is null
542     VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
543
544     // Create the control
545     CtrlCheckbox *pCheckbox = new CtrlCheckbox( getIntf(), *pBmpUp1,
546         *pBmpOver1, *pBmpDown1, *pBmpUp2, *pBmpOver2, *pBmpDown2, *pCommand1,
547         *pCommand2, UString( getIntf(), rData.m_tooltip1.c_str() ),
548         UString( getIntf(), rData.m_tooltip2.c_str() ), *pVar,
549         UString( getIntf(), rData.m_help.c_str() ), pVisible );
550     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pCheckbox );
551
552     // Compute the position of the control
553     // XXX (we suppose all the images have the same size...)
554     const GenericRect *pRect;
555     GET_BOX( pRect, rData.m_panelId , pLayout);
556     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
557                             rData.m_xPos, rData.m_yPos,
558                             pBmpUp1->getWidth(),
559                             pBmpUp1->getHeight() / pBmpUp1->getNbFrames(),
560                             *pRect, rData.m_xKeepRatio, rData.m_yKeepRatio );
561
562     pLayout->addControl( pCheckbox, pos, rData.m_layer );
563 }
564
565
566 void Builder::addImage( const BuilderData::Image &rData )
567 {
568     GenericBitmap *pBmp = NULL;
569     GET_BMP( pBmp, rData.m_bmpId );
570
571     GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
572     if( pLayout == NULL )
573     {
574         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
575         return;
576     }
577
578     TopWindow *pWindow = m_pTheme->getWindowById( rData.m_windowId );
579     if( pWindow == NULL )
580     {
581         msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
582         return;
583     }
584
585     CmdGeneric *pCommand = parseAction( rData.m_action2Id );
586     if( pCommand == NULL )
587     {
588         msg_Err( getIntf(), "invalid action: %s", rData.m_action2Id.c_str() );
589         return;
590     }
591
592     // Get the visibility variable
593     // XXX check when it is null
594     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
595     VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
596
597     CtrlImage::resize_t resizeMethod =
598         rData.m_resize == "scale"  ? CtrlImage::kScale :
599         rData.m_resize == "mosaic" ? CtrlImage::kMosaic :
600                                      CtrlImage::kScaleAndRatioPreserved;
601     CtrlImage *pImage = new CtrlImage( getIntf(), *pBmp, *pCommand,
602         resizeMethod, UString( getIntf(), rData.m_help.c_str() ), pVisible,
603         rData.m_art );
604     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pImage );
605
606     // Compute the position of the control
607     const GenericRect *pRect;
608     int width = (rData.m_width > 0) ? rData.m_width : pBmp->getWidth();
609     int height = (rData.m_height > 0) ? rData.m_height : pBmp->getHeight();
610     GET_BOX( pRect, rData.m_panelId , pLayout);
611     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
612                                        rData.m_xPos, rData.m_yPos,
613                                        width, height,
614                                        *pRect, rData.m_xKeepRatio,
615                                        rData.m_yKeepRatio );
616
617     if( rData.m_actionId == "move" )
618     {
619         CtrlMove *pMove = new CtrlMove( getIntf(), m_pTheme->getWindowManager(),
620              *pImage, *pWindow, UString( getIntf(), rData.m_help.c_str() ),
621              pVisible );
622         m_pTheme->m_controls[rData.m_id + "_move"] = CtrlGenericPtr( pMove );
623         pLayout->addControl( pMove, pos, rData.m_layer );
624     }
625     else if( rData.m_actionId == "resizeS" )
626     {
627         CtrlResize *pResize = new CtrlResize( getIntf(),
628                 m_pTheme->getWindowManager(), *pImage, *pLayout,
629                 UString( getIntf(), rData.m_help.c_str() ), pVisible,
630                 WindowManager::kResizeS );
631         m_pTheme->m_controls[rData.m_id + "_rsz"] = CtrlGenericPtr( pResize );
632         pLayout->addControl( pResize, pos, rData.m_layer );
633     }
634     else if( rData.m_actionId == "resizeE" )
635     {
636         CtrlResize *pResize = new CtrlResize( getIntf(),
637                 m_pTheme->getWindowManager(), *pImage, *pLayout,
638                 UString( getIntf(), rData.m_help.c_str() ), pVisible,
639                 WindowManager::kResizeE );
640         m_pTheme->m_controls[rData.m_id + "_rsz"] = CtrlGenericPtr( pResize );
641         pLayout->addControl( pResize, pos, rData.m_layer );
642     }
643     else if( rData.m_actionId == "resizeSE" )
644     {
645         CtrlResize *pResize = new CtrlResize( getIntf(),
646                 m_pTheme->getWindowManager(), *pImage, *pLayout,
647                 UString( getIntf(), rData.m_help.c_str() ), pVisible,
648                 WindowManager::kResizeSE );
649         m_pTheme->m_controls[rData.m_id + "_rsz"] = CtrlGenericPtr( pResize );
650         pLayout->addControl( pResize, pos, rData.m_layer );
651     }
652     else
653     {
654         pLayout->addControl( pImage, pos, rData.m_layer );
655     }
656 }
657
658
659 void Builder::addPanel( const BuilderData::Panel &rData )
660 {
661     // This method makes the assumption that the Panels are created in the
662     // order of the XML, because each child Panel expects its parent Panel
663     // in order to be fully created
664
665     GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
666     if( pLayout == NULL )
667     {
668         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
669         return;
670     }
671
672     const GenericRect *pRect;
673     GET_BOX( pRect, rData.m_panelId , pLayout);
674     Position *pPos =
675         new Position( makePosition( rData.m_leftTop, rData.m_rightBottom,
676                                     rData.m_xPos, rData.m_yPos,
677                                     rData.m_width, rData.m_height,
678                                     *pRect, rData.m_xKeepRatio,
679                                     rData.m_yKeepRatio ) );
680     m_pTheme->m_positions[rData.m_id] = PositionPtr( pPos );
681 }
682
683
684 void Builder::addText( const BuilderData::Text &rData )
685 {
686     GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
687     if( pLayout == NULL )
688     {
689         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
690         return;
691     }
692
693     GenericFont *pFont = getFont( rData.m_fontId );
694     if( pFont == NULL )
695     {
696         msg_Err( getIntf(), "unknown font id: %s", rData.m_fontId.c_str() );
697         return;
698     }
699
700     // Convert the scrolling mode
701     CtrlText::Scrolling_t scrolling;
702     if( rData.m_scrolling == "auto" )
703         scrolling = CtrlText::kAutomatic;
704     else if( rData.m_scrolling == "manual" )
705         scrolling = CtrlText::kManual;
706     else if( rData.m_scrolling == "none" )
707         scrolling = CtrlText::kNone;
708     else
709     {
710         msg_Err( getIntf(), "invalid scrolling mode: %s",
711                  rData.m_scrolling.c_str() );
712         return;
713     }
714
715     // Convert the alignment
716     CtrlText::Align_t alignment;
717     if( rData.m_alignment == "left" )
718         alignment = CtrlText::kLeft;
719     else if( rData.m_alignment == "center" || rData.m_alignment == "centre" )
720         alignment = CtrlText::kCenter;
721     else if( rData.m_alignment == "right" )
722         alignment = CtrlText::kRight;
723     else
724     {
725         msg_Err( getIntf(), "invalid alignment: %s",
726                  rData.m_alignment.c_str() );
727         return;
728     }
729
730     // Create a text variable
731     VarText *pVar = new VarText( getIntf() );
732     m_pTheme->m_vars.push_back( VariablePtr( pVar ) );
733
734     // Set the text of the control
735     UString msg( getIntf(), rData.m_text.c_str() );
736     pVar->set( msg );
737
738     // Get the visibility variable
739     // XXX check when it is null
740     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
741     VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
742     VarBool *pFocus = pInterpreter->getVarBool( rData.m_focus, m_pTheme );
743
744     CtrlText *pText = new CtrlText( getIntf(), *pVar, *pFont,
745         UString( getIntf(), rData.m_help.c_str() ), rData.m_color,
746         pVisible, pFocus, scrolling, alignment );
747     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pText );
748
749     int height = pFont->getSize();
750
751     // Compute the position of the control
752     const GenericRect *pRect;
753     GET_BOX( pRect, rData.m_panelId , pLayout);
754     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
755                                        rData.m_xPos, rData.m_yPos,
756                                        rData.m_width, height, *pRect,
757                                        rData.m_xKeepRatio, rData.m_yKeepRatio );
758
759     pLayout->addControl( pText, pos, rData.m_layer );
760
761 }
762
763
764 void Builder::addRadialSlider( const BuilderData::RadialSlider &rData )
765 {
766     // Get the bitmaps of the slider
767     GenericBitmap *pSeq = NULL;
768     GET_BMP( pSeq, rData.m_sequence );
769
770     GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
771     if( pLayout == NULL )
772     {
773         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
774         return;
775     }
776
777     // Get the variable associated to the slider
778     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
779     VarPercent *pVar = pInterpreter->getVarPercent( rData.m_value, m_pTheme );
780     if( pVar == NULL )
781     {
782         msg_Err( getIntf(), "unknown slider value: %s", rData.m_value.c_str() );
783         return;
784     }
785
786     // Get the visibility variable
787     // XXX check when it is null
788     VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
789
790     // Create the control
791     CtrlRadialSlider *pRadial =
792         new CtrlRadialSlider( getIntf(), *pSeq, rData.m_nbImages, *pVar,
793                               rData.m_minAngle, rData.m_maxAngle,
794                               UString( getIntf(), rData.m_help.c_str() ),
795                               pVisible );
796     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pRadial );
797
798     // XXX: resizing is not supported
799     // Compute the position of the control
800     const GenericRect *pRect;
801     GET_BOX( pRect, rData.m_panelId , pLayout);
802     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
803                                        rData.m_xPos, rData.m_yPos,
804                                        pSeq->getWidth(),
805                                        pSeq->getHeight() / rData.m_nbImages,
806                                        *pRect,
807                                        rData.m_xKeepRatio, rData.m_yKeepRatio );
808
809     pLayout->addControl( pRadial, pos, rData.m_layer );
810 }
811
812
813 void Builder::addSlider( const BuilderData::Slider &rData )
814 {
815     // Add the background first, so that we will still have something almost
816     // functional if the cursor cannot be created properly (this happens for
817     // some winamp2 skins, where the images of the cursor are not always
818     // present)
819
820     // Get the bitmaps of the background
821     GenericBitmap *pBgImage = NULL;
822     if( rData.m_imageId != "none" )
823     {
824         GET_BMP( pBgImage, rData.m_imageId );
825     }
826
827     GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
828     if( pLayout == NULL )
829     {
830         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
831         return;
832     }
833
834     Bezier *pCurve = getPoints( rData.m_points.c_str() );
835     if( pCurve == NULL )
836     {
837         msg_Err( getIntf(), "invalid format in tag points=\"%s\"",
838                  rData.m_points.c_str() );
839         return;
840     }
841     m_pTheme->m_curves.push_back( BezierPtr( pCurve ) );
842
843     // Get the visibility variable
844     // XXX check when it is null
845     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
846     VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
847
848     // Get the variable associated to the slider
849     VarPercent *pVar = pInterpreter->getVarPercent( rData.m_value, m_pTheme );
850     if( pVar == NULL )
851     {
852         msg_Err( getIntf(), "unknown slider value: %s", rData.m_value.c_str() );
853         return;
854     }
855
856     // Create the background control
857     CtrlSliderBg *pBackground = new CtrlSliderBg( getIntf(),
858         *pCurve, *pVar, rData.m_thickness, pBgImage, rData.m_nbHoriz,
859         rData.m_nbVert, rData.m_padHoriz, rData.m_padVert,
860         pVisible, UString( getIntf(), rData.m_help.c_str() ) );
861     m_pTheme->m_controls[rData.m_id + "_bg"] = CtrlGenericPtr( pBackground );
862
863     // Compute the position of the control
864     const GenericRect *pRect;
865     GET_BOX( pRect, rData.m_panelId , pLayout);
866     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
867                                        rData.m_xPos, rData.m_yPos,
868                                        pCurve->getWidth(), pCurve->getHeight(),
869                                        *pRect,
870                                        rData.m_xKeepRatio, rData.m_yKeepRatio );
871
872     pLayout->addControl( pBackground, pos, rData.m_layer );
873
874     // Get the bitmaps of the cursor
875     GenericBitmap *pBmpUp = NULL;
876     GET_BMP( pBmpUp, rData.m_upId );
877
878     GenericBitmap *pBmpDown = pBmpUp;
879     GET_BMP( pBmpDown, rData.m_downId );
880
881     GenericBitmap *pBmpOver = pBmpUp;
882     GET_BMP( pBmpOver, rData.m_overId );
883
884     // Create the cursor control
885     CtrlSliderCursor *pCursor = new CtrlSliderCursor( getIntf(), *pBmpUp,
886         *pBmpOver, *pBmpDown, *pCurve, *pVar, pVisible,
887         UString( getIntf(), rData.m_tooltip.c_str() ),
888         UString( getIntf(), rData.m_help.c_str() ) );
889     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pCursor );
890
891     pLayout->addControl( pCursor, pos, rData.m_layer );
892
893     // Associate the cursor to the background
894     pBackground->associateCursor( *pCursor );
895 }
896
897
898 void Builder::addList( const BuilderData::List &rData )
899 {
900     // Get the background bitmap, if any
901     GenericBitmap *pBgBmp = NULL;
902     GET_BMP( pBgBmp, rData.m_bgImageId );
903
904     GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
905     if( pLayout == NULL )
906     {
907         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
908         return;
909     }
910
911     GenericFont *pFont = getFont( rData.m_fontId );
912     if( pFont == NULL )
913     {
914         msg_Err( getIntf(), "unknown font id: %s", rData.m_fontId.c_str() );
915         return;
916     }
917
918     // Get the list variable
919     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
920     VarList *pVar = pInterpreter->getVarList( rData.m_var, m_pTheme );
921     if( pVar == NULL )
922     {
923         msg_Err( getIntf(), "no such list variable: %s", rData.m_var.c_str() );
924         return;
925     }
926
927     // Get the visibility variable
928     // XXX check when it is null
929     VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
930
931     // Get the color values
932     uint32_t fgColor = getColor( rData.m_fgColor );
933     uint32_t playColor = getColor( rData.m_playColor );
934     uint32_t bgColor1 = getColor( rData.m_bgColor1 );
935     uint32_t bgColor2 = getColor( rData.m_bgColor2 );
936     uint32_t selColor = getColor( rData.m_selColor );
937
938     // Create the list control
939     CtrlList *pList = new CtrlList( getIntf(), *pVar, *pFont, pBgBmp,
940        fgColor, playColor, bgColor1, bgColor2, selColor,
941        UString( getIntf(), rData.m_help.c_str() ), pVisible );
942     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pList );
943
944     // Compute the position of the control
945     const GenericRect *pRect;
946     GET_BOX( pRect, rData.m_panelId , pLayout);
947     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
948                                        rData.m_xPos, rData.m_yPos,
949                                        rData.m_width, rData.m_height,
950                                        *pRect,
951                                        rData.m_xKeepRatio, rData.m_yKeepRatio );
952
953     pLayout->addControl( pList, pos, rData.m_layer );
954 }
955
956 void Builder::addTree( const BuilderData::Tree &rData )
957 {
958     // Get the bitmaps, if any
959     GenericBitmap *pBgBmp = NULL;
960     GenericBitmap *pItemBmp = NULL;
961     GenericBitmap *pOpenBmp = NULL;
962     GenericBitmap *pClosedBmp = NULL;
963     GET_BMP( pBgBmp, rData.m_bgImageId );
964     GET_BMP( pItemBmp, rData.m_itemImageId );
965     GET_BMP( pOpenBmp, rData.m_openImageId );
966     GET_BMP( pClosedBmp, rData.m_closedImageId );
967
968     GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
969     if( pLayout == NULL )
970     {
971         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
972         return;
973     }
974
975     GenericFont *pFont = getFont( rData.m_fontId );
976     if( pFont == NULL )
977     {
978         msg_Err( getIntf(), "unknown font id: %s", rData.m_fontId.c_str() );
979         return;
980     }
981
982     // Get the list variable
983     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
984     VarTree *pVar = pInterpreter->getVarTree( rData.m_var, m_pTheme );
985     if( pVar == NULL )
986     {
987         msg_Err( getIntf(), "no such list variable: %s", rData.m_var.c_str() );
988         return;
989     }
990
991     // Get the visibility variable
992     // XXX check when it is null
993     VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
994     VarBool *pFlat = pInterpreter->getVarBool( rData.m_flat, m_pTheme );
995
996     // Get the color values
997     uint32_t fgColor = getColor( rData.m_fgColor );
998     uint32_t playColor = getColor( rData.m_playColor );
999     uint32_t bgColor1 = getColor( rData.m_bgColor1 );
1000     uint32_t bgColor2 = getColor( rData.m_bgColor2 );
1001     uint32_t selColor = getColor( rData.m_selColor );
1002
1003     // Create the list control
1004     CtrlTree *pTree = new CtrlTree( getIntf(), *pVar, *pFont, pBgBmp,
1005        pItemBmp, pOpenBmp, pClosedBmp,
1006        fgColor, playColor, bgColor1, bgColor2, selColor,
1007        UString( getIntf(), rData.m_help.c_str() ), pVisible, pFlat );
1008     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pTree );
1009
1010     // Compute the position of the control
1011     const GenericRect *pRect;
1012     GET_BOX( pRect, rData.m_panelId , pLayout);
1013     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
1014                                        rData.m_xPos, rData.m_yPos,
1015                                        rData.m_width, rData.m_height,
1016                                        *pRect,
1017                                        rData.m_xKeepRatio, rData.m_yKeepRatio );
1018
1019     pLayout->addControl( pTree, pos, rData.m_layer );
1020 }
1021
1022 void Builder::addVideo( const BuilderData::Video &rData )
1023 {
1024     GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
1025     if( pLayout == NULL )
1026     {
1027         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
1028         return;
1029     }
1030
1031     BuilderData::Video Data = rData;
1032     if( Data.m_autoResize )
1033     {
1034         // force autoresize to false if the control is not able to
1035         // freely resize within its container
1036         if( Data.m_xKeepRatio || Data.m_yKeepRatio ||
1037             !( Data.m_leftTop == "lefttop" &&
1038                Data.m_rightBottom == "rightbottom" ) )
1039         {
1040             msg_Err( getIntf(),
1041                 "video: resize policy and autoresize are not compatible" );
1042             Data.m_autoResize = false;
1043         }
1044     }
1045
1046     // Get the visibility variable
1047     // XXX check when it is null
1048     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
1049     VarBool *pVisible = pInterpreter->getVarBool( Data.m_visible, m_pTheme );
1050
1051     CtrlVideo *pVideo = new CtrlVideo( getIntf(), *pLayout,
1052         Data.m_autoResize, UString( getIntf(), Data.m_help.c_str() ),
1053         pVisible );
1054     m_pTheme->m_controls[Data.m_id] = CtrlGenericPtr( pVideo );
1055
1056     // Compute the position of the control
1057     const GenericRect *pRect;
1058     GET_BOX( pRect, rData.m_panelId , pLayout);
1059     const Position pos = makePosition( Data.m_leftTop, Data.m_rightBottom,
1060                                        Data.m_xPos, Data.m_yPos,
1061                                        Data.m_width, Data.m_height,
1062                                        *pRect,
1063                                        Data.m_xKeepRatio, Data.m_yKeepRatio );
1064
1065     pLayout->addControl( pVideo, pos, Data.m_layer );
1066 }
1067
1068
1069 const Position Builder::makePosition( const string &rLeftTop,
1070                                       const string &rRightBottom,
1071                                       int xPos, int yPos, int width,
1072                                       int height, const GenericRect &rRect,
1073                                       bool xKeepRatio, bool yKeepRatio ) const
1074 {
1075     int left = 0, top = 0, right = 0, bottom = 0;
1076     Position::Ref_t refLeftTop = Position::kLeftTop;
1077     Position::Ref_t refRightBottom = Position::kLeftTop;
1078
1079     int boxWidth = rRect.getWidth();
1080     int boxHeight = rRect.getHeight();
1081
1082     // Position of the left top corner
1083     if( rLeftTop == "lefttop" )
1084     {
1085         left = xPos;
1086         top = yPos;
1087         refLeftTop = Position::kLeftTop;
1088     }
1089     else if( rLeftTop == "righttop" )
1090     {
1091         left = xPos - boxWidth + 1;
1092         top = yPos;
1093         refLeftTop = Position::kRightTop;
1094     }
1095     else if( rLeftTop == "leftbottom" )
1096     {
1097         left = xPos;
1098         top = yPos - boxHeight + 1;
1099         refLeftTop = Position::kLeftBottom;
1100     }
1101     else if( rLeftTop == "rightbottom" )
1102     {
1103         left = xPos - boxWidth + 1;
1104         top = yPos - boxHeight + 1;
1105         refLeftTop = Position::kRightBottom;
1106     }
1107
1108     // Position of the right bottom corner
1109     if( rRightBottom == "lefttop" )
1110     {
1111         right = xPos + width - 1;
1112         bottom = yPos + height - 1;
1113         refRightBottom = Position::kLeftTop;
1114     }
1115     else if( rRightBottom == "righttop" )
1116     {
1117         right = xPos + width - boxWidth;
1118         bottom = yPos + height - 1;
1119         refRightBottom = Position::kRightTop;
1120     }
1121     else if( rRightBottom == "leftbottom" )
1122     {
1123         right = xPos + width - 1;
1124         bottom = yPos + height - boxHeight;
1125         refRightBottom = Position::kLeftBottom;
1126     }
1127     else if( rRightBottom == "rightbottom" )
1128     {
1129         right = xPos + width - boxWidth;
1130         bottom = yPos + height - boxHeight;
1131         refRightBottom = Position::kRightBottom;
1132     }
1133
1134     // In "keep ratio" mode, overwrite the previously computed values with the
1135     // actual ones
1136     // XXX: this coupling between makePosition and the Position class should
1137     // be reduced...
1138     if( xKeepRatio )
1139     {
1140         left = xPos;
1141         right = xPos + width;
1142     }
1143     if( yKeepRatio )
1144     {
1145         top = yPos;
1146         bottom = yPos + height;
1147     }
1148
1149     return Position( left, top, right, bottom, rRect, refLeftTop,
1150                      refRightBottom, xKeepRatio, yKeepRatio );
1151 }
1152
1153
1154 GenericFont *Builder::getFont( const string &fontId )
1155 {
1156     GenericFont *pFont = m_pTheme->getFontById(fontId);
1157     if( !pFont && fontId == "defaultfont" )
1158     {
1159         // Get the resource path and try to load the default font
1160         OSFactory *pOSFactory = OSFactory::instance( getIntf() );
1161         const list<string> &resPath = pOSFactory->getResourcePath();
1162         const string &sep = pOSFactory->getDirSeparator();
1163
1164         list<string>::const_iterator it;
1165         for( it = resPath.begin(); it != resPath.end(); ++it )
1166         {
1167             string path = (*it) + sep + "fonts" + sep + "FreeSans.ttf";
1168             pFont = new FT2Font( getIntf(), path, 12 );
1169             if( pFont->init() )
1170             {
1171                 // Font loaded successfully
1172                 m_pTheme->m_fonts["defaultfont"] = GenericFontPtr( pFont );
1173                 break;
1174             }
1175             else
1176             {
1177                 delete pFont;
1178                 pFont = NULL;
1179             }
1180         }
1181         if( !pFont )
1182         {
1183             msg_Err( getIntf(), "failed to open the default font" );
1184         }
1185     }
1186     return pFont;
1187 }
1188
1189
1190 string Builder::getFilePath( const string &rFileName ) const
1191 {
1192     OSFactory *pFactory = OSFactory::instance( getIntf() );
1193     const string &sep = pFactory->getDirSeparator();
1194
1195     string file = rFileName;
1196     if( file.find( "\\" ) != string::npos )
1197     {
1198         // For skins to be valid on both Linux and Win32,
1199         // slash should be used as path separator for both OSs.
1200         msg_Warn( getIntf(), "use of '/' is preferred to '\\' for paths" );
1201         int pos;
1202         while( ( pos = file.find( "\\" ) ) != string::npos )
1203            file[pos] = '/';
1204     }
1205
1206 #ifdef WIN32
1207     int pos;
1208     while( ( pos = file.find( "/" ) ) != string::npos )
1209        file.replace( pos, 1, sep );
1210 #endif
1211
1212     string full_path = m_path + sep + sFromLocale( file );
1213
1214     // check that the file exists and can be read
1215     if( ifstream( full_path.c_str() ).fail() )
1216     {
1217         msg_Err( getIntf(), "missing file: %s", file.c_str() );
1218         full_path = "";
1219     }
1220
1221     return full_path;
1222 }
1223
1224
1225
1226 Bezier *Builder::getPoints( const char *pTag ) const
1227 {
1228     vector<float> xBez, yBez;
1229     int x, y, n;
1230     while( 1 )
1231     {
1232         if( sscanf( pTag, "(%d,%d)%n", &x, &y, &n ) < 1 )
1233         {
1234             return NULL;
1235         }
1236
1237         xBez.push_back( x );
1238         yBez.push_back( y );
1239         pTag += n;
1240         if( *pTag == '\0' )
1241         {
1242             break;
1243         }
1244         if( *(pTag++) != ',' )
1245         {
1246             return NULL;
1247         }
1248     }
1249
1250     // Create the Bezier curve
1251     return new Bezier( getIntf(), xBez, yBez );
1252 }
1253
1254
1255 uint32_t Builder::getColor( const string &rVal ) const
1256 {
1257     // Check it the value is a registered constant
1258     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
1259     string val = pInterpreter->getConstant( rVal );
1260
1261     // Convert to an int value
1262     return SkinParser::convertColor( val.c_str() );
1263 }
1264