shoes-swt 4.0.0.pre2 → 4.0.0.pre3

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 (227) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -200
  3. data/Rakefile +1 -0
  4. data/bin/shoes-swt +11 -0
  5. data/lib/shoes/swt.rb +5 -2
  6. data/lib/shoes/swt/animation.rb +2 -2
  7. data/lib/shoes/swt/app.rb +45 -50
  8. data/lib/shoes/swt/arc.rb +7 -7
  9. data/lib/shoes/swt/background.rb +1 -1
  10. data/lib/shoes/swt/border.rb +1 -2
  11. data/lib/shoes/swt/click_listener.rb +70 -0
  12. data/lib/shoes/swt/color.rb +5 -5
  13. data/lib/shoes/swt/common/clickable.rb +2 -53
  14. data/lib/shoes/swt/common/fill.rb +1 -1
  15. data/lib/shoes/swt/common/painter.rb +7 -7
  16. data/lib/shoes/swt/common/painter_updates_position.rb +2 -2
  17. data/lib/shoes/swt/common/remove.rb +2 -3
  18. data/lib/shoes/swt/common/resource.rb +1 -1
  19. data/lib/shoes/swt/common/selection_listener.rb +14 -14
  20. data/lib/shoes/swt/common/stroke.rb +1 -2
  21. data/lib/shoes/swt/common/update_position.rb +1 -1
  22. data/lib/shoes/swt/dialog.rb +3 -45
  23. data/lib/shoes/swt/disposed_protection.rb +1 -1
  24. data/lib/shoes/swt/download.rb +0 -1
  25. data/lib/shoes/swt/font.rb +4 -4
  26. data/lib/shoes/swt/generate-backend.rb +9 -0
  27. data/lib/shoes/swt/gradient.rb +17 -16
  28. data/lib/shoes/swt/image.rb +3 -5
  29. data/lib/shoes/swt/image_pattern.rb +2 -2
  30. data/lib/shoes/swt/input_box.rb +3 -3
  31. data/lib/shoes/swt/key_listener.rb +6 -6
  32. data/lib/shoes/swt/line.rb +4 -24
  33. data/lib/shoes/swt/link.rb +2 -2
  34. data/lib/shoes/swt/link_segment.rb +3 -3
  35. data/lib/shoes/swt/list_box.rb +4 -4
  36. data/lib/shoes/swt/mouse_move_listener.rb +6 -5
  37. data/lib/shoes/swt/oval.rb +2 -3
  38. data/lib/shoes/swt/packager.rb +82 -0
  39. data/lib/shoes/swt/progress.rb +2 -2
  40. data/lib/shoes/swt/radio.rb +0 -2
  41. data/lib/shoes/swt/radio_group.rb +54 -54
  42. data/lib/shoes/swt/rect_painter.rb +7 -7
  43. data/lib/shoes/swt/redrawing_aspect.rb +32 -34
  44. data/lib/shoes/swt/shape.rb +1 -1
  45. data/lib/shoes/swt/shoes_layout.rb +5 -2
  46. data/lib/shoes/swt/slot.rb +2 -3
  47. data/lib/shoes/swt/sound.rb +17 -22
  48. data/lib/shoes/swt/star.rb +30 -8
  49. data/lib/shoes/swt/swt_button.rb +3 -2
  50. data/lib/shoes/swt/text_block.rb +3 -3
  51. data/lib/shoes/swt/text_block/cursor_painter.rb +2 -2
  52. data/lib/shoes/swt/text_block/fitter.rb +5 -3
  53. data/lib/shoes/swt/text_block/painter.rb +9 -9
  54. data/lib/shoes/swt/text_block/text_font_factory.rb +3 -3
  55. data/lib/shoes/swt/text_block/text_segment.rb +9 -9
  56. data/lib/shoes/swt/text_block/text_segment_collection.rb +2 -0
  57. data/lib/shoes/swt/text_block/text_style_factory.rb +9 -3
  58. data/lib/shoes/swt/timer.rb +1 -1
  59. data/lib/shoes/swt/version.rb +1 -1
  60. data/shoes-swt.gemspec +7 -6
  61. data/spec/shoes/cli_spec.rb +2 -2
  62. data/spec/{swt_shoes → shoes/swt}/animation_spec.rb +1 -1
  63. data/spec/{swt_shoes → shoes/swt}/app_spec.rb +36 -3
  64. data/spec/{swt_shoes → shoes/swt}/arc_spec.rb +1 -1
  65. data/spec/{swt_shoes → shoes/swt}/background_spec.rb +1 -1
  66. data/spec/{swt_shoes → shoes/swt}/border_spec.rb +1 -1
  67. data/spec/{swt_shoes → shoes/swt}/button_spec.rb +1 -1
  68. data/spec/{swt_shoes → shoes/swt}/check_spec.rb +1 -1
  69. data/spec/shoes/swt/click_listener_spec.rb +162 -0
  70. data/spec/{swt_shoes → shoes/swt}/color_factory_spec.rb +1 -1
  71. data/spec/{swt_shoes → shoes/swt}/color_spec.rb +1 -1
  72. data/spec/{swt_shoes → shoes/swt}/common/painter_spec.rb +1 -1
  73. data/spec/{swt_shoes → shoes/swt}/common/remove_spec.rb +4 -11
  74. data/spec/{swt_shoes → shoes/swt}/configuration_spec.rb +1 -1
  75. data/spec/{swt_shoes → shoes/swt}/dialog_spec.rb +1 -7
  76. data/spec/{swt_shoes → shoes/swt}/disposed_protection_spec.rb +0 -0
  77. data/spec/{swt_shoes → shoes/swt}/flow_spec.rb +1 -1
  78. data/spec/{swt_shoes → shoes/swt}/font_spec.rb +1 -1
  79. data/spec/{swt_shoes → shoes/swt}/gradient_spec.rb +1 -1
  80. data/spec/{swt_shoes → shoes/swt}/image_pattern_spec.rb +1 -1
  81. data/spec/{swt_shoes → shoes/swt}/image_spec.rb +4 -3
  82. data/spec/{swt_shoes → shoes/swt}/input_box_spec.rb +1 -1
  83. data/spec/{swt_shoes → shoes/swt}/integration_spec.rb +1 -1
  84. data/spec/{swt_shoes → shoes/swt}/key_listener_spec.rb +1 -1
  85. data/spec/{swt_shoes → shoes/swt}/line_spec.rb +4 -8
  86. data/spec/{swt_shoes → shoes/swt}/link_segment_spec.rb +1 -1
  87. data/spec/{swt_shoes → shoes/swt}/link_spec.rb +3 -10
  88. data/spec/{swt_shoes → shoes/swt}/list_box_spec.rb +5 -3
  89. data/spec/{swt_shoes → shoes/swt}/minimal.png +0 -0
  90. data/spec/{swt_shoes → shoes/swt}/mouse_move_listener_spec.rb +1 -1
  91. data/spec/{swt_shoes → shoes/swt}/oval_spec.rb +1 -1
  92. data/spec/{swt_shoes → shoes/swt}/progress_spec.rb +1 -1
  93. data/spec/{swt_shoes → shoes/swt}/radio_group_spec.rb +1 -1
  94. data/spec/{swt_shoes → shoes/swt}/radio_spec.rb +1 -1
  95. data/spec/{swt_shoes → shoes/swt}/rect_painter_spec.rb +1 -1
  96. data/spec/{swt_shoes → shoes/swt}/rect_spec.rb +1 -1
  97. data/spec/{swt_shoes → shoes/swt}/shape_spec.rb +1 -1
  98. data/spec/{swt_shoes → shoes/swt}/shared_examples/button.rb +0 -0
  99. data/spec/shoes/swt/shared_examples/clickable.rb +13 -0
  100. data/spec/{swt_shoes → shoes/swt}/shared_examples/movable.rb +0 -0
  101. data/spec/{swt_shoes → shoes/swt}/shared_examples/paintable.rb +0 -0
  102. data/spec/{swt_shoes → shoes/swt}/shared_examples/painter.rb +0 -0
  103. data/spec/{swt_shoes → shoes/swt}/shared_examples/pattern.rb +0 -0
  104. data/spec/{swt_shoes → shoes/swt}/shared_examples/removable.rb +1 -3
  105. data/spec/{swt_shoes → shoes/swt}/shared_examples/swt_app_context.rb +11 -3
  106. data/spec/{swt_shoes → shoes/swt}/shared_examples/visibility.rb +0 -0
  107. data/spec/{swt_shoes → shoes/swt}/shell_control_listener_spec.rb +1 -1
  108. data/spec/{swt_shoes → shoes/swt}/slot_spec.rb +1 -1
  109. data/spec/{swt_shoes → shoes/swt}/spec_helper.rb +0 -1
  110. data/spec/{swt_shoes → shoes/swt}/star_spec.rb +1 -1
  111. data/spec/{swt_shoes → shoes/swt}/text_block/centered_text_segment_spec.rb +1 -1
  112. data/spec/{swt_shoes → shoes/swt}/text_block/cursor_painter_spec.rb +8 -4
  113. data/spec/{swt_shoes → shoes/swt}/text_block/fitter_spec.rb +5 -5
  114. data/spec/{swt_shoes → shoes/swt}/text_block/painter_spec.rb +1 -1
  115. data/spec/{swt_shoes → shoes/swt}/text_block/text_font_factory_spec.rb +1 -1
  116. data/spec/{swt_shoes → shoes/swt}/text_block/text_segment_collection_spec.rb +7 -2
  117. data/spec/{swt_shoes → shoes/swt}/text_block/text_segment_spec.rb +1 -1
  118. data/spec/{swt_shoes → shoes/swt}/text_block_spec.rb +2 -5
  119. data/spec/spec_helper.rb +7 -3
  120. metadata +132 -331
  121. data/CHANGELOG +0 -84
  122. data/Gemfile +0 -24
  123. data/Guardfile +0 -11
  124. data/manifests/common.rb +0 -34
  125. data/manifests/shoes-swt.rb +0 -29
  126. data/spec/code_coverage.rb +0 -14
  127. data/spec/shoes/animation_spec.rb +0 -65
  128. data/spec/shoes/app_spec.rb +0 -484
  129. data/spec/shoes/arc_spec.rb +0 -51
  130. data/spec/shoes/background_spec.rb +0 -53
  131. data/spec/shoes/border_spec.rb +0 -47
  132. data/spec/shoes/builtin_methods_spec.rb +0 -110
  133. data/spec/shoes/button_spec.rb +0 -44
  134. data/spec/shoes/check_spec.rb +0 -35
  135. data/spec/shoes/color_spec.rb +0 -408
  136. data/spec/shoes/common/inspect_spec.rb +0 -26
  137. data/spec/shoes/common/remove_spec.rb +0 -38
  138. data/spec/shoes/common/style_normalizer_spec.rb +0 -28
  139. data/spec/shoes/common/style_spec.rb +0 -147
  140. data/spec/shoes/configuration_spec.rb +0 -36
  141. data/spec/shoes/constants_spec.rb +0 -38
  142. data/spec/shoes/dialog_spec.rb +0 -163
  143. data/spec/shoes/dimension_spec.rb +0 -407
  144. data/spec/shoes/dimensions_spec.rb +0 -837
  145. data/spec/shoes/download_spec.rb +0 -142
  146. data/spec/shoes/flow_spec.rb +0 -133
  147. data/spec/shoes/font_spec.rb +0 -37
  148. data/spec/shoes/framework_learning_spec.rb +0 -30
  149. data/spec/shoes/gradient_spec.rb +0 -32
  150. data/spec/shoes/helpers/fake_element.rb +0 -17
  151. data/spec/shoes/helpers/inspect_helpers.rb +0 -5
  152. data/spec/shoes/helpers/sample17_helper.rb +0 -66
  153. data/spec/shoes/image_spec.rb +0 -49
  154. data/spec/shoes/images/shoe.jpg +0 -0
  155. data/spec/shoes/input_box_spec.rb +0 -80
  156. data/spec/shoes/integration_spec.rb +0 -20
  157. data/spec/shoes/internal_app_spec.rb +0 -141
  158. data/spec/shoes/keypress_spec.rb +0 -11
  159. data/spec/shoes/keyrelease_spec.rb +0 -12
  160. data/spec/shoes/line_spec.rb +0 -49
  161. data/spec/shoes/link_spec.rb +0 -105
  162. data/spec/shoes/list_box_spec.rb +0 -74
  163. data/spec/shoes/logger/ruby_spec.rb +0 -8
  164. data/spec/shoes/logger_spec.rb +0 -45
  165. data/spec/shoes/oval_spec.rb +0 -24
  166. data/spec/shoes/point_spec.rb +0 -71
  167. data/spec/shoes/progress_spec.rb +0 -54
  168. data/spec/shoes/radio_spec.rb +0 -32
  169. data/spec/shoes/rect_spec.rb +0 -39
  170. data/spec/shoes/renamed_delegate_spec.rb +0 -70
  171. data/spec/shoes/shape_spec.rb +0 -95
  172. data/spec/shoes/shared_examples/button.rb +0 -6
  173. data/spec/shoes/shared_examples/changeable.rb +0 -26
  174. data/spec/shoes/shared_examples/clickable.rb +0 -5
  175. data/spec/shoes/shared_examples/common_methods.rb +0 -35
  176. data/spec/shoes/shared_examples/dimensions.rb +0 -32
  177. data/spec/shoes/shared_examples/dsl.rb +0 -44
  178. data/spec/shoes/shared_examples/dsl/animate.rb +0 -29
  179. data/spec/shoes/shared_examples/dsl/arc.rb +0 -45
  180. data/spec/shoes/shared_examples/dsl/background.rb +0 -26
  181. data/spec/shoes/shared_examples/dsl/border.rb +0 -10
  182. data/spec/shoes/shared_examples/dsl/button.rb +0 -5
  183. data/spec/shoes/shared_examples/dsl/cap.rb +0 -6
  184. data/spec/shoes/shared_examples/dsl/check.rb +0 -11
  185. data/spec/shoes/shared_examples/dsl/edit_box.rb +0 -8
  186. data/spec/shoes/shared_examples/dsl/edit_line.rb +0 -8
  187. data/spec/shoes/shared_examples/dsl/editable_element.rb +0 -29
  188. data/spec/shoes/shared_examples/dsl/fill.rb +0 -27
  189. data/spec/shoes/shared_examples/dsl/flow.rb +0 -15
  190. data/spec/shoes/shared_examples/dsl/gradient.rb +0 -62
  191. data/spec/shoes/shared_examples/dsl/image.rb +0 -21
  192. data/spec/shoes/shared_examples/dsl/line.rb +0 -9
  193. data/spec/shoes/shared_examples/dsl/nofill.rb +0 -6
  194. data/spec/shoes/shared_examples/dsl/nostroke.rb +0 -6
  195. data/spec/shoes/shared_examples/dsl/oval.rb +0 -88
  196. data/spec/shoes/shared_examples/dsl/pattern.rb +0 -34
  197. data/spec/shoes/shared_examples/dsl/progress.rb +0 -7
  198. data/spec/shoes/shared_examples/dsl/rect.rb +0 -92
  199. data/spec/shoes/shared_examples/dsl/rgb.rb +0 -26
  200. data/spec/shoes/shared_examples/dsl/shape.rb +0 -21
  201. data/spec/shoes/shared_examples/dsl/star.rb +0 -48
  202. data/spec/shoes/shared_examples/dsl/stroke.rb +0 -30
  203. data/spec/shoes/shared_examples/dsl/strokewidth.rb +0 -19
  204. data/spec/shoes/shared_examples/dsl/style.rb +0 -32
  205. data/spec/shoes/shared_examples/dsl/text_elements.rb +0 -81
  206. data/spec/shoes/shared_examples/dsl/video.rb +0 -5
  207. data/spec/shoes/shared_examples/dsl_app_context.rb +0 -8
  208. data/spec/shoes/shared_examples/hover_leave.rb +0 -11
  209. data/spec/shoes/shared_examples/parent.rb +0 -6
  210. data/spec/shoes/shared_examples/scroll.rb +0 -41
  211. data/spec/shoes/shared_examples/shared_element_method.rb +0 -60
  212. data/spec/shoes/shared_examples/slot.rb +0 -331
  213. data/spec/shoes/shared_examples/state.rb +0 -19
  214. data/spec/shoes/shared_examples/style.rb +0 -82
  215. data/spec/shoes/slot_spec.rb +0 -130
  216. data/spec/shoes/sound_spec.rb +0 -15
  217. data/spec/shoes/span_spec.rb +0 -112
  218. data/spec/shoes/spec_helper.rb +0 -24
  219. data/spec/shoes/stack_spec.rb +0 -79
  220. data/spec/shoes/star_spec.rb +0 -31
  221. data/spec/shoes/text_block_dimensions_spec.rb +0 -75
  222. data/spec/shoes/text_block_spec.rb +0 -270
  223. data/spec/shoes/url_spec.rb +0 -68
  224. data/spec/shoes/widget_spec.rb +0 -70
  225. data/spec/shoes_spec.rb +0 -44
  226. data/spec/swt_shoes/shared_examples/clickable.rb +0 -85
  227. data/spec/swt_shoes/sound.rb +0 -10
