Class: SKUI::Control

Inherits:
Base
  • Object
show all
Defined in:
src/SKUI/control.rb

Overview

Base class which all SKUI controls inherit from.

Since:

  • 1.0.0

Direct Known Subclasses

Button, Checkbox, Container, Image, Label, Listbox, Textbox

Instance Attribute Summary collapse

Attributes inherited from Base

#properties, #window

Instance Method Summary collapse

Methods inherited from Base

#background_color, #font, #foreground_color, #inspect, #parent, #to_js, #typename, #ui_id

Methods included from Events

#add_event_handler, included, #release_events, #trigger_event

Constructor Details

#initializeControl

Returns a new instance of Control.

Since:

  • 1.0.0



55
56
57
58
# File 'src/SKUI/control.rb', line 55

def initialize
  super()
  @rect = Rect.new( self )
end

Instance Attribute Details

#rectRect (readonly)

Returns:

Since:

  • 1.0.0



52
53
54
# File 'src/SKUI/control.rb', line 52

def rect
  @rect
end

Instance Method Details

#enabledBoolean

Returns:

  • (Boolean)

Since:

  • 1.0.0



21
# File 'src/SKUI/control.rb', line 21

prop_bool( :enabled, &TypeCheck::BOOLEAN )

#leftInteger

Returns:

  • (Integer)

Since:

  • 1.0.0



29
# File 'src/SKUI/control.rb', line 29

prop( :left, :top, :right, :bottom, &TypeCheck::INTEGER )

#nameSymbol

Alternative way to refer to a Control - by assigning a Symbol name to it you can refer to a control like so: ‘window.find_control_by_name( :foo )`

Returns:

  • (Symbol)

Since:

  • 1.0.0



17
# File 'src/SKUI/control.rb', line 17

prop( :name, &TypeCheck::SYMBOL )

#position(x, y) ⇒ Array(x,y)

Positive ‘x` value will anchor the control to the left side of the container, negative will anchor the control to the right side.

Likewise for y, positive anchors to the top, negative anchors to the bottom.

Not that if you have previously set ‘left` and `right`to stretch the control within it’s parent the stretch will be reset.

Parameters:

  • x (Numeric)
  • y (Numeric)

Returns:

  • (Array(x,y))

Since:

  • 1.0.0



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'src/SKUI/control.rb', line 74

def position( x, y )
  if x < 0
    @properties[ :right ] = x.abs
    @properties[ :left ] = nil
  else
    @properties[ :left ] = x
    @properties[ :right ] = nil
  end
  if y < 0
    @properties[ :bottom ] = y.abs
    @properties[ :top ] = nil
  else
    @properties[ :top ] = y
    @properties[ :bottom ] = nil
  end
  update_properties( :left, :top, :right, :bottom )
  [ x, y ]
end

#releaseNil

Returns:

  • (Nil)

See Also:

Since:

  • 1.0.0



96
97
98
99
100
101
# File 'src/SKUI/control.rb', line 96

def release
  super
  @rect.release
  @rect = nil
  nil
end

#size(width, height) ⇒ Array(width,height)

Parameters:

  • width (Numeric)
  • height (Numeric)

Returns:

Since:

  • 1.0.0



108
109
110
111
112
113
# File 'src/SKUI/control.rb', line 108

def size( width, height )
  @properties[ :width ]  = width
  @properties[ :height ] = height
  update_properties( :width, :height )
  [ width, height ]
end

#stretch(left, top, right, bottom) ⇒ Array(left,top,right,bottom)

Parameters:

  • left (Numeric)
  • top (Numeric)
  • right (Numeric)
  • bottom (Numeric)

Returns:

  • (Array(left,top,right,bottom))

Since:

  • 1.0.0



122
123
124
125
126
127
128
129
# File 'src/SKUI/control.rb', line 122

def stretch( left, top, right, bottom )
  @properties[ :left ]   = left
  @properties[ :top ]    = top
  @properties[ :right ]  = right
  @properties[ :bottom ] = bottom
  update_properties( :left, :top, :right, :bottom )
  [ left, top, right, bottom ]
end

#tab_indexInteger

Returns:

  • (Integer)

Since:

  • 1.0.0



41
# File 'src/SKUI/control.rb', line 41

prop( :tab_index, &TypeCheck::INTEGER )

#tooltipString

Returns:

  • (String)

Since:

  • 1.0.0



45
# File 'src/SKUI/control.rb', line 45

prop( :tooltip, &TypeCheck::STRING )

#visibleBoolean

Returns:

  • (Boolean)

Since:

  • 1.0.0



25
# File 'src/SKUI/control.rb', line 25

prop_bool( :visible, &TypeCheck::BOOLEAN )

#widthInteger

Returns:

  • (Integer)

Since:

  • 1.0.0



33
# File 'src/SKUI/control.rb', line 33

prop( :width, :height, &TypeCheck::INTEGER )

#z_indexInteger

Returns:

  • (Integer)

Since:

  • 1.0.0



37
# File 'src/SKUI/control.rb', line 37

prop( :z_index, &TypeCheck::INTEGER )