Ejemplo n.º 1
0
  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->dwTextColor = 0xe0f0f0f0;
    self->dwSelectedColor = 0xffffffff;
    self->dwImageHeight = 10;
    self->dwImageWidth = 10;
    self->dwItemHeight = 27;
    self->dwSpace = 2;
    self->dwItemTextXOffset = CONTROL_TEXT_OFFSET_X;
    self->dwItemTextYOffset = CONTROL_TEXT_OFFSET_Y;
    self->dwAlignmentY = XBFONT_CENTER_Y;
    //self->dwShadowColor = 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->dwImageWidth,
      &self->dwImageHeight,
      &self->dwItemTextXOffset,
      &self->dwItemTextYOffset,
      &self->dwItemHeight,
      &self->dwSpace,
      &self->dwAlignmentY//,
      ))//&cShadowColor))
    {
      Py_DECREF( self );
      return NULL;
    }

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

    self->strTextureButton = cTextureButton ? cTextureButton :
      PyGetDefaultImage((char*)"listcontrol", (char*)"texturenofocus", (char*)"list-nofocus.png");
    self->strTextureButtonFocus = cTextureButtonFocus ? cTextureButtonFocus :
      PyGetDefaultImage((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;
  }
Ejemplo n.º 2
0
  PyObject* ControlRadioButton_New(
    PyTypeObject *type,
    PyObject *args,
    PyObject *kwds )
  {
    static char *keywords[] = {
      "x", "y", "width", "height", "label",
      "focusTexture", "noFocusTexture",
      "textXOffset", "textYOffset", "alignment",
      "font", "textColor", "disabledColor", "angle", "shadowColor", "focusedColor",
      "TextureRadioFocus", "TextureRadioNoFocus", NULL };
    ControlRadioButton *self;
    char* cFont = NULL;
    char* cTextureFocus = NULL;
    char* cTextureNoFocus = NULL;
    char* cTextColor = NULL;
    char* cDisabledColor = NULL;
    char* cShadowColor = NULL;
    char* cFocusedColor = NULL;
    char* cTextureRadioFocus = NULL;
    char* cTextureRadioNoFocus = NULL;

    PyObject* pObjectText;

    self = (ControlRadioButton*)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(); 
    new(&self->strTextureRadioFocus) string();    
    new(&self->strTextureRadioNoFocus) string(); 
    
    // set up default values in case they are not supplied
    self->dwTextXOffset = CONTROL_TEXT_OFFSET_X;
    self->dwTextYOffset = CONTROL_TEXT_OFFSET_Y;
    self->dwAlign = (XBFONT_LEFT | XBFONT_CENTER_Y);
    self->strFont = "font13";
    self->dwTextColor = 0xffffffff;
    self->dwDisabledColor = 0x60ffffff;
    self->iAngle = 0;
    self->dwShadowColor = 0;
    self->dwFocusedColor = 0xffffffff;

    if (!PyArg_ParseTupleAndKeywords(
      args,
      kwds,
      "llllO|sslllssslssss",
      keywords,
      &self->dwPosX,
      &self->dwPosY,
      &self->dwWidth,
      &self->dwHeight,
      &pObjectText,
      &cTextureFocus,
      &cTextureNoFocus,
      &self->dwTextXOffset,
      &self->dwTextYOffset,
      &self->dwAlign,
      &cFont,
      &cTextColor,
      &cDisabledColor,
      &self->iAngle,
      &cShadowColor,
      &cFocusedColor,
      &cTextureRadioFocus,
      &cTextureRadioNoFocus))
    {
      Py_DECREF( self );
      return NULL;
    }

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

    // if texture is supplied use it, else get default ones
    self->strTextureFocus = cTextureFocus ?
      cTextureFocus :
      PyGetDefaultImage("radiobutton", "texturefocus", "radiobutton-focus.png");
    self->strTextureNoFocus = cTextureNoFocus ?
      cTextureNoFocus :
      PyGetDefaultImage("radiobutton", "texturenofocus", "radiobutton-nofocus.jpg");
    self->strTextureRadioFocus = cTextureRadioFocus ?
      cTextureRadioFocus :
      PyGetDefaultImage("radiobutton", "textureradiofocus", "radiobutton-focus.png");
    self->strTextureRadioNoFocus = cTextureRadioNoFocus ?
      cTextureRadioNoFocus :
      PyGetDefaultImage("radiobutton", "textureradionofocus", "radiobutton-nofocus.jpg");

    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 );
    return (PyObject*)self;
  }
Ejemplo n.º 3
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->dwCheckWidth = 30;
    self->dwCheckHeight = 30;
    self->dwAlign = XBFONT_RIGHT;
    self->strFont = "font13";
    self->dwTextColor = 0xffffffff;
    self->dwDisabledColor = 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->dwCheckWidth,
      &self->dwCheckHeight,
      &self->dwAlign,
      &cFont,
      &cTextColor,
      &cDisabledColor ))
    {
      Py_DECREF( self );
      return NULL;
    }
    if (!PyGetUnicodeString(self->strText, pObjectText, 5))
    {
      Py_DECREF( self );
      return NULL;
    }

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

    return (PyObject*)self;
  }