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