]> git.sesse.net Git - vlc/blob - modules/gui/skins2/parser/builder.cpp
e5963d86306938c5d10a167210c3da36e3a71efd
[vlc] / modules / gui / skins2 / parser / builder.cpp
1 /*****************************************************************************
2  * builder.cpp
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 #include <string.h>
26 #include "builder.hpp"
27 #include "builder_data.hpp"
28 #include "interpreter.hpp"
29 #include "../src/png_bitmap.hpp"
30 #include "../src/os_factory.hpp"
31 #include "../src/generic_bitmap.hpp"
32 #include "../src/top_window.hpp"
33 #include "../src/anchor.hpp"
34 #include "../src/ft2_font.hpp"
35 #include "../src/theme.hpp"
36 #include "../controls/ctrl_button.hpp"
37 #include "../controls/ctrl_checkbox.hpp"
38 #include "../controls/ctrl_image.hpp"
39 #include "../controls/ctrl_list.hpp"
40 #include "../controls/ctrl_move.hpp"
41 #include "../controls/ctrl_resize.hpp"
42 #include "../controls/ctrl_slider.hpp"
43 #include "../controls/ctrl_radialslider.hpp"
44 #include "../controls/ctrl_text.hpp"
45 #include "../controls/ctrl_video.hpp"
46 #include "../utils/position.hpp"
47 #include "../utils/var_bool.hpp"
48 #include "../utils/var_text.hpp"
49
50
51 Builder::Builder( intf_thread_t *pIntf, const BuilderData &rData):
52     SkinObject( pIntf ), m_rData( rData ), m_pTheme( NULL )
53 {
54 }
55
56
57 CmdGeneric *Builder::parseAction( const string &rAction )
58 {
59     return Interpreter::instance( getIntf() )->parseAction( rAction, m_pTheme );
60 }
61
62
63 // Useful macro
64 #define ADD_OBJECTS( type ) \
65     list<BuilderData::type>::const_iterator it##type; \
66     for( it##type = m_rData.m_list##type.begin(); \
67          it##type != m_rData.m_list##type.end(); it##type++ ) \
68     { \
69         add##type( *it##type ); \
70     }
71
72
73 Theme *Builder::build()
74 {
75     m_pTheme = new Theme( getIntf() );
76     if( m_pTheme == NULL )
77     {
78         return NULL;
79     }
80
81     // Create everything from the data in the XML
82     ADD_OBJECTS( Theme );
83     ADD_OBJECTS( Bitmap );
84     ADD_OBJECTS( Font );
85     ADD_OBJECTS( Window );
86     ADD_OBJECTS( Layout );
87     ADD_OBJECTS( Anchor );
88     ADD_OBJECTS( Button );
89     ADD_OBJECTS( Checkbox );
90     ADD_OBJECTS( Image );
91     ADD_OBJECTS( Text );
92     ADD_OBJECTS( RadialSlider );
93     ADD_OBJECTS( Slider );
94     ADD_OBJECTS( List );
95     ADD_OBJECTS( Video );
96
97     return m_pTheme;
98 }
99
100
101 // Macro to get a bitmap by its ID in the builder
102 #define GET_BMP( pBmp, id ) \
103     if( id != "none" ) \
104     { \
105         pBmp = m_pTheme->m_bitmaps[id].get(); \
106         if( pBmp == NULL ) \
107         { \
108             msg_Err( getIntf(), "unknown bitmap id: %s", id.c_str() ); \
109             return; \
110         } \
111     }
112
113 void Builder::addTheme( const BuilderData::Theme &rData )
114 {
115     WindowManager &rManager = m_pTheme->getWindowManager();
116     rManager.setMagnetValue( rData.m_magnet );
117     rManager.setAlphaValue( rData.m_alpha );
118     rManager.setMoveAlphaValue( rData.m_moveAlpha );
119     // XXX:  font to fix
120     GenericFont *pFont = new FT2Font( getIntf(), "FreeSans.ttf", 12 );
121     pFont->init();
122     rManager.createTooltip( *pFont );
123 }
124
125
126 void Builder::addBitmap( const BuilderData::Bitmap &rData )
127 {
128     GenericBitmap *pBmp = new PngBitmap( getIntf(), rData.m_fileName,
129                                          rData.m_alphaColor );
130     m_pTheme->m_bitmaps[rData.m_id] = GenericBitmapPtr( pBmp );
131 }
132
133
134 void Builder::addFont( const BuilderData::Font &rData )
135 {
136     GenericFont *pFont = new FT2Font( getIntf(), rData.m_fontName,
137                                       rData.m_size );
138     if( pFont->init() )
139     {
140         m_pTheme->m_fonts[rData.m_id] = GenericFontPtr( pFont );
141     }
142     else
143     {
144         delete pFont;
145     }
146 }
147
148
149 void Builder::addWindow( const BuilderData::Window &rData )
150 {
151     TopWindow *pWin =
152         new TopWindow( getIntf(), rData.m_xPos, rData.m_yPos,
153                            m_pTheme->getWindowManager(),
154                            rData.m_dragDrop, rData.m_playOnDrop );
155
156     m_pTheme->m_windows[rData.m_id] = TopWindowPtr( pWin );
157 }
158
159
160 void Builder::addLayout( const BuilderData::Layout &rData )
161 {
162     TopWindow *pWin = m_pTheme->m_windows[rData.m_windowId].get();
163     if( pWin == NULL )
164     {
165         msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
166         return;
167     }
168
169     int minWidth = rData.m_minWidth != -1 ? rData.m_minWidth : rData.m_width;
170     int maxWidth = rData.m_maxWidth != -1 ? rData.m_maxWidth : rData.m_width;
171     int minHeight = rData.m_minHeight != -1 ? rData.m_minHeight :
172                     rData.m_height;
173     int maxHeight = rData.m_maxHeight != -1 ? rData.m_maxHeight :
174                     rData.m_height;
175     GenericLayout *pLayout = new GenericLayout( getIntf(), rData.m_width,
176                                                 rData.m_height,
177                                                 minWidth, maxWidth, minHeight,
178                                                 maxHeight );
179     m_pTheme->m_layouts[rData.m_id] = GenericLayoutPtr( pLayout );
180
181     // Attach the layout to its window
182     pWin->setActiveLayout( pLayout );
183 }
184
185
186 void Builder::addAnchor( const BuilderData::Anchor &rData )
187 {
188     TopWindow *pWin = m_pTheme->m_windows[rData.m_windowId].get();
189     if( pWin == NULL )
190     {
191         msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
192         return;
193     }
194
195     Bezier *pCurve = getPoints( rData.m_points.c_str() );
196     if( pCurve == NULL )
197     {
198         msg_Err( getIntf(), "Invalid format in tag points=\"%s\"",
199                  rData.m_points.c_str() );
200         return;
201     }
202     m_pTheme->m_curves.push_back( BezierPtr( pCurve ) );
203
204     Anchor *pAnc = new Anchor( getIntf(), rData.m_xPos, rData.m_yPos,
205                                rData.m_range, rData.m_priority,
206                                *pCurve, *pWin );
207     pWin->addAnchor( pAnc );
208 }
209
210
211 void Builder::addButton( const BuilderData::Button &rData )
212 {
213     // Get the bitmaps of the button
214     GenericBitmap *pBmpUp = NULL;
215     GET_BMP( pBmpUp, rData.m_upId );
216
217     GenericBitmap *pBmpDown = pBmpUp;
218     GET_BMP( pBmpDown, rData.m_downId );
219
220     GenericBitmap *pBmpOver = pBmpUp;
221     GET_BMP( pBmpOver, rData.m_overId );
222
223     GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
224     if( pLayout == NULL )
225     {
226         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
227         return;
228     }
229
230     CmdGeneric *pCommand = parseAction( rData.m_actionId );
231     if( pCommand == NULL )
232     {
233         msg_Err( getIntf(), "Invalid action: %s", rData.m_actionId.c_str() );
234         return;
235     }
236
237     CtrlButton *pButton = new CtrlButton( getIntf(), *pBmpUp, *pBmpOver,
238         *pBmpDown, *pCommand, UString( getIntf(), rData.m_tooltip.c_str() ),
239         UString( getIntf(), rData.m_help.c_str() ), NULL );
240
241     // Compute the position of the control
242     // XXX (we suppose all the images have the same size...)
243     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
244                                        rData.m_xPos, rData.m_yPos,
245                                        pBmpUp->getWidth(),
246                                        pBmpUp->getHeight(), *pLayout );
247
248     pLayout->addControl( pButton, pos, rData.m_layer );
249
250     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pButton );
251 }
252
253
254 void Builder::addCheckbox( const BuilderData::Checkbox &rData )
255 {
256     // Get the bitmaps of the checkbox
257     GenericBitmap *pBmpUp1 = NULL;
258     GET_BMP( pBmpUp1, rData.m_up1Id );
259
260     GenericBitmap *pBmpDown1 = pBmpUp1;
261     GET_BMP( pBmpDown1, rData.m_down1Id );
262
263     GenericBitmap *pBmpOver1 = pBmpUp1;
264     GET_BMP( pBmpOver1, rData.m_over1Id );
265
266     GenericBitmap *pBmpUp2 = NULL;
267     GET_BMP( pBmpUp2, rData.m_up2Id );
268
269     GenericBitmap *pBmpDown2 = pBmpUp2;
270     GET_BMP( pBmpDown2, rData.m_down2Id );
271
272     GenericBitmap *pBmpOver2 = pBmpUp2;
273     GET_BMP( pBmpOver2, rData.m_over2Id );
274
275     GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
276     if( pLayout == NULL )
277     {
278         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
279         return;
280     }
281
282     CmdGeneric *pCommand1 = parseAction( rData.m_action1 );
283     if( pCommand1 == NULL )
284     {
285         msg_Err( getIntf(), "Invalid action: %s", rData.m_action1.c_str() );
286         return;
287     }
288
289     CmdGeneric *pCommand2 = parseAction( rData.m_action2 );
290     if( pCommand2 == NULL )
291     {
292         msg_Err( getIntf(), "Invalid action: %s", rData.m_action2.c_str() );
293         return;
294     }
295
296     // Get the state variable
297     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
298     VarBool *pVar = pInterpreter->getVarBool( rData.m_state, m_pTheme );
299     if( pVar == NULL )
300     {
301         // TODO: default state
302         return;
303     }
304
305     // Create the control
306     CtrlCheckbox *pCheckbox = new CtrlCheckbox( getIntf(), *pBmpUp1,
307         *pBmpOver1, *pBmpDown1, *pBmpUp2, *pBmpOver2, *pBmpDown2, *pCommand1,
308         *pCommand2, UString( getIntf(), rData.m_tooltip1.c_str() ),
309         UString( getIntf(), rData.m_tooltip2.c_str() ), *pVar,
310         UString( getIntf(), rData.m_help.c_str() ), NULL );
311
312     // Compute the position of the control
313     // XXX (we suppose all the images have the same size...)
314     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
315                                        rData.m_xPos, rData.m_yPos,
316                                        pBmpUp1->getWidth(),
317                                        pBmpUp1->getHeight(), *pLayout );
318
319     pLayout->addControl( pCheckbox, pos, rData.m_layer );
320
321     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pCheckbox );
322 }
323
324
325 void Builder::addImage( const BuilderData::Image &rData )
326 {
327     GenericBitmap *pBmp = NULL;
328     GET_BMP( pBmp, rData.m_bmpId );
329
330     GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
331     if( pLayout == NULL )
332     {
333         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
334         return;
335     }
336
337     TopWindow *pWindow = m_pTheme->m_windows[rData.m_windowId].get();
338     if( pWindow == NULL )
339     {
340         msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
341         return;
342     }
343
344     CtrlImage *pImage = new CtrlImage( getIntf(), *pBmp,
345                                 UString( getIntf(), rData.m_help.c_str() ),
346                                 NULL);
347
348     // Compute the position of the control
349     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
350                                        rData.m_xPos,
351                                        rData.m_yPos, pBmp->getWidth(),
352                                        pBmp->getHeight(), *pLayout );
353
354     // XXX: test to be changed! XXX
355     if( rData.m_actionId == "move" )
356     {
357         CtrlMove *pMove = new CtrlMove( getIntf(), m_pTheme->getWindowManager(),
358              *pImage, *pWindow, UString( getIntf(), rData.m_help.c_str() ),
359              NULL);
360         pLayout->addControl( pMove, pos, rData.m_layer );
361     }
362     else if( rData.m_actionId == "resize" )
363     {
364         CtrlResize *pResize = new CtrlResize( getIntf(), *pImage, *pLayout,
365                 UString( getIntf(), rData.m_help.c_str() ), NULL );
366         pLayout->addControl( pResize, pos, rData.m_layer );
367     }
368     else
369     {
370         pLayout->addControl( pImage, pos, rData.m_layer );
371     }
372
373     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pImage );
374 }
375
376
377 void Builder::addText( const BuilderData::Text &rData )
378 {
379     GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
380     if( pLayout == NULL )
381     {
382         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
383         return;
384     }
385
386     GenericFont *pFont = m_pTheme->m_fonts[rData.m_fontId].get();
387     if( pFont == NULL )
388     {
389         msg_Err( getIntf(), "Unknown font id: %s", rData.m_fontId.c_str() );
390         return;
391     }
392
393     // Create a text variable
394     VarText *pVar = new VarText( getIntf() );
395     UString msg( getIntf(), rData.m_text.c_str() );
396     pVar->set( msg );
397     m_pTheme->m_vars.push_back( VariablePtr( pVar ) );
398
399     CtrlText *pText = new CtrlText( getIntf(), *pVar, *pFont,
400             UString( getIntf(), rData.m_help.c_str() ), rData.m_color, NULL );
401
402     int height = pFont->getSize();
403
404     pLayout->addControl( pText, Position( rData.m_xPos, rData.m_yPos,
405                                           rData.m_xPos + rData.m_width,
406                                           rData.m_yPos + height, *pLayout ),
407                          rData.m_layer );
408
409     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pText );
410 }
411
412
413 void Builder::addRadialSlider( const BuilderData::RadialSlider &rData )
414 {
415     // Get the bitmaps of the slider
416     GenericBitmap *pSeq = NULL;
417     GET_BMP( pSeq, rData.m_sequence );
418
419     GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
420     if( pLayout == NULL )
421     {
422         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
423         return;
424     }
425
426     // Get the variable associated to the slider
427     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
428     VarPercent *pVar = pInterpreter->getVarPercent( rData.m_value, m_pTheme );
429     if( pVar == NULL )
430     {
431         msg_Err( getIntf(), "Unknown slider value: %s", rData.m_value.c_str() );
432         return;
433     }
434
435     // Create the control
436     CtrlRadialSlider *pRadial =
437         new CtrlRadialSlider( getIntf(), *pSeq, rData.m_nbImages, *pVar,
438                               rData.m_minAngle, rData.m_maxAngle,
439                               UString( getIntf(), rData.m_help.c_str() ),
440                               NULL );
441
442     // XXX: resizing is not supported
443     // Compute the position of the control
444     const Position pos =
445         makePosition( rData.m_leftTop, rData.m_rightBottom, rData.m_xPos,
446                       rData.m_yPos, pSeq->getWidth(),
447                       pSeq->getHeight() / rData.m_nbImages, *pLayout );
448
449     pLayout->addControl( pRadial, pos, rData.m_layer );
450
451     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pRadial );
452 }
453
454
455 void Builder::addSlider( const BuilderData::Slider &rData )
456 {
457     // Get the bitmaps of the slider
458     GenericBitmap *pBmpUp = NULL;
459     GET_BMP( pBmpUp, rData.m_upId );
460
461     GenericBitmap *pBmpDown = pBmpUp;
462     GET_BMP( pBmpDown, rData.m_downId );
463
464     GenericBitmap *pBmpOver = pBmpUp;
465     GET_BMP( pBmpOver, rData.m_overId );
466
467     GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
468     if( pLayout == NULL )
469     {
470         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
471         return;
472     }
473
474     Bezier *pCurve = getPoints( rData.m_points.c_str() );
475     if( pCurve == NULL )
476     {
477         msg_Err( getIntf(), "Invalid format in tag points=\"%s\"",
478                  rData.m_points.c_str() );
479         return;
480     }
481     m_pTheme->m_curves.push_back( BezierPtr( pCurve ) );
482
483     // Get the visibility variable
484     // XXX check when it is null
485     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
486     VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
487
488     // Get the variable associated to the slider
489     VarPercent *pVar = pInterpreter->getVarPercent( rData.m_value, m_pTheme );
490     if( pVar == NULL )
491     {
492         msg_Err( getIntf(), "Unknown slider value: %s", rData.m_value.c_str() );
493         return;
494     }
495
496     // Create the cursor and background controls
497     CtrlSliderCursor *pCursor = new CtrlSliderCursor( getIntf(), *pBmpUp,
498         *pBmpOver, *pBmpDown, *pCurve, *pVar, pVisible,
499         UString( getIntf(), rData.m_tooltip.c_str() ),
500         UString( getIntf(), rData.m_help.c_str() ) );
501
502     CtrlSliderBg *pBackground = new CtrlSliderBg( getIntf(), *pCursor,
503         *pCurve, *pVar, rData.m_thickness, pVisible,
504         UString( getIntf(), rData.m_help.c_str() ) );
505
506     // Compute the position of the control
507     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
508                                        rData.m_xPos, rData.m_yPos,
509                                        pCurve->getWidth(), pCurve->getHeight(),
510                                        *pLayout );
511
512     pLayout->addControl( pBackground, pos, rData.m_layer );
513     pLayout->addControl( pCursor, pos, rData.m_layer );
514
515     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pCursor );
516     m_pTheme->m_controls[rData.m_id + "_bg"] = CtrlGenericPtr( pBackground );
517 }
518
519
520 void Builder::addList( const BuilderData::List &rData )
521 {
522     GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
523     if( pLayout == NULL )
524     {
525         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
526         return;
527     }
528
529     GenericFont *pFont = m_pTheme->m_fonts[rData.m_fontId].get();
530     if( pFont == NULL )
531     {
532         msg_Err( getIntf(), "Unknown font id: %s", rData.m_fontId.c_str() );
533         return;
534     }
535
536     // Get the list variable
537     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
538     VarList *pVar = pInterpreter->getVarList( rData.m_var, m_pTheme );
539     if( pVar == NULL )
540     {
541         msg_Err( getIntf(), "No such list variable: %s", rData.m_var.c_str() );
542         return;
543     }
544
545     // Create the list control
546     CtrlList *pList = new CtrlList( getIntf(), *pVar, *pFont,
547        rData.m_fgColor, rData.m_playColor, rData.m_bgColor1,
548        rData.m_bgColor2, rData.m_selColor,
549        UString( getIntf(), rData.m_help.c_str() ), NULL );
550
551     // Compute the position of the control
552     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
553                                        rData.m_xPos, rData.m_yPos,
554                                        rData.m_width, rData.m_height,
555                                        *pLayout );
556
557     pLayout->addControl( pList, pos, rData.m_layer );
558
559     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pList );
560 }
561
562
563 void Builder::addVideo( const BuilderData::Video &rData )
564 {
565     GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
566     if( pLayout == NULL )
567     {
568         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
569         return;
570     }
571
572     CtrlVideo *pVideo = new CtrlVideo( getIntf(),
573         UString( getIntf(), rData.m_help.c_str() ), NULL);
574
575     // Compute the position of the control
576     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
577                                        rData.m_xPos, rData.m_yPos,
578                                        rData.m_width, rData.m_height,
579                                        *pLayout );
580
581     pLayout->addControl( pVideo, pos, rData.m_layer );
582
583     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pVideo );
584 }
585
586
587 const Position Builder::makePosition( const string &rLeftTop,
588                                       const string &rRightBottom,
589                                       int xPos, int yPos, int width,
590                                       int height, const Box &rBox ) const
591 {
592     int left = 0, top = 0, right = 0, bottom = 0;
593     Position::Ref_t refLeftTop = Position::kLeftTop;
594     Position::Ref_t refRightBottom = Position::kLeftTop;
595
596     int boxWidth = rBox.getWidth();
597     int boxHeight = rBox.getHeight();
598
599     // Position of the left top corner
600     if( rLeftTop == "lefttop" )
601     {
602         left = xPos;
603         top = yPos;
604         refLeftTop = Position::kLeftTop;
605     }
606     else if( rLeftTop == "righttop" )
607     {
608         left = xPos - boxWidth + 1;
609         top = yPos;
610         refLeftTop = Position::kRightTop;
611     }
612     else if( rLeftTop == "leftbottom" )
613     {
614         left = xPos;
615         top = yPos - boxHeight + 1;
616         refLeftTop = Position::kLeftBottom;
617     }
618     else if( rLeftTop == "rightbottom" )
619     {
620         left = xPos - boxWidth + 1;
621         top = yPos - boxHeight + 1;
622         refLeftTop = Position::kRightBottom;
623     }
624
625     // Position of the right bottom corner
626     if( rRightBottom == "lefttop" )
627     {
628         right = xPos + width - 1;
629         bottom = yPos + height - 1;
630         refRightBottom = Position::kLeftTop;
631     }
632     else if( rRightBottom == "righttop" )
633     {
634         right = xPos + width - boxWidth;
635         bottom = yPos + height - 1;
636         refRightBottom = Position::kRightTop;
637     }
638     else if( rRightBottom == "leftbottom" )
639     {
640         right = xPos + width - 1;
641         bottom = yPos + height - boxHeight;
642         refRightBottom = Position::kLeftBottom;
643     }
644     else if( rRightBottom == "rightbottom" )
645     {
646         right = xPos + width - boxWidth;
647         bottom = yPos + height - boxHeight;
648         refRightBottom = Position::kRightBottom;
649     }
650
651     return Position( left, top, right, bottom, rBox, refLeftTop,
652                      refRightBottom );
653 }
654
655
656 Bezier *Builder::getPoints( const char *pTag ) const
657 {
658     vector<float> xBez, yBez;
659     int x, y, n;
660     while( 1 )
661     {
662         if( sscanf( pTag, "(%d,%d)%n", &x, &y, &n ) < 1 )
663         {
664             return NULL;
665         }
666 #if 0
667         if( x < 0 || y < 0 )
668         {
669             msg_Err( getIntf(),
670                      "Slider points cannot have negative coordinates!" );
671             return NULL;
672         }
673 #endif
674         xBez.push_back( x );
675         yBez.push_back( y );
676         pTag += n;
677         if( *pTag == '\0' )
678         {
679             break;
680         }
681         if( *(pTag++) != ',' )
682         {
683             return NULL;
684         }
685     }
686
687     // Create the Bezier curve
688     return new Bezier( getIntf(), xBez, yBez );
689 }
690