class Canis::CheckBox

# 2014-04-17 - 13:15 XXX are these used. required ???

# 2014-08-19 - 20:48 trying to remove excess convenience code
class Widget
  def changed *args, &block
    bind :CHANGED, *args, &block
  end
  def leave *args, &block
    bind :LEAVE, *args, &block
  end
  def enter *args, &block
    bind :ENTER, *args, &block
  end
  # actually we already have command() for buttons
  def click *args, &block
    bind :PRESS, *args, &block
  end
end

A checkbox, may be selected or unselected

Public Class Methods

new(form, config={}) click to toggle source

if a variable has been defined, off and on value will be set in it (default 0,1)

Calls superclass method Canis::ToggleButton::new
# File lib/canis/core/widgets/rwidget.rb, line 3457
def initialize form, config={}, &block
  @surround_chars = ['[', ']']    # 2008-12-23 23:16 added space in Button so overriding
  super
end

Public Instance Methods

getvalue() click to toggle source
# File lib/canis/core/widgets/rwidget.rb, line 3461
def getvalue
  @value 
end
getvalue_for_paint() click to toggle source
# File lib/canis/core/widgets/rwidget.rb, line 3465
def getvalue_for_paint
  buttontext = getvalue() ? "X" : " "
  dtext = @width.nil? ? @text : "%-*s" % [@width, @text]
  dtext = "" if @text.nil?  # added 2009-01-13 00:41 since cbcellrenderer prints no text
  if @align_right
    @text_offset = 0
    @col_offset = dtext.length + @surround_chars[0].length + 1
    return "#{dtext} " + @surround_chars[0] + buttontext + @surround_chars[1] 
  else
    pretext = @surround_chars[0] + buttontext + @surround_chars[1] 
    @text_offset = pretext.length + 1
    @col_offset = @surround_chars[0].length
    #@surround_chars[0] + buttontext + @surround_chars[1] + " #{@text}"
    return pretext + " #{dtext}"
  end
end
text(*val) click to toggle source

a little dicey XXX

Calls superclass method Canis::Button#text
# File lib/canis/core/util/app.rb, line 65
def text(*val)
  raise "FIXME this is being used Checkbox app.rb text(), otherwise delete this. 2014-08-19 - 21:01 "
  if val.empty?
    @value ? @onvalue : @offvalue
  else
    super
  end
end