Merge pull request #4687 from ruuk/textboxgettext
[vuplus_xbmc] / xbmc / interfaces / legacy / Control.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "Control.h"
22 #include "LanguageHook.h"
23 #include "AddonUtils.h"
24
25 #include "guilib/GUILabel.h"
26 #include "guilib/GUIFontManager.h"
27 #include "guilib/GUILabelControl.h"
28 #include "guilib/GUIFadeLabelControl.h"
29 #include "guilib/GUITextBox.h"
30 #include "guilib/GUIButtonControl.h"
31 #include "guilib/GUICheckMarkControl.h"
32 #include "guilib/GUIImage.h"
33 #include "guilib/GUIListContainer.h"
34 #include "guilib/GUIProgressControl.h"
35 #include "guilib/GUISliderControl.h"
36 #include "guilib/GUIRadioButtonControl.h"
37 #include "GUIInfoManager.h"
38 #include "guilib/GUIWindowManager.h"
39 #include "guilib/GUIEditControl.h"
40 #include "guilib/GUIControlFactory.h"
41 #include "listproviders/StaticProvider.h"
42
43 #include "utils/XBMCTinyXML.h"
44 #include "utils/StringUtils.h"
45
46 namespace XBMCAddon
47 {
48   namespace xbmcgui
49   {
50
51     // ============================================================
52
53     // ============================================================
54     // ============================================================
55     ControlFadeLabel::ControlFadeLabel(long x, long y, long width, long height, 
56                                        const char* font, const char* _textColor, 
57                                        long _alignment) : 
58       strFont("font13"), textColor(0xffffffff), align(_alignment)
59     {
60       dwPosX = x;
61       dwPosY = y;
62       dwWidth = width;
63       dwHeight = height;
64
65       if (font)
66         strFont = font;
67
68       if (_textColor) 
69         sscanf(_textColor, "%x", &textColor);
70
71       pGUIControl = NULL;
72     }
73
74     void ControlFadeLabel::addLabel(const String& label) throw (UnimplementedException)
75     {
76       CGUIMessage msg(GUI_MSG_LABEL_ADD, iParentId, iControlId);
77       msg.SetLabel(label);
78
79       g_windowManager.SendThreadMessage(msg, iParentId);
80     }
81
82     void ControlFadeLabel::reset() throw (UnimplementedException)
83     {
84       CGUIMessage msg(GUI_MSG_LABEL_RESET, iParentId, iControlId);
85
86       vecLabels.clear();
87       g_windowManager.SendThreadMessage(msg, iParentId);
88     }
89
90     CGUIControl* ControlFadeLabel::Create() throw (WindowException)
91     {
92       CLabelInfo label;
93       label.font = g_fontManager.GetFont(strFont);
94       label.textColor = label.focusedColor = textColor;
95       label.align = align;
96       pGUIControl = new CGUIFadeLabelControl(
97         iParentId,
98         iControlId,
99         (float)dwPosX,
100         (float)dwPosY,
101         (float)dwWidth,
102         (float)dwHeight,
103         label,
104         true,
105         0,
106         true);
107
108       CGUIMessage msg(GUI_MSG_LABEL_RESET, iParentId, iControlId);
109       pGUIControl->OnMessage(msg);
110
111       return pGUIControl;
112     }
113
114     // ============================================================
115
116     // ============================================================
117     // ============================================================
118     ControlTextBox::ControlTextBox(long x, long y, long width, long height, 
119                                    const char* font, const char* _textColor) : 
120       strFont("font13"), textColor(0xffffffff)
121     {
122       dwPosX = x;
123       dwPosY = y;
124       dwWidth = width;
125       dwHeight = height;
126
127       if (font)
128         strFont = font;
129
130       if (_textColor) 
131         sscanf(_textColor, "%x", &textColor);
132     }
133
134     void ControlTextBox::setText(const String& text) throw(UnimplementedException)
135     {
136       // create message
137       CGUIMessage msg(GUI_MSG_LABEL_SET, iParentId, iControlId);
138       msg.SetLabel(text);
139
140       // send message
141       g_windowManager.SendThreadMessage(msg, iParentId);
142     }
143
144     String ControlTextBox::getText() throw (UnimplementedException)
145     {
146       if (!pGUIControl) return NULL;
147
148       LOCKGUI;
149       return ((CGUITextBox*) pGUIControl)->GetDescription();
150     }
151
152     void ControlTextBox::reset() throw(UnimplementedException)
153     {
154       // create message
155       CGUIMessage msg(GUI_MSG_LABEL_RESET, iParentId, iControlId);
156       g_windowManager.SendThreadMessage(msg, iParentId);
157     }
158
159     void ControlTextBox::scroll(long position) throw(UnimplementedException)
160     {
161       static_cast<CGUITextBox*>(pGUIControl)->Scroll((int)position);
162     }
163
164     CGUIControl* ControlTextBox::Create() throw (WindowException)
165     {
166       // create textbox
167       CLabelInfo label;
168       label.font = g_fontManager.GetFont(strFont);
169       label.textColor = label.focusedColor = textColor;
170
171       pGUIControl = new CGUITextBox(iParentId, iControlId,
172            (float)dwPosX, (float)dwPosY, (float)dwWidth, (float)dwHeight,
173            label);
174
175       // reset textbox
176       CGUIMessage msg(GUI_MSG_LABEL_RESET, iParentId, iControlId);
177       pGUIControl->OnMessage(msg);
178
179       return pGUIControl;
180     }
181
182     // ============================================================
183
184     // ============================================================
185     // ============================================================
186     ControlButton::ControlButton(long x, long y, long width, long height, const String& label,
187                                  const char* focusTexture, const char* noFocusTexture, 
188                                  long _textOffsetX, long _textOffsetY, 
189                                  long alignment, const char* font, const char* _textColor,
190                                  const char* _disabledColor, long angle,
191                                  const char* _shadowColor, const char* _focusedColor) :
192       textOffsetX(_textOffsetX), textOffsetY(_textOffsetY),
193       align(alignment), strFont("font13"), textColor(0xffffffff), disabledColor(0x60ffffff),
194       iAngle(angle), shadowColor(0), focusedColor(0xffffffff)
195     {
196       dwPosX = x;
197       dwPosY = y;
198       dwWidth = width;
199       dwHeight = height;
200
201       strText = label;
202
203       // if texture is supplied use it, else get default ones
204       strTextureFocus = focusTexture ? focusTexture :
205         XBMCAddonUtils::getDefaultImage((char*)"button", (char*)"texturefocus", (char*)"button-focus.png");
206       strTextureNoFocus = noFocusTexture ? noFocusTexture :
207         XBMCAddonUtils::getDefaultImage((char*)"button", (char*)"texturenofocus", (char*)"button-nofocus.jpg");
208       
209       if (font) strFont = font;
210       if (_textColor) sscanf( _textColor, "%x", &textColor );
211       if (_disabledColor) sscanf( _disabledColor, "%x", &disabledColor );
212       if (_shadowColor) sscanf( _shadowColor, "%x", &shadowColor );
213       if (_focusedColor) sscanf( _focusedColor, "%x", &focusedColor );
214     }
215
216     void ControlButton::setLabel(const String& label, 
217                                  const char* font,
218                                  const char* _textColor,
219                                  const char* _disabledColor,
220                                  const char* _shadowColor,
221                                  const char* _focusedColor,
222                                  const String& label2) throw (UnimplementedException)
223     {
224       if (!label.empty()) strText = label;
225       if (!label2.empty()) strText2 = label2;
226       if (font) strFont = font;
227       if (_textColor) sscanf(_textColor, "%x", &textColor);
228       if (_disabledColor) sscanf( _disabledColor, "%x", &disabledColor );
229       if (_shadowColor) sscanf(_shadowColor, "%x", &shadowColor);
230       if (_focusedColor) sscanf(_focusedColor, "%x", &focusedColor);
231
232       if (pGUIControl)
233       {
234         LOCKGUI;
235         ((CGUIButtonControl*)pGUIControl)->PythonSetLabel(strFont, strText, textColor, shadowColor, focusedColor);
236         ((CGUIButtonControl*)pGUIControl)->SetLabel2(strText2);
237         ((CGUIButtonControl*)pGUIControl)->PythonSetDisabledColor(disabledColor);
238       }
239     }
240
241     void ControlButton::setDisabledColor(const char* color) throw (UnimplementedException)
242     { 
243       if (color) sscanf(color, "%x", &disabledColor);
244
245       if (pGUIControl)
246       {
247         LOCKGUI;
248         ((CGUIButtonControl*)pGUIControl)->PythonSetDisabledColor(disabledColor);
249       }
250     }
251
252     String ControlButton::getLabel() throw (UnimplementedException)
253     {
254       if (!pGUIControl) return NULL;
255
256       LOCKGUI;
257       return ((CGUIButtonControl*) pGUIControl)->GetLabel();
258     }
259
260     String ControlButton::getLabel2() throw (UnimplementedException)
261     {
262       if (!pGUIControl) return NULL;
263
264       LOCKGUI;
265       return ((CGUIButtonControl*) pGUIControl)->GetLabel2();
266     }
267
268     CGUIControl* ControlButton::Create() throw (WindowException)
269     {
270       CLabelInfo label;
271       label.font = g_fontManager.GetFont(strFont);
272       label.textColor = textColor;
273       label.disabledColor = disabledColor;
274       label.shadowColor = shadowColor;
275       label.focusedColor = focusedColor;
276       label.align = align;
277       label.offsetX = (float)textOffsetX;
278       label.offsetY = (float)textOffsetY;
279       label.angle = (float)-iAngle;
280       pGUIControl = new CGUIButtonControl(
281         iParentId,
282         iControlId,
283         (float)dwPosX,
284         (float)dwPosY,
285         (float)dwWidth,
286         (float)dwHeight,
287         (CStdString)strTextureFocus,
288         (CStdString)strTextureNoFocus,
289         label);
290
291       CGUIButtonControl* pGuiButtonControl =
292         (CGUIButtonControl*)pGUIControl;
293
294       pGuiButtonControl->SetLabel(strText);
295       pGuiButtonControl->SetLabel2(strText2);
296
297       return pGUIControl;
298     }
299
300     // ============================================================
301
302     // ============================================================
303     // ============================================================
304     ControlCheckMark::ControlCheckMark(long x, long y, long width, long height, const String& label,
305                                        const char* focusTexture, const char* noFocusTexture, 
306                                        long _checkWidth, long _checkHeight,
307                                        long _alignment, const char* font, 
308                                        const char* _textColor, const char* _disabledColor) :
309       strFont("font13"), checkWidth(_checkWidth), checkHeight(_checkHeight),
310       align(_alignment), textColor(0xffffffff), disabledColor(0x60ffffff)
311     {
312       dwPosX = x;
313       dwPosY = y;
314       dwWidth = width;
315       dwHeight = height;
316
317       strText = label;
318       if (font) strFont = font;
319       if (_textColor) sscanf(_textColor, "%x", &textColor);
320       if (_disabledColor) sscanf( _disabledColor, "%x", &disabledColor );
321
322       strTextureFocus = focusTexture ?  focusTexture :
323         XBMCAddonUtils::getDefaultImage((char*)"checkmark", (char*)"texturefocus", (char*)"check-box.png");
324       strTextureNoFocus = noFocusTexture ? noFocusTexture :
325         XBMCAddonUtils::getDefaultImage((char*)"checkmark", (char*)"texturenofocus", (char*)"check-boxNF.png");
326     }
327
328     bool ControlCheckMark::getSelected() throw (UnimplementedException)
329     {
330       bool isSelected = false;
331
332       if (pGUIControl)
333       {
334         LOCKGUI;
335         isSelected = ((CGUICheckMarkControl*)pGUIControl)->GetSelected();
336       }
337
338       return isSelected;
339     }
340
341     void ControlCheckMark::setSelected(bool selected) throw (UnimplementedException)
342     {
343       if (pGUIControl)
344       {
345         LOCKGUI;
346         ((CGUICheckMarkControl*)pGUIControl)->SetSelected(selected);
347       }
348     }
349
350     void ControlCheckMark::setLabel(const String& label, 
351                                     const char* font,
352                                     const char* _textColor,
353                                     const char* _disabledColor,
354                                     const char* _shadowColor,
355                                     const char* _focusedColor,
356                                     const String& label2) throw (UnimplementedException)
357     {
358
359       if (font) strFont = font;
360       if (_textColor) sscanf(_textColor, "%x", &textColor);
361       if (_disabledColor) sscanf(_disabledColor, "%x", &disabledColor);
362
363       if (pGUIControl)
364       {
365         LOCKGUI;
366         ((CGUICheckMarkControl*)pGUIControl)->PythonSetLabel(strFont,strText,textColor);
367         ((CGUICheckMarkControl*)pGUIControl)->PythonSetDisabledColor(disabledColor);
368       }
369     }
370
371     void ControlCheckMark::setDisabledColor(const char* color) throw (UnimplementedException)
372     {
373       if (color) sscanf(color, "%x", &disabledColor);
374
375       if (pGUIControl)
376       {
377         LOCKGUI;
378         ((CGUICheckMarkControl*)pGUIControl)->PythonSetDisabledColor( disabledColor );
379       }
380     }
381
382     CGUIControl* ControlCheckMark::Create() throw (WindowException)
383     {
384       CLabelInfo label;
385       label.disabledColor = disabledColor;
386       label.textColor = label.focusedColor = textColor;
387       label.font = g_fontManager.GetFont(strFont);
388       label.align = align;
389       CTextureInfo imageFocus(strTextureFocus);
390       CTextureInfo imageNoFocus(strTextureNoFocus);
391       pGUIControl = new CGUICheckMarkControl(
392         iParentId,
393         iControlId,
394         (float)dwPosX,
395         (float)dwPosY,
396         (float)dwWidth,
397         (float)dwHeight,
398         imageFocus, imageNoFocus,
399         (float)checkWidth,
400         (float)checkHeight,
401         label );
402
403       CGUICheckMarkControl* pGuiCheckMarkControl = (CGUICheckMarkControl*)pGUIControl;
404       pGuiCheckMarkControl->SetLabel(strText);
405
406       return pGUIControl;
407     }
408
409     // ============================================================
410
411     // ============================================================
412     // ============================================================
413     ControlImage::ControlImage(long x, long y, long width, long height, 
414                                const char* filename, long aRatio,
415                                const char* _colorDiffuse):
416       aspectRatio(aRatio), colorDiffuse(0)
417     {
418       dwPosX = x;
419       dwPosY = y;
420       dwWidth = width;
421       dwHeight = height;
422
423       // check if filename exists
424       strFileName = filename;
425       if (_colorDiffuse) 
426         sscanf(_colorDiffuse, "%x", &colorDiffuse);
427     }
428
429     void ControlImage::setImage(const char* imageFilename, const bool useCache) throw (UnimplementedException)
430     {
431       strFileName = imageFilename;
432
433       LOCKGUI;
434       if (pGUIControl)
435         ((CGUIImage*)pGUIControl)->SetFileName(strFileName, false, useCache);
436     }
437
438     void ControlImage::setColorDiffuse(const char* cColorDiffuse) throw (UnimplementedException)
439     {
440       if (cColorDiffuse) sscanf(cColorDiffuse, "%x", &colorDiffuse);
441       else colorDiffuse = 0;
442
443       LOCKGUI;
444       if (pGUIControl)
445         ((CGUIImage *)pGUIControl)->SetColorDiffuse(colorDiffuse);
446     }
447     
448     CGUIControl* ControlImage::Create() throw (WindowException)
449     {
450       pGUIControl = new CGUIImage(iParentId, iControlId,
451             (float)dwPosX, (float)dwPosY, (float)dwWidth, (float)dwHeight,
452             (CStdString)strFileName);
453
454       if (pGUIControl && aspectRatio <= CAspectRatio::AR_KEEP)
455         ((CGUIImage *)pGUIControl)->SetAspectRatio((CAspectRatio::ASPECT_RATIO)aspectRatio);
456
457       if (pGUIControl && colorDiffuse)
458         ((CGUIImage *)pGUIControl)->SetColorDiffuse(colorDiffuse);
459
460       return pGUIControl;
461     }
462
463     // ============================================================
464
465     // ============================================================
466     // ============================================================
467     ControlProgress::ControlProgress(long x, long y, long width, long height, 
468                                      const char* texturebg,
469                                      const char* textureleft,
470                                      const char* texturemid,
471                                      const char* textureright,
472                                      const char* textureoverlay)
473     {
474       dwPosX = x;
475       dwPosY = y;
476       dwWidth = width;
477       dwHeight = height;
478
479       // if texture is supplied use it, else get default ones
480       strTextureBg = texturebg ? texturebg : 
481         XBMCAddonUtils::getDefaultImage((char*)"progress", (char*)"texturebg", (char*)"progress_back.png");
482       strTextureLeft = textureleft ? textureleft : 
483         XBMCAddonUtils::getDefaultImage((char*)"progress", (char*)"lefttexture", (char*)"progress_left.png");
484       strTextureMid = texturemid ? texturemid : 
485         XBMCAddonUtils::getDefaultImage((char*)"progress", (char*)"midtexture", (char*)"progress_mid.png");
486       strTextureRight = textureright ? textureright : 
487         XBMCAddonUtils::getDefaultImage((char*)"progress", (char*)"righttexture", (char*)"progress_right.png");
488       strTextureOverlay = textureoverlay ? textureoverlay : 
489         XBMCAddonUtils::getDefaultImage((char*)"progress", (char*)"overlaytexture", (char*)"progress_over.png");
490     }
491
492     void ControlProgress::setPercent(float pct) throw (UnimplementedException)
493     {
494       if (pGUIControl)
495         ((CGUIProgressControl*)pGUIControl)->SetPercentage(pct);
496     }
497
498     float ControlProgress::getPercent() throw (UnimplementedException)
499     {
500       return (pGUIControl) ? ((CGUIProgressControl*)pGUIControl)->GetPercentage() : 0.0f;
501     }
502
503     CGUIControl* ControlProgress::Create() throw (WindowException)
504     {
505       pGUIControl = new CGUIProgressControl(iParentId, iControlId,
506          (float)dwPosX, (float)dwPosY,
507          (float)dwWidth,(float)dwHeight,
508          (CStdString)strTextureBg,(CStdString)strTextureLeft,
509          (CStdString)strTextureMid,(CStdString)strTextureRight,
510          (CStdString)strTextureOverlay);
511
512       if (pGUIControl && colorDiffuse)
513         ((CGUIProgressControl *)pGUIControl)->SetColorDiffuse(colorDiffuse);
514
515       return pGUIControl;
516     }
517
518     // ============================================================
519
520     // ============================================================
521     // ============================================================
522     ControlSlider::ControlSlider(long x, long y, long width, long height, 
523                                  const char* textureback, 
524                                  const char* texture,
525                                  const char* texturefocus)
526     {
527       dwPosX = x;
528       dwPosY = y;
529       dwWidth = width;
530       dwHeight = height;
531
532       // if texture is supplied use it, else get default ones
533       strTextureBack = textureback ? textureback : 
534         XBMCAddonUtils::getDefaultImage((char*)"slider", (char*)"texturesliderbar", (char*)"osd_slider_bg_2.png");
535       strTexture = texture ? texture : 
536         XBMCAddonUtils::getDefaultImage((char*)"slider", (char*)"textureslidernib", (char*)"osd_slider_nibNF.png");
537       strTextureFoc = texturefocus ? texturefocus : 
538         XBMCAddonUtils::getDefaultImage((char*)"slider", (char*)"textureslidernibfocus", (char*)"osd_slider_nib.png");
539     }
540
541     float ControlSlider::getPercent() throw (UnimplementedException)
542     {
543       return (pGUIControl) ? ((CGUISliderControl*)pGUIControl)->GetPercentage() : 0.0f;
544     }
545
546     void ControlSlider::setPercent(float pct) throw (UnimplementedException)
547     {
548       if (pGUIControl)
549         ((CGUISliderControl*)pGUIControl)->SetPercentage(pct);
550     }
551
552     CGUIControl* ControlSlider::Create () throw (WindowException)
553     {
554       pGUIControl = new CGUISliderControl(iParentId, iControlId,(float)dwPosX, (float)dwPosY,
555                                           (float)dwWidth,(float)dwHeight,
556                                           (CStdString)strTextureBack,(CStdString)strTexture,
557                                           (CStdString)strTextureFoc,0);   
558     
559       return pGUIControl;
560     }  
561
562     // ============================================================
563
564     // ============================================================
565     // ============================================================
566     ControlGroup::ControlGroup(long x, long y, long width, long height)
567     {
568       dwPosX = x;
569       dwPosY = y;
570       dwWidth = width;
571       dwHeight = height;
572     }
573
574     CGUIControl* ControlGroup::Create() throw (WindowException)
575     {
576       pGUIControl = new CGUIControlGroup(iParentId,
577                                          iControlId,
578                                          (float) dwPosX,
579                                          (float) dwPosY,
580                                          (float) dwWidth,
581                                          (float) dwHeight);
582       return pGUIControl;
583     }
584
585     // ============================================================
586
587     // ============================================================
588     // ============================================================
589     ControlRadioButton::ControlRadioButton(long x, long y, long width, long height, const String& label,
590                                            const char* focusOnTexture,  const char* noFocusOnTexture,
591                                            const char* focusOffTexture, const char* noFocusOffTexture,
592                                            const char* focusTexture,    const char* noFocusTexture, 
593                                            long _textOffsetX, long _textOffsetY, 
594                                            long alignment, const char* font, const char* _textColor,
595                                            const char* _disabledColor, long angle,
596                                            const char* _shadowColor, const char* _focusedColor) :
597       strFont("font13"), textColor(0xffffffff), disabledColor(0x60ffffff), 
598       textOffsetX(_textOffsetX), textOffsetY(_textOffsetY), align(alignment), iAngle(angle), 
599       shadowColor(0), focusedColor(0xffffffff)
600     {
601       dwPosX = x;
602       dwPosY = y;
603       dwWidth = width;
604       dwHeight = height;
605
606       strText = label;
607
608       // if texture is supplied use it, else get default ones
609       strTextureFocus = focusTexture ? focusTexture :
610         XBMCAddonUtils::getDefaultImage((char*)"button", (char*)"texturefocus", (char*)"button-focus.png");
611       strTextureNoFocus = noFocusTexture ? noFocusTexture :
612         XBMCAddonUtils::getDefaultImage((char*)"button", (char*)"texturenofocus", (char*)"button-nofocus.jpg");
613
614       if (focusOnTexture && noFocusOnTexture)
615       {
616         strTextureRadioOnFocus = focusOnTexture;
617         strTextureRadioOnNoFocus = noFocusOnTexture;
618       }
619       else
620       {
621         strTextureRadioOnFocus = strTextureRadioOnNoFocus = focusTexture ? focusTexture :
622           XBMCAddonUtils::getDefaultImage((char*)"radiobutton", (char*)"textureradiofocus", (char*)"radiobutton-focus.png");
623       }
624
625       if (focusOffTexture && noFocusOffTexture)
626       {
627         strTextureRadioOffFocus = focusOffTexture;
628         strTextureRadioOffNoFocus = noFocusOffTexture;
629       }
630       else
631       {
632         strTextureRadioOffFocus = strTextureRadioOffNoFocus = noFocusTexture ? noFocusTexture :
633           XBMCAddonUtils::getDefaultImage((char*)"radiobutton", (char*)"textureradiofocus", (char*)"radiobutton-focus.png");
634       }
635
636       if (font) strFont = font;
637       if (_textColor) sscanf( _textColor, "%x", &textColor );
638       if (_disabledColor) sscanf( _disabledColor, "%x", &disabledColor );
639       if (_shadowColor) sscanf( _shadowColor, "%x", &shadowColor );
640       if (_focusedColor) sscanf( _focusedColor, "%x", &focusedColor );
641     }
642
643     void ControlRadioButton::setSelected(bool selected) throw (UnimplementedException)
644     {
645       if (pGUIControl)
646       {
647         LOCKGUI;
648         ((CGUIRadioButtonControl*)pGUIControl)->SetSelected(selected);
649       }
650     }
651
652     bool ControlRadioButton::isSelected() throw (UnimplementedException)
653     {
654       bool isSelected = false;
655
656       if (pGUIControl)
657       {
658         LOCKGUI;
659         isSelected = ((CGUIRadioButtonControl*)pGUIControl)->IsSelected();
660       }
661       return isSelected;
662     }
663
664     void ControlRadioButton::setLabel(const String& label, 
665                                       const char* font,
666                                       const char* _textColor,
667                                       const char* _disabledColor,
668                                       const char* _shadowColor,
669                                       const char* _focusedColor,
670                                       const String& label2) throw (UnimplementedException)
671     {
672       if (!label.empty()) strText = label;
673       if (font) strFont = font;
674       if (_textColor) sscanf(_textColor, "%x", &textColor);
675       if (_disabledColor) sscanf( _disabledColor, "%x", &disabledColor );
676       if (_shadowColor) sscanf(_shadowColor, "%x", &shadowColor);
677       if (_focusedColor) sscanf(_focusedColor, "%x", &focusedColor);
678
679       if (pGUIControl)
680       {
681         LOCKGUI;
682         ((CGUIRadioButtonControl*)pGUIControl)->PythonSetLabel(strFont, strText, textColor, shadowColor, focusedColor);
683         ((CGUIRadioButtonControl*)pGUIControl)->PythonSetDisabledColor(disabledColor);
684       }
685     }
686
687     void ControlRadioButton::setRadioDimension(long x, long y, long width, long height) 
688       throw (UnimplementedException)
689     {
690       dwPosX = x;
691       dwPosY = y;
692       dwWidth = width;
693       dwHeight = height;
694       if (pGUIControl)
695       {
696         LOCKGUI;
697         ((CGUIRadioButtonControl*)pGUIControl)->SetRadioDimensions((float)dwPosX, (float)dwPosY, (float)dwWidth, (float)dwHeight);
698       }
699     }
700
701     CGUIControl* ControlRadioButton::Create() throw (WindowException)
702     {
703       CLabelInfo label;
704       label.font = g_fontManager.GetFont(strFont);
705       label.textColor = textColor;
706       label.disabledColor = disabledColor;
707       label.shadowColor = shadowColor;
708       label.focusedColor = focusedColor;
709       label.align = align;
710       label.offsetX = (float)textOffsetX;
711       label.offsetY = (float)textOffsetY;
712       label.angle = (float)-iAngle;
713       pGUIControl = new CGUIRadioButtonControl(
714         iParentId,
715         iControlId,
716         (float)dwPosX,
717         (float)dwPosY,
718         (float)dwWidth,
719         (float)dwHeight,
720         (CStdString)strTextureFocus,
721         (CStdString)strTextureNoFocus,
722         label,
723         (CStdString)strTextureRadioOnFocus,
724         (CStdString)strTextureRadioOnNoFocus,
725         (CStdString)strTextureRadioOffFocus,
726         (CStdString)strTextureRadioOffNoFocus);
727
728       CGUIRadioButtonControl* pGuiButtonControl =
729         (CGUIRadioButtonControl*)pGUIControl;
730
731       pGuiButtonControl->SetLabel(strText);
732
733       return pGUIControl;
734     }
735
736     // ============================================================
737
738     // ============================================================
739     // ============================================================
740     Control::~Control() { deallocating(); }
741
742     CGUIControl* Control::Create() throw (WindowException)
743     {
744       throw WindowException("Object is a Control, but can't be added to a window");
745     }
746
747     std::vector<int> Control::getPosition()
748     {
749       std::vector<int> ret(2);
750       ret[0] = dwPosX;
751       ret[1] = dwPosY;
752       return ret;
753     }
754
755     void Control::setEnabled(bool enabled)
756     {
757       DelayedCallGuard dcguard(languageHook);
758       LOCKGUI;
759       if (pGUIControl)
760         pGUIControl->SetEnabled(enabled);
761     }
762
763     void Control::setVisible(bool visible)
764     {
765       DelayedCallGuard dcguard(languageHook);
766       LOCKGUI;
767       if (pGUIControl)
768         pGUIControl->SetVisible(visible);
769     }
770
771     void Control::setVisibleCondition(const char* visible, bool allowHiddenFocus)
772     {
773       DelayedCallGuard dcguard(languageHook);
774       LOCKGUI;
775
776       if (pGUIControl)
777         pGUIControl->SetVisibleCondition(visible, allowHiddenFocus ? "true" : "false");
778     }
779
780     void Control::setEnableCondition(const char* enable)
781     {
782       DelayedCallGuard dcguard(languageHook);
783       LOCKGUI;
784
785       if (pGUIControl)
786         pGUIControl->SetEnableCondition(enable);
787     }
788
789     void Control::setAnimations(const std::vector< Tuple<String,String> >& eventAttr) throw (WindowException)
790     {
791       CXBMCTinyXML xmlDoc;
792       TiXmlElement xmlRootElement("control");
793       TiXmlNode *pRoot = xmlDoc.InsertEndChild(xmlRootElement);
794       if (!pRoot)
795         throw WindowException("TiXmlNode creation error");
796
797       std::vector<CAnimation> animations;
798
799       for (unsigned int anim = 0; anim < eventAttr.size(); anim++)
800       {
801         const Tuple<String,String>& pTuple = eventAttr[anim];
802
803         if (pTuple.GetNumValuesSet() != 2)
804           throw WindowException("Error unpacking tuple found in list");
805
806         const String& cEvent = pTuple.first();
807         const String& cAttr = pTuple.second();
808
809         TiXmlElement pNode("animation");
810         CStdStringArray attrs;
811         StringUtils::SplitString(cAttr.c_str(), " ", attrs);
812         for (unsigned int i = 0; i < attrs.size(); i++)
813         {
814           CStdStringArray attrs2;
815           StringUtils::SplitString(attrs[i], "=", attrs2);
816           if (attrs2.size() == 2)
817             pNode.SetAttribute(attrs2[0], attrs2[1]);
818         }
819         TiXmlText value(cEvent.c_str());
820         pNode.InsertEndChild(value);
821         pRoot->InsertEndChild(pNode);
822       }
823
824       const CRect animRect((float)dwPosX, (float)dwPosY, (float)dwPosX + dwWidth, (float)dwPosY + dwHeight);
825       LOCKGUI;
826       if (pGUIControl)
827       {
828         CGUIControlFactory::GetAnimations(pRoot, animRect, iParentId, animations);
829         pGUIControl->SetAnimations(animations);
830       }
831     }
832
833     void Control::setPosition(long x, long y)
834     {
835       DelayedCallGuard dcguard(languageHook);
836       LOCKGUI;
837       dwPosX = x;
838       dwPosY = y;
839       if (pGUIControl)
840         pGUIControl->SetPosition((float)dwPosX, (float)dwPosY);
841     }
842
843     void Control::setWidth(long width)
844     {
845       DelayedCallGuard dcguard(languageHook);
846       LOCKGUI;
847       dwWidth = width;
848       if (pGUIControl) 
849         pGUIControl->SetWidth((float)dwWidth);
850     }
851
852     void Control::setHeight(long height)
853     {
854       DelayedCallGuard dcguard(languageHook);
855       LOCKGUI;
856       dwHeight = height;
857       if (pGUIControl) 
858         pGUIControl->SetHeight((float)dwHeight);
859     }
860
861     void Control::setNavigation(const Control* up, const Control* down,
862                                 const Control* left, const Control* right) 
863       throw (WindowException)
864     {
865       if(iControlId == 0)
866         throw WindowException("Control has to be added to a window first");
867
868       iControlUp = up->iControlId;
869       iControlDown = down->iControlId;
870       iControlLeft = left->iControlId;
871       iControlRight = right->iControlId;
872
873       {
874         LOCKGUI;
875         if (pGUIControl)
876           pGUIControl->SetNavigation(iControlUp,iControlDown,iControlLeft,iControlRight);
877       }
878     }
879
880     void Control::controlUp(const Control* control) throw (WindowException)
881     {
882       if(iControlId == 0)
883         throw WindowException("Control has to be added to a window first");
884
885       iControlUp = control->iControlId;
886       {
887         LOCKGUI;
888         if (pGUIControl) 
889           pGUIControl->SetNavigation(iControlUp,iControlDown,iControlLeft,iControlRight);
890       }
891     }
892
893     void Control::controlDown(const Control* control) throw (WindowException)
894     {
895       if(iControlId == 0)
896         throw WindowException("Control has to be added to a window first");
897
898       iControlDown = control->iControlId;
899       {
900         LOCKGUI;
901         if (pGUIControl) 
902           pGUIControl->SetNavigation(iControlUp,iControlDown,iControlLeft,iControlRight);
903       }
904     }
905
906     void Control::controlLeft(const Control* control) throw (WindowException)
907     {
908       if(iControlId == 0)
909         throw WindowException("Control has to be added to a window first");
910
911       iControlLeft = control->iControlId;
912       {
913         LOCKGUI;
914         if (pGUIControl) 
915           pGUIControl->SetNavigation(iControlUp,iControlDown,iControlLeft,iControlRight);
916       }
917     }
918
919     void Control::controlRight(const Control* control) throw (WindowException)
920     {
921       if(iControlId == 0)
922         throw WindowException("Control has to be added to a window first");
923
924       iControlRight = control->iControlId;
925       {
926         LOCKGUI;
927         if (pGUIControl) 
928           pGUIControl->SetNavigation(iControlUp,iControlDown,iControlLeft,iControlRight);
929       }
930     }
931
932     // ============================================================
933     //  ControlSpin
934     // ============================================================
935     ControlSpin::ControlSpin()
936     {
937       // default values for spin control
938       color = 0xffffffff;
939       dwPosX = 0;
940       dwPosY = 0;
941       dwWidth = 16;
942       dwHeight = 16;
943
944       // get default images
945       strTextureUp = XBMCAddonUtils::getDefaultImage((char*)"listcontrol", (char*)"textureup", (char*)"scroll-up.png");
946       strTextureDown = XBMCAddonUtils::getDefaultImage((char*)"listcontrol", (char*)"texturedown", (char*)"scroll-down.png");
947       strTextureUpFocus = XBMCAddonUtils::getDefaultImage((char*)"listcontrol", (char*)"textureupfocus", (char*)"scroll-up-focus.png");
948       strTextureDownFocus = XBMCAddonUtils::getDefaultImage((char*)"listcontrol", (char*)"texturedownfocus", (char*)"scroll-down-focus.png");
949     }
950
951     void ControlSpin::setTextures(const char* up, const char* down, 
952                                   const char* upFocus, 
953                                   const char* downFocus) throw(UnimplementedException)
954     {
955       strTextureUp = up;
956       strTextureDown = down;
957       strTextureUpFocus = upFocus;
958       strTextureDownFocus = downFocus;
959       /*
960         PyXBMCGUILock();
961         if (self->pGUIControl)
962         {
963         CGUISpinControl* pControl = (CGUISpinControl*)self->pGUIControl;
964         pControl->se
965         PyXBMCGUIUnlock();
966       */
967     }
968
969     ControlSpin::~ControlSpin() {}
970     // ============================================================
971
972     // ============================================================
973     //  ControlLabel
974     // ============================================================
975     ControlLabel::ControlLabel(long x, long y, long width, long height, 
976                                const String& label,
977                                const char* font, const char* p_textColor, 
978                                const char* p_disabledColor,
979                                long p_alignment, 
980                                bool hasPath, long angle) :
981       strFont("font13"), 
982       textColor(0xffffffff), disabledColor(0x60ffffff),
983       align(p_alignment), bHasPath(hasPath), iAngle(angle)
984     {
985       dwPosX = x;
986       dwPosY = y;
987       dwWidth = width;
988       dwHeight = height;
989
990       strText = label;
991       if (font)
992         strFont = font;
993
994       if (p_textColor) 
995         sscanf(p_textColor, "%x", &textColor);
996
997       if (p_disabledColor)
998         sscanf( p_disabledColor, "%x", &disabledColor );
999     }
1000
1001     ControlLabel::~ControlLabel() {}
1002
1003     CGUIControl* ControlLabel::Create()  throw (WindowException)
1004     {
1005       CLabelInfo label;
1006       label.font = g_fontManager.GetFont(strFont);
1007       label.textColor = label.focusedColor = textColor;
1008       label.disabledColor = disabledColor;
1009       label.align = align;
1010       label.angle = (float)-iAngle;
1011       pGUIControl = new CGUILabelControl(
1012         iParentId,
1013         iControlId,
1014         (float)dwPosX,
1015         (float)dwPosY,
1016         (float)dwWidth,
1017         (float)dwHeight,
1018         label,
1019         false,
1020         bHasPath);
1021       ((CGUILabelControl *)pGUIControl)->SetLabel(strText);
1022       return pGUIControl;
1023     }    
1024
1025     void ControlLabel::setLabel(const String& label, const char* font,
1026                                 const char* textColor, const char* disabledColor,
1027                                 const char* shadowColor, const char* focusedColor,
1028                                 const String& label2) throw(UnimplementedException)
1029     {
1030       strText = label;
1031       CGUIMessage msg(GUI_MSG_LABEL_SET, iParentId, iControlId);
1032       msg.SetLabel(strText);
1033       g_windowManager.SendThreadMessage(msg, iParentId);
1034     }
1035
1036     String ControlLabel::getLabel() throw(UnimplementedException)
1037     {
1038       if (!pGUIControl) 
1039         return NULL;
1040       return strText;
1041     }
1042     // ============================================================
1043
1044     // ============================================================
1045     //  ControlEdit
1046     // ============================================================
1047     ControlEdit::ControlEdit(long x, long y, long width, long height, const String& label,
1048                              const char* font, const char* _textColor, 
1049                              const char* _disabledColor,
1050                              long _alignment, const char* focusTexture,
1051                              const char* noFocusTexture, bool isPassword) :
1052       strFont("font13"), textColor(0xffffffff), disabledColor(0x60ffffff),
1053       align(_alignment), bIsPassword(isPassword)
1054
1055     {
1056       strTextureFocus = focusTexture ? focusTexture :
1057         XBMCAddonUtils::getDefaultImage((char*)"edit", (char*)"texturefocus", (char*)"button-focus.png");
1058
1059       strTextureNoFocus = noFocusTexture ? noFocusTexture :
1060         XBMCAddonUtils::getDefaultImage((char*)"edit", (char*)"texturenofocus", (char*)"button-focus.png");
1061
1062       if (font) strFont = font;
1063       if (_textColor) sscanf( _textColor, "%x", &textColor );
1064       if (_disabledColor) sscanf( _disabledColor, "%x", &disabledColor );
1065     }
1066
1067     CGUIControl* ControlEdit::Create()  throw (WindowException)
1068     {
1069       CLabelInfo label;
1070       label.font = g_fontManager.GetFont(strFont);
1071       label.textColor = label.focusedColor = textColor;
1072       label.disabledColor = disabledColor;
1073       label.align = align;
1074       pGUIControl = new CGUIEditControl(
1075         iParentId,
1076         iControlId,
1077         (float)dwPosX,
1078         (float)dwPosY,
1079         (float)dwWidth,
1080         (float)dwHeight,
1081         (CStdString)strTextureFocus,
1082         (CStdString)strTextureNoFocus,
1083         label,
1084         strText);
1085
1086       if (bIsPassword)
1087         ((CGUIEditControl *) pGUIControl)->SetInputType(CGUIEditControl::INPUT_TYPE_PASSWORD, 0);
1088       return pGUIControl;
1089     }
1090
1091     void ControlEdit::setLabel(const String& label, const char* font,
1092                                 const char* textColor, const char* disabledColor,
1093                                 const char* shadowColor, const char* focusedColor,
1094                                 const String& label2) throw(UnimplementedException)
1095     {
1096       strText = label;
1097       CGUIMessage msg(GUI_MSG_LABEL_SET, iParentId, iControlId);
1098       msg.SetLabel(strText);
1099       g_windowManager.SendThreadMessage(msg, iParentId);
1100     }
1101
1102     String ControlEdit::getLabel() throw(UnimplementedException)
1103     {
1104       if (!pGUIControl) 
1105         return NULL;
1106       return strText;
1107     }
1108
1109     void ControlEdit::setText(const String& text) throw(UnimplementedException)
1110     {
1111       // create message
1112       CGUIMessage msg(GUI_MSG_LABEL2_SET, iParentId, iControlId);
1113       msg.SetLabel(text);
1114
1115       // send message
1116       g_windowManager.SendThreadMessage(msg, iParentId);
1117     }
1118
1119     String ControlEdit::getText() throw(UnimplementedException)
1120     {
1121       CGUIMessage msg(GUI_MSG_ITEM_SELECTED, iParentId, iControlId);
1122       g_windowManager.SendMessage(msg, iParentId);
1123
1124       return msg.GetLabel();
1125     }
1126
1127     // ============================================================
1128     //  ControlList
1129     // ============================================================
1130     ControlList::ControlList(long x, long y, long width, long height, const char* font,
1131                              const char* ctextColor, const char* cbuttonTexture,
1132                              const char* cbuttonFocusTexture,
1133                              const char* cselectedColor,
1134                              long _imageWidth, long _imageHeight, long _itemTextXOffset,
1135                              long _itemTextYOffset, long _itemHeight, long _space, long _alignmentY) :
1136       strFont("font13"), 
1137       textColor(0xe0f0f0f0), selectedColor(0xffffffff),
1138       imageHeight(_imageHeight), imageWidth(_imageWidth),
1139       itemHeight(_itemHeight), space(_space),
1140       itemTextOffsetX(_itemTextXOffset),itemTextOffsetY(_itemTextYOffset),
1141       alignmentY(_alignmentY)
1142     {
1143       dwPosX = x;
1144       dwPosY = y;
1145       dwWidth = width;
1146       dwHeight = height;
1147
1148       // create a python spin control
1149       pControlSpin = new ControlSpin();
1150
1151       // initialize default values
1152       if (font)
1153         strFont = font;
1154
1155       if (ctextColor)
1156         sscanf( ctextColor, "%x", &textColor );
1157
1158       if (cselectedColor)
1159         sscanf( cselectedColor, "%x", &selectedColor );
1160
1161       strTextureButton = cbuttonTexture ? cbuttonTexture :
1162         XBMCAddonUtils::getDefaultImage((char*)"listcontrol", (char*)"texturenofocus", (char*)"list-nofocus.png");
1163
1164       strTextureButtonFocus = cbuttonFocusTexture ? cbuttonFocusTexture :
1165         XBMCAddonUtils::getDefaultImage((char*)"listcontrol", (char*)"texturefocus", (char*)"list-focus.png");
1166
1167       // default values for spin control
1168       pControlSpin->dwPosX = dwWidth - 35;
1169       pControlSpin->dwPosY = dwHeight - 15;
1170     }
1171
1172     ControlList::~ControlList() { }
1173
1174     CGUIControl* ControlList::Create() throw (WindowException)
1175     {
1176       CLabelInfo label;
1177       label.align = alignmentY;
1178       label.font = g_fontManager.GetFont(strFont);
1179       label.textColor = label.focusedColor = textColor;
1180       //label.shadowColor = shadowColor;
1181       label.selectedColor = selectedColor;
1182       label.offsetX = (float)itemTextOffsetX;
1183       label.offsetY = (float)itemTextOffsetY;
1184       // Second label should have the same font, alignment, and colours as the first, but
1185       // the offsets should be 0.
1186       CLabelInfo label2 = label;
1187       label2.offsetX = label2.offsetY = 0;
1188       label2.align |= XBFONT_RIGHT;
1189
1190       pGUIControl = new CGUIListContainer(
1191         iParentId,
1192         iControlId,
1193         (float)dwPosX,
1194         (float)dwPosY,
1195         (float)dwWidth,
1196         (float)dwHeight - pControlSpin->dwHeight - 5,
1197         label, label2,
1198         (CStdString)strTextureButton,
1199         (CStdString)strTextureButtonFocus,
1200         (float)itemHeight,
1201         (float)imageWidth, (float)imageHeight,
1202         (float)space);
1203
1204       return pGUIControl;
1205     }
1206
1207     void ControlList::addItem(const Alternative<String, const XBMCAddon::xbmcgui::ListItem* > & item, bool sendMessage)
1208     {
1209       XBMC_TRACE;
1210
1211       if (item.which() == first)
1212         internAddListItem(ListItem::fromString(item.former()),sendMessage);
1213       else
1214         internAddListItem(item.later(),sendMessage);
1215     }
1216
1217     void ControlList::addItems(const std::vector<Alternative<String, const XBMCAddon::xbmcgui::ListItem* > > & items)
1218     {
1219       XBMC_TRACE;
1220
1221       for (std::vector<Alternative<String, const XBMCAddon::xbmcgui::ListItem* > >::const_iterator iter = items.begin(); iter != items.end(); ++iter)
1222         addItem(*iter,false);
1223       sendLabelBind(items.size());
1224     }
1225
1226     void ControlList::internAddListItem(AddonClass::Ref<ListItem> pListItem, bool sendMessage) throw (WindowException)
1227     {
1228       if (pListItem.isNull())
1229         throw WindowException("NULL ListItem passed to ControlList::addListItem");
1230
1231       // add item to objects vector
1232       vecItems.push_back(pListItem);
1233
1234       // send all of the items ... this is what it did before.
1235       if (sendMessage)
1236         sendLabelBind(vecItems.size());
1237     }
1238
1239     void ControlList::sendLabelBind(int tail)
1240     {
1241       // construct a CFileItemList to pass 'em on to the list
1242       CGUIListItemPtr items(new CFileItemList());
1243       for (unsigned int i = vecItems.size() - tail; i < vecItems.size(); i++)
1244         ((CFileItemList*)items.get())->Add(vecItems[i]->item);
1245
1246       CGUIMessage msg(GUI_MSG_LABEL_BIND, iParentId, iControlId, 0, 0, items);
1247       msg.SetPointer(items.get());
1248       g_windowManager.SendThreadMessage(msg, iParentId);
1249     }
1250
1251     void ControlList::selectItem(long item) throw(UnimplementedException)
1252     {
1253       // create message
1254       CGUIMessage msg(GUI_MSG_ITEM_SELECT, iParentId, iControlId, item);
1255
1256       // send message
1257       g_windowManager.SendThreadMessage(msg, iParentId);
1258     }
1259
1260     void ControlList::removeItem(int index) throw(UnimplementedException,WindowException)
1261     {
1262       if (index < 0 || index >= (int)vecItems.size())
1263         throw WindowException("Index out of range");
1264
1265       vecItems.erase(vecItems.begin() + index);
1266
1267       sendLabelBind(vecItems.size());
1268     }
1269
1270     void ControlList::reset() throw(UnimplementedException)
1271     {
1272       CGUIMessage msg(GUI_MSG_LABEL_RESET, iParentId, iControlId);
1273
1274       g_windowManager.SendThreadMessage(msg, iParentId);
1275
1276       // delete all items from vector
1277       // delete all ListItem from vector
1278       vecItems.clear(); // this should delete all of the objects
1279     }
1280
1281     Control* ControlList::getSpinControl() throw (UnimplementedException)
1282     {
1283       return pControlSpin;
1284     }
1285
1286     long ControlList::getSelectedPosition() throw(UnimplementedException)
1287     {
1288       DelayedCallGuard dcguard(languageHook);
1289       LOCKGUI;
1290       
1291       // create message
1292       CGUIMessage msg(GUI_MSG_ITEM_SELECTED, iParentId, iControlId);
1293       long pos = -1;
1294
1295       // send message
1296       if ((vecItems.size() > 0) && pGUIControl)
1297       {
1298         pGUIControl->OnMessage(msg);
1299         pos = msg.GetParam1();
1300       }
1301
1302       return pos;
1303     }
1304
1305     XBMCAddon::xbmcgui::ListItem* ControlList::getSelectedItem() throw (UnimplementedException)
1306     {
1307       DelayedCallGuard dcguard(languageHook);
1308       LOCKGUI;
1309
1310       // create message
1311       CGUIMessage msg(GUI_MSG_ITEM_SELECTED, iParentId, iControlId);
1312       AddonClass::Ref<ListItem> pListItem = NULL;
1313
1314       // send message
1315       if ((vecItems.size() > 0) && pGUIControl)
1316       {
1317         pGUIControl->OnMessage(msg);
1318         if (msg.GetParam1() >= 0 && (size_t)msg.GetParam1() < vecItems.size())
1319           pListItem = vecItems[msg.GetParam1()];
1320       }
1321
1322       return pListItem.get();
1323     }
1324
1325     void ControlList::setImageDimensions(long imageWidth,long imageHeight) throw (UnimplementedException)
1326     {
1327       CLog::Log(LOGWARNING,"ControlList::setImageDimensions was called but ... it currently isn't defined to do anything.");
1328       /*
1329         PyXBMCGUILock();
1330         if (self->pGUIControl)
1331         {
1332         CGUIListControl* pListControl = (CGUIListControl*) self->pGUIControl;
1333         pListControl->SetImageDimensions((float)self->dwImageWidth, (float)self->dwImageHeight );
1334         }
1335         PyXBMCGUIUnlock();
1336       */
1337     }
1338
1339     void ControlList::setItemHeight(long height) throw (UnimplementedException)
1340     {
1341       CLog::Log(LOGWARNING,"ControlList::setItemHeight was called but ... it currently isn't defined to do anything.");
1342       /*
1343         PyXBMCGUILock();
1344         if (self->pGUIControl)
1345         {
1346         CGUIListControl* pListControl = (CGUIListControl*) self->pGUIControl;
1347         pListControl->SetItemHeight((float)self->dwItemHeight);
1348         }
1349         PyXBMCGUIUnlock();
1350       */
1351     }
1352
1353     void ControlList::setSpace(int space) throw (UnimplementedException)
1354     {
1355       CLog::Log(LOGWARNING,"ControlList::setSpace was called but ... it currently isn't defined to do anything.");
1356       /*
1357         PyXBMCGUILock();
1358         if (self->pGUIControl)
1359         {
1360         CGUIListControl* pListControl = (CGUIListControl*) self->pGUIControl;
1361         pListControl->SetSpaceBetweenItems((float)self->dwSpace);
1362         }
1363         PyXBMCGUIUnlock();
1364       */
1365     }
1366
1367     void ControlList::setPageControlVisible(bool visible) throw (UnimplementedException)
1368     {
1369       CLog::Log(LOGWARNING,"ControlList::setPageControlVisible was called but ... it currently isn't defined to do anything.");
1370
1371       //      char isOn = true;
1372
1373       /*
1374         PyXBMCGUILock();
1375         if (self->pGUIControl)
1376         {
1377         ((CGUIListControl*)self->pGUIControl)->SetPageControlVisible((bool)isOn );
1378         }
1379         PyXBMCGUIUnlock();
1380       */
1381     }
1382
1383     long ControlList::size() throw (UnimplementedException)
1384     {
1385       return (long)vecItems.size();
1386     }
1387
1388     long ControlList::getItemHeight() throw(UnimplementedException)
1389     {
1390       return (long)itemHeight;
1391     }
1392
1393     long ControlList::getSpace() throw (UnimplementedException)
1394     {
1395       return (long)space;
1396     }
1397
1398     XBMCAddon::xbmcgui::ListItem* ControlList::getListItem(int index) throw (UnimplementedException,WindowException)
1399     {
1400       if (index < 0 || index >= (int)vecItems.size())
1401         throw WindowException("Index out of range");
1402
1403       AddonClass::Ref<ListItem> pListItem = vecItems[index];
1404       return pListItem.get();
1405     }
1406
1407     void ControlList::setStaticContent(const ListItemList* pitems) throw (UnimplementedException)
1408     {
1409       const ListItemList& vecItems = *pitems;
1410
1411       std::vector<CGUIStaticItemPtr> items;
1412
1413       for (unsigned int item = 0; item < vecItems.size(); item++)
1414       {
1415         ListItem* pItem = vecItems[item];
1416
1417         // NOTE: This code has likely not worked fully correctly for some time
1418         //       In particular, the click behaviour won't be working.
1419         CGUIStaticItemPtr newItem(new CGUIStaticItem(*pItem->item));
1420         items.push_back(newItem);
1421       }
1422
1423       // set static list
1424       IListProvider *provider = new CStaticListProvider(items);
1425       ((CGUIBaseContainer *)pGUIControl)->SetListProvider(provider);
1426     }
1427
1428     // ============================================================
1429
1430   }
1431 }