PageRenderTime 283ms CodeModel.GetById 37ms RepoModel.GetById 5ms app.codeStats 0ms

/platform/osx/scaffold/graphics.d

https://github.com/bradk/djehuty
D | 246 lines | 157 code | 66 blank | 23 comment | 17 complexity | 0d615a47d1c4d78c9e743ff3b0c069c0 MD5 | raw file
  1. /*
  2. * graphics.d
  3. *
  4. * This Scaffold holds the Graphics implementations for the Linux platform
  5. *
  6. * Author: Dave Wilkinson
  7. *
  8. */
  9. module scaffold.graphics;
  10. import core.string;
  11. import core.color;
  12. import core.main;
  13. import core.definitions;
  14. import core.string;
  15. import graphics.view;
  16. import graphics.graphics;
  17. import platform.unix.common;
  18. import platform.vars.view;
  19. import platform.vars.region;
  20. import platform.vars.brush;
  21. import platform.vars.pen;
  22. import platform.vars.font;
  23. import graphics.region;
  24. import math.common;
  25. import binding.c;
  26. // Shapes
  27. // Draw a line
  28. extern(C) void _OSXDrawLine(_OSXViewPlatformVars* viewVars, int fromWindow, int x, int y, int x2, int y2);
  29. void drawLine(ViewPlatformVars* viewVars, int x, int y, int x2, int y2) {
  30. _OSXDrawLine(viewVars.vars, viewVars.fromWindow == 1, x, y, x2, y2);
  31. }
  32. // Draw a rectangle (filled with the current brush, outlined with current pen)
  33. extern(C) void _OSXDrawRect(_OSXViewPlatformVars* viewVars, int fromWindow, int x, int y, int x2, int y2);
  34. void drawRect(ViewPlatformVars* viewVars, int x, int y, int width, int height) {
  35. _OSXDrawRect(viewVars.vars, viewVars.fromWindow == 1, x, y, width, height);
  36. }
  37. extern(C) void _OSXFillRect(_OSXViewPlatformVars* viewVars, int fromWindow, int x, int y, int x2, int y2);
  38. void fillRect(ViewPlatformVars* viewVars, int x, int y, int width, int height) {
  39. _OSXFillRect(viewVars.vars, viewVars.fromWindow == 1, x, y, width, height);
  40. }
  41. extern(C) void _OSXStrokeRect(_OSXViewPlatformVars* viewVars, int fromWindow, int x, int y, int x2, int y2);
  42. void strokeRect(ViewPlatformVars* viewVars, int x, int y, int width, int height) {
  43. _OSXStrokeRect(viewVars.vars, viewVars.fromWindow == 1, x, y, width, height);
  44. }
  45. // Draw an ellipse (filled with current brush, outlined with current pen)
  46. extern(C) void _OSXDrawOval(_OSXViewPlatformVars* viewVars, int fromWindow, int x, int y, int x2, int y2);
  47. void drawOval(ViewPlatformVars* viewVars, int x, int y, int width, int height) {
  48. _OSXDrawRect(viewVars.vars, viewVars.fromWindow == 1, x, y, width, height);
  49. }
  50. extern(C) void _OSXFillOval(_OSXViewPlatformVars* viewVars, int fromWindow, int x, int y, int x2, int y2);
  51. void fillOval(ViewPlatformVars* viewVars, int x, int y, int width, int height) {
  52. _OSXFillRect(viewVars.vars, viewVars.fromWindow == 1, x, y, width, height);
  53. }
  54. extern(C) void _OSXStrokeOval(_OSXViewPlatformVars* viewVars, int fromWindow, int x, int y, int x2, int y2);
  55. void strokeOval(ViewPlatformVars* viewVars, int x, int y, int width, int height) {
  56. _OSXStrokeRect(viewVars.vars, viewVars.fromWindow == 1, x, y, width, height);
  57. }
  58. void drawPie(ViewPlatformVars* viewVars, int x, int y, int width, int height, double startAngle, double sweepAngle) {
  59. }
  60. void fillPie(ViewPlatformVars* viewVars, int x, int y, int width, int height, double startAngle, double sweepAngle) {
  61. }
  62. void strokePie(ViewPlatformVars* viewVars, int x, int y, int width, int height, double startAngle, double sweepAngle) {
  63. }
  64. // Fonts
  65. void createFont(FontPlatformVars* font, string fontname, int fontsize, int weight, bool italic, bool underline, bool strikethru) {
  66. }
  67. void setFont(ViewPlatformVars* viewVars, FontPlatformVars* font)
  68. {
  69. }
  70. void destroyFont(FontPlatformVars* font)
  71. {
  72. }
  73. // Text
  74. extern(C) void _OSXDrawText(_OSXViewPlatformVars* viewVars, int fromWindow, int x, int y, char* str);
  75. void drawText(ViewPlatformVars* viewVars, int x, int y, string str) {
  76. string tmp = str.dup ~ '\0';
  77. _OSXDrawText(viewVars.vars, viewVars.fromWindow == 1, x, y, tmp.ptr);
  78. }
  79. void drawText(ViewPlatformVars* viewVars, int x, int y, string str, uint length) {
  80. string tmp = str[0..length].dup ~ '\0';
  81. _OSXDrawText(viewVars.vars, viewVars.fromWindow == 1, x, y, tmp.ptr);
  82. }
  83. // Clipped Text
  84. void drawClippedText(ViewPlatformVars* viewVars, int x, int y, Rect region, string str) {
  85. }
  86. void drawClippedText(ViewPlatformVars* viewVars, int x, int y, Rect region, string str, uint length) {
  87. }
  88. // Text Measurement
  89. extern(C) void _OSXMeasureText(_OSXViewPlatformVars* viewVars, int fromWindow, char* str, uint* w, uint* h);
  90. void measureText(ViewPlatformVars* viewVars, string str, out Size sz) {
  91. string tmp = str.dup ~ '\0';
  92. _OSXMeasureText(viewVars.vars, viewVars.fromWindow == 1, tmp.ptr, &sz.x, &sz.y);
  93. }
  94. void measureText(ViewPlatformVars* viewVars, string str, uint length, out Size sz) {
  95. string tmp = str[0..length].dup ~ '\0';
  96. _OSXMeasureText(viewVars.vars, viewVars.fromWindow == 1, tmp.ptr, &sz.x, &sz.y);
  97. }
  98. // Text Colors
  99. void setTextBackgroundColor(ViewPlatformVars* viewVars, ref Color textColor) {
  100. }
  101. void setTextColor(ViewPlatformVars* viewVars, ref Color textColor)
  102. {
  103. }
  104. // Text States
  105. void setTextModeTransparent(ViewPlatformVars* viewVars)
  106. {
  107. }
  108. void setTextModeOpaque(ViewPlatformVars* viewVars)
  109. {
  110. }
  111. // Graphics States
  112. void setAntialias(ViewPlatformVars* viewVars, bool value) {
  113. }
  114. // Brushes
  115. extern(C) void _OSXCreateBrush(void** brush, double r, double g, double b, double a);
  116. void createBrush(BrushPlatformVars* brush, Color clr) {
  117. _OSXCreateBrush(&brush.brush, clr.red, clr.green, clr.blue, clr.alpha);
  118. }
  119. extern(C) void _OSXUseBrush(_OSXViewPlatformVars* viewVars, int fromWindow, void* brush);
  120. void setBrush(ViewPlatformVars* viewVars, BrushPlatformVars* brush) {
  121. _OSXUseBrush(viewVars.vars, viewVars.fromWindow == 1, brush.brush);
  122. }
  123. extern(C) void _OSXDestroyBrush(void* brush);
  124. void destroyBrush(BrushPlatformVars* brush) {
  125. _OSXDestroyBrush(brush.brush);
  126. }
  127. // BitmapBrush
  128. void createBitmapBrush(BrushPlatformVars* brush, ref ViewPlatformVars viewVarsSrc) {
  129. }
  130. void createGradientBrush(BrushPlatformVars* brush, double origx, double origy, double[] points, Color[] clrs, double angle, double width) {
  131. }
  132. // Pens
  133. extern(C) void _OSXCreatePen(void** pen, double r, double g, double b, double a);
  134. void createPen(PenPlatformVars* pen, ref Color clr, double width) {
  135. _OSXCreatePen(&pen.pen, clr.red, clr.green, clr.blue, clr.alpha);
  136. }
  137. void createPenWithBrush(PenPlatformVars* pen, ref BrushPlatformVars brush, double width) {
  138. }
  139. extern(C) void _OSXUsePen(_OSXViewPlatformVars* viewVars, int fromWindow, void* pen);
  140. void setPen(ViewPlatformVars* viewVars, PenPlatformVars* pen) {
  141. _OSXUsePen(viewVars.vars, viewVars.fromWindow == 1, pen.pen);
  142. }
  143. extern(C) void _OSXDestroyPen(void* pen);
  144. void destroyPen(PenPlatformVars* pen) {
  145. _OSXDestroyPen(pen.pen);
  146. }
  147. // View Interfacing
  148. extern(C) void _OSXDrawViewXY(_OSXViewPlatformVars* viewVars, int fromWindow, _OSXViewPlatformVars* srcViewVars, int srcFromWindow, int x, int y, int srcX, int srcY);
  149. void drawView(ref ViewPlatformVars* viewVars, ref View view, int x, int y, ref ViewPlatformVars* viewVarsSrc, ref View srcView) {
  150. _OSXDrawViewXY(viewVars.vars, viewVars.fromWindow == 1, viewVarsSrc.vars, viewVarsSrc.fromWindow == 1, x, y, 0, 0);
  151. }
  152. void drawView(ref ViewPlatformVars* viewVars, ref View view, int x, int y, ref ViewPlatformVars* viewVarsSrc, ref View srcView, int viewX, int viewY) {
  153. _OSXDrawViewXY(viewVars.vars, viewVars.fromWindow == 1, viewVarsSrc.vars, viewVarsSrc.fromWindow == 1, x, y, viewX, viewY);
  154. }
  155. void drawView(ref ViewPlatformVars* viewVars, ref View view, int x, int y, ref ViewPlatformVars* viewVarsSrc, ref View srcView, int viewX, int viewY, int viewWidth, int viewHeight) {
  156. }
  157. void drawView(ref ViewPlatformVars* viewVars, ref View view, int x, int y, ref ViewPlatformVars* viewVarsSrc, ref View srcView, double opacity) {
  158. }
  159. void drawView(ref ViewPlatformVars* viewVars, ref View view, int x, int y, ref ViewPlatformVars* viewVarsSrc, ref View srcView, int viewX, int viewY, double opacity) {
  160. }
  161. void drawView(ref ViewPlatformVars* viewVars, ref View view, int x, int y, ref ViewPlatformVars* viewVarsSrc, ref View srcView, int viewX, int viewY, int viewWidth, int viewHeight, double opacity) {
  162. }
  163. void fillRegion(ViewPlatformVars* viewVars, RegionPlatformVars* rgnVars, bool rgnPlatformDirty, Region rgn, int x, int y) {
  164. }
  165. void strokeRegion(ViewPlatformVars* viewVars, RegionPlatformVars* rgnVars, bool rgnPlatformDirty, Region rgn, int x, int y) {
  166. }
  167. void drawRegion(ViewPlatformVars* viewVars, RegionPlatformVars* rgnVars, bool rgnPlatformDirty, Region rgn, int x, int y) {
  168. }
  169. void clipSave(ViewPlatformVars* viewVars)
  170. {
  171. }
  172. void clipRestore(ViewPlatformVars* viewVars)
  173. {
  174. }
  175. void clipRect(ViewPlatformVars* viewVars, int x, int y, int x2, int y2)
  176. {
  177. }
  178. void clipRegion(ViewPlatformVars* viewVars, Region region)
  179. {
  180. }