wxruby3 0.9.0.pre.beta.10 → 0.9.0.pre.beta.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) 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/include/wxruby-ScaledDC.h +549 -0
  8. data/ext/wxruby3/swig/wx.i +1 -1
  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/data_object.rb +74 -6
  15. data/lib/wx/core/dataformat.rb +3 -1
  16. data/lib/wx/core/dc.rb +76 -52
  17. data/lib/wx/core/enum.rb +4 -0
  18. data/lib/wx/core/event.rb +38 -5
  19. data/lib/wx/core/evthandler.rb +64 -23
  20. data/lib/wx/core/icon.rb +50 -35
  21. data/lib/wx/core/id_helper.rb +32 -0
  22. data/lib/wx/core/image.rb +63 -53
  23. data/lib/wx/core/point.rb +35 -10
  24. data/lib/wx/core/real_point.rb +35 -10
  25. data/lib/wx/core/rect.rb +44 -9
  26. data/lib/wx/core/region_iterator.rb +37 -0
  27. data/lib/wx/core/size.rb +32 -5
  28. data/lib/wx/core/window.rb +8 -31
  29. data/lib/wx/doc/array_ext.rb +27 -0
  30. data/lib/wx/doc/art_locator.rb +57 -0
  31. data/lib/wx/doc/bitmap.rb +27 -0
  32. data/lib/wx/doc/clipboard.rb +12 -0
  33. data/lib/wx/doc/const.rb +77 -0
  34. data/lib/wx/doc/cursor.rb +16 -0
  35. data/lib/wx/doc/data_object.rb +103 -0
  36. data/lib/wx/doc/dc.rb +63 -46
  37. data/lib/wx/doc/event.rb +24 -0
  38. data/lib/wx/doc/events.rb +14 -0
  39. data/lib/wx/doc/evthandler.rb +24 -3
  40. data/lib/wx/doc/extra/00_starting.md +1 -1
  41. data/lib/wx/doc/extra/06_geometry.md +10 -4
  42. data/lib/wx/doc/extra/10_art.md +105 -0
  43. data/lib/wx/doc/gc_dc.rb +21 -0
  44. data/lib/wx/doc/gdi_common.rb +155 -6
  45. data/lib/wx/doc/graphics_context.rb +42 -0
  46. data/lib/wx/doc/icon.rb +18 -0
  47. data/lib/wx/doc/id_helper.rb +25 -0
  48. data/lib/wx/doc/image.rb +33 -0
  49. data/lib/wx/doc/region_iterator.rb +31 -0
  50. data/lib/wx/doc/scaled_dc.rb +17 -0
  51. data/lib/wx/doc/window.rb +18 -0
  52. data/lib/wx/global_const.rb +4 -3
  53. data/lib/wx/version.rb +1 -1
  54. data/lib/wx/wxruby/cmd/sampler.rb +3 -21
  55. data/rakelib/lib/config.rb +4 -4
  56. data/rakelib/lib/core/package.rb +6 -6
  57. data/rakelib/lib/core/spec.rb +2 -0
  58. data/rakelib/lib/director/art_provider.rb +2 -2
  59. data/rakelib/lib/director/busy_info.rb +9 -7
  60. data/rakelib/lib/director/clipboard.rb +1 -1
  61. data/rakelib/lib/director/colour_picker_ctrl.rb +1 -0
  62. data/rakelib/lib/director/data_object.rb +162 -0
  63. data/rakelib/lib/director/data_object_simple_base.rb +123 -0
  64. data/rakelib/lib/director/derived_dc.rb +134 -2
  65. data/rakelib/lib/director/dir_picker_ctrl.rb +1 -0
  66. data/rakelib/lib/director/event.rb +73 -8
  67. data/rakelib/lib/director/events.rb +19 -1
  68. data/rakelib/lib/director/file_picker_ctrl.rb +1 -0
  69. data/rakelib/lib/director/font_picker_ctrl.rb +1 -0
  70. data/rakelib/lib/director/gdicommon.rb +1 -3
  71. data/rakelib/lib/director/graphics_context.rb +89 -0
  72. data/rakelib/lib/director/help_controller.rb +2 -2
  73. data/rakelib/lib/director/html_data_object.rb +37 -0
  74. data/rakelib/lib/director/image.rb +55 -0
  75. data/rakelib/lib/director/region_iterator.rb +48 -0
  76. data/rakelib/lib/director/richtext_buffer.rb +1 -1
  77. data/rakelib/lib/director/richtext_buffer_data_object.rb +45 -0
  78. data/rakelib/lib/director/scroll_bar.rb +39 -0
  79. data/rakelib/lib/director/slider.rb +39 -0
  80. data/rakelib/lib/director/window.rb +36 -5
  81. data/rakelib/lib/director/window_disabler.rb +0 -7
  82. data/rakelib/lib/extractor/class.rb +1 -1
  83. data/rakelib/lib/extractor/function.rb +1 -1
  84. data/rakelib/lib/generate/doc.rb +26 -6
  85. data/rakelib/lib/specs/interfaces.rb +8 -1
  86. data/rakelib/lib/typemap/common.rb +1 -1
  87. data/rakelib/lib/typemap/data_object_data.rb +13 -4
  88. data/rakelib/lib/util/string.rb +29 -8
  89. data/samples/art/wxruby-128x128.png +0 -0
  90. data/samples/art/wxruby-256x256.png +0 -0
  91. data/samples/art/wxruby-64x64.png +0 -0
  92. data/samples/art/wxruby.ico +0 -0
  93. data/samples/art/wxruby.png +0 -0
  94. data/samples/drawing/graphics_drawing.rb +1 -2
  95. data/samples/propgrid/propgrid.rb +65 -65
  96. data/samples/sample.xpm +246 -470
  97. data/samples/treectrl/treectrl.rb +1 -1
  98. data/tests/art/my_art/sample.xpm +251 -0
  99. data/tests/art/sample3.xpm +251 -0
  100. data/tests/art/test_art/bitmap/sample.xpm +251 -0
  101. data/tests/art/test_art/bitmap/wxruby.bmp +0 -0
  102. data/tests/art/test_art/bitmap/wxruby.png +0 -0
  103. data/tests/art/test_art/bitmap/wxruby.xpm +251 -0
  104. data/tests/art/test_art/cursor/wxruby.bmp +0 -0
  105. data/tests/art/test_art/icon/sample.xpm +251 -0
  106. data/tests/art/test_art/icon/wxruby.ico +0 -0
  107. data/tests/art/test_art/icon/wxruby.png +0 -0
  108. data/tests/art/test_art/image/sample.xpm +251 -0
  109. data/tests/art/test_art/image/wxruby.jpg +0 -0
  110. data/tests/art/test_art/image/wxruby.png +0 -0
  111. data/tests/art/test_art/sample2.xpm +251 -0
  112. data/tests/lib/wxapp_runner.rb +64 -0
  113. data/tests/test_art.rb +91 -0
  114. data/tests/test_basic.rb +0 -5
  115. data/tests/test_clipboard.rb +149 -17
  116. data/tests/test_dc.rb +70 -0
  117. data/tests/test_dialog.rb +2 -13
  118. data/tests/test_event_handling.rb +2 -13
  119. data/tests/test_events.rb +14 -6
  120. data/tests/test_geometry.rb +67 -17
  121. data/tests/test_intl.rb +2 -15
  122. data/tests/test_item_data.rb +2 -15
  123. data/tests/test_variant.rb +1 -15
  124. data/tests/testapp.rb +0 -5
  125. data/tests/testapp_noframe.rb +0 -5
  126. metadata +56 -5
