Class: Shoes::ListBox

Inherits:
Common::UIElement show all
Includes:
Common::Changeable, Common::Focus, Common::State
Defined in:
shoes-core/lib/shoes/list_box.rb

Constant Summary collapse

STYLES =
{ width: 200, height: 29, items: [""] }.freeze

Constants included from Common::State

Common::State::DISABLED_STATE

Constants included from Common::Style

Common::Style::DEFAULT_STYLES, Common::Style::STYLE_GROUPS

Instance Attribute Summary

Attributes inherited from Common::UIElement

#app, #dimensions, #gui, #parent

Instance Method Summary collapse

Methods included from Common::State

#enabled?, #state=, #update_from_state

Methods included from Common::Focus

#focus, #focused?

Methods included from Common::Changeable

#change

Methods included from Common::SafelyEvaluate

#safely_evaluate

Methods inherited from Common::UIElement

#add_to_parent, #before_initialize, #create_backend, #create_dimensions, #initialize, #needs_rotate?, #painted?, #redraw_height, #redraw_left, #redraw_top, #redraw_width, #update_fill, #update_stroke

Methods included from Common::Style

#applicable_app_styles, #create_style_hash, included, #style, #style_init

Methods included from Common::Remove

#remove

Methods included from Common::Positioning

#_position, #displace, #move

Methods included from Common::Visibility

#hidden?, #hidden_from_view?, #hide, #outside_parent_view?, #show, #toggle, #visible?

Methods included from Common::Inspect

#inspect, #to_s

Methods included from Common::Attachable

#attached_to

Constructor Details

This class inherits a constructor from Shoes::Common::UIElement

Instance Method Details

#after_initializeObject



41
42
43
44
45
# File 'shoes-core/lib/shoes/list_box.rb', line 41

def after_initialize
  super
  proxy_array = Shoes::ProxyArray.new(items, @gui)
  @style[:items] = proxy_array
end

#choose(item_or_hash = nil) ⇒ Object Also known as: choose=



57
58
59
60
61
62
63
64
65
66
67
# File 'shoes-core/lib/shoes/list_box.rb', line 57

def choose(item_or_hash = nil)
  case item_or_hash
  when String
    style(choose: item_or_hash)
    @gui.choose item_or_hash
  when Hash
    style(choose: item_or_hash[:item])
    @gui.choose item_or_hash[:item]
  end
  self
end

#handle_block(blk) ⇒ Object



37
38
39
# File 'shoes-core/lib/shoes/list_box.rb', line 37

def handle_block(blk)
  change(&blk) if blk
end

#items=(vanilla_array) ⇒ Object



47
48
49
50
51
# File 'shoes-core/lib/shoes/list_box.rb', line 47

def items=(vanilla_array)
  proxy_array = Shoes::ProxyArray.new(vanilla_array, @gui)
  style(items: proxy_array)
  @gui.update_items
end

#textObject



53
54
55
# File 'shoes-core/lib/shoes/list_box.rb', line 53

def text
  @gui.text
end