Re: how to get the width of a string



Once you have the pango layout, check out the following for how to use
the layout's set_ellipsize method: 
http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classPango_1_1Layout.html#a41

Bob

Marco Scholten wrote:

>
>> there is a entry in my window, so I want to put a string to the entry
>> box.
>> if the string is too long to fit the entry, so I need cut the string
>> to be like this:
>> aaaaaa...bbb,
>> so, my question is how to get the width of the specify string with
>> default font style.
>> Thanks for any hint!
>
>
>
>
>
>
> something like:
>
> Glib::RefPtr<Pango::Layout> layout;
> layout = m_entry.create_pango_layout("");
> layout->set_markup("<span font_desc=\"sans 12\">some text</span>");
> int LayoutWidth, LayoutHeight;
> layout->get_size(LayoutWidth, LayoutHeight);
> double text_width = LayoutWidth / PANGO_SCALE;
>
> -- 
> Marco
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
begin:vcard
fn:Robert L Caryl Jr.
n:Caryl Jr.;Robert L
org:Fiscal Systems, Inc.
adr:;;102 Commerce Circle;Madison;AL;35758-2706;USA
email;internet:bob fis-cal com
title:Senior Systems Designer
tel;work:256-772-8920 x108
tel;fax:256-772-8590
tel;cell:256-527-7855
x-mozilla-html:TRUE
url:http://www.fis-cal.com
version:2.1
end:vcard



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]