Class: SKUI::Control
Overview
Base class which all SKUI controls inherit from.
Instance Attribute Summary collapse
- #rect ⇒ Rect readonly
Attributes inherited from Base
Instance Method Summary collapse
- #enabled ⇒ Boolean
-
#initialize ⇒ Control
constructor
A new instance of Control.
- #left ⇒ Integer
-
#name ⇒ Symbol
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 )`.
-
#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.
- #release ⇒ Nil
- #size(width, height) ⇒ Array(width,height)
- #stretch(left, top, right, bottom) ⇒ Array(left,top,right,bottom)
- #tab_index ⇒ Integer
- #tooltip ⇒ String
- #visible ⇒ Boolean
- #width ⇒ Integer
- #z_index ⇒ Integer
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
Instance Attribute Details
Instance Method Details
#enabled ⇒ Boolean
21 |
# File 'src/SKUI/control.rb', line 21 prop_bool( :enabled, &TypeCheck::BOOLEAN ) |
#left ⇒ Integer
29 |
# File 'src/SKUI/control.rb', line 29 prop( :left, :top, :right, :bottom, &TypeCheck::INTEGER ) |
#name ⇒ Symbol
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 )`
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.
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 |
#release ⇒ Nil
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)
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)
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_index ⇒ Integer
41 |
# File 'src/SKUI/control.rb', line 41 prop( :tab_index, &TypeCheck::INTEGER ) |
#visible ⇒ Boolean
25 |
# File 'src/SKUI/control.rb', line 25 prop_bool( :visible, &TypeCheck::BOOLEAN ) |