Class: Umbra::Checkbox

Inherits:
ToggleButton show all
Defined in:
lib/umbra/checkbox.rb

Overview

A checkbox, may be selected or unselected

Instance Attribute Summary

Attributes inherited from ToggleButton

#offvalue, #onvalue

Attributes inherited from Button

#mnemonic, #surround_chars

Attributes inherited from Widget

#col, #col_offset, #curpos, #focusable, #graphic, #handler, #key_label, #modified, #name, #repaint_required, #row, #row_offset, #state

Instance Method Summary collapse

Methods inherited from ToggleButton

#checked, #checked?, #fire, #handle_key, #toggle, #value

Methods inherited from Button

#action, button_layout, #fire, #handle_key, #map_keys, #repaint, #selected?

Methods inherited from Widget

#_form=, #color_pair, #command, #handle_key, #height, #highlight_attr, #init_vars, #modified?, #on_enter, #on_leave, #repaint, #repaint_all, #rowcol, #set_form_col, #set_form_row, #text, #touch, #variable_set, #visible, #width

Methods included from KeyMappingHandler

#_process_key, #bind_key, #bind_keys, #process_key, #unbind_key

Methods included from EventHandler

#bind_event, #event?, #fire_handler, #fire_property_change, #register_events

Constructor Details

#initialize(config = {}, &block) ⇒ Checkbox

Returns a new instance of Checkbox.



17
18
19
20
# File 'lib/umbra/checkbox.rb', line 17

def initialize config={}, &block
  @surround_chars = ['[', ']']    # 2008-12-23 23:16 added space in Button so overriding
  super
end

Instance Method Details

#getvalueObject



21
22
23
# File 'lib/umbra/checkbox.rb', line 21

def getvalue
  @value 
end

#getvalue_for_paintObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/umbra/checkbox.rb', line 25

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