GammaManagerAPI.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #pragma once
  2. #include <api/skin/colorthemes.h>
  3. #include <api/service/svcs/svc_skinfilter.h>
  4. #include <vector>
  5. #include <api/skin/api_colorthemes.h>
  6. class ColorThemeGroupI : public ColorThemeGroup
  7. {
  8. public:
  9. ColorThemeGroupI(const wchar_t *pname, int pred, int pgreen, int pblue, int pgray, int pboost)
  10. : name(0), red(pred), green(pgreen), blue(pblue), make_grayscale(pgray), boost_levels(pboost)
  11. {
  12. name = _wcsdup(pname);
  13. }
  14. ~ColorThemeGroupI()
  15. {
  16. free(name);
  17. }
  18. ColorThemeGroupI(ColorThemeGroup &copy_group)
  19. {
  20. name = _wcsdup(copy_group.getName());
  21. red = copy_group.getRed();
  22. green = copy_group.getGreen();
  23. blue = copy_group.getBlue();
  24. make_grayscale = copy_group.getGray();
  25. boost_levels = copy_group.getBoost();
  26. }
  27. const wchar_t *getName() { return name; }
  28. int getRed() { return red; }
  29. int getGreen() { return green; }
  30. int getBlue() { return blue; }
  31. int getGray() { return make_grayscale; }
  32. int getBoost() { return boost_levels; }
  33. void setName(const wchar_t *pname) { free(name); name = _wcsdup(pname); }
  34. void setRed(int r) { red = r; }
  35. void setGreen(int g) { green = g; }
  36. void setBlue(int b) { blue = b; }
  37. void setGray(int g) { make_grayscale = g; }
  38. void setBoost(int b) { boost_levels = b; }
  39. protected:
  40. RECVS_DISPATCH;
  41. wchar_t *name;
  42. int red;
  43. int green;
  44. int blue;
  45. int make_grayscale;
  46. int boost_levels;
  47. };
  48. static bool IsKeyword(const wchar_t *a, const wchar_t *b)
  49. {
  50. return (CompareStringW(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, a, -1, b, -1) == CSTR_EQUAL);
  51. }
  52. class GammaSet
  53. {
  54. public:
  55. GammaSet( const wchar_t *pname ) : name( 0 ), generalgroup( L"General", 0, 0, 0, 0, 0 )
  56. {
  57. name = _wcsdup( pname );
  58. }
  59. ~GammaSet()
  60. {
  61. //gammagroups.deleteAll();
  62. for ( ColorThemeGroupI *obj : gammagroups )
  63. delete obj;
  64. gammagroups.clear();
  65. free( name );
  66. }
  67. int haveGroup( const wchar_t *grp )
  68. {
  69. if ( !grp )
  70. return 0;
  71. for ( ColorThemeGroupI *obj : gammagroups )
  72. {
  73. if ( IsKeyword( grp, obj->getName() ) )
  74. return 1;
  75. }
  76. return 0;
  77. }
  78. void SetName( const wchar_t *newname )
  79. {
  80. free( name );
  81. name = _wcsdup( newname );
  82. }
  83. wchar_t *name;
  84. std::vector<ColorThemeGroupI *> gammagroups;
  85. ColorThemeGroupI generalgroup;
  86. };
  87. class GammaManagerAPI : public api_colorthemes
  88. {
  89. public:
  90. static const char *getServiceName() { return "Color Themes API"; }
  91. static const GUID getServiceGuid() { return ColorThemesAPIGUID; }
  92. GammaManagerAPI();
  93. void StartTransaction();
  94. void EndTransaction();
  95. /* Gamma Sets */
  96. size_t getNumGammaSets();
  97. const wchar_t *enumGammaSet(size_t n);
  98. void deleteGammaSet(const wchar_t *set);
  99. void deleteAllGammaSets();
  100. void resetGammaSet(const wchar_t *set);
  101. void renameGammaSet(const wchar_t *set, const wchar_t *newname);
  102. size_t newGammaSet(const wchar_t *set); // returns index of your new gamma group
  103. void updateGammaSet(const wchar_t *set);
  104. /* Gamma Groups */
  105. int getNumGammaGroups(const wchar_t *gammaset);
  106. const wchar_t *enumGammaGroup(const wchar_t *gammaset, int n);
  107. ColorThemeGroup *enumColorThemeGroup(int colorset, int colorgroup);
  108. ColorThemeGroup *getColorThemeGroup(const wchar_t *colorset, const wchar_t *colorgroup);
  109. int getGammaForGroup(const wchar_t *group, int *r, int *g, int *b, int *gray, int *boost);
  110. void addGammaGroup(const wchar_t *set, ColorThemeGroup *group);
  111. void addGammaGroup2(size_t gammaSetIndex, ColorThemeGroup *group);
  112. /* Active Gamma Set */
  113. const wchar_t *getGammaSet();
  114. void setGammaSet(const wchar_t *set);
  115. protected:
  116. RECVS_DISPATCH;
  117. private:
  118. void setGammaSetInternal(GammaSet *set);
  119. std::vector<GammaSet*> gammasets;
  120. GammaSet *curSetSel; // current color theme
  121. size_t inTransaction;
  122. };