iup-ffi 0.13.0-x86_64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENCE.md +21 -0
- data/README.md +139 -0
- data/lib/iup-ffi-plain.rb +51 -0
- data/lib/iup-ffi.rb +70 -0
- data/lib/library/linux/libcd.so +0 -0
- data/lib/library/linux/libim.so +0 -0
- data/lib/library/linux/libiup.so +0 -0
- data/lib/library/linux/libiup_scintilla.so +0 -0
- data/lib/library/linux/libiupcd.so +0 -0
- data/lib/library/linux/libiupcontrols.so +0 -0
- data/lib/library/linux/libiupim.so +0 -0
- data/lib/library/linux/libiupimglib.so +0 -0
- data/lib/plain/iupcdlib.rb +158 -0
- data/lib/plain/iupcontrolslib.rb +28 -0
- data/lib/plain/iupimglib.rb +15 -0
- data/lib/plain/iupimlib.rb +18 -0
- data/lib/plain/iuplib.rb +354 -0
- data/lib/plain/scintilla-lib.rb +17 -0
- data/lib/wrapped/attribute-builders.rb +93 -0
- data/lib/wrapped/attribute-reference.rb +27 -0
- data/lib/wrapped/background-box.rb +37 -0
- data/lib/wrapped/button.rb +152 -0
- data/lib/wrapped/callback-setter.rb +78 -0
- data/lib/wrapped/canvas.rb +698 -0
- data/lib/wrapped/colorbar.rb +212 -0
- data/lib/wrapped/colordialog.rb +121 -0
- data/lib/wrapped/common-attributes.rb +34 -0
- data/lib/wrapped/constants.rb +504 -0
- data/lib/wrapped/dial.rb +129 -0
- data/lib/wrapped/dialog.rb +309 -0
- data/lib/wrapped/drag-drop-attributes.rb +98 -0
- data/lib/wrapped/dynamic-fill-methods.rb +22 -0
- data/lib/wrapped/expander.rb +128 -0
- data/lib/wrapped/filedialog.rb +168 -0
- data/lib/wrapped/fill.rb +29 -0
- data/lib/wrapped/fontdialog.rb +71 -0
- data/lib/wrapped/frame.rb +70 -0
- data/lib/wrapped/gridbox.rb +188 -0
- data/lib/wrapped/hbox.rb +90 -0
- data/lib/wrapped/image-attributes.rb +58 -0
- data/lib/wrapped/image.rb +178 -0
- data/lib/wrapped/iup-global.rb +46 -0
- data/lib/wrapped/label.rb +110 -0
- data/lib/wrapped/link.rb +54 -0
- data/lib/wrapped/list.rb +567 -0
- data/lib/wrapped/matrix.rb +575 -0
- data/lib/wrapped/menu.rb +91 -0
- data/lib/wrapped/menuitem.rb +150 -0
- data/lib/wrapped/messagedialog.rb +127 -0
- data/lib/wrapped/progressbar.rb +91 -0
- data/lib/wrapped/progressdialog.rb +85 -0
- data/lib/wrapped/radio.rb +74 -0
- data/lib/wrapped/scintilla.rb +1112 -0
- data/lib/wrapped/scrollbar-attributes.rb +178 -0
- data/lib/wrapped/scrollbox.rb +40 -0
- data/lib/wrapped/separator.rb +24 -0
- data/lib/wrapped/splitbox.rb +114 -0
- data/lib/wrapped/stretchbox.rb +70 -0
- data/lib/wrapped/submenu.rb +58 -0
- data/lib/wrapped/tabs.rb +223 -0
- data/lib/wrapped/text.rb +382 -0
- data/lib/wrapped/timer.rb +82 -0
- data/lib/wrapped/toggle.rb +150 -0
- data/lib/wrapped/tree.rb +612 -0
- data/lib/wrapped/val.rb +162 -0
- data/lib/wrapped/vbox.rb +93 -0
- data/lib/wrapped/widget.rb +282 -0
- data/lib/wrapped/zbox.rb +80 -0
- metadata +131 -0
|
@@ -0,0 +1,698 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A canvas is a working area for the application. The API documentation
|
|
4
|
+
# can only hint at the use of this control. For more information see
|
|
5
|
+
# Tecgraf's documentation on the
|
|
6
|
+
# {Canvas}[https://www.tecgraf.puc-rio.br/iup/en/elem/iupcanvas.html] and
|
|
7
|
+
# on the {CD graphics library}[https://www.tecgraf.puc-rio.br/cd/], from
|
|
8
|
+
# which many of the drawing commands and primitives are taken,
|
|
9
|
+
# documented under {CD drawing}[#CD+drawing].
|
|
10
|
+
#
|
|
11
|
+
# === Example
|
|
12
|
+
#
|
|
13
|
+
# In the following example, notice how the canvas is placed
|
|
14
|
+
# in a dialog, which is mapped, and then #init is called on the
|
|
15
|
+
# canvas before the dialog is shown.
|
|
16
|
+
#
|
|
17
|
+
# class MyCanvas < Iup::Canvas
|
|
18
|
+
# def initialize
|
|
19
|
+
# super()
|
|
20
|
+
#
|
|
21
|
+
# self.scrollbar = 'yes' # explicit receivers are needed in subclass
|
|
22
|
+
# self.xmax = 599
|
|
23
|
+
# self.ymax = 399
|
|
24
|
+
#
|
|
25
|
+
# self.scroll_cb = ->(op, posx, posy){ # redraw on scroll
|
|
26
|
+
# redraw(posx, posy)
|
|
27
|
+
# Iup::DEFAULT
|
|
28
|
+
# }
|
|
29
|
+
#
|
|
30
|
+
# self.resize_cb = ->(w, h){ # redraw on resize
|
|
31
|
+
# self.dx = w
|
|
32
|
+
# self.dy = h
|
|
33
|
+
# activate # redraws the canvas
|
|
34
|
+
# Iup::DEFAULT
|
|
35
|
+
# }
|
|
36
|
+
#
|
|
37
|
+
# self.action = ->(posx, posy){ # called to redraw canvas
|
|
38
|
+
# redraw(posx, posy)
|
|
39
|
+
# }
|
|
40
|
+
# end
|
|
41
|
+
#
|
|
42
|
+
# def redraw(posx, posy) # the redraw logic, uses some CD commands
|
|
43
|
+
# iposx = posx.to_i
|
|
44
|
+
# iposy = posy.to_i
|
|
45
|
+
# # invert scroll reference (YMAX-DY - POSY)
|
|
46
|
+
# iposy = 399-dy - iposy
|
|
47
|
+
#
|
|
48
|
+
# clear
|
|
49
|
+
# self.foreground = Iup::CD_RED
|
|
50
|
+
# line(0-iposx, 0-iposy, 599-iposx, 399-iposy)
|
|
51
|
+
# line(0-iposx, 399-iposy, 599-iposx, 0-iposy)
|
|
52
|
+
#
|
|
53
|
+
# Iup::DEFAULT
|
|
54
|
+
# end
|
|
55
|
+
# end
|
|
56
|
+
#
|
|
57
|
+
# Iup.mainloop do
|
|
58
|
+
# canvas = MyCanvas.new do |c| # 1. make the canvas
|
|
59
|
+
# c.rastersize = '300x200'
|
|
60
|
+
# end
|
|
61
|
+
#
|
|
62
|
+
# dialog = Iup::Dialog.new(canvas) do |d| # 2. put it in a dialog
|
|
63
|
+
# d.title = 'Scrollbar Test'
|
|
64
|
+
# end.map # 3. map the dialog
|
|
65
|
+
#
|
|
66
|
+
# canvas.init # 4. init the canvas
|
|
67
|
+
# canvas.rastersize = nil # release the minimum limitation
|
|
68
|
+
#
|
|
69
|
+
# dialog.show # 5. show the dialog
|
|
70
|
+
# end
|
|
71
|
+
#
|
|
72
|
+
# Also see BackgroundBox.
|
|
73
|
+
#
|
|
74
|
+
class Canvas < Iup::Widget
|
|
75
|
+
include DragDropAttributes
|
|
76
|
+
include ScrollBarAttributes
|
|
77
|
+
|
|
78
|
+
# Creates a new instance.
|
|
79
|
+
# If a block is given, the new instance is yielded to it.
|
|
80
|
+
# * +handle+ - an optional Canvas handle.
|
|
81
|
+
def initialize(handle = IupLib.IupCanvas(''))
|
|
82
|
+
@handle = handle
|
|
83
|
+
|
|
84
|
+
# run any provided block on instance, to set up further attributes
|
|
85
|
+
yield self if block_given?
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# :category: CD drawing
|
|
89
|
+
# This must be called after the widget is mapped, to create and
|
|
90
|
+
# setup the canvas.
|
|
91
|
+
def init
|
|
92
|
+
@canvas = CdLib.cdCreateCanvas(CdLib.cdContextIup, @handle)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# -- attributes
|
|
96
|
+
|
|
97
|
+
##
|
|
98
|
+
# :attr: border
|
|
99
|
+
# Sets border around canvas, values 'yes' / 'no'.
|
|
100
|
+
define_attribute :border
|
|
101
|
+
|
|
102
|
+
##
|
|
103
|
+
# :attr: canfocus
|
|
104
|
+
# Enables the control to gain focus. Values 'yes' / 'no'.
|
|
105
|
+
define_attribute :canfocus
|
|
106
|
+
|
|
107
|
+
##
|
|
108
|
+
# :attr: cursor
|
|
109
|
+
# Defines the mouse shape / cursor for the canvas.
|
|
110
|
+
# Available cursors are shown in the
|
|
111
|
+
# {Tecgraf documentation}[http://www.tecgraf.puc-rio.br/iup/en/attrib/iup_cursor.html].
|
|
112
|
+
define_attribute :cursor
|
|
113
|
+
|
|
114
|
+
##
|
|
115
|
+
# :attr: drawsize
|
|
116
|
+
# Size of the drawing area in pixels, as "widthxheight".
|
|
117
|
+
define_attribute :drawsize
|
|
118
|
+
|
|
119
|
+
##
|
|
120
|
+
# :attr: expand
|
|
121
|
+
# Allows canvas to fill available space in indicated direction.
|
|
122
|
+
# Values 'no' / 'horizontal' / 'vertical' / 'yes'.
|
|
123
|
+
define_attribute :expand
|
|
124
|
+
|
|
125
|
+
##
|
|
126
|
+
# :attr: padding
|
|
127
|
+
# Margin in x and y directions, value as "mxn".
|
|
128
|
+
define_attribute :padding
|
|
129
|
+
|
|
130
|
+
##
|
|
131
|
+
# :attr_reader: position
|
|
132
|
+
# returns position in pixels within client window as "x,y".
|
|
133
|
+
define_reader :position
|
|
134
|
+
|
|
135
|
+
##
|
|
136
|
+
# :attr: rastersize
|
|
137
|
+
# Size of the canvas, in pixels, value as "widthxheight".
|
|
138
|
+
define_attribute :rastersize
|
|
139
|
+
|
|
140
|
+
##
|
|
141
|
+
# :attr_reader: screenposition
|
|
142
|
+
# returns position in pixels on screen
|
|
143
|
+
define_reader :screenposition
|
|
144
|
+
|
|
145
|
+
##
|
|
146
|
+
# :attr: tip
|
|
147
|
+
# Tooltip string.
|
|
148
|
+
define_attribute :tip
|
|
149
|
+
|
|
150
|
+
# redraws the underlying canvas.
|
|
151
|
+
def redraw
|
|
152
|
+
IupLib.IupRedraw @handle
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# -- CD method calls
|
|
156
|
+
|
|
157
|
+
# :section: CD drawing
|
|
158
|
+
|
|
159
|
+
# --- initialisation
|
|
160
|
+
|
|
161
|
+
# call when canvas no longer needed.
|
|
162
|
+
def kill
|
|
163
|
+
CdLib.cdKillCanvas @canvas
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# call to activate canvas.
|
|
167
|
+
# (Not usually needed - depends on driver.)
|
|
168
|
+
def activate
|
|
169
|
+
CdLib.cdCanvasActivate @canvas
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# call to deactivate canvas.
|
|
173
|
+
# (Not usually needed - depends on driver.)
|
|
174
|
+
def deactivate
|
|
175
|
+
CdLib.cdCanvasDeactivate @canvas
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Used to set coordinates of a viewport (the canvas coordinates).
|
|
179
|
+
def viewport x1, y1, x2, y2
|
|
180
|
+
CdLib.wdCanvasViewport @canvas, x1, y1, x2, y2
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# Used to set coordinates of a window (the world coordinates).
|
|
184
|
+
def window x1, y1, x2, y2
|
|
185
|
+
CdLib.wdCanvasWindow @canvas, x1, y1, x2, y2
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# --- general attributes
|
|
189
|
+
|
|
190
|
+
##
|
|
191
|
+
# :attr: foreground
|
|
192
|
+
# Accesses the foreground color.
|
|
193
|
+
#
|
|
194
|
+
# Color may be one of:
|
|
195
|
+
# * string, in form "r g b"
|
|
196
|
+
# * color constant, e.g. CD_BLACK, as listed in {CD colors}[../Iup.html#CD+colors]
|
|
197
|
+
|
|
198
|
+
#--
|
|
199
|
+
def foreground
|
|
200
|
+
CdLib.cdCanvasForeground(@canvas, Iup::CD_QUERY)
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def foreground= color # :nodoc:
|
|
204
|
+
case color
|
|
205
|
+
when String # assume in form 'RR GG BB'
|
|
206
|
+
r, g, b = color.split(' ').collect(&:to_i)
|
|
207
|
+
CdLib.cdCanvasForeground(@canvas, CdLib.cdEncodeColor(r, g, b))
|
|
208
|
+
else
|
|
209
|
+
CdLib.cdCanvasForeground(@canvas, color)
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
##
|
|
214
|
+
# :category: CD drawing
|
|
215
|
+
# :attr: background
|
|
216
|
+
# Accesses the background color.
|
|
217
|
+
#
|
|
218
|
+
# Color may be one of:
|
|
219
|
+
# * string, in form "r g b"
|
|
220
|
+
# * color constant, e.g. CD_BLACK, as listed in {CD colors}[../Iup.html#CD+colors]
|
|
221
|
+
|
|
222
|
+
# --
|
|
223
|
+
def background
|
|
224
|
+
CdLib.cdCanvasBackground(@canvas, Iup::CD_QUERY)
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def background= color # :nodoc:
|
|
228
|
+
case color
|
|
229
|
+
when String # assume in form 'RR GG BB'
|
|
230
|
+
r, g, b = color.split(' ').collect(&:to_i)
|
|
231
|
+
CdLib.cdCanvasBackground(@canvas, CdLib.cdEncodeColor(r, g, b))
|
|
232
|
+
else
|
|
233
|
+
CdLib.cdCanvasBackground(@canvas, color)
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
##
|
|
238
|
+
# :attr: writemode
|
|
239
|
+
# Accesses. the writing mode for all primitives.
|
|
240
|
+
# See {CD write mode}[../Iup.html#CD+write+mode] for a list of available values.
|
|
241
|
+
|
|
242
|
+
# --
|
|
243
|
+
def writemode
|
|
244
|
+
CdLib.cdCanvasWriteMode(@canvas, Iup::CD_QUERY)
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
def writemode= mode # :nodoc:
|
|
248
|
+
CdLib.cdCanvasWriteMode(@canvas, mode)
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
# --- control
|
|
252
|
+
|
|
253
|
+
# Clears the canvas.
|
|
254
|
+
def clear
|
|
255
|
+
CdLib.cdCanvasClear @canvas
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
# --- begin/end blocks
|
|
260
|
+
|
|
261
|
+
# Begin the definition of a sequence of vertices to define a polygon.
|
|
262
|
+
# See {CD polygon mode}[../Iup.html#CD+polygon+mode] for polygon mode
|
|
263
|
+
# values.
|
|
264
|
+
#
|
|
265
|
+
# Filled polygons are defined using #begin_block, multiple calls to
|
|
266
|
+
# #vertex, and ended with #end_block.
|
|
267
|
+
def begin_block mode
|
|
268
|
+
CdLib.cdCanvasBegin @canvas, mode
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
# Specify a vertex at position (x, y).
|
|
272
|
+
# See #begin_block.
|
|
273
|
+
def vertex x, y
|
|
274
|
+
CdLib.cdCanvasVertex @canvas, x, y
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
# End the definition of a sequence of vertices.
|
|
278
|
+
# See #begin_block.
|
|
279
|
+
def end_block
|
|
280
|
+
CdLib.cdCanvasEnd @canvas
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
# Specify action for next point on path.
|
|
284
|
+
# See {CD path action}[../Iup.html#CD+path+action] for path actions.
|
|
285
|
+
def pathset action
|
|
286
|
+
CdLib.cdCanvasPathSet @canvas, action
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
# --- marks
|
|
290
|
+
|
|
291
|
+
# Configures pixel (x, y) with color.
|
|
292
|
+
def pixel x, y, color
|
|
293
|
+
CdLib.cdCanvasPixel @canvas, x, y, color
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
# Draws a mark at position (x, y).
|
|
297
|
+
def mark x, y
|
|
298
|
+
CdLib.cdCanvasMark @canvas, x, y
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
##
|
|
302
|
+
# :attr: marktype
|
|
303
|
+
# Accesses the marktype to display.
|
|
304
|
+
# See {CD mark type}[../Iup.html#CD+mark+type] for available marktype values.
|
|
305
|
+
|
|
306
|
+
# --
|
|
307
|
+
def marktype
|
|
308
|
+
CdLib.cdCanvasMarkType(@canvas, Iup::CD_QUERY)
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
def marktype= type # :nodoc:
|
|
312
|
+
CdLib.cdCanvasMarkType(@canvas, type)
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
##
|
|
316
|
+
# :attr: marksize
|
|
317
|
+
# Accesses the mark size, given in pixels. Must be >= 1, default is 10.
|
|
318
|
+
|
|
319
|
+
# --
|
|
320
|
+
def marksize
|
|
321
|
+
CdLib.cdCanvasMarkSize(@canvas, Iup::CD_QUERY)
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
def marksize= size # :nodoc:
|
|
325
|
+
CdLib.cdCanvasMarkSize(@canvas, size)
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
# --- lines
|
|
329
|
+
|
|
330
|
+
# Draws a line from (x1, y1) to (x2, y2).
|
|
331
|
+
def line x1, y1, x2, y2
|
|
332
|
+
CdLib.cdCanvasLine @canvas, x1, y1, x2, y2
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
# Draws a rectangle bounding (xmin, ymin) to (xmax, ymax).
|
|
336
|
+
def rectangle xmin, xmax, ymin, ymax
|
|
337
|
+
CdLib.cdCanvasRect @canvas, xmin, xmax, ymin, ymax
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
# Draws an arc of an ellipse - a pie-shaped slice.
|
|
341
|
+
# Angles are in degrees, counterclockwise.
|
|
342
|
+
def arc xc, yc, w, h, angle1, angle2
|
|
343
|
+
CdLib.cdCanvasArc @canvas, xc, yc, w, h, angle1, angle2
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
##
|
|
347
|
+
# :attr: linestyle
|
|
348
|
+
# Accesses linestyle value.
|
|
349
|
+
# See {CD line style}[../Iup.html#CD+line+style] for available linestyle values.
|
|
350
|
+
|
|
351
|
+
# --
|
|
352
|
+
def linestyle
|
|
353
|
+
CdLib.cdCanvasLineStyle(@canvas, Iup::CD_QUERY)
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
def linestyle= style # :nodoc:
|
|
357
|
+
CdLib.cdCanvasLineStyle(@canvas, style)
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
##
|
|
361
|
+
# :attr: linewidth
|
|
362
|
+
# Accesses linewidth, in pixels.
|
|
363
|
+
|
|
364
|
+
# --
|
|
365
|
+
def linewidth
|
|
366
|
+
CdLib.cdCanvasLineWidth(@canvas, Iup::CD_QUERY)
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
def linewidth= width # :nodoc:
|
|
370
|
+
CdLib.cdCanvasLineWidth(@canvas, width)
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
##
|
|
374
|
+
# :attr: linejoin
|
|
375
|
+
# Accesses linejoin value.
|
|
376
|
+
# See {CD line join}[../Iup.html#CD+line+join] for available linejoin values.
|
|
377
|
+
|
|
378
|
+
# --
|
|
379
|
+
def linejoin
|
|
380
|
+
CdLib.cdCanvasLineJoin(@canvas, Iup::CD_QUERY)
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
def linejoin= style # :nodoc:
|
|
384
|
+
CdLib.cdCanvasLineJoin(@canvas, style)
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
##
|
|
388
|
+
# :attr: linecap
|
|
389
|
+
# Accesses linecap value.
|
|
390
|
+
# See {CD line cap}[../Iup.html#CD+line+cap] for available linecap values.
|
|
391
|
+
|
|
392
|
+
# --
|
|
393
|
+
def linecap
|
|
394
|
+
CdLib.cdCanvasLineCap(@canvas, Iup::CD_QUERY)
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
def linecap= style # :nodoc:
|
|
398
|
+
CdLib.cdCanvasLineCap(@canvas, style)
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
# -- filled areas
|
|
402
|
+
|
|
403
|
+
# Fills a rectangle, according to current interior style.
|
|
404
|
+
def box xmin, xmax, ymin, ymax
|
|
405
|
+
CdLib.cdCanvasBox @canvas, xmin, xmax, ymin, ymax
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
# Fills a sector, according to current interior style.
|
|
409
|
+
# A sector is an arc of an ellipse - a pie-shaped slice.
|
|
410
|
+
# Angles are in degrees, counterclockwise.
|
|
411
|
+
def sector xc, yc, w, h, angle1, angle2
|
|
412
|
+
CdLib.cdCanvasSector @canvas, xc, yc, w, h, angle1, angle2
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
# Fills a chord, according to current interior style.
|
|
416
|
+
# A chord is an arc of an ellipse - with the arc points connected.
|
|
417
|
+
# Angles are in degrees, counterclockwise.
|
|
418
|
+
def chord xc, yc, w, h, angle1, angle2
|
|
419
|
+
CdLib.cdCanvasChord @canvas, xc, yc, w, h, angle1, angle2
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
##
|
|
423
|
+
# :attr: backopacity
|
|
424
|
+
# Accesses backopacity value.
|
|
425
|
+
# See {CD background opacity mode}[../Iup.html#CD+background+opacity+mode]
|
|
426
|
+
# for background opacity mode values.
|
|
427
|
+
|
|
428
|
+
# --
|
|
429
|
+
def backopacity
|
|
430
|
+
CdLib.cdCanvasBackOpacity(@canvas, Iup::CD_QUERY)
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
def backopacity= opacity # :nodoc:
|
|
434
|
+
CdLib.cdCanvasBackOpacity(@canvas, opacity)
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
##
|
|
438
|
+
# :attr: fillmode
|
|
439
|
+
# Accesses fillmode value.
|
|
440
|
+
# See {CD fill mode}[../Iup.html#CD+fill+mode] for fill mode values.
|
|
441
|
+
|
|
442
|
+
# --
|
|
443
|
+
def fillmode
|
|
444
|
+
CdLib.cdCanvasFillMode(@canvas, Iup::CD_QUERY)
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
def fillmode= mode # :nodoc:
|
|
448
|
+
CdLib.cdCanvasFillMode(@canvas, mode)
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
##
|
|
452
|
+
# :attr: interiorstyle
|
|
453
|
+
# Accesses interiorstyle value.
|
|
454
|
+
# See {CD interior style}[../Iup.html#CD+interior+style] for interior style values.
|
|
455
|
+
|
|
456
|
+
# --
|
|
457
|
+
def interiorstyle
|
|
458
|
+
CdLib.cdCanvasInteriorStyle(@canvas, Iup::CD_QUERY)
|
|
459
|
+
end
|
|
460
|
+
|
|
461
|
+
def interiorstyle= style # :nodoc:
|
|
462
|
+
CdLib.cdCanvasInteriorStyle(@canvas, style)
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
##
|
|
466
|
+
# :attr: hatch
|
|
467
|
+
# Accesses hatch value.
|
|
468
|
+
# See {CD hatch type}[../Iup.html#CD+hatch+type] for hatch style values.
|
|
469
|
+
|
|
470
|
+
# --
|
|
471
|
+
def hatch
|
|
472
|
+
CdLib.cdCanvasHatch(@canvas, Iup::CD_QUERY)
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
def hatch= style # :nodoc:
|
|
476
|
+
CdLib.cdCanvasHatch(@canvas, style)
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
# Defines a stipple pattern of a specified size:
|
|
480
|
+
# * +w+ - width of stipple pattern
|
|
481
|
+
# * +h+ - height of stipple pattern
|
|
482
|
+
# * +fgbg+ - a string representing the stipple pattern in binary
|
|
483
|
+
def stipple w, h, fgbg
|
|
484
|
+
CdLib.cdCanvasStipple @canvas, w, h, fgbg
|
|
485
|
+
end
|
|
486
|
+
|
|
487
|
+
# -- text
|
|
488
|
+
|
|
489
|
+
# Draw text str at position (x, y). Expects an ANSI-string.
|
|
490
|
+
def text x, y, str
|
|
491
|
+
CdLib.cdCanvasText @canvas, x, y, str
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
# Sets text font.
|
|
495
|
+
# * +typeface+ - 'Courier', 'Helvetica', 'Times' built-in, but any known font can be used
|
|
496
|
+
# * +style+ - see {CD text style}[../Iup.html#CD+text+style]
|
|
497
|
+
# * +size+ - the font height, default is 12.
|
|
498
|
+
def font typeface, style, size
|
|
499
|
+
CdLib.cdCanvasFont @canvas, typeface, style, size
|
|
500
|
+
end
|
|
501
|
+
|
|
502
|
+
##
|
|
503
|
+
# :attr_writer: nativefont
|
|
504
|
+
# Sets the current font.
|
|
505
|
+
|
|
506
|
+
# --
|
|
507
|
+
def nativefont= font
|
|
508
|
+
CdLib.cdCanvasNativefont(@canvas, font)
|
|
509
|
+
end
|
|
510
|
+
|
|
511
|
+
##
|
|
512
|
+
# :attr: textalignment
|
|
513
|
+
# Accesses the textalignment value.
|
|
514
|
+
# See {CD text alignment}[../Iup.html#CD+text+alignment].
|
|
515
|
+
|
|
516
|
+
# --
|
|
517
|
+
def textalignment
|
|
518
|
+
CdLib.cdCanvasTextAlignment(@canvas, Iup::CD_QUERY)
|
|
519
|
+
end
|
|
520
|
+
|
|
521
|
+
def textalignment= alignment # :nodoc:
|
|
522
|
+
CdLib.cdCanvasTextAlignment(@canvas, alignment)
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
##
|
|
526
|
+
# :attr: textorientation
|
|
527
|
+
# Accesses the textorientation value.
|
|
528
|
+
# The orientation is an angle in degrees to the horizontal.
|
|
529
|
+
|
|
530
|
+
# --
|
|
531
|
+
def textorientation
|
|
532
|
+
CdLib.cdCanvasTextOrientation(@canvas, Iup::CD_QUERY)
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
def textorientation= orientation # :nodoc:
|
|
536
|
+
CdLib.cdCanvasTextOrientation(@canvas, orientation)
|
|
537
|
+
end
|
|
538
|
+
|
|
539
|
+
# -- vector text
|
|
540
|
+
|
|
541
|
+
# Draws str as vector text at position (x, y).
|
|
542
|
+
# Call #vectortext_size to set the text size before calling this method.
|
|
543
|
+
def vectortext x, y, str
|
|
544
|
+
CdLib.cdCanvasVectorText @canvas, x, y, str
|
|
545
|
+
end
|
|
546
|
+
|
|
547
|
+
# Defines the text direction using two points: (x1, y1) and (x2, y2).
|
|
548
|
+
def vectortext_direction x1, y1, x2, y2
|
|
549
|
+
CdLib.cdCanvasVectorTextDirection @canvas, x1, y1, x2, y2
|
|
550
|
+
end
|
|
551
|
+
|
|
552
|
+
# Modifies font size so str fits within a box width x height in size.
|
|
553
|
+
def vectortext_size width, height, str
|
|
554
|
+
CdLib.cdCanvasVectorTextSize @canvas, width, height, str
|
|
555
|
+
end
|
|
556
|
+
|
|
557
|
+
##
|
|
558
|
+
# :attr: vectortext_charsize
|
|
559
|
+
# The font size.
|
|
560
|
+
|
|
561
|
+
# --
|
|
562
|
+
def vectortext_charsize
|
|
563
|
+
CdLib.cdCanvasVectorCharSize(@canvas, Iup::CD_QUERY)
|
|
564
|
+
end
|
|
565
|
+
|
|
566
|
+
def vectortext_charsize= size # :nodoc:
|
|
567
|
+
CdLib.cdCanvasVectorCharSize(@canvas, size)
|
|
568
|
+
end
|
|
569
|
+
|
|
570
|
+
# Directly modifies the font size.
|
|
571
|
+
def vectortext_fontsize size_x, size_y
|
|
572
|
+
CdLib.cdCanvasVectorFontSize @canvas, size_x, size_y
|
|
573
|
+
end
|
|
574
|
+
|
|
575
|
+
# Replaces current vector font with that loaded from given filename.
|
|
576
|
+
# Returns the font name, or null.
|
|
577
|
+
def vectortext_loadfont filename
|
|
578
|
+
CdLib.cdCanvasVectorFont @canvas, filename
|
|
579
|
+
end
|
|
580
|
+
|
|
581
|
+
# :section: Callbacks
|
|
582
|
+
|
|
583
|
+
##
|
|
584
|
+
# :attr_writer: action
|
|
585
|
+
# Callback called when the canvas needs to be redrawn.
|
|
586
|
+
# Callback must respond to +call+ and accepts 2 arguments: (posx, posy)
|
|
587
|
+
# * +posx+ - position of horizonal scrollbar thumb
|
|
588
|
+
# * +posy+ - position of vertical scrollbar thumb
|
|
589
|
+
#
|
|
590
|
+
# Typically redraws canvas: see {CD drawing}[#CD+drawing].
|
|
591
|
+
|
|
592
|
+
# --
|
|
593
|
+
def action= callback
|
|
594
|
+
unless callback.arity == 2
|
|
595
|
+
raise ArgumentError, 'action must take 2 arguments: (posx, posy)'
|
|
596
|
+
end
|
|
597
|
+
cb = Proc.new do |ih, posx, posy|
|
|
598
|
+
callback.call posx, posy
|
|
599
|
+
end
|
|
600
|
+
define_callback cb, 'ACTION', :ff_i
|
|
601
|
+
end
|
|
602
|
+
|
|
603
|
+
include ButtonCallback
|
|
604
|
+
|
|
605
|
+
##
|
|
606
|
+
# :attr_writer: focus_cb
|
|
607
|
+
# Callback called when the canvas gets or loses the keyboard focus.
|
|
608
|
+
# Callback must respond to +call+ and takes a single parameter: (focus)
|
|
609
|
+
# * +focus+ - non-zero if canvas gaining focus, else zero.
|
|
610
|
+
|
|
611
|
+
# --
|
|
612
|
+
def focus_cb= callback
|
|
613
|
+
unless callback.arity == 1
|
|
614
|
+
raise ArgumentError, 'focus_cb callback must take 1 argument, the focus'
|
|
615
|
+
end
|
|
616
|
+
cb = Proc.new do |ih, focus|
|
|
617
|
+
callback.call focus
|
|
618
|
+
end
|
|
619
|
+
define_callback cb, 'FOCUS_CB', :i_i
|
|
620
|
+
end
|
|
621
|
+
|
|
622
|
+
##
|
|
623
|
+
# :attr_writer: keypress_cb
|
|
624
|
+
# Callback called when a key is pressed or released.
|
|
625
|
+
# Callback must respond to +call+ and takes a 2-argument callback: (character, pressed).
|
|
626
|
+
# * +character+ - code for character pressed/released
|
|
627
|
+
# * +pressed+ - 1 if key is pressed, 0 if released
|
|
628
|
+
|
|
629
|
+
# --
|
|
630
|
+
def keypress_cb= callback
|
|
631
|
+
unless callback.arity == 2
|
|
632
|
+
raise ArgumentError, 'keypress_cb callback must take 2 arguments: (char, press)'
|
|
633
|
+
end
|
|
634
|
+
cb = Proc.new do |ih, char, press|
|
|
635
|
+
callback.call char, press
|
|
636
|
+
end
|
|
637
|
+
define_callback cb, 'KEYPRESS_CB', :ii_i
|
|
638
|
+
end
|
|
639
|
+
|
|
640
|
+
##
|
|
641
|
+
# :attr_writer: motion_cb
|
|
642
|
+
# Callback called when the mouse is moved.
|
|
643
|
+
# Callback must respond to +call+ and takes 3 arguments: (x, y, state)
|
|
644
|
+
# * +x+ - x position of mouse
|
|
645
|
+
# * +y+ - y position of mouse
|
|
646
|
+
# * +state+ - status of mouse buttons and certain keyboard keys at the moment the event was generated.
|
|
647
|
+
|
|
648
|
+
#--
|
|
649
|
+
def motion_cb= callback
|
|
650
|
+
unless callback.arity == 3
|
|
651
|
+
raise ArgumentError, 'motion_cb callback must take 3 arguments: (x, y, state)'
|
|
652
|
+
end
|
|
653
|
+
cb = Proc.new do |ih, x, y, state|
|
|
654
|
+
callback.call x, y, state
|
|
655
|
+
end
|
|
656
|
+
define_callback cb, 'MOTION_CB', :iis_i
|
|
657
|
+
end
|
|
658
|
+
|
|
659
|
+
##
|
|
660
|
+
# :attr_writer: resize_cb
|
|
661
|
+
# Callback called when the canvas size is changed.
|
|
662
|
+
# Callback must respond to +call+ and takes 2 arguments: (width, height).
|
|
663
|
+
# * +width+ -internal width of canvas (client width)
|
|
664
|
+
# * +height+ - internal height of canvas (client height)
|
|
665
|
+
|
|
666
|
+
# --
|
|
667
|
+
def resize_cb= callback # :nodoc:
|
|
668
|
+
unless callback.arity == 2
|
|
669
|
+
raise ArgumentError, 'resize_cb callback must take 2 arguments: (width, height)'
|
|
670
|
+
end
|
|
671
|
+
cb = Proc.new do |ih, width, height|
|
|
672
|
+
callback.call width, height
|
|
673
|
+
end
|
|
674
|
+
define_callback cb, 'RESIZE_CB', :ii_i
|
|
675
|
+
end
|
|
676
|
+
|
|
677
|
+
##
|
|
678
|
+
# :attr_writer: wheel_cb
|
|
679
|
+
# Callback called when the mouse wheel is rotated.
|
|
680
|
+
# Callback must respond to +call+ and accepts a 4-argument callback: (delta, x, y, status).
|
|
681
|
+
# * +delta+ - the amount the wheel was rotated in notches.
|
|
682
|
+
# * +x+ - x position in the canvas where the event has occurred, in pixels.
|
|
683
|
+
# * +y+ - y position in the canvas where the event has occurred, in pixels.
|
|
684
|
+
# * +status+ - status of mouse buttons and certain keyboard keys at the moment the event was generated.
|
|
685
|
+
|
|
686
|
+
# --
|
|
687
|
+
def wheel_cb= callback
|
|
688
|
+
unless callback.arity == 4
|
|
689
|
+
raise ArgumentError, 'wheel_cb callback must take 4 arguments: (delta, x, y, status)'
|
|
690
|
+
end
|
|
691
|
+
cb = Proc.new do |ih, delta, x, y, status_ptr|
|
|
692
|
+
status = FFI::Pointer.new(status_ptr).read_string
|
|
693
|
+
callback.call delta, x, y, status
|
|
694
|
+
end
|
|
695
|
+
define_callback cb, 'WHEEL_CB', :fiis_i
|
|
696
|
+
end
|
|
697
|
+
end
|
|
698
|
+
end
|