3
* Copyright (C) 2001-2004 Murray Cumming
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License as
7
* published by the Free Software Foundation; either version 2 of the
8
* License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful, but
11
* WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* General Public License for more details.
15
* You should have received a copy of the GNU General Public
16
* License along with this program; if not, write to the
17
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
* Boston, MA 02111-1307, USA.
21
#include "combo_summarytype.h"
22
#include <gtk/gtkcombobox.h>
23
#include <glibmm/i18n.h>
28
Combo_SummaryType::Combo_SummaryType(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& /* refGlade */)
29
: Gtk::ComboBox(cobject)
31
m_model = Gtk::ListStore::create(m_model_columns);
35
Gtk::TreeModel::iterator iter = m_model->append();
36
(*iter)[m_model_columns.m_summary_type] = LayoutItem_FieldSummary::TYPE_SUM;
37
(*iter)[m_model_columns.m_name] = LayoutItem_FieldSummary::get_summary_type_name(LayoutItem_FieldSummary::TYPE_SUM);
38
iter = m_model->append();
39
(*iter)[m_model_columns.m_summary_type] = LayoutItem_FieldSummary::TYPE_AVERAGE;
40
(*iter)[m_model_columns.m_name] = LayoutItem_FieldSummary::get_summary_type_name(LayoutItem_FieldSummary::TYPE_AVERAGE);
41
iter = m_model->append();
42
(*iter)[m_model_columns.m_summary_type] = LayoutItem_FieldSummary::TYPE_COUNT;
43
(*iter)[m_model_columns.m_name] = LayoutItem_FieldSummary::get_summary_type_name(LayoutItem_FieldSummary::TYPE_COUNT);
48
pack_start(m_model_columns.m_name);
52
Combo_SummaryType::~Combo_SummaryType()
57
void Combo_SummaryType::set_summary_type(LayoutItem_FieldSummary::summaryType summary_type)
59
for(Gtk::TreeModel::iterator iter = m_model->children().begin(); iter != m_model->children().end(); ++iter)
61
const LayoutItem_FieldSummary::summaryType this_value = (*iter)[m_model_columns.m_summary_type];
63
if(this_value == summary_type)
70
g_warning("Combo_SummaryType::set_summary_type(): no item found");
72
//Not found, so mark it as blank:
76
LayoutItem_FieldSummary::summaryType Combo_SummaryType::get_summary_type() const
79
Gtk::TreeModel::iterator active_row = get_active();
82
Gtk::TreeModel::Row row = *active_row;
83
return row[m_model_columns.m_summary_type];
86
return LayoutItem_FieldSummary::TYPE_INVALID;