aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/wnd/paintcb.h
blob: acb6fc6ecc64b31baa7b17d94c9f1c98e47d3b67 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef _PAINTCB_H
#define _PAINTCB_H

#include <bfc/depview.h>
#include <bfc/dispatch.h>
#include <api/wnd/api_window.h>

class Canvas;
class api_region;

class PaintCallbackInfo : public Dispatchable {
  public:
    Canvas *getCanvas();
    api_region *getRegion();

  enum {
    PAINTCBINFO_GETCANVAS = 10,
    PAINTCBINFO_GETREGION = 20,
  };

};

inline Canvas *PaintCallbackInfo::getCanvas() {
  return _call(PAINTCBINFO_GETCANVAS, (Canvas *)NULL);
}

inline api_region *PaintCallbackInfo::getRegion() {
  return _call(PAINTCBINFO_GETREGION, (api_region *)NULL);
}

class PaintCallbackInfoI : public PaintCallbackInfo {
  public:
    PaintCallbackInfoI(Canvas *_canvas, api_region *_region) : canvas(_canvas), region(_region)  {}
    virtual ~PaintCallbackInfoI() {}

    virtual Canvas *getCanvas() { return canvas; }
    virtual api_region *getRegion() { return region; }

  private:

    Canvas *canvas;
    api_region *region;

  protected:
    RECVS_DISPATCH;
};

class PaintCallback : DependentViewerTPtr<ifc_window> {
public:
  PaintCallback() { wnd = NULL; };
  PaintCallback(ifc_window *w);
  virtual ~PaintCallback();

  virtual void monitorWindow(ifc_window *w);
  virtual int viewer_onEvent(ifc_window *item, int event, intptr_t param, void *ptr, size_t ptrlen);
  virtual int viewer_onItemDeleted(ifc_window *item);

  // override those
  virtual void onBeforePaint(PaintCallbackInfo *info) { }
  virtual void onAfterPaint(PaintCallbackInfo *info) { }
  virtual void onWindowDeleted(ifc_window *w)=0; // warning, pointer invalid
  virtual void onInvalidation(PaintCallbackInfo *info) { }

  enum {
    BEFOREPAINT = 10,
    AFTERPAINT = 20,
  };

private:
  ifc_window *wnd;
};

#endif