@@ -0,0 +1,32 @@
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
+ def self.included(base)
21
+ base.singleton_class.class_eval do
22
+ def next_id(offset = nil)
23
+ # set the offset if @next_id still unset or a user defined offset has been specified
24
+ @next_id = (offset || Wx::ID_HIGHEST) if @next_id.nil? || offset
25
+ @next_id += 1 # increment and return next id
26
+ end
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+ end
data/lib/wx/core/image.rb CHANGED
@@ -1,68 +1,78 @@
1
1
  # A platform-independent image; can be manipulated more extensively than
2
2
  # Bitmap, but must be converted to a Bitmap for drawing.
3
- class Wx::Image
3
+ module Wx
4
+ class Image
4
5
 
5
- # restore the overloaded method
6
- def set_rgb_data(data, *size)
7
- if size.empty?
8
- height = self.get_size.height
9
- width = self.get_size.width
10
- else
11
- width, height = size
12
- if Wx::Size === width
13
- height = width.height
14
- width = width.width
6
+ # restore the overloaded method
7
+ def set_rgb_data(data, *size)
8
+ if size.empty?
9
+ height = self.get_size.height
10
+ width = self.get_size.width
11
+ else
12
+ width, height = size
13
+ if Wx::Size === width
14
+ height = width.height
15
+ width = width.width
16
+ end
15
17
  end
