rootwndholder.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #include "precomp.h"
  2. #include <api/wnd/api_wnd.h>
  3. #include "rootwndholder.h"
  4. #include <api/wnd/notifmsg.h>
  5. #include <tataki/canvas/canvas.h>
  6. RootWndHolder::RootWndHolder() {
  7. privptr = NULL;
  8. }
  9. RootWndHolder::~RootWndHolder() {
  10. }
  11. void RootWndHolder::rootwndholder_getRect(RECT *r) {
  12. if (isInited())
  13. getClientRect(r);
  14. else
  15. MEMSET(r, 0, sizeof(RECT));
  16. }
  17. int RootWndHolder::onInit() {
  18. ROOTWNDHOLDER_PARENT::onInit();
  19. ifc_window *w = rootwndholder_getRootWnd();
  20. if (w) {
  21. checkInit(w);
  22. setName(rootwndholder_getRootWnd()->getRootWndName());
  23. }
  24. return 1;
  25. }
  26. void RootWndHolder::checkInit(ifc_window *w) {
  27. if (w && !w->isInited()) {
  28. if (w->getParent() == NULL)
  29. w->setParent(this);
  30. // w->setStartHidden(getStartHidden());
  31. w->init(this);
  32. }
  33. }
  34. int RootWndHolder::onResize() {
  35. int rv = ROOTWNDHOLDER_PARENT::onResize();
  36. if (!isInited()) return 1;
  37. ifc_window *held = rootwndholder_getRootWnd();
  38. if (!held) return rv;
  39. RECT r;
  40. rootwndholder_getRect(&r);
  41. if (renderRatioActive() && !held->handleRatio())
  42. multRatio(&r);
  43. held->resize(r.left, r.top, r.right-r.left, r.bottom-r.top);
  44. return rv;
  45. }
  46. /*void RootWndHolder::onSetVisible(int v) {
  47. ROOTWNDHOLDER_PARENT::onSetVisible(v);
  48. if (!rootwndholder_getRootWnd()) return;
  49. rootwndholder_getRootWnd()->setVisible(v);
  50. }*/
  51. int RootWndHolder::onActivate() {
  52. int r = ROOTWNDHOLDER_PARENT::onActivate();
  53. if (rootwndholder_getRootWnd())
  54. rootwndholder_getRootWnd()->onActivate();
  55. return r;
  56. }
  57. int RootWndHolder::onDeactivate() {
  58. int r = ROOTWNDHOLDER_PARENT::onDeactivate();
  59. if (rootwndholder_getRootWnd())
  60. rootwndholder_getRootWnd()->onDeactivate();
  61. return r;
  62. }
  63. int RootWndHolder::getPreferences(int what) {
  64. if (rootwndholder_getRootWnd())
  65. return rootwndholder_getRootWnd()->getPreferences(what);
  66. return ROOTWNDHOLDER_PARENT::getPreferences(what);
  67. }
  68. ifc_window *RootWndHolder::rootwndholder_getRootWnd() {
  69. return privptr;
  70. }
  71. void RootWndHolder::rootwndholder_setRootWnd(ifc_window *w) {
  72. if (privptr == w) return;
  73. privptr = w;
  74. checkInit(w);
  75. if (isPostOnInit())
  76. onResize();
  77. }
  78. int RootWndHolder::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) {
  79. if (rootwndholder_getRootWnd())
  80. return rootwndholder_getRootWnd()->onAction(action, param, x, y, p1, p2, data, datalen, source);
  81. return ROOTWNDHOLDER_PARENT::onAction(action, param, x, y, p1, p2, data, datalen, source);
  82. }
  83. int RootWndHolder::childNotify(ifc_window *child, int msg, intptr_t param1, intptr_t param2) {
  84. if (msg == ChildNotify::NAMECHANGED && child == rootwndholder_getRootWnd())
  85. setName(child->getRootWndName());
  86. return passNotifyUp(child, msg, (int)param1, (int)param2);
  87. }
  88. int RootWndHolder::onPaint(Canvas *c) {
  89. int rt = ROOTWNDHOLDER_PARENT::onPaint(c);
  90. if (wantRenderBaseTexture()) {
  91. RECT r;
  92. rootwndholder_getRect(&r);
  93. WASABI_API_WND->skin_renderBaseTexture(getBaseTextureWindow(), c, r, this);
  94. }
  95. return rt;
  96. }