Re: TreeView::append_column_numeric() format?
- From: pks timing com
- To: "Murray Cumming" <murrayc murrayc com>, gtkmm-list gnome org
- Cc:
- Subject: Re: TreeView::append_column_numeric() format?
- Date: Mon, 22 Nov 2004 10:23:49 -0700
pks timing com writes:
>
> append_column_numeric(modelcolumn, Gtk::FixedDecimals(3));
> append_column_numeric(modelcolumn, User::DerivedFormat(anything, they_need, to_format));
both Gtk::FixedDecimals and User::DerivedFormat would override a virtual
function or, if templated (could provide formatting functor for any old
type) operator() as one would for stl algorithms ...
something like
FixedDecimals
{
public:
FixedDecimals(gint numdecimals) : m_NumDecimals {}
Glib::ustring operator()(const float &src)
{
// use m_NumDecimals with snprintf or std::ostringstream
// or whatever strikes your fancy to get the ustring out ...
}
private:
int m_NumDecimals;
};
StringReverse
{
public:
Glib::ustring operator()(const Glib::ustring &src)
{
Glib::ustring result;
for (int i = src.size()-1; i >= 0; i--)
result += src[i];
return result;
}
};
append_column(float_column, FixedDecimals(3));
append_column(string_column, StringReverse());
under the hood use the set_cell_data_func() to use call back the
conversion operator on the formatting object ...
I'll quit spamming the list now :)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]