Class: GGLib::RadioGroup
- Inherits:
-
Widget
- Object
- Tile
- Containable
- Widget
- GGLib::RadioGroup
- Defined in:
- lib/ext/widgets.rb
Defined Under Namespace
Instance Attribute Summary
Attributes inherited from Widget
#buttonId, #defimage, #id, #name, #sleeping, #window, #zfocus
Attributes inherited from Containable
#align, #container, #maxSize, #minSize, #offset, #padding, #valign
Attributes inherited from Tile
#id, #inclusive, #x1, #x2, #y1, #y2
Instance Method Summary collapse
-
#initialize(name, x, y, buttons = {}, layout = Layout::Vertical, spacing = -1,, theme = Themes::blank) ⇒ RadioGroup
constructor
A new instance of RadioGroup.
- #selected ⇒ Object
- #selected=(val) ⇒ Object
- #theme ⇒ Object
- #theme=(val) ⇒ Object
- #value ⇒ Object
- #value=(val) ⇒ Object
Methods inherited from Widget
#acceptStickyFocus?, #acceptText?, #blur, #button, #clicked?, #del, #downevent, #draw, #event, #feedText, #focus, #hasFocus?, #hasStickyFocus?, #intDraw, #onClick, #onDelete, #onDrag, #onInitialize, #onKeyDown, #onKeyUp, #onMouseDown, #onMouseOut, #onMouseOver, #onRightClick, #onRightDrag, #onRightMouseDown, #onStickyBlur, #onStickyFocus, #over?, #sleep, #sleeping?, #stickFocus, #unstickFocus, #wakeUp
Methods inherited from Tile
#centerOn, #del, deleteAllInstances, deleteById, #each, #eachBorder, getAllInstances, getById, #height, #iTile, intersect?, #intersect?, #isInTile?, #move, #resize, setAllInstances, #setCoordinates, #setTile, #width, #xTile
Constructor Details
#initialize(name, x, y, buttons = {}, layout = Layout::Vertical, spacing = -1,, theme = Themes::blank) ⇒ RadioGroup
Returns a new instance of RadioGroup.
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
# File 'lib/ext/widgets.rb', line 476 def initialize(name, x, y, = {}, layout = Layout::Vertical, spacing = -1, theme = Themes::blank) super(name,x,y,x,y,Themes::blank,false) @buttons = Array.new(.size) i = 0 if layout == Layout::Horizontal if spacing == -1 spacing = 75 end .each { |k,v| @buttons.push(RadioButton.new(k, x+i, y, v, self, false, theme)) i+=spacing } else if spacing == -1 spacing = 25 end .each { |k,v| @buttons.push(RadioButton.new(k, x, y+i, v, self, false, theme)) i+=spacing } end end |
Instance Method Details
#selected ⇒ Object
517 518 519 |
# File 'lib/ext/widgets.rb', line 517 def selected return @selected end |
#selected=(val) ⇒ Object
520 521 522 |
# File 'lib/ext/widgets.rb', line 520 def selected=(val) @selected = val end |
#theme ⇒ Object
498 499 500 501 |
# File 'lib/ext/widgets.rb', line 498 def theme return @buttons[0].theme if @buttons.size > 0 return Themes::blank end |
#theme=(val) ⇒ Object
502 503 504 505 506 |
# File 'lib/ext/widgets.rb', line 502 def theme=(val) @buttons.each { || .theme = val } end |
#value ⇒ Object
507 508 509 510 |
# File 'lib/ext/widgets.rb', line 507 def value return @selected.value unless @selected.nil? return nil end |
#value=(val) ⇒ Object
511 512 513 514 515 516 |
# File 'lib/ext/widgets.rb', line 511 def value=(val) @buttons.each { || self.selected = if .value == val } raise RuntimeException.new("No value #{val} in #{self.inspect} (#{self.name})") end |