Class: Tk::TkGeometry

Inherits:
Struct
  • Object
show all
Defined in:
lib/ffi-tk/geometry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tcl_string) ⇒ TkGeometry

Returns a new instance of TkGeometry.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ffi-tk/geometry.rb', line 4

def initialize(tcl_string)
  str = tcl_string.to_s

  if /^\=?(?<width>\d+)x(?<height>\d+)(?<x>[+-]\d+)(?<y>[+-]\d+)$/ =~ str
    self.width = Integer(width)
    self.height = Integer(height)
    self.x = Integer(x)
    self.y = Integer(y)
  elsif /^\=?(?<width>\d+)x(?<height>\d+)$/ =~ str
    self.width = Integer(width)
    self.height = Integer(height)
  elsif /^\=?(?<x>[+-]\d+)(?<y>[+-]\d+)$/ =~ str
    self.x = Integer(x)
    self.y = Integer(y)
  else
    raise 'Invalid geometry: %p' % [tcl_string]
  end
end

Instance Attribute Details

#heightObject

Returns the value of attribute height

Returns:

  • (Object)

    the current value of height



3
4
5
# File 'lib/ffi-tk/geometry.rb', line 3

def height
  @height
end

#originalObject

Returns the value of attribute original

Returns:

  • (Object)

    the current value of original



3
4
5
# File 'lib/ffi-tk/geometry.rb', line 3

def original
  @original
end

#widthObject

Returns the value of attribute width

Returns:

  • (Object)

    the current value of width



3
4
5
# File 'lib/ffi-tk/geometry.rb', line 3

def width
  @width
end

#xObject

Returns the value of attribute x

Returns:

  • (Object)

    the current value of x



3
4
5
# File 'lib/ffi-tk/geometry.rb', line 3

def x
  @x
end

#yObject

Returns the value of attribute y

Returns:

  • (Object)

    the current value of y



3
4
5
# File 'lib/ffi-tk/geometry.rb', line 3

def y
  @y
end

Instance Method Details

#to_tclObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ffi-tk/geometry.rb', line 23

def to_tcl
  if width && height && x && y
    '=%dx%d%+d%+d' % [width, height, x, y]
  elsif width && height
    '=%dx%d%' % [width, height]
  elsif x && y
    '=+d%+d' % [x, y]
  else
    raise 'Incomplete geometry: %p' % [self]
  end
end