@@ -1,7 +1,6 @@
1
1
  class Shoes
2
2
  module Swt
3
3
  class Download
4
-
5
4
  attr_accessor :busy
6
5
  def initialize(_dsl)
7
6
  @busy = false
@@ -1,5 +1,4 @@
1
1
  class Shoes
2
-
3
2
  module Swt
4
3
  module Font
5
4
  class << self
@@ -10,11 +9,12 @@ class Shoes
10
9
  end
11
10
 
12
11
  def initial_fonts
13
- load_shoes_fonts #system fonts are loaded automatically by SWT
12
+ load_shoes_fonts # system fonts are loaded automatically by SWT
14
13
  ::Swt.display.get_font_list(nil, true).map(&:name)
15
14
  end
16
15
 
17
16
  private
17
+
18
18
  def load_font(path)
19
19
  ::Swt.display.load_font path
20
20
  end
@@ -28,5 +28,5 @@ class Shoes
28
28
  end
29
29
  end
30
30
 
31
- ::Shoes::Font.initial_fonts.each {|font| Shoes::FONTS << font}
32
- end
31
+ ::Shoes::Font.initial_fonts.each { |font| Shoes::FONTS << font }
32
+ end
@@ -0,0 +1,9 @@
1
+ require 'rbconfig'
2
+
3
+ def generate_backend(path)
4
+ if RbConfig::CONFIG["host_os"] =~ /darwin/
5
+ options = "-J-XstartOnFirstThread"
6
+ end
7
+
8
+ "jruby --1.9 #{options} #{path}/shoes-swt"
9
+ end
@@ -40,7 +40,8 @@ class Shoes
40
40
  end
