Method: VR::ViewCommon#renderer

Defined in:
lib/treeview/ViewCommon.rb

#renderer(sym) ⇒ Object

Returns the renderer for a given column ID.

In VR::ListView#new (and VR::TreeView#new) method, a data model (VR::ListStore or VR::TreeStore) is automatically contstructed. Then the class will automatically assign a renderer to show it on the screen. These renderers simply convert a piece of data to something visual on the screen. For example, a column in the model might contain a value “true,” but the renderer converts it to a GtkCheckButton which shows a check-mark. The VR::ListView class will automatically assign renderers to each column based on its type:

String, Integer, Float => VR::Col::Ren::CellRendererText TrueClass => VR::Col::Ren::CellRendererToggle GdkPixbuf => VR::Col::Ren::CellRendererPixbuf DateTime => VR::Col::Ren::CellRendererDate VR::Col::CalendarCol, VR::Col::BlobCol => VR::Col::Ren::CellRendererObject VR::Col::SpinCol => VR::Col::Ren::CellRendererSpin VR::Col::ProgressCol => VR::Col::Ren::CellRendererProgress VR::Col::ComboCol => VR::Col::Ren::CellRendererCombo

The renderer() method will return one of these renderers:

ren = @view.renderer(:ok) puts ren.class.name # VR::Col::Ren::CellRendererToggle (:ok column is a TrueClass) puts @view.renderer(:name).class.name # => VR::Col::Ren::CellRendererText

All the types of renderers are subclasses of Gtk renderers. For example, VR::Col::Ren::CellRendererText is a subclass of Gtk::CellRendererText. So, you can use these objects just as you would use a normal Gtk renderer:

@view.renderer(:name).width = 100

This is perfectly valid even though there are better ways of setting these properties in visualruby.



388
389
390
# File 'lib/treeview/ViewCommon.rb', line 388

def renderer(sym)
  @vr_renderer[sym]
end