18
+ set_rgb_data_with_size(data, width, height)
16
19
  end
17
- set_rgb_data_with_size(data, width, height)
18
- end
19
20
 
20
- # alias for backward compatibility
21
- alias :get_data :get_rgb_data
22
- alias :set_data :set_rgb_data
23
-
24
- # Load the type-guessing hash from Wx::Bitmap
25
- require_relative './bitmap'
26
- BITMAP_TYPE_GUESS = Wx::Bitmap::BITMAP_TYPE_GUESS
21
+ # alias for backward compatibility
22
+ alias :get_data :get_rgb_data
23
+ alias :set_data :set_rgb_data
27
24
 
28
- # Load a new image from an IO-like object that supports "read"
29
- def self.read(an_io, type_or_mime, index = -1)
30
- img = new
31
- img.load_stream(an_io, type_or_mime, index)
32
- img
33
- end
25
+ # Load the type-guessing hash from Wx::Bitmap
26
+ require_relative './bitmap'
27
+ BITMAP_TYPE_GUESS = Wx::Bitmap::BITMAP_TYPE_GUESS
34
28
 
35
- # Create a new image from Wx::Bitmap, preserving mask information
36
- def self.from_bitmap(bmp)
37
- bmp.convert_to_image
38
- end
29
+ # Load a new image from an IO-like object that supports "read"
30
+ def self.read(an_io, type_or_mime, index = -1)
31
+ img = new
32
+ img.load_stream(an_io, type_or_mime, index)
33
+ img
34
+ end
39
35
 
40
- # Ruby methods that switch class are conventionally named to_foo
41
- def to_bitmap
42
- Wx::Bitmap.from_image(self)
43
- end
36
+ # Create a new image from Wx::Bitmap, preserving mask information
37
+ def self.from_bitmap(bmp)
38
+ bmp.convert_to_image
39
+ end
44
40
 
45
- # Redefine the initialize method so it raises an exception if a
46
- # non-existent file is given to the constructor; otherwise, wx Widgets
47
- # just carries on with an invalid image, which may cause faults
48
- # later. Also, if loading from a file, and the type is not specified,
49
- # try to guess it from the filename extension
50
- wx_init = self.instance_method(:initialize)
51
- define_method(:initialize) do | *args |
52
- if args[0].kind_of? String
53
- if not File.exist?( File.expand_path(args[0]) )
54
- Kernel.raise(ArgumentError, "Image file does not exist: #{args[0]}")
55
- end
56
- # If type not specified, try to guess it from the file extension
57
- if not args[1] and file_ext = args[0][/\w+$/]
58
- args[1] = BITMAP_TYPE_GUESS[file_ext.downcase]
41
+ # Ruby methods that switch class are conventionally named to_foo
42
+ def to_bitmap
43
+ Wx::Bitmap.from_image(self)
44
+ end
45
+
46
+ # Redefine the initialize method so it raises an exception if a
47
+ # non-existent file is given to the constructor; otherwise, wx Widgets
48
+ # just carries on with an invalid image, which may cause faults
49
+ # later. Also, if loading from a file, and the type is not specified,
50
+ # try to guess it from the filename extension
51
+ wx_init = self.instance_method(:initialize)
52
+ define_method(:initialize) do | *args |
53
+ if args[0].kind_of? String
54
+ if not File.exist?( File.expand_path(args[0]) )
55
+ Kernel.raise(ArgumentError, "Image file does not exist: #{args[0]}")
56
+ end
57
+ # If type not specified, try to guess it from the file extension
58
+ if not args[1] and file_ext = args[0][/\w+$/]
59
+ args[1] = BITMAP_TYPE_GUESS[file_ext.downcase]
60
+ end
59
61
  end
