Class: VR::Col::BlobCol
- Inherits:
-
Object
- Object
- VR::Col::BlobCol
- Includes:
- GladeGUI
- Defined in:
- lib/treeview/columns/BlobCol.rb
Overview
The BlobCol class is a simple text editor for editing strings of data:
It is a very useful class when you want to display and edit long strings
of data in a VR::ListView. To create a coulmn of long strings in a VR::ListView,
simply define the column type as VR::Col::BlobCol:
@view = VR::ListView.new(:name => String, :quote => VR::Col::BlobCol)
row = @view.add_row
row[:name] = "Eric"
row[:quote] = VR::Col::BlobCol.new("I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. - Umberto Eco) ")
The above listview will only display the first 20 characters of the quote, so
it won't destroy the appearance of the listview. When a user clicks on the
quote column, a window like the one above will appear.
See the example project, "listview_objects" for more.
Instance Attribute Summary collapse
-
#edited_callback ⇒ Object
Returns the value of attribute edited_callback.
-
#length_to_display ⇒ Object
Returns the value of attribute length_to_display.
-
#text ⇒ Object
Returns the value of attribute text.
Attributes included from GladeGUI
Instance Method Summary collapse
- #<=>(text_col) ⇒ Object
- #before_show ⇒ Object
-
#buttonCancel__clicked(*args) ⇒ Object
:nodoc:.
-
#buttonSave__clicked(*args) ⇒ Object
:nodoc:.
-
#initialize(text, length_to_display = 20) ⇒ BlobCol
constructor
A new instance of BlobCol.
-
#to_s ⇒ Object
The to_s method outputs the string that is shown in the VR::ListView.
Methods included from GladeGUI
#extract_key, #get_glade_active_record, #get_glade_all, #get_glade_variables, #load_glade, #parse_signals, #set_drag_drop, #set_glade_active_record, #set_glade_all, #set_glade_hash, #set_glade_variables, #show_glade, #try_to_select_text_in_combobox, #window1__destroy
Constructor Details
#initialize(text, length_to_display = 20) ⇒ BlobCol
Returns a new instance of BlobCol
30 31 32 33 |
# File 'lib/treeview/columns/BlobCol.rb', line 30 def initialize(text, length_to_display = 20) @length_to_display = length_to_display @text = text end |
Instance Attribute Details
#edited_callback ⇒ Object
Returns the value of attribute edited_callback.
25 26 27 |
# File 'lib/treeview/columns/BlobCol.rb', line 25 def edited_callback @edited_callback end |
#length_to_display ⇒ Object
Returns the value of attribute length_to_display.
25 26 27 |
# File 'lib/treeview/columns/BlobCol.rb', line 25 def length_to_display @length_to_display end |
#text ⇒ Object
Returns the value of attribute text.
25 26 27 |
# File 'lib/treeview/columns/BlobCol.rb', line 25 def text @text end |
Instance Method Details
#<=>(text_col) ⇒ Object
57 58 59 |
# File 'lib/treeview/columns/BlobCol.rb', line 57 def <=>(text_col) self.text <=> text_col.text end |
#before_show ⇒ Object
35 36 37 |
# File 'lib/treeview/columns/BlobCol.rb', line 35 def before_show() @builder["window1"].resize 650, 360 end |
#buttonCancel__clicked(*args) ⇒ Object
:nodoc:
53 54 55 |
# File 'lib/treeview/columns/BlobCol.rb', line 53 def (*args) # :nodoc: @builder["window1"].close end |
#buttonSave__clicked(*args) ⇒ Object
:nodoc:
48 49 50 51 |
# File 'lib/treeview/columns/BlobCol.rb', line 48 def (*args) # :nodoc: get_glade_variables() @builder["window1"].close end |
#to_s ⇒ Object
The to_s method outputs the string that is shown in the VR::ListView. By default
it will display the first 20 characters of the string. If you
want to change the number of characters it displays, change the
value of the length_to_display variable.
44 45 46 |
# File 'lib/treeview/columns/BlobCol.rb', line 44 def to_s (@text.size > @length_to_display ? @text[0, @length_to_display - 4] + "..." : @text).gsub("\n"," ") end |