Re: GTK & Pango string measurement
- From: Piñeiro <apinheiro igalia com>
- To: wesley hoke gmail com
- Cc: gtk-list gnome org
- Subject: Re: GTK & Pango string measurement
- Date: Wed, 16 Sep 2009 19:02:11 +0200 (CEST)
From: Wesley Smith <wesley hoke gmail com>
> >> In the situation I'm talking about, there is no GtkWidget object so
> >> your technique won't work. This is the code I'm going off of
> >> actually. Thus my question is how can I get a pango context from a
> >> GtkCellRendererText?
> >
> > AFAIK, the pango context used by the GtkCellRenderer is the same used
> > by the treeview, so try to make something like:
> >
>
>
> Hmmm. But then I'm allowed to add many GtkCellRendererText views to
> GtkTreeView and each of those can have different font settings, so
> what would happen then? I might not be getting the correct
> measurements from the PangoContext in GtkTreeView.
Hmm, yes, looking a litte deeper on that, it seems that my previous
pseudocode was just a rough estimation.
(And about the different font settings, I guess that you configure it
with the other GtkCellRendererText properties):
http://library.gnome.org/devel/gtk/stable/GtkCellRendererText.html#GtkCellRendererText.properties
So looking in the current GTK+ code, my advice is check
gtk_tree_view_column_cell_get_size, as it tries to solve a similar
problem to ours. After a quick review:
* gtk_tree_view_column_cell_get_size: C&P the documentation:
> * Obtains the width and height needed to render the column. This is used
> *primarily by the #GtkTreeView.
* internally it calls gtk_cell_renderer_get_size, for each cell
renderer in this column. Their doc:
> * Obtains the width and height needed to render the cell. Used by view
> * widgets to determine the appropriate size for the cell_area passed to
> * gtk_cell_renderer_render(). If @cell_area is not %NULL, fills in the
> * x and y offsets (if set) of the cell relative to this location.
* And the call to this function is that:
gtk_cell_renderer_get_size (info->cell,
tree_column->tree_view,
cell_area,
x_offset,
y_offset,
&new_width,
&new_height);
So is using the tree_view as widget.
* In the specific case of gtk_cell_renderer_text_get_size, it calls a
internal get_size, passing NULL as layout. Looking at that function,
as it is receiving a NULL layout, then it creates a new pango_layout,
based on treeview layout, the cell_renderer attributtes and so on.
BR
===
API (apinheiro igalia com)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]