41
41
 
42
42
  private
43
- def create_pattern left, top, width, height, angle
43
+
44
+ def create_pattern(left, top, width, height, angle)
44
45
  width = width * 0.5
45
46
  height = height * 0.5
46
47
  angle = normalize_angle(angle)
@@ -52,20 +53,20 @@ class Shoes
52
53
  end
53
54
 
54
55
  def normalize_angle(angle)
55
- angle = Math::PI * (angle/180.0)
56
- angle % (Math::PI*2.0)
56
+ angle = Math::PI * (angle / 180.0)
57
+ angle % (Math::PI * 2.0)
57
58
  end
58
59
 
59
60
  def determine_args_based_on_angle(angle, left, top, width, height)
60
61
  x, y = calculate_x_and_y(angle, height, width)
61
- if 0 <= angle and angle < Math::PI*0.5
62
- args = [left+width+x, top+height-y, left+width-x, top+height+y]
63
- elsif Math::PI*0.5 <= angle and angle < Math::PI
64
- args = [left+width+y, top+height+x, left+width-y, top+height-x]
65
- elsif Math::PI <= angle and angle < Math::PI*1.5
66
- args = [left+width-x, top+height+y, left+width+x, top+height-y]
67
- elsif Math::PI*1.5 <= angle and angle < Math::PI*2.0
68
- args = [left+width-y, top+height-x, left+width+y, top+height+x]
62
+ if 0 <= angle && angle < Math::PI * 0.5
63
+ args = [left + width + x, top + height - y, left + width - x, top + height + y]
64
+ elsif Math::PI * 0.5 <= angle && angle < Math::PI
65
+ args = [left + width + y, top + height + x, left + width - y, top + height - x]
66
+ elsif Math::PI <= angle && angle < Math::PI * 1.5
67
+ args = [left + width - x, top + height + y, left + width + x, top + height - y]
68
+ elsif Math::PI * 1.5 <= angle && angle < Math::PI * 2.0
69
+ args = [left + width - y, top + height - x, left + width + y, top + height + x]
69
70
  end
