[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Formatted Text in Gtk::TreeView

Michael Gebhart

2/27/2005 10:45:00 AM

Hi,

I wanna have some formatted text in my treeview. The problem is: I wanna
have different formats in one cell, that means:

I have one cell. In this cell, there are 3 lines of text. The first line
has to be bold, the second one grey colored, and the third one underlined.

I've read the tutorial about the treeview and I know, that I have to use
the cellrenderer. But now I only can set the format for the whole cell,
not for each line different.

Any ideas, how to do this?

Greetings

Michael
2 Answers

Masao Mutoh

2/27/2005 11:30:00 AM

0

Hi,

On Sun, 27 Feb 2005 19:49:58 +0900
Michael Gebhart <mail@miketech.net> wrote:

> Hi,
>
> I wanna have some formatted text in my treeview. The problem is: I wanna
> have different formats in one cell, that means:
>
> I have one cell. In this cell, there are 3 lines of text. The first line
> has to be bold, the second one grey colored, and the third one underlined.
>
> I've read the tutorial about the treeview and I know, that I have to use
> the cellrenderer. But now I only can set the format for the whole cell,
> not for each line different.
>
> Any ideas, how to do this?

Use Gtk::CellRendererText#markup=.

Pango Text Attribute Markup Language is similer HTML/CSS and you can
apply it to Gtk::Widgets which have #markup= method.

http://developer.gnome.org/doc/API/2.0/pango/PangoMarkupF...

---------------------------------------
require 'gtk2'

Gtk.init

model = Gtk::TreeStore.new(String)
tv = Gtk::TreeView.new(model)

cell = Gtk::CellRendererText.new
column = Gtk::TreeViewColumn.new("Title", cell, :markup => 0)
tv.append_column(column)

msg = %Q[
<b>bold</b>
<span foreground="#dddddd">Grey colored</span>
<u>Underlined</u>
]

2.times do
iter = model.append(nil)
model.set_value(iter, 0, msg)
end

window = Gtk::Window.new.add(tv).set_default_size(300,300).show_all

--
:% Masao Mutoh<mutoh@highway.ne.jp>


Michael Gebhart

2/27/2005 6:21:00 PM

0

Yeah great, thanks!!

Michael