62
+ wx_init.bind(self).call(*args)
63
+ end
64
+
65
+ # Convert to bitmap
66
+ def convert_to_bitmap
67
+ Wx::Bitmap.from_image(self)
60
68
  end
61
- wx_init.bind(self).call(*args)
62
69
  end
63
-
64
- # Convert to bitmap
65
- def convert_to_bitmap
66
- Wx::Bitmap.from_image(self)
70
+
71
+ def self.Image(name, bmp_type = nil, *rest)
72
+ art_path = File.dirname(caller_path = caller_locations(1).first.absolute_path)
73
+ art_owner = File.basename(caller_path, '.*')
74
+ art_file = ArtLocator.find_art(name, art_type: :image, art_path: art_path, art_section: art_owner, bmp_type: bmp_type)
75
+ ::Kernel.raise ArgumentError, "Cannot locate art file for #{name}:Image" unless art_file
76
+ Image.new(art_file, bmp_type, *rest)
67
77
  end
68
78
  end
data/lib/wx/core/point.rb CHANGED
@@ -1,4 +1,7 @@
1
1
  class Wx::Point
2
+
3
+ include Comparable
4
+
2
5
  # More informative output when converted to string
3
6
  def to_s
4
7
  "#<Wx::Point: (#{x}, #{y})>"
@@ -16,23 +19,26 @@ class Wx::Point
16
19
  alias :get_x :x
17
20
  alias :get_y :y
18
21
 
19
- # Compare point values
20
- def ==(other)
21
- if Wx::Point === other
22
+ # Correct comparison for Points - same if same x and y
23
+ def eql?(other)
24
+ if other.instance_of?(self.class)
22
25
  x == other.x and y == other.y
23
- elsif Array === other && other.size == 2
24
- to_ary == other
25
26
  else
26
- Kernel.raise TypeError, "Cannot compare Point to #{other}"
27
+ false
27
28
  end
28
29
  end
29
30
 
30
- # Correct comparison for Points - same if same x and y
31
- def eql?(other)
31
+ def hash
32
+ to_ary.hash
33
+ end
34
+
35
+ def <=>(other)
32
36
  if Wx::Point === other
33
- x == other.x and y == other.y
37
+ (x*y) <=> (other.x*other.y)
38
+ elsif Array === other && other.size == 2
39
+ (x*y) <=> (other.first.to_i*other.last.to_i)
34
40
  else
35
- false
41
+ nil
36
42
  end
37
43
  end
38
44
 
@@ -89,4 +95,23 @@ class Wx::Point
89
95
  end
90
96
  end
91
97
  end
98
+
99
+ def to_real_point
100
+ Wx::RealPoint.new(self.x.to_f, self.y.to_f)
101
+ end
102
+ alias :to_real :to_real_point
103
+
104
+ def to_point
105
+ self
106
+ end
107
+
108
+ def dup
109
+ Wx::Point.new(self.x, self.y)
110
+ end
111
+
112
+ def assign(pt)
113
+ self.x = pt.x
114
+ self.y = pt.y
115
+ self
116
+ end
92
117
  end
@@ -1,4 +1,7 @@
1
1
  class Wx::RealPoint
2
+
3
+ include Comparable
4
+
2
5
  # More informative output when converted to string
