skinwnd.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #include <precomp.h>
  2. #include "skinwnd.h"
  3. #include <api/wnd/api_window.h>
  4. #include <api/wnd/wndclass/guiobjwnd.h>
  5. #include <api/script/scriptguid.h>
  6. #include <api/script/objects/c_script/c_group.h>
  7. #include <api/script/objects/c_script/c_layout.h>
  8. #include <api/script/objects/c_script/c_container.h>
  9. #include <api/wnd/wndclass/wndholder.h>
  10. SkinWnd::SkinWnd(const wchar_t *group_id, const wchar_t *prefered_container, int container_flag, RECT *animated_rect_source, int transcient, int starthidden)
  11. {
  12. isnew = 0;
  13. wnd = WASABI_API_WNDMGR->skinwnd_createByGroupId(group_id, prefered_container, container_flag, animated_rect_source, transcient, starthidden, &isnew);
  14. notifyMinMaxChanged();
  15. }
  16. SkinWnd::SkinWnd(GUID svc_or_group_guid, const wchar_t *prefered_container, int container_flag, RECT *animated_rect_source, int transcient, int starthidden)
  17. {
  18. isnew = 0;
  19. wnd = WASABI_API_WNDMGR->skinwnd_createByGuid(svc_or_group_guid, prefered_container, container_flag, animated_rect_source, transcient, starthidden, &isnew);
  20. notifyMinMaxChanged();
  21. }
  22. SkinWnd::~SkinWnd()
  23. {}
  24. void SkinWnd::destroy(RECT *animated_rect_dest)
  25. {
  26. if (wnd == NULL) return ;
  27. if (!isnew)
  28. {
  29. ifc_window *w = wnd->findWindowByInterface(windowHolderGuid);
  30. WindowHolder *wh = static_cast<WindowHolder*>(w->getInterface(windowHolderGuid));
  31. if (wh != NULL)
  32. {
  33. wh->onRemoveWindow();
  34. return ;
  35. }
  36. }
  37. WASABI_API_WNDMGR->skinwnd_destroy(wnd, animated_rect_dest);
  38. }
  39. int SkinWnd::runModal(int center)
  40. {
  41. if (wnd == NULL) return 0;
  42. ifc_window *w = wnd->getDesktopParent();
  43. if (center)
  44. {
  45. C_Layout l(getLayout());
  46. l.center();
  47. }
  48. w->setVisible(1);
  49. return w->runModal();
  50. }
  51. void SkinWnd::endModal(int retcode)
  52. {
  53. if (wnd == NULL) return ;
  54. wnd->endModal(retcode);
  55. }
  56. GuiObject *SkinWnd::findObject(const wchar_t *object_id)
  57. {
  58. if (wnd == NULL) return NULL;
  59. GuiObject *obj = NULL;
  60. obj = static_cast<GuiObject *>(wnd->getInterface(guiObjectGuid));
  61. return obj->guiobject_findObject(object_id);
  62. }
  63. ScriptObject *SkinWnd::getContainer()
  64. {
  65. if (wnd == NULL) return NULL;
  66. ifc_window *dw = wnd->getDesktopParent();
  67. if (!dw) return NULL;
  68. ScriptObject *o = static_cast<ScriptObject *>(dw->getInterface(scriptObjectGuid));
  69. if (o != NULL)
  70. {
  71. return C_Layout(o).getContainer();
  72. }
  73. return NULL;
  74. }
  75. ScriptObject *SkinWnd::getLayout()
  76. {
  77. if (wnd == NULL) return NULL;
  78. ifc_window *dw = wnd->getDesktopParent();
  79. if (!dw) return NULL;
  80. ScriptObject *o = static_cast<ScriptObject *>(dw->getInterface(scriptObjectGuid));
  81. return o;
  82. }
  83. void SkinWnd::notifyMinMaxChanged()
  84. {
  85. if (wnd != NULL)
  86. {
  87. wnd->signalMinMaxEnforcerChanged();
  88. }
  89. }