Class: TkWrapper::Widgets::Base::Padding

Inherits:
Object
  • Object
show all
Defined in:
lib/widgets/base/padding.rb

Instance Method Summary collapse

Constructor Details

#initialize(widget) ⇒ Padding

Returns a new instance of Padding.



4
5
6
# File 'lib/widgets/base/padding.rb', line 4

def initialize(widget)
  @widget = widget
end

Instance Method Details

#bottomObject



41
42
43
# File 'lib/widgets/base/padding.rb', line 41

def bottom
  get[:bottom]
end

#bottom=(bottom) ⇒ Object



57
58
59
# File 'lib/widgets/base/padding.rb', line 57

def bottom=(bottom)
  set(bottom: bottom)
end

#getObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/widgets/base/padding.rb', line 18

def get
  (left, top, right, bottom) = @widget.tk_widget.padding.split

  {
    left:   left   || 0,
    top:    top    || left || 0,
    right:  right  || left || 0,
    bottom: bottom || top  || left || 0
  }
end

#leftObject



29
30
31
# File 'lib/widgets/base/padding.rb', line 29

def left
  get[:left]
end

#left=(left) ⇒ Object



45
46
47
# File 'lib/widgets/base/padding.rb', line 45

def left=(left)
  set(left: left)
end

#rightObject



37
38
39
# File 'lib/widgets/base/padding.rb', line 37

def right
  get[:right]
end

#right=(right) ⇒ Object



53
54
55
# File 'lib/widgets/base/padding.rb', line 53

def right=(right)
  set(right: right)
end

#set(left: nil, top: nil, right: nil, bottom: nil) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/widgets/base/padding.rb', line 8

def set(left: nil, top: nil, right: nil, bottom: nil)
  values = get
  @widget.tk_widget.padding = [
    left   || values.left,
    top    || values.top,
    right  || values.right,
    bottom || values.bottom
  ]
end

#topObject



33
34
35
# File 'lib/widgets/base/padding.rb', line 33

def top
  get[:top]
end

#top=(top) ⇒ Object



49
50
51
# File 'lib/widgets/base/padding.rb', line 49

def top=(top)
  set(top: top)
end