Class: GGLib::CheckBox

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

Defined Under Namespace

Classes: CheckedHk

Instance Attribute Summary

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, text = "", checked = false, theme = Themes::blank) ⇒ CheckBox

Returns a new instance of CheckBox.



366
367
368
369
370
# File 'lib/ext/widgets.rb', line 366

def initialize(name, x, y, text="", checked=false, theme = Themes::blank)
  @themek = theme
  super(name,x,y,x+13,y+13,theme)
  @checked = checked
end

Instance Method Details

#checked=(val) ⇒ Object



386
387
388
389
390
391
392
393
394
# File 'lib/ext/widgets.rb', line 386

def checked=(val)
  return if val == @checked
  @checked = val
  if @checked
    @theme = @themek.newInstance(CheckedHk.new(@x1,@y1,@x2,@y2))
  else
    @theme = @themek.newInstance(self)
  end
end

#checked?Boolean

Returns:

  • (Boolean)


383
384
385
# File 'lib/ext/widgets.rb', line 383

def checked?
  return @checked
end

#drawObject



395
396
397
# File 'lib/ext/widgets.rb', line 395

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

#onClickObject



371
372
373
# File 'lib/ext/widgets.rb', line 371

def onClick
  self.checked = !@checked
end

#onMouseDownObject



374
375
376
# File 'lib/ext/widgets.rb', line 374

def onMouseDown
  @theme.setDownState
end

#onMouseOutObject



380
381
382
# File 'lib/ext/widgets.rb', line 380

def onMouseOut
  @theme.setDefaultState
end

#onMouseOverObject



377
378
379
# File 'lib/ext/widgets.rb', line 377

def onMouseOver
  @theme.setOverState
end