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