Example #1
0
  PyObject* Control_ControlRight(Control* self, PyObject* args)
  {
    Control* pControl;
    if (!PyArg_ParseTuple(args, "O", &pControl)) return NULL;
    // type checking, object should be of type Control
    if (!Control_Check(pControl))
    {
      PyErr_SetString(PyExc_TypeError, "Object should be of type Control");
      return NULL;
    }
    if(self->iControlId == 0)
    {
      PyErr_SetString(PyExc_ReferenceError, "Control has to be added to a window first");
      return NULL;
    }

    self->iControlRight = pControl->iControlId;
    PyGUILock();
    if (self->pGUIControl) self->pGUIControl->SetNavigation(self->iControlUp,
      self->iControlDown,self->iControlLeft,self->iControlRight);
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Example #2
0
  PyObject* ControlList_Reset(ControlList *self, PyObject *args)
  {
    // create message
    ControlList *pControl = (ControlList*)self;
    CGUIMessage msg(GUI_MSG_LABEL_RESET, pControl->iParentId, pControl->iControlId);

    // send message
    PyGUILock();
    if (pControl->pGUIControl) pControl->pGUIControl->OnMessage(msg);
    PyGUIUnlock();

    // delete all items from vector
    // delete all ListItem from vector
    vector<ListItem*>::iterator it = self->vecItems.begin();
    while (it != self->vecItems.end())
    {
      ListItem* pListItem = *it;
      Py_DECREF(pListItem);
      ++it;
    }
    self->vecItems.clear();

    Py_INCREF(Py_None);
    return Py_None;
  }
  PyObject* ControlRadioButton_SetSelected(ControlRadioButton *self, PyObject *args, PyObject *kwds)
  {
    static char *keywords[] = {
      "selected",
      NULL};

    bool selected = false;
 
    if (!PyArg_ParseTupleAndKeywords(
      args,
      kwds,
      "b",
      keywords,
      &selected))
    {
      return NULL;
    }

    PyGUILock();
    if (self->pGUIControl)
      ((CGUIRadioButtonControl*)self->pGUIControl)->SetSelected(selected);
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Example #4
0
  PyObject* ControlList_AddItem(ControlList *self, PyObject *args)
  {
    PyObject *pObject;
    if (!PyArg_ParseTuple(args, (char*)"O", &pObject))  return NULL;

    ListItem* pListItem = NULL;
    if (ListItem_CheckExact(pObject))
    {
      // object is a listitem
      pListItem = (ListItem*)pObject;
      Py_INCREF(pListItem);
    }
    else
    {
      string strText;
      // object is probably a text item
      if (!PyGetUnicodeString(strText, pObject, 1)) return NULL;
      // object is a unicode string now, create a new ListItem
      pListItem = ListItem_FromString(strText);
    }

    // add item to objects vector
    self->vecItems.push_back(pListItem);

    // create message
    CGUIMessage msg(GUI_MSG_LABEL_ADD, self->iParentId, self->iControlId, 0, 0, pListItem->item);

    // send message
    PyGUILock();
    if (self->pGUIControl) self->pGUIControl->OnMessage(msg);
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
  PyObject* ControlRadioButton_SetRadioDimension(ControlRadioButton *self, PyObject *args, PyObject *kwds)
  {
    static char *keywords[] = {
      "x",
      "y",
      "width",
      "height",
      NULL};
 
    if (!PyArg_ParseTupleAndKeywords(
      args,
      kwds,
      "llll",
      keywords,
      &self->dwPosX,
      &self->dwPosY,
      &self->dwWidth,
      &self->dwHeight))
    {
      return NULL;
    }

    PyGUILock();
    if (self->pGUIControl)
      ((CGUIRadioButtonControl*)self->pGUIControl)->SetRadioDimensions((float)self->dwPosX, (float)self->dwPosY, (float)self->dwWidth, (float)self->dwHeight);
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
  PyObject* ControlRadioButton_SetLabel(ControlRadioButton *self, PyObject *args, PyObject *kwds)
  {
    static char *keywords[] = {
      "label",
      "font",
      "textColor",
      "disabledColor",
      "shadowColor",
      "focusedColor",
      NULL};
    char *cFont = NULL;
    char *cTextColor = NULL;
    char *cDisabledColor = NULL;
    char *cShadowColor = NULL;
    char *cFocusedColor = NULL;
    PyObject *pObjectText = NULL;
 
    if (!PyArg_ParseTupleAndKeywords(
      args,
      kwds,
      "O|sssss",
      keywords,
      &pObjectText,
      &cFont,
      &cTextColor,
      &cDisabledColor,
      &cShadowColor,
      &cFocusedColor))
    {
      return NULL;
    }

    if (!PyGetUnicodeString(self->strText, pObjectText, 1))
    {
      return NULL;
    }

    if (cFont) self->strFont = cFont;
    if (cTextColor) sscanf(cTextColor, "%x", &self->dwTextColor);
    if (cDisabledColor) sscanf( cDisabledColor, "%x", &self->dwDisabledColor );
    if (cShadowColor) sscanf(cShadowColor, "%x", &self->dwShadowColor);
    if (cFocusedColor) sscanf(cFocusedColor, "%x", &self->dwFocusedColor);

    PyGUILock();
    if (self->pGUIControl)
    {
      ((CGUIRadioButtonControl*)self->pGUIControl)->PythonSetLabel(
        self->strFont, self->strText, self->dwTextColor, self->dwShadowColor, self->dwFocusedColor );
      ((CGUIRadioButtonControl*)self->pGUIControl)->PythonSetDisabledColor(self->dwDisabledColor);
    }
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Example #7
0
  PyObject* Control_SetHeight(Control* self, PyObject* args)
  {
    if (!PyArg_ParseTuple(args, "l", &self->dwHeight)) return NULL;

    PyGUILock();
    if (self->pGUIControl) self->pGUIControl->SetHeight((float)self->dwHeight);
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Example #8
0
  PyObject* Control_SetPosition(Control* self, PyObject* args)
  {
    if (!PyArg_ParseTuple(args, "ll", &self->dwPosX, &self->dwPosY)) return NULL;

    PyGUILock();
    if (self->pGUIControl) self->pGUIControl->SetPosition((float)self->dwPosX, (float)self->dwPosY);
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
  PyObject* ControlRadioButton_IsSelected(ControlRadioButton *self, PyObject *args)
  {
    bool isSelected = false;

    PyGUILock();
    if (self->pGUIControl)
      isSelected = ((CGUIRadioButtonControl*)self->pGUIControl)->IsSelected();
    PyGUIUnlock();

    return Py_BuildValue("b", isSelected);
  }
Example #10
0
  PyObject* ControlList_AddItems(ControlList *self, PyObject *args, PyObject *kwds)
  {
    PyObject *pList = NULL;
    static const char *keywords[] = { "items", NULL };

    if (!PyArg_ParseTupleAndKeywords(
      args,
      kwds,
      (char*)"O",
      (char**)keywords,
      &pList) || pList == NULL || !PyObject_TypeCheck(pList, &PyList_Type))
    {
      PyErr_SetString(PyExc_TypeError, "Object should be of type List");
      return NULL;
    }

    CFileItemList items;
    for (int item = 0; item < PyList_Size(pList); item++)
    {
      PyObject *pItem = PyList_GetItem(pList, item);

      ListItem* pListItem = NULL;
      if (ListItem_CheckExact(pItem))
      {
        // object is a listitem
        pListItem = (ListItem*)pItem;
        Py_INCREF(pListItem);
      }
      else
      {
        string strText;
        // object is probably a text item
        if (!PyGetUnicodeString(strText, pItem, 1)) return NULL;
        // object is a unicode string now, create a new ListItem
        pListItem = ListItem_FromString(strText);
      }

      // add item to objects vector
      self->vecItems.push_back(pListItem);
      items.Add(pListItem->item);
    }

    // create message
    CGUIMessage msg(GUI_MSG_LABEL_BIND, self->iParentId, self->iControlId, 0, 0, &items);

    // send message
    PyGUILock();
    if (self->pGUIControl) self->pGUIControl->OnMessage(msg);
    PyGUIUnlock();


    Py_INCREF(Py_None);
    return Py_None;
  }
Example #11
0
  PyObject* Control_SetEnabled(Control* self, PyObject* args)
  {
    bool enabled;
    if (!PyArg_ParseTuple(args, "b", &enabled)) return NULL;

    PyGUILock();
    if (self->pGUIControl)   self->pGUIControl->SetEnabled(enabled);
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Example #12
0
  PyObject* XBMC_GetCondVisibility(PyObject *self, PyObject *args)
  {
    char *cLine = NULL;
    if (!PyArg_ParseTuple(args, (char*)"s", &cLine)) return NULL;

    PyGUILock();
    DWORD dwId = m_gWindowManager.GetTopMostModalDialogID();
    if (dwId == WINDOW_INVALID) dwId = m_gWindowManager.GetActiveWindow();
    PyGUIUnlock();

    int ret = g_infoManager.TranslateString(cLine);
    return Py_BuildValue((char*)"b", g_infoManager.GetBool(ret,dwId));
  }
Example #13
0
  PyObject* ControlCheckMark_GetSelected( ControlCheckMark *self )
  {
    bool isSelected = 0;

    PyGUILock();
    if (self->pGUIControl)
    {
      isSelected = ((CGUICheckMarkControl*)self->pGUIControl)->GetSelected();
    }
    PyGUIUnlock();

    return Py_BuildValue((char*)"b", isSelected);
  }
Example #14
0
  PyObject* ControlFadeLabel_Reset(ControlFadeLabel *self, PyObject *args)
  {
    ControlFadeLabel *pControl = (ControlFadeLabel*)self;
    CGUIMessage msg(GUI_MSG_LABEL_RESET, pControl->iParentId, pControl->iControlId);

    pControl->vecLabels.clear();
    PyGUILock();
    if (pControl->pGUIControl) pControl->pGUIControl->OnMessage(msg);
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Example #15
0
  PyObject* ControlTextBox_Reset(ControlTextBox *self, PyObject *args)
  {
    // create message
    ControlTextBox *pControl = (ControlTextBox*)self;
    CGUIMessage msg(GUI_MSG_LABEL_RESET, pControl->iParentId, pControl->iControlId);

    // send message
    PyGUILock();
    if (pControl->pGUIControl) pControl->pGUIControl->OnMessage(msg);
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Example #16
0
  PyObject* Control_SetVisible(Control* self, PyObject* args)
  {
    bool visible;
    if (!PyArg_ParseTuple(args, "b", &visible)) return NULL;

    PyGUILock();
    if (self->pGUIControl)
    {
      self->pGUIControl->SetVisible(visible);
    }
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Example #17
0
  PyObject* Control_SetEnableCondition(Control* self, PyObject* args)
  {
    char *cEnable = NULL;

    if (!PyArg_ParseTuple(args, "s", &cEnable)) return NULL;

    int ret = g_infoManager.TranslateString(cEnable);

    PyGUILock();
    if (self->pGUIControl)
      self->pGUIControl->SetEnableCondition(ret);
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Example #18
0
  PyObject* ControlList_SelectItem(ControlList *self, PyObject *args)
  {
    long itemIndex;

    if (!PyArg_ParseTuple(args, (char*)"l", &itemIndex)) return NULL;

    // create message
    CGUIMessage msg(GUI_MSG_ITEM_SELECT, self->iParentId, self->iControlId, itemIndex);

    // send message
    PyGUILock();
    if (self->pGUIControl) self->pGUIControl->OnMessage(msg);
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Example #19
0
  PyObject* Control_SetVisibleCondition(Control* self, PyObject* args)
  {
    char *cVisible = NULL;
    bool bHidden = false;

    if (!PyArg_ParseTuple(args, "s|b", &cVisible, &bHidden)) return NULL;

    int ret = g_infoManager.TranslateString(cVisible);

    PyGUILock();
    if (self->pGUIControl)
      self->pGUIControl->SetVisibleCondition(ret, bHidden);
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Example #20
0
  PyObject* ControlCheckMark_SetSelected(ControlCheckMark *self, PyObject *args)
  {
    bool isSelected = 0;

    if (!PyArg_ParseTuple(args, (char*)"b", &isSelected))
      return NULL;

    PyGUILock();
    if (self->pGUIControl)
    {
      ((CGUICheckMarkControl*)self->pGUIControl)->SetSelected(isSelected);
    }
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Example #21
0
  PyObject* ControlList_GetSelectedPosition(ControlList *self, PyObject *args)
  {
    // create message
    ControlList *pControl = (ControlList*)self;
    CGUIMessage msg(GUI_MSG_ITEM_SELECTED, pControl->iParentId, pControl->iControlId);
    long pos = -1;

    // send message
    PyGUILock();
    if ((self->vecItems.size() > 0) && pControl->pGUIControl)
    {
      pControl->pGUIControl->OnMessage(msg);
      pos = msg.GetParam1();
    }
    PyGUIUnlock();

    return Py_BuildValue((char*)"l", pos);
  }
Example #22
0
  PyObject* ControlFadeLabel_AddLabel(ControlFadeLabel *self, PyObject *args)
  {
    PyObject *pObjectText;
    string strText;

    if (!PyArg_ParseTuple(args, (char*)"O", &pObjectText))   return NULL;
    if (!PyGetUnicodeString(strText, pObjectText, 1)) return NULL;

    ControlFadeLabel *pControl = (ControlFadeLabel*)self;
    CGUIMessage msg(GUI_MSG_LABEL_ADD, pControl->iParentId, pControl->iControlId);
    msg.SetLabel(strText);

    PyGUILock();
    if (pControl->pGUIControl) pControl->pGUIControl->OnMessage(msg);
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Example #23
0
  PyObject* ControlList_GetSelectedItem(ControlList *self, PyObject *args)
  {
    // create message
    ControlList *pControl = (ControlList*)self;
    CGUIMessage msg(GUI_MSG_ITEM_SELECTED, pControl->iParentId, pControl->iControlId);
    PyObject* pListItem = Py_None;

    // send message
    PyGUILock();
    if ((self->vecItems.size() > 0) && pControl->pGUIControl)
    {
      pControl->pGUIControl->OnMessage(msg);
      pListItem = (PyObject*)self->vecItems[msg.GetParam1()];
    }
    PyGUIUnlock();

    Py_INCREF(pListItem);
    return pListItem;
  }
Example #24
0
  PyObject* ControlTextBox_SetText(ControlTextBox *self, PyObject *args)
  {
    PyObject *pObjectText;
    string strText;
    if (!PyArg_ParseTuple(args, (char*)"O", &pObjectText))	return NULL;
    if (!PyGetUnicodeString(strText, pObjectText, 1)) return NULL;

    // create message
    ControlTextBox *pControl = (ControlTextBox*)self;
    CGUIMessage msg(GUI_MSG_LABEL_SET, pControl->iParentId, pControl->iControlId);
    msg.SetLabel(strText);

    // send message
    PyGUILock();
    if (pControl->pGUIControl) pControl->pGUIControl->OnMessage(msg);
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Example #25
0
  PyObject* ControlButton_SetDisabledColor(ControlButton *self, PyObject *args)
  {
    char *cDisabledColor = NULL;

    if (!PyArg_ParseTuple(args, "s", &cDisabledColor))  return NULL;

    // ControlButton *pControl = (ControlButton*)self;

    if (cDisabledColor) sscanf(cDisabledColor, "%x", &self->dwDisabledColor);

    PyGUILock();
    if (self->pGUIControl)
    {
      ((CGUIButtonControl*)self->pGUIControl)->PythonSetDisabledColor(self->dwDisabledColor);
    }
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Example #26
0
  PyObject* ControlCheckMark_SetLabel(ControlCheckMark *self, PyObject *args)
  {
    PyObject *pObjectText;
    char *cFont = NULL;
    char *cTextColor = NULL;
    char* cDisabledColor = NULL;

    if (!PyArg_ParseTuple(
      args, (char*)"O|sss",
      &pObjectText, &cFont,
      &cTextColor,  &cDisabledColor))
      return NULL;

    if (!PyGetUnicodeString(self->strText, pObjectText, 1))
      return NULL;

    if (cFont) self->strFont = cFont;
    if (cTextColor)
    {
      sscanf(cTextColor, "%x", &self->dwTextColor);
    }
    if (cDisabledColor)
    {
      sscanf(cDisabledColor, "%x", &self->dwDisabledColor);
    }

    PyGUILock();
    if (self->pGUIControl)
    {
      ((CGUICheckMarkControl*)self->pGUIControl)->PythonSetLabel(
        self->strFont,
        self->strText,
        self->dwTextColor );
      ((CGUICheckMarkControl*)self->pGUIControl)->PythonSetDisabledColor(
        self->dwDisabledColor );
    }
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Example #27
0
  PyObject* ControlCheckMark_SetDisabledColor(ControlCheckMark *self, PyObject *args)
  {
    char *cDisabledColor = NULL;

    if (!PyArg_ParseTuple(args, (char*)"s", &cDisabledColor))	return NULL;

    if (cDisabledColor)
    {
      sscanf(cDisabledColor, "%x", &self->dwDisabledColor);
    }

    PyGUILock();
    if (self->pGUIControl)
    {
      ((CGUICheckMarkControl*)self->pGUIControl)->PythonSetDisabledColor( self->dwDisabledColor );
    }
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Example #28
0
  PyObject* Control_SetAnimations(Control* self, PyObject* args)
  {
    PyObject *pList = NULL;
    if (!PyArg_ParseTuple(args, "O", &pList) || pList == NULL || !PyObject_TypeCheck(pList, &PyList_Type))
    {
      PyErr_SetString(PyExc_TypeError, "Object should be of type List");
      return NULL;
    }

    TiXmlDocument xmlDoc;
    TiXmlElement xmlRootElement("control");
    TiXmlNode *pRoot = xmlDoc.InsertEndChild(xmlRootElement);
    if (!pRoot)
    {
      PyErr_SetString(PyExc_TypeError, "TiXmlNode creation error");
      return NULL;
    }
    vector<CAnimation> animations;
    for (int anim = 0; anim < PyList_Size(pList); anim++)
    {
      PyObject *pTuple = NULL;
      char *cEvent = NULL;
      char *cAttr = NULL;
      pTuple = PyList_GetItem(pList, anim);
      if (pTuple == NULL || !PyObject_TypeCheck(pTuple, &PyTuple_Type))
      {
        PyErr_SetString(PyExc_TypeError, "List must only contain tuples");
        return NULL;
      }
      if (!PyArg_ParseTuple(pTuple, "ss", &cEvent, &cAttr))
      {
        PyErr_SetString(PyExc_TypeError, "Error unpacking tuple found in list");
        return NULL;
      }

      if (NULL != cAttr && NULL != cEvent)
      {
        TiXmlElement pNode("animation");
        CStdStringArray attrs;
        StringUtils::SplitString(cAttr, " ", attrs);
        for (unsigned int i = 0; i < attrs.size(); i++)
        {
          CStdStringArray attrs2;
          StringUtils::SplitString(attrs[i], "=", attrs2);
          if (attrs2.size() == 2)
            pNode.SetAttribute(attrs2[0], attrs2[1]);
        }
        TiXmlText value(cEvent);
        pNode.InsertEndChild(value);
        pRoot->InsertEndChild(pNode);
      }
    }

    //bool ret = xmlDoc.SaveFile("q:\\userdata\\test.txt");

    const FRECT animRect = { (float)self->dwPosX, (float)self->dwPosY, (float)self->dwWidth, (float)self->dwHeight };
    PyGUILock();
    if (self->pGUIControl)
      CGUIControlFactory::GetAnimations(pRoot, animRect, animations);
    self->pGUIControl->SetAnimations(animations);
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }