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 Tile

#id, #inclusive, #x1, #x2, #y1, #y2

Instance Method Summary collapse

Methods inherited from Widget

#blur, #button, #clicked?, #del, #downevent, #event, #feedText, #focus, #hasFocus?, #hasStickyFocus?, #intDraw, #onDelete, #onDrag, #onInitialize, #onKeyPress, #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, 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.



409
410
411
412
413
414
415
# File 'lib/ext/widgets.rb', line 409

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.



408
409
410
# File 'lib/ext/widgets.rb', line 408

def parent
  @parent
end

#valueObject (readonly)

Returns the value of attribute value.



408
409
410
# File 'lib/ext/widgets.rb', line 408

def value
  @value
end

Instance Method Details

#checked=(val) ⇒ Object



431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
# File 'lib/ext/widgets.rb', line 431

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)


428
429
430
# File 'lib/ext/widgets.rb', line 428

def checked?
  return @checked
end

#drawObject



448
449
450
# File 'lib/ext/widgets.rb', line 448

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

#onClickObject



416
417
418
# File 'lib/ext/widgets.rb', line 416

def onClick
  self.checked=!@checked
end

#onMouseDownObject



419
420
421
# File 'lib/ext/widgets.rb', line 419

def onMouseDown
  @theme.setDownState
end

#onMouseOutObject



425
426
427
# File 'lib/ext/widgets.rb', line 425

def onMouseOut
  @theme.setDefaultState
end

#onMouseOverObject



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

def onMouseOver
  @theme.setOverState
end