shoes 4.0.0.pre1 → 4.0.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +84 -32
- data/Gemfile +22 -1
- data/README.md +28 -13
- data/Rakefile +7 -210
- data/bin/ruby-shoes +2 -2
- data/ext/install/shoes.bat +4 -1
- data/lib/shoes.rb +1 -121
- data/lib/shoes/{cli.rb → ui/cli.rb} +7 -1
- data/lib/shoes/{help.rb → ui/help.rb} +2 -2
- data/lib/shoes/{manual.rb → ui/manual.rb} +1 -1
- data/lib/shoes/version.rb +1 -1
- data/manifests/common.rb +34 -0
- data/manifests/shoes.rb +44 -0
- data/samples/Gemfile +3 -0
- data/samples/Gemfile.lock +35 -0
- data/samples/README +16 -5
- data/samples/boom.rb +239 -0
- data/samples/clicky.rb +24 -0
- data/samples/flow.rb +63 -0
- data/samples/gray.rb +11 -0
- data/samples/nks_booklist.rb +24 -0
- data/samples/nks_breadsticks.rb +7 -0
- data/samples/nks_dancing_circle.rb +13 -0
- data/samples/nks_dictionary.rb +23 -0
- data/samples/nks_edit_box.rb +4 -0
- data/samples/nks_edit_line.rb +6 -0
- data/samples/nks_notes.rb +16 -0
- data/samples/nks_self.rb +6 -0
- data/samples/nks_text_sizes.rb +10 -0
- data/samples/nks_trurl.rb +5 -0
- data/samples/packaging/package_me.rb +6 -0
- data/samples/present.rb +27 -0
- data/samples/progress.rb +10 -0
- data/samples/sample31.rb +1 -1
- data/samples/simple-calc.rb +1 -1
- data/samples/simple-tictactoe.rb +238 -0
- data/samples/simple-visibility.rb +11 -0
- data/samples/simple-widget.rb +9 -0
- data/samples/swt-raw.rb +20 -0
- data/samples/troll.rb +22 -0
- data/shoes.gemspec +10 -22
- data/snapshots/sample56.png +0 -0
- data/static/manual-en.txt +16 -7
- data/tasks/changelog.rb +92 -0
- data/tasks/gem.rb +38 -0
- data/tasks/rspec.rb +106 -0
- data/tasks/sample.rb +66 -0
- data/tasks/yard.rb +13 -0
- metadata +55 -488
- data/.gitignore +0 -53
- data/.rspec +0 -3
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -31
- data/bin/shoes +0 -59
- data/bin/shoes.bat +0 -6
- data/fonts/Coolvetica.ttf +0 -0
- data/fonts/Lacuna.ttf +0 -0
- data/lib/ext/highlighter.rb +0 -2
- data/lib/ext/highlighter/common.rb +0 -197
- data/lib/ext/highlighter/lang/ruby.rb +0 -316
- data/lib/ext/highlighter/markup.rb +0 -222
- data/lib/rubygems_plugin.rb +0 -19
- data/lib/shoes/animation.rb +0 -55
- data/lib/shoes/app.rb +0 -320
- data/lib/shoes/arc.rb +0 -35
- data/lib/shoes/background.rb +0 -30
- data/lib/shoes/border.rb +0 -33
- data/lib/shoes/builtin_methods.rb +0 -73
- data/lib/shoes/button.rb +0 -32
- data/lib/shoes/check_button.rb +0 -43
- data/lib/shoes/color.rb +0 -375
- data/lib/shoes/common/background_element.rb +0 -9
- data/lib/shoes/common/changeable.rb +0 -34
- data/lib/shoes/common/clickable.rb +0 -17
- data/lib/shoes/common/common_methods.rb +0 -70
- data/lib/shoes/common/fill.rb +0 -21
- data/lib/shoes/common/registration.rb +0 -33
- data/lib/shoes/common/state.rb +0 -18
- data/lib/shoes/common/stroke.rb +0 -28
- data/lib/shoes/common/style.rb +0 -34
- data/lib/shoes/common/style_normalizer.rb +0 -16
- data/lib/shoes/configuration.rb +0 -96
- data/lib/shoes/dialog.rb +0 -27
- data/lib/shoes/dimension.rb +0 -237
- data/lib/shoes/dimensions.rb +0 -194
- data/lib/shoes/download.rb +0 -117
- data/lib/shoes/dsl.rb +0 -478
- data/lib/shoes/font.rb +0 -49
- data/lib/shoes/gradient.rb +0 -18
- data/lib/shoes/image.rb +0 -33
- data/lib/shoes/image_pattern.rb +0 -10
- data/lib/shoes/input_box.rb +0 -68
- data/lib/shoes/key_event.rb +0 -17
- data/lib/shoes/line.rb +0 -38
- data/lib/shoes/link.rb +0 -49
- data/lib/shoes/link_hover.rb +0 -5
- data/lib/shoes/list_box.rb +0 -44
- data/lib/shoes/logger.rb +0 -66
- data/lib/shoes/logger/ruby.rb +0 -18
- data/lib/shoes/mock.rb +0 -30
- data/lib/shoes/mock/animation.rb +0 -8
- data/lib/shoes/mock/app.rb +0 -44
- data/lib/shoes/mock/arc.rb +0 -8
- data/lib/shoes/mock/background.rb +0 -10
- data/lib/shoes/mock/border.rb +0 -7
- data/lib/shoes/mock/button.rb +0 -10
- data/lib/shoes/mock/check.rb +0 -24
- data/lib/shoes/mock/common_methods.rb +0 -11
- data/lib/shoes/mock/dialog.rb +0 -13
- data/lib/shoes/mock/download.rb +0 -18
- data/lib/shoes/mock/font.rb +0 -17
- data/lib/shoes/mock/image.rb +0 -12
- data/lib/shoes/mock/image_pattern.rb +0 -9
- data/lib/shoes/mock/input_box.rb +0 -23
- data/lib/shoes/mock/keypress.rb +0 -8
- data/lib/shoes/mock/keyrelease.rb +0 -8
- data/lib/shoes/mock/line.rb +0 -14
- data/lib/shoes/mock/link.rb +0 -11
- data/lib/shoes/mock/list_box.rb +0 -16
- data/lib/shoes/mock/oval.rb +0 -11
- data/lib/shoes/mock/progress.rb +0 -10
- data/lib/shoes/mock/radio.rb +0 -26
- data/lib/shoes/mock/rect.rb +0 -13
- data/lib/shoes/mock/shape.rb +0 -19
- data/lib/shoes/mock/slot.rb +0 -14
- data/lib/shoes/mock/sound.rb +0 -8
- data/lib/shoes/mock/star.rb +0 -13
- data/lib/shoes/mock/text_block.rb +0 -29
- data/lib/shoes/mock/timer.rb +0 -8
- data/lib/shoes/oval.rb +0 -28
- data/lib/shoes/point.rb +0 -43
- data/lib/shoes/progress.rb +0 -26
- data/lib/shoes/radio.rb +0 -15
- data/lib/shoes/rect.rb +0 -28
- data/lib/shoes/renamed_delegate.rb +0 -15
- data/lib/shoes/shape.rb +0 -175
- data/lib/shoes/slot.rb +0 -232
- data/lib/shoes/slot_contents.rb +0 -56
- data/lib/shoes/sound.rb +0 -16
- data/lib/shoes/span.rb +0 -16
- data/lib/shoes/star.rb +0 -49
- data/lib/shoes/swt.rb +0 -114
- data/lib/shoes/swt/animation.rb +0 -46
- data/lib/shoes/swt/app.rb +0 -300
- data/lib/shoes/swt/arc.rb +0 -70
- data/lib/shoes/swt/background.rb +0 -31
- data/lib/shoes/swt/border.rb +0 -37
- data/lib/shoes/swt/button.rb +0 -18
- data/lib/shoes/swt/check.rb +0 -14
- data/lib/shoes/swt/check_button.rb +0 -19
- data/lib/shoes/swt/color.rb +0 -45
- data/lib/shoes/swt/common/child.rb +0 -16
- data/lib/shoes/swt/common/clear.rb +0 -24
- data/lib/shoes/swt/common/clickable.rb +0 -62
- data/lib/shoes/swt/common/container.rb +0 -28
- data/lib/shoes/swt/common/fill.rb +0 -37
- data/lib/shoes/swt/common/painter.rb +0 -83
- data/lib/shoes/swt/common/painter_updates_position.rb +0 -12
- data/lib/shoes/swt/common/resource.rb +0 -14
- data/lib/shoes/swt/common/selection_listener.rb +0 -14
- data/lib/shoes/swt/common/stroke.rb +0 -41
- data/lib/shoes/swt/common/toggle.rb +0 -13
- data/lib/shoes/swt/common/update_position.rb +0 -15
- data/lib/shoes/swt/dialog.rb +0 -89
- data/lib/shoes/swt/disposed_protection.rb +0 -23
- data/lib/shoes/swt/download.rb +0 -24
- data/lib/shoes/swt/fitted_text_layout.rb +0 -94
- data/lib/shoes/swt/fitted_text_layout_collection.rb +0 -108
- data/lib/shoes/swt/font.rb +0 -32
- data/lib/shoes/swt/gradient.rb +0 -77
- data/lib/shoes/swt/image.rb +0 -130
- data/lib/shoes/swt/image_pattern.rb +0 -19
- data/lib/shoes/swt/input_box.rb +0 -73
- data/lib/shoes/swt/key_listener.rb +0 -145
- data/lib/shoes/swt/line.rb +0 -57
- data/lib/shoes/swt/link.rb +0 -37
- data/lib/shoes/swt/link_segment.rb +0 -108
- data/lib/shoes/swt/list_box.rb +0 -49
- data/lib/shoes/swt/mouse_move_listener.rb +0 -61
- data/lib/shoes/swt/oval.rb +0 -53
- data/lib/shoes/swt/progress.rb +0 -35
- data/lib/shoes/swt/radio.rb +0 -29
- data/lib/shoes/swt/radio_group.rb +0 -54
- data/lib/shoes/swt/rect.rb +0 -31
- data/lib/shoes/swt/rect_painter.rb +0 -23
- data/lib/shoes/swt/redrawing_aspect.rb +0 -122
- data/lib/shoes/swt/shape.rb +0 -101
- data/lib/shoes/swt/shoes_layout.rb +0 -43
- data/lib/shoes/swt/slot.rb +0 -25
- data/lib/shoes/swt/sound.rb +0 -119
- data/lib/shoes/swt/star.rb +0 -51
- data/lib/shoes/swt/swt_button.rb +0 -49
- data/lib/shoes/swt/text_block.rb +0 -133
- data/lib/shoes/swt/text_block_cursor_painter.rb +0 -112
- data/lib/shoes/swt/text_block_fitter.rb +0 -180
- data/lib/shoes/swt/text_block_painter.rb +0 -49
- data/lib/shoes/swt/text_font_factory.rb +0 -27
- data/lib/shoes/swt/text_style_factory.rb +0 -88
- data/lib/shoes/swt/timer.rb +0 -19
- data/lib/shoes/swt/tooling/leak_hunter.rb +0 -84
- data/lib/shoes/text.rb +0 -14
- data/lib/shoes/text_block.rb +0 -162
- data/lib/shoes/timer.rb +0 -10
- data/lib/shoes/url.rb +0 -47
- data/lib/shoes/widget.rb +0 -73
- data/lib/support/jl1.0.1.jar +0 -0
- data/lib/support/jogg-0.0.7.jar +0 -0
- data/lib/support/jorbis-0.0.15.jar +0 -0
- data/lib/support/log4j-1.2.16.jar +0 -0
- data/lib/support/mp3spi1.9.5.jar +0 -0
- data/lib/support/tritonus_share.jar +0 -0
- data/lib/support/vorbisspi1.0.3.jar +0 -0
- data/samples/good-clock-adjusted.rb +0 -49
- data/spec/async_helper.rb +0 -21
- data/spec/code_coverage.rb +0 -11
- data/spec/shoes/animation_spec.rb +0 -65
- data/spec/shoes/app_spec.rb +0 -411
- data/spec/shoes/arc_spec.rb +0 -53
- data/spec/shoes/background_spec.rb +0 -48
- data/spec/shoes/border_spec.rb +0 -43
- data/spec/shoes/builtin_methods_spec.rb +0 -84
- data/spec/shoes/button_spec.rb +0 -41
- data/spec/shoes/check_spec.rb +0 -31
- data/spec/shoes/cli_spec.rb +0 -16
- data/spec/shoes/color_spec.rb +0 -396
- data/spec/shoes/common/style_normalizer_spec.rb +0 -28
- data/spec/shoes/common/style_spec.rb +0 -58
- data/spec/shoes/configuration_spec.rb +0 -37
- data/spec/shoes/constants_spec.rb +0 -38
- data/spec/shoes/dialog_spec.rb +0 -163
- data/spec/shoes/dimension_spec.rb +0 -381
- data/spec/shoes/dimensions_spec.rb +0 -831
- data/spec/shoes/download_spec.rb +0 -133
- data/spec/shoes/flow_spec.rb +0 -92
- data/spec/shoes/font_spec.rb +0 -38
- data/spec/shoes/framework_learning_spec.rb +0 -30
- data/spec/shoes/helpers/fake_element.rb +0 -11
- data/spec/shoes/helpers/sample17_helper.rb +0 -66
- data/spec/shoes/image_spec.rb +0 -45
- data/spec/shoes/images/shoe.jpg +0 -0
- data/spec/shoes/input_box_spec.rb +0 -44
- data/spec/shoes/integration_spec.rb +0 -20
- data/spec/shoes/keypress_spec.rb +0 -11
- data/spec/shoes/keyrelease_spec.rb +0 -12
- data/spec/shoes/line_spec.rb +0 -47
- data/spec/shoes/link_spec.rb +0 -89
- data/spec/shoes/list_box_spec.rb +0 -63
- data/spec/shoes/logger/ruby_spec.rb +0 -9
- data/spec/shoes/logger_spec.rb +0 -45
- data/spec/shoes/oval_spec.rb +0 -20
- data/spec/shoes/point_spec.rb +0 -51
- data/spec/shoes/progress_spec.rb +0 -40
- data/spec/shoes/radio_spec.rb +0 -28
- data/spec/shoes/rect_spec.rb +0 -38
- data/spec/shoes/renamed_delegate_spec.rb +0 -70
- data/spec/shoes/shape_spec.rb +0 -54
- data/spec/shoes/shared_examples/button.rb +0 -6
- data/spec/shoes/shared_examples/changeable.rb +0 -26
- data/spec/shoes/shared_examples/clickable.rb +0 -5
- data/spec/shoes/shared_examples/common_methods.rb +0 -42
- data/spec/shoes/shared_examples/dimensions.rb +0 -32
- data/spec/shoes/shared_examples/dsl.rb +0 -42
- data/spec/shoes/shared_examples/dsl/animate.rb +0 -29
- data/spec/shoes/shared_examples/dsl/arc.rb +0 -45
- data/spec/shoes/shared_examples/dsl/background.rb +0 -26
- data/spec/shoes/shared_examples/dsl/border.rb +0 -10
- data/spec/shoes/shared_examples/dsl/cap.rb +0 -6
- data/spec/shoes/shared_examples/dsl/check.rb +0 -11
- data/spec/shoes/shared_examples/dsl/edit_box.rb +0 -8
- data/spec/shoes/shared_examples/dsl/edit_line.rb +0 -8
- data/spec/shoes/shared_examples/dsl/editable_element.rb +0 -29
- data/spec/shoes/shared_examples/dsl/fill.rb +0 -27
- data/spec/shoes/shared_examples/dsl/flow.rb +0 -15
- data/spec/shoes/shared_examples/dsl/gradient.rb +0 -52
- data/spec/shoes/shared_examples/dsl/image.rb +0 -21
- data/spec/shoes/shared_examples/dsl/line.rb +0 -9
- data/spec/shoes/shared_examples/dsl/nofill.rb +0 -6
- data/spec/shoes/shared_examples/dsl/nostroke.rb +0 -6
- data/spec/shoes/shared_examples/dsl/oval.rb +0 -60
- data/spec/shoes/shared_examples/dsl/pattern.rb +0 -34
- data/spec/shoes/shared_examples/dsl/progress.rb +0 -7
- data/spec/shoes/shared_examples/dsl/rect.rb +0 -92
- data/spec/shoes/shared_examples/dsl/rgb.rb +0 -26
- data/spec/shoes/shared_examples/dsl/shape.rb +0 -21
- data/spec/shoes/shared_examples/dsl/star.rb +0 -48
- data/spec/shoes/shared_examples/dsl/stroke.rb +0 -30
- data/spec/shoes/shared_examples/dsl/strokewidth.rb +0 -19
- data/spec/shoes/shared_examples/dsl/style.rb +0 -32
- data/spec/shoes/shared_examples/dsl/text_elements.rb +0 -81
- data/spec/shoes/shared_examples/dsl_app_context.rb +0 -8
- data/spec/shoes/shared_examples/hover_leave.rb +0 -11
- data/spec/shoes/shared_examples/parent.rb +0 -6
- data/spec/shoes/shared_examples/shared_element_method.rb +0 -52
- data/spec/shoes/shared_examples/slot.rb +0 -272
- data/spec/shoes/shared_examples/state.rb +0 -19
- data/spec/shoes/shared_examples/style.rb +0 -24
- data/spec/shoes/slot_spec.rb +0 -60
- data/spec/shoes/sound_spec.rb +0 -15
- data/spec/shoes/span_spec.rb +0 -94
- data/spec/shoes/spec_helper.rb +0 -1
- data/spec/shoes/stack_spec.rb +0 -53
- data/spec/shoes/star_spec.rb +0 -30
- data/spec/shoes/text_block_spec.rb +0 -242
- data/spec/shoes/url_spec.rb +0 -66
- data/spec/shoes/widget_spec.rb +0 -34
- data/spec/shoes_spec.rb +0 -44
- data/spec/spec_helper.rb +0 -16
- data/spec/swt_shoes/animation_spec.rb +0 -86
- data/spec/swt_shoes/app_spec.rb +0 -75
- data/spec/swt_shoes/arc_spec.rb +0 -101
- data/spec/swt_shoes/background_spec.rb +0 -56
- data/spec/swt_shoes/border_spec.rb +0 -51
- data/spec/swt_shoes/button_spec.rb +0 -101
- data/spec/swt_shoes/check_spec.rb +0 -28
- data/spec/swt_shoes/color_spec.rb +0 -67
- data/spec/swt_shoes/common/painter_spec.rb +0 -29
- data/spec/swt_shoes/configuration_spec.rb +0 -12
- data/spec/swt_shoes/dialog_spec.rb +0 -106
- data/spec/swt_shoes/disposed_protection_spec.rb +0 -49
- data/spec/swt_shoes/fitted_text_layout_collection_spec.rb +0 -174
- data/spec/swt_shoes/fitted_text_layout_spec.rb +0 -130
- data/spec/swt_shoes/flow_spec.rb +0 -26
- data/spec/swt_shoes/font_spec.rb +0 -33
- data/spec/swt_shoes/gradient_spec.rb +0 -20
- data/spec/swt_shoes/image_pattern_spec.rb +0 -19
- data/spec/swt_shoes/image_spec.rb +0 -100
- data/spec/swt_shoes/input_box_spec.rb +0 -110
- data/spec/swt_shoes/integration_spec.rb +0 -18
- data/spec/swt_shoes/key_listener_spec.rb +0 -320
- data/spec/swt_shoes/line_spec.rb +0 -43
- data/spec/swt_shoes/link_segment_spec.rb +0 -103
- data/spec/swt_shoes/link_spec.rb +0 -59
- data/spec/swt_shoes/list_box_spec.rb +0 -51
- data/spec/swt_shoes/minimal.png +0 -0
- data/spec/swt_shoes/mouse_move_listener_spec.rb +0 -129
- data/spec/swt_shoes/oval_spec.rb +0 -51
- data/spec/swt_shoes/progress_spec.rb +0 -44
- data/spec/swt_shoes/radio_group_spec.rb +0 -73
- data/spec/swt_shoes/radio_spec.rb +0 -56
- data/spec/swt_shoes/rect_painter_spec.rb +0 -45
- data/spec/swt_shoes/rect_spec.rb +0 -19
- data/spec/swt_shoes/shape_spec.rb +0 -81
- data/spec/swt_shoes/shared_examples/button.rb +0 -24
- data/spec/swt_shoes/shared_examples/clearable.rb +0 -32
- data/spec/swt_shoes/shared_examples/clickable.rb +0 -60
- data/spec/swt_shoes/shared_examples/movable.rb +0 -36
- data/spec/swt_shoes/shared_examples/paintable_spec.rb +0 -7
- data/spec/swt_shoes/shared_examples/painter.rb +0 -83
- data/spec/swt_shoes/shared_examples/pattern.rb +0 -32
- data/spec/swt_shoes/shared_examples/swt_app_context.rb +0 -17
- data/spec/swt_shoes/shared_examples/togglable.rb +0 -15
- data/spec/swt_shoes/shell_control_listener_spec.rb +0 -23
- data/spec/swt_shoes/sound.rb +0 -10
- data/spec/swt_shoes/spec_helper.rb +0 -31
- data/spec/swt_shoes/star_spec.rb +0 -47
- data/spec/swt_shoes/text_block_cursor_painter_spec.rb +0 -202
- data/spec/swt_shoes/text_block_fitter_spec.rb +0 -181
- data/spec/swt_shoes/text_block_painter_spec.rb +0 -221
- data/spec/swt_shoes/text_block_spec.rb +0 -183
@@ -1,221 +0,0 @@
|
|
1
|
-
require 'swt_shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Swt::TextBlockPainter do
|
4
|
-
include_context "swt app"
|
5
|
-
|
6
|
-
let(:opts) { {justify: true, leading: 10, underline: "single"} }
|
7
|
-
let(:gui) { double("gui", dispose: nil) }
|
8
|
-
let(:dsl) { double("dsl", app: shoes_app, gui: gui,
|
9
|
-
text: text, cursor: nil,
|
10
|
-
opts: opts, element_width: 200, element_height: 180,
|
11
|
-
element_left: 0, element_top: 10, font: "font",
|
12
|
-
font_size: 16, margin_left: 0, margin_top: 0,
|
13
|
-
text_styles: text_styles, :hidden? => false).as_null_object
|
14
|
-
}
|
15
|
-
|
16
|
-
let(:fitted_layout) do
|
17
|
-
::Swt::Font.stub(:new) { font }
|
18
|
-
::Swt::TextLayout.stub(:new) { text_layout }
|
19
|
-
::Swt::TextStyle.stub(:new) { style }
|
20
|
-
|
21
|
-
fitted = Shoes::Swt::FittedTextLayout.new(dsl, text, 200)
|
22
|
-
fitted.position_at(0, 10)
|
23
|
-
end
|
24
|
-
|
25
|
-
let(:text_layout) { double("text layout", text: text).as_null_object }
|
26
|
-
|
27
|
-
let(:event) { double("event").as_null_object }
|
28
|
-
let(:style) { double(:style).as_null_object }
|
29
|
-
let(:font) { double(:font).as_null_object }
|
30
|
-
|
31
|
-
let(:blue) { Shoes::Color.new(0, 0, 255) }
|
32
|
-
let(:swt_blue) { Shoes::Swt::Color.new(blue).real}
|
33
|
-
let(:text_styles) {{}}
|
34
|
-
let(:text) {'hello world'}
|
35
|
-
|
36
|
-
subject { Shoes::Swt::TextBlockPainter.new(dsl) }
|
37
|
-
|
38
|
-
before :each do
|
39
|
-
::Swt::TextStyle.stub(:new) { style.as_null_object }
|
40
|
-
|
41
|
-
# Can't stub this in during initial let because of circular reference
|
42
|
-
# fitted_layouts -> dsl -> gui -> fitted_layouts...
|
43
|
-
gui.stub(fitted_layouts: [fitted_layout])
|
44
|
-
end
|
45
|
-
|
46
|
-
it "draws" do
|
47
|
-
expect(fitted_layout).to receive(:draw)
|
48
|
-
subject.paintControl(event)
|
49
|
-
end
|
50
|
-
|
51
|
-
it "sets justify" do
|
52
|
-
expect(text_layout).to receive(:justify=).with(opts[:justify])
|
53
|
-
subject.paintControl(event)
|
54
|
-
end
|
55
|
-
|
56
|
-
it "sets spacing" do
|
57
|
-
expect(text_layout).to receive(:spacing=).with(opts[:leading])
|
58
|
-
subject.paintControl(event)
|
59
|
-
end
|
60
|
-
|
61
|
-
it "sets alignment" do
|
62
|
-
expect(text_layout).to receive(:alignment=).with(anything)
|
63
|
-
subject.paintControl(event)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "sets text styles" do
|
67
|
-
expect(text_layout).to receive(:set_style).with(anything, anything, anything).at_least(1).times
|
68
|
-
subject.paintControl(event)
|
69
|
-
end
|
70
|
-
|
71
|
-
context "rise option" do
|
72
|
-
it "sets default rise value to nil" do
|
73
|
-
expect(style).to receive(:rise=).with(nil)
|
74
|
-
subject.paintControl(event)
|
75
|
-
end
|
76
|
-
|
77
|
-
it "sets correct rise value" do
|
78
|
-
opts[:rise] = 10
|
79
|
-
expect(style).to receive(:rise=).with(10)
|
80
|
-
|
81
|
-
subject.paintControl(event)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context "underline option" do
|
86
|
-
it "sets default underline style to none" do
|
87
|
-
opts.delete(:underline)
|
88
|
-
|
89
|
-
expect(style).to receive(:underline=).with(false)
|
90
|
-
expect(style).to receive(:underlineStyle=).with(nil)
|
91
|
-
|
92
|
-
subject.paintControl(event)
|
93
|
-
end
|
94
|
-
|
95
|
-
it "sets correct underline style" do
|
96
|
-
|
97
|
-
expect(style).to receive(:underline=).with(true)
|
98
|
-
expect(style).to receive(:underlineStyle=).with(Shoes::Swt::TextStyleFactory::UNDERLINE_STYLES["single"])
|
99
|
-
|
100
|
-
subject.paintControl(event)
|
101
|
-
end
|
102
|
-
|
103
|
-
it "sets underline color" do
|
104
|
-
opts[:undercolor] = blue
|
105
|
-
|
106
|
-
expect(style).to receive(:underlineColor=).with(swt_blue)
|
107
|
-
|
108
|
-
subject.paintControl(event)
|
109
|
-
end
|
110
|
-
|
111
|
-
it "sets default underline color to nil" do
|
112
|
-
expect(style).to receive(:underlineColor=).with(nil)
|
113
|
-
|
114
|
-
subject.paintControl(event)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
context "strikethrough option" do
|
119
|
-
it "sets default strikethrough to none" do
|
120
|
-
expect(style).to receive(:strikeout=).with(false)
|
121
|
-
|
122
|
-
subject.paintControl(event)
|
123
|
-
end
|
124
|
-
|
125
|
-
it "sets strikethrough" do
|
126
|
-
opts[:strikethrough] = "single"
|
127
|
-
|
128
|
-
expect(style).to receive(:strikeout=).with(true)
|
129
|
-
|
130
|
-
subject.paintControl(event)
|
131
|
-
end
|
132
|
-
|
133
|
-
it "sets strikethrough color" do
|
134
|
-
opts[:strikecolor] = blue
|
135
|
-
|
136
|
-
expect(style).to receive(:strikeoutColor=).with(swt_blue)
|
137
|
-
|
138
|
-
subject.paintControl(event)
|
139
|
-
end
|
140
|
-
|
141
|
-
it "sets default strikethrough color to nil" do
|
142
|
-
expect(style).to receive(:strikeoutColor=).with(nil)
|
143
|
-
|
144
|
-
subject.paintControl(event)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
context "font styles" do
|
149
|
-
it "sets font style to bold" do
|
150
|
-
opts[:weight] = true
|
151
|
-
expect(::Swt::Font).to receive(:new).with(anything, anything, anything, ::Swt::SWT::BOLD)
|
152
|
-
subject.paintControl(event)
|
153
|
-
end
|
154
|
-
|
155
|
-
it "sets font style to italic" do
|
156
|
-
opts[:emphasis] = true
|
157
|
-
expect(::Swt::Font).to receive(:new).with(anything, anything, anything, ::Swt::SWT::ITALIC)
|
158
|
-
subject.paintControl(event)
|
159
|
-
end
|
160
|
-
|
161
|
-
it "sets font style to both bold and italic" do
|
162
|
-
opts[:weight] = true
|
163
|
-
opts[:emphasis] = true
|
164
|
-
expect(::Swt::Font).to receive(:new).with(anything, anything, anything, ::Swt::SWT::BOLD | ::Swt::SWT::ITALIC)
|
165
|
-
|
166
|
-
subject.paintControl(event)
|
167
|
-
end
|
168
|
-
|
169
|
-
it "sets font style to normal by default" do
|
170
|
-
expect(::Swt::Font).to receive(:new).with(anything, anything, anything, ::Swt::SWT::NORMAL)
|
171
|
-
|
172
|
-
subject.paintControl(event)
|
173
|
-
end
|
174
|
-
|
175
|
-
end
|
176
|
-
|
177
|
-
context "colors" do
|
178
|
-
let(:black) { Shoes::Swt::Color.new(Shoes::COLORS[:black]).real }
|
179
|
-
let(:salmon) { Shoes::Swt::Color.new(Shoes::COLORS[:salmon]).real }
|
180
|
-
|
181
|
-
describe "stroke" do
|
182
|
-
it "is black by default" do
|
183
|
-
expect(::Swt::TextStyle).to receive(:new).with(anything, black, anything)
|
184
|
-
subject.paintControl(event)
|
185
|
-
end
|
186
|
-
|
187
|
-
it "is set with opts[:stroke]" do
|
188
|
-
opts[:stroke] = Shoes::COLORS[:salmon]
|
189
|
-
expect(::Swt::TextStyle).to receive(:new).with(anything, salmon, anything)
|
190
|
-
subject.paintControl(event)
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
describe "fill" do
|
195
|
-
it "is nil by default" do
|
196
|
-
expect(::Swt::TextStyle).to receive(:new).with(anything, anything, nil)
|
197
|
-
subject.paintControl(event)
|
198
|
-
end
|
199
|
-
|
200
|
-
it "is set with opts[:fill]" do
|
201
|
-
opts[:fill] = Shoes::COLORS[:salmon]
|
202
|
-
expect(::Swt::TextStyle).to receive(:new).with(anything, anything, salmon)
|
203
|
-
subject.paintControl(event)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
describe 'text_styles' do
|
209
|
-
# this text_styles relies a lot on the internal structure of TextBlock/Painter
|
210
|
-
# right now, which I'm not too fond of... :)
|
211
|
-
let(:text_styles) {[[0...text.length, [Shoes::Span.new([text], size: 50)]]]}
|
212
|
-
it 'sets the font size to 50' do
|
213
|
-
expect(::Swt::Font).to receive(:new).
|
214
|
-
with(anything, anything, dsl.font_size, anything)
|
215
|
-
expect(::Swt::Font).to receive(:new).
|
216
|
-
with(anything, anything, 50, anything)
|
217
|
-
|
218
|
-
subject.paintControl event
|
219
|
-
end
|
220
|
-
end
|
221
|
-
end
|
@@ -1,183 +0,0 @@
|
|
1
|
-
require 'swt_shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Swt::TextBlock do
|
4
|
-
include_context "swt app"
|
5
|
-
|
6
|
-
let(:height) { 100 }
|
7
|
-
let(:width) { 200 }
|
8
|
-
let(:margin) { 10 }
|
9
|
-
let(:dsl) { double("dsl", app: shoes_app,
|
10
|
-
margin_left: 0, margin_right: 0,
|
11
|
-
margin_top: 0, margin_bottom: 0).as_null_object }
|
12
|
-
|
13
|
-
subject { Shoes::Swt::TextBlock.new(dsl) }
|
14
|
-
|
15
|
-
it_behaves_like "paintable"
|
16
|
-
it_behaves_like "togglable"
|
17
|
-
|
18
|
-
# reported nil, caused trouble in simple-downloader.rb
|
19
|
-
it 'initially responds with empty fitted layouts' do
|
20
|
-
expect(subject.fitted_layouts).to be_empty
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "bounds checking" do
|
24
|
-
it "delegates to fitted layout" do
|
25
|
-
layout = create_layout(0,0)
|
26
|
-
subject.fitted_layouts = [layout]
|
27
|
-
expect(layout).to receive(:in_bounds?)
|
28
|
-
|
29
|
-
subject.in_bounds?(1,1)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "contents alignment" do
|
34
|
-
let(:layout_width) { 100 }
|
35
|
-
let(:layout_height) { 200 }
|
36
|
-
let(:line_height) { 10 }
|
37
|
-
let(:layout) { create_layout(layout_width, layout_height) }
|
38
|
-
let(:fitter) { double("fitter") }
|
39
|
-
let(:fitted_layout) { double("fitted_layout", disposed?: false, layout: layout) }
|
40
|
-
let(:second_fitted_layout) { double("second_fitted_layout", disposed?: false, layout: layout) }
|
41
|
-
let(:current_position) { Shoes::Slot::CurrentPosition.new(0, 0) }
|
42
|
-
|
43
|
-
before(:each) do
|
44
|
-
::Shoes::Swt::TextBlockFitter.stub(:new) { fitter }
|
45
|
-
fitter.stub(:fit_it_in).and_return([fitted_layout], [second_fitted_layout])
|
46
|
-
layout.stub(:line_metrics) { double("line_metrics", height: line_height)}
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "with single layout" do
|
50
|
-
before(:each) do
|
51
|
-
dsl.stub(:absolute_left) { 50 }
|
52
|
-
dsl.stub(:absolute_top) { 0 }
|
53
|
-
dsl.stub(:absolute_bottom) { layout_height }
|
54
|
-
layout.stub(:line_count) { 1 }
|
55
|
-
end
|
56
|
-
|
57
|
-
it "positions single line of text" do
|
58
|
-
expect(dsl).to receive(:absolute_right=).with(layout_width + 50)
|
59
|
-
expect(dsl).to receive(:absolute_bottom=).with(layout_height)
|
60
|
-
expect(dsl).to receive(:absolute_top=).with(layout_height - line_height)
|
61
|
-
|
62
|
-
subject.contents_alignment(current_position)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "positions single line with margin" do
|
66
|
-
dsl.stub(margin_left: margin, margin_right: margin,
|
67
|
-
margin_top: margin, margin_bottom: margin)
|
68
|
-
|
69
|
-
expect(dsl).to receive(:absolute_right=).with(layout_width + 50 + margin)
|
70
|
-
expect(dsl).to receive(:absolute_bottom=).with(layout_height + 2 * margin)
|
71
|
-
expect(dsl).to receive(:absolute_top=).with(layout_height - line_height)
|
72
|
-
|
73
|
-
subject.contents_alignment(current_position)
|
74
|
-
end
|
75
|
-
|
76
|
-
it "pushes to next line if ends in newline" do
|
77
|
-
layout.stub(:text) { "text\n" }
|
78
|
-
|
79
|
-
expect(dsl).to receive(:absolute_right=).with(50)
|
80
|
-
expect(dsl).to receive(:absolute_bottom=).with(layout_height)
|
81
|
-
expect(dsl).to receive(:absolute_top=).with(layout_height)
|
82
|
-
|
83
|
-
subject.contents_alignment(current_position)
|
84
|
-
end
|
85
|
-
|
86
|
-
it "disposes of prior layouts" do
|
87
|
-
subject.contents_alignment(current_position)
|
88
|
-
expect(fitted_layout).to receive(:dispose)
|
89
|
-
|
90
|
-
subject.contents_alignment(current_position)
|
91
|
-
end
|
92
|
-
|
93
|
-
it "should not dispose any layouts" do
|
94
|
-
expect(fitted_layout).not_to receive(:dispose)
|
95
|
-
expect(second_fitted_layout).not_to receive(:dispose)
|
96
|
-
|
97
|
-
subject.contents_alignment(current_position)
|
98
|
-
end
|
99
|
-
|
100
|
-
context "on the second call" do
|
101
|
-
before(:each) do
|
102
|
-
subject.contents_alignment(current_position)
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should only dispose old fitted layout" do
|
106
|
-
expect(fitted_layout).to receive(:dispose)
|
107
|
-
expect(second_fitted_layout).not_to receive(:dispose)
|
108
|
-
|
109
|
-
subject.contents_alignment(current_position)
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should dispose all layouts on clear" do
|
113
|
-
swt_app.stub(:remove_listener)
|
114
|
-
|
115
|
-
expect(fitted_layout).to receive(:dispose).at_least(1).times
|
116
|
-
expect(second_fitted_layout).to receive(:dispose).at_least(1).times
|
117
|
-
|
118
|
-
subject.contents_alignment(current_position)
|
119
|
-
subject.clear
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
describe "with two layouts" do
|
125
|
-
before(:each) do
|
126
|
-
dsl.stub(:parent) { double("dsl parent", absolute_left: 0) }
|
127
|
-
dsl.stub(:absolute_bottom) { layout_height }
|
128
|
-
|
129
|
-
current_position.next_line_start = 0
|
130
|
-
|
131
|
-
fitter.stub(:fit_it_in) {
|
132
|
-
[:unused_layout, double("fitted_layout", layout: layout)]
|
133
|
-
}
|
134
|
-
end
|
135
|
-
|
136
|
-
it "positions in two layouts" do
|
137
|
-
expect(dsl).to receive(:absolute_right=).with(layout_width)
|
138
|
-
expect(dsl).to receive(:absolute_bottom=).with(layout_height)
|
139
|
-
expect(dsl).to receive(:absolute_top=).with(layout_height - line_height)
|
140
|
-
|
141
|
-
subject.contents_alignment(current_position)
|
142
|
-
end
|
143
|
-
|
144
|
-
it "positions in two layouts with margins" do
|
145
|
-
dsl.stub(margin_left: margin, margin_right: margin,
|
146
|
-
margin_top: margin, margin_bottom: margin)
|
147
|
-
|
148
|
-
expect(dsl).to receive(:absolute_right=).with(layout_width + margin)
|
149
|
-
expect(dsl).to receive(:absolute_bottom=).with(layout_height + 2 * margin)
|
150
|
-
expect(dsl).to receive(:absolute_top=).with(layout_height - line_height)
|
151
|
-
|
152
|
-
subject.contents_alignment(current_position)
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
context "links" do
|
158
|
-
let(:link) { Shoes::Link.new(shoes_app, subject, ["link"]) }
|
159
|
-
|
160
|
-
before(:each) do
|
161
|
-
dsl.stub(:links) { [link] }
|
162
|
-
swt_app.stub(:remove_listener)
|
163
|
-
end
|
164
|
-
|
165
|
-
it "clears links" do
|
166
|
-
expect(link).to receive(:clear)
|
167
|
-
subject.clear
|
168
|
-
end
|
169
|
-
|
170
|
-
it "clears links on replace" do
|
171
|
-
expect(link).to receive(:clear)
|
172
|
-
subject.replace("text")
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
def create_layout(width, height, text="layout text")
|
177
|
-
bounds = double("bounds", height: height, width: width)
|
178
|
-
double("layout",
|
179
|
-
get_line_bounds: bounds, bounds: bounds,
|
180
|
-
spacing: 0, text: text).as_null_object
|
181
|
-
end
|
182
|
-
|
183
|
-
end
|