SkinColorElement.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef NULLSOFT_GEN_FF_SKINCOLORELEMENT_H
  2. #define NULLSOFT_GEN_FF_SKINCOLORELEMENT_H
  3. #include <api/skin/skinitem.h>
  4. #include "ParamList.h"
  5. struct SkinColorElement : public SkinItem
  6. {
  7. public:
  8. SkinColorElement(const wchar_t *_id, ARGB32 v, int script_id = -1, int secondarycounter = 0, const wchar_t *colorgrp = NULL, const wchar_t *path = NULL, ifc_xmlreaderparams *p = NULL)
  9. : id(_id), value(v), scriptid(script_id), seccount(secondarycounter), colorgroup(colorgrp), rootpath(path)
  10. {
  11. if (p != NULL)
  12. {
  13. for (size_t i = 0;i != p->getNbItems();i++)
  14. params.addItem(p->getItemName(i), p->getItemValue(i));
  15. }
  16. }
  17. const wchar_t *getXmlRootPath() { return rootpath; }
  18. const wchar_t *getName() { return L"color"; }
  19. ifc_xmlreaderparams *getParams() { return &params; }
  20. int getSkinPartId() { return scriptid; }
  21. SkinItem *getAncestor();
  22. const wchar_t *getId() { return id; }
  23. ARGB32 getColor() { return value; }
  24. ARGB32 *getColorRef() { return &value; }
  25. int getSecCount() { return seccount; }
  26. const wchar_t *getColorGroup() { return colorgroup; }
  27. private:
  28. RECVS_DISPATCH;
  29. StringW id;
  30. ARGB32 value;
  31. int scriptid;
  32. int seccount;
  33. StringW colorgroup;
  34. StringW rootpath;
  35. ParamList params;
  36. };
  37. class SortSkinColorElement
  38. {
  39. public:
  40. static int compareItem(SkinColorElement *p1, SkinColorElement *p2)
  41. {
  42. int r = WCSICMP(p1->getId(), p2->getId());
  43. if (!r)
  44. {
  45. if (p1->getSkinPartId() < p2->getSkinPartId()) return -1;
  46. if (p1->getSkinPartId() > p2->getSkinPartId()) return 1;
  47. if (p1->getSecCount() < p2->getSecCount()) return -1;
  48. if (p1->getSecCount() > p2->getSecCount()) return 1;
  49. return 0;
  50. }
  51. return r;
  52. }
  53. static int compareAttrib(const wchar_t *attrib, SkinColorElement *item)
  54. {
  55. return WCSICMP(attrib, item->getId());
  56. }
  57. };
  58. #endif