wxruby3 0.9.0.pre.beta.11 → 0.9.0.pre.beta.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +85 -0
  3. data/README.md +2 -0
  4. data/assets/logo.png +0 -0
  5. data/assets/logo.svg +170 -0
  6. data/assets/logo.xcf +0 -0
  7. data/ext/wxruby3/swig/wx.i +1 -1
  8. data/lib/wx/accessors.rb +8 -2
  9. data/lib/wx/core/array_ext.rb +26 -0
  10. data/lib/wx/core/art_locator.rb +92 -0
  11. data/lib/wx/core/artprovider.rb +1 -1
  12. data/lib/wx/core/bitmap.rb +90 -53
  13. data/lib/wx/core/cursor.rb +12 -0
  14. data/lib/wx/core/dataformat.rb +3 -1
  15. data/lib/wx/core/dc.rb +76 -52
  16. data/lib/wx/core/enum.rb +4 -0
  17. data/lib/wx/core/event.rb +38 -5
  18. data/lib/wx/core/evthandler.rb +64 -23
  19. data/lib/wx/core/icon.rb +50 -35
  20. data/lib/wx/core/id_helper.rb +32 -0
  21. data/lib/wx/core/image.rb +63 -53
  22. data/lib/wx/core/point.rb +14 -0
  23. data/lib/wx/core/real_point.rb +15 -1
  24. data/lib/wx/core/rect.rb +42 -7
  25. data/lib/wx/core/region_iterator.rb +37 -0
  26. data/lib/wx/core/size.rb +20 -0
  27. data/lib/wx/core/window.rb +8 -31
  28. data/lib/wx/doc/array_ext.rb +27 -0
  29. data/lib/wx/doc/art_locator.rb +57 -0
  30. data/lib/wx/doc/bitmap.rb +27 -0
  31. data/lib/wx/doc/clipboard.rb +12 -0
  32. data/lib/wx/doc/const.rb +77 -0
  33. data/lib/wx/doc/cursor.rb +16 -0
  34. data/lib/wx/doc/data_object.rb +1 -2
  35. data/lib/wx/doc/dc.rb +63 -46
  36. data/lib/wx/doc/event.rb +24 -0
  37. data/lib/wx/doc/events.rb +14 -0
  38. data/lib/wx/doc/evthandler.rb +24 -3
  39. data/lib/wx/doc/extra/00_starting.md +1 -1
  40. data/lib/wx/doc/extra/06_geometry.md +10 -4
  41. data/lib/wx/doc/extra/10_art.md +105 -0
  42. data/lib/wx/doc/gc_dc.rb +21 -0
  43. data/lib/wx/doc/gdi_common.rb +122 -1
  44. data/lib/wx/doc/graphics_context.rb +42 -0
  45. data/lib/wx/doc/icon.rb +18 -0
  46. data/lib/wx/doc/id_helper.rb +25 -0
  47. data/lib/wx/doc/image.rb +33 -0
  48. data/lib/wx/doc/region_iterator.rb +31 -0
  49. data/lib/wx/doc/scaled_dc.rb +1 -0
  50. data/lib/wx/doc/window.rb +18 -0
  51. data/lib/wx/global_const.rb +24 -18
  52. data/lib/wx/version.rb +1 -1
  53. data/lib/wx/wxruby/cmd/sampler.rb +3 -21
  54. data/rakelib/lib/config.rb +4 -4
  55. data/rakelib/lib/core/package.rb +3 -3
  56. data/rakelib/lib/director/art_provider.rb +2 -2
  57. data/rakelib/lib/director/busy_info.rb +9 -7
  58. data/rakelib/lib/director/clipboard.rb +1 -1
  59. data/rakelib/lib/director/colour_picker_ctrl.rb +1 -0
  60. data/rakelib/lib/director/data_object.rb +72 -4
  61. data/rakelib/lib/director/derived_dc.rb +100 -6
  62. data/rakelib/lib/director/dir_picker_ctrl.rb +1 -0
  63. data/rakelib/lib/director/event.rb +73 -8
  64. data/rakelib/lib/director/events.rb +19 -1
  65. data/rakelib/lib/director/file_picker_ctrl.rb +1 -0
  66. data/rakelib/lib/director/font_picker_ctrl.rb +1 -0
  67. data/rakelib/lib/director/gdicommon.rb +1 -3
  68. data/rakelib/lib/director/graphics_context.rb +89 -0
  69. data/rakelib/lib/director/help_controller.rb +2 -2
  70. data/rakelib/lib/director/html_data_object.rb +37 -0
  71. data/rakelib/lib/director/image.rb +55 -0
  72. data/rakelib/lib/director/region_iterator.rb +48 -0
  73. data/rakelib/lib/director/richtext_buffer.rb +1 -1
  74. data/rakelib/lib/director/richtext_buffer_data_object.rb +45 -0
  75. data/rakelib/lib/director/scroll_bar.rb +39 -0
  76. data/rakelib/lib/director/slider.rb +39 -0
  77. data/rakelib/lib/director/window.rb +36 -5
  78. data/rakelib/lib/director/window_disabler.rb +0 -7
  79. data/rakelib/lib/extractor/class.rb +1 -1
  80. data/rakelib/lib/extractor/function.rb +1 -1
  81. data/rakelib/lib/generate/doc.rb +27 -7
  82. data/rakelib/lib/specs/interfaces.rb +6 -1
  83. data/rakelib/lib/typemap/common.rb +1 -1
  84. data/rakelib/lib/util/string.rb +29 -8
  85. data/samples/art/wxruby-128x128.png +0 -0
  86. data/samples/art/wxruby-256x256.png +0 -0
  87. data/samples/art/wxruby-64x64.png +0 -0
  88. data/samples/art/wxruby.ico +0 -0
  89. data/samples/art/wxruby.png +0 -0
  90. data/samples/drawing/graphics_drawing.rb +1 -2
  91. data/samples/propgrid/propgrid.rb +65 -65
  92. data/samples/sample.xpm +246 -470
  93. data/samples/treectrl/treectrl.rb +1 -1
  94. data/tests/art/my_art/sample.xpm +251 -0
  95. data/tests/art/sample3.xpm +251 -0
  96. data/tests/art/test_art/bitmap/sample.xpm +251 -0
  97. data/tests/art/test_art/bitmap/wxruby.bmp +0 -0
  98. data/tests/art/test_art/bitmap/wxruby.png +0 -0
  99. data/tests/art/test_art/bitmap/wxruby.xpm +251 -0
  100. data/tests/art/test_art/cursor/wxruby.bmp +0 -0
  101. data/tests/art/test_art/icon/sample.xpm +251 -0
  102. data/tests/art/test_art/icon/wxruby.ico +0 -0
  103. data/tests/art/test_art/icon/wxruby.png +0 -0
  104. data/tests/art/test_art/image/sample.xpm +251 -0
  105. data/tests/art/test_art/image/wxruby.jpg +0 -0
  106. data/tests/art/test_art/image/wxruby.png +0 -0
  107. data/tests/art/test_art/sample2.xpm +251 -0
  108. data/tests/test_art.rb +91 -0
  109. data/tests/test_clipboard.rb +35 -0
  110. data/tests/test_dc.rb +70 -0
  111. data/tests/test_events.rb +12 -0
  112. data/tests/test_geometry.rb +13 -0
  113. metadata +51 -5