70
71
  args
71
72
  end
@@ -80,12 +81,12 @@ class Shoes
80
81
  end
81
82
  my_angle = angle % (Math::PI * 0.5)
82
83
  length = Math.sqrt(my_width**2 + my_height**2)
83
- b = (my_height==0 and my_width==0) ? 0 : Math.atan(my_height/my_width)
84
- c = Math::PI*0.5 - my_angle - b
84
+ b = (my_height == 0 && my_width == 0) ? 0 : Math.atan(my_height / my_width)
85
+ c = Math::PI * 0.5 - my_angle - b
85
86
  r = length * Math.cos(c.abs)
86
- x = r * Math.cos(b+c)
87
- y = r * Math.sin(b+c)
88
- return x, y
87
+ x = r * Math.cos(b + c)
88
+ y = r * Math.sin(b + c)
89
+ [x, y]
89
90
  end
90
91
  end
91
92
  end
@@ -11,8 +11,6 @@ class Shoes
11
11
  include Common::Remove
12
12
  include ::Shoes::BackendDimensionsDelegations
13
13
 
14
- BINARY_ENCODING = Encoding.find('binary')
15
-
16
14
  attr_reader :parent, :real, :dsl, :painter
17
15
 
18
16
  def initialize(dsl, parent)
@@ -29,6 +27,7 @@ class Shoes
29
27
  end
