Class: RubyCurses::CellEditor
- Inherits:
-
Object
- Object
- RubyCurses::CellEditor
- Includes:
- ConfigSetup, Utils
- Defined in:
- lib/rbcurse/celleditor.rb
Instance Method Summary collapse
-
#cancel_editor ⇒ Object
This may not really be necessary since we paint the cell editor only if editing is on.
- #checkbox_getvalue ⇒ Object
- #combobox_getvalue ⇒ Object
- #component ⇒ Object
-
#field_getvalue ⇒ Object
maybe this should check valid (on_leave) and throw exception.
- #getvalue ⇒ Object
-
#initialize(component, config = {}, &block) ⇒ CellEditor
constructor
A new instance of CellEditor.
-
#on_leave(row, col) ⇒ Object
should be called from on_leave_cell of table, but is beng called from editing_stopped FIXME.
- #prepare_editor(parent, row, col, value) ⇒ Object
- #setvalue(value) ⇒ Object
Methods included from Utils
#_process_key, #bind_key, #clean_string!, #get_color, #keycode_tos, #repeatm, #wrap_text
Methods included from ConfigSetup
#cget, #config_setup, #configure, #variable_set
Constructor Details
#initialize(component, config = {}, &block) ⇒ CellEditor
Returns a new instance of CellEditor.
21 22 23 24 25 26 27 28 29 |
# File 'lib/rbcurse/celleditor.rb', line 21 def initialize component, config={}, &block @component = component s = @component.class.to_s.downcase() s.slice!("rubycurses::") @_class = s.to_sym #$log.debug " CELL EIDOTR got #{@_class}" config_setup config # @config.each_pair { |k,v| variable_set(k,v) } instance_eval &block if block_given? end |
Instance Method Details
#cancel_editor ⇒ Object
This may not really be necessary since we paint the cell editor only if editing is on
109 110 111 112 113 114 115 116 117 118 |
# File 'lib/rbcurse/celleditor.rb', line 109 def cancel_editor = component() # NOOO THIS IS CALLED BY CANCEL AND STOP # somehow we need to ensure that if on_leave fails you can't get out. Here its a bit late # i think FIXME TODO #widget.on_leave # call so any triggers or validations can fire .focusable = false .visible = false .attr = Ncurses::A_REVERSE end |
#checkbox_getvalue ⇒ Object
48 49 50 |
# File 'lib/rbcurse/celleditor.rb', line 48 def checkbox_getvalue @component.getvalue end |
#combobox_getvalue ⇒ Object
51 52 53 54 55 |
# File 'lib/rbcurse/celleditor.rb', line 51 def combobox_getvalue #@component.on_leave # added 2009-01-19 12:12 @component.getvalue #@component.selected_item end |
#component ⇒ Object
70 71 72 |
# File 'lib/rbcurse/celleditor.rb', line 70 def component @component end |
#field_getvalue ⇒ Object
maybe this should check valid (on_leave) and throw exception
43 44 45 46 47 |
# File 'lib/rbcurse/celleditor.rb', line 43 def field_getvalue #@component.on_leave # throws exception! Added 2009-01-17 00:47 @component.init_vars # 2009-01-18 01:13 should not carry over to next row curpos and pcol return @component.getvalue end |
#getvalue ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rbcurse/celleditor.rb', line 30 def getvalue case @_class when :field return field_getvalue when :checkbox return checkbox_getvalue when :combobox return combobox_getvalue else raise "Unknown class #{@_class} in CellEditor getv" end end |
#on_leave(row, col) ⇒ Object
should be called from on_leave_cell of table, but is beng called from editing_stopped FIXME
74 75 76 77 78 79 80 81 |
# File 'lib/rbcurse/celleditor.rb', line 74 def on_leave row, col f = @component f.on_leave if f.respond_to? :editable and f.modified? $log.debug " Table about to fire CHANGED for #{f} " f.fire_handler(:CHANGED, f) end end |
#prepare_editor(parent, row, col, value) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/rbcurse/celleditor.rb', line 82 def prepare_editor parent, row, col, value #value = value.dup if value.respond_to? :dup value = value.dup rescue value setvalue value #.dup = component() .row = row .col = col # unfortunately 2009-01-11 19:47 combo boxes editable allows changing value # FIXME so combo's can be editable, but no new value added if @_class == :combobox .editable = false if .respond_to? :editable # chb's don't ??? else .editable = true if .respond_to? :editable # chb's don't ??? end .focusable = true .visible = true .form = parent.form #$log.debug " prepare editor value #{widget.display_length} displlen #{widget.maxlen}" $log.debug " prepare editor form: #{.form} " #widget.display_length = widget.display_length -1 .bgcolor = 'yellow' .color = 'black' .on_enter #widget.attr = Ncurses::A_REVERSE | Ncurses::A_BOLD #$log.debug " prepare editor value #{value} : fr:#{row}, fc:#{col}" end |
#setvalue(value) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rbcurse/celleditor.rb', line 56 def setvalue value case @_class when :field @component.set_buffer value when :checkbox @component.checked value when :combobox @component.set_buffer value #index = @component.list.index value #@component.current_index = index else raise "Unknown class #{@_class} in CellEditor setv" end end |