[xbmc-addons] r2288 committed - Added for jfcaroll

16 views
Skip to first unread message

xbmc-...@googlecode.com

unread,
Mar 28, 2013, 10:12:43 PM3/28/13
to xbmc-addo...@googlegroups.com
Revision: 2288
Author: nuka...@gmail.com
Date: Thu Mar 28 19:12:29 2013
Log: Added for jfcaroll
http://code.google.com/p/xbmc-addons/source/detail?r=2288

Added:
/packages/Branch_Python_ControlSpinEx.patch

=======================================
--- /dev/null
+++ /packages/Branch_Python_ControlSpinEx.patch Thu Mar 28 19:12:29 2013
@@ -0,0 +1,378 @@
+ xbmc/guilib/GUISpinControl.h | 2 +
+ xbmc/interfaces/legacy/Control.cpp | 123
++++++++++++++++++++++++++++++
+ xbmc/interfaces/legacy/Control.h | 128
+++++++++++++++++++++++++++++++-
+ xbmc/interfaces/legacy/ModuleXbmcgui.h | 5 ++
+ xbmc/interfaces/legacy/Window.cpp | 13 ++++
+ xbmc/interfaces/legacy/Window.h | 2 +
+ 6 files changed, 269 insertions(+), 4 deletions(-)
+
+diff --git a/xbmc/guilib/GUISpinControl.h b/xbmc/guilib/GUISpinControl.h
+index 3f2a54a..1657bef 100644
+--- a/xbmc/guilib/GUISpinControl.h
++++ b/xbmc/guilib/GUISpinControl.h
+@@ -68,6 +68,8 @@ public:
+ void SetValueFromLabel(const CStdString &label);
+ void SetFloatValue(float fValue);
+ int GetValue() const;
++ int GetType() const { return m_iType; };
++ const CLabelInfo& GetLabelInfo() const { return m_label.GetLabelInfo();
};
+ float GetFloatValue() const;
+ void AddLabel(const std::string& strLabel, int iValue);
+ const std::string GetLabel() const;
+diff --git a/xbmc/interfaces/legacy/Control.cpp
b/xbmc/interfaces/legacy/Control.cpp
+index f6e369b..a47a9d2 100644
+--- a/xbmc/interfaces/legacy/Control.cpp
++++ b/xbmc/interfaces/legacy/Control.cpp
+@@ -34,6 +34,7 @@
+ #include "guilib/GUIListContainer.h"
+ #include "guilib/GUIProgressControl.h"
+ #include "guilib/GUISliderControl.h"
++#include "guilib/GUISpinControlEx.h"
+ #include "guilib/GUIRadioButtonControl.h"
+ #include "GUIInfoManager.h"
+ #include "guilib/GUIWindowManager.h"
+@@ -1386,5 +1387,127 @@ namespace XBMCAddon
+
+ // ============================================================
+
++ // ============================================================
++ // ============================================================
++ ControlSpinEx::ControlSpinEx(long x, long y, long width, long height,
const String& label,
++ const char* font, const char* _textColor, const char*
_disabledColor,
++ const char* _shadowColor, const char* _focusedColor,
long _alignment,
++ long _iType) :
++ Control("ControlSpinEx"),
++ strFont("font13"),
++ textColor(0xffffffff),
++ disabledColor(0x60ffffff),
++ shadowColor(0),
++ focusedColor(0xffffffff)
++ {
++ dwPosX = x;
++ dwPosY = y;
++ dwWidth = width;
++ dwHeight = height;
++ strText = label;
++ align = _alignment;
++ iType=_iType;
++
++ // if textures are supplied use them, else get default ones
++ if (font) strFont = font;
++ if (_textColor) sscanf( _textColor, "%x", &textColor );
++ if (_disabledColor) sscanf( _disabledColor, "%x", &disabledColor );
++ if (_shadowColor) sscanf( _shadowColor, "%x", &shadowColor );
++ if (_focusedColor) sscanf( _focusedColor, "%x", &focusedColor );
++ }
++
++ // setType() Method
++ void ControlSpinEx::setType(int type) throw (UnimplementedException)
++ {
++ if (pGUIControl && (type >= SPIN_CONTROL_TYPE_INT && type <=
SPIN_CONTROL_TYPE_PAGE))
++ {
++ LOCKGUI;
++ ((CGUISpinControlEx *)pGUIControl)->SetType(type);
++ }
++ }
++
++ // getType() Method
++ int ControlSpinEx::getType() throw (UnimplementedException)
++ {
++ if (!pGUIControl) return NULL;
++
++ LOCKGUI;
++ return ((CGUISpinControlEx*) pGUIControl)->GetType();
++ }
++
++ // setValue() Method
++ void ControlSpinEx::setValue(const String& value) throw
(UnimplementedException)
++ {
++ const String& strValue = value;
++
++ if (pGUIControl)
++ {
++ LOCKGUI;
++ ((CGUISpinControlEx*)pGUIControl)->SetValueFromLabel(strValue);
++ }
++ }
++
++ // getValue() Method
++ String ControlSpinEx::getValue() throw (UnimplementedException)
++ {
++ if (!pGUIControl) return NULL;
++
++ LOCKGUI;
++ return ((CGUISpinControlEx*) pGUIControl)->GetCurrentLabel();
++ }
++
++ // addValues() Method
++ void ControlSpinEx::addValues(const std::vector<String>& values)
throw (UnimplementedException)
++ {
++ const std::vector<String>& vecValues = values;
++
++ if (pGUIControl)
++ {
++ LOCKGUI;
++ ((CGUISpinControlEx *)pGUIControl)->Clear();
++ for (unsigned int item = 0; item < vecValues.size(); item++)
++ {
++ ((CGUISpinControlEx*)pGUIControl)->AddLabel(vecValues[item],
item);
++ }
++ }
++ }
++
++ CGUIControl* ControlSpinEx::Create() throw (WindowException)
++ {
++ CLabelInfo label;
++ CLabelInfo label2;
++ label.font = g_fontManager.GetFont(strFont);
++ label.textColor = textColor;
++ label.disabledColor = disabledColor;
++ label.shadowColor = shadowColor;
++ label.focusedColor = focusedColor;
++ label.align = align;
++ label.offsetX = (float)textOffsetX;
++ label.offsetY = (float)textOffsetY;
++ label.angle = (float)-iAngle;
++ pGUIControl = new CGUISpinControlEx(
++ iParentId,
++ iControlId,
++ (float)dwPosX,
++ (float)dwPosY,
++ (float)dwWidth,
++ (float)dwHeight,
++ (float)spinWidth,
++ (float)spinHeight,
++ label,
++ (CStdString)strTextureFocus,
++ (CStdString)strTextureNoFocus,
++ (CStdString)strTextureUp,
++ (CStdString)strTextureDown,
++ (CStdString)strTextureUpFocus,
++ (CStdString)strTextureDownFocus,
++ label2,
++ iType);
++
++ return pGUIControl;
++ }
++
++ // ============================================================
++
+ }
+ }
+diff --git a/xbmc/interfaces/legacy/Control.h
b/xbmc/interfaces/legacy/Control.h
+index 6bddb3a..a2679d0 100644
+--- a/xbmc/interfaces/legacy/Control.h
++++ b/xbmc/interfaces/legacy/Control.h
+@@ -22,6 +22,7 @@
+ #pragma once
+
+ #include "guilib/GUIControl.h"
++#include "guilib/GUISpinControl.h"
+ #include "guilib/GUIFont.h"
+ #include "guilib/Key.h"
+
+@@ -30,8 +31,6 @@
+ #include "swighelper.h"
+ #include "WindowException.h"
+
+-#include "ListItem.h"
+-
+ // hardcoded offsets for button controls (and controls that use button
controls)
+ // ideally they should be dynamically read in as with all the other
properties.
+ #define CONTROL_TEXT_OFFSET_X 10
+@@ -132,6 +131,12 @@ namespace XBMCAddon
+ virtual String getLabel2() DECL_UNIMP("Control");
+ virtual long getItemHeight() DECL_UNIMP("Control");
+ virtual void addLabel(const String& label) DECL_UNIMP("Control");
++ // spincontrolex methods
++ virtual void setType(int type) DECL_UNIMP("Control");
++ virtual int getType() DECL_UNIMP("Control");
++ virtual void setValue(const String& value) DECL_UNIMP("Control");
++ virtual String getValue() DECL_UNIMP("Control");
++ virtual void addValues(const std::vector<String>& values)
DECL_UNIMP("Control");
+
+ // These need to be here for the stubbed out addItem
+ // and addItems methods
+@@ -1461,13 +1466,128 @@ namespace XBMCAddon
+ #ifndef SWIG
+ std::string strTextureBack;
+ std::string strTexture;
+- std::string strTextureFoc;
++ std::string strTextureFoc;
+
+ SWIGHIDDENVIRTUAL CGUIControl* Create() throw (WindowException);
+
+ ControlSlider() : Control("ControlSlider") {}
+ #endif
+ };
++
++ /**
++ * ControlSlider class.\n
++ *\n
++ * ControlSpinEx(x, y, width, height, label[, font, textColor,
disabledColor, shadowColor, alignment, type]\n
++ *\n
++ * x : integer - x coordinate of control.\n
++ * y : integer - y coordinate of control.\n
++ * width : integer - width of control.\n
++ * height : integer - height of control.\n
++ * label : string or unicode - text string.\n
++ * font : [opt] string - font used for label text.
(e.g. 'font13')\n
++ * textColor : [opt] hexstring - color of enabled spin control's
label. (e.g. '0xFFFFFFFF')\n
++ * disabledColor : [opt] hexstring - color of disabled spin control's
label. (e.g. '0xFFFF3300')\n
++ * shadowColor : [opt] hexstring - color of enabled spin control's
shadow. (e.g. '0xFF000000')\n
++ * focusedColor : [opt] hexstring - color of enabled spin control's
label when focused. (e.g. '0xFF0000FF')\n
++ * alignment : [opt] integer - alignment of label - *Note, see
xbfont.h\n
++ * type : [opt] integer - type of spinner. (e.g.
xbmcgui.SPIN_CONTROL_TYPE_TEXT)\n
++ *\n
++ * example:\n
++ * - self.spincontrol = xbmcgui.ControlSpinEx(100, 250, 350,
40, "Scraper",type=xbmcgui.SPIN_CONTROL_TYPE_TEXT)\n
++ */
++ class ControlSpinEx : public Control
++ {
++ public:
++ ControlSpinEx(long x, long y, long width, long height, const
String& label,
++ const char* font = NULL, const char* _textColor =
NULL,
++ const char* _disabledColor = NULL, const char*
_shadowColor = NULL,
++ const char* _focusedColor = NULL, long _alignment =
(XBFONT_LEFT | XBFONT_CENTER_Y),
++ long iType = SPIN_CONTROL_TYPE_INT);
++
++ // setType() method
++ /**
++ * setType(type) -- Sets the spinner control's type.\n
++ * \n
++ * type : integer - spin control type\n
++ * \n"
++ * *Note, SPIN_CONTROL_TYPE_INT (default), SPIN_CONTROL_TYPE_FLOAT,
SPIN_CONTROL_TYPE_TEXT, SPIN_CONTROL_TYPE_PAGE\n
++ * \n
++ * example:\n
++ * - self.spincontrol.setType(type=xbmcgui.SPIN_CONTROL_TYPE_TEXT)\n
++ */
++ virtual void ControlSpinEx::setType(int type) throw
(UnimplementedException);
++
++ // getType() Method
++ /**
++ * getType() -- Returns the spin control's type as an integer.\n
++ *\n
++ *Note, return value can be:\n
++ * SPIN_CONTROL_TYPE_INT, SPIN_CONTROL_TYPE_FLOAT,
SPIN_CONTROL_TYPE_TEXT, SPIN_CONTROL_TYPE_PAGE\n
++ *\n
++ * example:\n
++ * - value = self.spincontrol.getValue()\n
++ */
++ virtual int getType() throw (UnimplementedException);
++
++ // setValue() Method
++ /**
++ * setValue(value) -- Sets the spin control's value.\n
++ * \n
++ * value : unicode string - value to set spin control to\n
++ * \n
++ * example:\n
++ * -self.spincontrol.setValue(u'Windows')\n
++ */
++ virtual void setValue(const String& value) throw
(UnimplementedException);
++
++ // getValue() Method
++ /**
++ * getValue() -- Returns the spin control's current label as a
unicode string.\n
++ *\n
++ * example:\n
++ * - value = self.spincontrol.getValue()\n
++ */
++ virtual String getValue() throw (UnimplementedException);
++
++ // addValues() method
++ /**
++ * addValues(values) -- Adds a list of strings to this spinner
control.\n
++ * \n
++ * values : List - list of unicode strings to add.\n
++ * \n
++ *example:\n
++ * - self.spincontrol.addValues(items=[u'Windows', u'OSX',
u'Linux'])\n
++ */
++ virtual void addValues(const std::vector<String>& values) throw
(UnimplementedException);
++
++#ifndef SWIG
++ ControlSpinEx() : Control("ControlSpinEx") {}
++
++ SWIGHIDDENVIRTUAL bool canAcceptMessages(int actionId) { return
true; }
++
++ std::string strFont;
++ std::string strText;
++ std::string strTextureFocus;
++ std::string strTextureNoFocus;
++ std::string strTextureUp;
++ std::string strTextureDown;
++ std::string strTextureUpFocus;
++ std::string strTextureDownFocus;
++ color_t textColor;
++ color_t disabledColor;
++ int textOffsetX;
++ int textOffsetY;
++ uint32_t align;
++ int iAngle;
++ color_t shadowColor;
++ color_t focusedColor;
++ int iType;
++ int spinWidth;
++ int spinHeight;
++
++ SWIGHIDDENVIRTUAL CGUIControl* Create() throw (WindowException);
++#endif
++ };
++
+ }
+ }
+-
+diff --git a/xbmc/interfaces/legacy/ModuleXbmcgui.h
b/xbmc/interfaces/legacy/ModuleXbmcgui.h
+index 1e2cceb..a90f046 100644
+--- a/xbmc/interfaces/legacy/ModuleXbmcgui.h
++++ b/xbmc/interfaces/legacy/ModuleXbmcgui.h
+@@ -70,5 +70,10 @@ namespace XBMCAddon
+ SWIG_CONSTANT2(int,ICON_OVERLAY_WATCHED,
CGUIListItem::ICON_OVERLAY_WATCHED);
+ SWIG_CONSTANT2(int,ICON_OVERLAY_HD, CGUIListItem::ICON_OVERLAY_HD);
+
++ SWIG_CONSTANT(int,SPIN_CONTROL_TYPE_INT);
++ SWIG_CONSTANT(int,SPIN_CONTROL_TYPE_FLOAT);
++ SWIG_CONSTANT(int,SPIN_CONTROL_TYPE_TEXT);
++ SWIG_CONSTANT(int,SPIN_CONTROL_TYPE_PAGE);
++
+ }
+ }
+diff --git a/xbmc/interfaces/legacy/Window.cpp
b/xbmc/interfaces/legacy/Window.cpp
+index c4478b0..829628e 100644
+--- a/xbmc/interfaces/legacy/Window.cpp
++++ b/xbmc/interfaces/legacy/Window.cpp
+@@ -359,6 +359,19 @@ namespace XBMCAddon
+ if (li.font) ((ControlEdit*)pControl)->strFont =
li.font->GetFontName();
+ ((ControlButton*)pControl)->align = li.align;
+ break;
++ case CGUIControl::GUICONTROL_SPINEX:
++ pControl = new ControlSpinEx();
++
++ li = ((CGUISpinControl *)pGUIControl)->GetLabelInfo();
++
++ // note: conversion from infocolors -> plain colors here
++ ((ControlSpinEx*)pControl)->disabledColor = li.disabledColor;
++ ((ControlSpinEx*)pControl)->focusedColor = li.focusedColor;
++ ((ControlSpinEx*)pControl)->textColor = li.textColor;
++ ((ControlSpinEx*)pControl)->shadowColor = li.shadowColor;
++ if (li.font) ((ControlSpinEx*)pControl)->strFont =
li.font->GetFontName();
++ ((ControlSpinEx*)pControl)->align = li.align;
++ break;
+ default:
+ break;
+ }
+diff --git a/xbmc/interfaces/legacy/Window.h
b/xbmc/interfaces/legacy/Window.h
+index da414e2..6d2fffd 100644
+--- a/xbmc/interfaces/legacy/Window.h
++++ b/xbmc/interfaces/legacy/Window.h
+@@ -364,6 +364,8 @@ namespace XBMCAddon
+ * -ControlGroup
+ * -ControlImage
+ * -ControlRadioButton
++ * -ControlEdit
++ * -ControlSpinEx
+ * -ControlProgress\n
+ */
+ SWIGHIDDENVIRTUAL void addControl(Control* pControl) throw
(WindowException);
Reply all
Reply to author
Forward
0 new messages