Re: Cell size



Here is what I use to force a scrolled window to fit its content's width :

myclass::myclass
{
	…
	sw.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
	sw.add(widget);
widget.signal_size_request().connect(sigc::mem_fun(this, &myclass::adjust_width));
	…
}

void myclass::adjust_width(Gtk::Requisition *req)
{
sw.set_size_request(req->width + 20, -1); // TODO look for something more elegant than a plain "20" to take into account the vertical scroll bar
}

Depending on the widget inside your scrolled windows, you may need to deactivate and reactivate the signal at some point to avoid an unwanted recursion.

I hope this will help…
yann

On 23/03/2011 08:36, Glus Xof wrote:
2011/3/22 Glus Xof<gtglus gmail com>:
In my app, a Gtk::TreeView is included in a Gtk::ScrolledWindow...

In a precedent message, I asked for the cell wrapping method... but
right now, I cannot see the method to set the "property_wrap_width()"
according the Gtk::ScrolledWindow width.

(The concerned cells are the last column ones... so, resize when the
app main window resize too).

I know that it's not always easy to explain the things...

In my app, I have a

	Gtk::TreeView m_treeview

with these columns,

	m_treeview.append_column (" Id. ", m_columns.v_tid);
	m_treeview.append_column_editable ("Sel.", m_columns.v_sel);
	m_treeview.append_column ("First", m_columns.v_fst);
	m_treeview.append_column ("Second", m_columns.v_sed);
	m_treeview.append_column ("Third", m_columns.v_thb);
	m_treeview.append_column ("Value", m_columns.v_val);

The idea, like it's yet doing, is to limit the width of the first
columns, but the last one should take all the space available. That
I'm trying here, with these column cells, is to adjust the text along
of the *visible* free space... and cut lines when longer.

Maybe, because this TreeView is inserted in a Gtk::ScrolledWindow, to
set this width becomes more difficult... and here a scroll bar
appears, just that I'm trying to avoid. I'd like to see only the
vertical one.

Moreover, when the Main Window resize, the ScrolledWindow resize too,
and the text should refit.

Is there a way to manage it ?

Glus
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list


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