30
28
 
31
29
  private
30
+
32
31
  def load_image(name_or_data)
33
32
  if url?(name_or_data)
34
33
  save_width_and_height
@@ -40,7 +39,7 @@ class Shoes
40
39
  end
41
40
 
42
41
  def url?(name_or_data)
43
- name_or_data =~ /^(http|https):\/\//
42
+ @dsl.url?(name_or_data)
44
43
  end
45
44
 
46
45
  def save_width_and_height
@@ -102,7 +101,7 @@ class Shoes
102
101
  end
103
102
 
104
103
  def raw_image_data?(name_or_data)
105
- name_or_data.encoding == BINARY_ENCODING
104
+ @dsl.raw_image_data?(name_or_data)
106
105
  end
107
106
 
108
107
  def load_raw_image_data(name_or_data)
@@ -122,7 +121,6 @@ class Shoes
122
121
  end
123
122
  app.add_paint_listener(@painter)
124
123
  end
125
-
126
124
  end
127
125
  end
128
126
  end
@@ -19,11 +19,11 @@ class Shoes
19
19
  @pattern ||= ::Swt::Pattern.new(Shoes.display, @image)
20
20
  end
21
21
 
22
- def apply_as_fill(gc, left, top, width, height, angle = 0)
22
+ def apply_as_fill(gc, _left, _top, _width, _height, _angle = 0)
23
23
  gc.set_background_pattern pattern
