Re: A couple of questions about gtkmm



Thanks sledge hammer and Ian.

I've dove into it and actually managed to do what I wanted with the Notebook widget: I did use the set_resizable() (..very straightforward -once you find it out-). For the right alignment of numbers I did the following (it was not straightforward to find...):

tw->get_column_cell_renderer(4)->property_xalign() = 1.0;
tw->get_column_cell_renderer(5)->property_xalign() = 1.0;

Now, I know that column 4 and 5 do exist, so I just set it on the right. The point is, should I implement a check on the pointer returned by get_column_cell_renderer(), isn't it (if it's NULL wouldn't be good at all)...
What I tried the first time was this:

Gtk::TreeViewColumn    *pColumn = tw->get_column(4);
if (pColumn) {
Gtk::CellRendererText *render = Gtk::manage(new Gtk::CellRendererText);
           render->property_xalign() = 1.0;
           pColumn->set_renderer(*render, _cf_data._col_value);
}

But I kept having the following error:

Gtk-CRITICAL **: gtk_tree_view_column_cell_layout_add_attribute: assertion `info != NULL' failed

What was I doing wrong? Why can't I set the cell rendered to a new type of object? What's possibly wrong with this approach form a logical point of view?

Now, going back to point 1:
If I put as example, 3 Label into a VBox:

vb->pack_start(*Gtk::manage(new Gtk::Label("a")), Gtk::PACK_SHRINK);
vb->pack_start(*Gtk::manage(new Gtk::Label("bb")), Gtk::PACK_SHRINK);
vb->pack_start(*Gtk::manage(new Gtk::Label("ccc")), Gtk::PACK_SHRINK);

I see the horizontal alignment as centered.
I'd like all of them to be aligned on the right hand side of the VBox. Is there a way to specify them as the cell renderers?
How can I do this?
I've tried the example the Ian suggested but it's valid only for ButtonBox types... I mean, doesn't it make sense for any type box to specify the horizontal alignment?

Thanks again,
Regards,

E. Oriani

sledge hammer wrote:

> 2) When I use a TreeView with a ListStore, how can I do the following:
> - Align on the right hand side the content of some columns (for example
> numerical columns)

One approach is this: Use a Gtk::CellRendererText and then use property_markup <http://gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1CellRendererText.html#c5a5082f96afe81faa0f3ac4fd0e0c7f> ()

> - Make the columns resizable by the user

On the TreeView widget use get_column <http://gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1TreeView.html#513e50ad0acdd817d1a443f1eaa3debe> (int n) to get a pointer to the column. Then use: Gtk::TreeViewColumn::set_resizable() on that.

> - Implement a conditional rendering of a column (should I use a
> CellRendererText implementing a Label with Pango format?)

If you use CellRendererText then take a look on here->http://gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/sec-treeview.html on the topic "Specifying CellRenderer Details". And then use the property_visible <http://gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1CellRenderer.html#be91e2d555a940bb3214be7bf04210a6> () of the CellRendererText

I hope I didn't confuse you. At first I was confused at how TreeView works...
About the documentation part: you're dead on.

------------------------------------------------------------------------
Μείνετε συνδεδεμένοι με τους φίλους σας στο Zoo Κάντε κλικ εδώ! <http://cid-7251ab28a7fb687e.profile.live.com/WebActivities/Add.aspx?appid=1275114792>


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