Class: GGLib::RadioButton

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

Defined Under Namespace

Classes: CheckedHk

Instance Attribute Summary collapse

Attributes inherited from Widget

#buttonId, #defimage, #id, #name, #sleeping, #theme, #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, #event, #feedText, #focus, #hasFocus?, #hasStickyFocus?, #intDraw, #onDelete, #onDrag, #onInitialize, #onKeyDown, #onKeyUp, #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, value, parent, checked = false, theme = Themes::blank) ⇒ RadioButton

Returns a new instance of RadioButton.



423
424
425
426
427
428
429
# File 'lib/ext/widgets.rb', line 423

def initialize(name, x, y, value, parent, checked=false, theme = Themes::blank)
  @themek = theme
  super(name,x,y,x+12,y+12,theme)
  @value = value
  @checked = checked
  @parent = parent
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



422
423
424
# File 'lib/ext/widgets.rb', line 422

def parent
  @parent
end

#valueObject (readonly)

Returns the value of attribute value.



422
423
424
# File 'lib/ext/widgets.rb', line 422

def value
  @value
end

Instance Method Details

#checked=(val) ⇒ Object



445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
# File 'lib/ext/widgets.rb', line 445

def checked=(val)
  @checked = val
  if @checked
    if @parent.selected.nil?
      @theme = @themek.newInstance(CheckedHk.new(@x1,@y1,@x2,@y2))
      @parent.selected = self
      return
    end
    return if @parent.selected  == self
    @theme = @themek.newInstance(CheckedHk.new(@x1,@y1,@x2,@y2))
    @parent.selected.checked = false
    @parent.selected = self
  else
    return if @parent.selected  != self
    @theme = @themek.newInstance(self)
  end
end

#checked?Boolean

Returns:

  • (Boolean)


442
443
444
# File 'lib/ext/widgets.rb', line 442

def checked?
  return @checked
end

#drawObject



462
463
464
# File 'lib/ext/widgets.rb', line 462

def draw
  @theme.font.default.draw(name, @x1+12+1, @y1-2, ZOrder::Text)
end

#onClickObject



430
431
432
# File 'lib/ext/widgets.rb', line 430

def onClick
  self.checked=!@checked
end

#onMouseDownObject



433
434
435
# File 'lib/ext/widgets.rb', line 433

def onMouseDown
  @theme.setDownState
end

#onMouseOutObject



439
440
441
# File 'lib/ext/widgets.rb', line 439

def onMouseOut
  @theme.setDefaultState
end

#onMouseOverObject



436
437
438
# File 'lib/ext/widgets.rb', line 436

def onMouseOver
  @theme.setOverState
end