Re: TreeView::append_column_numeric() format?



maybe it's an option to add iostream functions like precision(), width(), flags() etc. to Gtk::CellRenderer.
so we can do something like:

MyTreeViewColumn->get_first_cell_renderer()->precision(2);

Marco Scholten.

----- Original Message ----- From: "Murray Cumming" <murrayc murrayc com>
To: "Ainsley Pereira" <gtkmm pebble org uk>
Cc: <gtkmm-list gnome org>
Sent: Monday, November 22, 2004 1:10 PM
Subject: Re: TreeView::append_column_numeric() format?


So I would like to add another templated convenience method like this:
Gtk::TreeView::append_column_numeric(TreeModelColumn& model,
numeric_format);

But what's the best way to specify the display format for the number?
I'd
rather not use that nasty printf() style format. Does C++ have something
more suitable?

Boost has a "format" object (described here:
http://www.boost.org/libs/format/doc/format.html)

Using a formatter object is a good idea, but it seems to mostly use the
sprintf format anyway, with some extensions.

Also I would feel bad about reproducing so much code in gtkmm. And we
can't depend on boost because it's not a stable (API or ABI) library yet.

If we find no better alternative to the sprintf format then we could just
decide to live with
 TreeView::append_column_numeric(TreeModelColumn& column, const
Glib::ustring& format);
where format is something like "%.4f" for 4decimal places.

I'm not suggesting that this actual class should be used, but it's a
starting point for ideas. The Gtk::TreeView::append_column_numeric()
method could take an object that formats a number (perhaps with a number
of
simple/common ones supplied). I don't know how all this works underneath
though, does it need to translate to printf format for the Gtk+ interface,
or does all the formatting happen in the C++ wrapper?

Gtk+ has no equivalent for this. Their whole GtkTreeView API is much more
unpleasant. And they are probably happy to use C-style sprintf formatting
for this.

Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com
_______________________________________________
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]