Class: RubyCurses::CheckBox

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

Overview

A checkbox, may be selected or unselected

Since:

  • 1.2.0

Instance Attribute Summary

Attributes inherited from Widget

#_object_created, #col_offset, #cols_panned, #config, #curpos, #focussed, #form, #id, #key_label, #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, #default_button, #fire, #handle_key, #mnemonic, #repaint, #selected?

Methods inherited from Widget

#action_manager, #changed, #click, #color_pair, #command, #destroy, #enter, #event_list, #focus, #get_preferred_size, #handle_key, #height, #height=, #hide, #init_vars, #leave, #modified?, #move, #on_enter, #on_leave, #override_graphic, #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

#__create_footer_window, #clear_this, #get_file, #print_this, #rb_getchar, #rb_gets, #rbgetstr, #warn

Methods included from Utils

#OLDdefine_key, #_process_key, #bind_key, #bind_keys, #clean_string!, #define_key, #define_prefix_command, #display_app_help, #get_attrib, #get_color, #keycode_tos, #last_line, #one_line_window, #parse_formatted_text, #print_key_bindings, #repeatm, #run_command, #shell_out, #shell_output, #suspend, #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)

Since:

  • 1.2.0



3162
3163
3164
3165
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 3162

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

Instance Method Details

#getvalueObject

Since:

  • 1.2.0



3166
3167
3168
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 3166

def getvalue
  @value 
end

#getvalue_for_paintObject

Since:

  • 1.2.0



3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 3170

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



61
62
63
64
65
66
67
# File 'lib/rbcurse/core/util/app.rb', line 61

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