iup-ffi 0.12.0 → 0.13.0

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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/{LICENCE.txt → LICENCE.md} +1 -1
  3. data/README.md +139 -0
  4. data/lib/iup-ffi-plain.rb +43 -1
  5. data/lib/iup-ffi.rb +2 -8
  6. data/lib/plain/iupcdlib.rb +63 -12
  7. data/lib/plain/iupcontrolslib.rb +13 -9
  8. data/lib/plain/iupimglib.rb +10 -9
  9. data/lib/plain/iupimlib.rb +11 -9
  10. data/lib/plain/iuplib.rb +156 -11
  11. data/lib/plain/scintilla-lib.rb +11 -9
  12. data/lib/wrapped/attribute-builders.rb +40 -52
  13. data/lib/wrapped/attribute-reference.rb +7 -7
  14. data/lib/wrapped/background-box.rb +26 -22
  15. data/lib/wrapped/button.rb +107 -63
  16. data/lib/wrapped/callback-setter.rb +2 -2
  17. data/lib/wrapped/canvas.rb +410 -179
  18. data/lib/wrapped/colorbar.rb +212 -0
  19. data/lib/wrapped/colordialog.rb +121 -0
  20. data/lib/wrapped/common-attributes.rb +14 -44
  21. data/lib/wrapped/constants.rb +135 -584
  22. data/lib/wrapped/dial.rb +72 -30
  23. data/lib/wrapped/dialog.rb +203 -70
  24. data/lib/wrapped/drag-drop-attributes.rb +48 -7
  25. data/lib/wrapped/dynamic-fill-methods.rb +6 -11
  26. data/lib/wrapped/expander.rb +94 -31
  27. data/lib/wrapped/filedialog.rb +124 -49
  28. data/lib/wrapped/fill.rb +15 -12
  29. data/lib/wrapped/fontdialog.rb +47 -18
  30. data/lib/wrapped/frame.rb +48 -25
  31. data/lib/wrapped/gridbox.rb +147 -53
  32. data/lib/wrapped/hbox.rb +66 -25
  33. data/lib/wrapped/image-attributes.rb +40 -9
  34. data/lib/wrapped/image.rb +126 -66
  35. data/lib/wrapped/iup-global.rb +13 -18
  36. data/lib/wrapped/label.rb +78 -66
  37. data/lib/wrapped/link.rb +33 -38
  38. data/lib/wrapped/list.rb +376 -162
  39. data/lib/wrapped/matrix.rb +419 -77
  40. data/lib/wrapped/menu.rb +72 -31
  41. data/lib/wrapped/menuitem.rb +101 -31
  42. data/lib/wrapped/messagedialog.rb +97 -21
  43. data/lib/wrapped/progressbar.rb +65 -22
  44. data/lib/wrapped/progressdialog.rb +52 -78
  45. data/lib/wrapped/radio.rb +52 -21
  46. data/lib/wrapped/scintilla.rb +942 -107
  47. data/lib/wrapped/scrollbar-attributes.rb +122 -85
  48. data/lib/wrapped/scrollbox.rb +24 -131
  49. data/lib/wrapped/separator.rb +15 -2
  50. data/lib/wrapped/splitbox.rb +91 -25
  51. data/lib/wrapped/stretchbox.rb +51 -23
  52. data/lib/wrapped/submenu.rb +40 -16
  53. data/lib/wrapped/tabs.rb +135 -61
  54. data/lib/wrapped/text.rb +274 -117
  55. data/lib/wrapped/timer.rb +47 -7
  56. data/lib/wrapped/toggle.rb +105 -53
  57. data/lib/wrapped/tree.rb +353 -206
  58. data/lib/wrapped/val.rb +97 -32
  59. data/lib/wrapped/vbox.rb +68 -26
  60. data/lib/wrapped/widget.rb +169 -24
  61. data/lib/wrapped/zbox.rb +58 -32
  62. metadata +12 -13
  63. data/README.rdoc +0 -348
  64. data/lib/wrapped/colourbar.rb +0 -94
  65. data/lib/wrapped/colourdialog.rb +0 -63
  66. data/lib/wrapped/dialogs.rb +0 -106
  67. data/lib/wrapped/internal-drag-drop-attributes.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4da0308e74093ebf8c476f7f3583ff762013eafe1be412894daf037c507829fe
4
- data.tar.gz: 1d20c7fb3d37676ce2a375dbb6e7a29582cf97283cd0d31d1338dccc4bafb6ad
3
+ metadata.gz: ea00447c91daa75cf96893d3220254365ed3fae24436ab053e85e62844ebe7e3
4
+ data.tar.gz: 9f4970854bba59a5927d7725cababd42ea76b5af9d0c00b95b4ee3fb3d21326d
5
5
  SHA512:
6
- metadata.gz: febbb65f5bcdf7897ac7b7e504337ae8188e907b5242f5c8f95f9283318736d703be6806fe5519242e32107a17413c428b9cfa864bb513c41ae5f313d39c4c7e
7
- data.tar.gz: cef7c7426dc4af9b20a23e3e27e1f8687264044459c5fd4a73128308a816771856e36c63188c1fcf95549913f22a2987af376e89938f1320c7c8a97ea4238bbd
6
+ metadata.gz: 0054d4678c2605c8a850cae83d6f3a14782984b4d0a79901567d9d018cf17d76f6508bf3f9041dcb8db4d5753bdbdb57ee812f8d62b8b6db848f067c048d5726
7
+ data.tar.gz: df029fefd4c1ac476b234d35b137cb533f1e3f0bd72605da9788f1632c30952b5451160725e08bec34cf51b7d228e52390396abb151600e32fc6a9441db8ad4b
@@ -1,4 +1,4 @@
1
- The MIT Licence (MIT)
1
+ # The MIT Licence (MIT)
2
2
 
3
3
  Copyright (c) 2014-26, Peter Lane.
4
4
 
data/README.md ADDED
@@ -0,0 +1,139 @@
1
+ # iup-ffi
2
+
3
+ FFI binding for Ruby to [Tecgraf's IUP](http://www.tecgraf.puc-rio.br/iup/)
4
+ portable user interface toolkit; IUP is a multi-platform toolkit for building
5
+ graphical user interfaces. The library provides both a low-level binding to
6
+ the C library calls, and a high-level wrapping of most widgets to give a more
7
+ natural Ruby syntax.
8
+
9
+ This library is available as a [rubygem](https://rubygems.org/gems/iup-ffi) or
10
+ in [source](https://codeberg.org/peterlane/iup-ffi) format.
11
+
12
+ [Tecgraf's IUP](http://www.tecgraf.puc-rio.br/iup/) documentation (Version
13
+ 3.32) should be read along with the API documentation for iup-ffi. A number of
14
+ examples can be found in the source, or downloaded with the latest tagged
15
+ [version](https://codeberg.org/peterlane/iup-ffi/tags).
16
+
17
+ ## Description
18
+
19
+ The module Iup provides a Ruby-flavoured syntax for creating a GUI, wrapping
20
+ each IUP component in a Ruby class with suitable mutators/accessors for the
21
+ attributes and associated methods. For example:
22
+
23
+ ```
24
+ require "iup-ffi"
25
+
26
+ Iup.mainloop do
27
+ btn = Iup::Button.new("click me", ->{ puts "clicked" }) do |b|
28
+ b.font = "Times, Bold 18"
29
+ end
30
+ puts "Button font is: ", btn.font
31
+
32
+ Iup::Dialog.new(btn) do |d|
33
+ d.title = "Example program"
34
+ end.show
35
+ end
36
+ ```
37
+
38
+ For direct access to the shared libraries, the bound functions for IUP, CD and
39
+ IM are available in separate modules (names ending in "Lib"). These low-level
40
+ functions provide a direct mapping to the C API of IUP. This can be useful
41
+ when converting code from other sources or when something is missing from the
42
+ wrapper. For example, the C program
43
+ (https://www.tecgraf.puc-rio.br/iup/examples/C/message.c):
44
+
45
+ ```
46
+ /* IupMessage Example */
47
+
48
+ #include <stdlib.h>
49
+ #include <stdio.h>
50
+
51
+ /* IUP libraries include */
52
+ #include <iup.h>
53
+
54
+ /* Main program */
55
+ int main(int argc, char **argv)
56
+ {
57
+ /* Initializes IUP */
58
+ IupOpen(&argc, &argv);
59
+
60
+ /* Executes IupMessage */
61
+ IupMessage("IupMessage Example", "Press the button");
62
+
63
+ /* Finishes IUP */
64
+ IupClose ();
65
+
66
+ /* Program finished successfully */
67
+ return EXIT_SUCCESS;
68
+
69
+ }
70
+ ```
71
+
72
+ is translated into Ruby as:
73
+
74
+ ```
75
+ require "iup-ffi" # or "iup-ffi-plain" for just the low-level bindings
76
+
77
+ IupLib.IupOpen(0, nil)
78
+ IupLib.IupMessage("IupMessage Example", "Press the button")
79
+ IupLib.IupClose
80
+ ```
81
+
82
+ ## Supported Widgets
83
+
84
+ (As IUP is a large library and continues to be expanded, the list of supported
85
+ widgets and their properties is at best partial.)
86
+
87
+ Top-level containers:
88
+
89
+ * Iup::ColorDialog, Iup::Dialog, Iup::FileDialog,
90
+ Iup::FontDialog, Iup::MessageDialog, Iup::ProgressDialog
91
+
92
+ Layout containers to arrange child widgets:
93
+
94
+ * Iup::Fill, Iup::GridBox, Iup::HBox, Iup::VBox, Iup::ZBox, Iup::ScrollBox, Iup::SplitBox, Iup::StretchBox,
95
+
96
+ Grouping containers to organise related controls:
97
+
98
+ * Iup::BackgroundBox, Iup::Expander, Iup::Frame, Iup::Radio, Iup::Tabs
99
+
100
+ Information controls to display data:
101
+
102
+ * Iup::Image, Iup::ImageRGB, Iup::ImageRGBA, Iup::Label, Iup::Link, Iup::ProgressBar
103
+
104
+ Interactive controls:
105
+
106
+ * Iup::Button, Iup::ColorBar, Iup::Dial, Iup::List, Iup::Text, Iup::Toggle, Iup::Tree, Iup::Val
107
+
108
+ Specialised/complex widgets:
109
+
110
+ * Iup::Canvas, Iup::Matrix, Iup::Scintilla
111
+
112
+ Non-visual controls and menus:
113
+
114
+ * Iup::Menu, Iup::MenuItem, Iup::Separator, Iup::SubMenu, Iup::Timer
115
+
116
+ ## Installation
117
+
118
+ Pre-built binaries are supported on Linux and Windows (x64) platforms:
119
+
120
+ ```
121
+ $ gem install iup-ffi
122
+ ```
123
+
124
+ * Windows gem does not include Iup::Scintilla.
125
+
126
+ From source, download the CD, IM and IUP shared libraries from
127
+ https://www.tecgraf.puc-rio.br/iup/en/download_tips.html into the appropriate
128
+ "lib/library" folder: Linux68_64 and Win64_dllw6 are used in the pre-built
129
+ binaries.
130
+
131
+ ## Support
132
+
133
+ File bugs at the [codeberg issues page](https://codeberg.org/peterlane/iup-ffi/issues), or send an email to `peterlane@gmx.com`.
134
+
135
+ ## Copyright/Licence
136
+
137
+ iup-ffi is copyright (c) 2014-26 Peter Lane, and released under the [MIT Licence](https://opensource.org/license/MIT).
138
+ Tecgraf IUP products are also released under the MIT licence: https://www.tecgraf.puc-rio.br/iup/en/copyright.html
139
+
data/lib/iup-ffi-plain.rb CHANGED
@@ -1,9 +1,51 @@
1
1
  # Provides the direct bindings through FFI to the IUP libraries.
2
2
 
3
+ require 'ffi'
4
+ require 'rbconfig'
5
+ require "securerandom"
6
+
7
+ module Iup
8
+ # :nodoc:
9
+ library_base = File.expand_path("../library", __FILE__)
10
+ IUP_LIBS = case RbConfig::CONFIG['host_os']
11
+ when /linux|cygwin/
12
+ library_path = File.join(library_base, "linux")
13
+ [
14
+ "gobject-2.0", "pango-1.0",
15
+ File.join(library_path, 'libcd.so'),
16
+ File.join(library_path, 'libim.so'),
17
+ File.join(library_path, "libiup.so"),
18
+ File.join(library_path, 'libiupcd.so'),
19
+ File.join(library_path, 'libiupcontrols.so'),
20
+ File.join(library_path, 'libiupim.so'),
21
+ File.join(library_path, 'libiupimglib.so'),
22
+ File.join(library_path, 'libiup_scintilla.so')
23
+ ]
24
+ when /mswin|mingw/
25
+ library_path = File.join(library_base, "windows")
26
+ [
27
+ File.join(library_path, "freetype6.dll"),
28
+ File.join(library_path, "zlib1.dll"),
29
+ File.join(library_path, 'cd.dll'),
30
+ File.join(library_path, 'im.dll'),
31
+ File.join(library_path, "iup.dll"),
32
+ File.join(library_path, 'iupcd.dll'),
33
+ File.join(library_path, 'iupcontrols.dll'),
34
+ File.join(library_path, 'iupim.dll'),
35
+ File.join(library_path, 'iupimglib.dll') #,
36
+ # File.join(library_path, 'iup_scintilla.dll')
37
+ ]
38
+ else
39
+ raise Exception,
40
+ 'iup libraries not found this platform',
41
+ RbConfig::CONFIG['host_os']
42
+ end
43
+ end
44
+
3
45
  require 'wrapped/constants'
4
46
  require 'plain/iuplib'
5
47
  require 'plain/iupcdlib'
6
48
  require 'plain/iupcontrolslib'
7
49
  require 'plain/iupimlib'
8
50
  require 'plain/iupimglib'
9
- require 'plain/scintilla-lib'
51
+ require 'plain/scintilla-lib' unless /mswin|mingw/ === RbConfig::CONFIG['host_os']
data/lib/iup-ffi.rb CHANGED
@@ -1,8 +1,5 @@
1
1
  # Requires files needed for wrapping the plain Iup libraries.
2
2
  #
3
- require 'ffi'
4
- require 'rbconfig'
5
-
6
3
  require 'iup-ffi-plain'
7
4
 
8
5
  # helper code
@@ -13,13 +10,10 @@ require 'wrapped/common-attributes'
13
10
  require 'wrapped/image-attributes'
14
11
  require 'wrapped/callback-setter'
15
12
  require 'wrapped/drag-drop-attributes'
16
- require 'wrapped/internal-drag-drop-attributes'
17
13
  require 'wrapped/scrollbar-attributes'
18
14
 
19
15
  # the wrapper classes themselves
20
16
  # -- core libraries
21
- require 'wrapped/dialogs'
22
-
23
17
  require 'wrapped/widget'
24
18
  require 'wrapped/button'
25
19
  require 'wrapped/canvas'
@@ -35,8 +29,8 @@ require 'wrapped/tree'
35
29
  require 'wrapped/val'
36
30
 
37
31
  # -- dialogs
38
- require 'wrapped/colourdialog'
39
32
  require 'wrapped/dialog'
33
+ require 'wrapped/colordialog'
40
34
  require 'wrapped/filedialog'
41
35
  require 'wrapped/fontdialog'
42
36
  require 'wrapped/messagedialog'
@@ -67,7 +61,7 @@ require 'wrapped/zbox'
67
61
  require 'wrapped/scintilla'
68
62
 
69
63
  # -- additional controls
70
- require 'wrapped/colourbar'
64
+ require 'wrapped/colorbar'
71
65
  require 'wrapped/dial'
72
66
  require 'wrapped/matrix'
73
67
 
@@ -1,20 +1,71 @@
1
- # Binding to the CD library
1
+ # Binding to the iupcd shared library: CD is a vector graphics
2
+ # toolkit.
3
+ # This module can be used to access features not available
4
+ # in Iup.
2
5
  #
6
+ # For reference, the following functions are bound:
7
+ #
8
+ # * cdContextIup, [], :pointer
9
+ # * cdCreateCanvas, [:pointer, :pointer], :pointer
10
+ # * cdKillCanvas, [:pointer], :void
11
+ # * cdCanvasActivate, [:pointer], :int
12
+ # * cdCanvasDeactivate, [:pointer], :void
13
+ # * cdUseContextPlus, [:int], :int
14
+ # * cdCanvasGetContext, [:pointer], :pointer
15
+ # * cdContextCaps, [:pointer], :int
16
+ # * cdContextType, [:pointer], :int
17
+ # * cdContextIsPlus, [:pointer], :int
18
+ # * cdCanvasSimulate, [:pointer, :int], :int
19
+ # * wdCanvasViewport, [:pointer, :int, :int, :int, :int], :void
20
+ # * wdCanvasWindow, [:pointer, :double, :double, :double, :double], :void
21
+ # * cdCanvasForeground, [:pointer, :long], :long
22
+ # * cdCanvasBackground, [:pointer, :long], :long
23
+ # * cdCanvasWriteMode, [:pointer, :int], :int
24
+ # * cdCanvasClear, [:pointer], :int
25
+ # * cdCanvasBegin, [:pointer, :int], :void
26
+ # * cdCanvasVertex, [:pointer, :int, :int], :void
27
+ # * cdCanvasEnd, [:pointer], :void
28
+ # * cdCanvasPathSet, [:pointer, :int], :void
29
+ # * cdCanvasPixel, [:pointer, :int, :int], :void
30
+ # * cdCanvasMark, [:pointer, :int, :int], :void
31
+ # * cdCanvasMarkType, [:pointer, :int], :int
32
+ # * cdCanvasMarkSize, [:pointer, :int], :int
33
+ # * cdCanvasLine, [:pointer, :int, :int, :int, :int], :void
34
+ # * cdCanvasRect, [:pointer, :int, :int, :int, :int], :void
35
+ # * cdCanvasArc, [:pointer, :int, :int, :int, :int, :double, :double], :void
36
+ # * cdCanvasLineStyle, [:pointer, :int], :int
37
+ # * cdCanvasLineWidth, [:pointer, :int], :int
38
+ # * cdCanvasLineJoin, [:pointer, :int], :int
39
+ # * cdCanvasLineCap, [:pointer, :int], :int
40
+ # * cdCanvasBox, [:pointer, :int, :int, :int, :int], :void
41
+ # * cdCanvasSector, [:pointer, :int, :int, :int, :int, :double, :double], :int
42
+ # * cdCanvasChord, [:pointer, :int, :int, :int, :int, :double, :double], :int
43
+ # * cdCanvasBackOpacity, [:pointer, :int], :int
44
+ # * cdCanvasFillMode, [:pointer, :int], :int
45
+ # * cdCanvasInteriorStyle, [:pointer, :int], :int
46
+ # * cdCanvasHatch, [:pointer, :int], :int
47
+ # * cdCanvasStipple, [:pointer, :int, :int, :string], :void
48
+ # * cdCanvasText, [:pointer, :int, :int, :string], :void
49
+ # * cdCanvasFont, [:pointer, :string, :int, :int], :void
50
+ # * cdCanvasNativeFont, [:pointer, :string], :string
51
+ # * cdCanvasTextAlignment, [:pointer, :int], :int
52
+ # * cdCanvasTextOrientation, [:pointer, :double], :double
53
+ # * cdCanvasVectorText, [:pointer, :int, :int, :string], :void
54
+ # * cdCanvasVectorTextDirection, [:pointer, :int, :int, :int, :int], :void
55
+ # * cdCanvasVectorTextSize, [:pointer, :int, :int, :string], :void
56
+ # * cdCanvasVectorCharSize, [:pointer, :int], :void
57
+ # * cdCanvasVectorFontSize, [:pointer, :double, :double], :void
58
+ # * cdCanvasVectorFont, [:pointer, :string], :string
59
+ # * cdEncodeColor, [:int, :int, :int], :long
60
+ #
3
61
  # TODO:
4
62
  # - images
5
63
  # - various get functions
6
64
  #
7
- module CdLib # :nodoc:
65
+ module CdLib
8
66
  extend FFI::Library
9
67
 
10
- case RbConfig::CONFIG['host_os']
11
- # when /mswin|mingw/
12
- # ffi_lib 'lib/library/iup.dll'
13
- when /linux|cygwin/
14
- ffi_lib 'libiupcd'
15
- else
16
- raise Exception, 'iup libraries not found for this platform'
17
- end
68
+ ffi_lib *Iup::IUP_LIBS
18
69
 
19
70
  attach_function :cdContextIup, [], :pointer
20
71
 
@@ -25,7 +76,7 @@ module CdLib # :nodoc:
25
76
  attach_function :cdCanvasActivate, [:pointer], :int
26
77
  attach_function :cdCanvasDeactivate, [:pointer], :void
27
78
  attach_function :cdUseContextPlus, [:int], :int
28
- # attach_function :cdInitContextPlus, [:void], :void
79
+ # attach_function :cdInitContextPlus, [:void], :void
29
80
  attach_function :cdCanvasGetContext, [:pointer], :pointer
30
81
  attach_function :cdContextCaps, [:pointer], :int
31
82
  attach_function :cdContextType, [:pointer], :int
@@ -62,7 +113,7 @@ module CdLib # :nodoc:
62
113
  attach_function :cdCanvasRect, [:pointer, :int, :int, :int, :int], :void
63
114
  attach_function :cdCanvasArc, [:pointer, :int, :int, :int, :int, :double, :double], :void
64
115
  attach_function :cdCanvasLineStyle, [:pointer, :int], :int
65
- # attach_function :cdCanvasLineStyleDashes, [:pointer, :pointer, :int], :void # TODO: pointer to int array?
116
+ # attach_function :cdCanvasLineStyleDashes, [:pointer, :pointer, :int], :void # TODO: pointer to int array?
66
117
  attach_function :cdCanvasLineWidth, [:pointer, :int], :int
67
118
  attach_function :cdCanvasLineJoin, [:pointer, :int], :int
68
119
  attach_function :cdCanvasLineCap, [:pointer, :int], :int
@@ -1,14 +1,18 @@
1
- module ControlsLib # :nodoc:
1
+ # Binding to the iupcontrols shared library.
2
+ # This module can be used to access features not available
3
+ # in Iup.
4
+ #
5
+ # For reference, the following functions are bound:
6
+ #
7
+ # * IupControlsOpen, [], :int
8
+ # * IupColorbar, [], :pointer
9
+ # * IupDial, [:string], :pointer
10
+ # * IupMatrix, [:string], :pointer
11
+ #
12
+ module ControlsLib
2
13
  extend FFI::Library
3
14
 
4
- case RbConfig::CONFIG['host_os']
5
- # when /mswin|mingw/
6
- # ffi_lib 'lib/library/iupcontrols.dll'
7
- when /linux|cygwin/
8
- ffi_lib 'libiupcontrols'
9
- else
10
- raise Exception, 'iup libraries not found for this platform'
11
- end
15
+ ffi_lib *Iup::IUP_LIBS
12
16
 
13
17
  attach_function :IupControlsOpen, [], :int
14
18
 
@@ -1,14 +1,15 @@
1
- module ImgLib # :nodoc:
1
+ # Binding to the iupimglib shared library.
2
+ # This module can be used to access features not available
3
+ # in Iup.
4
+ #
5
+ # For reference, the following functions are bound:
6
+ #
7
+ # * IupImageLibOpen, [], :void
8
+ #
9
+ module ImgLib
2
10
  extend FFI::Library
3
11
 
4
- case RbConfig::CONFIG['host_os']
5
- when /mswin|mingw/
6
- ffi_lib 'lib/library/iupimglib.lib'
7
- when /linux|cygwin/
8
- ffi_lib 'libiupimglib'
9
- else
10
- raise Exception, 'iup libraries not found for this platform'
11
- end
12
+ ffi_lib *Iup::IUP_LIBS
12
13
 
13
14
  attach_function :IupImageLibOpen, [], :void
14
15
  end
@@ -1,14 +1,16 @@
1
- module ImLib # :nodoc:
1
+ # Binding to the imlib shared library: IM is a toolkit for images.
2
+ # This module can be used to access features not available
3
+ # in Iup.
4
+ #
5
+ # For reference, the following functions are bound:
6
+ #
7
+ # * IupLoadImage, [:string], :pointer
8
+ # * IupSaveImage, [:string, :string], :int
9
+ #
10
+ module ImLib
2
11
  extend FFI::Library
3
12
 
4
- case RbConfig::CONFIG['host_os']
5
- # when /mswin|mingw/
6
- # ffi_lib 'lib/library/iup.dll'
7
- when /linux|cygwin/
8
- ffi_lib 'libiupim'
9
- else
10
- raise Exception, 'iup libraries not found for this platform'
11
- end
13
+ ffi_lib *Iup::IUP_LIBS
12
14
 
13
15
  attach_function :IupLoadImage, [:string], :pointer
14
16
  attach_function :IupSaveImage, [:string, :string], :int
data/lib/plain/iuplib.rb CHANGED
@@ -1,14 +1,157 @@
1
- module IupLib # :nodoc:
1
+ # Binding to the libiup shared library.
2
+ # This module can be used to access features not available
3
+ # in Iup.
4
+ #
5
+ # As an example of using the library:
6
+ #
7
+ # require 'iup-ffi-plain'
8
+ #
9
+ # IupLib.IupOpen(0, nil)
10
+ # IupLib.IupMessage("IupMessage Example", "Press the button")
11
+ # IupLib.IupClose
12
+ #
13
+ # For reference, the following functions are bound:
14
+ #
15
+ # * pango_font_family_get_type, [], :ulong
16
+ # * pango_font_face_get_type, [], :ulong
17
+ # * pango_font_description_get_type, [], :ulong
18
+ # * IupSetAttribute, [:pointer, :string, :string], :void
19
+ # * IupSetAttributes, [:pointer, :string], :pointer
20
+ # * IupGetAttribute, [:pointer, :string], :strptr
21
+ # * IupSetAttributeHandle, [:pointer, :string, :pointer], :void
22
+ # * IupSetGlobal, [:string, :string], :void
23
+ # * IupGetGlobal, [:string], :strptr
24
+ # * IupSetFunction, [:string, :iup_callback], :iup_callback
25
+ # * IupGetInt, [:pointer, :string], :int
26
+ # * IupOpen, [:int, :pointer], :int
27
+ # * IupMainLoop, [], :void
28
+ # * IupClose, [], :void
29
+ # * IupDestroy, [:pointer], :void
30
+ # * IupRedraw, [:pointer], :void
31
+ # * IupMap, [:pointer], :void
32
+ # * IupSetCallbackD_I, :IupSetCallback, [:pointer, :string, :iup_callback_d_i], :iup_callback_d_i
33
+ # * IupSetCallbackFF_I, :IupSetCallback, [:pointer, :string, :iup_callback_ff_i], :iup_callback_ff_i
34
+ # * IupSetCallbackFIIS_I, :IupSetCallback, [:pointer, :string, :iup_callback_fiis_i], :iup_callback_fiis_i
35
+ # * IupSetCallbackS_I, :IupSetCallback, [:pointer, :string, :iup_callback_s_i], :iup_callback_s_i
36
+ # * IupSetCallbackSII_I, :IupSetCallback, [:pointer, :string, :iup_callback_sii_i], :iup_callback_sii_i
37
+ # * IupSetCallbackI_I, :IupSetCallback, [:pointer, :string, :iup_callback_i_i], :iup_callback_i_i
38
+ # * IupSetCallbackI_S, :IupSetCallback, [:pointer, :string, :iup_callback_i_s], :iup_callback_i_s
39
+ # * IupSetCallbackIFF_I, :IupSetCallback, [:pointer, :string, :iup_callback_iff_i], :iup_callback_iff_i
40
+ # * IupSetCallbackII_I, :IupSetCallback, [:pointer, :string, :iup_callback_ii_i], :iup_callback_ii_i
41
+ # * IupSetCallbackIIFF_I, :IupSetCallback, [:pointer, :string, :iup_callback_iiff_i], :iup_callback_iiff_i
42
+ # * IupSetCallbackIIFFI_I, :IupSetCallback, [:pointer, :string, :iup_callback_iiffi_i], :iup_callback_iiffi_i
43
+ # * IupSetCallbackIIFFFF_I, :IupSetCallback, [:pointer, :string, :iup_callback_iiffff_i], :iup_callback_iiffff_i
44
+ # * IupSetCallbackIS_I, :IupSetCallback, [:pointer, :string, :iup_callback_is_i], :iup_callback_is_i
45
+ # * IupSetCallbackIIS_I, :IupSetCallback, [:pointer, :string, :iup_callback_iis_i], :iup_callback_iis_i
46
+ # * IupSetCallbackIII_I, :IupSetCallback, [:pointer, :string, :iup_callback_iii_i], :iup_callback_iii_i
47
+ # * IupSetCallbackIIII_I, :IupSetCallback, [:pointer, :string, :iup_callback_iiii_i], :iup_callback_iiii_i
48
+ # * IupSetCallbackIIS_I, :IupSetCallback, [:pointer, :string, :iup_callback_iis_i], :iup_callback_iis_i
49
+ # * IupSetCallbackIIIIS_I, :IupSetCallback, [:pointer, :string, :iup_callback_iiiis_i], :iup_callback_iiiis_i
50
+ # * IupSetCallbackPlain, :IupSetCallback, [:pointer, :string, :iup_callback_plain], :iup_callback_plain
51
+ # * IupSetCallbackPlain_V, :IupSetCallback, [:pointer, :string, :iup_callback_plain_v], :iup_callback_plain_v
52
+ # * IupSetCallbackP_I, :IupSetCallback, [:pointer, :string, :iup_callback_p_i], :iup_callback_p_i
53
+ # * IupSetCallbackPP_I, :IupSetCallback, [:pointer, :string, :iup_callback_pp_i], :iup_callback_pp_i
54
+ # * IupSetCallbackSS_I, :IupSetCallback, [:pointer, :string, :iup_callback_ss_i], :iup_callback_ss_i
55
+ # * IupSetCallbackSSI_I, :IupSetCallback, [:pointer, :string, :iup_callback_ssi_i], :iup_callback_ssi_i
56
+ # * IupSetCallbackSSIII_I, :IupSetCallback, [:pointer, :string, :iup_callback_ssiii_i], :iup_callback_ssiii_i
57
+ # * IupFill, [], :pointer
58
+ # * IupGridBox, [:pointer, :varargs], :pointer
59
+ # * IupVbox, [:pointer, :varargs], :pointer
60
+ # * IupHbox, [:pointer, :varargs], :pointer
61
+ # * IupZbox, [:pointer, :varargs], :pointer
62
+ # * IupRadio, [:pointer], :pointer
63
+ # * IupNormalizer, [:pointer, :varargs], :pointer
64
+ # * IupBackgroundBox, [:pointer], :pointer
65
+ # * IupCbox, [:pointer, :varargs], :pointer
66
+ # * IupDetachBox, [:pointer], :pointer
67
+ # * IupExpander, [:pointer], :pointer
68
+ # * IupSbox, [:pointer], :pointer
69
+ # * IupScrollBox, [:pointer], :pointer
70
+ # * IupSplit, [:pointer, :pointer], :pointer
71
+ # * IupAppend, [:pointer, :pointer], :pointer
72
+ # * IupDetach, [:pointer], :void
73
+ # * IupInsert, [:pointer, :pointer, :pointer], :pointer
74
+ # * IupReparent, [:pointer, :pointer, :pointer], :int
75
+ # * IupGetParent, [:pointer], :pointer
76
+ # * IupGetChild, [:pointer, :int], :pointer
77
+ # * IupGetChildPos, [:pointer, :pointer], :int
78
+ # * IupGetChildCount, [:pointer], :int
79
+ # * IupGetNextChild, [:pointer, :pointer], :pointer
80
+ # * IupGetBrother, [:pointer], :pointer
81
+ # * IupGetDialog, [:pointer], :pointer
82
+ # * IupGetDialogChild, [:pointer, :string], :pointer
83
+ # * IupRefresh, [:pointer], :void
84
+ # * IupRefreshChildren, [:pointer], :void
85
+ # * IupUpdate, [:pointer], :void
86
+ # * IupRedraw, [:pointer, :int], :void
87
+ # * IupConvertXYToPos, [:pointer, :int, :int], :int
88
+ # * IupDialog, [:pointer], :pointer
89
+ # * IupPopup, [:pointer, :int, :int], :int
90
+ # * IupShow, [:pointer], :void
91
+ # * IupShowXY, [:pointer, :int, :int], :int
92
+ # * IupHide, [:pointer], :void
93
+ # * IupFileDlg, [], :pointer
94
+ # * IupMessageDlg, [], :pointer
95
+ # * IupColorDlg, [], :pointer
96
+ # * IupFontDlg, [], :pointer
97
+ # * IupProgressDlg, [], :pointer
98
+ # * IupAlarm, [:string, :string, :string, :string, :string], :int
99
+ # * IupGetFile, [:string], :int
100
+ # * IupGetColor, [:int, :int, :pointer, :pointer, :pointer], :int
101
+ # * IupGetText, [:pointer, :pointer], :int
102
+ # * IupListDialog, [:int, :string, :int, :pointer, :int, :int, :int, :pointer], :int
103
+ # * IupMessage, [:string, :string], :void
104
+ # * IupButton, [:string, :string], :pointer
105
+ # * IupCanvas, [:string], :pointer
106
+ # * IupFrame, [:pointer], :pointer
107
+ # * IupLabel, [:string], :pointer
108
+ # * IupLink, [:string, :string], :pointer
109
+ # * IupList, [:string], :pointer
110
+ # * IupProgressBar, [], :pointer
111
+ # * IupSpin, [], :pointer
112
+ # * IupTabs, [:pointer, :varargs], :pointer
113
+ # * IupText, [:string], :pointer
114
+ # * IupToggle, [:string, :string], :pointer
115
+ # * IupTree, [], :pointer
116
+ # * IupVal, [:string], :pointer
117
+ # * IupImage, [:int, :int, :pointer], :pointer
118
+ # * IupImageRGB, [:int, :int, :pointer], :pointer
119
+ # * IupImageRGBA, [:int, :int, :pointer], :pointer
120
+ # * IupSaveImageAsText, [:pointer, :string, :string, :string], :int
121
+ # * IupNextField, [:pointer], :pointer
122
+ # * IupPreviousField, [:pointer], :pointer
123
+ # * IupGetFocus, [], :pointer
124
+ # * IupSetFocus, [:pointer], :pointer
125
+ # * IupItem, [:string, :string], :pointer
126
+ # * IupMenu, [:pointer, :varargs], :pointer
127
+ # * IupSeparator, [], :pointer
128
+ # * IupSubmenu, [:string, :pointer], :pointer
129
+ # * IupSetHandle, [:string, :pointer], :void
130
+ # * IupGetHandle, [:string], :pointer
131
+ # * IupGetName, [:pointer], :strptr
132
+ # * IupSetLanguage, [:string], :void
133
+ # * IupGetLanguage, [], :strptr
134
+ # * IupClipboard, [], :pointer
135
+ # * IupTimer, [], :pointer
136
+ # * IupHelp, [:string], :int
137
+ #
138
+ module IupLib
2
139
  extend FFI::Library
3
140
 
4
- this_dir = File.dirname(__FILE__)
5
- case RbConfig::CONFIG['host_os']
6
- when /mswin|mingw/
7
- ffi_lib 'lib/library/iup.dll'
8
- when /linux|cygwin/
9
- ffi_lib 'libiup'
10
- else
11
- raise Exception, 'iup libraries not found for this platform'
141
+ ffi_lib *Iup::IUP_LIBS
142
+
143
+ if /linux|cygwin/ === RbConfig::CONFIG['host_os']
144
+ # This function returns the GType ID for a PangoFontFamily.
145
+ # Calling it forces Pango to register its types with GObject.
146
+ attach_function :pango_font_family_get_type, [], :ulong
147
+ attach_function :pango_font_face_get_type, [], :ulong
148
+ attach_function :pango_font_description_get_type, [], :ulong
149
+
150
+ # Note: ping the Pango Type System to register types
151
+ # between the shared libraries and GObject
152
+ pango_font_family_get_type()
153
+ pango_font_face_get_type()
154
+ pango_font_description_get_type()
12
155
  end
13
156
 
14
157
  # Attributes
@@ -190,17 +333,19 @@ module IupLib # :nodoc:
190
333
 
191
334
  # helper functions, to create memory structures from arrays
192
335
 
336
+ # Creates a memory structure from an array.
193
337
  # Input:: an array of chars
194
338
  # Output:: pointer to memory holding array of chars
195
- def IupLib.pointer_from_chars array
339
+ def self.pointer_from_chars array
196
340
  ptr = FFI::MemoryPointer.new :char, array.size
197
341
  ptr.write_array_of_char array
198
342
  return ptr
199
343
  end
200
344
 
345
+ # Creates a memory structure from an array.
201
346
  # Input:: an array of ints
202
347
  # Output:: pointer to memory holding array of ints
203
- def IupLib.pointer_from_ints array
348
+ def self.pointer_from_ints array
204
349
  ptr = FFI::MemoryPointer.new :int, array.size
205
350
  ptr.write_array_of_int array
206
351
  return ptr
@@ -1,14 +1,16 @@
1
- module ScintillaLib # :nodoc:
1
+ # Binding to the iup_scintilla shared library.
2
+ # This module can be used to access features not available
3
+ # in Iup.
4
+ #
5
+ # For reference, the following functions are bound:
6
+ #
7
+ # * IupScintilla, [], :pointer
8
+ # * IupScintillaOpen, [], :void
9
+ #
10
+ module ScintillaLib
2
11
  extend FFI::Library
3
12
 
4
- case RbConfig::CONFIG['host_os']
5
- # when /mswin|mingw/
6
- # ffi_lib 'lib/library/iupimglib.lib'
7
- when /linux|cygwin/
8
- ffi_lib 'libiup_scintilla'
9
- else
10
- raise Exception, 'iup scintilla library not found for this platform'
11
- end
13
+ ffi_lib *Iup::IUP_LIBS
12
14
 
13
15
  attach_function :IupScintilla, [], :pointer
14
16
  attach_function :IupScintillaOpen, [], :void