/*
   * allocate a new controlspin. Used for c++ and not the python user
   */
  PyObject* ControlSpin_New()
  {
    //ControlSpin* self = (ControlSpin*)_PyObject_New(&ControlSpin_Type);
    ControlSpin*self = (ControlSpin*)ControlSpin_Type.tp_alloc(&ControlSpin_Type, 0);
    if (!self) return NULL;
    new(&self->strTextureUp) string();
    new(&self->strTextureDown) string();
    new(&self->strTextureUpFocus) string();
    new(&self->strTextureDownFocus) string();

    // default values for spin control
    self->color = 0xffffffff;
    self->dwPosX = 0;
    self->dwPosY = 0;
    self->dwWidth = 16;
    self->dwHeight = 16;

    // get default images
    self->strTextureUp = PyXBMCGetDefaultImage((char*)"listcontrol", (char*)"textureup", (char*)"scroll-up.png");
    self->strTextureDown = PyXBMCGetDefaultImage((char*)"listcontrol", (char*)"texturedown", (char*)"scroll-down.png");
    self->strTextureUpFocus = PyXBMCGetDefaultImage((char*)"listcontrol", (char*)"textureupfocus", (char*)"scroll-up-focus.png");
    self->strTextureDownFocus = PyXBMCGetDefaultImage((char*)"listcontrol", (char*)"texturedownfocus", (char*)"scroll-down-focus.png");

    return (PyObject*)self;
  }
Exemplo n.º 2
0
  PyObject* ControlProgress_New(PyTypeObject *type, PyObject *args, PyObject *kwds)
  {
    static const char* keywords[] = { "x", "y", "width", "height", "texturebg", "textureleft", "texturemid", "textureright", "textureoverlay", NULL };

    ControlProgress *self;
    char *cTextureBg = NULL;
    char *cTextureLeft = NULL;
    char *cTextureMid  = NULL;
    char *cTextureRight  = NULL;
    char *cTextureOverLay  = NULL;

    self = (ControlProgress*)type->tp_alloc(type, 0);
    if (!self) return NULL;
    new(&self->strTextureLeft) string();
    new(&self->strTextureMid) string();
    new(&self->strTextureRight) string();
    new(&self->strTextureBg) string();
    new(&self->strTextureOverlay) string();

    // parse arguments to constructor
    if (!PyArg_ParseTupleAndKeywords(args, kwds,
      (char*)"llll|sssss",
      (char**)keywords,
      &self->dwPosX,
      &self->dwPosY,
      &self->dwWidth,
      &self->dwHeight,
      &cTextureBg,
      &cTextureLeft,
      &cTextureMid,
      &cTextureRight,
      &cTextureOverLay))
    {
      Py_DECREF( self );
      return NULL;
    }

    // if texture is supplied use it, else get default ones
    self->strTextureBg = cTextureBg ? cTextureBg : PyXBMCGetDefaultImage((char*)"progress", (char*)"texturebg", (char*)"progress_back.png");
    self->strTextureLeft = cTextureLeft ? cTextureLeft : PyXBMCGetDefaultImage((char*)"progress", (char*)"lefttexture", (char*)"progress_left.png");
    self->strTextureMid = cTextureMid ? cTextureMid : PyXBMCGetDefaultImage((char*)"progress", (char*)"midtexture", (char*)"progress_mid.png");
    self->strTextureRight = cTextureRight ? cTextureRight : PyXBMCGetDefaultImage((char*)"progress", (char*)"righttexture", (char*)"progress_right.png");
    self->strTextureOverlay = cTextureOverLay ? cTextureOverLay : PyXBMCGetDefaultImage((char*)"progress", (char*)"overlaytexture", (char*)"progress_over.png");

    //if (cColorDiffuse) sscanf(cColorDiffuse, "%x", &self->colorDiffuse);
    //else self->colorDiffuse = 0;

    return (PyObject*)self;
  }
Exemplo n.º 3
0
  PyObject * ControlSlider_New (PyTypeObject *type, PyObject *args, PyObject *kwds)
  {
    static const char* keywords[] = { "x", "y", "width", "height", "textureback", "texture", "texturefocus", NULL };
	
    ControlSlider *self;
    char *cTextureBack = NULL;
    char *cTexture = NULL;
    char *cTextureFoc  = NULL;
	
    self = (ControlSlider *) type->tp_alloc (type, 0);
    if (!self) return NULL;
    new(&self->strTextureBack) string();
    new(&self->strTexture) string();
    new(&self->strTextureFoc) string();    
	
    if (!PyArg_ParseTupleAndKeywords(args, kwds,
                                     (char*)"llll|sss",
                                     (char**)keywords,
                                     &self->dwPosX,
                                     &self->dwPosY,
                                     &self->dwWidth,
                                     &self->dwHeight,
                                     &cTextureBack,
                                     &cTexture,
                                     &cTextureFoc))
    {
      Py_DECREF( self );
      return NULL;
    }
    // if texture is supplied use it, else get default ones
    self->strTextureBack = cTextureBack ? cTextureBack : PyXBMCGetDefaultImage((char*)"slider", (char*)"texturesliderbar", (char*)"osd_slider_bg_2.png");
    self->strTexture = cTexture ? cTexture : PyXBMCGetDefaultImage((char*)"slider", (char*)"textureslidernib", (char*)"osd_slider_nibNF.png");
    self->strTextureFoc = cTextureFoc ? cTextureFoc : PyXBMCGetDefaultImage((char*)"slider", (char*)"textureslidernibfocus", (char*)"osd_slider_nib.png");
    
    return (PyObject*)self;
  }
