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