3
6
  def to_s
4
7
  "#<Wx::RealPoint: (#{x}, #{y})>"
@@ -16,23 +19,26 @@ class Wx::RealPoint
16
19
  alias :get_x :x
17
20
  alias :get_y :y
18
21
 
19
- # Compare point values
20
- def ==(other)
21
- if Wx::RealPoint === other
22
+ # Correct comparison for RealPoints - same if same x and y
23
+ def eql?(other)
24
+ if other.instance_of?(self.class)
22
25
  x == other.x and y == other.y
23
- elsif Array === other && other.size == 2
24
- to_ary == other
25
26
  else
26
- Kernel.raise TypeError, "Cannot compare RealPoint to #{other}"
27
+ false
27
28
  end
28
29
  end
29
30
 
30
- # Correct comparison for RealPoints - same if same x and y
31
- def eql?(other)
31
+ def hash
32
+ to_ary.hash
33
+ end
34
+
35
+ def <=>(other)
32
36
  if Wx::RealPoint === other
33
- x == other.x and y == other.y
37
+ (x*y) <=> (other.x*other.y)
38
+ elsif Array === other && other.size == 2
39
+ (x*y) <=> (other.first.to_f*other.last.to_f)
34
40
  else
35
- false
41
+ nil
36
42
  end
37
43
  end
38
44
 
@@ -89,4 +95,23 @@ class Wx::RealPoint
89
95
  end
90
96
  end
91
97
  end
98
+
99
+ def to_point
100
+ Wx::Point.new(self.x.to_i, self.y.to_i)
101
+ end
102
+
103
+ def to_real_point
104
+ self
105
+ end
106
+
107
+ def dup
108
+ Wx::RealPoint.new(self.x, self.y)
109
+ end
110
+
111
+ def assign(pt)
112
+ self.x = pt.x
113
+ self.y = pt.y
114
+ self
115
+ end
116
+
92
117
  end
data/lib/wx/core/rect.rb CHANGED
@@ -23,12 +23,12 @@ class Wx::Rect
23
23
  elsif Array === other && other.size == 4
24
24
  to_ary == other
25
25
  else
26
- Kernel.raise TypeError, "Cannot compare Rect to #{other}"
26
+ false
27
27
  end
28
28
  end
29
29
 
30
30
  def eql?(other)
31
- if Wx::Rect === other
31
+ if other.instance_of?(self.class)
32
32
  left == other.left and top == other.top and
33
33
  width == other.width and height == other.height
34
34
  else
@@ -36,15 +36,40 @@ class Wx::Rect
36
36
  end
37
37
  end
38
38
 
39
- # make sure union and intersect are constant operations, i.e. not changing self
40
- wx_union = instance_method :union
41
- define_method :union do |rect|
42
- wx_union.bind(Wx::Rect.new(*self.to_ary)).call(rect)
39
+ # provide both constant and non-constant versions of union/intersect/inflate/deflate/offset
40
+
41
+ # first alias the wrapped (non-constant) versions with correct names
42
+ alias :union! :union
43
+ alias :intersect! :intersect
44
+ alias :inflate! :inflate
45
+ alias :deflate! :deflate
46
+
47
+ # redefine offset as offset! returning self
48
+ wx_offset = instance_method :offset
49
+ define_method :offset! do |*args|
50
+ wx_offset.bind(self).call(*args)
51
+ self
52
+ end
53
+
54
+ # next provide new constant versions
55
+ def offset(*args)
56
+ self.dup.offset!(*args)
57
+ end
58
+
59
+ def union(rect)
60
+ self.dup.union!(rect)
43
61
  end
44
62
 
45
- wx_intersect = instance_method :intersect
46
- define_method :intersect do |rect|
47
- wx_intersect.bind(Wx::Rect.new(*self.to_ary)).call(rect)
63
+ def intersect(rect)
64
+ self.dup.intersect!(rect)
65
+ end
66
+
67
+ def inflate(*args)
68
+ self.dup.inflate!(*args)
69
+ end
70
+
71
+ def deflate(*args)
72
+ self.dup.deflate!(*args)
48
73
  end
