1
0

paintcb.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef _PAINTCB_H
  2. #define _PAINTCB_H
  3. #include <bfc/depview.h>
  4. #include <bfc/dispatch.h>
  5. #include <api/wnd/api_window.h>
  6. class Canvas;
  7. class api_region;
  8. class PaintCallbackInfo : public Dispatchable {
  9. public:
  10. Canvas *getCanvas();
  11. api_region *getRegion();
  12. enum {
  13. PAINTCBINFO_GETCANVAS = 10,
  14. PAINTCBINFO_GETREGION = 20,
  15. };
  16. };
  17. inline Canvas *PaintCallbackInfo::getCanvas() {
  18. return _call(PAINTCBINFO_GETCANVAS, (Canvas *)NULL);
  19. }
  20. inline api_region *PaintCallbackInfo::getRegion() {
  21. return _call(PAINTCBINFO_GETREGION, (api_region *)NULL);
  22. }
  23. class PaintCallbackInfoI : public PaintCallbackInfo {
  24. public:
  25. PaintCallbackInfoI(Canvas *_canvas, api_region *_region) : canvas(_canvas), region(_region) {}
  26. virtual ~PaintCallbackInfoI() {}
  27. virtual Canvas *getCanvas() { return canvas; }
  28. virtual api_region *getRegion() { return region; }
  29. private:
  30. Canvas *canvas;
  31. api_region *region;
  32. protected:
  33. RECVS_DISPATCH;
  34. };
  35. class PaintCallback : DependentViewerTPtr<ifc_window> {
  36. public:
  37. PaintCallback() { wnd = NULL; };
  38. PaintCallback(ifc_window *w);
  39. virtual ~PaintCallback();
  40. virtual void monitorWindow(ifc_window *w);
  41. virtual int viewer_onEvent(ifc_window *item, int event, intptr_t param, void *ptr, size_t ptrlen);
  42. virtual int viewer_onItemDeleted(ifc_window *item);
  43. // override those
  44. virtual void onBeforePaint(PaintCallbackInfo *info) { }
  45. virtual void onAfterPaint(PaintCallbackInfo *info) { }
  46. virtual void onWindowDeleted(ifc_window *w)=0; // warning, pointer invalid
  47. virtual void onInvalidation(PaintCallbackInfo *info) { }
  48. enum {
  49. BEFOREPAINT = 10,
  50. AFTERPAINT = 20,
  51. };
  52. private:
  53. ifc_window *wnd;
  54. };
  55. #endif