ruby-iup 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. data/Rakefile +1 -1
  2. data/examples/ctrl/degrade.rb +5 -2
  3. data/examples/ctrl/iupgauge.rb +5 -5
  4. data/examples/ctrl/iupplot2.rb +2 -5
  5. data/examples/dlg/iupalarm.rb +3 -1
  6. data/examples/elem/iupbutton.rb +42 -59
  7. data/examples/elem/iupcanvas.rb +4 -2
  8. data/examples/elem/iupcanvas2.rb +9 -8
  9. data/examples/elem/iupcanvas3.rb +19 -29
  10. data/examples/elem/iupdialog.rb +3 -7
  11. data/examples/elem/progressbar.rb +104 -118
  12. data/ext/iup-linux/include/cd.h +494 -494
  13. data/ext/iup-linux/include/cd_canvas.hpp +358 -358
  14. data/ext/iup-linux/include/cd_old.h +158 -158
  15. data/ext/iup-linux/include/cd_private.h +362 -362
  16. data/ext/iup-linux/include/cdcgm.h +34 -34
  17. data/ext/iup-linux/include/cdclipbd.h +22 -22
  18. data/ext/iup-linux/include/cddbuf.h +23 -23
  19. data/ext/iup-linux/include/cddebug.h +24 -24
  20. data/ext/iup-linux/include/cddgn.h +23 -23
  21. data/ext/iup-linux/include/cddxf.h +22 -22
  22. data/ext/iup-linux/include/cdemf.h +22 -22
  23. data/ext/iup-linux/include/cdgdiplus.h +29 -29
  24. data/ext/iup-linux/include/cdimage.h +23 -23
  25. data/ext/iup-linux/include/cdirgb.h +30 -30
  26. data/ext/iup-linux/include/cdiup.h +22 -22
  27. data/ext/iup-linux/include/cdlua.h +39 -39
  28. data/ext/iup-linux/include/cdlua3_private.h +120 -120
  29. data/ext/iup-linux/include/cdlua5_private.h +141 -141
  30. data/ext/iup-linux/include/cdluaim.h +24 -24
  31. data/ext/iup-linux/include/cdluaiup.h +27 -27
  32. data/ext/iup-linux/include/cdluapdf.h +27 -27
  33. data/ext/iup-linux/include/cdmf.h +24 -24
  34. data/ext/iup-linux/include/cdmf_private.h +32 -32
  35. data/ext/iup-linux/include/cdnative.h +26 -26
  36. data/ext/iup-linux/include/cdpdf.h +38 -38
  37. data/ext/iup-linux/include/cdpicture.h +22 -22
  38. data/ext/iup-linux/include/cdprint.h +23 -23
  39. data/ext/iup-linux/include/cdps.h +37 -37
  40. data/ext/iup-linux/include/cdwmf.h +22 -22
  41. data/ext/iup-linux/include/iup.h +318 -255
  42. data/ext/iup-linux/include/iup_pplot.h +40 -40
  43. data/ext/iup-linux/include/iupcb.h +25 -25
  44. data/ext/iup-linux/include/iupcbs.h +43 -42
  45. data/ext/iup-linux/include/iupcells.h +130 -130
  46. data/ext/iup-linux/include/iupcolorbar.h +126 -126
  47. data/ext/iup-linux/include/iupcontrols.h +36 -40
  48. data/ext/iup-linux/include/iupdef.h +520 -520
  49. data/ext/iup-linux/include/iupdial.h +63 -64
  50. data/ext/iup-linux/include/iupgauge.h +57 -57
  51. data/ext/iup-linux/include/iupgetparam.h +1 -1
  52. data/ext/iup-linux/include/iupgl.h +101 -101
  53. data/ext/iup-linux/include/iupim.h +21 -21
  54. data/ext/iup-linux/include/iupkey.h +457 -290
  55. data/ext/iup-linux/include/iuplua.h +41 -41
  56. data/ext/iup-linux/include/iuplua_pplot.h +26 -26
  57. data/ext/iup-linux/include/iupluacontrols.h +27 -27
  58. data/ext/iup-linux/include/iupluagl.h +26 -26
  59. data/ext/iup-linux/include/iupluaim.h +26 -26
  60. data/ext/iup-linux/include/iupluaole.h +26 -26
  61. data/ext/iup-linux/include/iupmask.h +40 -52
  62. data/ext/iup-linux/include/iupmatrix.h +63 -69
  63. data/ext/iup-linux/include/iupole.h +24 -24
  64. data/ext/iup-linux/include/iupspin.h +21 -21
  65. data/ext/iup-linux/include/iuptabs.h +75 -79
  66. data/ext/iup-linux/include/iuptree.h +93 -93
  67. data/ext/iup-linux/include/iupval.h +46 -46
  68. data/ext/iup-linux/include/wd.h +78 -78
  69. data/ext/iup-linux/include/wd_old.h +85 -85
  70. data/ext/iup-linux/libcd.so +0 -0
  71. data/ext/iup-linux/libcdcontextplus.so +0 -0
  72. data/ext/iup-linux/libcdpdf.so +0 -0
  73. data/ext/iup-linux/libim.so +0 -0
  74. data/ext/iup-linux/libim_fftw.so +0 -0
  75. data/ext/iup-linux/libim_jp2.so +0 -0
  76. data/ext/iup-linux/libim_process.so +0 -0
  77. data/ext/iup-linux/libiup.so +0 -0
  78. data/ext/iup-linux/libiup_pplot.so +0 -0
  79. data/ext/iup-linux/libiupcontrols.so +0 -0
  80. data/ext/iup-linux/libiupgl.so +0 -0
  81. data/ext/iup-linux/libiupim.so +0 -0
  82. data/ext/iup-linux/libiupimglib.so +0 -0
  83. data/ext/iup-linux/libiupmot.so +0 -0
  84. data/ext/iup-win32/cd.dll +0 -0
  85. data/ext/iup-win32/cd.lib +0 -0
  86. data/ext/iup-win32/cdcontextplus.dll +0 -0
  87. data/ext/iup-win32/cdcontextplus.lib +0 -0
  88. data/ext/iup-win32/cdpdf.dll +0 -0
  89. data/ext/iup-win32/cdpdf.lib +0 -0
  90. data/ext/iup-win32/freetype6.dll +0 -0
  91. data/ext/iup-win32/freetype6.lib +0 -0
  92. data/ext/iup-win32/im.dll +0 -0
  93. data/ext/iup-win32/im.lib +0 -0
  94. data/ext/iup-win32/im_avi.dll +0 -0
  95. data/ext/iup-win32/im_avi.lib +0 -0
  96. data/ext/iup-win32/im_capture.dll +0 -0
  97. data/ext/iup-win32/im_capture.lib +0 -0
  98. data/ext/iup-win32/im_fftw.dll +0 -0
  99. data/ext/iup-win32/im_fftw.lib +0 -0
  100. data/ext/iup-win32/im_jp2.dll +0 -0
  101. data/ext/iup-win32/im_jp2.lib +0 -0
  102. data/ext/iup-win32/im_process.dll +0 -0
  103. data/ext/iup-win32/im_process.lib +0 -0
  104. data/ext/iup-win32/im_wmv.dll +0 -0
  105. data/ext/iup-win32/im_wmv.lib +0 -0
  106. data/ext/iup-win32/imlua_capture51.dll +0 -0
  107. data/ext/iup-win32/imlua_capture51.lib +0 -0
  108. data/ext/iup-win32/imlua_wmv51.dll +0 -0
  109. data/ext/iup-win32/imlua_wmv51.lib +0 -0
  110. data/ext/iup-win32/include/cd.h +494 -494
  111. data/ext/iup-win32/include/cd_canvas.hpp +358 -358
  112. data/ext/iup-win32/include/cd_old.h +158 -158
  113. data/ext/iup-win32/include/cd_private.h +362 -362
  114. data/ext/iup-win32/include/cdcgm.h +34 -34
  115. data/ext/iup-win32/include/cdclipbd.h +22 -22
  116. data/ext/iup-win32/include/cddbuf.h +23 -23
  117. data/ext/iup-win32/include/cddebug.h +24 -24
  118. data/ext/iup-win32/include/cddgn.h +23 -23
  119. data/ext/iup-win32/include/cddxf.h +22 -22
  120. data/ext/iup-win32/include/cdemf.h +22 -22
  121. data/ext/iup-win32/include/cdgdiplus.h +29 -29
  122. data/ext/iup-win32/include/cdimage.h +23 -23
  123. data/ext/iup-win32/include/cdirgb.h +30 -30
  124. data/ext/iup-win32/include/cdiup.h +22 -22
  125. data/ext/iup-win32/include/cdlua.h +39 -39
  126. data/ext/iup-win32/include/cdlua3_private.h +120 -120
  127. data/ext/iup-win32/include/cdlua5_private.h +141 -141
  128. data/ext/iup-win32/include/cdluaim.h +24 -24
  129. data/ext/iup-win32/include/cdluaiup.h +27 -27
  130. data/ext/iup-win32/include/cdluapdf.h +27 -27
  131. data/ext/iup-win32/include/cdmf.h +24 -24
  132. data/ext/iup-win32/include/cdmf_private.h +32 -32
  133. data/ext/iup-win32/include/cdnative.h +26 -26
  134. data/ext/iup-win32/include/cdpdf.h +38 -38
  135. data/ext/iup-win32/include/cdpicture.h +22 -22
  136. data/ext/iup-win32/include/cdprint.h +23 -23
  137. data/ext/iup-win32/include/cdps.h +37 -37
  138. data/ext/iup-win32/include/cdwmf.h +22 -22
  139. data/ext/iup-win32/include/iup.h +318 -255
  140. data/ext/iup-win32/include/iup_pplot.h +40 -40
  141. data/ext/iup-win32/include/iupcb.h +25 -25
  142. data/ext/iup-win32/include/iupcbs.h +43 -42
  143. data/ext/iup-win32/include/iupcells.h +130 -130
  144. data/ext/iup-win32/include/iupcolorbar.h +126 -126
  145. data/ext/iup-win32/include/iupcontrols.h +36 -40
  146. data/ext/iup-win32/include/iupdef.h +520 -520
  147. data/ext/iup-win32/include/iupdial.h +63 -64
  148. data/ext/iup-win32/include/iupgauge.h +57 -57
  149. data/ext/iup-win32/include/iupgetparam.h +1 -1
  150. data/ext/iup-win32/include/iupgl.h +101 -101
  151. data/ext/iup-win32/include/iupim.h +21 -21
  152. data/ext/iup-win32/include/iupkey.h +457 -290
  153. data/ext/iup-win32/include/iuplua.h +41 -41
  154. data/ext/iup-win32/include/iuplua_pplot.h +26 -26
  155. data/ext/iup-win32/include/iupluacontrols.h +27 -27
  156. data/ext/iup-win32/include/iupluagl.h +26 -26
  157. data/ext/iup-win32/include/iupluaim.h +26 -26
  158. data/ext/iup-win32/include/iupluaole.h +26 -26
  159. data/ext/iup-win32/include/iupmask.h +40 -52
  160. data/ext/iup-win32/include/iupmatrix.h +63 -69
  161. data/ext/iup-win32/include/iupole.h +24 -24
  162. data/ext/iup-win32/include/iupspin.h +21 -21
  163. data/ext/iup-win32/include/iuptabs.h +75 -79
  164. data/ext/iup-win32/include/iuptree.h +93 -93
  165. data/ext/iup-win32/include/iupval.h +46 -46
  166. data/ext/iup-win32/include/wd.h +78 -78
  167. data/ext/iup-win32/include/wd_old.h +85 -85
  168. data/ext/iup-win32/iup.dll +0 -0
  169. data/ext/iup-win32/iup.lib +0 -0
  170. data/ext/iup-win32/iup_pplot.dll +0 -0
  171. data/ext/iup-win32/iup_pplot.lib +0 -0
  172. data/ext/iup-win32/iupcd.dll +0 -0
  173. data/ext/iup-win32/iupcd.lib +0 -0
  174. data/ext/iup-win32/iupcontrols.dll +0 -0
  175. data/ext/iup-win32/iupcontrols.lib +0 -0
  176. data/ext/iup-win32/iupgl.dll +0 -0
  177. data/ext/iup-win32/iupgl.lib +0 -0
  178. data/ext/iup-win32/iupgtk.dll +0 -0
  179. data/ext/iup-win32/iupgtk.lib +0 -0
  180. data/ext/iup-win32/iupim.dll +0 -0
  181. data/ext/iup-win32/iupim.lib +0 -0
  182. data/ext/iup-win32/iupimglib.dll +0 -0
  183. data/ext/iup-win32/iupimglib.lib +0 -0
  184. data/ext/iup-win32/iupole.dll +0 -0
  185. data/ext/iup-win32/iupole.lib +0 -0
  186. data/ext/iup-win32/iupstub.lib +0 -0
  187. data/ext/iup-win32/pdflib.dll +0 -0
  188. data/ext/iup-win32/pdflib.lib +0 -0
  189. data/ext/iup.c +3 -351
  190. data/ext/rb_iup.h +48 -15
  191. data/ext/rb_iupcb.h +1 -0
  192. data/ext/rb_iupcells.h +1 -0
  193. data/ext/rb_iupcolorbar.h +1 -4
  194. data/ext/rb_iupcontrols.h +0 -5
  195. data/ext/rb_iupdial.h +1 -0
  196. data/ext/rb_iupgauge.h +1 -0
  197. data/ext/rb_iupgc.h +0 -1
  198. data/ext/rb_iupmatrix.h +1 -0
  199. data/ext/rb_iupsbox.h +0 -1
  200. data/ext/rb_iuptabs.h +1 -0
  201. data/ext/rb_iuptree.h +1 -0
  202. data/ext/rb_iupval.h +1 -0
  203. metadata +16 -29
  204. data/ext/iup-linux/include/iupcbox.h +0 -23
  205. data/ext/iup-linux/include/iupcompat.h +0 -62
  206. data/ext/iup-linux/include/iupcpi.h +0 -76
  207. data/ext/iup-linux/include/iupgc.h +0 -20
  208. data/ext/iup-linux/include/iupsbox.h +0 -20
  209. data/ext/iup-linux/include/iupspeech.h +0 -23
  210. data/ext/iup-linux/libcdluacontextplus51.so +0 -0
  211. data/ext/iup-win32/cdlua51.lib +0 -0
  212. data/ext/iup-win32/cdluacontextplus51.lib +0 -0
  213. data/ext/iup-win32/cdluaim51.lib +0 -0
  214. data/ext/iup-win32/cdluapdf51.lib +0 -0
  215. data/ext/iup-win32/include/iupcbox.h +0 -23
  216. data/ext/iup-win32/include/iupcompat.h +0 -62
  217. data/ext/iup-win32/include/iupcpi.h +0 -76
  218. data/ext/iup-win32/include/iupgc.h +0 -20
  219. data/ext/iup-win32/include/iupsbox.h +0 -20
  220. data/ext/iup-win32/include/iupspeech.h +0 -23
  221. data/ext/iup-win32/iuplua51.lib +0 -0
  222. data/ext/iup-win32/iuplua_pplot51.lib +0 -0
  223. data/ext/iup-win32/iupluacd51.lib +0 -0
  224. data/ext/iup-win32/iupluacontrols51.lib +0 -0
  225. data/ext/iup-win32/iupluagl51.lib +0 -0
  226. data/ext/iup-win32/iupluaim51.lib +0 -0
  227. data/ext/iup-win32/iupluaimglib51.lib +0 -0
  228. data/ext/iup-win32/iupluaole51.lib +0 -0
  229. data/ext/rb_iupcbox.h +0 -40
  230. data/ext/rb_iupspeech.h +0 -25
