Class: Shoes::Swt::Slot

Inherits:
Object
  • Object
show all
Includes:
Common::Container, Common::Clickable, Common::Visibility
Defined in:
shoes-swt/lib/shoes/swt/slot.rb

Direct Known Subclasses

Flow, Stack, Widget

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

Attributes included from Common::Clickable

#pass_coordinates

Instance Method Summary collapse

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

#appObject (readonly)

Returns the value of attribute app.



10
11
12
# File 'shoes-swt/lib/shoes/swt/slot.rb', line 10

def app
  @app
end

#dslObject (readonly)

Returns the value of attribute dsl.



10
11
12
# File 'shoes-swt/lib/shoes/swt/slot.rb', line 10

def dsl
  @dsl
end

#parentObject (readonly)

Returns the value of attribute parent.



10
11
12
# File 'shoes-swt/lib/shoes/swt/slot.rb', line 10

def parent
  @parent
end

#realObject (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_targetObject



52
53
54
# File 'shoes-swt/lib/shoes/swt/slot.rb', line 52

def redraw_target
  @dsl
end

#removeObject



56
57
58
# File 'shoes-swt/lib/shoes/swt/slot.rb', line 56

def remove
  app.click_listener.remove_listeners_for(dsl)
end

#update_positionObject

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_scrollObject



29
30
31
# File 'shoes-swt/lib/shoes/swt/slot.rb', line 29

def update_scroll
  @dsl.scroll_top = @scroll.selection
end

#update_visibilityObject



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