49
74
 
50
75
  alias :+ :add
@@ -54,4 +79,14 @@ class Wx::Rect
54
79
 
55
80
  # More ruby-ish names
56
81
  alias :contains? :contains
82
+
83
+ def dup
84
+ Wx::Rect.new(self.x, self.y, self.width, self.height)
85
+ end
86
+
87
+ def assign(rct)
88
+ self.position = rct.position
89
+ self.size = rct.size
90
+ self
91
+ end
57
92
  end
@@ -0,0 +1,37 @@
1
+
2
+ class Wx::RegionIterator
3
+
4
+ alias :have_rects? :have_rects
5
+
6
+ # Ruby like enumeration
7
+ def each
8
+ if block_given?
9
+ while have_rects
10
+ yield get_rect
11
+ next_rect
12
+ end
13
+ else
14
+ # The region iterator instance cannot be allowed to exist beyond the outer
15
+ # Wx::RegionIterator.for_region block as it is a temporary instance that
16
+ # will stop to exist when the outer block finishes, so we collect the rectangles
17
+ # here and return an enumerator on that
18
+ arr = []
19
+ while has_rects
20
+ arr << get_rect
21
+ next_rect
22
+ end
23
+ arr.each
24
+ end
25
+ end
26
+
27
+ def self.iterate(region, &block)
28
+ return unless block
29
+ for_region(region) do |ri|
30
+ while ri.have_rects
31
+ block.call(ri)
32
+ ri.next_rect
33
+ end
34
+ end
35
+ end
36
+
37
+ end
data/lib/wx/core/size.rb CHANGED
@@ -1,4 +1,13 @@
1
1
  class Wx::Size
2
+
3
+ include Comparable
4
+
5
+ # provide compatibility methods
6
+ alias :get_x :get_width
7
+ alias :x :get_width
8
+ alias :get_y :get_height
9
+ alias :y :get_height
10
+
2
11
  # More informative output for inspect etc
3
12
  def to_s
4
13
  "#<Wx::Size: #{width}x#{height}>"
@@ -14,24 +23,28 @@ class Wx::Size
14
23
  end
15
24
 
16
25
  # Compare with another size value
17
- def ==(other)
26
+ def <=>(other)
18
27
  if Wx::Size === other
19
- width == other.width and height == other.height
28
+ (width*height) <=> (other.width*other.height)
20
29
  elsif Array === other and other.size == 2
21
- to_ary == other
30
+ (width*height) <=> (other.first*other.last)
22
31
  else
23
- Kernel.raise TypeError, "Cannot compare Size to #{other}"
32
+ nil
24
33
  end
25
34
  end
26
35
 
27
36
  def eql?(other)
28
- if Wx::Size === other
37
+ if other.instance_of?(self.class)
29
38
  width == other.width and height == other.height
30
39
  else
31
40
  false
32
41
  end
33
42
  end
34
43
 
44
+ def hash
45
+ to_ary.hash
46
+ end
47
+
35
48
  # Return a new Wx::Size with the width and height values both divided
36
49
  # by parameter +num+, which should be a Numeric
37
50
  def /(num)
@@ -83,4 +96,18 @@ class Wx::Size
83
96
  end
84
97
  end
85
98
  end
99
+
100
+ def dup
101
+ Wx::Size.new(self.width, self.height)
102
+ end
103
+
104
+ def to_size
105
+ self
106
+ end
107
+
108
+ def assign(sz)
109
+ self.width = sz.width
110
+ self.height = sz.height
111
+ self
112
+ end
86
113
  end
@@ -53,43 +53,20 @@ class Wx::Window
53
53
  def evt_paint(meth = nil, &block)
54
54
  paint_proc = acquire_handler(meth, block)
55
55
  wrapped_block = proc do | event |
56
- instance_variable_set("@__painting__", true)
56
+ instance_variable_set('@__painting__', true)
57
57
  paint_proc.call(event)
