Re: [gtkmm] treeview column width
- From: Christer Palm <palm nogui se>
- To: Gtkmm List <gtkmm-list gnome org>
- Cc: Matt Gerginski <mattgerg users sourceforge net>
- Subject: Re: [gtkmm] treeview column width
- Date: Tue, 11 May 2004 19:45:51 +0200
Hello Matt!
I use code similar to the following:
You need to provide your own toInt() and StringTokenizer(), but their
function should be obvious.
Also note that setting the columns to fixed width doesn't mean that they
can't be resized by the user - it just means that the width doesn't
automatically adapt to the column contents, so fixed width is what you
want. IIRC there's a resizable property that controls whether the user
can resize the column or not.
std::string saveColumnWidths(std::vector<Gtk::TreeViewColumn*>& columns)
{
std::string widths;
typedef std::vector<Gtk::TreeViewColumn*>::const_iterator Iterator;
for (Iterator col = columns.begin(); col != columns.end(); col++) {
if (!widths.empty()) {
widths += ",";
}
widths += toString((*col)->get_width());
}
return widths;
}
void restoreColumnWidths(std::vector<Gtk::TreeViewColumn*>& columns,
const std::string& widths_setting,
const std::string& default_widths)
{
if (widths_setting.empty()) {
widths_setting = default_widths;
}
StringTokenizer tokenizer(widths_setting, ',');
StringList& width_list = tokenizer.getTokens();
StringList::const_iterator width = width_list.begin();
std::vector<Gtk::TreeViewColumn*>::const_iterator col =
columns.begin();
while (col != columns.end() && width != width_list.end()) {
(*col++)->set_fixed_width(toInt(*width++));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]