24
24
  end
25
25
 
26
- def apply_as_stroke(gc, left, top, width, height, angle = 0)
26
+ def apply_as_stroke(gc, _left, _top, _width, _height, _angle = 0)
27
27
  gc.set_foreground_pattern pattern
28
28
  end
29
29
  end
@@ -45,11 +45,12 @@ class Shoes
45
45
  end
46
46
 
47
47
  private
48
+
48
49
  def nothing_changed?(event)
49
50
  source = event.source
50
51
  event.instance_of?(Java::OrgEclipseSwtEvents::ModifyEvent) &&
51
- source.instance_of?(Java::OrgEclipseSwtWidgets::Text) &&
52
- source.text == @last_text
52
+ source.instance_of?(Java::OrgEclipseSwtWidgets::Text) &&
53
+ source.text == @last_text
53
54
  end
54
55
  end
55
56
 
@@ -68,6 +69,5 @@ class Shoes
68
69
  super(dsl, parent, DEFAULT_STYLES)
69
70
  end
70
71
  end
71
-
72
72
  end
73
73
  end
@@ -9,11 +9,11 @@ class Shoes
9
9
 
10
10
  SPECIAL_KEY_NAMES = {}
11
11
 
12
- %w[TAB PAGE_UP PAGE_DOWN HOME END F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12
13
- F13 F14 F15].each do|key|
12
+ %w(TAB PAGE_UP PAGE_DOWN HOME END F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12
13
+ F13 F14 F15).each do|key|
14
14
  SPECIAL_KEY_NAMES[get_swt_constant key] = key.downcase
15
15
  end
16
- %w[UP DOWN LEFT RIGHT].each do |key|
16
+ %w(UP DOWN LEFT RIGHT).each do |key|
17
17
  SPECIAL_KEY_NAMES[get_swt_constant "ARROW_#{key}"] = key.downcase
18
18
  end
19
19
 
@@ -22,11 +22,11 @@ class Shoes
22
22
  SPECIAL_KEY_NAMES[::Swt::SWT::ESC] = "escape"
23
23
  SPECIAL_KEY_NAMES[::Swt::SWT::CR] = "\n"
24
24
 
25
- MODIFIER_KEYS = %w[CTRL SHIFT ALT CAPS_LOCK COMMAND].map do |key|
25
+ MODIFIER_KEYS = %w(CTRL SHIFT ALT CAPS_LOCK COMMAND).map do |key|
26
26
  get_swt_constant key
27
27
  end
28
28
 
29
- def initialize(dsl, app, &blk)
29
+ def initialize(_dsl, app, &blk)
30
30
  @block = blk
31
31
  @app = app
32
32
  @app.add_key_listener(self)
@@ -45,7 +45,7 @@ class Shoes
45
45
  end
46
46
 
47
47
  BUTTON_EXCLUDES = ["\n", " "]
48
- COMBO_EXCLUDES = %w[up down] + BUTTON_EXCLUDES
48
+ COMBO_EXCLUDES = %w(up down) + BUTTON_EXCLUDES
49
49
 
50
50
  # For a variety of SWT controls, certain characters should not be passed
51
51
  # to Shoes key listeners, since they're already handled by the controls.
@@ -9,50 +9,30 @@ class Shoes
9
9
  include ::Shoes::BackendDimensionsDelegations
10
10
 
11
11
  attr_reader :dsl, :app
12
- attr_reader :translated_point_a, :translated_point_b
13
12
  attr_reader :transform
14
13
 
15
- # @param [Shoes::Line] dsl The {Shoes::Line} implemented by this object
16
- # @param [Shoes::Swt::App] app The {Swt::App} this object belongs to
17
- # @param [Shoes::Point] point_a One endpoint of the line
18
- # @param [Shoes::Point] point_b The other endpoint of the line
19
14
  def initialize(dsl, app)
20
15
  @dsl, @app = dsl, app
21
- translate_according_to_enclosing_box
22
16
  @painter = Painter.new(self)
23
17
  @app.add_paint_listener(@painter)
24
- end
25
18
 
26
- def dispose
27
- @transform.dispose unless @transform.disposed?
19
+ @transform = nil # Not necessary for this shape
28
20
  end
