xuithemeslist.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #ifndef __THEMESLIST_H
  2. #define __THEMESLIST_H
  3. #include <api/wnd/wndclass/listwnd.h>
  4. #include <api/skin/nakedobject.h>
  5. #include <api/service/svcs/svc_action.h>
  6. class ThemesSlotActionSvc : public svc_actionI {
  7. public:
  8. ThemesSlotActionSvc() {
  9. registerAction(L"ThemesSlotsMenu", 0);
  10. }
  11. virtual ~ThemesSlotActionSvc() {}
  12. virtual int onActionId(int pvtid, const wchar_t *action, const wchar_t *param=NULL, int p1=0, int p2=0, void *data=NULL, int datalen=0, ifc_window *source=NULL);
  13. static const char *getServiceName() { return "ThemesSlotMenu Service"; }
  14. };
  15. #define THEMESLIST_PARENT ListWnd
  16. #define THEMESLIST2_PARENT NakedObject
  17. // -----------------------------------------------------------------------
  18. class ColorThemesList : public THEMESLIST_PARENT, public SkinCallbackI
  19. {
  20. public:
  21. ColorThemesList();
  22. virtual ~ColorThemesList();
  23. virtual int onInit();
  24. virtual void onDoubleClick(int itemnum);
  25. virtual int onPaint(Canvas *canvas);
  26. virtual int onRightClick(int itemnum);
  27. virtual int onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source);
  28. virtual int onResize();
  29. virtual int wantResizeCols() { return 0; }
  30. virtual int setXuiParam(int _xuihandle, int xmlattrid, const wchar_t *name, const wchar_t *value);
  31. virtual int wantHScroll() { return !nohscroll; }
  32. virtual int getTextBold(LPARAM lParam);
  33. virtual void onSetVisible(int show);
  34. virtual int skincb_onColorThemesListChanged() { loadThemes(); return 1;}
  35. enum {
  36. CTLIST_NOHSCROLL = 0,
  37. };
  38. static void setSlot(int s, const wchar_t *set);
  39. static const wchar_t *getSlot(int s);
  40. protected:
  41. /*static */void CreateXMLParameters(int master_handle);
  42. private:
  43. static XMLParamPair params[];
  44. void colorthemes_switch();
  45. void colorthemes_next();
  46. void colorthemes_previous();
  47. void colorthemes_advance(int i);
  48. void loadThemes();
  49. int xuihandle;
  50. int nohscroll;
  51. int ensure_on_paint;
  52. };
  53. // -----------------------------------------------------------------------
  54. class NakedItem
  55. {
  56. public:
  57. NakedItem(const wchar_t *_name, int _p) : name(_name), data(_p) {}
  58. virtual ~NakedItem() {}
  59. const wchar_t *getName() { return name; }
  60. int getData() { return data; }
  61. private:
  62. StringW name;
  63. int data;
  64. };
  65. // -----------------------------------------------------------------------
  66. class NakedItemSort {
  67. public:
  68. // comparator for sorting
  69. static int compareItem(NakedItem *p1, NakedItem *p2) {
  70. return _wcsicmp(p1->getName(), p2->getName());
  71. }
  72. // comparator for searching
  73. static int compareAttrib(const wchar_t *attrib, NakedItem *item) {
  74. return _wcsicmp(attrib, item->getName());
  75. }
  76. };
  77. // -----------------------------------------------------------------------
  78. class NakedColorThemesList : public THEMESLIST2_PARENT, public SkinCallbackI
  79. {
  80. public:
  81. NakedColorThemesList();
  82. virtual ~NakedColorThemesList();
  83. virtual int onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source);
  84. virtual void onSetVisible(int show);
  85. virtual int skincb_onColorThemesListChanged() { loadThemes(); return 1;}
  86. private:
  87. PtrListQuickSorted<NakedItem, NakedItemSort> items;
  88. void colorthemes_switch();
  89. void colorthemes_next();
  90. void colorthemes_previous();
  91. void colorthemes_advance(int i);
  92. void loadThemes();
  93. int xuihandle;
  94. };
  95. // -----------------------------------------------------------------------
  96. extern const wchar_t ColorThemesListXuiObjectStr[];
  97. extern char ColorThemesListXuiSvcName[];
  98. class ColorThemesListXuiSvc : public XuiObjectSvc<ColorThemesList, ColorThemesListXuiObjectStr, ColorThemesListXuiSvcName> {};
  99. extern const wchar_t NakedColorThemesListXuiObjectStr[];
  100. extern char NakedColorThemesListXuiSvcName[];
  101. class NakedColorThemesListXuiSvc : public XuiObjectSvc<NakedColorThemesList, NakedColorThemesListXuiObjectStr, NakedColorThemesListXuiSvcName> {};
  102. #endif