[gtkada] more control when displaying numeric values by a Gtk_Cell_Renderer_Text (was: Re: more control when displaying numeric values by a Gtk_Cell_Renderer_Text)

Dmitry A. Kazakov mailbox at dmitry-kazakov.de
Tue Aug 18 14:33:52 CEST 2015


On Tue, 18 Aug 2015 13:48:22 +0200, you wrote:

>> Yes, you can. You would use the Cell_Render_Text and set its property
>> "text" formatted as you wished from Cell_Data function.
> 
> Could you explain how I can change the property "text" so that it formats
> as I wish? The Cell_Data function parameters don't give a clue as how to
> do that.

1. Get the GDbuble from the model. You get the iterator and the model in
the callback. Cast the model to Tree_Store or List_Store, as needed.

2. Format GDouble into a String (using Ada formatting or by other means)

3. Set the string as the value of the "text" property, e.g.

   Set_Property (Renderer, Build ("text"), Formatted_String);

The renderer is yet another parameter of the callback.

(An additional advantage of the method is that you can leave cells blank if
you don't have a value set in the model. The default behavior is to show
0.0, which is not nice.)

> I can't find other properties of the renderer
> that look applicable. When setting the Xalign to 1.0 the misalignment of
> the '.' is not a big issue for me

OK
 
-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


More information about the gtkada mailing list