Class: RubyCurses::RadioButton
- Inherits:
-
ToggleButton
- Object
- Widget
- Button
- ToggleButton
- RubyCurses::RadioButton
- Defined in:
- lib/rbhex/core/widgets/rwidget.rb
Overview
A selectable button that has a text value. It is based on a Variable that is shared by other radio buttons. Only one is selected at a time, unlike checkbox 2008-11-27 18:45 just made this inherited from Checkbox
Direct Known Subclasses
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
-
#checked(tf) ⇒ Object
ideally this should not be used.
-
#fire ⇒ Object
added for bindkeys since that calls fire, not toggle - XXX i don’t like this.
-
#getvalue ⇒ Object
all radio buttons will return the value of the selected value, not the offered value.
- #getvalue_for_paint ⇒ Object
-
#initialize(form, config = {}, &block) ⇒ RadioButton
constructor
if a variable has been defined, off and on value will be set in it (default 0,1).
- #toggle ⇒ Object
Methods inherited from ToggleButton
Methods inherited from Button
#action, #bind_hotkey, button_layout, #command, #default_button, #handle_key, #mnemonic, #repaint, #selected?, #text
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) ⇒ RadioButton
if a variable has been defined, off and on value will be set in it (default 0,1)
3213 3214 3215 3216 3217 3218 3219 3220 3221 |
# File 'lib/rbhex/core/widgets/rwidget.rb', line 3213 def initialize form, config={}, &block @surround_chars = ['(', ')'] if @surround_chars.nil? super $log.warn "XXX: FIXME Please set 'value' for radiobutton. If you don't know, try setting it to 'text'" unless @value # I am setting value of value here if not set 2011-10-21 @value ||= @text ## trying with off since i can't do conventional style construction #raise "A single Variable must be set for a group of Radio Buttons for this to work." unless @variable end |
Instance Method Details
#checked(tf) ⇒ Object
ideally this should not be used. But implemented for completeness. it is recommended to toggle some other radio button than to uncheck this.
3259 3260 3261 3262 3263 3264 3265 |
# File 'lib/rbhex/core/widgets/rwidget.rb', line 3259 def checked tf if tf toggle elsif !@variable.nil? and getvalue() != @value # XXX ??? @variable.set_value "","" end end |
#fire ⇒ Object
added for bindkeys since that calls fire, not toggle - XXX i don’t like this
3251 3252 3253 3254 |
# File 'lib/rbhex/core/widgets/rwidget.rb', line 3251 def fire @variable.set_value @value,@name super end |
#getvalue ⇒ Object
all radio buttons will return the value of the selected value, not the offered value
3224 3225 3226 3227 |
# File 'lib/rbhex/core/widgets/rwidget.rb', line 3224 def getvalue #@text_variable.value @variable.get_value @name end |
#getvalue_for_paint ⇒ Object
3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 |
# File 'lib/rbhex/core/widgets/rwidget.rb', line 3229 def getvalue_for_paint = getvalue() == @value ? "o" : " " dtext = @display_length.nil? ? text : "%-*s" % [@display_length, text] if @align_right @text_offset = 0 @col_offset = dtext.length + @surround_chars[0].length + 1 return "#{dtext} " + @surround_chars[0] + + @surround_chars[1] else pretext = @surround_chars[0] + + @surround_chars[1] @text_offset = pretext.length + 1 @col_offset = @surround_chars[0].length return pretext + " #{dtext}" end end |
#toggle ⇒ Object
3244 3245 3246 3247 3248 |
# File 'lib/rbhex/core/widgets/rwidget.rb', line 3244 def toggle @variable.set_value @value, @name # call fire of button class 2008-12-09 17:49 fire end |