1
0

guiradiogroup.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #include <precomp.h>
  2. #include "guiradiogroup.h"
  3. #include <api/script/objects/c_script/c_button.h>
  4. #include <api/script/objects/guiobject.h>
  5. #include <api/script/scriptguid.h>
  6. void GuiRadioGroup::toggleChild(GuiObject *who) {
  7. int i, num = children.getNumItems();
  8. for (i = 0; i < num; i++) {
  9. GuiObject *childGuiObj = children.enumItem(i);
  10. if (childGuiObj != NULL) {
  11. GuiObject *toggleGuiObj = childGuiObj->guiobject_findObject(L"checkbox.toggle");
  12. if (toggleGuiObj != NULL) {
  13. C_Button buttonObj(*toggleGuiObj);
  14. if (childGuiObj != who) {
  15. buttonObj.setActivated(0);
  16. }
  17. }
  18. }
  19. }
  20. }
  21. void GuiRadioGroup::registerChild(GuiObject *who) {
  22. children.addItem(who);
  23. }
  24. int GuiRadioGroup::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) {
  25. if (!_wcsicmp(action, L"REGISTER") && source != NULL) {
  26. registerChild(static_cast<GuiObject *>(source->getInterface(guiObjectGuid)));
  27. } else if (!_wcsicmp(action, L"TOGGLE")) {
  28. toggleChild(static_cast<GuiObject *>(source->getInterface(guiObjectGuid)));
  29. return 1;
  30. }
  31. return GUIRADIOGROUP_PARENT::onAction(action, param, x, y, p1, p2, data, datalen, source);
  32. }