Exemplo n.º 4
0
  PyObject* ControlButton_New(
    PyTypeObject *type,
    PyObject *args,
    PyObject *kwds )
  {
    static const char *keywords[] = {
      "x", "y", "width", "height", "label",
      "focusTexture", "noFocusTexture",
      "textOffsetX", "textOffsetY", "alignment",
      "font", "textColor", "disabledColor", "angle", "shadowColor", "focusedColor", NULL };
    ControlButton *self;
    char* cFont = NULL;
    char* cTextureFocus = NULL;
    char* cTextureNoFocus = NULL;
    char* cTextColor = NULL;
    char* cDisabledColor = NULL;
    char* cShadowColor = NULL;
    char* cFocusedColor = NULL;

    PyObject* pObjectText;

    self = (ControlButton*)type->tp_alloc(type, 0);
    if (!self) return NULL;
    new(&self->strFont) string();
    new(&self->strText) string();
    new(&self->strText2) string();
    new(&self->strTextureFocus) string();
    new(&self->strTextureNoFocus) string();

    // set up default values in case they are not supplied
    self->textOffsetX = CONTROL_TEXT_OFFSET_X;
    self->textOffsetY = CONTROL_TEXT_OFFSET_Y;
    self->align = (XBFONT_LEFT | XBFONT_CENTER_Y);
    self->strFont = "font13";
    self->textColor = 0xffffffff;
    self->disabledColor = 0x60ffffff;
    self->iAngle = 0;
    self->shadowColor = 0;
    self->focusedColor = 0xffffffff;

    if (!PyArg_ParseTupleAndKeywords(
      args,
      kwds,
      (char*)"llllO|sslllssslss",
      (char**)keywords,
      &self->dwPosX,
      &self->dwPosY,
      &self->dwWidth,
      &self->dwHeight,
      &pObjectText,
      &cTextureFocus,
      &cTextureNoFocus,
      &self->textOffsetX,
      &self->textOffsetY,
      &self->align,
      &cFont,
      &cTextColor,
      &cDisabledColor,
      &self->iAngle,
      &cShadowColor,
      &cFocusedColor))
    {
      Py_DECREF( self );
      return NULL;
    }


    if (!PyXBMCGetUnicodeString(self->strText, pObjectText, 5))
    {
      Py_DECREF( self );
      return NULL;
    }

    // if texture is supplied use it, else get default ones
    self->strTextureFocus = cTextureFocus ?
      cTextureFocus :
      PyXBMCGetDefaultImage((char*)"button", (char*)"texturefocus", (char*)"button-focus.png");
    self->strTextureNoFocus = cTextureNoFocus ?
      cTextureNoFocus :
      PyXBMCGetDefaultImage((char*)"button", (char*)"texturenofocus", (char*)"button-nofocus.jpg");

    if (cFont) self->strFont = cFont;
    if (cTextColor) sscanf( cTextColor, "%x", &self->textColor );
    if (cDisabledColor) sscanf( cDisabledColor, "%x", &self->disabledColor );
    if (cShadowColor) sscanf( cShadowColor, "%x", &self->shadowColor );
    if (cFocusedColor) sscanf( cFocusedColor, "%x", &self->focusedColor );
    return (PyObject*)self;
  }
  PyObject* ControlList_New(PyTypeObject *type, PyObject *args, PyObject *kwds)
  {
    static const char *keywords[] = {
      "x", "y", "width", "height", "font",
      "textColor", "buttonTexture", "buttonFocusTexture",
      // maintain order of above items for backward compatibility
      "selectedColor",
      "imageWidth", "imageHeight",
      "itemTextXOffset", "itemTextYOffset",
      "itemHeight", "space", "alignmentY", NULL };//"shadowColor", NULL };
    ControlList *self;
    char *cFont = NULL;
    char *cTextColor = NULL;
    char *cSelectedColor = NULL;
    char *cTextureButton = NULL;
    char *cTextureButtonFocus = NULL;
    //char* cShadowColor = NULL;
    self = (ControlList*)type->tp_alloc(type, 0);
    if (!self) return NULL;
    new(&self->strFont) string();
    new(&self->strTextureButton) string();
    new(&self->strTextureButtonFocus) string();
    new(&self->vecItems) std::vector<PYXBMC::ListItem*>();

    // create a python spin control
    self->pControlSpin = (ControlSpin*)ControlSpin_New();
    if (!self->pControlSpin)
    {
      Py_DECREF( self );
      return NULL;
    }

    // initialize default values
    self->strFont = "font13";
    self->textColor = 0xe0f0f0f0;
    self->selectedColor = 0xffffffff;
    self->imageHeight = 10;
    self->imageWidth = 10;
    self->itemHeight = 27;
    self->space = 2;
    self->itemTextOffsetX = CONTROL_TEXT_OFFSET_X;
    self->itemTextOffsetY = CONTROL_TEXT_OFFSET_Y;
    self->alignmentY = XBFONT_CENTER_Y;
    //self->shadowColor = NULL;

    if (!PyArg_ParseTupleAndKeywords(
      args,
      kwds,
      (char*)"llll|ssssslllllll",//s",
      (char**)keywords,
      &self->dwPosX,
      &self->dwPosY,
      &self->dwWidth,
      &self->dwHeight,
      &cFont,
      &cTextColor,
      &cTextureButton,
      &cTextureButtonFocus,
      &cSelectedColor,
      &self->imageWidth,
      &self->imageHeight,
      &self->itemTextOffsetX,
      &self->itemTextOffsetY,
      &self->itemHeight,
      &self->space,
      &self->alignmentY//,
      ))//&cShadowColor))
    {
      Py_DECREF( self );
      return NULL;
    }

    // set specified values
    if (cFont) self->strFont = cFont;
    if (cTextColor)
    {
      sscanf( cTextColor, "%x", &self->textColor );
    }
    if (cSelectedColor)
    {
      sscanf( cSelectedColor, "%x", &self->selectedColor );
    }
    //if (cShadowColor) sscanf( cShadowColor, "%x", &self->shadowColor );

    self->strTextureButton = cTextureButton ? cTextureButton :
      PyXBMCGetDefaultImage((char*)"listcontrol", (char*)"texturenofocus", (char*)"list-nofocus.png");
    self->strTextureButtonFocus = cTextureButtonFocus ? cTextureButtonFocus :
      PyXBMCGetDefaultImage((char*)"listcontrol", (char*)"texturefocus", (char*)"list-focus.png");

    // default values for spin control
    self->pControlSpin->dwPosX = self->dwWidth - 35;
    self->pControlSpin->dwPosY = self->dwHeight - 15;

    return (PyObject*)self;
  }