29
21
 
30
22
  def angle
31
23
  @dsl.angle
32
24
  end
33
25
 
34
- def update_position
35
- translate_according_to_enclosing_box
36
- end
37
-
38
26
  private
39
- def translate_according_to_enclosing_box
40
- @translated_point_a = @dsl.point_a.to(-left, -top)
41
- @translated_point_b = @dsl.point_b.to(-left, -top)
42
- @transform = ::Swt::Transform.new(::Swt.display)
43
- @transform_elements = Java::float[6].new
44
- @transform.get_elements @transform_elements
45
- @transform.set_elements @transform_elements[0], @transform_elements[1], @transform_elements[2], @transform_elements[3], dsl.element_left, dsl.element_top
46
- end
47
27
 
48
28
  class Painter < Common::Painter
49
29
  def draw(gc)
50
- point_a, point_b = @obj.translated_point_a, @obj.translated_point_b
51
- gc.draw_line(point_a.x, point_a.y, point_b.x, point_b.y)
30
+ gc.draw_line(@obj.element_left, @obj.element_top,
31
+ @obj.element_right + 1, @obj.element_bottom + 1)
52
32
  end
53
33
 
54
34
  # Don't do fill setup
55
- def fill_setup(gc)
35
+ def fill_setup(_gc)
56
36
  end
57
37
  end
58
38
  end
@@ -13,7 +13,7 @@ class Shoes
13
13
 
14
14
  def remove
15
15
  @link_segments.clear
16
- remove_listener_for self, ::Swt::SWT::MouseDown
16
+ app.click_listener.remove_listeners_for(self)
17
17
  end
18
18
 
19
19
  def create_links_in(text_segment_ranges)
@@ -24,7 +24,7 @@ class Shoes
24
24
  end
25
25
 
26
26
  def in_bounds?(x, y)
27
- @link_segments.any? {|segment| segment.in_bounds?(x, y)}
27
+ @link_segments.any? { |segment| segment.in_bounds?(x, y) }
28
28
  end
29
29
  end
30
30
  end
@@ -32,7 +32,7 @@ class Shoes
32
32
  end
33
33
 
34
34
  def line_bounds
35
- (0..layout.line_count-1).map do |index|
35
+ (0..layout.line_count - 1).map do |index|
36
36
  layout.line_bounds(index)
37
37
  end
38
38
  end
@@ -71,7 +71,7 @@ class Shoes
71
71
  end
72
72
 
73
73
  def in_bounds?(x, y)
74
- @regions.any? {|region| region.in_bounds?(x, y)}
74
+ @regions.any? { |region| region.in_bounds?(x, y) }
75
75
  end
76
76
 
77
77
  def start_position
@@ -103,7 +103,7 @@ class Shoes
103
103
  end
104
104
 
105
105
  def in_bounds?(x, y)
106
- (@start_x..@end_x).include?(x) and (@start_y..@end_y).include?(y)
106
+ (@start_x..@end_x).include?(x) && (@start_y..@end_y).include?(y)
107
107
  end
108
108
  end
109
109
  end
@@ -21,14 +21,14 @@ class Shoes
21
21
  ::Swt::SWT::DROP_DOWN | ::Swt::SWT::READ_ONLY
22
22
  )
23
23
  @real.set_size dsl.element_width, dsl.element_height
24
- @real.add_selection_listener do |event|
24
+ @real.add_selection_listener do |_event|
25
25
  @dsl.call_change_listeners
26
26
  end
27
- update_items @dsl.items
27
+ update_items
28
28
  end
29
29
 
30
- def update_items(values)
31
- @real.items = values.map(&:to_s)
30
+ def update_items
31
+ @real.items = @dsl.items.map(&:to_s)
32
32
  end
33
33
 
34
34
  def text
@@ -3,19 +3,20 @@ class Shoes
3
3
  class MouseMoveListener
4
4
  include ::Swt::Events::MouseMoveListener
5
5
 
6
- def initialize app
6
+ def initialize(app)
7
7
  @app = app
8
8
  end
9
9
 
10
10
  def mouse_move(mouse_event)
11
11
  @app.dsl.mouse_pos = [mouse_event.x, mouse_event.y]
12
- @app.dsl.mouse_motion.each{|blk| eval_move_block blk, mouse_event}
12
+ @app.dsl.mouse_motion.each { |blk| eval_move_block blk, mouse_event }
13
13
  mouse_shape_control mouse_event
14
14
  mouse_leave_control mouse_event
15
15
  mouse_hover_control mouse_event
16
16
  end
17
17
 
18
18
  private
19
+
19
20
  def eval_move_block(blk, event)
20
21
  blk.call event.x, event.y