58
- remove_instance_variable("@__painting__")
58
+ remove_instance_variable('@__painting__')
59
59
  end
60
60
  __old_evt_paint(&wrapped_block)
61
61
  end
62
62
 
63
- # Provides bufferd drawing facility to reduce flicker for complex
64
- # drawing commands. Works similar to BufferedDC and BufferedPaintDC in
65
- # the wxWidgets API, by doing drawing on an in-memory Bitmap, then
66
- # copying the result in bulk to the screen.
67
- #
68
- # The method may be passed an existing Wx::Bitmap as the +buffer+,
69
- # otherwise one will be created.
70
- #
71
- # Works like wxAutoBufferedDC in that additional buffering will only
72
- # be done on platforms that do not already natively support buffering
73
- # for the standard PaintDC / ClientDC - Windows, in particular.
74
- def paint_buffered(buffer = nil)
75
- # OS X and GTK do double-buffering natively
76
- if self.double_buffered?
77
- paint { | dc | yield dc }
63
+ # Overload the wrapper method to check for @__painting__
64
+ wx_paint_buffered = instance_method :paint_buffered
65
+ define_method :paint_buffered do |&block|
66
+ if instance_variable_defined?('@__painting__')
67
+ wx_paint_buffered.bind(self).call(&block)
78
68
  else
79
- # client_size is the window area available for drawing upon
80
- c_size = client_size
81
- # Create an in-memory buffer if none supplied
82
- buffer ||= Wx::Bitmap.new(c_size.width, c_size.height)
83
- buffer.draw do | mem_dc |
84
- mem_dc.background = Wx::TRANSPARENT_BRUSH
85
- mem_dc.clear
86
- # Yield the bitmap for the user code to draw upon
87
- yield mem_dc
88
- paint do | dc |
89
- # Copy the buffer to the window
90
- dc.blit(0, 0, c_size.width, c_size.height, mem_dc, 0, 0)
91
- end
92
- end
69
+ self.paint(&block)
93
70
  end
94
71
  end
95
72
  end
