2 * Copyright (C) 2005-2013 Team XBMC
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)
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.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 #include "guilib/GUIControl.h"
25 #include "guilib/GUIFont.h"
26 #include "guilib/Key.h"
30 #include "swighelper.h"
31 #include "WindowException.h"
35 // hardcoded offsets for button controls (and controls that use button controls)
36 // ideally they should be dynamically read in as with all the other properties.
37 #define CONTROL_TEXT_OFFSET_X 10
38 #define CONTROL_TEXT_OFFSET_Y 2
46 * Parent for control classes. The problem here is that Python uses
47 * references to this class in a dynamic typing way. For example,
48 * you will find this type of python code frequently:
50 * window.getControl( 100 ).setLabel( "Stupid Dynamic Type")
52 * Notice that the 'getControl' call returns a 'Control' object.
53 * In a dynamically typed language, the subsequent call to setLabel
54 * works if the specific type of control has the method. The script
55 * writer is often in a position to know more than the code about
56 * the specific Control type (in the example, that control id 100
57 * is a 'ControlLabel') where the C++ code is not.
59 * SWIG doesn't support this type of dynamic typing. The 'Control'
60 * wrapper that's returned will wrap a ControlLabel but will not
61 * have the 'setLabel' method on it. The only way to handle this is
62 * to add all possible subclass methods to the parent class. This is
63 * ugly but the alternative is nearly as ugly. It's particularly ugly
64 * here because the majority of the methods are unique to the
65 * particular subclass.
67 * If anyone thinks they have a solution then let me know. The alternative
68 * would be to have a set of 'getContol' methods, each one coresponding
69 * to a type so that the downcast can be done in the native code. IOW
70 * rather than a simple 'getControl' there would be a 'getControlLabel',
71 * 'getControlRadioButton', 'getControlButton', etc.
73 * TODO:This later solution should be implemented for future scripting
74 * languages while the former will remain as deprecated functionality
77 // We don't need the SWIGHIDDENVIRTUAL since this is not a director.
78 class Control : public AddonClass
82 Control(const char* classname) : AddonClass(classname),
83 iControlId(0), iParentId(0), dwPosX(0), dwPosY(0), dwWidth(0),
84 dwHeight(0), iControlUp(0), iControlDown(0), iControlLeft(0),
85 iControlRight(0), pGUIControl(NULL) {}
90 virtual CGUIControl* Create() throw (WindowException);
93 // currently we only accept messages from a button or controllist with a select action
94 virtual bool canAcceptMessages(int actionId) { return false; }
96 virtual void setLabel(const String& label = emptyString,
97 const char* font = NULL,
98 const char* textColor = NULL,
99 const char* disabledColor = NULL,
100 const char* shadowColor = NULL,
101 const char* focusedColor = NULL,
102 const String& label2 = emptyString) DECL_UNIMP("Control");
103 virtual void reset() DECL_UNIMP("Control");
104 virtual void setSelected(bool selected) DECL_UNIMP("Control");
105 virtual void setPercent(float pct) DECL_UNIMP("Control");
106 virtual void setDisabledColor(const char* color) DECL_UNIMP("Control");
107 virtual float getPercent() DECL_UNIMP("Control");
108 virtual String getLabel() DECL_UNIMP("Control");
109 virtual String getText() DECL_UNIMP("Control");
110 virtual long size() DECL_UNIMP("Control");
111 virtual void setTextures(const char* up, const char* down,
113 const char* downFocus) DECL_UNIMP("Control");
114 virtual void setText(const String& text) DECL_UNIMP("Control");
115 virtual void setStaticContent(const ListItemList* items) DECL_UNIMP("Control");
116 virtual void setSpace(int space) DECL_UNIMP("Control");
117 virtual void setRadioDimension(long x, long y, long width, long height) DECL_UNIMP("Control");
118 virtual void setPageControlVisible(bool visible) DECL_UNIMP("Control");
119 virtual void setItemHeight(long height) DECL_UNIMP("Control");
120 virtual void setImageDimensions(long imageWidth,long imageHeight) DECL_UNIMP("Control");
121 virtual void setImage(const char* imageFilename) DECL_UNIMP("Control");
122 virtual void setColorDiffuse(const char* hexString) DECL_UNIMP("Control");
123 virtual void selectItem(long item) DECL_UNIMP("Control");
124 virtual void scroll(long id) DECL_UNIMP("Control");
125 virtual bool isSelected() DECL_UNIMP("Control");
126 virtual Control* getSpinControl() DECL_UNIMP("Control");
127 virtual long getSpace() DECL_UNIMP("Control");
128 virtual long getSelectedPosition() DECL_UNIMP("Control");
129 virtual XBMCAddon::xbmcgui::ListItem* getSelectedItem() DECL_UNIMP("Control");
130 virtual bool getSelected() DECL_UNIMP("Control");
131 virtual XBMCAddon::xbmcgui::ListItem* getListItem(int index) DECL_UNIMP2("Control",WindowException);
132 virtual String getLabel2() DECL_UNIMP("Control");
133 virtual long getItemHeight() DECL_UNIMP("Control");
134 virtual void addLabel(const String& label) DECL_UNIMP("Control");
136 // These need to be here for the stubbed out addItem
137 // and addItems methods
138 virtual void addItemStream(const String& fileOrUrl, bool sendMessage = true) DECL_UNIMP2("Control",WindowException);
139 virtual void addListItem(const XBMCAddon::xbmcgui::ListItem* listitem, bool sendMessage = true) DECL_UNIMP2("Control",WindowException);
142 * getId() -- Returns the control's current id as an integer.
145 * - id = self.button.getId()\n
147 virtual int getId() { return iControlId; }
149 inline bool operator==(const Control& other) const { return iControlId == other.iControlId; }
150 inline bool operator>(const Control& other) const { return iControlId > other.iControlId; }
151 inline bool operator<(const Control& other) const { return iControlId < other.iControlId; }
153 // hack this because it returns a tuple
155 * getPosition() -- Returns the control's current position as a x,y integer tuple.
158 * - pos = self.button.getPosition()
160 virtual std::vector<int> getPosition();
161 virtual int getX() { return dwPosX; }
162 virtual int getY() { return dwPosY; }
165 * getHeight() -- Returns the control's current height as an integer.
168 * - height = self.button.getHeight()
170 virtual int getHeight() { return dwHeight; }
174 * getWidth() -- Returns the control's current width as an integer.
177 * - width = self.button.getWidth()
179 virtual int getWidth() { return dwWidth; }
181 // setEnabled() Method
183 * setEnabled(enabled) -- Set's the control's enabled/disabled state.
185 * enabled : bool - True=enabled / False=disabled.
188 * - self.button.setEnabled(False)\n
190 virtual void setEnabled(bool enabled);
192 // setVisible() Method
194 * setVisible(visible) -- Set's the control's visible/hidden state.
196 * visible : bool - True=visible / False=hidden.
199 * - self.button.setVisible(False)
201 virtual void setVisible(bool visible);
203 // setVisibleCondition() Method
205 * setVisibleCondition(visible[,allowHiddenFocus]) -- Set's the control's visible condition.
206 * Allows XBMC to control the visible status of the control.
208 * visible : string - Visible condition.
209 * allowHiddenFocus : bool - True=gains focus even if hidden.
211 * List of Conditions - http://wiki.xbmc.org/index.php?title=List_of_Boolean_Conditions
214 * - self.button.setVisibleCondition('[Control.IsVisible(41) + !Control.IsVisible(12)]', True)\n
216 virtual void setVisibleCondition(const char* visible, bool allowHiddenFocus = false);
218 // setEnableCondition() Method
220 * setEnableCondition(enable) -- Set's the control's enabled condition.
221 * Allows XBMC to control the enabled status of the control.
223 * enable : string - Enable condition.
225 * List of Conditions - http://wiki.xbmc.org/index.php?title=List_of_Boolean_Conditions
228 * - self.button.setEnableCondition('System.InternetState')
230 virtual void setEnableCondition(const char* enable);
232 // setAnimations() Method
234 * setAnimations([(event, attr,)*]) -- Set's the control's animations.
236 * [(event,attr,)*] : list - A list of tuples consisting of event and attributes pairs.
237 * - event : string - The event to animate.
238 * - attr : string - The whole attribute string separated by spaces.
240 * Animating your skin - http://wiki.xbmc.org/?title=Animating_Your_Skin
243 * - self.button.setAnimations([('focus', 'effect=zoom end=90,247,220,56 time=0',)])\n
245 virtual void setAnimations(const std::vector< Tuple<String,String> >& eventAttr) throw (WindowException);
247 // setPosition() Method
249 * setPosition(x, y) -- Set's the controls position.
251 * x : integer - x coordinate of control.
252 * y : integer - y coordinate of control.
254 * *Note, You may use negative integers. (e.g sliding a control into view)
257 * - self.button.setPosition(100, 250)\n
259 virtual void setPosition(long x, long y);
263 * setWidth(width) -- Set's the controls width.
265 * width : integer - width of control.
268 * - self.image.setWidth(100)
270 virtual void setWidth(long width);
272 // setHeight() Method
274 * setHeight(height) -- Set's the controls height.
276 * height : integer - height of control.
279 * - self.image.setHeight(100)
281 virtual void setHeight(long height);
283 // setNavigation() Method
285 * setNavigation(up, down, left, right) -- Set's the controls navigation.
287 * up : control object - control to navigate to on up.
288 * down : control object - control to navigate to on down.
289 * left : control object - control to navigate to on left.
290 * right : control object - control to navigate to on right.
292 * *Note, Same as controlUp(), controlDown(), controlLeft(), controlRight().
293 * Set to self to disable navigation for that direction.
295 * Throws: TypeError, if one of the supplied arguments is not a control type.
296 * ReferenceError, if one of the controls is not added to a window.
299 * - self.button.setNavigation(self.button1, self.button2, self.button3, self.button4)
301 virtual void setNavigation(const Control* up, const Control* down,
302 const Control* left, const Control* right)
303 throw (WindowException);
305 // controlUp() Method
307 * controlUp(control) -- Set's the controls up navigation.
309 * control : control object - control to navigate to on up.
311 * *Note, You can also use setNavigation(). Set to self to disable navigation.
313 * Throws: TypeError, if one of the supplied arguments is not a control type.
314 * ReferenceError, if one of the controls is not added to a window.
317 * - self.button.controlUp(self.button1)
319 virtual void controlUp(const Control* up) throw (WindowException);
321 // controlDown() Method
323 * controlDown(control) -- Set's the controls down navigation.
325 * control : control object - control to navigate to on down.
327 * *Note, You can also use setNavigation(). Set to self to disable navigation.
329 * Throws: TypeError, if one of the supplied arguments is not a control type.
330 * ReferenceError, if one of the controls is not added to a window.
333 * - self.button.controlDown(self.button1)
335 virtual void controlDown(const Control* control) throw (WindowException);
337 // controlLeft() Method
339 * controlLeft(control) -- Set's the controls left navigation.
341 * control : control object - control to navigate to on left.
343 * *Note, You can also use setNavigation(). Set to self to disable navigation.
345 * Throws: TypeError, if one of the supplied arguments is not a control type.
346 * ReferenceError, if one of the controls is not added to a window.
349 * - self.button.controlLeft(self.button1)
351 virtual void controlLeft(const Control* control) throw (WindowException);
353 // controlRight() Method
355 * controlRight(control) -- Set's the controls right navigation.
357 * control : control object - control to navigate to on right.
359 * *Note, You can also use setNavigation(). Set to self to disable navigation.
361 * Throws: TypeError, if one of the supplied arguments is not a control type.
362 * ReferenceError, if one of the controls is not added to a window.
365 * - self.button.controlRight(self.button1)\n
367 virtual void controlRight(const Control* control) throw (WindowException);
380 CGUIControl* pGUIControl;
388 * - Not working yet -.
390 * you can't create this object, it is returned by objects like ControlTextBox and ControlList.
392 class ControlSpin : public Control
395 virtual ~ControlSpin();
398 * setTextures(up, down, upFocus, downFocus) -- Set's textures for this control.
400 * texture are image files that are used for example in the skin
402 virtual void setTextures(const char* up, const char* down,
404 const char* downFocus) throw(UnimplementedException);
407 std::string strTextureUp;
408 std::string strTextureDown;
409 std::string strTextureUpFocus;
410 std::string strTextureDownFocus;
417 friend class ControlList;
422 * ControlLabel class.
424 * ControlLabel(x, y, width, height, label[, font, textColor,
425 * disabledColor, alignment, hasPath, angle])
427 * x : integer - x coordinate of control.
428 * y : integer - y coordinate of control.
429 * width : integer - width of control.
430 * height : integer - height of control.
431 * label : string or unicode - text string.
432 * font : [opt] string - font used for label text. (e.g. 'font13')
433 * textColor : [opt] hexstring - color of enabled label's label. (e.g. '0xFFFFFFFF')
434 * disabledColor : [opt] hexstring - color of disabled label's label. (e.g. '0xFFFF3300')
435 * alignment : [opt] integer - alignment of label - *Note, see xbfont.h
436 * hasPath : [opt] bool - True=stores a path / False=no path.
437 * angle : [opt] integer - angle of control. (+ rotates CCW, - rotates C
440 * - self.label = xbmcgui.ControlLabel(100, 250, 125, 75, 'Status', angle=45)\n
442 class ControlLabel : public Control
445 ControlLabel(long x, long y, long width, long height, const String& label,
446 const char* font = NULL, const char* textColor = NULL,
447 const char* disabledColor = NULL,
448 long alignment = XBFONT_LEFT,
449 bool hasPath = false, long angle = 0);
451 virtual ~ControlLabel();
454 * getLabel() -- Returns the text value for this label.
457 * - label = self.label.getLabel()\n
459 virtual String getLabel() throw(UnimplementedException);
462 * setLabel(label) -- Set's text for this label.
464 * label : string or unicode - text string.
467 * - self.label.setLabel('Status')
469 virtual void setLabel(const String& label = emptyString,
470 const char* font = NULL,
471 const char* textColor = NULL,
472 const char* disabledColor = NULL,
473 const char* shadowColor = NULL,
474 const char* focusedColor = NULL,
475 const String& label2 = emptyString) throw(UnimplementedException);
477 ControlLabel() : Control("ControlLabel") {}
482 color_t disabledColor;
487 SWIGHIDDENVIRTUAL CGUIControl* Create() throw (WindowException);
495 * ControlEdit(x, y, width, height, label[, font, textColor,
496 * disabledColor, alignment, focusTexture, noFocusTexture])
498 * x : integer - x coordinate of control.
499 * y : integer - y coordinate of control.
500 * width : integer - width of control.
501 * height : integer - height of control.
502 * label : string or unicode - text string.
503 * font : [opt] string - font used for label text. (e.g. 'font13')
504 * textColor : [opt] hexstring - color of enabled label's label. (e.g. '0xFFFFFFFF')
505 * disabledColor : [opt] hexstring - color of disabled label's label. (e.g. '0xFFFF3300')
506 * alignment : [opt] integer - alignment of label - *Note, see xbfont.h
507 * focusTexture : [opt] string - filename for focus texture.
508 * noFocusTexture : [opt] string - filename for no focus texture.
509 * isPassword : [opt] bool - if true, mask text value.
511 * *Note, You can use the above as keywords for arguments and skip certain optional arguments.
512 * Once you use a keyword, all following arguments require the keyword.
513 * After you create the control, you need to add it to the window with addControl().
516 * - self.edit = xbmcgui.ControlEdit(100, 250, 125, 75, 'Status')
518 class ControlEdit : public Control
521 ControlEdit(long x, long y, long width, long height, const String& label,
522 const char* font = NULL, const char* textColor = NULL,
523 const char* disabledColor = NULL,
524 long _alignment = XBFONT_LEFT, const char* focusTexture = NULL,
525 const char* noFocusTexture = NULL, bool isPassword = false);
530 * setLabel(label) -- Set's text heading for this edit control.
532 * label : string or unicode - text string.
535 * - self.edit.setLabel('Status')\n
537 virtual void setLabel(const String& label = emptyString,
538 const char* font = NULL,
539 const char* textColor = NULL,
540 const char* disabledColor = NULL,
541 const char* shadowColor = NULL,
542 const char* focusedColor = NULL,
543 const String& label2 = emptyString) throw(UnimplementedException);
547 * getLabel() -- Returns the text heading for this edit control.
550 * - label = self.edit.getLabel()
552 virtual String getLabel() throw(UnimplementedException);
556 * setText(value) -- Set's text value for this edit control.
558 * value : string or unicode - text string.
561 * - self.edit.setText('online')\n
563 virtual void setText(const String& text) throw(UnimplementedException);
567 * getText() -- Returns the text value for this edit control.
570 * - value = self.edit.getText()
572 virtual String getText() throw(UnimplementedException);
575 ControlEdit() : Control("ControlEdit") {}
579 std::string strTextureFocus;
580 std::string strTextureNoFocus;
582 color_t disabledColor;
586 SWIGHIDDENVIRTUAL CGUIControl* Create() throw (WindowException);
593 * ControlList(x, y, width, height[, font, textColor, buttonTexture, buttonFocusTexture,
594 * selectedColor, imageWidth, imageHeight, itemTextXOffset, itemTextYOffset,
595 * itemHeight, space, alignmentY])\n"//, shadowColor])
597 * x : integer - x coordinate of control.
598 * y : integer - y coordinate of control.
599 * width : integer - width of control.
600 * height : integer - height of control.
601 * font : [opt] string - font used for items label. (e.g. 'font13')
602 * textColor : [opt] hexstring - color of items label. (e.g. '0xFFFFFFFF')
603 * buttonTexture : [opt] string - filename for focus texture.
604 * buttonFocusTexture : [opt] string - filename for no focus texture.
605 * selectedColor : [opt] integer - x offset of label.
606 * imageWidth : [opt] integer - width of items icon or thumbnail.
607 * imageHeight : [opt] integer - height of items icon or thumbnail.
608 * itemTextXOffset : [opt] integer - x offset of items label.
609 * itemTextYOffset : [opt] integer - y offset of items label.
610 * itemHeight : [opt] integer - height of items.
611 * space : [opt] integer - space between items.
612 * alignmentY : [opt] integer - Y-axis alignment of items label - *Note, see xbfont.h
613 * //"shadowColor : [opt] hexstring - color of items label's shadow. (e.g. '0xFF000000')
615 * *Note, You can use the above as keywords for arguments and skip certain optional arguments.
616 * Once you use a keyword, all following arguments require the keyword.
617 * After you create the control, you need to add it to the window with addControl().
620 * - self.cList = xbmcgui.ControlList(100, 250, 200, 250, 'font14', space=5)
622 class ControlList : public Control
624 void internAddListItem(AddonClass::Ref<ListItem> listitem, bool sendMessage) throw(WindowException);
627 ControlList(long x, long y, long width, long height, const char* font = NULL,
628 const char* textColor = NULL, const char* buttonTexture = NULL,
629 const char* buttonFocusTexture = NULL,
630 const char* selectedColor = NULL,
631 long _imageWidth=10, long _imageHeight=10, long _itemTextXOffset = CONTROL_TEXT_OFFSET_X,
632 long _itemTextYOffset = CONTROL_TEXT_OFFSET_Y, long _itemHeight = 27, long _space = 2,
633 long _alignmentY = XBFONT_CENTER_Y);
635 virtual ~ControlList();
638 * addItem(item) -- Add a new item to this list control.
640 * item : string, unicode or ListItem - item to add.
643 * - cList.addItem('Reboot XBMC')
645 virtual void addItemStream(const String& fileOrUrl, bool sendMessage = true) throw(UnimplementedException,WindowException);
646 virtual void addListItem(const XBMCAddon::xbmcgui::ListItem* listitem, bool sendMessage = true) throw(UnimplementedException,WindowException);
649 * selectItem(item) -- Select an item by index number.
651 * item : integer - index number of the item to select.
654 * - cList.selectItem(12)
656 virtual void selectItem(long item) throw(UnimplementedException);
659 * reset() -- Clear all ListItems in this control list.
664 virtual void reset() throw (UnimplementedException);
667 * getSpinControl() -- returns the associated ControlSpin object.
669 * *Note, Not working completely yet -
670 * After adding this control list to a window it is not possible to change
671 * the settings of this spin control.
674 * - ctl = cList.getSpinControl()
676 virtual Control* getSpinControl() throw (UnimplementedException);
679 * getSelectedPosition() -- Returns the position of the selected item as an integer.
681 * *Note, Returns -1 for empty lists.
684 * - pos = cList.getSelectedPosition()
686 virtual long getSelectedPosition() throw (UnimplementedException);
689 * getSelectedItem() -- Returns the selected item as a ListItem object.
691 * *Note, Same as getSelectedPosition(), but instead of an integer a ListItem object
692 * is returned. Returns None for empty lists.
693 * See windowexample.py on how to use this.
696 * - item = cList.getSelectedItem()
698 virtual XBMCAddon::xbmcgui::ListItem* getSelectedItem() throw (UnimplementedException);
701 // setImageDimensions() method
703 * setImageDimensions(imageWidth, imageHeight) -- Sets the width/height of items icon or thumbnail.
705 * imageWidth : [opt] integer - width of items icon or thumbnail.
706 * imageHeight : [opt] integer - height of items icon or thumbnail.
709 * - cList.setImageDimensions(18, 18)\n
711 virtual void setImageDimensions(long imageWidth,long imageHeight) throw (UnimplementedException);
713 // setItemHeight() method
715 * setItemHeight(itemHeight) -- Sets the height of items.
717 * itemHeight : integer - height of items.
720 * - cList.setItemHeight(25)
722 virtual void setItemHeight(long height) throw (UnimplementedException);
726 * setSpace(space) -- Set's the space between items.
728 * space : [opt] integer - space between items.
731 * - cList.setSpace(5)
733 virtual void setSpace(int space) throw (UnimplementedException);
735 // setPageControlVisible() method
737 * setPageControlVisible(visible) -- Sets the spin control's visible/hidden state.
739 * visible : boolean - True=visible / False=hidden.
742 * - cList.setPageControlVisible(True)
744 virtual void setPageControlVisible(bool visible) throw(UnimplementedException);
748 * size() -- Returns the total number of items in this list control as an integer.
751 * - cnt = cList.size()
753 virtual long size() throw (UnimplementedException);
756 // getItemHeight() Method
758 * getItemHeight() -- Returns the control's current item height as an integer.
761 * - item_height = self.cList.getItemHeight()\n
763 virtual long getItemHeight() throw(UnimplementedException);
767 * getSpace() -- Returns the control's space between items as an integer.
770 * - gap = self.cList.getSpace()\n
772 virtual long getSpace() throw (UnimplementedException);
774 // getListItem() method
776 * getListItem(index) -- Returns a given ListItem in this List.
778 * index : integer - index number of item to return.
780 * *Note, throws a ValueError if index is out of range.
783 * - listitem = cList.getListItem(6)\n
785 virtual XBMCAddon::xbmcgui::ListItem* getListItem(int index) throw (UnimplementedException,WindowException);
788 * setStaticContent(items) -- Fills a static list with a list of listitems.
790 * items : List - list of listitems to add.
792 * *Note, You can use the above as keywords for arguments.
795 * - cList.setStaticContent(items=listitems)\n
797 virtual void setStaticContent(const ListItemList* items) throw (UnimplementedException);
800 void sendLabelBind(int tail);
802 SWIGHIDDENVIRTUAL bool canAcceptMessages(int actionId)
803 { return ((actionId == ACTION_SELECT_ITEM) | (actionId == ACTION_MOUSE_LEFT_CLICK)); }
805 // This is called from AddonWindow.cpp but shouldn't be available
806 // to the scripting languages.
807 ControlList() : Control("ControlList") {}
809 std::vector<AddonClass::Ref<ListItem> > vecItems;
811 AddonClass::Ref<ControlSpin> pControlSpin;
814 color_t selectedColor;
815 std::string strTextureButton;
816 std::string strTextureButtonFocus;
827 SWIGHIDDENVIRTUAL CGUIControl* Create() throw (WindowException);
831 // ControlFadeLabel class
833 * ControlFadeLabel class.
834 * Control that scroll's labl
836 * ControlFadeLabel(x, y, width, height[, font, textColor, alignment])
838 * x : integer - x coordinate of control.
839 * y : integer - y coordinate of control.
840 * width : integer - width of control.
841 * height : integer - height of control.
842 * font : [opt] string - font used for label text. (e.g. 'font13')
843 * textColor : [opt] hexstring - color of fadelabel's labels. (e.g. '0xFFFFFFFF')
844 * alignment : [opt] integer - alignment of label - *Note, see xbfont.h
846 * *Note, You can use the above as keywords for arguments and skip certain optional arguments.
847 * Once you use a keyword, all following arguments require the keyword.
848 * After you create the control, you need to add it to the window with addControl().
851 * - self.fadelabel = xbmcgui.ControlFadeLabel(100, 250, 200, 50, textColor='0xFFFFFFFF')
853 class ControlFadeLabel : public Control
856 ControlFadeLabel(long x, long y, long width, long height,
857 const char* font = NULL,
858 const char* textColor = NULL,
859 long _alignment = XBFONT_LEFT);
863 * addLabel(label) -- Add a label to this control for scrolling.
865 * label : string or unicode - text string.
868 * - self.fadelabel.addLabel('This is a line of text that can scroll.')
870 virtual void addLabel(const String& label) throw (UnimplementedException);
873 * reset() -- Clear this fade label.
876 * - self.fadelabel.reset()\n
878 virtual void reset() throw (UnimplementedException);
883 std::vector<std::string> vecLabels;
886 SWIGHIDDENVIRTUAL CGUIControl* Create() throw (WindowException);
888 ControlFadeLabel() : Control("ControlFadeLabel") {}
893 * ControlTextBox class.
895 * ControlTextBox(x, y, width, height[, font, textColor])
897 * x : integer - x coordinate of control.
898 * y : integer - y coordinate of control.
899 * width : integer - width of control.
900 * height : integer - height of control.
901 * font : [opt] string - font used for text. (e.g. 'font13')
902 * textColor : [opt] hexstring - color of textbox's text. (e.g. '0xFFFFFFFF')
904 * *Note, You can use the above as keywords for arguments and skip certain optional arguments.
905 * Once you use a keyword, all following arguments require the keyword.
906 * After you create the control, you need to add it to the window with addControl().
909 * - self.textbox = xbmcgui.ControlTextBox(100, 250, 300, 300, textColor='0xFFFFFFFF')
911 class ControlTextBox : public Control
914 ControlTextBox(long x, long y, long width, long height,
915 const char* font = NULL,
916 const char* textColor = NULL);
920 * setText(text) -- Set's the text for this textbox.
922 * text : string or unicode - text string.
925 * - self.textbox.setText('This is a line of text that can wrap.')
927 virtual void setText(const String& text) throw(UnimplementedException);
931 * reset() -- Clear's this textbox.
934 * - self.textbox.reset()\n
936 virtual void reset() throw(UnimplementedException);
940 * scroll(position) -- Scrolls to the given position.
942 * id : integer - position to scroll to.
945 * - self.textbox.scroll(10)
947 virtual void scroll(long id) throw(UnimplementedException);
953 SWIGHIDDENVIRTUAL CGUIControl* Create() throw (WindowException);
955 ControlTextBox() : Control("ControlTextBox") {}
959 // ControlImage class
961 * ControlImage class.
963 * ControlImage(x, y, width, height, filename[, aspectRatio, colorDiffuse])
965 * x : integer - x coordinate of control.
966 * y : integer - y coordinate of control.
967 * width : integer - width of control.
968 * height : integer - height of control.
969 * filename : string - image filename.
970 * aspectRatio : [opt] integer - (values 0 = stretch (default), 1 = scale up (crops), 2 = scale down (black bar
971 * colorDiffuse : hexString - (example, '0xC0FF0000' (red tint))
973 * *Note, You can use the above as keywords for arguments and skip certain optional arguments.
974 * Once you use a keyword, all following arguments require the keyword.
975 * After you create the control, you need to add it to the window with addControl().
978 * - self.image = xbmcgui.ControlImage(100, 250, 125, 75, aspectRatio=2)
980 class ControlImage : public Control
983 ControlImage(long x, long y, long width, long height,
984 const char* filename, long aspectRatio = 0,
985 const char* colorDiffuse = NULL);
988 * setImage(filename) -- Changes the image.
990 * filename : string - image filename.
993 * - self.image.setImage('special://home/scripts/test.png')
995 virtual void setImage(const char* imageFilename) throw (UnimplementedException);
998 * setColorDiffuse(colorDiffuse) -- Changes the images color.
1000 * colorDiffuse : hexString - (example, '0xC0FF0000' (red tint))
1003 * - self.image.setColorDiffuse('0xC0FF0000')
1005 virtual void setColorDiffuse(const char* hexString) throw (UnimplementedException);
1008 ControlImage() : Control("ControlImage") {}
1010 std::string strFileName;
1012 color_t colorDiffuse;
1014 SWIGHIDDENVIRTUAL CGUIControl* Create() throw (WindowException);
1018 class ControlProgress : public Control
1021 ControlProgress(long x, long y, long width, long height,
1022 const char* texturebg = NULL,
1023 const char* textureleft = NULL,
1024 const char* texturemid = NULL,
1025 const char* textureright = NULL,
1026 const char* textureoverlay = NULL);
1029 * setPercent(percent) -- Sets the percentage of the progressbar to show.
1031 * percent : float - percentage of the bar to show.
1033 * *Note, valid range for percent is 0-100
1036 * - self.progress.setPercent(60)
1038 virtual void setPercent(float pct) throw (UnimplementedException);
1041 * getPercent() -- Returns a float of the percent of the progress.
1044 * - print self.progress.getValue()
1046 virtual float getPercent() throw (UnimplementedException);
1049 std::string strTextureLeft;
1050 std::string strTextureMid;
1051 std::string strTextureRight;
1052 std::string strTextureBg;
1053 std::string strTextureOverlay;
1055 color_t colorDiffuse;
1057 SWIGHIDDENVIRTUAL CGUIControl* Create() throw (WindowException);
1058 ControlProgress() : Control("ControlProgress") {}
1062 // ControlButton class
1064 * ControlButton class.
1066 * ControlButton(x, y, width, height, label[, focusTexture, noFocusTexture, textOffsetX, textOffsetY,
1067 * alignment, font, textColor, disabledColor, angle, shadowColor, focusedColor])
1069 * x : integer - x coordinate of control.
1070 * y : integer - y coordinate of control.
1071 * width : integer - width of control.
1072 * height : integer - height of control.
1073 * label : string or unicode - text string.
1074 * focusTexture : [opt] string - filename for focus texture.
1075 * noFocusTexture : [opt] string - filename for no focus texture.
1076 * textOffsetX : [opt] integer - x offset of label.
1077 * textOffsetY : [opt] integer - y offset of label.
1078 * alignment : [opt] integer - alignment of label - *Note, see xbfont.h
1079 * font : [opt] string - font used for label text. (e.g. 'font13')
1080 * textColor : [opt] hexstring - color of enabled button's label. (e.g. '0xFFFFFFFF')
1081 * disabledColor : [opt] hexstring - color of disabled button's label. (e.g. '0xFFFF3300')
1082 * angle : [opt] integer - angle of control. (+ rotates CCW, - rotates CW)
1083 * shadowColor : [opt] hexstring - color of button's label's shadow. (e.g. '0xFF000000')
1084 * focusedColor : [opt] hexstring - color of focused button's label. (e.g. '0xFF00FFFF')
1086 * *Note, You can use the above as keywords for arguments and skip certain optional arguments.
1087 * Once you use a keyword, all following arguments require the keyword.
1088 * After you create the control, you need to add it to the window with addControl().
1091 * - self.button = xbmcgui.ControlButton(100, 250, 200, 50, 'Status', font='font14')
1093 class ControlButton : public Control
1096 ControlButton(long x, long y, long width, long height, const String& label,
1097 const char* focusTexture = NULL, const char* noFocusTexture = NULL,
1098 long textOffsetX = CONTROL_TEXT_OFFSET_X,
1099 long textOffsetY = CONTROL_TEXT_OFFSET_Y,
1100 long alignment = (XBFONT_LEFT | XBFONT_CENTER_Y),
1101 const char* font = NULL, const char* textColor = NULL,
1102 const char* disabledColor = NULL, long angle = 0,
1103 const char* shadowColor = NULL, const char* focusedColor = NULL);
1105 // setLabel() Method
1107 * setLabel([label, font, textColor, disabledColor, shadowColor, focusedColor]) -- Set's this buttons text attributes.
1109 * label : [opt] string or unicode - text string.
1110 * font : [opt] string - font used for label text. (e.g. 'font13')
1111 * textColor : [opt] hexstring - color of enabled button's label. (e.g. '0xFFFFFFFF')
1112 * disabledColor : [opt] hexstring - color of disabled button's label. (e.g. '0xFFFF3300')
1113 * shadowColor : [opt] hexstring - color of button's label's shadow. (e.g. '0xFF000000')
1114 * focusedColor : [opt] hexstring - color of focused button's label. (e.g. '0xFFFFFF00')
1115 * label2 : [opt] string or unicode - text string.
1117 * *Note, You can use the above as keywords for arguments and skip certain optional arguments.
1118 * Once you use a keyword, all following arguments require the keyword.
1121 * - self.button.setLabel('Status', 'font14', '0xFFFFFFFF', '0xFFFF3300', '0xFF000000')
1123 virtual void setLabel(const String& label = emptyString,
1124 const char* font = NULL,
1125 const char* textColor = NULL,
1126 const char* disabledColor = NULL,
1127 const char* shadowColor = NULL,
1128 const char* focusedColor = NULL,
1129 const String& label2 = emptyString) throw (UnimplementedException);
1131 // setDisabledColor() Method
1133 * setDisabledColor(disabledColor) -- Set's this buttons disabled color.
1135 * disabledColor : hexstring - color of disabled button's label. (e.g. '0xFFFF3300')
1138 * - self.button.setDisabledColor('0xFFFF3300')
1140 virtual void setDisabledColor(const char* color) throw (UnimplementedException);
1142 // getLabel() Method
1144 * getLabel() -- Returns the buttons label as a unicode string.
1147 * - label = self.button.getLabel()
1149 virtual String getLabel() throw (UnimplementedException);
1151 // getLabel2() Method
1153 * getLabel2() -- Returns the buttons label2 as a unicode string.
1156 * - label = self.button.getLabel2()
1158 virtual String getLabel2() throw (UnimplementedException);
1160 SWIGHIDDENVIRTUAL bool canAcceptMessages(int actionId) { return true; }
1165 std::string strFont;
1167 color_t disabledColor;
1171 std::string strText;
1172 std::string strText2;
1173 std::string strTextureFocus;
1174 std::string strTextureNoFocus;
1176 SWIGHIDDENVIRTUAL CGUIControl* Create() throw (WindowException);
1178 ControlButton() : Control("ControlButton") {}
1182 // ControlCheckMark class
1184 * ControlCheckMark class.
1186 * ControlCheckMark(x, y, width, height, label[, focusTexture, noFocusTexture,
1187 * checkWidth, checkHeight, alignment, font, textColor, disabledColor])
1189 * x : integer - x coordinate of control.
1190 * y : integer - y coordinate of control.
1191 * width : integer - width of control.
1192 * height : integer - height of control.
1193 * label : string or unicode - text string.
1194 * focusTexture : [opt] string - filename for focus texture.
1195 * noFocusTexture : [opt] string - filename for no focus texture.
1196 * checkWidth : [opt] integer - width of checkmark.
1197 * checkHeight : [opt] integer - height of checkmark.
1198 * alignment : [opt] integer - alignment of label - *Note, see xbfont.h
1199 * font : [opt] string - font used for label text. (e.g. 'font13')
1200 * textColor : [opt] hexstring - color of enabled checkmark's label. (e.g. '0xFFFFFFFF')
1201 * disabledColor : [opt] hexstring - color of disabled checkmark's label. (e.g. '0xFFFF3300')
1203 * *Note, You can use the above as keywords for arguments and skip certain optional arguments.
1204 * Once you use a keyword, all following arguments require the keyword.
1205 * After you create the control, you need to add it to the window with addControl().
1208 * - self.checkmark = xbmcgui.ControlCheckMark(100, 250, 200, 50, 'Status', font='font14')
1210 class ControlCheckMark : public Control
1214 ControlCheckMark(long x, long y, long width, long height, const String& label,
1215 const char* focusTexture = NULL, const char* noFocusTexture = NULL,
1216 long checkWidth = 30, long checkHeight = 30,
1217 long _alignment = XBFONT_RIGHT, const char* font = NULL,
1218 const char* textColor = NULL, const char* disabledColor = NULL);
1220 // getSelected() Method
1222 * getSelected() -- Returns the selected status for this checkmark as a bool.
1225 * - selected = self.checkmark.getSelected()
1227 virtual bool getSelected() throw (UnimplementedException);
1229 // setSelected() Method
1231 * setSelected(isOn) -- Sets this checkmark status to on or off.
1233 * isOn : bool - True=selected (on) / False=not selected (off)
1236 * - self.checkmark.setSelected(True)
1238 virtual void setSelected(bool selected) throw (UnimplementedException);
1240 // setLabel() Method
1242 * setLabel(label[, font, textColor, disabledColor]) -- Set's this controls text attributes.
1244 * label : string or unicode - text string.
1245 * font : [opt] string - font used for label text. (e.g. 'font13')
1246 * textColor : [opt] hexstring - color of enabled checkmark's label. (e.g. '0xFFFFFFFF')
1247 * disabledColor : [opt] hexstring - color of disabled checkmark's label. (e.g. '0xFFFF3300')
1250 * - self.checkmark.setLabel('Status', 'font14', '0xFFFFFFFF', '0xFFFF3300')
1252 virtual void setLabel(const String& label = emptyString,
1253 const char* font = NULL,
1254 const char* textColor = NULL,
1255 const char* disabledColor = NULL,
1256 const char* shadowColor = NULL,
1257 const char* focusedColor = NULL,
1258 const String& label2 = emptyString) throw (UnimplementedException);
1260 // setDisabledColor() Method
1262 * setDisabledColor(disabledColor) -- Set's this controls disabled color.
1264 * disabledColor : hexstring - color of disabled checkmark's label. (e.g. '0xFFFF3300')
1267 * - self.checkmark.setDisabledColor('0xFFFF3300')
1269 virtual void setDisabledColor(const char* color) throw (UnimplementedException);
1272 SWIGHIDDENVIRTUAL bool canAcceptMessages(int actionId) { return true; }
1274 std::string strFont;
1279 color_t disabledColor;
1280 std::string strTextureFocus;
1281 std::string strTextureNoFocus;
1282 std::string strText;
1284 SWIGHIDDENVIRTUAL CGUIControl* Create() throw (WindowException);
1286 ControlCheckMark() : Control("ControlCheckMark") {}
1290 // ControlGroup class
1292 * ControlGroup class.
1294 * ControlGroup(x, y, width, height
1296 * x : integer - x coordinate of control.
1297 * y : integer - y coordinate of control.
1298 * width : integer - width of control.
1299 * height : integer - height of control.
1301 * - self.group = xbmcgui.ControlGroup(100, 250, 125, 75)
1303 class ControlGroup : public Control
1306 ControlGroup(long x, long y, long width, long height);
1309 SWIGHIDDENVIRTUAL CGUIControl* Create() throw (WindowException);
1311 ControlGroup() : Control("ControlGroup") {}
1315 class ControlRadioButton : public Control
1318 ControlRadioButton(long x, long y, long width, long height, const String& label,
1319 const char* focusTexture = NULL, const char* noFocusTexture = NULL,
1320 long textOffsetX = CONTROL_TEXT_OFFSET_X,
1321 long textOffsetY = CONTROL_TEXT_OFFSET_Y,
1322 long _alignment = (XBFONT_LEFT | XBFONT_CENTER_Y),
1323 const char* font = NULL, const char* textColor = NULL,
1324 const char* disabledColor = NULL, long angle = 0,
1325 const char* shadowColor = NULL, const char* focusedColor = NULL,
1326 const char* TextureRadioFocus = NULL,
1327 const char* TextureRadioNoFocus = NULL);
1329 // setSelected() Method
1331 * setSelected(selected) -- Sets the radio buttons's selected status.
1333 * selected : bool - True=selected (on) / False=not selected (off)
1335 * *Note, You can use the above as keywords for arguments and skip certain optional arguments.
1336 * Once you use a keyword, all following arguments require the keyword.
1339 * - self.radiobutton.setSelected(True)
1341 virtual void setSelected(bool selected) throw (UnimplementedException);
1343 // isSelected() Method
1345 * isSelected() -- Returns the radio buttons's selected status.
1348 * - is = self.radiobutton.isSelected()\n
1350 virtual bool isSelected() throw (UnimplementedException);
1352 // setLabel() Method
1354 * setLabel(label[, font, textColor, disabledColor, shadowColor, focusedColor]) -- Set's the radio buttons text attributes.
1356 * label : string or unicode - text string.
1357 * font : [opt] string - font used for label text. (e.g. 'font13')
1358 * textColor : [opt] hexstring - color of enabled radio button's label. (e.g. '0xFFFFFFFF')
1359 * disabledColor : [opt] hexstring - color of disabled radio button's label. (e.g. '0xFFFF3300')
1360 * shadowColor : [opt] hexstring - color of radio button's label's shadow. (e.g. '0xFF000000')
1361 * focusedColor : [opt] hexstring - color of focused radio button's label. (e.g. '0xFFFFFF00')
1363 * *Note, You can use the above as keywords for arguments and skip certain optional arguments.
1364 * Once you use a keyword, all following arguments require the keyword.
1367 * - self.radiobutton.setLabel('Status', 'font14', '0xFFFFFFFF', '0xFFFF3300', '0xFF000000')
1369 virtual void setLabel(const String& label = emptyString,
1370 const char* font = NULL,
1371 const char* textColor = NULL,
1372 const char* disabledColor = NULL,
1373 const char* shadowColor = NULL,
1374 const char* focusedColor = NULL,
1375 const String& label2 = emptyString) throw (UnimplementedException);
1377 // setRadioDimension() Method
1379 * setRadioDimension(x, y, width, height) -- Sets the radio buttons's radio texture's position and size.
1381 * x : integer - x coordinate of radio texture.
1382 * y : integer - y coordinate of radio texture.
1383 * width : integer - width of radio texture.
1384 * height : integer - height of radio texture.
1386 * *Note, You can use the above as keywords for arguments and skip certain optional arguments.
1387 * Once you use a keyword, all following arguments require the keyword.
1390 * - self.radiobutton.setRadioDimension(x=100, y=5, width=20, height=20)
1392 virtual void setRadioDimension(long x, long y, long width, long height) throw (UnimplementedException);
1395 SWIGHIDDENVIRTUAL bool canAcceptMessages(int actionId) { return true; }
1397 std::string strFont;
1398 std::string strText;
1399 std::string strTextureFocus;
1400 std::string strTextureNoFocus;
1401 std::string strTextureRadioFocus;
1402 std::string strTextureRadioNoFocus;
1404 color_t disabledColor;
1409 color_t shadowColor;
1410 color_t focusedColor;
1412 SWIGHIDDENVIRTUAL CGUIControl* Create() throw (WindowException);
1414 ControlRadioButton() : Control("ControlRadioButton") {}
1419 * ControlSlider class.
1421 * ControlSlider(x, y, width, height[, textureback, texture, texturefocus])
1423 * x : integer - x coordinate of control.
1424 * y : integer - y coordinate of control.
1425 * width : integer - width of control.
1426 * height : integer - height of control.
1427 * textureback : [opt] string - image filename.
1428 * texture : [opt] string - image filename.
1429 * texturefocus : [opt] string - image filename.\n"
1430 * *Note, You can use the above as keywords for arguments and skip certain optional arguments.
1431 * Once you use a keyword, all following arguments require the keyword.
1432 * After you create the control, you need to add it to the window with addControl().
1435 * - self.slider = xbmcgui.ControlSlider(100, 250, 350, 40)
1437 class ControlSlider : public Control
1440 ControlSlider(long x, long y, long width, long height,
1441 const char* textureback = NULL,
1442 const char* texture = NULL,
1443 const char* texturefocus = NULL);
1446 * getPercent() -- Returns a float of the percent of the slider.
1449 * - print self.slider.getPercent()
1451 virtual float getPercent() throw (UnimplementedException);
1454 * setPercent(50) -- Sets the percent of the slider.
1457 * self.slider.setPercent(50)
1459 virtual void setPercent(float pct) throw (UnimplementedException);
1462 std::string strTextureBack;
1463 std::string strTexture;
1464 std::string strTextureFoc;
1466 SWIGHIDDENVIRTUAL CGUIControl* Create() throw (WindowException);
1468 ControlSlider() : Control("ControlSlider") {}