canvas.h 2.5 KB

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