ifc_canvas.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #ifndef NULLSOFT_TATAKI_IFC_CANVAS_H
  2. #define NULLSOFT_TATAKI_IFC_CANVAS_H
  3. #include <bfc/dispatch.h>
  4. #include <bfc/platform/platform.h>
  5. #include <api/service/svcs/svc_font.h> // for STDFONT_* stuff. should make a std_font thingy later
  6. #include <bfc/wasabi_std.h> // for WASABI_DEFAULT_FONTNAMEW
  7. namespace Wasabi
  8. {
  9. // benski> move this to std_font later
  10. struct FontInfo
  11. {
  12. FontInfo()
  13. {
  14. // defaults
  15. face = WASABI_DEFAULT_FONTNAMEW;
  16. pointSize = 12;
  17. bold = 0;
  18. opaque = false;
  19. underline = false;
  20. italic = false;
  21. alignFlags = STDFONT_LEFT;
  22. antialias = 1;
  23. bgColor = RGBA(255, 255, 255, 255);
  24. color = RGBA(0, 0, 0, 0);
  25. }
  26. const wchar_t *face;
  27. unsigned int pointSize;
  28. int bold; // bold level
  29. bool opaque;
  30. bool underline;
  31. bool italic;
  32. int alignFlags;
  33. int antialias; // anti-alias level
  34. ARGB32 color;
  35. ARGB32 bgColor;
  36. };
  37. }
  38. class ifc_window;
  39. // abstract base class: safe to use in API
  40. class NOVTABLE ifc_canvas : public Dispatchable
  41. {
  42. protected:
  43. ifc_canvas()
  44. {} // protect constructor
  45. ~ifc_canvas()
  46. {}
  47. public:
  48. DISPATCH_CODES
  49. {
  50. GETHDC = 100,
  51. GETROOTWND = 200,
  52. GETBITS = 300,
  53. GETOFFSETS = 400,
  54. ISFIXEDCOORDS = 500,
  55. GETDIM = 600,
  56. GETTEXTFONT = 700,
  57. GETTEXTSIZE = 710,
  58. GETTEXTBOLD = 720,
  59. GETTEXTOPAQUE = 730,
  60. GETTEXTALIGN = 740,
  61. GETTEXTCOLOR = 750,
  62. GETTEXTBKCOLOR = 760,
  63. GETTEXTAA = 770,
  64. GETTEXTUNDERLINE = 780,
  65. GETTEXTITALIC = 790,
  66. GETCLIPBOX = 800,
  67. };
  68. public:
  69. HDC getHDC();
  70. ifc_window *getRootWnd();
  71. void *getBits();
  72. void getOffsets(int *x, int *y);
  73. bool isFixedCoords(); //FG> allows onPaint to handle double buffers as well as normal DCs
  74. bool getDim(int *w, int *h = NULL, int *p = NULL); // w & h in pixels, pitch in bytes. 0 on success.
  75. int getClipBox(RECT *r); // returns 0 if no clipping region
  76. const wchar_t *getTextFont();
  77. int getTextSize();
  78. int getTextBold();
  79. int getTextAntialias();
  80. int getTextOpaque();
  81. int getTextUnderline();
  82. int getTextItalic();
  83. int getTextAlign();
  84. ARGB32 getTextColor();
  85. ARGB32 getTextBkColor();
  86. };
  87. inline HDC ifc_canvas::getHDC()
  88. {
  89. return _call(ifc_canvas::GETHDC, (HDC)0);
  90. }
  91. inline ifc_window *ifc_canvas::getRootWnd()
  92. {
  93. return _call(ifc_canvas::GETROOTWND, (ifc_window*)0);
  94. }
  95. inline void *ifc_canvas::getBits()
  96. {
  97. return _call(ifc_canvas::GETBITS, (void *)0);
  98. }
  99. inline void ifc_canvas::getOffsets(int *x, int *y)
  100. {
  101. _voidcall(ifc_canvas::GETOFFSETS, x, y);
  102. }
  103. inline bool ifc_canvas::isFixedCoords()
  104. { //FG> allows onPaint to handle double buffers as well as normal DCs
  105. return _call(ifc_canvas::ISFIXEDCOORDS, false);
  106. }
  107. inline bool ifc_canvas::getDim(int *w, int *h, int *p)
  108. { // w & h in pixels, pitch in bytes. 0 on success.
  109. return _call(ifc_canvas::GETDIM, false, w, h, p);
  110. }
  111. inline int ifc_canvas::getClipBox(RECT *r)
  112. { // returns 0 if no clipping region
  113. return _call(ifc_canvas::GETCLIPBOX, 0, r);
  114. }
  115. inline const wchar_t *ifc_canvas::getTextFont()
  116. {
  117. return _call(ifc_canvas::GETTEXTFONT, L"");
  118. }
  119. inline int ifc_canvas::getTextSize()
  120. {
  121. return _call(ifc_canvas::GETTEXTSIZE, -1);
  122. }
  123. inline int ifc_canvas::getTextBold()
  124. {
  125. return _call(ifc_canvas::GETTEXTBOLD, 0);
  126. }
  127. inline int ifc_canvas::getTextAntialias()
  128. {
  129. return _call(ifc_canvas::GETTEXTAA, 0);
  130. }
  131. inline int ifc_canvas::getTextOpaque()
  132. {
  133. return _call(ifc_canvas::GETTEXTOPAQUE, 0);
  134. }
  135. inline int ifc_canvas::getTextUnderline()
  136. {
  137. return _call(ifc_canvas::GETTEXTUNDERLINE, 0);
  138. }
  139. inline int ifc_canvas::getTextItalic()
  140. {
  141. return _call(ifc_canvas::GETTEXTITALIC, 0);
  142. }
  143. inline int ifc_canvas::getTextAlign()
  144. {
  145. return _call(ifc_canvas::GETTEXTALIGN, -1);
  146. }
  147. inline ARGB32 ifc_canvas::getTextColor()
  148. {
  149. return _call(ifc_canvas::GETTEXTCOLOR, RGB(0, 0, 0));
  150. }
  151. inline ARGB32 ifc_canvas::getTextBkColor()
  152. {
  153. return _call(ifc_canvas::GETTEXTBKCOLOR, RGB(255, 255, 255));
  154. }
  155. typedef ifc_canvas api_canvas;
  156. #endif