Class: RubyCurses::CheckBox

Inherits:
ToggleButton show all
Defined in:
lib/rbcurse/rwidget.rb,
lib/rbcurse/app.rb

Overview

A checkbox, may be selected or unselected TODO hotkey should work here too.

Constant Summary

Constants included from Io

Io::ERROR_COLOR_PAIR, Io::FOOTER_COLOR_PAIR, Io::LINEONE, Io::MAIN_WINDOW_COLOR_PAIR

Instance Attribute Summary

Attributes inherited from Widget

#_object_created, #col_offset, #cols_panned, #config, #curpos, #focussed, #form, #id, #parent_component, #row_offset, #rows_panned, #state

Instance Method Summary collapse

Methods inherited from ToggleButton

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

Methods inherited from Button

#action, #bind_hotkey, button_layout, #command, #fire, #handle_key, #mnemonic, #repaint

Methods inherited from Widget

#changed, #click, #destroy, #enter, #event_list, #focus, #get_preferred_size, #handle_key, #height, #height=, #hide, #init_vars, #leave, #modified?, #move, #on_enter, #on_leave, #override_graphic, #printstring, #process_key, #remove, #repaint, #repaint_all, #repaint_required, #rowcol, #set_buffer_modified, #set_buffering, #set_form, #set_form_col, #set_form_row, #set_modified, #setformrowcol, #setrowcol, #show, #text_variable, #unbind_key, #width, #width=

Methods included from Io

#askchoice, #askyesno, #askyesnocancel, #clear_error, #clear_this, #get_string, #newaskyesno, #old_print_header, #old_print_top_right, #print_action, #print_error, #print_footer_help, #print_header, #print_headers, #print_help, #print_help_page, #print_in_middle, #print_key_labels, #print_key_labels_row, #print_screen_labels, #print_status, #print_this, #print_top_right, #rbgetstr, #warn

Methods included from Utils

#_process_key, #bind_key, #clean_string!, #get_color, #keycode_tos, #repeatm, #view, #wrap_text

Methods included from ConfigSetup

#cget, #config_setup, #configure, #variable_set

Methods included from EventHandler

#bind, #fire_handler, #fire_property_change

Constructor Details

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

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



2569
2570
2571
2572
# File 'lib/rbcurse/rwidget.rb', line 2569

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

Instance Method Details

#getvalueObject



2573
2574
2575
# File 'lib/rbcurse/rwidget.rb', line 2573

def getvalue
  @value 
end

#getvalue_for_paintObject



2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
# File 'lib/rbcurse/rwidget.rb', line 2577

def getvalue_for_paint
  buttontext = getvalue() ? "X" : " "
  dtext = @display_length.nil? ? @text : "%-*s" % [@display_length, @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) ⇒ Object

a little dicey XXX



64
65
66
67
68
69
70
# File 'lib/rbcurse/app.rb', line 64

def text(*val)
  if val.empty?
    @value ? @onvalue : @offvalue
  else
    super
  end
end