Exemplo n.º 6
0
  PyObject* ControlCheckMark_New(PyTypeObject *type, PyObject *args, PyObject *kwds )
  {
    static const char *keywords[] = {
      "x", "y", "width", "height", "label", "focusTexture", "noFocusTexture",
      "checkWidth", "checkHeight", "alignment", "font", "textColor", "disabledColor", NULL };
    ControlCheckMark *self;
    char* cFont = NULL;
    char* cTextureFocus = NULL;
    char* cTextureNoFocus = NULL;
    char* cTextColor = NULL;
    char* cDisabledColor = NULL;

    PyObject* pObjectText;

    self = (ControlCheckMark*)type->tp_alloc(type, 0);
    if (!self) return NULL;
    new(&self->strFont) string();
    new(&self->strText) string();
    new(&self->strTextureFocus) string();
    new(&self->strTextureNoFocus) string();

    // set up default values in case they are not supplied
    self->checkWidth = 30;
    self->checkHeight = 30;
    self->align = XBFONT_RIGHT;
    self->strFont = "font13";
    self->textColor = 0xffffffff;
    self->disabledColor = 0x60ffffff;

    // parse arguments to constructor
    if (!PyArg_ParseTupleAndKeywords(
      args,
      kwds,
      (char*)"llllO|sslllsss:ControlCheckMark",
      (char**)keywords,
      &self->dwPosX,
      &self->dwPosY,
      &self->dwWidth,
      &self->dwHeight,
      &pObjectText,
      &cTextureFocus,
      &cTextureNoFocus,
      &self->checkWidth,
      &self->checkHeight,
      &self->align,
      &cFont,
      &cTextColor,
      &cDisabledColor ))
    {
      Py_DECREF( self );
      return NULL;
    }
    if (!PyXBMCGetUnicodeString(self->strText, pObjectText, 5))
    {
      Py_DECREF( self );
      return NULL;
    }

    if (cFont) self->strFont = cFont;
    if (cTextColor) sscanf(cTextColor, "%x", &self->textColor);
    if (cDisabledColor)
    {
      sscanf( cDisabledColor, "%x", &self->disabledColor );
    }
    self->strTextureFocus = cTextureFocus ?
      cTextureFocus :
      PyXBMCGetDefaultImage((char*)"checkmark", (char*)"texturefocus", (char*)"check-box.png");
    self->strTextureNoFocus = cTextureNoFocus ?
      cTextureNoFocus :
      PyXBMCGetDefaultImage((char*)"checkmark", (char*)"texturenofocus", (char*)"check-boxNF.png");

    return (PyObject*)self;
  }