Class: GGLib::RadioGroup

Inherits:
Widget show all
Defined in:
lib/ext/widgets.rb

Defined Under Namespace

Modules: Layout, Spacing

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

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, buttons = {}, layout = Layout::Vertical, spacing = -1, theme = Themes::blank)
  super(name,x,y,x,y,Themes::blank,false)
  @buttons = Array.new(buttons.size)
  i = 0
  if layout == Layout::Horizontal
    if spacing == -1
      spacing = 75
    end
    buttons.each { |k,v|
      @buttons.push(RadioButton.new(k, x+i, y, v, self, false, theme))
      i+=spacing
    }
  else
    if spacing == -1
      spacing = 25
    end
    buttons.each { |k,v|
      @buttons.push(RadioButton.new(k, x, y+i, v, self, false, theme))
      i+=spacing
    }
  end
end

Instance Method Details

#selectedObject



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

#themeObject



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 { |button|
    button.theme = val
  }
end

#valueObject



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

Raises:

  • (RuntimeException)


511
512
513
514
515
516
# File 'lib/ext/widgets.rb', line 511

def value=(val)
  @buttons.each { |button|
    self.selected = button if button.value == val
  }
  raise RuntimeException.new("No value #{val} in #{self.inspect} (#{self.name})")
end