class MyRendererMultiline

this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)

Attributes

pc[RW]
tv[RW]

Public Class Methods

new(pc) click to toggle source
Calls superclass method
# File lib/FormHolder/Form/InputHolder/MultiLine.rb, line 7
def initialize(pc)
        @pc=pc
        super(nil,nil)
        set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC)
        @tv=Gtk::TextView.new(@source_buffer = Gtk::TextBuffer.new)
        add(@tv)
        @tv.modify_font(Pango::FontDescription.new('Monospace 10'))
        @found_tag=@tv.buffer.create_tag('found',{'background' => 'yellow'})
        @search_window=Gtk::Window.new(Gtk::Window::POPUP).set_destroy_with_parent(true).set_modal(true).set_window_position(Gtk::Window::POS_CENTER_ON_PARENT).set_decorated(false)
        @search_window.add(Gtk::VBox.new.
                pack_start(Gtk::Label.new("filter: #{item['description']}")).
                pack_start(@entry=Gtk::Entry.new.set_can_focus(true).set_can_default(true))
        )

        @entry.signal_connect("key-release-event"){|me,ev|
                @tv.buffer.remove_tag(@found_tag,@tv.buffer.start_iter,@tv.buffer.end_iter)
                if ev.keyval == Gdk::Keyval::GDK_KEY_Escape
                        @search_window.hide
                        else
                        start_iter=@tv.buffer.start_iter
                        while bounds=start_iter.forward_search(me.text,Gtk::TextIter::SEARCH_TEXT_ONLY,nil)
                                @tv.buffer.apply_tag(@found_tag,bounds[0],bounds[1])
                                start_iter=bounds[1]
                        end
                end
        }
        @entry.signal_connect("activate"){|me|
                @search_window.hide
        }
end

Public Instance Methods

editable() click to toggle source
# File lib/FormHolder/Form/InputHolder/MultiLine.rb, line 43
def editable
        @tv.editable
end
inspect() click to toggle source
# File lib/FormHolder/Form/InputHolder/MultiLine.rb, line 81
def inspect
        "Multiline(#{item['description']})"
end
item() click to toggle source
# File lib/FormHolder/Form/InputHolder/MultiLine.rb, line 40
def item
        @pc.item
end
modify_font(f) click to toggle source
# File lib/FormHolder/Form/InputHolder/MultiLine.rb, line 47
def modify_font(f)
        @tv.modify_font(f)
end
parentM() click to toggle source
# File lib/FormHolder/Form/InputHolder/MultiLine.rb, line 78
def parentM
        @pc.parentM
end
parentselected() click to toggle source
# File lib/FormHolder/Form/InputHolder/MultiLine.rb, line 74
def parentselected
        @pc.parentselected
end
set_sensitive(sens) click to toggle source
# File lib/FormHolder/Form/InputHolder/MultiLine.rb, line 55
def set_sensitive(sens)
        @tv.set_sensitive(sens)
end
text() click to toggle source
# File lib/FormHolder/Form/InputHolder/MultiLine.rb, line 51
def text
        @tv.buffer.text
end
to_s() click to toggle source
# File lib/FormHolder/Form/InputHolder/MultiLine.rb, line 84
def to_s
        inspect
end
update(new_value) click to toggle source
# File lib/FormHolder/Form/InputHolder/MultiLine.rb, line 59
def update(new_value)
        run_events(item['id'],'form_item-BeforeUpdate')
        pc.run_query

        @source_buffer.delete(*@source_buffer.bounds)
        @source_buffer.insert(@source_buffer.get_iter_at_offset(0),"#{item['default']}")
        @tv.set_buffer(@source_buffer)
        edebug("#{self} updated to #{item['default']}","form","info")
        run_events(item['id'],'form_item-AfterUpdate')
end