@@ -0,0 +1,105 @@
1
+ <!--
2
+ # @markup markdown
3
+ # @title 10. wxRuby Locating and loading art
4
+ -->
5
+
6
+ # 9. wxRuby Locating and loading art
7
+
8
+ ## Introduction
9
+
10
+ With C++ wxWidgets applications art (icons, bitmaps, cursors, images) can be loaded in a variety
11
+ of ways from embedded resources (platform specific binary resources or embedded XPM files) or from
12
+ binary datasets retrieved from some data source.
13
+
14
+ With wxRuby that is for various reasons not a viable option so we are left with the option to
15
+ load art from files. In and of itself that option is not really too bad but for the issue of locating
16
+ the art files.
17
+ Art that is part of the application's design will preferably be stored with the source code but there
18
+ is not standard for this nor is there any standard support for locating those files from the application
19
+ code like there is for `require`-s of other code modules.
20
+
21
+ The wxRuby framework provides a convenience module `Wx::ArtLocator` to assist in that respect.
22
+ Wx::ArtLocator aims on the one side to standardize folder structures for storing art files and on the
23
+ other side to provide runtime support for locating those files from code.
24
+
25
+ The main locator method provided is:
26
+
27
+ ```ruby
28
+ module Wx::Locator
29
+ def self.find_art(art_name, art_type: nil, art_path: nil, art_section: nil, bmp_type: nil)
30
+ # ...
31
+ end
32
+ end
33
+ ```
34
+
35
+ The 'art_name' argument should provide the base name for matching art files and can be specified as either
36
+ String or Symbol.
37
+
38
+ ## Storage locations
39
+
40
+ Wx::ArtLocator defines a standardized directory structure that is assumed to be used for application art
41
+ file storage.
42
+ Working from a certain (application defined) base search path ('art_path' argument) this structure looks like this:
43
+
44
+ <art_path>
45
+ \art
46
+ \<art_section>
47
+ \<art_type>
48
+
49
+ Where '<art_path>' is an application supplied search path, 'art' is the default name for Art folders (this can be overridden by an application specific name),
50
+ '<art_section>' is an application defined id allowing sub-categorizing art and '<art_type>' is the type of art indicator
51
+ (which can be 'icon', 'bitmap', 'cursor', 'image').
52
+ Art files can be located at any level in this hierarchy and all sub levels in this hierarchy are optional.
53
+ When locating files the art locator will test a file's existence at all levels starting with the
54
+ deepest level working it's way up returning the absolute path of the first file found this way.
55
+
56
+ So locating an art file would involve testing for the file at the following paths:
57
+ 1. \<art_path>/art/<art_section>/<art_type>/
58
+ 2. \<art_path>/art/<art_section>/
59
+ 3. \<art_path>/art/
60
+ 4. \<art_path>/
61
+
62
+ The first location can be skipped by specifying `nil` for 'art_type'.
63
+
64
+ ## Bitmap types
65
+
66
+ Based on platform and specified '<art_type>' (and optionally a specific Wx::BitmapType) art files with a specific
67
+ range of extensions will be tested in a specific order.
68
+ For example for locating an `:icon` (<art_type>) on platform 'WXGTK' the locator will test the preferred extension
69
+ '.xpm' followed by any of supported extensions of all other supported bitmap types.
70
+ For platform 'WXMSW' however the same search would test only the extensions '.ico' and '.xpm' (in that
71
+ order).
72
+ Specifying a specific Wx::BitmapType for a search will restrict the search to testing only the extensions supported
73
+ for the specified Wx::BitmapType.
74
+
75
+ ## Search paths
76
+
77
+ To prevent having to specify base search path for every location request Wx::Locator provides 2 options.
78
+
79
+ When an explicit specification of a base search path ('art_path) is omitted from a location request the locator
80
+ will determine one by using `Kernel#caller_locations` to extract the absolute path for the source file containing
81
+ the caller's code. The result of `File.dirname(src_path)` is than used as base search path.
82
+ If 'art_section' is also omitted the result of `File.basename(src_path, '.*')` will be used instead.
83
+
84
+ This means that calling `Wx::ArtLocator.find_art` from some code in file `/some/lib/path/to/ruby/code.rb` without
85
+ specifying both 'art_path' and 'art_section' would result in looking for an art file with the base search path
86
+ being `/some/lib/path/to/ruby/` and using `code` as 'art_section'.
87
+
88
+ It is also possible to add 'application global' search paths with the method `Wx::ArtLocator.add_search_path`.
89
+ Search paths added in this way will be tested after failing to find any matching art file at the initial 'art_path'
90
+ location. The same location steps apply to these search paths as with the initial 'art_path' (see above).
91
+
92
+ ## Convenience methods
93
+
94
+ Based on the Wx::ArtLocator implementation wxRuby additionally provides a number of convenience methods to
95
+ easily create Icons, Bitmaps, Cursors and Images from simple ids (symbols).
96
+ These methods mimic the ease of use of the `wxICON` and `wxBITMAP` macros used with C++ wxWidgets such that
97
+ creating an Wx::Icon instance could be as easy as:
98
+
99
+ ```ruby
100
+ frame.icon = Wx::Icon(:sample)
101
+ ```
102
+
103
+ As these methods apply the same search path 'automagic' as `Wx::ArtLocator.find_art` (see [Search paths](#Search-paths))
104
+ this would search for an art file with base name 'sample' and an appropriate extension (like '.xpm' for the 'WXGTK' platform)
105
+ in a location starting at the directory in which the caller's code is stored (applying the steps described above).
@@ -0,0 +1,21 @@
1
+
2
+ class Wx
3
+
4
+ class GCDC < Wx::DC
5
+
6
+ private :initialize
7
+
8
+ # Creates a Wx::GCDC instance for target and
9
+ # passes the instance to the given block to draw on.
10
+ # @overload draw_on(dc)
11
+ # @param [Wx::WindowDC,Wx::MemoryDC,Wx::PrinterDC] target DC to draw on
12
+ # @yieldparam [Wx::GCDC] dc GCDC instance to draw on
13
+ # @return [Object] result from block
14
+ # @overload draw_on(dc)
15
+ # @param [Wx::GraphicsContext] gc GraphicsContext to draw on
16
+ # @yieldparam [Wx::GCDC] dc GCDC instance to draw on
17
+ # @return [Object] result from block
18
+ def self.draw_on(arg) end
19
+ end
20
+
21
+ end
@@ -52,6 +52,20 @@ module Wx
52
52
  # @return [Wx::Size]
53
53
  def +(arg) end
54
54
 
55
+ alias :get_x :get_width
56
+ alias :x :get_width
57
+ alias :get_y :get_height
58
+ alias :y :get_height
59
+
60
+ # Set this size to the given size's width,height values
61
+ # @param [Wx::Size] sz
62
+ # @return [self]
63
+ def assign(sz) end
64
+
65
+ # Returns self.
66
+ # @return [self]
67
+ def to_size; end
68
+
55
69
  end
56
70
 
57
71
  class Point
@@ -110,6 +124,15 @@ module Wx
110
124
  def to_real_point; end
111
125
  alias :to_real :to_real_point
112
126
 
127
+ # Returns self.
128
+ # @return [self]
129
+ def to_point; end
130
+
131
+ # Set this point to the given point's x,y values
132
+ # @param [Wx::Point] pt
133
+ # @return [self]
134
+ def assign(pt) end
135
+
113
136
  end
114
137
 
115
138
  class RealPoint
@@ -172,6 +195,15 @@ module Wx
172
195
  # @return [Wx::Point] Wx::Point instance from real point coordinates
173
196
  def to_point; end
174
197
 
198
+ # Returns self.
199
+ # @return [self]
200
+ def to_real_point; end
201
+
202
+ # Set this point to the given point's x,y values
203
+ # @param [Wx::RealPoint] pt
204
+ # @return [self]
205
+ def assign(pt) end
206
+
175
207
  end
176
208
 
177
209
  class Rect
@@ -190,6 +222,88 @@ module Wx
190
222
  # @return [Boolean]
191
223
  def eql?(other)end
192
224
 
225
+ # Update this rectangle to the union with 'rect'
226
+ # @param [Wx::Rect] rect
227
+ # @return [self]
228
+ def union!(rect) end
229
+
230
+ # Update this rectangle to the intersection with 'rect'
231
+ # @param [Wx::Rect] rect
232
+ # @return [self]
233
+ def intersect!(rect) end
234
+
235
+ # @overload deflate!(dx, dy)
236
+ # Decrease the rectangle size.
237
+ # This method is the opposite from {inflate!}: deflate!(a, b) is equivalent to inflate!(-a, -b). Please refer to {inflate!} for full description.
238
+ # @param dx [Integer]
239
+ # @param dy [Integer]
240
+ # @return [self]
241
+ # @overload deflate!(diff)
242
+ # Decrease the rectangle size.
243
+ # This method is the opposite from {inflate!}: deflate!(a, b) is equivalent to inflate!(-a, -b). Please refer to {inflate!} for full description.
244
+ # @param diff [Array(Integer, Integer), Wx::Size]
245
+ # @return [self]
246
+ # @overload deflate!(diff)
247
+ # Decrease the rectangle size.
248
+ # This method is the opposite from {inflate!}: deflate!(a, b) is equivalent to inflate!(-a, -b). Please refer to {inflate!} for full description.
249
+ # @param diff [Integer]
250
+ # @return [self]
251
+ def deflate!(*args) end
252
+
253
+ # @overload inflate!(dx, dy)
254
+ # Increases the size of the rectangle.
255
+ # The left border is moved farther left and the right border is moved farther right by dx. The upper border is moved farther up and the bottom border is moved farther down by dy. (Note that the width and height of the rectangle thus change by 2*dx and 2*dy, respectively.) If one or both of dx and dy are negative, the opposite happens: the rectangle size decreases in the respective direction.
256
+ # Inflating and deflating behaves "naturally". Defined more precisely, that means:
257
+ # - "Real" inflates (that is, dx and/or dy = 0) are not constrained. Thus inflating a rectangle can cause its upper left corner to move into the negative numbers. (2.5.4 and older forced the top left coordinate to not fall below (0, 0), which implied a forced move of the rectangle.)- Deflates are clamped to not reduce the width or height of the rectangle below zero. In such cases, the top-left corner is nonetheless handled properly. For example, a rectangle at (10, 10) with size (20, 40) that is inflated by (-15, -15) will become located at (20, 25) at size (0, 10). Finally, observe that the width and height are treated independently. In the above example, the width is reduced by 20, whereas the height is reduced by the full 30 (rather than also stopping at 20, when the width reached zero).
258
+ # @see #inflate
259
+ # @see #deflate!
260
+ # @param dx [Integer]
261
+ # @param dy [Integer]
262
+ # @return [self]
263
+ # @overload inflate!(diff)
264
+ # Increases the size of the rectangle.
265
+ # The left border is moved farther left and the right border is moved farther right by dx. The upper border is moved farther up and the bottom border is moved farther down by dy. (Note that the width and height of the rectangle thus change by 2*dx and 2*dy, respectively.) If one or both of dx and dy are negative, the opposite happens: the rectangle size decreases in the respective direction.
266
+ # Inflating and deflating behaves "naturally". Defined more precisely, that means:
267
+ # - "Real" inflates (that is, dx and/or dy = 0) are not constrained. Thus inflating a rectangle can cause its upper left corner to move into the negative numbers. (2.5.4 and older forced the top left coordinate to not fall below (0, 0), which implied a forced move of the rectangle.)- Deflates are clamped to not reduce the width or height of the rectangle below zero. In such cases, the top-left corner is nonetheless handled properly. For example, a rectangle at (10, 10) with size (20, 40) that is inflated by (-15, -15) will become located at (20, 25) at size (0, 10). Finally, observe that the width and height are treated independently. In the above example, the width is reduced by 20, whereas the height is reduced by the full 30 (rather than also stopping at 20, when the width reached zero).
268
+ # @see deflate
269
+ # @param diff [Array(Integer, Integer), Wx::Size]
270
+ # @return [self]
271
+ # @overload inflate!(diff)
272
+ # Increases the size of the rectangle.
273
+ # The left border is moved farther left and the right border is moved farther right by dx. The upper border is moved farther up and the bottom border is moved farther down by dy. (Note that the width and height of the rectangle thus change by 2*dx and 2*dy, respectively.) If one or both of dx and dy are negative, the opposite happens: the rectangle size decreases in the respective direction.
274
+ # Inflating and deflating behaves "naturally". Defined more precisely, that means:
275
+ # - "Real" inflates (that is, dx and/or dy = 0) are not constrained. Thus inflating a rectangle can cause its upper left corner to move into the negative numbers. (2.5.4 and older forced the top left coordinate to not fall below (0, 0), which implied a forced move of the rectangle.)- Deflates are clamped to not reduce the width or height of the rectangle below zero. In such cases, the top-left corner is nonetheless handled properly. For example, a rectangle at (10, 10) with size (20, 40) that is inflated by (-15, -15) will become located at (20, 25) at size (0, 10). Finally, observe that the width and height are treated independently. In the above example, the width is reduced by 20, whereas the height is reduced by the full 30 (rather than also stopping at 20, when the width reached zero).
276
+ # @see deflate
277
+ # @param diff [Integer]
278
+ # @return [self]
279
+ def inflate!(*args) end
280
+
281
+ # @overload offset(dx, dy)
282
+ # Moves the rectangle by the specified offset.
283
+ # If dx is positive, the rectangle is moved to the right, if dy is positive, it is moved to the bottom, otherwise it is moved to the left or top respectively.
284
+ # @param dx [Integer]
285
+ # @param dy [Integer]
286
+ # @return [Wx::Rect]
287
+ # @overload offset(pt)
288
+ # Moves the rectangle by the specified offset.
289
+ # If dx is positive, the rectangle is moved to the right, if dy is positive, it is moved to the bottom, otherwise it is moved to the left or top respectively.
290
+ # @param pt [Array(Integer, Integer), Wx::Point]
291
+ # @return [Wx::Rect]
292
+ def offset(*args) end
293
+
294
+ # @overload offset!(dx, dy)
295
+ # Moves the rectangle by the specified offset.
296
+ # If dx is positive, the rectangle is moved to the right, if dy is positive, it is moved to the bottom, otherwise it is moved to the left or top respectively.
297
+ # @param dx [Integer]
298
+ # @param dy [Integer]
299
+ # @return [self]
300
+ # @overload offset!(pt)
301
+ # Moves the rectangle by the specified offset.
302
+ # If dx is positive, the rectangle is moved to the right, if dy is positive, it is moved to the bottom, otherwise it is moved to the left or top respectively.
303
+ # @param pt [Array(Integer, Integer), Wx::Point]
304
+ # @return [self]
305
+ def offset!(*args) end
306
+
193
307
  alias :& :intersect
194
308
 
195
309
  alias :| :union
@@ -197,13 +311,20 @@ module Wx
197
311
  # Returns the overlap of the rectangle areas.
198
312
  # Does not check negative or zero overlap like #intersect.
199
313
  # @param [Wx::Rect] rect
314
+ # @return [Wx::Rect]
200
315
  def *(rect) end
201
316
 
202
- # Modifies the rectangle to contain the bounding box of this rectangle and the one passed in as parameter.
317
+ # Returns a rectangle containing the bounding box of this rectangle and the one passed in as parameter.
203
318
  # Does not ignore empty rectangles like #union
204
319
  # @param [Wx::Rect] rect
320
+ # @return [Wx::Rect]
205
321
  def +(rect) end
206
322
 
323
+ # Set this rectangle to the given rectangle's position & size values
324
+ # @param [Wx::Rect] rct
325
+ # @return [self]
326
+ def assign(rct) end
327
+
207
328
  end
208
329
 
209
330
  end
@@ -0,0 +1,42 @@
1
+
2
+ class Wx::GraphicsContext
3
+
4
+ # @overload self.draw_on(window)
5
+ # Creates a {Wx::GraphicsContext} from a {Wx::Window} and passes that object to the given block.
6
+ # Deletes the gc object after the block returns.
7
+ # @see Wx::GraphicsRenderer#create_context
8
+ # @param window [Wx::Window]
9
+ # @return [Wx::GraphicsContext]
10
+ # @overload self.draw_on(windowDC)
11
+ # Creates a {Wx::GraphicsContext} from a {Wx::WindowDC} and passes that object to the given block.
12
+ # Deletes the gc object after the block returns.
13
+ # @see Wx::GraphicsRenderer#create_context
14
+ # @param windowDC [Wx::WindowDC]
15
+ # @return [Wx::GraphicsContext]
16
+ # @overload self.draw_on(memoryDC)
17
+ # Creates a {Wx::GraphicsContext} from a {Wx::MemoryDC} and passes that object to the given block.
18
+ # Deletes the gc object after the block returns.
19
+ # @see Wx::GraphicsRenderer#create_context
20
+ # @param memoryDC [Wx::MemoryDC]
21
+ # @return [Wx::GraphicsContext]
22
+ # @overload self.draw_on(printerDC)
23
+ # Creates a {Wx::GraphicsContext} from a {Wx::PrinterDC} and passes that object to the given block.
24
+ # Deletes the gc object after the block returns.
25
+ # Under GTK+, this will only work when using the GtkPrint printing backend which is available since GTK+ 2.10.
26
+ # @see Wx::GraphicsRenderer#create_context
27
+ # @see Printing Under Unix (GTK+)
28
+ # @param printerDC [Wx::PrinterDC]
29
+ # @return [Wx::GraphicsContext]
30
+ # @overload self.draw_on(image)
31
+ # Creates a {Wx::GraphicsContext} associated with a {Wx::Image} and passes that object to the given block.
32
+ # Deletes the gc object after the block returns.
33
+ # The image specifies the size of the context as well as whether alpha is supported (if {Wx::Image#has_alpha}) or not and the initial contents of the context. The image object must have a life time greater than that of the new context as the context copies its contents back to the image when it is destroyed.
34
+ # @param image [Wx::Image]
35
+ # @return [Wx::GraphicsContext]
36
+ # @overload self.draw_on()
37
+ # Create a lightweight context that can be used only for measuring text and passes that object to the given block.
38
+ # Deletes the gc object after the block returns.
39
+ # @return [Wx::GraphicsContext]
40
+ def self.draw_on(*args) end
41
+
42
+ end
@@ -0,0 +1,18 @@
1
+
2
+ class Wx::Icon
3
+
4
+ # Searches for an art file with basename 'name' and creates an Icon if found.
5
+ # Raises an ArgumentError if not found.
6
+ # Wx::ArtLocator::find_art is used to look up the art file using ::Kernel#caller_locations to
7
+ # determine the values for the 'art_path' and 'art_owner' arguments ('art_path' is set to the
8
+ # absolute path to the folder holding the caller's code and 'art_owner' to the basename of the
9
+ # caller's source file). The 'art_type' argument is set to <code>:icon</code>.
10
+ # @param [String,Symbol] name base name of art file
11
+ # @param [Wx::BitmapType,nil] bmp_type bitmap type for art file (nil means any supported type)
12
+ # @param [Integer] desired_width
13
+ # @param [Integer] desired_height
14
+ # @return [Wx::Icon]
15
+ # @see Wx::ArtLocator::find_art
16
+ def self.Icon(name, bmp_type = nil, desired_width=-1, desired_height=-1); end
17
+
18
+ end
@@ -0,0 +1,25 @@
1
+
2
+ module Wx
3
+
4
+ # Mixin module to provide convenience method for defining Windows/Control ids.
5
+ # @example Define an ID module
6
+ # module MyIDS
7
+ # include Wx::IDHelper
8
+ # # by default the offset for the next id is Wx::ID_HIGHEST which makes 'Wx::ID_HIGHEST+1'
9
+ # # the first id value returned.
10
+ # MY_FIRST_ID = self.next_id
11
+ # MY_SECOND_ID = self.next_id # MY_SECOND_ID will have value Wx::ID_HIGHEST+2
12
+ #
13
+ # # optionally a user defined offset can be specified like this:
14
+ # MY_OTHER_ID = self.next_id(MY_FIRST_ID+1000) # MY_OTHER_ID will have value MY_FIRST_ID+1001
15
+ # MY_OTHER_ID2 = self.next_id # MY_OTHER_ID2 will have value MY_FIRST_ID+1002
16
+ # end
17
+ #
18
+ module IDHelper
19
+
20
+ # Provides the singleton method #next_id to the including module.
21
+ def self.included(base) end
22
+
23
+ end
24
+
25
+ end
@@ -0,0 +1,33 @@
1
+
2
+ module Wx
3
+
4
+ class Image
5
+
6
+ # Returns an array of BitmapTypes identifying the available image handlers.
7
+ # @return [Array<Wx::BitmapType>]
8
+ def self.handlers; end
9
+
10
+ # Returns an array with the supported file extensions (as 'bmp') of the available image handlers.
11
+ # @return [Array<String>]
12
+ def self.extensions; end
13
+
14
+ # returns a Hash with all supported extensions per available BitmapType
15
+ # @return [Hash]
16
+ def self.handler_extensions; end
17
+
18
+ # Searches for an art file with basename 'name' and creates an Image if found.
19
+ # Raises an ArgumentError if not found.
20
+ # Wx::ArtLocator::find_art is used to look up the art file using ::Kernel#caller_locations to
21
+ # determine the values for the 'art_path' and 'art_owner' arguments ('art_path' is set to the
22
+ # absolute path to the folder holding the caller's code and 'art_owner' to the basename of the
23
+ # caller's source file). The 'art_type' argument is set to <code>:icon</code>.
24
+ # @param [String,Symbol] name base name of art file
25
+ # @param [Wx::BitmapType,nil] bmp_type bitmap type for art file (nil means any supported type)
26
+ # @param [Integer] index Index of the image to load in the case that the image file contains multiple images. This is only used by GIF, ICO and TIFF handlers. The default value (-1) means "choose the default image" and is interpreted as the first image (index=0) by the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.
27
+ # @return [Wx::Image]
28
+ # @see Wx::ArtLocator::find_art
29
+ def self.Image(name, bmp_type = nil, index=-1); end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,31 @@
1
+
2
+ class Wx::RegionIterator
3
+
4
+ # Creates a Wx::RegionIterator and passes that to the given block.
5
+ # Removes the iterator after the block finishes.
6
+ # @param [Wx::Region] region
7
+ # @yieldparam [Wx::RegionIterator] region_it
8
+ def self.for_region(region) end
9
+
10
+ # Creates a Wx::RegionIterator and iterates each rectangle in the region executing the given block
11
+ # for each iteration passing the region iterator.
12
+ # @param [Wx::Region] region
13
+ # @yieldparam [Wx::RegionIterator] region_it
14
+ def self.iterate(region) end
15
+
16
+ alias :have_rects? :have_rects
17
+
18
+ # Moves to the next rectangle of the iterated region.
19
+ # @return [void]
20
+ def next_rect; end
21
+
22
+ # If a block is given the given block is called for each rectangle in the region passing the rectangle.
23
+ # If no block is given an Enumerator is returned.
24
+ # @overload each(&block)
25
+ # @yieldparam [Wx::Rect] rect
26
+ # @return [Object]
27
+ # @overload each()
28
+ # @return [Enumerator]
29
+ def each; end
30
+
31
+ end
@@ -10,6 +10,7 @@ class Wx
10
10
  # @param [Wx::DC] target DC to draw on (scaled)
11
11
  # @param [Float] scale scale factor
12
12
  # @yieldparam [Wx::ScaledDC] dc scaled dc to draw on
13
+ # @return [Object] result from block
13
14
  def self.draw_on(target, scale) end
14
15
  end
15
16
 
@@ -0,0 +1,18 @@
1
+
2
+ class Wx::Window
3
+
4
+ # Creates an appropriate (temporary) DC to paint on and
5
+ # passes that to the given block. Deletes the DC when the block returns.
6
+ # Creates a Wx::PaintDC when called from an evt_paint handler and a
7
+ # Wx::ClientDC otherwise.
8
+ # @yieldparam [Wx::PaintDC,Wx::ClientDC] dc dc to paint on
9
+ # @return [Object] result from block
10
+ def paint; end
11
+
12
+ # Similar to #paint but this time creates a Wx::AutoBufferedPaintDC when called
13
+ # from an evt_paint handler and a Wx::ClientDC otherwise.
14
+ # @yieldparam [Wx::AutoBufferedPaintDC,Wx::ClientDC] dc dc to paint on
15
+ # @return [Object] result from block
16
+ def paint_buffered; end
17
+
18
+ end
@@ -7,24 +7,30 @@ module WxGlobalConstants
7
7
  def search_nested(mod, sym, path = [])
8
8
  # check any nested modules and/or (enum) classes
9
9
  const_val = nil
10
- mod.constants.each do |c|
11
- case cv = mod.const_get(c)
12
- when ::Class
13
- if cv < Wx::Enum
14
- # the only thing of interest in Enum classes are the enum values
15
- const_val = cv[sym]
16
- elsif cv.name.start_with?('Wx::') # only search Wx namespace
17
- # prevent const_missing being triggered here since that may lead to unexpected results
18
- const_val = cv.const_get(sym) if cv.constants.include?(sym)
19
- const_val = search_nested(cv, sym, path+[mod]) unless const_val || path.include?(cv)
20
- end
21
- when ::Module
22
- if cv.name.start_with?('Wx::') # only search Wx namespace
23
- const_val = cv.const_get(sym) if cv.constants.include?(sym)
24
- const_val = search_nested(cv, sym, path+[mod]) unless const_val || path.include?(cv)
25
- end
26
- end unless mod == cv # watch out for infinite recursion
27
- break if const_val
10
+ org_verbose = $VERBOSE
11
+ begin
12
+ $VERBOSE = nil
13
+ mod.constants.each do |c|
14
+ case cv = mod.const_get(c)
15
+ when ::Class
16
+ if cv < Wx::Enum
17
+ # the only thing of interest in Enum classes are the enum values
18
+ const_val = cv[sym]
19
+ elsif cv.name.start_with?('Wx::') # only search Wx namespace
20
+ # prevent const_missing being triggered here since that may lead to unexpected results
21
+ const_val = cv.const_get(sym) if cv.constants.include?(sym)
22
+ const_val = search_nested(cv, sym, path+[mod]) unless const_val || path.include?(cv)
23
+ end
24
+ when ::Module
25
+ if cv.name.start_with?('Wx::') # only search Wx namespace
26
+ const_val = cv.const_get(sym) if cv.constants.include?(sym)
27
+ const_val = search_nested(cv, sym, path+[mod]) unless const_val || path.include?(cv)
28
+ end
29
+ end unless mod == cv # watch out for infinite recursion
30
+ break if const_val
31
+ end
32
+ ensure
33
+ $VERBOSE = org_verbose
28
34
  end
29
35
  const_val
30
36
  end
data/lib/wx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wx
2
- WXRUBY_VERSION = '0.9.0-beta.11'
2
+ WXRUBY_VERSION = '0.9.0-beta.14'
3
3
  end
@@ -15,24 +15,6 @@ module WxRuby
15
15
  " sampler [help]|[copy DEST]\tRun wxRuby3 Sampler application (or copy samples)."
16
16
  end
17
17
 
18
- def self.parse_args(args)
19
- opts = OptionParser.new
20
- opts.banner = "Usage: wxruby [global options] sampler [-h]|[-s PATH]\n"
21
- opts.separator ''
22
- opts.on('-s PATH', '--save=PATH',
23
- 'Save wxRuby samples under PATH.') do |v|
24
- OPTIONS[:save_path] = v.to_s
25
- end
26
- opts.on('-h', '--help',
27
- 'Show this message.') do |v|
28
- puts opts
29
- puts
30
- exit(0)
31
- end
32
- opts.raise_unknown = false
33
- opts.parse!(args)
34
- end
35
-
36
18
  def self.run(argv)
37
19
  if argv == :describe
38
20
  description
@@ -47,15 +29,15 @@ module WxRuby
47
29
  puts ' Starts the sampler application if called without arguments.'
48
30
  puts ' Otherwise shows this help for argument "help" or copies the included wxRuby'
49
31
  puts ' sample folders under the directory indicated by DEST for argument "copy DEST".'
50
- puts ' The directory indicated by DEST *must* already exist.'
32
+ puts ' The directory indicated by DEST *must* already exist.'
51
33
  puts
52
34
  elsif arg == 'copy'
53
35
  unless File.directory?(dest = argv.shift)
54
- STDERR.puts "ERROR: Invalid destination folder #{DEST}"
36
+ STDERR.puts "ERROR: Invalid destination folder #{dest}"
55
37
  exit(1)
56
38
  end
57
39
  Dir[File.join(WxRuby::ROOT, 'samples', '*')].each do |fp|
58
- FileUtils.cp_r(fp, dest, verbose: true, noop: true)
40
+ FileUtils.cp_r(fp, dest, verbose: true)
59
41
  end
60
42
  end
61
43
  end
@@ -145,11 +145,11 @@ module WXRuby3
145
145
  end
146
146
  private :do_run
147
147
 
148
- def make_ruby_cmd(*cmd)
148
+ def make_ruby_cmd(*cmd, verbose: true)
149
149
  [
150
150
  FileUtils::RUBY,
151
151
  '-I', rb_lib_path,
152
- (verbose? ? '-v' : nil),
152
+ (verbose && verbose? ? '-v' : nil),
153
153
  *cmd.flatten
154
154
  ].compact
155
155
  end
@@ -159,8 +159,8 @@ module WXRuby3
159
159
  do_run(*cmd.flatten)
160
160
  end
161
161
 
162
- def run(*cmd, capture: nil)
163
- do_run(*make_ruby_cmd(cmd), capture: capture)
162
+ def run(*cmd, capture: nil, verbose: true)
163
+ do_run(*make_ruby_cmd(cmd, verbose: verbose), capture: capture)
164
164
  end
165
165
 
166
166
  def debug_command(*args)
@@ -389,7 +389,7 @@ module WXRuby3
389
389
 
390
390
  def generate_event_types(fout, item, evts_handled)
391
391
  fout.puts " # from #{item.name}"
392
- item.event_types.each do |evt_hnd, evt_type, evt_arity, evt_klass|
392
+ item.event_types.each do |evt_hnd, evt_type, evt_arity, evt_klass, _|
393
393
  evh_name = evt_hnd.downcase
394
394
  unless evts_handled.include?(evh_name)
395
395
  evt_klass ||= item.name
@@ -463,11 +463,11 @@ module WXRuby3
463
463
  end
464
464
 
465
465
  def generate_event_doc(fdoc, item, evts_handled)
466
- item.event_types.each do |evt_hnd, evt_type, evt_arity, evt_klass|
466
+ item.event_types.each do |evt_hnd, evt_type, evt_arity, evt_klass, evt_nodoc|
467
467
  evh_name = evt_hnd.downcase
468
468
  unless evts_handled.include?(evh_name)
469
469
  evt_klass ||= item.name
470
- evh_args, evh_docstr = find_event_doc(evh_name)
470
+ evh_args, evh_docstr = evt_nodoc ? nil : find_event_doc(evh_name)
471
471
  fdoc.doc.puts evh_docstr if evh_docstr
472
472
  fdoc.doc.puts "Processes a {#{fullname}::#{evt_type}} event." unless /Process.*\s(event|command)/ =~ evh_docstr
473
473
  case evt_arity
@@ -69,7 +69,7 @@ module WXRuby3
69
69
 
70
70
  v_id = WXSTR_TO_RSTR(id);
71
71
  v_client = WXSTR_TO_RSTR(client);
72
- v_size = SWIG_NewPointerObj(SWIG_as_voidptr(&size), SWIGTYPE_p_wxSize, 0);
72
+ v_size = SWIG_NewPointerObj(new wxSize(size), SWIGTYPE_p_wxSize, 1);
73
73
  v_ret = rb_funcall(self, create_bitmap_id(), 3, v_id, v_client, v_size);
74
74
 
75
75
  if (v_ret != Qnil)
@@ -87,7 +87,7 @@ module WXRuby3
87
87
 
88
88
  v_id = WXSTR_TO_RSTR(id);
89
89
  v_client = WXSTR_TO_RSTR(client);
90
- v_size = SWIG_NewPointerObj(SWIG_as_voidptr(&size), SWIGTYPE_p_wxSize, 0);
90
+ v_size = SWIG_NewPointerObj(new wxSize(size), SWIGTYPE_p_wxSize, 1);
91
91
  v_ret = rb_funcall(self, create_bitmap_bundle_id(), 3, v_id, v_client, v_size);
92
92
 
93
93
  if (v_ret != Qnil)