canvas.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef NULLSOFT_WASABI_CANVAS_H
  2. #define NULLSOFT_WASABI_CANVAS_H
  3. #include <Carbon/Carbon.h>
  4. #include <tataki/canvas/ifc_canvas.h>
  5. #include <bfc/platform/platform.h>
  6. #include <api/service/svcs/svc_font.h> // for STDFONT_* stuff. should make a std_font thingy later
  7. #include <bfc/std.h> // for WASABI_DEFAULT_FONTNAMEW
  8. class BaseWnd;
  9. class api_region;
  10. class Canvas : public ifc_canvas
  11. {
  12. public:
  13. Canvas() :context(0), wnd(0) {}
  14. Canvas(CGContextRef _context) : context(_context), wnd(0) {}
  15. Canvas(CGrafPtr _context);
  16. HDC getHDC();
  17. void fillRect(const RECT *r, RGB32 color);
  18. void fillRgn(api_region *r, RGB32 color);
  19. void setBaseWnd(BaseWnd *_wnd) { wnd=_wnd; }
  20. void selectClipRgn(api_region *r);
  21. virtual void blit(int srcx, int srcy, Canvas *dest, int dstx, int dsty, int dstw, int dsth);
  22. virtual void stretchblit(int srcx, int srcy, int srcw, int srch, Canvas *dest, int dstx, int dsty, int dstw, int dsth);
  23. void textOut(int x, int y, const wchar_t *txt, const Wasabi::FontInfo *fontInfo);
  24. static float getSystemFontScale() { return 1.0f; }
  25. int getTextWidth(const wchar_t *text, const Wasabi::FontInfo *fontInfo);
  26. int getTextHeight(const wchar_t *text, const Wasabi::FontInfo *fontInfo);
  27. int getTextHeight(const Wasabi::FontInfo *fontInfo)
  28. {
  29. return getTextHeight(L"M", fontInfo);
  30. }
  31. void getTextExtent(const wchar_t *text, int *w, int *h, const Wasabi::FontInfo *fontInfo);
  32. void textOutCentered(RECT *r, const wchar_t *txt, const Wasabi::FontInfo *fontInfo);
  33. void textOut(int x, int y, int w, int h, const wchar_t *txt, const Wasabi::FontInfo *fontInfo);
  34. void textOutEllipsed(int x, int y, int w, int h, const wchar_t *txt, const Wasabi::FontInfo *fontInfo);
  35. void drawSysObject(const RECT *r, int sysobj, int alpha=255);
  36. protected:
  37. RECVS_DISPATCH;
  38. CGContextRef context;
  39. BaseWnd *wnd; // TODO: not 100% sure we'll need this. win32 version has it so we'll keep it for now
  40. };
  41. class BaseCloneCanvas : public Canvas
  42. {
  43. public:
  44. BaseCloneCanvas(ifc_canvas *cloner=NULL);
  45. virtual ~BaseCloneCanvas();
  46. int clone(ifc_canvas *cloner);
  47. };
  48. namespace DrawSysObj {
  49. enum {
  50. BUTTON, BUTTON_PUSHED, BUTTON_DISABLED,
  51. OSBUTTON, OSBUTTON_PUSHED, OSBUTTON_DISABLED,
  52. OSBUTTON_CLOSE, OSBUTTON_CLOSE_PUSHED, OSBUTTON_CLOSE_DISABLED,
  53. OSBUTTON_MINIMIZE, OSBUTTON_MINIMIZE_PUSHED, OSBUTTON_MINIMIZE_DISABLED,
  54. OSBUTTON_MAXIMIZE, OSBUTTON_MAXIMIZE_PUSHED, OSBUTTON_MAXIMIZE_DISABLED,
  55. };
  56. };
  57. #endif