@@ -0,0 +1,27 @@
1
+
2
+ module Wx
3
+
4
+ # Mixin module providing Array extensions.
5
+ module ArrayExt
6
+
7
+ # Returns a new Wx::Size instance created from the first two elements of the array.
8
+ # Any missing element will be supplemented by a Wx::DEFAULT_COORD value.
9
+ # The array is not altered.
10
+ # @return [Wx::Size]
11
+ def to_size; end
12
+
13
+ # Returns a new Wx::Point instance created from the first two elements of the array.
14
+ # Any missing element will be supplemented by a Wx::DEFAULT_COORD value.
15
+ # The array is not altered.
16
+ # @return [Wx::Point]
17
+ def to_point; end
18
+
19
+ # Returns a new Wx::RealPoint instance created from the first two elements of the array.
20
+ # Any missing element will be supplemented by a Wx::DEFAULT_COORD value.
21
+ # The array is not altered.
22
+ # @return [Wx::RealPoint]
23
+ def to_real_point; end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,57 @@
1
+
2
+
3
+ # This module provides and standardizes support for locating application art files.
4
+ #
5
+ module Wx::ArtLocator
6
+
7
+ # Default name of art folder.
8
+ ART_FOLDER = 'art'
9
+
10
+ class << self
11
+
12
+ # Returns the base name for the folder holding application art files.
13
+ # By default this returns ART_FOLDER
14
+ # @return [String]
15
+ def art_folder; end
16
+
17
+ # Sets the base name for the folder holding application art files.
18
+ # @param [String] name art folder base name
19
+ def art_folder=(name) end
20
+
21
+ # Adds one or more search paths to look for art files.
22
+ # By default ArtLocator#find_art will look only at locations of the caller's
23
+ # file path. If search paths have been added though these will be searched
24
+ # after the lookup in the caller's path has failed.
25
+ def add_search_path(*names) end
26
+ alias :add_search_paths :add_search_path
27
+
28
+ # Searches for the an art file for the given 'art_name'.
29
+ # By default the search will be performed at the following locations (in order):
30
+ # 1. <art_path>/<#art_folder>/<art_section>/<art_type>/
31
+ # 2. <art_path>/<#art_folder>/<art_section>/
32
+ # 3. <art_path>/<#art_folder>/
33
+ # 4. <art_path>/
34
+ # Where 'art_type' is any of <code>:icon</code>, <code>:bitmap</code>, <code>:cursor</code>,
35
+ # <code>:image</code> or <code>nil</code>. If 'art_type' is nil the first location will be skipped.
36
+ # In case 'art_path' == <code>nil</code> the absolute path to the folder holding the caller's
37
+ # code will be used which is determined through ::Kernel#caller_locations.
38
+ # If 'art_section' is also <code>nil</code> the basename of the caller's source file will be used.
39
+ # At each location the existence of a file with base name 'art_name' and each of the supported
40
+ # extensions for the given 'art_type' (see wxWidgets documentation) will be tested. If 'art_type' is nil
41
+ # all extensions for all supported bitmap types will be tested (similar to when 'art_type' is :image).
42
+ # If an optional Wx::BitmapType is specified through 'bmp_type' the tested extensions will
43
+ # be restricted to the extensions supported for specified the bitmap type.
44
+ #
45
+ # In case additional search paths have been specified through #add_search_path these will be
46
+ # searched after the lookup at 'art_path' fails. For each search path the same lookups
47
+ # will be performed (replacing 'art_path' by the search path).
48
+ # @param [String,Symbol] art_name base name for art file
49
+ # @param [Symbol,nil] art_type type of art to look for (:icon, :bitmap, :cursor, :image)
50
+ # @param [String,nil] art_path base path to look up the art file
51
+ # @param [String,nil] art_section optional owner folder name for art files
52
+ # @param [Wx::BitmapType,nil] bmp_type bitmap type of art file
53
+ def find_art(art_name, art_type: nil, art_path: nil, art_section: nil, bmp_type: nil) end
54
+
55
+ end
56
+
57
+ end
@@ -0,0 +1,27 @@
1
+
2
+ module Wx
3
+
4
+ # Default BitmapType for current platform. Actual value is platform dependent.
5
+ ICON_DEFAULT_TYPE = Wx::BitmapType::BITMAP_TYPE_ANY
6
+ # Default BitmapType for current platform. Actual value is platform dependent.
7
+ BITMAP_DEFAULT_TYPE = Wx::BitmapType::BITMAP_TYPE_ANY
8
+ # Default BitmapType for current platform. Actual value is platform dependent.
9
+ CURSOR_DEFAULT_TYPE = Wx::BitmapType::BITMAP_TYPE_ANY
10
+
11
+ class Bitmap
12
+
13
+ # Searches for an art file with basename 'name' and creates a Bitmap if found.
14
+ # Raises an ArgumentError if not found.
15
+ # Wx::ArtLocator::find_art is used to look up the art file using ::Kernel#caller_locations to
16
+ # determine the values for the 'art_path' and 'art_owner' arguments ('art_path' is set to the
17
+ # absolute path to the folder holding the caller's code and 'art_owner' to the basename of the
18
+ # caller's source file). The 'art_type' argument is set to <code>:icon</code>.
19
+ # @param [String,Symbol] name base name of art file
20
+ # @param [Wx::BitmapType,nil] bmp_type bitmap type for art file (nil means any supported type)
21
+ # @return [Wx::Bitmap]
22
+ # @see Wx::ArtLocator::find_art
23
+ def self.Bitmap(name, bmp_type = nil); end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,12 @@
1
+
2
+ class Wx::Clipboard
3
+
4
+ alias :place :set_data
5
+ alias :fetch :get_data
6
+
7
+ # Opens the global clipboard and passes the clipboard object to the block.
8
+ # @yieldparam [Wx::Clipboard] clip the global clipboard object
9
+ # @return [Object] block result
10
+ def self.open; end
11
+
12
+ end