paintcb.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "precomp.h"
  2. #include "paintcb.h"
  3. #include "api_window.h"
  4. #define CBCLASS PaintCallbackInfoI
  5. START_DISPATCH;
  6. CB(PAINTCBINFO_GETCANVAS, getCanvas);
  7. CB(PAINTCBINFO_GETREGION, getRegion);
  8. END_DISPATCH;
  9. PaintCallback::PaintCallback(ifc_window *w) {
  10. monitorWindow(w);
  11. }
  12. PaintCallback::~PaintCallback() {
  13. if (wnd != NULL) viewer_delViewItem(wnd);
  14. }
  15. void PaintCallback::monitorWindow(ifc_window *w) {
  16. if (wnd != NULL) {
  17. viewer_delViewItem(wnd);
  18. wnd = NULL;
  19. }
  20. if (w != NULL) {
  21. viewer_addViewItem(w);
  22. wnd = w;
  23. }
  24. }
  25. int PaintCallback::viewer_onItemDeleted(ifc_window *item) {
  26. ASSERT(item == wnd);//jic
  27. onWindowDeleted(wnd);
  28. wnd = NULL;
  29. return 1;
  30. }
  31. int PaintCallback::viewer_onEvent(ifc_window *item, int event, intptr_t param, void *ptr, size_t ptrlen) {
  32. PaintCallbackInfo *info = reinterpret_cast<PaintCallbackInfo *>(ptr);
  33. switch (event) {
  34. case ifc_window::Event_ONPAINT:
  35. if (param == BEFOREPAINT)
  36. onBeforePaint(info);
  37. else
  38. onAfterPaint(info);
  39. break;
  40. case ifc_window::Event_ONINVALIDATE:
  41. onInvalidation(info);
  42. break;
  43. }
  44. return 1;
  45. }