@@ -1,11 +1,9 @@
1
1
  require 'rubygems'
2
- require 'iupruby'
2
+ require 'iup'
3
3
 
4
- exit
4
+ @increment = 0.01
5
5
 
6
- $increment = 0.01
7
-
8
- $pixmap_play = [
6
+ @pixmap_play = [
9
7
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
10
8
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
11
9
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
@@ -29,7 +27,7 @@ $pixmap_play = [
29
27
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
30
28
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]
31
29
 
32
- $pixmap_restart = [
30
+ @pixmap_restart = [
33
31
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
34
32
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
35
33
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
@@ -53,7 +51,7 @@ $pixmap_restart = [
53
51
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
54
52
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]
55
53
 
56
- $pixmap_rewind = [
54
+ @pixmap_rewind = [
57
55
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
58
56
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
59
57
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
@@ -77,7 +75,7 @@ $pixmap_rewind = [
77
75
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
78
76
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]
79
77
 
80
- $pixmap_forward = [
78
+ @pixmap_forward = [
81
79
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
82
80
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
83
81
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
@@ -101,7 +99,7 @@ $pixmap_forward = [
101
99
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
102
100
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]
103
101
 
104
- $pixmap_pause = [
102
+ @pixmap_pause = [
105
103
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
106
104
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
107
105
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
@@ -126,169 +124,157 @@ $pixmap_pause = [
126
124
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]
127
125
 
128
126
  def createimg_s()
129
- img_restart = Iup.Image(22,22, $pixmap_restart)
130
- img_play = Iup.Image(22,22, $pixmap_play)
131
- img_forward = Iup.Image(22,22, $pixmap_forward)
132
- img_rewind = Iup.Image(22,22, $pixmap_rewind)
133
- img_pause = Iup.Image(22,22, $pixmap_pause)
134
-
135
- Iup.SetHandle("img_restart", img_restart)
136
- Iup.SetHandle("img_play", img_play)
137
- Iup.SetHandle("img_forward", img_forward)
138
- Iup.SetHandle("img_rewind", img_rewind)
139
- Iup.SetHandle("img_pause", img_pause)
140
-
141
- Iup.SetAttribute(img_restart, "1", "0 0 0")
142
- Iup.SetAttribute(img_restart, "2", "BGCOLOR")
143
- Iup.SetAttribute(img_play, "1", "0 0 0")
144
- Iup.SetAttribute(img_play, "2", "BGCOLOR")
145
- Iup.SetAttribute(img_forward, "1", "0 0 0")
146
- Iup.SetAttribute(img_forward, "2", "BGCOLOR")
147
- Iup.SetAttribute(img_rewind, "1", "0 0 0")
148
- Iup.SetAttribute(img_rewind, "2", "BGCOLOR")
149
- Iup.SetAttribute(img_pause, "1", "0 0 0")
150
- Iup.SetAttribute(img_pause, "2", "BGCOLOR")
127
+ @img_restart = Iup.Image(22,22, @pixmap_restart)
128
+ @img_play = Iup.Image(22,22, @pixmap_play)
129
+ @img_forward = Iup.Image(22,22, @pixmap_forward)
130
+ @img_rewind = Iup.Image(22,22, @pixmap_rewind)
131
+ @img_pause = Iup.Image(22,22, @pixmap_pause)
132
+
133
+ @img_restart["1"]= "0 0 0"
134
+ @img_restart["2"]= "BGCOLOR"
135
+ @img_play["1"]= "0 0 0"
136
+ @img_play["2"]= "BGCOLOR"
137
+ @img_forward["1"]= "0 0 0"
138
+ @img_forward["2"]= "BGCOLOR"
139
+ @img_rewind["1"]= "0 0 0"
140
+ @img_rewind["2"]= "BGCOLOR"
141
+ @img_pause["1"]= "0 0 0"
142
+ @img_pause["2"]= "BGCOLOR"
151
143
  end
152
144
 
153
- def time_cb(ih)
154
- value = Iup.GetFloat($progressbar1, "VALUE")
155
- value += $increment
145
+ @time_cb = lambda do |ih|
146
+ value = @progressbar1.value.to_f
147
+ value += @increment
156
148
  if(value > 1)
157
149
  value = 0 # start over */
158
150
  end
159
- Iup.SetAttribute($progressbar1, "VALUE", "%f" % value)
151
+ @progressbar1.value = value
160
152
 
161
- value = Iup.GetFloat($progressbar2, "VALUE")
162
- value += $increment*50
153
+ value = @progressbar2.value.to_f
154
+ value += @increment*50
163
155
  if(value > 50)
164
156
  value = 0 # start over */
165
157
  end
166
- Iup.SetAttribute($progressbar2, "VALUE", "%f" % value)
158
+ @progressbar2.value = value
167
159
  return Iup::DEFAULT
168
160
  end
169
161
 
170
- def btn_pause_cb(ih)
171
- if(Iup.GetInt($timer, "RUN")==0)
172
- Iup.SetAttribute($timer, "RUN", "YES")
173
- Iup.SetAttribute($btn_pause, "IMAGE", "img_pause")
162
+ @btn_pause_cb = lambda do |ih|
163
+ if(@timer.run == "NO")
164
+ @timer.run = "YES"
165
+ @btn_pause.image = @img_pause
174
166
  else
175
- Iup.SetAttribute($timer, "RUN", "NO")
176
- Iup.SetAttribute($btn_pause, "IMAGE", "img_play")
167
+ @timer.run = "NO"
168
+ @btn_pause.image = @img_play
177
169
  end
178
170
 
179
171
  return Iup::DEFAULT
180
172
  end
181
173
 
182
- def btn_restart_cb(ih)
183
- Iup.SetAttribute($progressbar1, "VALUE", "0")
184
- Iup.SetAttribute($progressbar2, "VALUE", "0")
174
+ @btn_restart_cb = lambda do |ih|
175
+ @progressbar1.value = 0
176
+ @progressbar2.value = 0
185
177
  return Iup::DEFAULT
186
178
  end
187
179
 
188
- def btn_accelerate_cb(ih)
189
- $increment *= 2
180
+ @btn_accelerate_cb = lambda do |ih|
181
+ @increment *= 2
190
182
  return Iup::DEFAULT
191
183
  end
192
184
 
193
- def btn_decelerate_cb(ih)
194
- $increment /= 2
185
+ @btn_decelerate_cb = lambda do |ih|
186
+ @increment /= 2
195
187
  return Iup::DEFAULT
196
188
  end
197
189
 
198
- def btn_show1_cb(ih)
199
- if(Iup.GetInt($progressbar1, "DASHED")==0)
200
- Iup.SetAttribute($progressbar1, "DASHED", "YES")
190
+ @btn_show1_cb = lambda do |ih|
191
+ if(@progressbar1.dashed=="NO")
192
+ @progressbar1.dashed = "YES"
201
193
  else
202
- Iup.SetAttribute($progressbar1, "DASHED", "NO")
194
+ @progressbar1.dashed = "NO"
203
195
  end
204
196
  return Iup::DEFAULT
205
197
  end
206
198
 
207
- def btn_show2_cb(ih)
208
- if(Iup.GetInt($progressbar1, "MARQUEE")==0)
209
- Iup.SetAttribute($progressbar1, "MARQUEE", "YES")
199
+ @btn_show2_cb = lambda do |ih|
200
+ if(@progressbar1.marquee=="NO")
201
+ @progressbar1.marquee = "YES"
210
202
  else
211
- Iup.SetAttribute($progressbar1, "MARQUEE", "NO")
203
+ @progressbar1.marquee = "NO"
212
204
  end
213
205
  return Iup::DEFAULT
214
206
  end
215
207
 
216
- Iup.Open # IUP initialization */
217
208
 
218
- $timer = Iup.Timer()
219
- Iup.SetCallback($timer, "ACTION_CB",'time_cb')
220
- Iup.SetAttribute($timer, "TIME", "100")
209
+ @timer = Iup.Timer()
210
+ @timer.action_cb = @time_cb
211
+ @timer.time = 100
221
212
 
222
- $progressbar1 = Iup.ProgressBar()
223
- $progressbar2 = Iup.ProgressBar()
213
+ @progressbar1 = Iup.ProgressBar()
214
+ @progressbar2 = Iup.ProgressBar()
224
215
 
225
- Iup.SetAttribute($progressbar1, "EXPAND", "YES")
226
- Iup.SetAttribute($progressbar1, "DASHED", "YES")
216
+ @progressbar1.expand = "YES"
217
+ @progressbar1.dashed = "YES"
218
+
219
+ @progressbar2.orientation = "VERTICAL"
220
+ @progressbar2.bgcolor = "255 0 128"
221
+ @progressbar2.fgcolor = "0 128 0"
222
+ @progressbar2.rastersize = "30x100"
223
+ @progressbar2.max = 50
224
+ @progressbar2.value = 25
227
225
 
228
- Iup.SetAttribute($progressbar2, "ORIENTATION", "VERTICAL")
229
- Iup.SetAttribute($progressbar2, "BGCOLOR", "255 0 128")
230
- Iup.SetAttribute($progressbar2, "FGCOLOR", "0 128 0")
231
- Iup.SetAttribute($progressbar2, "RASTERSIZE", "30x100")
232
- Iup.SetAttribute($progressbar2, "MAX", "50")
233
- Iup.SetAttribute($progressbar2, "VALUE", "25")
234
-
235
- btn_restart = Iup.Button(NULL, NULL)
236
- $btn_pause = Iup.Button(NULL, NULL)
237
- btn_accelerate = Iup.Button(NULL, NULL)
238
- btn_decelerate = Iup.Button(NULL, NULL)
239
- btn_show1 = Iup.Button("Dashed", NULL)
240
- btn_show2 = Iup.Button("Marquee", NULL)
226
+ @btn_restart = Iup.Button('')
227
+ @btn_pause = Iup.Button('')
228
+ @btn_accelerate = Iup.Button('')
229
+ @btn_decelerate = Iup.Button('')
230
+ @btn_show1 = Iup.Button("Dashed")
231
+ @btn_show2 = Iup.Button("Marquee")
241
232
 
242
233
  createimg_s()
243
234
 
244
- Iup.SetAttribute(btn_restart, "IMAGE", "img_restart")
245
- Iup.SetAttribute(btn_restart, "TIP", "Restart" )
246
- Iup.SetAttribute($btn_pause, "IMAGE", "img_pause")
247
- Iup.SetAttribute($btn_pause, "TIP", "Play/Pause")
248
- Iup.SetAttribute(btn_accelerate, "IMAGE", "img_forward")
249
- Iup.SetAttribute(btn_accelerate, "TIP", "Accelerate")
250
- Iup.SetAttribute(btn_decelerate, "IMAGE", "img_rewind")
251
- Iup.SetAttribute(btn_decelerate, "TIP", "Decelerate")
252
- Iup.SetAttribute(btn_show1, "TIP", "Dashed or Continuous")
253
- Iup.SetAttribute(btn_show2, "TIP", "Marquee or Defined")
235
+ @btn_restart.image = @img_restart
236
+ @btn_restart.tip = "Restart"
237
+ @btn_pause.image = @img_pause
238
+ @btn_pause.tip = "Play/Pause"
239
+ @btn_accelerate.image = @img_forward
240
+ @btn_accelerate.tip = "Accelerate"
241
+ @btn_decelerate.image = @img_rewind
242
+ @btn_decelerate.tip = "Decelerate"
243
+ @btn_show1.tip = "Dashed or Continuous"
244
+ @btn_show2.tip = "Marquee or Defined"
245
+
246
+ @progressbar1.dashed = "NO"
254
247
 
255
- hbox = Iup.Hbox([
248
+ @hbox = Iup.Hbox([
256
249
  Iup.Fill(),
257
- $btn_pause,
258
- btn_restart,
259
- btn_decelerate,
260
- btn_accelerate,
261
- btn_show1,
262
- btn_show2,
250
+ @btn_pause,
251
+ @btn_restart,
252
+ @btn_decelerate,
253
+ @btn_accelerate,
254
+ @btn_show1,
255
+ @btn_show2,
263
256
  Iup.Fill()])
264
257
 
265
- vbox = Iup.Hbox([Iup.Vbox([$progressbar1, hbox]), $progressbar2])
266
- Iup.SetAttribute(vbox, "MARGIN", "10x10")
267
- Iup.SetAttribute(vbox, "GAP", "5")
258
+ vbox = Iup.Hbox([Iup.Vbox([@progressbar1, @hbox]), @progressbar2])
259
+ vbox.margin = "10x10"
260
+ vbox.gap = "5"
268
261
 
269
262
  dlg = Iup.Dialog(vbox)
270
263
 
271
- Iup.SetAttribute(dlg, "TITLE", "Iup.ProgressBar Test")
264
+ dlg.title = "IupProgressBar Test"
272
265
 
273
- Iup.SetCallback($btn_pause, "ACTION",'$btn_pause_cb')
274
- Iup.SetCallback(btn_restart, "ACTION",'btn_restart_cb')
275
- Iup.SetCallback(btn_accelerate, "ACTION",'btn_accelerate_cb')
276
- Iup.SetCallback(btn_decelerate, "ACTION",'btn_decelerate_cb')
277
- Iup.SetCallback(btn_show1, "ACTION",'btn_show1_cb')
278
- Iup.SetCallback(btn_show2, "ACTION",'btn_show2_cb')
266
+ @btn_pause.action = @btn_pause_cb
267
+ @btn_restart.action = @btn_restart_cb
268
+ @btn_accelerate.action = @btn_accelerate_cb
269
+ @btn_decelerate.action = @btn_decelerate_cb
270
+ @btn_show1.action = @btn_show1_cb
271
+ @btn_show2.action = @btn_show2_cb
279
272
 
280
- Iup.ShowXY(dlg, Iup::CENTER, Iup::CENTER)
273
+ dlg.ShowXY(Iup::CENTER, Iup::CENTER)
281
274
 
282
- Iup.SetAttribute($timer, "RUN", "YES")
275
+ @timer.run = "YES"
283
276
 
284
- Iup.MainLoop()
277
+ Iup.MainLoop
285
278
 
286
- Iup.Destroy(dlg)
287
- Iup.Destroy(Iup.GetHandle("img_restart"))
288
- Iup.Destroy(Iup.GetHandle("img_play"))
289
- Iup.Destroy(Iup.GetHandle("img_forward"))
290
- Iup.Destroy(Iup.GetHandle("img_rewind"))
291
- Iup.Destroy(Iup.GetHandle("img_pause"))
292
-
293
- Iup.Close()
279
+ dlg.Destroy
294
280
 
@@ -1,494 +1,494 @@
1
- /** \file
2
- * \brief User API
3
- * CD - Canvas Draw
4
- * Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil
5
- * http://www.tecgraf.puc-rio.br/cd
6
- * mailto:cd@tecgraf.puc-rio.br
7
- *
8
- * See Copyright Notice at the end of this file
9
- */
10
-
11
- #ifndef __CD_H
12
- #define __CD_H
13
-
14
- #ifdef __cplusplus
15
- extern "C" {
16
- #endif
17
-
18
-
19
- #define CD_NAME "CD - Canvas Draw"
20
- #define CD_DESCRIPTION "A 2D Graphics Library"
21
- #define CD_COPYRIGHT "Copyright (C) 1994-2008 Tecgraf, PUC-Rio."
22
- #define CD_VERSION "5.1.0"
23
- #define CD_VERSION_DATE "2008/10/14"
24
- #define CD_VERSION_NUMBER 501000
25
-
26
- typedef struct _cdContext cdContext;
27
- typedef struct _cdCanvas cdCanvas;
28
- typedef struct _cdCanvas cdState;
29
- typedef struct _cdImage cdImage;
30
-
31
- /* client images using bitmap structure */
32
- typedef struct _cdBitmap {
33
- int w;
34
- int h;
35
- int type;
36
- void *data;
37
- } cdBitmap;
38
-
39
-
40
- /* library */
41
- char* cdVersion(void);
42
- char* cdVersionDate(void);
43
- int cdVersionNumber(void);
44
-
45
- /* canvas init */
46
- cdCanvas* cdCreateCanvas(cdContext *context, void *data);
47
- cdCanvas* cdCreateCanvasf(cdContext *context, const char* format, ...);
48
- void cdKillCanvas(cdCanvas* canvas);
49
-
50
- cdContext* cdCanvasGetContext(cdCanvas* canvas);
51
- int cdCanvasActivate(cdCanvas* canvas);
52
- void cdCanvasDeactivate(cdCanvas* canvas);
53
- int cdUseContextPlus(int use);
54
- void cdInitContextPlus(void); /* need an external library */
55
-
56
- /* context */
57
- typedef int (*cdCallback)(cdCanvas* canvas, ...);
58
- int cdContextRegisterCallback(cdContext *context, int cb, cdCallback func);
59
- unsigned long cdContextCaps(cdContext *context);
60
-
61
- /* control */
62
- int cdCanvasSimulate(cdCanvas* canvas, int mode);
63
- void cdCanvasFlush(cdCanvas* canvas);
64
- void cdCanvasClear(cdCanvas* canvas);
65
- cdState* cdCanvasSaveState(cdCanvas* canvas);
66
- void cdCanvasRestoreState(cdCanvas* canvas, cdState* state);
67
- void cdReleaseState(cdState* state);
68
- void cdCanvasSetAttribute(cdCanvas* canvas, const char* name, char* data);
69
- void cdCanvasSetfAttribute(cdCanvas* canvas, const char* name, const char* format, ...);
70
- char* cdCanvasGetAttribute(cdCanvas* canvas, const char* name);
71
-
72
- /* interpretation */
73
- int cdCanvasPlay(cdCanvas* canvas, cdContext *context, int xmin, int xmax, int ymin, int ymax, void *data);
74
-
75
- /* coordinate transformation */
76
- void cdCanvasGetSize(cdCanvas* canvas, int *width, int *height, double *width_mm, double *height_mm);
77
- int cdCanvasUpdateYAxis(cdCanvas* canvas, int* y);
78
- double cdfCanvasUpdateYAxis(cdCanvas* canvas, double* y);
79
- int cdCanvasInvertYAxis(cdCanvas* canvas, int y);
80
- double cdfCanvasInvertYAxis(cdCanvas* canvas, double y);
81
- void cdCanvasMM2Pixel(cdCanvas* canvas, double mm_dx, double mm_dy, int *dx, int *dy);
82
- void cdCanvasPixel2MM(cdCanvas* canvas, int dx, int dy, double *mm_dx, double *mm_dy);
83
- void cdfCanvasMM2Pixel(cdCanvas* canvas, double mm_dx, double mm_dy, double *dx, double *dy);
84
- void cdfCanvasPixel2MM(cdCanvas* canvas, double dx, double dy, double *mm_dx, double *mm_dy);
85
- void cdCanvasOrigin(cdCanvas* canvas, int x, int y);
86
- void cdfCanvasOrigin(cdCanvas* canvas, double x, double y);
87
- void cdCanvasGetOrigin(cdCanvas* canvas, int *x, int *y);
88
- void cdfCanvasGetOrigin(cdCanvas* canvas, double *x, double *y);
89
- void cdCanvasTransform(cdCanvas* canvas, const double* matrix);
90
- double* cdCanvasGetTransform(cdCanvas* canvas);
91
- void cdCanvasTransformMultiply(cdCanvas* canvas, const double* matrix);
92
- void cdCanvasTransformRotate(cdCanvas* canvas, double angle);
93
- void cdCanvasTransformScale(cdCanvas* canvas, double sx, double sy);
94
- void cdCanvasTransformTranslate(cdCanvas* canvas, double dx, double dy);
95
- void cdCanvasTransformPoint(cdCanvas* canvas, int x, int y, int *tx, int *ty);
96
- void cdfCanvasTransformPoint(cdCanvas* canvas, double x, double y, double *tx, double *ty);
97
-
98
- /* clipping */
99
- int cdCanvasClip(cdCanvas* canvas, int mode);
100
- void cdCanvasClipArea(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax);
101
- int cdCanvasGetClipArea(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax);
102
- void cdfCanvasClipArea(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax);
103
- int cdfCanvasGetClipArea(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax);
104
-
105
- /* clipping region */
106
- int cdCanvasIsPointInRegion(cdCanvas* canvas, int x, int y);
107
- void cdCanvasOffsetRegion(cdCanvas* canvas, int x, int y);
108
- void cdCanvasGetRegionBox(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax);
109
- int cdCanvasRegionCombineMode(cdCanvas* canvas, int mode);
110
-
111
- /* primitives */
112
- void cdCanvasPixel(cdCanvas* canvas, int x, int y, long color);
113
- void cdCanvasMark(cdCanvas* canvas, int x, int y);
114
-
115
- void cdCanvasLine(cdCanvas* canvas, int x1, int y1, int x2, int y2);
116
- void cdCanvasBegin(cdCanvas* canvas, int mode);
117
- void cdCanvasVertex(cdCanvas* canvas, int x, int y);
118
- void cdCanvasEnd(cdCanvas* canvas);
119
- void cdCanvasRect(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax);
120
- void cdCanvasBox(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax);
121
- void cdCanvasArc(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2);
122
- void cdCanvasSector(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2);
123
- void cdCanvasChord(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2);
124
- void cdCanvasText(cdCanvas* canvas, int x, int y, const char* s);
125
-
126
- void cdfCanvasLine(cdCanvas* canvas, double x1, double y1, double x2, double y2);
127
- void cdfCanvasVertex(cdCanvas* canvas, double x, double y);
128
- void cdfCanvasRect(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax);
129
- void cdfCanvasBox(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax);
130
- void cdfCanvasArc(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2);
131
- void cdfCanvasSector(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2);
132
- void cdfCanvasChord(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2);
133
- void cdfCanvasText(cdCanvas* canvas, double x, double y, const char* s);
134
-
135
- /* attributes */
136
- void cdCanvasSetBackground(cdCanvas* canvas, long color);
137
- void cdCanvasSetForeground(cdCanvas* canvas, long color);
138
- long cdCanvasBackground(cdCanvas* canvas, long color);
139
- long cdCanvasForeground(cdCanvas* canvas, long color);
140
- int cdCanvasBackOpacity(cdCanvas* canvas, int opacity);
141
- int cdCanvasWriteMode(cdCanvas* canvas, int mode);
142
- int cdCanvasLineStyle(cdCanvas* canvas, int style);
143
- void cdCanvasLineStyleDashes(cdCanvas* canvas, const int* dashes, int count);
144
- int cdCanvasLineWidth(cdCanvas* canvas, int width);
145
- int cdCanvasLineJoin(cdCanvas* canvas, int join);
146
- int cdCanvasLineCap(cdCanvas* canvas, int cap);
147
- int cdCanvasInteriorStyle(cdCanvas* canvas, int style);
148
- int cdCanvasHatch(cdCanvas* canvas, int style);
149
- void cdCanvasStipple(cdCanvas* canvas, int w, int h, const unsigned char* stipple);
150
- unsigned char* cdCanvasGetStipple(cdCanvas* canvas, int *n, int *m);
151
- void cdCanvasPattern(cdCanvas* canvas, int w, int h, long const int *pattern);
152
- long* cdCanvasGetPattern(cdCanvas* canvas, int* n, int* m);
153
- int cdCanvasFillMode(cdCanvas* canvas, int mode);
154
- int cdCanvasFont(cdCanvas* canvas, const char* type_face, int style, int size);
155
- void cdCanvasGetFont(cdCanvas* canvas, char *type_face, int *style, int *size);
156
- char* cdCanvasNativeFont(cdCanvas* canvas, const char* font);
157
- int cdCanvasTextAlignment(cdCanvas* canvas, int alignment);
158
- double cdCanvasTextOrientation(cdCanvas* canvas, double angle);
159
- int cdCanvasMarkType(cdCanvas* canvas, int type);
160
- int cdCanvasMarkSize(cdCanvas* canvas, int size);
161
-
162
- /* vector text */
163
- void cdCanvasVectorText(cdCanvas* canvas, int x, int y, const char* s);
164
- void cdCanvasMultiLineVectorText(cdCanvas* canvas, int x, int y, const char* s);
165
-
166
- /* vector text attributes */
167
- char *cdCanvasVectorFont(cdCanvas* canvas, const char *filename);
168
- void cdCanvasVectorTextDirection(cdCanvas* canvas, int x1, int y1, int x2, int y2);
169
- double* cdCanvasVectorTextTransform(cdCanvas* canvas, const double* matrix);
170
- void cdCanvasVectorTextSize(cdCanvas* canvas, int size_x, int size_y, const char* s);
171
- int cdCanvasVectorCharSize(cdCanvas* canvas, int size);
172
-
173
- /* vector text properties */
174
- void cdCanvasGetVectorTextSize(cdCanvas* canvas, const char* s, int *x, int *y);
175
- void cdCanvasGetVectorTextBounds(cdCanvas* canvas, const char* s, int x, int y, int *rect);
176
-
177
- /* properties */
178
- void cdCanvasGetFontDim(cdCanvas* canvas, int *max_width, int *height, int *ascent, int *descent);
179
- void cdCanvasGetTextSize(cdCanvas* canvas, const char* s, int *width, int *height);
180
- void cdCanvasGetTextBox(cdCanvas* canvas, int x, int y, const char* s, int *xmin, int *xmax, int *ymin, int *ymax);
181
- void cdCanvasGetTextBounds(cdCanvas* canvas, int x, int y, const char* s, int *rect);
182
- int cdCanvasGetColorPlanes(cdCanvas* canvas);
183
-
184
- /* color */
185
- void cdCanvasPalette(cdCanvas* canvas, int n, const long *palette, int mode);
186
-
187
- /* client images */
188
- void cdCanvasGetImageRGB(cdCanvas* canvas, unsigned char* r, unsigned char* g, unsigned char* b, int x, int y, int w, int h);
189
- void cdCanvasPutImageRectRGB(cdCanvas* canvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax);
190
- void cdCanvasPutImageRectRGBA(cdCanvas* canvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, const unsigned char* a, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax);
191
- void cdCanvasPutImageRectMap(cdCanvas* canvas, int iw, int ih, const unsigned char* index, const long* colors, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax);
192
-
193
- /* server images */
194
- cdImage* cdCanvasCreateImage(cdCanvas* canvas, int w, int h);
195
- void cdKillImage(cdImage* image);
196
- void cdCanvasGetImage(cdCanvas* canvas, cdImage* image, int x, int y);
197
- void cdCanvasPutImageRect(cdCanvas* canvas, cdImage* image, int x, int y, int xmin, int xmax, int ymin, int ymax);
198
- void cdCanvasScrollArea(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, int dx, int dy);
199
-
200
- /* bitmap */
201
- cdBitmap* cdCreateBitmap(int w, int h, int type);
202
- cdBitmap* cdInitBitmap(int w, int h, int type, ...);
203
- void cdKillBitmap(cdBitmap* bitmap);
204
- unsigned char* cdBitmapGetData(cdBitmap* bitmap, int dataptr);
205
- void cdBitmapSetRect(cdBitmap* bitmap, int xmin, int xmax, int ymin, int ymax);
206
- void cdCanvasPutBitmap(cdCanvas* canvas, cdBitmap* bitmap, int x, int y, int w, int h);
207
- void cdCanvasGetBitmap(cdCanvas* canvas, cdBitmap* bitmap, int x, int y);
208
- void cdBitmapRGB2Map(cdBitmap* bitmap_rgb, cdBitmap* bitmap_map);
209
-
210
- /* color */
211
- long cdEncodeColor(unsigned char red, unsigned char green, unsigned char blue);
212
- void cdDecodeColor(long color, unsigned char* red, unsigned char* green, unsigned char* blue);
213
- unsigned char cdDecodeAlpha(long color);
214
- long cdEncodeAlpha(long color, unsigned char alpha);
215
-
216
- #define cdAlpha(_) (unsigned char)(~(((_) >> 24) & 0xFF))
217
- #define cdReserved(_) (unsigned char)(((_) >> 24) & 0xFF)
218
- #define cdRed(_) (unsigned char)(((_) >> 16) & 0xFF)
219
- #define cdGreen(_) (unsigned char)(((_) >> 8) & 0xFF)
220
- #define cdBlue(_) (unsigned char)(((_) >> 0) & 0xFF)
221
-
222
- /* client image color convertion */
223
- void cdRGB2Map(int width, int height, const unsigned char* red, const unsigned char* green, const unsigned char* blue, unsigned char* index, int pal_size, long *color);
224
-
225
-
226
- /* CD Values */
227
-
228
- #define CD_QUERY -1 /* query value */
229
-
230
- enum { /* bitmap type */
231
- CD_RGB, /* these definitions are compatible with the IM library */
232
- CD_MAP,
233
- CD_RGBA = 0x100
234
- };
235
-
236
- enum { /* bitmap data */
237
- CD_IRED,
238
- CD_IGREEN,
239
- CD_IBLUE,
240
- CD_IALPHA,
241
- CD_INDEX,
242
- CD_COLORS
243
- };
244
-
245
- enum { /* status report */
246
- CD_ERROR = -1,
247
- CD_OK = 0
248
- };
249
-
250
- enum { /* clip mode */
251
- CD_CLIPOFF,
252
- CD_CLIPAREA,
253
- CD_CLIPPOLYGON,
254
- CD_CLIPREGION
255
- };
256
-
257
- enum { /* region combine mode */
258
- CD_UNION,
259
- CD_INTERSECT,
260
- CD_DIFFERENCE,
261
- CD_NOTINTERSECT
262
- };
263
-
264
- enum { /* polygon mode (begin...end) */
265
- CD_FILL,
266
- CD_OPEN_LINES,
267
- CD_CLOSED_LINES,
268
- CD_CLIP,
269
- CD_BEZIER,
270
- CD_REGION
271
- };
272
-
273
- #define CD_POLYCUSTOM 10
274
-
275
- enum { /* fill mode */
276
- CD_EVENODD,
277
- CD_WINDING
278
- };
279
-
280
- enum { /* line join */
281
- CD_MITER,
282
- CD_BEVEL,
283
- CD_ROUND
284
- };
285
-
286
- enum { /* line cap */
287
- CD_CAPFLAT,
288
- CD_CAPSQUARE,
289
- CD_CAPROUND
290
- };
291
-
292
- enum { /* background opacity mode */
293
- CD_OPAQUE,
294
- CD_TRANSPARENT
295
- };
296
-
297
- enum { /* write mode */
298
- CD_REPLACE,
299
- CD_XOR,
300
- CD_NOT_XOR
301
- };
302
-
303
- enum { /* color allocation mode (palette) */
304
- CD_POLITE,
305
- CD_FORCE
306
- };
307
-
308
- enum { /* line style */
309
- CD_CONTINUOUS,
310
- CD_DASHED,
311
- CD_DOTTED,
312
- CD_DASH_DOT,
313
- CD_DASH_DOT_DOT,
314
- CD_CUSTOM
315
- };
316
-
317
- enum { /* marker type */
318
- CD_PLUS,
319
- CD_STAR,
320
- CD_CIRCLE,
321
- CD_X,
322
- CD_BOX,
323
- CD_DIAMOND,
324
- CD_HOLLOW_CIRCLE,
325
- CD_HOLLOW_BOX,
326
- CD_HOLLOW_DIAMOND
327
- };
328
-
329
- enum { /* hatch type */
330
- CD_HORIZONTAL,
331
- CD_VERTICAL,
332
- CD_FDIAGONAL,
333
- CD_BDIAGONAL,
334
- CD_CROSS,
335
- CD_DIAGCROSS
336
- };
337
-
338
- enum { /* interior style */
339
- CD_SOLID,
340
- CD_HATCH,
341
- CD_STIPPLE,
342
- CD_PATTERN,
343
- CD_HOLLOW
344
- };
345
-
346
- enum { /* text alignment */
347
- CD_NORTH,
348
- CD_SOUTH,
349
- CD_EAST,
350
- CD_WEST,
351
- CD_NORTH_EAST,
352
- CD_NORTH_WEST,
353
- CD_SOUTH_EAST,
354
- CD_SOUTH_WEST,
355
- CD_CENTER,
356
- CD_BASE_LEFT,
357
- CD_BASE_CENTER,
358
- CD_BASE_RIGHT
359
- };
360
-
361
- enum { /* style */
362
- CD_PLAIN = 0,
363
- CD_BOLD = 1,
364
- CD_ITALIC = 2,
365
- CD_UNDERLINE = 4,
366
- CD_STRIKEOUT = 8
367
- };
368
-
369
- #define CD_BOLD_ITALIC (CD_BOLD|CD_ITALIC) /* compatibility name */
370
-
371
- enum { /* some font sizes */
372
- CD_SMALL = 8,
373
- CD_STANDARD = 12,
374
- CD_LARGE = 18
375
- };
376
-
377
- /* Canvas Capabilities */
378
- #define CD_CAP_NONE 0x00000000
379
- #define CD_CAP_FLUSH 0x00000001
380
- #define CD_CAP_CLEAR 0x00000002
381
- #define CD_CAP_PLAY 0x00000004
382
- #define CD_CAP_YAXIS 0x00000008
383
- #define CD_CAP_CLIPAREA 0x00000010
384
- #define CD_CAP_CLIPPOLY 0x00000020
385
- #define CD_CAP_REGION 0x00000040
386
- #define CD_CAP_RECT 0x00000080
387
- #define CD_CAP_CHORD 0x00000100
388
- #define CD_CAP_IMAGERGB 0x00000200
389
- #define CD_CAP_IMAGERGBA 0x00000400
390
- #define CD_CAP_IMAGEMAP 0x00000800
391
- #define CD_CAP_GETIMAGERGB 0x00001000
392
- #define CD_CAP_IMAGESRV 0x00002000
393
- #define CD_CAP_BACKGROUND 0x00004000
394
- #define CD_CAP_BACKOPACITY 0x00008000
395
- #define CD_CAP_WRITEMODE 0x00010000
396
- #define CD_CAP_LINESTYLE 0x00020000
397
- #define CD_CAP_LINEWITH 0x00040000
398
- #define CD_CAP_FPRIMTIVES 0x00080000
399
- #define CD_CAP_HATCH 0x00100000
400
- #define CD_CAP_STIPPLE 0x00200000
401
- #define CD_CAP_PATTERN 0x00400000
402
- #define CD_CAP_FONT 0x00800000
403
- #define CD_CAP_FONTDIM 0x01000000
404
- #define CD_CAP_TEXTSIZE 0x02000000
405
- #define CD_CAP_TEXTORIENTATION 0x04000000
406
- #define CD_CAP_PALETTE 0x08000000
407
- #define CD_CAP_LINECAP 0x10000000
408
- #define CD_CAP_LINEJOIN 0x20000000
409
- #define CD_CAP_ALL 0xFFFFFFFF
410
-
411
- /* cdPlay definitions */
412
- #define CD_SIZECB 0 /* size callback */
413
- typedef int(*cdSizeCB)(cdCanvas *canvas, int w, int h, double w_mm, double h_mm);
414
- #define CD_ABORT 1
415
- #define CD_CONTINUE 0
416
-
417
- /* simulation flags */
418
- #define CD_SIM_NONE 0x0000
419
- #define CD_SIM_LINE 0x0001
420
- #define CD_SIM_RECT 0x0002
421
- #define CD_SIM_BOX 0x0004
422
- #define CD_SIM_ARC 0x0008
423
- #define CD_SIM_SECTOR 0x0010
424
- #define CD_SIM_CHORD 0x0020
425
- #define CD_SIM_POLYLINE 0x0040
426
- #define CD_SIM_POLYGON 0x0080
427
- #define CD_SIM_TEXT 0x0100
428
- #define CD_SIM_ALL 0xFFFF
429
-
430
- #define CD_SIM_LINES (CD_SIM_LINE | CD_SIM_RECT | CD_SIM_ARC | CD_SIM_POLYLINE)
431
- #define CD_SIM_FILLS (CD_SIM_BOX | CD_SIM_SECTOR | CD_SIM_CHORD | CD_SIM_POLYGON)
432
-
433
- /* some predefined colors for convenience */
434
- #define CD_RED 0xFF0000L /* 255, 0, 0 */
435
- #define CD_DARK_RED 0x800000L /* 128, 0, 0 */
436
- #define CD_GREEN 0x00FF00L /* 0,255, 0 */
437
- #define CD_DARK_GREEN 0x008000L /* 0,128, 0 */
438
- #define CD_BLUE 0x0000FFL /* 0, 0,255 */
439
- #define CD_DARK_BLUE 0x000080L /* 0, 0,128 */
440
-
441
- #define CD_YELLOW 0xFFFF00L /* 255,255, 0 */
442
- #define CD_DARK_YELLOW 0x808000L /* 128,128, 0 */
443
- #define CD_MAGENTA 0xFF00FFL /* 255, 0,255 */
444
- #define CD_DARK_MAGENTA 0x800080L /* 128, 0,128 */
445
- #define CD_CYAN 0x00FFFFL /* 0,255,255 */
446
- #define CD_DARK_CYAN 0x008080L /* 0,128,128 */
447
-
448
- #define CD_WHITE 0xFFFFFFL /* 255,255,255 */
449
- #define CD_BLACK 0x000000L /* 0, 0, 0 */
450
-
451
- #define CD_DARK_GRAY 0x808080L /* 128,128,128 */
452
- #define CD_GRAY 0xC0C0C0L /* 192,192,192 */
453
-
454
- /* some usefull conversion factors */
455
- #define CD_MM2PT 2.834645669 /* milimeters to points (pt = CD_MM2PT * mm) */
456
- #define CD_RAD2DEG 57.295779513 /* radians to degrees (deg = CD_RAD2DEG * rad) */
457
- #define CD_DEG2RAD 0.01745329252 /* degrees to radians (rad = CD_DEG2RAD * deg) */
458
-
459
-
460
- #ifdef __cplusplus
461
- }
462
- #endif
463
-
464
-
465
- #ifndef CD_NO_OLD_INTERFACE
466
- #include "cd_old.h"
467
- #endif
468
-
469
-
470
- /******************************************************************************
471
- Copyright (C) 1994-2008 Tecgraf, PUC-Rio.
472
-
473
- Permission is hereby granted, free of charge, to any person obtaining
474
- a copy of this software and associated documentation files (the
475
- "Software"), to deal in the Software without restriction, including
476
- without limitation the rights to use, copy, modify, merge, publish,
477
- distribute, sublicense, and/or sell copies of the Software, and to
478
- permit persons to whom the Software is furnished to do so, subject to
479
- the following conditions:
480
-
481
- The above copyright notice and this permission notice shall be
482
- included in all copies or substantial portions of the Software.
483
-
484
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
485
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
486
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
487
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
488
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
489
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
490
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
491
- ******************************************************************************/
492
-
493
- #endif /* ifndef CD_H */
494
-
1
+ /** \file
2
+ * \brief User API
3
+ * CD - Canvas Draw
4
+ * Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil
5
+ * http://www.tecgraf.puc-rio.br/cd
6
+ * mailto:cd@tecgraf.puc-rio.br
7
+ *
8
+ * See Copyright Notice at the end of this file
9
+ */
10
+
11
+ #ifndef __CD_H
12
+ #define __CD_H
13
+
14
+ #ifdef __cplusplus
15
+ extern "C" {
16
+ #endif
17
+
18
+
19
+ #define CD_NAME "CD - Canvas Draw"
20
+ #define CD_DESCRIPTION "A 2D Graphics Library"
21
+ #define CD_COPYRIGHT "Copyright (C) 1994-2008 Tecgraf, PUC-Rio."
22
+ #define CD_VERSION "5.1"
23
+ #define CD_VERSION_DATE "2008/10/14"
24
+ #define CD_VERSION_NUMBER 501000
25
+
26
+ typedef struct _cdContext cdContext;
27
+ typedef struct _cdCanvas cdCanvas;
28
+ typedef struct _cdCanvas cdState;
29
+ typedef struct _cdImage cdImage;
30
+
31
+ /* client images using bitmap structure */
32
+ typedef struct _cdBitmap {
33
+ int w;
34
+ int h;
35
+ int type;
36
+ void *data;
37
+ } cdBitmap;
38
+
39
+
40
+ /* library */
41
+ char* cdVersion(void);
42
+ char* cdVersionDate(void);
43
+ int cdVersionNumber(void);
44
+
45
+ /* canvas init */
46
+ cdCanvas* cdCreateCanvas(cdContext *context, void *data);
47
+ cdCanvas* cdCreateCanvasf(cdContext *context, const char* format, ...);
48
+ void cdKillCanvas(cdCanvas* canvas);
49
+
50
+ cdContext* cdCanvasGetContext(cdCanvas* canvas);
51
+ int cdCanvasActivate(cdCanvas* canvas);
52
+ void cdCanvasDeactivate(cdCanvas* canvas);
53
+ int cdUseContextPlus(int use);
54
+ void cdInitContextPlus(void); /* need an external library */
55
+
56
+ /* context */
57
+ typedef int (*cdCallback)(cdCanvas* canvas, ...);
58
+ int cdContextRegisterCallback(cdContext *context, int cb, cdCallback func);
59
+ unsigned long cdContextCaps(cdContext *context);
60
+
61
+ /* control */
62
+ int cdCanvasSimulate(cdCanvas* canvas, int mode);
63
+ void cdCanvasFlush(cdCanvas* canvas);
64
+ void cdCanvasClear(cdCanvas* canvas);
65
+ cdState* cdCanvasSaveState(cdCanvas* canvas);
66
+ void cdCanvasRestoreState(cdCanvas* canvas, cdState* state);
67
+ void cdReleaseState(cdState* state);
68
+ void cdCanvasSetAttribute(cdCanvas* canvas, const char* name, char* data);
69
+ void cdCanvasSetfAttribute(cdCanvas* canvas, const char* name, const char* format, ...);
70
+ char* cdCanvasGetAttribute(cdCanvas* canvas, const char* name);
71
+
72
+ /* interpretation */
73
+ int cdCanvasPlay(cdCanvas* canvas, cdContext *context, int xmin, int xmax, int ymin, int ymax, void *data);
74
+
75
+ /* coordinate transformation */
76
+ void cdCanvasGetSize(cdCanvas* canvas, int *width, int *height, double *width_mm, double *height_mm);
77
+ int cdCanvasUpdateYAxis(cdCanvas* canvas, int* y);
78
+ double cdfCanvasUpdateYAxis(cdCanvas* canvas, double* y);
79
+ int cdCanvasInvertYAxis(cdCanvas* canvas, int y);
80
+ double cdfCanvasInvertYAxis(cdCanvas* canvas, double y);
81
+ void cdCanvasMM2Pixel(cdCanvas* canvas, double mm_dx, double mm_dy, int *dx, int *dy);
82
+ void cdCanvasPixel2MM(cdCanvas* canvas, int dx, int dy, double *mm_dx, double *mm_dy);
83
+ void cdfCanvasMM2Pixel(cdCanvas* canvas, double mm_dx, double mm_dy, double *dx, double *dy);
84
+ void cdfCanvasPixel2MM(cdCanvas* canvas, double dx, double dy, double *mm_dx, double *mm_dy);
85
+ void cdCanvasOrigin(cdCanvas* canvas, int x, int y);
86
+ void cdfCanvasOrigin(cdCanvas* canvas, double x, double y);
87
+ void cdCanvasGetOrigin(cdCanvas* canvas, int *x, int *y);
88
+ void cdfCanvasGetOrigin(cdCanvas* canvas, double *x, double *y);
89
+ void cdCanvasTransform(cdCanvas* canvas, const double* matrix);
90
+ double* cdCanvasGetTransform(cdCanvas* canvas);
91
+ void cdCanvasTransformMultiply(cdCanvas* canvas, const double* matrix);
92
+ void cdCanvasTransformRotate(cdCanvas* canvas, double angle);
93
+ void cdCanvasTransformScale(cdCanvas* canvas, double sx, double sy);
94
+ void cdCanvasTransformTranslate(cdCanvas* canvas, double dx, double dy);
95
+ void cdCanvasTransformPoint(cdCanvas* canvas, int x, int y, int *tx, int *ty);
96
+ void cdfCanvasTransformPoint(cdCanvas* canvas, double x, double y, double *tx, double *ty);
97
+
98
+ /* clipping */
99
+ int cdCanvasClip(cdCanvas* canvas, int mode);
100
+ void cdCanvasClipArea(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax);
101
+ int cdCanvasGetClipArea(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax);
102
+ void cdfCanvasClipArea(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax);
103
+ int cdfCanvasGetClipArea(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax);
104
+
105
+ /* clipping region */
106
+ int cdCanvasIsPointInRegion(cdCanvas* canvas, int x, int y);
107
+ void cdCanvasOffsetRegion(cdCanvas* canvas, int x, int y);
108
+ void cdCanvasGetRegionBox(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax);
109
+ int cdCanvasRegionCombineMode(cdCanvas* canvas, int mode);
110
+
111
+ /* primitives */
112
+ void cdCanvasPixel(cdCanvas* canvas, int x, int y, long color);
113
+ void cdCanvasMark(cdCanvas* canvas, int x, int y);
114
+
115
+ void cdCanvasLine(cdCanvas* canvas, int x1, int y1, int x2, int y2);
116
+ void cdCanvasBegin(cdCanvas* canvas, int mode);
117
+ void cdCanvasVertex(cdCanvas* canvas, int x, int y);
118
+ void cdCanvasEnd(cdCanvas* canvas);
119
+ void cdCanvasRect(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax);
120
+ void cdCanvasBox(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax);
121
+ void cdCanvasArc(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2);
122
+ void cdCanvasSector(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2);
123
+ void cdCanvasChord(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2);
124
+ void cdCanvasText(cdCanvas* canvas, int x, int y, const char* s);
125
+
126
+ void cdfCanvasLine(cdCanvas* canvas, double x1, double y1, double x2, double y2);
127
+ void cdfCanvasVertex(cdCanvas* canvas, double x, double y);
128
+ void cdfCanvasRect(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax);
129
+ void cdfCanvasBox(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax);
130
+ void cdfCanvasArc(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2);
131
+ void cdfCanvasSector(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2);
132
+ void cdfCanvasChord(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2);
133
+ void cdfCanvasText(cdCanvas* canvas, double x, double y, const char* s);
134
+
135
+ /* attributes */
136
+ void cdCanvasSetBackground(cdCanvas* canvas, long color);
137
+ void cdCanvasSetForeground(cdCanvas* canvas, long color);
138
+ long cdCanvasBackground(cdCanvas* canvas, long color);
139
+ long cdCanvasForeground(cdCanvas* canvas, long color);
140
+ int cdCanvasBackOpacity(cdCanvas* canvas, int opacity);
141
+ int cdCanvasWriteMode(cdCanvas* canvas, int mode);
142
+ int cdCanvasLineStyle(cdCanvas* canvas, int style);
143
+ void cdCanvasLineStyleDashes(cdCanvas* canvas, const int* dashes, int count);
144
+ int cdCanvasLineWidth(cdCanvas* canvas, int width);
145
+ int cdCanvasLineJoin(cdCanvas* canvas, int join);
146
+ int cdCanvasLineCap(cdCanvas* canvas, int cap);
147
+ int cdCanvasInteriorStyle(cdCanvas* canvas, int style);
148
+ int cdCanvasHatch(cdCanvas* canvas, int style);
149
+ void cdCanvasStipple(cdCanvas* canvas, int w, int h, const unsigned char* stipple);
150
+ unsigned char* cdCanvasGetStipple(cdCanvas* canvas, int *n, int *m);
151
+ void cdCanvasPattern(cdCanvas* canvas, int w, int h, long const int *pattern);
152
+ long* cdCanvasGetPattern(cdCanvas* canvas, int* n, int* m);
153
+ int cdCanvasFillMode(cdCanvas* canvas, int mode);
154
+ int cdCanvasFont(cdCanvas* canvas, const char* type_face, int style, int size);
155
+ void cdCanvasGetFont(cdCanvas* canvas, char *type_face, int *style, int *size);
156
+ char* cdCanvasNativeFont(cdCanvas* canvas, const char* font);
157
+ int cdCanvasTextAlignment(cdCanvas* canvas, int alignment);
158
+ double cdCanvasTextOrientation(cdCanvas* canvas, double angle);
159
+ int cdCanvasMarkType(cdCanvas* canvas, int type);
160
+ int cdCanvasMarkSize(cdCanvas* canvas, int size);
161
+
162
+ /* vector text */
163
+ void cdCanvasVectorText(cdCanvas* canvas, int x, int y, const char* s);
164
+ void cdCanvasMultiLineVectorText(cdCanvas* canvas, int x, int y, const char* s);
165
+
166
+ /* vector text attributes */
167
+ char *cdCanvasVectorFont(cdCanvas* canvas, const char *filename);
168
+ void cdCanvasVectorTextDirection(cdCanvas* canvas, int x1, int y1, int x2, int y2);
169
+ double* cdCanvasVectorTextTransform(cdCanvas* canvas, const double* matrix);
170
+ void cdCanvasVectorTextSize(cdCanvas* canvas, int size_x, int size_y, const char* s);
171
+ int cdCanvasVectorCharSize(cdCanvas* canvas, int size);
172
+
173
+ /* vector text properties */
174
+ void cdCanvasGetVectorTextSize(cdCanvas* canvas, const char* s, int *x, int *y);
175
+ void cdCanvasGetVectorTextBounds(cdCanvas* canvas, const char* s, int x, int y, int *rect);
176
+
177
+ /* properties */
178
+ void cdCanvasGetFontDim(cdCanvas* canvas, int *max_width, int *height, int *ascent, int *descent);
179
+ void cdCanvasGetTextSize(cdCanvas* canvas, const char* s, int *width, int *height);
180
+ void cdCanvasGetTextBox(cdCanvas* canvas, int x, int y, const char* s, int *xmin, int *xmax, int *ymin, int *ymax);
181
+ void cdCanvasGetTextBounds(cdCanvas* canvas, int x, int y, const char* s, int *rect);
182
+ int cdCanvasGetColorPlanes(cdCanvas* canvas);
183
+
184
+ /* color */
185
+ void cdCanvasPalette(cdCanvas* canvas, int n, const long *palette, int mode);
186
+
187
+ /* client images */
188
+ void cdCanvasGetImageRGB(cdCanvas* canvas, unsigned char* r, unsigned char* g, unsigned char* b, int x, int y, int w, int h);
189
+ void cdCanvasPutImageRectRGB(cdCanvas* canvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax);
190
+ void cdCanvasPutImageRectRGBA(cdCanvas* canvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, const unsigned char* a, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax);
191
+ void cdCanvasPutImageRectMap(cdCanvas* canvas, int iw, int ih, const unsigned char* index, const long* colors, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax);
192
+
193
+ /* server images */
194
+ cdImage* cdCanvasCreateImage(cdCanvas* canvas, int w, int h);
195
+ void cdKillImage(cdImage* image);
196
+ void cdCanvasGetImage(cdCanvas* canvas, cdImage* image, int x, int y);
197
+ void cdCanvasPutImageRect(cdCanvas* canvas, cdImage* image, int x, int y, int xmin, int xmax, int ymin, int ymax);
198
+ void cdCanvasScrollArea(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, int dx, int dy);
199
+
200
+ /* bitmap */
201
+ cdBitmap* cdCreateBitmap(int w, int h, int type);
202
+ cdBitmap* cdInitBitmap(int w, int h, int type, ...);
203
+ void cdKillBitmap(cdBitmap* bitmap);
204
+ unsigned char* cdBitmapGetData(cdBitmap* bitmap, int dataptr);
205
+ void cdBitmapSetRect(cdBitmap* bitmap, int xmin, int xmax, int ymin, int ymax);
206
+ void cdCanvasPutBitmap(cdCanvas* canvas, cdBitmap* bitmap, int x, int y, int w, int h);
207
+ void cdCanvasGetBitmap(cdCanvas* canvas, cdBitmap* bitmap, int x, int y);
208
+ void cdBitmapRGB2Map(cdBitmap* bitmap_rgb, cdBitmap* bitmap_map);
209
+
210
+ /* color */
211
+ long cdEncodeColor(unsigned char red, unsigned char green, unsigned char blue);
212
+ void cdDecodeColor(long color, unsigned char* red, unsigned char* green, unsigned char* blue);
213
+ unsigned char cdDecodeAlpha(long color);
214
+ long cdEncodeAlpha(long color, unsigned char alpha);
215
+
216
+ #define cdAlpha(_) (unsigned char)(~(((_) >> 24) & 0xFF))
217
+ #define cdReserved(_) (unsigned char)(((_) >> 24) & 0xFF)
218
+ #define cdRed(_) (unsigned char)(((_) >> 16) & 0xFF)
219
+ #define cdGreen(_) (unsigned char)(((_) >> 8) & 0xFF)
220
+ #define cdBlue(_) (unsigned char)(((_) >> 0) & 0xFF)
221
+
222
+ /* client image color convertion */
223
+ void cdRGB2Map(int width, int height, const unsigned char* red, const unsigned char* green, const unsigned char* blue, unsigned char* index, int pal_size, long *color);
224
+
225
+
226
+ /* CD Values */
227
+
228
+ #define CD_QUERY -1 /* query value */
229
+
230
+ enum { /* bitmap type */
231
+ CD_RGB, /* these definitions are compatible with the IM library */
232
+ CD_MAP,
233
+ CD_RGBA = 0x100
234
+ };
235
+
236
+ enum { /* bitmap data */
237
+ CD_IRED,
238
+ CD_IGREEN,
239
+ CD_IBLUE,
240
+ CD_IALPHA,
241
+ CD_INDEX,
242
+ CD_COLORS
243
+ };
244
+
245
+ enum { /* status report */
246
+ CD_ERROR = -1,
247
+ CD_OK = 0
248
+ };
249
+
250
+ enum { /* clip mode */
251
+ CD_CLIPOFF,
252
+ CD_CLIPAREA,
253
+ CD_CLIPPOLYGON,
254
+ CD_CLIPREGION
255
+ };
256
+
257
+ enum { /* region combine mode */
258
+ CD_UNION,
259
+ CD_INTERSECT,
260
+ CD_DIFFERENCE,
261
+ CD_NOTINTERSECT
262
+ };
263
+
264
+ enum { /* polygon mode (begin...end) */
265
+ CD_FILL,
266
+ CD_OPEN_LINES,
267
+ CD_CLOSED_LINES,
268
+ CD_CLIP,
269
+ CD_BEZIER,
270
+ CD_REGION
271
+ };
272
+
273
+ #define CD_POLYCUSTOM 10
274
+
275
+ enum { /* fill mode */
276
+ CD_EVENODD,
277
+ CD_WINDING
278
+ };
279
+
280
+ enum { /* line join */
281
+ CD_MITER,
282
+ CD_BEVEL,
283
+ CD_ROUND
284
+ };
285
+
286
+ enum { /* line cap */
287
+ CD_CAPFLAT,
288
+ CD_CAPSQUARE,
289
+ CD_CAPROUND
290
+ };
291
+
292
+ enum { /* background opacity mode */
293
+ CD_OPAQUE,
294
+ CD_TRANSPARENT
295
+ };
296
+
297
+ enum { /* write mode */
298
+ CD_REPLACE,
299
+ CD_XOR,
300
+ CD_NOT_XOR
301
+ };
302
+
303
+ enum { /* color allocation mode (palette) */
304
+ CD_POLITE,
305
+ CD_FORCE
306
+ };
307
+
308
+ enum { /* line style */
309
+ CD_CONTINUOUS,
310
+ CD_DASHED,
311
+ CD_DOTTED,
312
+ CD_DASH_DOT,
313
+ CD_DASH_DOT_DOT,
314
+ CD_CUSTOM
315
+ };
316
+
317
+ enum { /* marker type */
318
+ CD_PLUS,
319
+ CD_STAR,
320
+ CD_CIRCLE,
321
+ CD_X,
322
+ CD_BOX,
323
+ CD_DIAMOND,
324
+ CD_HOLLOW_CIRCLE,
325
+ CD_HOLLOW_BOX,
326
+ CD_HOLLOW_DIAMOND
327
+ };
328
+
329
+ enum { /* hatch type */
330
+ CD_HORIZONTAL,
331
+ CD_VERTICAL,
332
+ CD_FDIAGONAL,
333
+ CD_BDIAGONAL,
334
+ CD_CROSS,
335
+ CD_DIAGCROSS
336
+ };
337
+
338
+ enum { /* interior style */
339
+ CD_SOLID,
340
+ CD_HATCH,
341
+ CD_STIPPLE,
342
+ CD_PATTERN,
343
+ CD_HOLLOW
344
+ };
345
+
346
+ enum { /* text alignment */
347
+ CD_NORTH,
348
+ CD_SOUTH,
349
+ CD_EAST,
350
+ CD_WEST,
351
+ CD_NORTH_EAST,
352
+ CD_NORTH_WEST,
353
+ CD_SOUTH_EAST,
354
+ CD_SOUTH_WEST,
355
+ CD_CENTER,
356
+ CD_BASE_LEFT,
357
+ CD_BASE_CENTER,
358
+ CD_BASE_RIGHT
359
+ };
360
+
361
+ enum { /* style */
362
+ CD_PLAIN = 0,
363
+ CD_BOLD = 1,
364
+ CD_ITALIC = 2,
365
+ CD_UNDERLINE = 4,
366
+ CD_STRIKEOUT = 8
367
+ };
368
+
369
+ #define CD_BOLD_ITALIC (CD_BOLD|CD_ITALIC) /* compatibility name */
370
+
371
+ enum { /* some font sizes */
372
+ CD_SMALL = 8,
373
+ CD_STANDARD = 12,
374
+ CD_LARGE = 18
375
+ };
376
+
377
+ /* Canvas Capabilities */
378
+ #define CD_CAP_NONE 0x00000000
379
+ #define CD_CAP_FLUSH 0x00000001
380
+ #define CD_CAP_CLEAR 0x00000002
381
+ #define CD_CAP_PLAY 0x00000004
382
+ #define CD_CAP_YAXIS 0x00000008
383
+ #define CD_CAP_CLIPAREA 0x00000010
384
+ #define CD_CAP_CLIPPOLY 0x00000020
385
+ #define CD_CAP_REGION 0x00000040
386
+ #define CD_CAP_RECT 0x00000080
387
+ #define CD_CAP_CHORD 0x00000100
388
+ #define CD_CAP_IMAGERGB 0x00000200
389
+ #define CD_CAP_IMAGERGBA 0x00000400
390
+ #define CD_CAP_IMAGEMAP 0x00000800
391
+ #define CD_CAP_GETIMAGERGB 0x00001000
392
+ #define CD_CAP_IMAGESRV 0x00002000
393
+ #define CD_CAP_BACKGROUND 0x00004000
394
+ #define CD_CAP_BACKOPACITY 0x00008000
395
+ #define CD_CAP_WRITEMODE 0x00010000
396
+ #define CD_CAP_LINESTYLE 0x00020000
397
+ #define CD_CAP_LINEWITH 0x00040000
398
+ #define CD_CAP_FPRIMTIVES 0x00080000
399
+ #define CD_CAP_HATCH 0x00100000
400
+ #define CD_CAP_STIPPLE 0x00200000
401
+ #define CD_CAP_PATTERN 0x00400000
402
+ #define CD_CAP_FONT 0x00800000
403
+ #define CD_CAP_FONTDIM 0x01000000
404
+ #define CD_CAP_TEXTSIZE 0x02000000
405
+ #define CD_CAP_TEXTORIENTATION 0x04000000
406
+ #define CD_CAP_PALETTE 0x08000000
407
+ #define CD_CAP_LINECAP 0x10000000
408
+ #define CD_CAP_LINEJOIN 0x20000000
409
+ #define CD_CAP_ALL 0xFFFFFFFF
410
+
411
+ /* cdPlay definitions */
412
+ #define CD_SIZECB 0 /* size callback */
413
+ typedef int(*cdSizeCB)(cdCanvas *canvas, int w, int h, double w_mm, double h_mm);
414
+ #define CD_ABORT 1
415
+ #define CD_CONTINUE 0
416
+
417
+ /* simulation flags */
418
+ #define CD_SIM_NONE 0x0000
419
+ #define CD_SIM_LINE 0x0001
420
+ #define CD_SIM_RECT 0x0002
421
+ #define CD_SIM_BOX 0x0004
422
+ #define CD_SIM_ARC 0x0008
423
+ #define CD_SIM_SECTOR 0x0010
424
+ #define CD_SIM_CHORD 0x0020
425
+ #define CD_SIM_POLYLINE 0x0040
426
+ #define CD_SIM_POLYGON 0x0080
427
+ #define CD_SIM_TEXT 0x0100
428
+ #define CD_SIM_ALL 0xFFFF
429
+
430
+ #define CD_SIM_LINES (CD_SIM_LINE | CD_SIM_RECT | CD_SIM_ARC | CD_SIM_POLYLINE)
431
+ #define CD_SIM_FILLS (CD_SIM_BOX | CD_SIM_SECTOR | CD_SIM_CHORD | CD_SIM_POLYGON)
432
+
433
+ /* some predefined colors for convenience */
434
+ #define CD_RED 0xFF0000L /* 255, 0, 0 */
435
+ #define CD_DARK_RED 0x800000L /* 128, 0, 0 */
436
+ #define CD_GREEN 0x00FF00L /* 0,255, 0 */
437
+ #define CD_DARK_GREEN 0x008000L /* 0,128, 0 */
438
+ #define CD_BLUE 0x0000FFL /* 0, 0,255 */
439
+ #define CD_DARK_BLUE 0x000080L /* 0, 0,128 */
440
+
441
+ #define CD_YELLOW 0xFFFF00L /* 255,255, 0 */
442
+ #define CD_DARK_YELLOW 0x808000L /* 128,128, 0 */
443
+ #define CD_MAGENTA 0xFF00FFL /* 255, 0,255 */
444
+ #define CD_DARK_MAGENTA 0x800080L /* 128, 0,128 */
445
+ #define CD_CYAN 0x00FFFFL /* 0,255,255 */
446
+ #define CD_DARK_CYAN 0x008080L /* 0,128,128 */
447
+
448
+ #define CD_WHITE 0xFFFFFFL /* 255,255,255 */
449
+ #define CD_BLACK 0x000000L /* 0, 0, 0 */
450
+
451
+ #define CD_DARK_GRAY 0x808080L /* 128,128,128 */
452
+ #define CD_GRAY 0xC0C0C0L /* 192,192,192 */
453
+
454
+ /* some usefull conversion factors */
455
+ #define CD_MM2PT 2.834645669 /* milimeters to points (pt = CD_MM2PT * mm) */
456
+ #define CD_RAD2DEG 57.295779513 /* radians to degrees (deg = CD_RAD2DEG * rad) */
457
+ #define CD_DEG2RAD 0.01745329252 /* degrees to radians (rad = CD_DEG2RAD * deg) */
458
+
459
+
460
+ #ifdef __cplusplus
461
+ }
462
+ #endif
463
+
464
+
465
+ #ifndef CD_NO_OLD_INTERFACE
466
+ #include "cd_old.h"
467
+ #endif
468
+
469
+
470
+ /******************************************************************************
471
+ Copyright (C) 1994-2008 Tecgraf, PUC-Rio.
472
+
473
+ Permission is hereby granted, free of charge, to any person obtaining
474
+ a copy of this software and associated documentation files (the
475
+ "Software"), to deal in the Software without restriction, including
476
+ without limitation the rights to use, copy, modify, merge, publish,
477
+ distribute, sublicense, and/or sell copies of the Software, and to
478
+ permit persons to whom the Software is furnished to do so, subject to
479
+ the following conditions:
480
+
481
+ The above copyright notice and this permission notice shall be
482
+ included in all copies or substantial portions of the Software.
483
+
484
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
485
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
486
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
487
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
488
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
489
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
490
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
491
+ ******************************************************************************/
492
+
493
+ #endif /* ifndef CD_H */
494
+