Class: RubyCurses::CellEditor
- Inherits:
-
Object
- Object
- RubyCurses::CellEditor
- Includes:
- ConfigSetup, Utils
- Defined in:
- lib/rbcurse/extras/include/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
Constructor Details
#initialize(component, config = {}, &block) ⇒ CellEditor
Returns a new instance of CellEditor.
16 17 18 19 20 21 22 23 |
# File 'lib/rbcurse/extras/include/celleditor.rb', line 16 def initialize component, config={}, &block @component = component s = @component.class.to_s.downcase() s.slice!("rubycurses::") @_class = s.to_sym 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
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/rbcurse/extras/include/celleditor.rb', line 101 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
42 43 44 |
# File 'lib/rbcurse/extras/include/celleditor.rb', line 42 def checkbox_getvalue @component.getvalue end |
#combobox_getvalue ⇒ Object
45 46 47 48 49 |
# File 'lib/rbcurse/extras/include/celleditor.rb', line 45 def combobox_getvalue #@component.on_leave # added 2009-01-19 12:12 @component.getvalue #@component.selected_item end |
#component ⇒ Object
64 65 66 |
# File 'lib/rbcurse/extras/include/celleditor.rb', line 64 def component @component end |
#field_getvalue ⇒ Object
maybe this should check valid (on_leave) and throw exception
37 38 39 40 41 |
# File 'lib/rbcurse/extras/include/celleditor.rb', line 37 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
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rbcurse/extras/include/celleditor.rb', line 24 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
68 69 70 71 72 73 74 |
# File 'lib/rbcurse/extras/include/celleditor.rb', line 68 def on_leave row, col f = @component f.on_leave if f.respond_to? :editable and f.modified? f.fire_handler(:CHANGED, f) end end |
#prepare_editor(parent, row, col, value) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/rbcurse/extras/include/celleditor.rb', line 75 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: #{widget.form} " # 2011-11-15 12:54:41 #widget.display_length = widget.display_length -1 .bgcolor = 'yellow' .color = 'black' .on_enter #widget.attr = Ncurses::A_REVERSE | Ncurses::A_BOLD end |
#setvalue(value) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rbcurse/extras/include/celleditor.rb', line 50 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 |