Class: UnderOs::UI::Icon

Inherits:
View
  • Object
show all
Includes:
IconEngine
Defined in:
lib/under_os/ui/icon.rb

Constant Summary

Constants included from Wrap

Wrap::INSTANCES_CACHE, Wrap::RAW_WRAPS_MAP, Wrap::WRAPS_TAGS_MAP

Instance Method Summary collapse

Methods included from IconEngine

included

Methods inherited from View

#inspect

Methods included from Manipulation

#append, #clear, #insert, #insertTo, #prepend, #remove

Methods included from Traversing

#children, #empty?, #find, #first, #matches, #parent, #siblings

Methods included from Dimensions

#position, #position=

Methods included from Animation

#animate, #fade_in, #fade_out, #highlight

Methods included from Commons

#data, #data=, #hidden, #hide, #id, #id=, #page, #show, #tagName, #toggle, #visible

Methods included from Styles

#addClass, #className, #className=, #classNames, #classNames=, #hasClass, #radioClass, #removeClass, #repaint, #style, #style=, #toggleClass

Methods included from Events

#emit, #off, #on, #on=

Methods included from Wrap

included

Constructor Details

#initialize(options) ⇒ Icon

Returns a new instance of Icon.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/under_os/ui/icon.rb', line 7

def initialize(options)
  options = {type: options} if ! options.is_a?(Hash)

  super(options)

  self.type = options.delete(:type) || :bug
  self.size = options.delete(:size) || 20

  @_.sizeToFit
  @_.showsTouchWhenHighlighted = true
end

Instance Method Details

#size(size = nil) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/under_os/ui/icon.rb', line 28

def size(size=nil)
  if size
    self.size = size
    self
  else
    @size
  end
end

#size=(size) ⇒ Object



37
38
39
40
41
# File 'lib/under_os/ui/icon.rb', line 37

def size=(size)
  @size = size
  @_.setFont self.class.engine.font(size)
  @_.sizeToFit
end

#typeObject



19
20
21
# File 'lib/under_os/ui/icon.rb', line 19

def type
  @type
end

#type=(type) ⇒ Object



23
24
25
26
# File 'lib/under_os/ui/icon.rb', line 23

def type=(type)
  @type = type
  @_.setTitle self.class.engine.text(type), forState:UIControlStateNormal
end