Class: Shoes::Swt::Slot
- Inherits:
-
Object
- Object
- Shoes::Swt::Slot
- Includes:
- Common::Container, Common::Clickable, Common::Visibility
- Defined in:
- shoes-swt/lib/shoes/swt/slot.rb
Constant Summary collapse
- SCROLLBAR_MAX_WIDTH =
This is more than the scrollbar is expected to be on any OS
20
- SCROLLBAR_PADDING =
For some reason, if we set max to match, you can’t get past last 10!
10
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#dsl ⇒ Object
readonly
Returns the value of attribute dsl.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#real ⇒ Object
readonly
Returns the value of attribute real.
Attributes included from Common::Clickable
Instance Method Summary collapse
-
#initialize(dsl, parent) ⇒ Slot
constructor
A new instance of Slot.
- #redraw_target ⇒ Object
- #remove ⇒ Object
-
#update_position ⇒ Object
needed by Layouter code, but slots are no physical elements so they.
- #update_scroll ⇒ Object
- #update_visibility ⇒ Object
Methods included from Common::Visibility
#hidden?, #hidden_from_view?, #hide, #outside_parent_view?, #show, #toggle, #visible?
Methods included from Common::Clickable
#click, #pass_coordinates?, #register_click, #release
Constructor Details
#initialize(dsl, parent) ⇒ Slot
Returns a new instance of Slot.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'shoes-swt/lib/shoes/swt/slot.rb', line 12 def initialize(dsl, parent) @dsl = dsl @parent = parent @real = parent.real @app = @parent.app @scroll = ::Swt::Widgets::Slider.new(@app.real, ::Swt::SWT::VERTICAL) @scroll.add_selection_listener do |_event| update_scroll end end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
10 11 12 |
# File 'shoes-swt/lib/shoes/swt/slot.rb', line 10 def app @app end |
#dsl ⇒ Object (readonly)
Returns the value of attribute dsl.
10 11 12 |
# File 'shoes-swt/lib/shoes/swt/slot.rb', line 10 def dsl @dsl end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
10 11 12 |
# File 'shoes-swt/lib/shoes/swt/slot.rb', line 10 def parent @parent end |
#real ⇒ Object (readonly)
Returns the value of attribute real.
10 11 12 |
# File 'shoes-swt/lib/shoes/swt/slot.rb', line 10 def real @real end |
Instance Method Details
#redraw_target ⇒ Object
52 53 54 |
# File 'shoes-swt/lib/shoes/swt/slot.rb', line 52 def redraw_target @dsl end |
#remove ⇒ Object
56 57 58 |
# File 'shoes-swt/lib/shoes/swt/slot.rb', line 56 def remove app.click_listener.remove_listeners_for(dsl) end |
#update_position ⇒ Object
needed by Layouter code, but slots are no physical elements so they
26 27 |
# File 'shoes-swt/lib/shoes/swt/slot.rb', line 26 def update_position end |
#update_scroll ⇒ Object
29 30 31 |
# File 'shoes-swt/lib/shoes/swt/slot.rb', line 29 def update_scroll @dsl.scroll_top = @scroll.selection end |
#update_visibility ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'shoes-swt/lib/shoes/swt/slot.rb', line 39 def update_visibility @scroll.set_visible(@dsl.scroll && @dsl.scroll_max.positive?) return unless @dsl.scroll @scroll.selection = @dsl.scroll_top @scroll.maximum = @dsl.scroll_max + SCROLLBAR_PADDING @scroll.set_bounds @dsl.element_right - SCROLLBAR_MAX_WIDTH + 1, @dsl.element_top, SCROLLBAR_MAX_WIDTH, @dsl.element_height end |