21
22
  end
@@ -26,12 +27,12 @@ class Shoes
26
27
  else
27
28
  ::Swt::SWT::CURSOR_ARROW
28
29
  end
29
- @app.shell.setCursor Shoes.display.getSystemCursor(cursor)
30
+ @app.shell.setCursor Shoes.display.getSystemCursor(cursor)
30
31
  end
31
32
 
32
33
  def mouse_leave_control(mouse_event)
33
34
  @app.dsl.mouse_hover_controls.each do |element|
34
- if !mouse_on?(element, mouse_event) and element.hovered?
35
+ if !mouse_on?(element, mouse_event) && element.hovered?
35
36
  element.mouse_left
36
37
  end
37
38
  end
@@ -39,7 +40,7 @@ class Shoes
39
40
 
40
41
  def mouse_hover_control(mouse_event)
41
42
  @app.dsl.mouse_hover_controls.each do |element|
42
- if mouse_on?(element, mouse_event) and !element.hovered?
43
+ if mouse_on?(element, mouse_event) && !element.hovered?
43
44
  element.mouse_hovered
44
45
  end
45
46
  end
@@ -11,7 +11,6 @@ class Shoes
11
11
 
12
12
  attr_reader :dsl, :app, :transform, :painter, :container
13
13
 
14
-
15
14
  # @param [Shoes::Oval] dsl the dsl object to provide gui for
16
15
  # @param [Shoes::Swt::App] app the app
17
16
  # @param [Hash] opts options
@@ -43,8 +42,8 @@ class Shoes
43
42
 
44
43
  def draw(graphics_context)
45
44
  sw = graphics_context.get_line_width
46
- graphics_context.draw_oval(@obj.element_left+sw/2, @obj.element_top+sw/2,
47
- @obj.element_width-sw, @obj.element_height-sw)
45
+ graphics_context.draw_oval(@obj.element_left + sw / 2, @obj.element_top + sw / 2,
46
+ @obj.element_width - sw, @obj.element_height - sw)
48
47
  end
49
48
  end
50
49
  end
@@ -0,0 +1,82 @@
1
+ class Shoes
2
+ module Swt
3
+ class Packager
4
+ def initialize(dsl)
5
+ @dsl = dsl
6
+ end
7
+
8
+ def create_package(program_name, package)
9
+ unless package =~ /^(swt):(app|jar)$/
10
+ abort("#{program_name}: Can't package as '#{package}'. See '#{program_name} --help'")
11
+ end
12
+ package.split(':')
13
+ end
14
+
15
+ def run(path)
16
+ begin
17
+ require 'shoes/package/configuration'
18
+ require 'shoes/package/jar'
19
+ require 'shoes/package/jar_app'
20
+ master_config = ::Shoes::Package::Configuration.load(path)
21
+ rescue Errno::ENOENT => e
22
+ abort "shoes: #{e.message}"
23
+ end
24
+
25
+ @dsl.packages.each do |backend, wrapper|
26
+ puts "Packaging #{backend}:#{wrapper}..."
27
+ config = create_config(master_config, backend)
28
+ packager = create_packager(config, wrapper)
29
+ packager.package
30
+ end
31
+ end
32
+
33
+ def help(program_name)
34
+ <<-EOS
35
+
36
+ Package types:
37
+ #{package_types}
38
+ Examples:
39
+ #{examples(program_name)}
40
+ EOS
41
+ end
42
+
43
+ def package_types()
44
+ <<-EOS
45
+ swt:app A standalone OS X executable with the Swt backend
46
+ swt:jar An executable JAR with the Swt backend
47
+ EOS
48
+ end
49
+
50
+ def examples(program_name)
51
+ <<-EOS
52
+ To run a Shoes app:
53
+ #{program_name} path/to/shoes-app.rb
54
+
55
+ Two ways to package a Shoes app as an APP and a JAR, using the Swt backend:
56
+ #{program_name} -p swt:app -p swt:jar path/to/app.yaml
57
+ #{program_name} -p swt:app -p swt:jar path/to/shoes-app.rb
58
+ EOS
59
+ end
60
+
61
+ private
62
+ # Copy the master config (including singleton class), since we may be
63
+ # packaging for more than one backend
64
+ def create_config(master_config, backend)
65
+ config = master_config.clone
66
+ config.gems << "shoes-#{backend}"
67
+ config
68
+ end
69
+
70
+ def create_packager(config, wrapper)
71
+ case wrapper
72
+ when 'jar'
73
+ ::Furoshiki::Jar.new(config)
74
+ when 'app'
75
+ ::Furoshiki::JarApp.new(config)
76
+ else
77
+ abort "shoes: Don't know how to make #{backend}:#{wrapper} packages"
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end