Exemplo n.º 1
0
  PyObject* Control_SetNavigation(Control* self, PyObject* args)
  {
    Control* pUpControl = NULL;
    Control* pDownControl = NULL;
    Control* pLeftControl = NULL;
    Control* pRightControl = NULL;

    if (!PyArg_ParseTuple(args, (char*)"OOOO", &pUpControl, &pDownControl, &pLeftControl, &pRightControl)) return NULL;

    // type checking, objects should be of type Control
    if(!(Control_Check(pUpControl) &&  Control_Check(pDownControl) &&
        Control_Check(pLeftControl) && Control_Check(pRightControl)))
    {
      PyErr_SetString(PyExc_TypeError, "Objects 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->iControlUp = pUpControl->iControlId;
    self->iControlDown = pDownControl->iControlId;
    self->iControlLeft = pLeftControl->iControlId;
    self->iControlRight = pRightControl->iControlId;

    PyXBMCGUILock();
    if (self->pGUIControl) self->pGUIControl->SetNavigation(
        self->iControlUp,self->iControlDown,self->iControlLeft,self->iControlRight);
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Exemplo n.º 2
0
static PyObject* Control_controlNext(Control* self, PyObject* args)
{
  if(!self->isInitialized)
  {
    PyErr_SetString(PyExc_AssertionError, "Base class __init__() not called");
    return NULL;
  }

  Control *pControl;

  if (!PyArg_ParseTuple(args, "O", &pControl))
    return NULL;

  if (!Control_Check(pControl))
  {
    PyErr_SetString(PyExc_TypeError, "Object should be of type Control");
    return NULL;
  }

  if(pControl->pControl->getId() == 0)
  {
    PyErr_SetString(PyExc_ReferenceError, "Control has to be added to a window first");
    return NULL;
  }

  if (self->pControl)
    self->pControl->controlNext(pControl->pControl);

  Py_INCREF(Py_None);
  return Py_None;
}
Exemplo n.º 3
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;
  }
Exemplo n.º 4
0
  PyObject* Window_SetFocus(Window *self, PyObject *args)
  {
    Control* pControl;
    if (!PyArg_ParseTuple(args, (char*)"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;
    }

    CGUIMessage msg = CGUIMessage(GUI_MSG_SETFOCUS,pControl->iParentId, pControl->iControlId);
    g_windowManager.SendThreadMessage(msg, pControl->iParentId);

    Py_INCREF(Py_None);
    return Py_None;
  }
Exemplo n.º 5
0
  PyObject* Window_RemoveControl(Window *self, PyObject *args)
  {
    Control* pControl;
    if (!PyArg_ParseTuple(args, (char*)"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;
    }
    GilSafeSingleLock lock(g_graphicsContext);
    if(!self->pWindow->GetControl(pControl->iControlId))
    {
      PyErr_SetString(PyExc_RuntimeError, "Control does not exist in window");
      return NULL;
    }

    // delete control from vecControls in window object
    vector<Control*>::iterator it = self->vecControls.begin();
    while (it != self->vecControls.end())
    {
      Control* control = *it;
      if (control->iControlId == pControl->iControlId)
      {
        it = self->vecControls.erase(it);
      } else ++it;
    }

    {
      CPyThreadState state;
      CGUIMessage msg(GUI_MSG_REMOVE_CONTROL, 0, 0);
      msg.SetPointer(pControl->pGUIControl);
      g_application.getApplicationMessenger().SendGUIMessage(msg, self->iWindowId, true);
    }

    // initialize control to zero
    pControl->pGUIControl = NULL;
    pControl->iControlId = 0;
    pControl->iParentId = 0;
    Py_DECREF(pControl);

    Py_INCREF(Py_None);
    return Py_None;
  }
Exemplo n.º 6
0
  PyObject* Window_RemoveControl(Window *self, PyObject *args)
  {
    Control* pControl;
    if (!PyArg_ParseTuple(args, (char*)"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;
    }
    GilSafeSingleLock lock(g_graphicsContext);
    if(!self->pWindow->GetControl(pControl->iControlId))
    {
      PyErr_SetString(PyExc_RuntimeError, "Control does not exist in window");
      return NULL;
    }

    // delete control from vecControls in window object
    vector<Control*>::iterator it = self->vecControls.begin();
    while (it != self->vecControls.end())
    {
      Control* control = *it;
      if (control->iControlId == pControl->iControlId)
      {
        it = self->vecControls.erase(it);
      } else ++it;
    }

    self->pWindow->RemoveControl(pControl->pGUIControl);
    pControl->pGUIControl->FreeResources();
    delete pControl->pGUIControl;

    // initialize control to zero
    pControl->pGUIControl = NULL;
    pControl->iControlId = 0;
    pControl->iParentId = 0;
    Py_DECREF(pControl);

    Py_INCREF(Py_None);
    return Py_None;
  }
Exemplo n.º 7
0
  PyObject* Window_AddControl(Window *self, PyObject *args)
  {
    Control* pControl;

    if (!PyArg_ParseTuple(args, (char*)"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(pControl->iControlId != 0)
    {
      PyErr_SetString(PyExc_ReferenceError, "Control is already used");
      return NULL;
    }

    // lock xbmc GUI before accessing data from it
    GilSafeSingleLock lock(g_graphicsContext);
    pControl->iParentId = self->iWindowId;
    // assign control id, if id is already in use, try next id
    do pControl->iControlId = ++self->iCurrentControlId;
    while (self->pWindow->GetControl(pControl->iControlId));

    // Control Label
    if (ControlLabel_Check(pControl))
      ControlLabel_Create((ControlLabel*)pControl);

    // Control Fade Label
    else if (ControlFadeLabel_Check(pControl))
      ControlFadeLabel_Create((ControlFadeLabel*)pControl);

    // Control TextBox
    else if (ControlTextBox_Check(pControl))
      ControlTextBox_Create((ControlTextBox*)pControl);

    // Control Button
    else if (ControlButton_Check(pControl))
      ControlButton_Create((ControlButton*)pControl);

    // Control CheckMark
    else if (ControlCheckMark_Check(pControl))
      ControlCheckMark_Create((ControlCheckMark*)pControl);

    // Image
    else if (ControlImage_Check(pControl))
      ControlImage_Create((ControlImage*)pControl);

    // Control List
    else if (ControlList_Check(pControl))
      ControlList_Create((ControlList*)pControl);

    // Control Progress
    else if (ControlProgress_Check(pControl))
      ControlProgress_Create((ControlProgress*)pControl);

    // Control Slider
    else if (ControlSlider_Check(pControl))
      ControlSlider_Create((ControlSlider*)pControl);    

    // Control Group
    else if (ControlGroup_Check(pControl))
      ControlGroup_Create((ControlGroup*)pControl);

    // Control RadioButton
    else if (ControlRadioButton_Check(pControl))
      ControlRadioButton_Create((ControlRadioButton*)pControl);

    else if (ControlEdit_Check(pControl))
      ControlEdit_Create((ControlEdit*)pControl);
    //unknown control type to add, should not happen
    else
    {
      PyErr_SetString(PyExc_RuntimeError, "Object is a Control, but can't be added to a window");
      return NULL;
    }

    Py_INCREF(pControl);

    // set default navigation for control
    pControl->iControlUp = pControl->iControlId;
    pControl->iControlDown = pControl->iControlId;
    pControl->iControlLeft = pControl->iControlId;
    pControl->iControlRight = pControl->iControlId;

    pControl->pGUIControl->SetNavigation(pControl->iControlUp,
      pControl->iControlDown, pControl->iControlLeft, pControl->iControlRight);

    // add control to list and allocate recources for the control
    self->vecControls.push_back(pControl);
    {
      CPyThreadState state;
      CGUIMessage msg(GUI_MSG_ADD_CONTROL, 0, 0);
      msg.SetPointer(pControl->pGUIControl);
      g_application.getApplicationMessenger().SendGUIMessage(msg, self->iWindowId, true);
    }
    Py_INCREF(Py_None);
    return Py_None;
  }