1 | /* |
---|
2 | * CuculSharp .NET bindings for libcucul |
---|
3 | * Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org> |
---|
4 | * All Rights Reserved |
---|
5 | * |
---|
6 | * $Id: Cucul.cs 943 2006-05-09 00:59:29Z sam $ |
---|
7 | * |
---|
8 | * This library is free software; you can redistribute it and/or |
---|
9 | * modify it under the terms of the Do What The Fuck You Want To |
---|
10 | * Public License, Version 2, as published by Sam Hocevar. See |
---|
11 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
12 | */ |
---|
13 | |
---|
14 | |
---|
15 | |
---|
16 | using System; |
---|
17 | using System.Runtime.InteropServices; |
---|
18 | using System.Security; |
---|
19 | |
---|
20 | |
---|
21 | |
---|
22 | namespace libCucul |
---|
23 | { |
---|
24 | public unsafe class Cucul : IDisposable |
---|
25 | { |
---|
26 | /* Fixme */ |
---|
27 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
28 | public static extern IntPtr cucul_create_canvas(int w, int h); |
---|
29 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
30 | public static extern Int32 cucul_get_canvas_width(IntPtr qq); |
---|
31 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
32 | public static extern Int32 cucul_get_canvas_height(IntPtr qq); |
---|
33 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
34 | public static extern Int32 cucul_set_canvas_size(IntPtr qq, int w, int h); |
---|
35 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
36 | public static extern Int32 cucul_rand(int min, int max); |
---|
37 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
38 | public static extern Int32 cucul_free_canvas(IntPtr qq); |
---|
39 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
40 | public static extern Int32 cucul_set_color(IntPtr qq, int fg, int bg); |
---|
41 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
42 | public static extern Int32 cucul_set_truecolor(IntPtr qq, Int32 fg, Int32 bg); |
---|
43 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
44 | public static extern Int32 cucul_putchar(IntPtr qq, int x, int y, char c); |
---|
45 | /* [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
46 | public static extern Int32 cucul_putstr(IntPtr qq, int, int, String);*/ |
---|
47 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
48 | public static extern Int32 cucul_clear_canvas(IntPtr qq); |
---|
49 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
50 | public static extern Int32 cucul_blit(IntPtr qq, Int32 x, Int32 y, IntPtr qq1, IntPtr qq2); |
---|
51 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
52 | public static extern Int32 cucul_draw_line(IntPtr qq, Int32 x1, Int32 y1, Int32 x2, Int32 y2, string c); |
---|
53 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
54 | public static extern Int32 cucul_draw_polyline(IntPtr qq, Int32[] x, Int32[] y, Int32 n, IntPtr c); |
---|
55 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
56 | public static extern Int32 cucul_draw_thin_line(IntPtr qq, Int32 x1, Int32 y1, Int32 x2, Int32 y2); |
---|
57 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
58 | public static extern Int32 cucul_draw_thin_polyline(IntPtr qq, Int32[] x, Int32[] y, Int32 n); |
---|
59 | |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | |
---|
64 | /* |
---|
65 | char const *cucul_get_color_name(unsigned int); |
---|
66 | int cucul_putstr(IntPtr *, int, int, char const *); |
---|
67 | int cucul_printf(IntPtr *, int, int, char const *, ...); |
---|
68 | */ |
---|
69 | |
---|
70 | |
---|
71 | |
---|
72 | IntPtr qq; |
---|
73 | |
---|
74 | public Cucul() |
---|
75 | { |
---|
76 | qq = cucul_create_canvas(0, 0); |
---|
77 | } |
---|
78 | public void Dispose() |
---|
79 | { |
---|
80 | cucul_free_canvas(qq); |
---|
81 | GC.SuppressFinalize(this); |
---|
82 | } |
---|
83 | public Cucul(Int32 w, Int32 h) |
---|
84 | { |
---|
85 | qq = cucul_create_canvas(w, h); |
---|
86 | } |
---|
87 | public Int32 getWidth() |
---|
88 | { |
---|
89 | return cucul_get_canvas_width(qq); |
---|
90 | } |
---|
91 | public Int32 getHeight() |
---|
92 | { |
---|
93 | return cucul_get_canvas_height(qq); |
---|
94 | } |
---|
95 | public Int32 setSize(Int32 w, Int32 h) |
---|
96 | { |
---|
97 | return cucul_set_canvas_size(qq, w, h); |
---|
98 | } |
---|
99 | public static Int32 Rand(Int32 min, Int32 max) |
---|
100 | { |
---|
101 | return cucul_rand(min, max); |
---|
102 | } |
---|
103 | public Int32 setColor(int fg, int bg) |
---|
104 | { |
---|
105 | return cucul_set_color(qq, fg, bg); |
---|
106 | } |
---|
107 | public Int32 setTruecolor(Int32 fg, Int32 bg) |
---|
108 | { |
---|
109 | return cucul_set_truecolor(qq, fg, bg); |
---|
110 | } |
---|
111 | public Int32 putChar(int x, int y, char c) |
---|
112 | { |
---|
113 | return cucul_putchar(qq, x, y, c); |
---|
114 | } |
---|
115 | public Int32 clearCanvas() |
---|
116 | { |
---|
117 | return cucul_clear_canvas(qq); |
---|
118 | } |
---|
119 | public Int32 Blit(int x, int y, Cucul qq1, Cucul qq2) |
---|
120 | { |
---|
121 | return cucul_blit(qq, x, y, qq1.get_cucul_t(), qq2.get_cucul_t()); |
---|
122 | } |
---|
123 | public Int32 drawLine(Int32 x1, Int32 y1, Int32 x2, Int32 y2, string c) |
---|
124 | { |
---|
125 | return cucul_draw_line(qq, x1, y1, x2, y2, c); |
---|
126 | } |
---|
127 | |
---|
128 | |
---|
129 | |
---|
130 | |
---|
131 | |
---|
132 | |
---|
133 | /* |
---|
134 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
135 | public static extern Int32 cucul_draw_polyline(IntPtr qq, Int32[] x, Int32[] y, Int32 n, IntPtr c); |
---|
136 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
137 | public static extern Int32 cucul_draw_thin_line(IntPtr qq, Int32 x1, Int32 y1, Int32 x2, Int32 y2); |
---|
138 | [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
---|
139 | public static extern Int32 cucul_draw_thin_polyline(IntPtr qq, Int32[] x, Int32[] y, Int32 n); |
---|
140 | */ |
---|
141 | |
---|
142 | |
---|
143 | |
---|
144 | /* Privates methods, are not meant to be called by user*/ |
---|
145 | |
---|
146 | public IntPtr get_cucul_t() |
---|
147 | { |
---|
148 | return qq; |
---|
149 | } |
---|
150 | } |
---|
151 | } |
---|
152 | |
---|