1
0

xuigroupxfade.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #include <precomp.h>
  2. #include "xuigroupxfade.h"
  3. #ifndef _WASABIRUNTIME
  4. BEGIN_SERVICES(GroupXFade_Svc);
  5. DECLARE_SERVICE(XuiObjectCreator<GroupXFadeXuiSvc>);
  6. END_SERVICES(GroupXFade_Svc, _GroupXFade_Svc);
  7. #ifdef _X86_
  8. extern "C" { int _link_GroupXFadeXuiSvc; }
  9. #else
  10. extern "C" { int __link_GroupXFadeXuiSvc; }
  11. #endif
  12. #endif
  13. XMLParamPair GroupXFade::params[] = {
  14. {GROUPXFADE_SETGROUP, L"GROUP"},
  15. {GROUPXFADE_SETGROUP, L"GROUPID"},
  16. {GROUPXFADE_SETSPEED, L"SPEED"},
  17. };
  18. GroupXFade::GroupXFade() {
  19. child[0] = child[1] = NULL;
  20. curchild = 0;
  21. myxuihandle = newXuiHandle();
  22. CreateXMLParameters(myxuihandle);
  23. speed = 0.25;
  24. }
  25. void GroupXFade::CreateXMLParameters(int master_handle)
  26. {
  27. //GROUPXFADE_PARENT::CreateXMLParameters(master_handle);
  28. int numParams = sizeof(params) / sizeof(params[0]);
  29. hintNumberOfParams(myxuihandle, numParams);
  30. for (int i = 0;i < numParams;i++)
  31. addParam(myxuihandle, params[i], XUI_ATTRIBUTE_IMPLIED);
  32. }
  33. GroupXFade::~GroupXFade() {
  34. if (child[0]) {
  35. ifc_window *w = child[0]->guiobject_getRootWnd();
  36. if (w) WASABI_API_SKIN->group_destroy(w);
  37. }
  38. if (child[1]) {
  39. ifc_window *w = child[1]->guiobject_getRootWnd();
  40. if (w) WASABI_API_SKIN->group_destroy(w);
  41. }
  42. }
  43. int GroupXFade::onInit() {
  44. GROUPXFADE_PARENT::onInit();
  45. return 1;
  46. }
  47. int GroupXFade::setXuiParam(int xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value) {
  48. if (xuihandle != myxuihandle)
  49. return GROUPXFADE_PARENT::setXuiParam(xuihandle, xmlattributeid, xmlattributename, value);
  50. switch(xmlattributeid) {
  51. case GROUPXFADE_SETGROUP:
  52. setNewGroup(value);
  53. return 1;
  54. case GROUPXFADE_SETSPEED:
  55. speed = WTOF(value);
  56. return 1;
  57. default:
  58. return 0;
  59. }
  60. }
  61. int GroupXFade::onResize() {
  62. GROUPXFADE_PARENT::onResize();
  63. RECT r;
  64. getClientRect(&r);
  65. if (child[curchild])
  66. child[curchild]->guiobject_getRootWnd()->resize(r.left, r.top, r.right-r.left, r.bottom-r.top);
  67. int nextchild = curchild == 1 ? 0 : 1;
  68. if (child[nextchild])
  69. child[nextchild]->guiobject_getRootWnd()->resize(r.left, r.top, r.right-r.left, r.bottom-r.top);
  70. return 1;
  71. }
  72. void GroupXFade::setNewGroup(const wchar_t *grp) {
  73. if (child[curchild] && id[curchild].iscaseequal(grp)) return;
  74. if (child[curchild]) {
  75. child[curchild]->guiobject_setTargetA(0);
  76. child[curchild]->guiobject_setTargetSpeed((float)speed);
  77. child[curchild]->guiobject_gotoTarget();
  78. }
  79. int nextchild = curchild == 1 ? 0 : 1;
  80. if (child[nextchild]) {
  81. ifc_window *w = child[nextchild]->guiobject_getRootWnd();
  82. WASABI_API_SKIN->group_destroy(w);
  83. child[nextchild] = NULL;
  84. }
  85. if (grp && *grp) {
  86. ifc_window *w = WASABI_API_SKIN->group_create(grp);
  87. if (w) {
  88. child[nextchild] = w->getGuiObject();
  89. w->setParent(this);
  90. w->setStartHidden(1);
  91. RECT r;
  92. getClientRect(&r);
  93. w->setAlpha(0);
  94. w->init(this);
  95. w->setVisible(1);
  96. w->resize(r.left, r.top, r.right-r.left, r.bottom-r.top);
  97. child[nextchild]->guiobject_setTargetA(255);
  98. child[nextchild]->guiobject_setTargetSpeed((float)speed);
  99. child[nextchild]->guiobject_gotoTarget();
  100. id[nextchild] = grp;
  101. }
  102. }
  103. curchild = nextchild;
  104. }