Advertisement
Guest User

vattila

a guest
May 18th, 2009
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 11.27 KB | None | 0 0
  1. Index: xbmc/lib/libPython/xbmcmodule/xbmcguimodule.cpp
  2. ===================================================================
  3. --- xbmc/lib/libPython/xbmcmodule/xbmcguimodule.cpp     (revision 20410)
  4. +++ xbmc/lib/libPython/xbmcmodule/xbmcguimodule.cpp     (working copy)
  5. @@ -228,8 +228,8 @@
  6.      PyModule_AddObject(pXbmcGuiModule, (char*)"WindowXML", (PyObject*)&WindowXML_Type);
  7.      PyModule_AddObject(pXbmcGuiModule, (char*)"WindowXMLDialog", (PyObject*)&WindowXMLDialog_Type);
  8.      PyModule_AddObject(pXbmcGuiModule, (char*)"ListItem", (PyObject*)&ListItem_Type);
  9. -    //PyModule_AddObject(pXbmcGuiModule, (char*)"Control", (PyObject*)&Control_Type);
  10. -    //PyModule_AddObject(pXbmcGuiModule, (char*)"ControlSpin", (PyObject*)&ControlSpin_Type);
  11. +    PyModule_AddObject(pXbmcGuiModule, (char*)"Control", (PyObject*)&Control_Type);
  12. +    PyModule_AddObject(pXbmcGuiModule, (char*)"ControlSpin", (PyObject*)&ControlSpin_Type);
  13.      PyModule_AddObject(pXbmcGuiModule, (char*)"ControlLabel", (PyObject*)&ControlLabel_Type);
  14.      PyModule_AddObject(pXbmcGuiModule, (char*)"ControlFadeLabel", (PyObject*)&ControlFadeLabel_Type);
  15.      PyModule_AddObject(pXbmcGuiModule, (char*)"ControlTextBox", (PyObject*)&ControlTextBox_Type);
  16. Index: xbmc/lib/libPython/xbmcmodule/window.cpp
  17. ===================================================================
  18. --- xbmc/lib/libPython/xbmcmodule/window.cpp    (revision 20410)
  19. +++ xbmc/lib/libPython/xbmcmodule/window.cpp    (working copy)
  20. @@ -602,6 +602,10 @@
  21.      else if (ControlRadioButton_Check(pControl))
  22.        ControlRadioButton_Create((ControlRadioButton*)pControl);
  23.  
  24. +    // Control SpinControl
  25. +    else if (ControlSpin_Check(pControl))
  26. +      ControlSpin_Create((ControlSpin*)pControl);
  27. +
  28.      //unknown control type to add, should not happen
  29.      else
  30.      {
  31. Index: xbmc/lib/libPython/xbmcmodule/GUIPythonWindow.cpp
  32. ===================================================================
  33. --- xbmc/lib/libPython/xbmcmodule/GUIPythonWindow.cpp   (revision 20410)
  34. +++ xbmc/lib/libPython/xbmcmodule/GUIPythonWindow.cpp   (working copy)
  35. @@ -122,6 +122,7 @@
  36.            // currently we only accept messages from a button or controllist with a select action
  37.            if ((ControlList_CheckExact(inf->pObject) && (message.GetParam1() == ACTION_SELECT_ITEM || message.GetParam1() == ACTION_MOUSE_LEFT_CLICK)) ||
  38.              ControlButton_CheckExact(inf->pObject) || ControlRadioButton_CheckExact(inf->pObject) ||
  39. +            ControlSpin_CheckExact(inf->pObject) ||
  40.              ControlCheckMark_CheckExact(inf->pObject))
  41.            {
  42.              // create a new call and set it in the python queue
  43. Index: xbmc/lib/libPython/xbmcmodule/control.h
  44. ===================================================================
  45. --- xbmc/lib/libPython/xbmcmodule/control.h     (revision 20410)
  46. +++ xbmc/lib/libPython/xbmcmodule/control.h     (working copy)
  47. @@ -248,6 +248,7 @@
  48.    CGUIControl* ControlList_Create(ControlList* pControl);
  49.    CGUIControl* ControlProgress_Create(ControlProgress* pControl);
  50.    CGUIControl* ControlRadioButton_Create(ControlRadioButton* pControl);
  51. +  CGUIControl* ControlSpin_Create(ControlSpin* pControl);
  52.  
  53.    void initControl_Type();
  54.    void initControlSpin_Type();
  55. Index: xbmc/lib/libPython/xbmcmodule/controltextbox.cpp
  56. ===================================================================
  57. --- xbmc/lib/libPython/xbmcmodule/controltextbox.cpp    (revision 20410)
  58. +++ xbmc/lib/libPython/xbmcmodule/controltextbox.cpp    (working copy)
  59. @@ -107,6 +107,33 @@
  60.      return pControl->pGUIControl;
  61.    }
  62.  
  63. +
  64. +  // SetPageControl() Method
  65. +  PyDoc_STRVAR(SetPageControl__doc__,
  66. +    "setPageControl(id) -- Sets the page control for this textbox.\n"
  67. +    "\n"
  68. +    "id           : integer - id of the Page Control.\n"
  69. +    "\n"
  70. +    "example:\n"
  71. +    "  - self.textbox.setPageControl(10)");
  72. +
  73. +  PyObject* ControlTextBox_SetPageControl(ControlTextBox *self, PyObject *args)
  74. +  {
  75. +    CLog::Log(LOGNOTICE, "SetPage Control invoked");
  76. +    PyObject *pObjectText;
  77. +    int pageControlId = -1;
  78. +    if (!PyArg_ParseTuple(args, (char*)"l", &pageControlId))   return NULL;
  79. +    CLog::Log(LOGNOTICE, "SetPage Control Parsed %d", pageControlId);
  80. +
  81. +    ControlTextBox *pControl = (ControlTextBox*)self;
  82. +    PyGUILock();
  83. +    static_cast<CGUITextBox*>(pControl->pGUIControl)->SetPageControl(pageControlId);
  84. +    PyGUIUnlock();
  85. +    CLog::Log(LOGNOTICE, "SetPage Control finished");
  86. +
  87. +    return Py_None;
  88. +  }
  89. +
  90.    // SetText() Method
  91.    PyDoc_STRVAR(setText__doc__,
  92.      "setText(text) -- Set's the text for this textbox.\n"
  93. @@ -163,6 +190,7 @@
  94.    PyMethodDef ControlTextBox_methods[] = {
  95.      {(char*)"setText", (PyCFunction)ControlTextBox_SetText, METH_VARARGS, setText__doc__},
  96.      {(char*)"reset", (PyCFunction)ControlTextBox_Reset, METH_VARARGS, reset__doc__},
  97. +    {(char*)"setPageControl",(PyCFunction)ControlTextBox_SetPageControl, METH_VARARGS, SetPageControl__doc__},
  98.      {NULL, NULL, 0, NULL}
  99.    };
  100.  
  101. Index: xbmc/lib/libPython/xbmcmodule/controlspin.cpp
  102. ===================================================================
  103. --- xbmc/lib/libPython/xbmcmodule/controlspin.cpp       (revision 20410)
  104. +++ xbmc/lib/libPython/xbmcmodule/controlspin.cpp       (working copy)
  105. @@ -41,9 +41,9 @@
  106.  
  107.  namespace PYXBMC
  108.  {
  109. -  /*
  110. +
  111.    // not used for now
  112. -  PyObject* ControlSpin_New(PyTypeObject *type, PyObject *args, PyObject *kwds)
  113. +  PyObject* ControlSpin1_New(PyTypeObject *type, PyObject *args, PyObject *kwds)
  114.    {
  115.      ControlSpin *self;
  116.      char* cTextureFocus = NULL;
  117. @@ -60,23 +60,27 @@
  118.  
  119.      if (!PyArg_ParseTuple(args, "llll|Oss", &self->dwPosX, &self->dwPosY, &self->dwWidth, &self->dwHeight,
  120.        &pObjectText, &cTextureFocus, &cTextureNoFocus)) return NULL;
  121. -    if (!PyGetUnicodeString(self->strText, pObjectText, 5)) return NULL;
  122. +    //if (!PyGetUnicodeString(self->strText, pObjectText, 5)) return NULL;
  123.  
  124. -    // SetLabel(const CStdString& strFontName,const CStdString& strLabel,D3DCOLOR dwColor)
  125. -    self->strFont = "font13";
  126. -    self->dwTextColor = 0xffffffff;
  127. -    self->dwDisabledColor = 0x60ffffff;
  128. +    // default values for spin control
  129. +    self->dwColor = 0xffffffff;
  130.  
  131. -    self->strTextureFocus = cTextureFocus ? cTextureFocus : "button-focus.png";
  132. -    self->strTextureNoFocus = cTextureNoFocus ? cTextureNoFocus : "button-nofocus.jpg";
  133. +    //SetLabel(const CStdString& strFontName,const CStdString& strLabel,D3DCOLOR dwColor);
  134. +    //self->strFont = "font13";
  135. +    //self->dwTextColor = 0xffffffff;
  136. +    //self->dwDisabledColor = 0x60ffffff;
  137.  
  138. +    //self->strTextureFocus = cTextureFocus ? cTextureFocus : "button-focus.png";
  139. +    //self->strTextureNoFocus = cTextureNoFocus ? cTextureNoFocus : "button-nofocus.jpg";
  140. +
  141.      return (PyObject*)self;
  142.    }
  143. -*/
  144. +
  145.    /*
  146.     * allocate a new controlspin. Used for c++ and not the python user
  147.     */
  148. -  PyObject* ControlSpin_New()
  149. +
  150. + PyObject* ControlSpin_New()
  151.    {
  152.      //ControlSpin* self = (ControlSpin*)_PyObject_New(&ControlSpin_Type);
  153.      ControlSpin*self = (ControlSpin*)ControlSpin_Type.tp_alloc(&ControlSpin_Type, 0);
  154. @@ -111,6 +115,80 @@
  155.      self->ob_type->tp_free((PyObject*)self);
  156.    }
  157.  
  158. +  CGUIControl* ControlSpin_Create(ControlSpin* pControl)
  159. +  {
  160. +    CLabelInfo label;
  161. +/*    label.font = g_fontManager.GetFont(pControl->strFont);
  162. +    label.textColor = pControl->dwTextColor;
  163. +    label.disabledColor = pControl->dwDisabledColor;
  164. +    label.shadowColor = pControl->dwShadowColor;
  165. +    label.focusedColor = pControl->dwFocusedColor;
  166. +    label.align = pControl->dwAlign;
  167. +    label.offsetX = (float)pControl->dwTextXOffset;
  168. +    label.offsetY = (float)pControl->dwTextYOffset;
  169. +    label.angle = (float)-pControl->iAngle;
  170. +*/
  171. +    pControl->pGUIControl = new CGUISpinControl(
  172. +           pControl->iParentId,
  173. +           pControl->iControlId,
  174. +           (float)pControl->dwPosX,
  175. +           (float)pControl->dwPosY,
  176. +           (float)pControl->dwWidth,
  177. +           (float)pControl->dwHeight,
  178. +           (CStdString)pControl->strTextureUp,
  179. +           (CStdString)pControl->strTextureDown,
  180. +           (CStdString)pControl->strTextureUpFocus,
  181. +           (CStdString)pControl->strTextureDownFocus,
  182. +           label,
  183. +           SPIN_CONTROL_TYPE_PAGE
  184. +           );
  185. +    CLog::Log(LOGNOTICE, "CnotrolSpin_Create invoked");
  186. +    return pControl->pGUIControl;
  187. +  }
  188. +
  189. +  // MoveUp() Method
  190. +   PyDoc_STRVAR(moveUp__doc__,
  191. +       "pageUp() -- Invokes the MoveUp method of the spin control."
  192. +       "\n"
  193. +       "example:\n"
  194. +       "  - self.controlspin.moveUp()");
  195. +
  196. +
  197. +  PyObject* ControlSpin_MoveUp(ControlSpin *self, PyObject *args)
  198. +  {
  199. +    ControlSpin *pControl = (ControlSpin*)self;
  200. +    PyGUILock();
  201. +    static_cast<CGUISpinControl*>(pControl->pGUIControl)->MoveUp();
  202. +
  203. +    PyGUIUnlock();
  204. +
  205. +    Py_INCREF(Py_None);
  206. +    return Py_None;
  207. +
  208. +  }
  209. +
  210. +  // MoveDown() Method
  211. +   PyDoc_STRVAR(moveDown__doc__,
  212. +       "pageDown() -- Invokes the MoveDown method of the spin control."
  213. +       "\n"
  214. +       "example:\n"
  215. +       "  - self.controlspin.pageDown()");
  216. +
  217. +
  218. +  PyObject* ControlSpin_MoveDown(ControlSpin *self, PyObject *args)
  219. +  {
  220. +    ControlSpin *pControl = (ControlSpin*)self;
  221. +    PyGUILock();
  222. +    static_cast<CGUISpinControl*>(pControl->pGUIControl)->MoveDown();
  223. +
  224. +    PyGUIUnlock();
  225. +
  226. +    Py_INCREF(Py_None);
  227. +    return Py_None;
  228. +
  229. +  }
  230. +
  231. +
  232.    PyObject* ControlSpin_SetColor(ControlSpin *self, PyObject *args)
  233.    {
  234.      char *cColor = NULL;
  235. @@ -162,6 +240,8 @@
  236.    PyMethodDef ControlSpin_methods[] = {
  237.      //{(char*)"setColor", (PyCFunction)ControlSpin_SetColor, METH_VARARGS, ""},
  238.      {(char*)"setTextures", (PyCFunction)ControlSpin_SetTextures, METH_VARARGS, setTextures__doc__},
  239. +    {(char*)"moveUp", (PyCFunction)ControlSpin_MoveUp, METH_VARARGS, moveUp__doc__},
  240. +    {(char*)"moveDown", (PyCFunction)ControlSpin_MoveDown, METH_VARARGS, moveDown__doc__},
  241.      {NULL, NULL, 0, NULL}
  242.    };
  243.  
  244. @@ -194,7 +274,7 @@
  245.      ControlSpin_Type.tp_doc = controlSpin__doc__;
  246.      ControlSpin_Type.tp_methods = ControlSpin_methods;
  247.      ControlSpin_Type.tp_base = &Control_Type;
  248. -    ControlSpin_Type.tp_new = 0; //ControlSpin_New
  249. +    ControlSpin_Type.tp_new = ControlSpin1_New; // 0
  250.    }
  251.  }
  252.  
  253. Index: xbmc/lib/libPython/XBPython.cpp
  254. ===================================================================
  255. --- xbmc/lib/libPython/XBPython.cpp     (revision 20410)
  256. +++ xbmc/lib/libPython/XBPython.cpp     (working copy)
  257. @@ -248,9 +248,9 @@
  258.  
  259.  void XBPython::DeInitializeInterpreter()
  260.  {
  261. -  DeinitXBMCModule();
  262. +  //DeinitXBMCModule();
  263.    DeinitPluginModule();
  264. -  DeinitGUIModule();
  265. +  //DeinitGUIModule();
  266.  }
  267.  
  268.  /**
  269. Index: guilib/GUISpinControl.h
  270. ===================================================================
  271. --- guilib/GUISpinControl.h     (revision 20410)
  272. +++ guilib/GUISpinControl.h     (working copy)
  273. @@ -85,6 +85,8 @@
  274.    void Clear();
  275.    virtual CStdString GetDescription() const;
  276.    bool IsFocusedOnUp() const;
  277. +  void MoveUp(bool bTestReverse = true);
  278. +  void MoveDown(bool bTestReverse = true);
  279.  
  280.    virtual bool IsVisible() const;
  281.  
  282. @@ -94,8 +96,6 @@
  283.    void PageDown();
  284.    bool CanMoveDown(bool bTestReverse = true);
  285.    bool CanMoveUp(bool bTestReverse = true);
  286. -  void MoveUp(bool bTestReverse = true);
  287. -  void MoveDown(bool bTestReverse = true);
  288.    void ChangePage(int amount);
  289.    int m_iStart;
  290.    int m_iEnd;
  291.  
  292.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement