Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

1243 рядки
45 KiB

  1. /*
  2. * libcaca .NET bindings for libcaca
  3. * Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>
  4. * 2007 Sam Hocevar <sam@zoy.org>
  5. * All Rights Reserved
  6. *
  7. * $Id$
  8. *
  9. * This library is free software. It comes without any warranty, to
  10. * the extent permitted by applicable law. You can redistribute it
  11. * and/or modify it under the terms of the Do What The Fuck You Want
  12. * To Public License, Version 2, as published by Sam Hocevar. See
  13. * http://sam.zoy.org/wtfpl/COPYING for more details.
  14. */
  15. using System;
  16. using System.Runtime.InteropServices;
  17. using System.Security;
  18. using System.Drawing;
  19. namespace Caca
  20. {
  21. /* Static libcaca stuff that does not fit in any object */
  22. public static class Libcaca
  23. {
  24. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  25. SuppressUnmanagedCodeSecurity]
  26. private static extern int caca_rand(int min, int max);
  27. public static int Rand(int min, int max)
  28. {
  29. return caca_rand(min, max);
  30. }
  31. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  32. SuppressUnmanagedCodeSecurity]
  33. private static extern IntPtr caca_get_version();
  34. public static string getVersion()
  35. {
  36. return Marshal.PtrToStringAnsi(caca_get_version());
  37. }
  38. public const uint BLACK = 0x00,
  39. BLUE = 0x01,
  40. GREEN = 0x02,
  41. CYAN = 0x03,
  42. RED = 0x04,
  43. MAGENTA = 0x05,
  44. BROWN = 0x06,
  45. LIGHTGRAY = 0x07,
  46. DARKGRAY = 0x08,
  47. LIGHTBLUE = 0x09,
  48. LIGHTGREEN = 0x0a,
  49. LIGHTCYAN = 0x0b,
  50. LIGHTRED = 0x0c,
  51. LIGHTMAGENTA = 0x0d,
  52. YELLOW = 0x0e,
  53. WHITE = 0x0f,
  54. DEFAULT = 0x10,
  55. TRANSPARENT = 0x20;
  56. public const uint BOLD = 0x01,
  57. ITALICS = 0x02,
  58. UNDERLINE = 0x04,
  59. BLINK = 0x08;
  60. }
  61. public enum CacaEventType
  62. {
  63. NONE = 0x0000,
  64. KEY_PRESS = 0x0001,
  65. KEY_RELEASE = 0x0002,
  66. MOUSE_PRESS = 0x0004,
  67. MOUSE_RELEASE = 0x0008,
  68. MOUSE_MOTION = 0x0010,
  69. RESIZE = 0x0020,
  70. QUIT = 0x0040,
  71. ANY = 0xffff,
  72. }
  73. public enum CacaEventKey
  74. {
  75. UNKNOWN = 0x00,
  76. CTRL_A = 0x01,
  77. CTRL_B = 0x02,
  78. CTRL_C = 0x03,
  79. CTRL_D = 0x04,
  80. CTRL_E = 0x05,
  81. CTRL_F = 0x06,
  82. CTRL_G = 0x07,
  83. BACKSPACE = 0x08,
  84. TAB = 0x09,
  85. CTRL_J = 0x0a,
  86. CTRL_K = 0x0b,
  87. CTRL_L = 0x0c,
  88. RETURN = 0x0d,
  89. CTRL_N = 0x0e,
  90. CTRL_O = 0x0f,
  91. CTRL_P = 0x10,
  92. CTRL_Q = 0x11,
  93. CTRL_R = 0x12,
  94. PAUSE = 0x13,
  95. CTRL_T = 0x14,
  96. CTRL_U = 0x15,
  97. CTRL_V = 0x16,
  98. CTRL_W = 0x17,
  99. CTRL_X = 0x18,
  100. CTRL_Y = 0x19,
  101. CTRL_Z = 0x1a,
  102. ESCAPE = 0x1b,
  103. DELETE = 0x7f,
  104. UP = 0x111,
  105. DOWN = 0x112,
  106. LEFT = 0x113,
  107. RIGHT = 0x114,
  108. INSERT = 0x115,
  109. HOME = 0x116,
  110. END = 0x117,
  111. PAGEUP = 0x118,
  112. PAGEDOWN = 0x119,
  113. F1 = 0x11a,
  114. F2 = 0x11b,
  115. F3 = 0x11c,
  116. F4 = 0x11d,
  117. F5 = 0x11e,
  118. F6 = 0x11f,
  119. F7 = 0x120,
  120. F8 = 0x121,
  121. F9 = 0x122,
  122. F10 = 0x123,
  123. F11 = 0x124,
  124. F12 = 0x125,
  125. F13 = 0x126,
  126. F14 = 0x127,
  127. F15 = 0x128,
  128. }
  129. public class CacaCanvas : IDisposable
  130. {
  131. public readonly IntPtr _c_cv;
  132. /* libcaca basic functions */
  133. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  134. SuppressUnmanagedCodeSecurity]
  135. private static extern IntPtr caca_create_canvas(int w, int h);
  136. public CacaCanvas()
  137. {
  138. _c_cv = caca_create_canvas(0, 0);
  139. }
  140. public CacaCanvas(Size s)
  141. {
  142. _c_cv = caca_create_canvas(s.Width, s.Height);
  143. }
  144. public CacaCanvas(int w, int h)
  145. {
  146. _c_cv = caca_create_canvas(h, w);
  147. }
  148. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  149. SuppressUnmanagedCodeSecurity]
  150. private static extern int caca_free_canvas(IntPtr cv);
  151. public void Dispose()
  152. {
  153. /* FIXME: don't destroy ourselves if we're attached */
  154. caca_free_canvas(_c_cv);
  155. GC.SuppressFinalize(this);
  156. }
  157. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  158. SuppressUnmanagedCodeSecurity]
  159. private static extern int caca_set_canvas_size(IntPtr cv,
  160. int w, int h);
  161. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  162. SuppressUnmanagedCodeSecurity]
  163. private static extern int caca_get_canvas_width(IntPtr cv);
  164. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  165. SuppressUnmanagedCodeSecurity]
  166. private static extern int caca_get_canvas_height(IntPtr cv);
  167. public Size Size
  168. {
  169. get { return new Size(caca_get_canvas_width(_c_cv),
  170. caca_get_canvas_height(_c_cv)); }
  171. set { caca_set_canvas_size(_c_cv, value.Width, value.Height); }
  172. }
  173. public Rectangle Rectangle
  174. {
  175. get { return new Rectangle(0, 0, caca_get_canvas_width(_c_cv),
  176. caca_get_canvas_height(_c_cv)); }
  177. set { caca_set_canvas_size(_c_cv, value.Width, value.Height); }
  178. }
  179. /* canvas drawing */
  180. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  181. SuppressUnmanagedCodeSecurity]
  182. private static extern int caca_gotoxy(IntPtr cv, int x, int y);
  183. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  184. SuppressUnmanagedCodeSecurity]
  185. private static extern int caca_get_cursor_x(IntPtr cv);
  186. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  187. SuppressUnmanagedCodeSecurity]
  188. private static extern int caca_get_cursor_y(IntPtr cv);
  189. public Point Cursor
  190. {
  191. get { return new Point(caca_get_cursor_x(_c_cv),
  192. caca_get_cursor_y(_c_cv)); }
  193. set { caca_gotoxy(_c_cv, value.X, value.Y); }
  194. }
  195. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  196. SuppressUnmanagedCodeSecurity]
  197. private static extern int caca_put_char(IntPtr cv,
  198. int x, int y, uint c);
  199. public int putChar(Point p, uint c)
  200. {
  201. return caca_put_char(_c_cv, p.X, p.Y, c);
  202. }
  203. public int putChar(int x, int y, uint c)
  204. {
  205. return caca_put_char(_c_cv, x, y, c);
  206. }
  207. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  208. SuppressUnmanagedCodeSecurity]
  209. private static extern uint caca_get_char(IntPtr cv, int x, int y);
  210. public uint getChar(Point p)
  211. {
  212. return caca_get_char(_c_cv, p.X, p.Y);
  213. }
  214. public uint getChar(int x, int y)
  215. {
  216. return caca_get_char(_c_cv, x, y);
  217. }
  218. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  219. SuppressUnmanagedCodeSecurity]
  220. private static extern int caca_put_str(IntPtr cv,
  221. int x, int y, string c);
  222. public int putStr(Point p, string c)
  223. {
  224. return caca_put_str(_c_cv, p.X, p.Y, c);
  225. }
  226. public int putStr(int x, int y, string c)
  227. {
  228. return caca_put_str(_c_cv, x, y, c);
  229. }
  230. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  231. SuppressUnmanagedCodeSecurity]
  232. private static extern int caca_get_attr(IntPtr cv, int x, int y);
  233. public int getAttr(Point p)
  234. {
  235. return caca_get_attr(_c_cv, p.X, p.Y);
  236. }
  237. public int getAttr(int x, int y)
  238. {
  239. return caca_get_attr(_c_cv, x, y);
  240. }
  241. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  242. SuppressUnmanagedCodeSecurity]
  243. private static extern int caca_set_attr(IntPtr cv, uint a);
  244. public int setAttr(uint a)
  245. {
  246. return caca_set_attr(_c_cv, a);
  247. }
  248. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  249. SuppressUnmanagedCodeSecurity]
  250. private static extern int caca_put_attr(IntPtr cv,
  251. int x, int y, uint a);
  252. public int putAttr(Point p, uint a)
  253. {
  254. return caca_put_attr(_c_cv, p.X, p.Y, a);
  255. }
  256. public int putAttr(int x, int y, uint a)
  257. {
  258. return caca_put_attr(_c_cv, x, y, a);
  259. }
  260. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  261. SuppressUnmanagedCodeSecurity]
  262. private static extern int caca_set_color_ansi(IntPtr cv,
  263. byte fg, byte bg);
  264. public int setColorAnsi(uint fg, uint bg)
  265. {
  266. return caca_set_color_ansi(_c_cv, (byte)fg, (byte)bg);
  267. }
  268. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  269. SuppressUnmanagedCodeSecurity]
  270. private static extern int caca_set_color_argb(IntPtr cv,
  271. uint fg, uint bg);
  272. public int setColorArgb(uint fg, uint bg)
  273. {
  274. return caca_set_color_argb(_c_cv, fg, bg);
  275. }
  276. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  277. SuppressUnmanagedCodeSecurity]
  278. private static extern int caca_clear_canvas(IntPtr cv);
  279. public int Clear()
  280. {
  281. return caca_clear_canvas(_c_cv);
  282. }
  283. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  284. SuppressUnmanagedCodeSecurity]
  285. private static extern int caca_set_canvas_handle(IntPtr cv,
  286. int x, int y);
  287. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  288. SuppressUnmanagedCodeSecurity]
  289. private static extern int caca_get_canvas_handle_x(IntPtr cv);
  290. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  291. SuppressUnmanagedCodeSecurity]
  292. private static extern int caca_get_canvas_handle_y(IntPtr cv);
  293. public Point Handle
  294. {
  295. get { return new Point(caca_get_canvas_handle_x(_c_cv),
  296. caca_get_canvas_handle_y(_c_cv)); }
  297. set { caca_set_canvas_handle(_c_cv, value.X, value.Y); }
  298. }
  299. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  300. SuppressUnmanagedCodeSecurity]
  301. private static extern int caca_blit(IntPtr cv, int x, int y,
  302. IntPtr cv1, IntPtr cv2);
  303. public int Blit(Point p, CacaCanvas canvas)
  304. {
  305. return caca_blit(_c_cv, p.X, p.Y, canvas._c_cv, IntPtr.Zero);
  306. }
  307. public int Blit(Point p, CacaCanvas cv, CacaCanvas mask)
  308. {
  309. return caca_blit(_c_cv, p.X, p.Y, cv._c_cv, mask._c_cv);
  310. }
  311. public int Blit(int x, int y, CacaCanvas canvas)
  312. {
  313. return caca_blit(_c_cv, x, y, canvas._c_cv, IntPtr.Zero);
  314. }
  315. public int Blit(int x, int y, CacaCanvas cv, CacaCanvas mask)
  316. {
  317. return caca_blit(_c_cv, x, y, cv._c_cv, mask._c_cv);
  318. }
  319. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  320. SuppressUnmanagedCodeSecurity]
  321. private static extern int caca_set_canvas_boundaries(IntPtr cv,
  322. int x, int y,
  323. int h, int w);
  324. public int setBoundaries(Rectangle r)
  325. {
  326. return caca_set_canvas_boundaries(_c_cv, r.X, r.Y,
  327. r.Width, r.Height);
  328. }
  329. public int setBoundaries(int x, int y, int w, int h)
  330. {
  331. return caca_set_canvas_boundaries(_c_cv, x, y, w, h);
  332. }
  333. /* canvas transformation */
  334. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  335. SuppressUnmanagedCodeSecurity]
  336. private static extern int caca_invert(IntPtr cv);
  337. public int Invert()
  338. {
  339. return caca_invert(_c_cv);
  340. }
  341. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  342. SuppressUnmanagedCodeSecurity]
  343. private static extern int caca_flip(IntPtr cv);
  344. public int Flip()
  345. {
  346. return caca_flip(_c_cv);
  347. }
  348. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  349. SuppressUnmanagedCodeSecurity]
  350. private static extern int caca_flop(IntPtr cv);
  351. public int Flop()
  352. {
  353. return caca_flop(_c_cv);
  354. }
  355. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  356. SuppressUnmanagedCodeSecurity]
  357. private static extern int caca_rotate_180(IntPtr cv);
  358. public int Rotate180()
  359. {
  360. return caca_rotate_180(_c_cv);
  361. }
  362. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  363. SuppressUnmanagedCodeSecurity]
  364. private static extern int caca_rotate_left(IntPtr cv);
  365. public int RotateLeft()
  366. {
  367. return caca_rotate_left(_c_cv);
  368. }
  369. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  370. SuppressUnmanagedCodeSecurity]
  371. private static extern int caca_rotate_right(IntPtr cv);
  372. public int RotateRight()
  373. {
  374. return caca_rotate_right(_c_cv);
  375. }
  376. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  377. SuppressUnmanagedCodeSecurity]
  378. private static extern int caca_stretch_left(IntPtr cv);
  379. public int StretchLeft()
  380. {
  381. return caca_stretch_left(_c_cv);
  382. }
  383. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  384. SuppressUnmanagedCodeSecurity]
  385. private static extern int caca_stretch_right(IntPtr cv);
  386. public int StretchRight()
  387. {
  388. return caca_stretch_right(_c_cv);
  389. }
  390. /* primitives drawing */
  391. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  392. SuppressUnmanagedCodeSecurity]
  393. private static extern int caca_draw_line(IntPtr cv, int x1, int y1,
  394. int x2, int y2, uint c);
  395. public int drawLine(Point p1, Point p2, uint c)
  396. {
  397. return caca_draw_line(_c_cv, p1.X, p1.Y, p2.X, p2.Y, c);
  398. }
  399. public int drawLine(int x1, int y1, int x2, int y2, uint c)
  400. {
  401. return caca_draw_line(_c_cv, x1, y1, x2, y2, c);
  402. }
  403. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  404. SuppressUnmanagedCodeSecurity]
  405. private static extern int caca_draw_polyline(IntPtr cv, int[] x,
  406. int[] y, int n, uint c);
  407. public int drawPolyline(Point[] lp, uint c)
  408. {
  409. int[] lx = new int[lp.Length];
  410. int[] ly = new int[lp.Length];
  411. for(int i = 0; i < lp.Length; i++)
  412. {
  413. lx[i] = lp[i].X;
  414. ly[i] = lp[i].Y;
  415. }
  416. return caca_draw_polyline(_c_cv, lx, ly, lp.Length - 1, c);
  417. }
  418. public int drawPolyline(int[] lx, int[] ly, uint c)
  419. {
  420. if(lx.Length != ly.Length)
  421. return -1;
  422. return caca_draw_polyline(_c_cv, lx, ly, lx.Length - 1, c);
  423. }
  424. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  425. SuppressUnmanagedCodeSecurity]
  426. private static extern int caca_draw_thin_line(IntPtr cv, int x1,
  427. int y1, int x2, int y2);
  428. public int drawThinLine(Point p1, Point p2)
  429. {
  430. return caca_draw_thin_line(_c_cv, p1.X, p1.Y, p2.X, p2.Y);
  431. }
  432. public int drawThinLine(int x1, int y1, int x2, int y2)
  433. {
  434. return caca_draw_thin_line(_c_cv, x1, y1, x2, y2);
  435. }
  436. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  437. SuppressUnmanagedCodeSecurity]
  438. private static extern int caca_draw_thin_polyline(IntPtr cv, int[] x,
  439. int[] y, int n);
  440. public int drawThinPolyline(Point[] lp)
  441. {
  442. int[] lx = new int[lp.Length];
  443. int[] ly = new int[lp.Length];
  444. for(int i = 0; i < lp.Length; i++)
  445. {
  446. lx[i] = lp[i].X;
  447. ly[i] = lp[i].Y;
  448. }
  449. return caca_draw_thin_polyline(_c_cv, lx, ly, lp.Length - 1);
  450. }
  451. public int drawThinPolyline(int[] lx, int[] ly)
  452. {
  453. if(lx.Length != ly.Length)
  454. return -1;
  455. return caca_draw_thin_polyline(_c_cv, lx, ly, lx.Length - 1);
  456. }
  457. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  458. SuppressUnmanagedCodeSecurity]
  459. private static extern int caca_draw_circle(IntPtr cv, int x, int y,
  460. int r, uint c);
  461. public int drawCircle(Point p, int r, uint c)
  462. {
  463. return caca_draw_circle(_c_cv, p.X, p.Y, r, c);
  464. }
  465. public int drawCircle(int x, int y, int r, uint c)
  466. {
  467. return caca_draw_circle(_c_cv, x, y, r, c);
  468. }
  469. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  470. SuppressUnmanagedCodeSecurity]
  471. private static extern int caca_draw_ellipse(IntPtr cv, int x, int y,
  472. int a, int b, uint c);
  473. public int drawEllipse(Point p, int a, int b, uint c)
  474. {
  475. return caca_draw_ellipse(_c_cv, p.X, p.Y, a, b, c);
  476. }
  477. public int drawEllipse(int x, int y, int a, int b, uint c)
  478. {
  479. return caca_draw_ellipse(_c_cv, x, y, a, b, c);
  480. }
  481. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  482. SuppressUnmanagedCodeSecurity]
  483. private static extern int caca_draw_thin_ellipse(IntPtr cv,
  484. int x, int y,
  485. int a, int b);
  486. public int drawThinEllipse(Point p, int a, int b)
  487. {
  488. return caca_draw_thin_ellipse(_c_cv, p.X, p.Y, a, b);
  489. }
  490. public int drawThinEllipse(int x, int y, int a, int b)
  491. {
  492. return caca_draw_thin_ellipse(_c_cv, x, y, a, b);
  493. }
  494. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  495. SuppressUnmanagedCodeSecurity]
  496. private static extern int caca_fill_ellipse(IntPtr cv, int x, int y,
  497. int a, int b, uint c);
  498. public int fillEllipse(Point p, int a, int b, uint c)
  499. {
  500. return caca_fill_ellipse(_c_cv, p.X, p.Y, a, b, c);
  501. }
  502. public int fillEllipse(int x, int y, int a, int b, uint c)
  503. {
  504. return caca_fill_ellipse(_c_cv, x, y, a, b, c);
  505. }
  506. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  507. SuppressUnmanagedCodeSecurity]
  508. private static extern int caca_draw_box(IntPtr cv, int x, int y,
  509. int w, int h, uint c);
  510. public int drawBox(Rectangle r, uint c)
  511. {
  512. return caca_draw_box(_c_cv, r.X, r.Y, r.Width, r.Height, c);
  513. }
  514. public int drawBox(int x, int y, int w, int h, uint c)
  515. {
  516. return caca_draw_box(_c_cv, x, y, w, h, c);
  517. }
  518. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  519. SuppressUnmanagedCodeSecurity]
  520. private static extern int caca_draw_thin_box(IntPtr cv, int x, int y,
  521. int w, int h);
  522. public int drawThinBox(Rectangle r)
  523. {
  524. return caca_draw_thin_box(_c_cv, r.X, r.Y, r.Width, r.Height);
  525. }
  526. public int drawThinBox(int x, int y, int w, int h)
  527. {
  528. return caca_draw_thin_box(_c_cv, x, y, w, h);
  529. }
  530. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  531. SuppressUnmanagedCodeSecurity]
  532. private static extern int caca_draw_cp437_box(IntPtr cv, int x, int y,
  533. int w, int h);
  534. public int drawCp437Box(Rectangle r)
  535. {
  536. return caca_draw_cp437_box(_c_cv, r.X, r.Y, r.Width, r.Height);
  537. }
  538. public int drawCp437Box(int x, int y, int w, int h)
  539. {
  540. return caca_draw_cp437_box(_c_cv, x, y, w, h);
  541. }
  542. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  543. SuppressUnmanagedCodeSecurity]
  544. private static extern int caca_fill_box(IntPtr cv, int x, int y,
  545. int w, int h, uint c);
  546. public int fillBox(Rectangle r, uint c)
  547. {
  548. return caca_fill_box(_c_cv, r.X, r.Y, r.Width, r.Height, c);
  549. }
  550. public int fillBox(int x, int y, int w, int h, uint c)
  551. {
  552. return caca_fill_box(_c_cv, x, y, w, h, c);
  553. }
  554. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  555. SuppressUnmanagedCodeSecurity]
  556. private static extern int caca_draw_triangle(IntPtr cv, int x1,
  557. int y1, int x2, int y2,
  558. int x3, int y3, uint c);
  559. public int drawTriangle(Point p1, Point p2, Point p3, uint c)
  560. {
  561. return caca_draw_triangle(_c_cv, p1.X, p1.Y, p2.X, p2.Y,
  562. p3.X, p3.Y, c);
  563. }
  564. public int drawTriangle(int x1, int y1, int x2, int y2,
  565. int x3, int y3, uint c)
  566. {
  567. return caca_draw_triangle(_c_cv, x1, y1, x2, y2, x3, y3, c);
  568. }
  569. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  570. SuppressUnmanagedCodeSecurity]
  571. private static extern int caca_draw_thin_triangle(IntPtr cv,
  572. int x1, int y1,
  573. int x2, int y2,
  574. int x3, int y3);
  575. public int drawThinTriangle(Point p1, Point p2, Point p3)
  576. {
  577. return caca_draw_thin_triangle(_c_cv, p1.X, p1.Y, p2.X, p2.Y,
  578. p3.X, p3.Y);
  579. }
  580. public int drawThinTriangle(int x1, int y1, int x2, int y2,
  581. int x3, int y3)
  582. {
  583. return caca_draw_thin_triangle(_c_cv, x1, y1, x2, y2, x3, y3);
  584. }
  585. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  586. SuppressUnmanagedCodeSecurity]
  587. private static extern int caca_fill_triangle(IntPtr cv, int x1,
  588. int y1, int x2, int y2,
  589. int x3, int y3, uint c);
  590. public int fillTriangle(Point p1, Point p2, Point p3, uint c)
  591. {
  592. return caca_fill_triangle(_c_cv, p1.X, p1.Y, p2.X, p2.Y,
  593. p3.X, p3.Y, c);
  594. }
  595. public int fillTriangle(int x1, int y1, int x2, int y2,
  596. int x3, int y3, uint c)
  597. {
  598. return caca_fill_triangle(_c_cv, x1, y1, x2, y2, x3, y3, c);
  599. }
  600. /* frame handling */
  601. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  602. SuppressUnmanagedCodeSecurity]
  603. private static extern int caca_get_frame_count(IntPtr cv);
  604. public int getFrameCount()
  605. {
  606. return caca_get_frame_count(_c_cv);
  607. }
  608. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  609. SuppressUnmanagedCodeSecurity]
  610. private static extern int caca_set_frame(IntPtr cv, int f);
  611. public int setFrame(int f)
  612. {
  613. return caca_set_frame(_c_cv, f);
  614. }
  615. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  616. SuppressUnmanagedCodeSecurity]
  617. private static extern string caca_get_frame_name(IntPtr cv);
  618. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  619. SuppressUnmanagedCodeSecurity]
  620. private static extern int caca_set_frame_name(IntPtr cv, string n);
  621. public string FrameName
  622. {
  623. get { return caca_get_frame_name(_c_cv); }
  624. set { caca_set_frame_name(_c_cv, value); }
  625. }
  626. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  627. SuppressUnmanagedCodeSecurity]
  628. private static extern int caca_create_frame(IntPtr cv, int f);
  629. public int createFrame(int f)
  630. {
  631. return caca_create_frame(_c_cv, f);
  632. }
  633. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  634. SuppressUnmanagedCodeSecurity]
  635. private static extern int caca_free_frame(IntPtr cv, int f);
  636. public int freeFrame(int f)
  637. {
  638. return caca_free_frame(_c_cv, f);
  639. }
  640. /* bitmap dithering */
  641. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  642. SuppressUnmanagedCodeSecurity]
  643. private static extern int caca_dither_bitmap(IntPtr c, int x, int y,
  644. int w, int h,
  645. IntPtr d, IntPtr data);
  646. public int ditherBitmap(Rectangle r, CacaDither d, object data)
  647. {
  648. GCHandle gch = GCHandle.Alloc(data, GCHandleType.Pinned);
  649. int ret = caca_dither_bitmap(_c_cv, r.X, r.Y, r.Width, r.Height,
  650. d._dither, gch.AddrOfPinnedObject());
  651. gch.Free();
  652. return ret;
  653. }
  654. public int ditherBitmap(int x, int y, int w, int h,
  655. CacaDither d, object data)
  656. {
  657. GCHandle gch = GCHandle.Alloc(data, GCHandleType.Pinned);
  658. int ret = caca_dither_bitmap(_c_cv, x, y, w, h, d._dither,
  659. gch.AddrOfPinnedObject());
  660. gch.Free();
  661. return ret;
  662. }
  663. }
  664. public class CacaAttr
  665. {
  666. private uint _attr;
  667. public CacaAttr(uint attr)
  668. {
  669. _attr = attr;
  670. }
  671. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  672. SuppressUnmanagedCodeSecurity]
  673. private static extern byte caca_attr_to_ansi(uint a);
  674. public byte toAnsi()
  675. {
  676. return caca_attr_to_ansi(_attr);
  677. }
  678. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  679. SuppressUnmanagedCodeSecurity]
  680. private static extern byte caca_attr_to_ansi_fg(uint a);
  681. public byte toAnsiFg()
  682. {
  683. return caca_attr_to_ansi_fg(_attr);
  684. }
  685. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  686. SuppressUnmanagedCodeSecurity]
  687. private static extern byte caca_attr_to_ansi_bg(uint a);
  688. public byte toAnsiBg()
  689. {
  690. return caca_attr_to_ansi_bg(_attr);
  691. }
  692. }
  693. public class CacaDither : IDisposable
  694. {
  695. public readonly IntPtr _dither;
  696. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  697. SuppressUnmanagedCodeSecurity]
  698. private static extern IntPtr caca_create_dither(int bpp, int w,
  699. int h, int pitch,
  700. uint rmask,
  701. uint gmask,
  702. uint bmask,
  703. uint amask);
  704. public CacaDither(int bpp, Size s, int pitch,
  705. uint rmask, uint gmask, uint bmask, uint amask)
  706. {
  707. _dither = caca_create_dither(bpp, s.Width, s.Height, pitch,
  708. rmask, gmask, bmask, amask);
  709. }
  710. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  711. SuppressUnmanagedCodeSecurity]
  712. private static extern int caca_free_dither(IntPtr d);
  713. public void Dispose()
  714. {
  715. caca_free_dither(_dither);
  716. GC.SuppressFinalize(this);
  717. }
  718. /* TODO: fix this shit */
  719. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  720. SuppressUnmanagedCodeSecurity]
  721. private static extern int caca_set_dither_palette(IntPtr d,
  722. uint[] r, uint[] g,
  723. uint[] b, uint[] a);
  724. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  725. SuppressUnmanagedCodeSecurity]
  726. private static extern int caca_set_dither_brightness(IntPtr d, float b);
  727. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  728. SuppressUnmanagedCodeSecurity]
  729. private static extern int caca_set_dither_gamma(IntPtr d, float g);
  730. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  731. SuppressUnmanagedCodeSecurity]
  732. private static extern int caca_set_dither_contrast(IntPtr d, float c);
  733. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  734. SuppressUnmanagedCodeSecurity]
  735. private static extern int caca_set_dither_invert(IntPtr d, int i);
  736. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  737. SuppressUnmanagedCodeSecurity]
  738. private static extern int caca_set_dither_antialias(IntPtr d, string s);
  739. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  740. SuppressUnmanagedCodeSecurity]
  741. private static extern string[] caca_get_dither_antialias_list(IntPtr d);
  742. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  743. SuppressUnmanagedCodeSecurity]
  744. private static extern int caca_set_dither_color(IntPtr d, string s);
  745. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  746. SuppressUnmanagedCodeSecurity]
  747. private static extern string[] caca_get_dither_color_list(IntPtr d);
  748. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  749. SuppressUnmanagedCodeSecurity]
  750. private static extern int caca_set_dither_charset(IntPtr d, string s);
  751. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  752. SuppressUnmanagedCodeSecurity]
  753. private static extern string[] caca_get_dither_charset_list(IntPtr d);
  754. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  755. SuppressUnmanagedCodeSecurity]
  756. private static extern int caca_set_dither_mode(IntPtr d, string s);
  757. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  758. SuppressUnmanagedCodeSecurity]
  759. private static extern string[] caca_get_dither_mode_list(IntPtr d);
  760. public int setBrightness(float b)
  761. {
  762. return caca_set_dither_brightness(_dither, b);
  763. }
  764. public int setGamma(float g)
  765. {
  766. return caca_set_dither_gamma(_dither, g);
  767. }
  768. public int setContrast(float c)
  769. {
  770. return caca_set_dither_contrast(_dither, c);
  771. }
  772. public int setInvert(int i)
  773. {
  774. return caca_set_dither_invert(_dither, i);
  775. }
  776. public int setAntialias(string s)
  777. {
  778. return caca_set_dither_antialias(_dither, s);
  779. }
  780. public int setColor(string s)
  781. {
  782. return caca_set_dither_color(_dither, s);
  783. }
  784. public int setCharset(string s)
  785. {
  786. return caca_set_dither_charset(_dither, s);
  787. }
  788. public int setMode(string s)
  789. {
  790. return caca_set_dither_mode(_dither, s);
  791. }
  792. /* <FIXME> */
  793. public string[] getAntialiasList()
  794. {
  795. return caca_get_dither_antialias_list(_dither);
  796. }
  797. public string[] getColorList()
  798. {
  799. return caca_get_dither_color_list(_dither);
  800. }
  801. public string[] getCharsetList()
  802. {
  803. return caca_get_dither_charset_list(_dither);
  804. }
  805. public string[] getModeList()
  806. {
  807. return caca_get_dither_mode_list(_dither);
  808. }
  809. /* </FIXME> */
  810. }
  811. public class CacaFont : IDisposable
  812. {
  813. private IntPtr _font;
  814. private GCHandle _gch;
  815. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  816. SuppressUnmanagedCodeSecurity]
  817. private static extern IntPtr caca_load_font(IntPtr data, uint len);
  818. public CacaFont(string s)
  819. {
  820. IntPtr name = Marshal.StringToHGlobalAnsi(s);
  821. _font = caca_load_font(name, 0);
  822. Marshal.FreeHGlobal(name);
  823. }
  824. public CacaFont(byte[] buf)
  825. {
  826. GCHandle _gch = GCHandle.Alloc(buf, GCHandleType.Pinned);
  827. _font = caca_load_font(_gch.AddrOfPinnedObject(),
  828. (uint)buf.Length);
  829. }
  830. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  831. SuppressUnmanagedCodeSecurity]
  832. private static extern int caca_free_font(IntPtr d);
  833. public void Dispose()
  834. {
  835. caca_free_font(_font);
  836. _gch.Free();
  837. GC.SuppressFinalize(this);
  838. }
  839. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  840. SuppressUnmanagedCodeSecurity]
  841. private static extern IntPtr caca_get_font_list();
  842. public static string[] getList()
  843. {
  844. IntPtr l = caca_get_font_list();
  845. int size;
  846. for(size = 0; true; size++)
  847. if(Marshal.ReadIntPtr(l, IntPtr.Size * size) == IntPtr.Zero)
  848. break;
  849. string[] ret = new string[size];
  850. for(int i = 0; i < size; i++)
  851. {
  852. IntPtr s = Marshal.ReadIntPtr(l, IntPtr.Size * i);
  853. ret[i] = Marshal.PtrToStringAnsi(s);
  854. }
  855. return ret;
  856. }
  857. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  858. SuppressUnmanagedCodeSecurity]
  859. private static extern int caca_get_font_width(IntPtr font);
  860. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  861. SuppressUnmanagedCodeSecurity]
  862. private static extern int caca_get_font_height(IntPtr font);
  863. public Size Size
  864. {
  865. get { return new Size(caca_get_font_width(_font),
  866. caca_get_font_height(_font)); }
  867. }
  868. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  869. SuppressUnmanagedCodeSecurity]
  870. private static extern IntPtr caca_get_font_blocks(IntPtr font);
  871. public int[,] getBlocks()
  872. {
  873. IntPtr l = caca_get_font_blocks(_font);
  874. int size;
  875. for(size = 1; true; size += 2)
  876. if(Marshal.ReadIntPtr(l, IntPtr.Size * size) == IntPtr.Zero)
  877. break;
  878. int[,] ret = new int[size,2];
  879. for(int i = 0; i < size; i++)
  880. {
  881. ret[i,0] = (int)Marshal.ReadIntPtr(l, IntPtr.Size * i * 2);
  882. ret[i,1] = (int)Marshal.ReadIntPtr(l, IntPtr.Size * i * 2 + 1);
  883. }
  884. return ret;
  885. }
  886. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  887. SuppressUnmanagedCodeSecurity]
  888. private static extern int caca_render_canvas(IntPtr cv, IntPtr f,
  889. IntPtr buf, int w, int h,
  890. int pitch);
  891. public int Render(CacaCanvas cv, uint[,] buf, int pitch)
  892. {
  893. GCHandle gch = GCHandle.Alloc(buf, GCHandleType.Pinned);
  894. int ret = caca_render_canvas(cv._c_cv, _font,
  895. gch.AddrOfPinnedObject(),
  896. buf.GetLength(0), buf.GetLength(1),
  897. pitch);
  898. gch.Free();
  899. return ret;
  900. }
  901. }
  902. public class CacaEvent : IDisposable
  903. {
  904. public IntPtr cevent;
  905. private IntPtr _utf8;
  906. public CacaEvent()
  907. {
  908. cevent = Marshal.AllocHGlobal(32);
  909. _utf8 = Marshal.AllocHGlobal(8);
  910. }
  911. public void Dispose()
  912. {
  913. Marshal.FreeHGlobal(cevent);
  914. Marshal.FreeHGlobal(_utf8);
  915. GC.SuppressFinalize(this);
  916. }
  917. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  918. SuppressUnmanagedCodeSecurity]
  919. private static extern int caca_get_event_type(IntPtr ev);
  920. public CacaEventType Type
  921. {
  922. get { return (CacaEventType)caca_get_event_type(cevent); }
  923. }
  924. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  925. SuppressUnmanagedCodeSecurity]
  926. private static extern int caca_get_event_key_ch(IntPtr ev);
  927. public int KeyCh
  928. {
  929. get { return caca_get_event_key_ch(cevent); }
  930. }
  931. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  932. SuppressUnmanagedCodeSecurity]
  933. private static extern uint caca_get_event_key_utf32(IntPtr ev);
  934. public uint KeyUtf32
  935. {
  936. get { return caca_get_event_key_utf32(cevent); }
  937. }
  938. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  939. SuppressUnmanagedCodeSecurity]
  940. private static extern int caca_get_event_key_utf8(IntPtr ev,
  941. IntPtr _utf8);
  942. public string KeyUtf8
  943. {
  944. get
  945. {
  946. caca_get_event_key_utf8(cevent, _utf8);
  947. return Marshal.PtrToStringAnsi(_utf8);
  948. }
  949. }
  950. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  951. SuppressUnmanagedCodeSecurity]
  952. private static extern int caca_get_event_mouse_button(IntPtr ev);
  953. public int MouseButton
  954. {
  955. get { return caca_get_event_mouse_button(cevent); }
  956. }
  957. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  958. SuppressUnmanagedCodeSecurity]
  959. private static extern int caca_get_event_mouse_x(IntPtr ev);
  960. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  961. SuppressUnmanagedCodeSecurity]
  962. private static extern int caca_get_event_mouse_y(IntPtr ev);
  963. public Point MousePos
  964. {
  965. get { return new Point(caca_get_event_mouse_x(cevent),
  966. caca_get_event_mouse_y(cevent)); }
  967. }
  968. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  969. SuppressUnmanagedCodeSecurity]
  970. private static extern int caca_get_event_resize_width(IntPtr ev);
  971. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  972. SuppressUnmanagedCodeSecurity]
  973. private static extern int caca_get_event_resize_height(IntPtr ev);
  974. public Size ResizeSize
  975. {
  976. get { return new Size(caca_get_event_resize_width(cevent),
  977. caca_get_event_resize_height(cevent)); }
  978. }
  979. }
  980. public class CacaDisplay : IDisposable
  981. {
  982. private CacaCanvas _cv;
  983. public CacaCanvas Canvas { get { return _cv; } }
  984. private IntPtr _c_cv;
  985. private IntPtr _c_dp;
  986. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  987. SuppressUnmanagedCodeSecurity]
  988. private static extern IntPtr caca_create_display(IntPtr cv);
  989. public CacaDisplay(CacaCanvas cv)
  990. {
  991. _cv = cv;
  992. _c_cv = _cv._c_cv;
  993. _c_dp = caca_create_display(_c_cv);
  994. }
  995. public CacaDisplay()
  996. {
  997. /* XXX: we do not call caca_create_display() with a NULL
  998. * argument because it's then impossible to create a CacaCanvas
  999. * and I don't want to add a weird constructor */
  1000. _cv = new CacaCanvas();
  1001. _c_cv = _cv._c_cv;
  1002. _c_dp = caca_create_display(_c_cv);
  1003. }
  1004. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  1005. SuppressUnmanagedCodeSecurity]
  1006. private static extern int caca_free_display(IntPtr dp);
  1007. public void Dispose()
  1008. {
  1009. caca_free_display(_c_dp);
  1010. GC.SuppressFinalize(this);
  1011. }
  1012. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  1013. SuppressUnmanagedCodeSecurity]
  1014. private static extern int caca_refresh_display(IntPtr dp);
  1015. public void Refresh()
  1016. {
  1017. caca_refresh_display(_c_dp);
  1018. }
  1019. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  1020. SuppressUnmanagedCodeSecurity]
  1021. private static extern int caca_set_display_time(IntPtr dp, int d);
  1022. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  1023. SuppressUnmanagedCodeSecurity]
  1024. private static extern int caca_get_display_time(IntPtr dp);
  1025. public int DisplayTime
  1026. {
  1027. get { return caca_get_display_time(_c_dp); }
  1028. set { caca_set_display_time(_c_dp, value); }
  1029. }
  1030. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  1031. SuppressUnmanagedCodeSecurity]
  1032. private static extern int caca_get_event(IntPtr dp, uint t,
  1033. IntPtr cevent,
  1034. int timeout);
  1035. public CacaEvent getEvent(CacaEventType t, int timeout)
  1036. {
  1037. CacaEvent e = new CacaEvent();
  1038. caca_get_event(_c_dp, (uint)t, e.cevent, timeout);
  1039. return e;
  1040. }
  1041. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  1042. SuppressUnmanagedCodeSecurity]
  1043. private static extern int caca_get_display_width(IntPtr dp);
  1044. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  1045. SuppressUnmanagedCodeSecurity]
  1046. private static extern int caca_get_display_height(IntPtr dp);
  1047. public Size Size
  1048. {
  1049. get { return new Size(caca_get_display_width(_c_dp),
  1050. caca_get_display_height(_c_dp)); }
  1051. }
  1052. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  1053. SuppressUnmanagedCodeSecurity]
  1054. private static extern int caca_set_display_title(IntPtr dp, string t);
  1055. public string Title
  1056. {
  1057. set { caca_set_display_title(_c_dp, value); }
  1058. }
  1059. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  1060. SuppressUnmanagedCodeSecurity]
  1061. private static extern int caca_set_mouse(IntPtr k, bool status);
  1062. public bool Mouse
  1063. {
  1064. set { caca_set_mouse(_c_dp, value); }
  1065. }
  1066. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  1067. SuppressUnmanagedCodeSecurity]
  1068. private static extern int caca_get_mouse_x(IntPtr k);
  1069. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  1070. SuppressUnmanagedCodeSecurity]
  1071. private static extern int caca_get_mouse_y(IntPtr k);
  1072. public Point MousePos
  1073. {
  1074. get { return new Point(caca_get_mouse_x(_c_dp),
  1075. caca_get_mouse_y(_c_dp)); }
  1076. }
  1077. [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
  1078. SuppressUnmanagedCodeSecurity]
  1079. private static extern int caca_set_cursor(IntPtr k, bool status);
  1080. public bool Cursor
  1081. {
  1082. set { caca_set_cursor(_c_dp, value); }
  1083. }
  1084. }
  1085. }