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
#ifndef GLOM_UTILITYWIDGETS_FLOWTABLEWITHFIELDS_H
22
#define GLOM_UTILITYWIDGETS_FLOWTABLEWITHFIELDS_H
24
#include "flowtable.h"
25
#include <glom/libglom/data_structure/layout/layoutgroup.h>
26
#include <glom/libglom/data_structure/layout/layoutitem_field.h>
27
#include <glom/libglom/data_structure/layout/layoutitem_notebook.h>
28
#include <glom/libglom/data_structure/layout/layoutitem_portal.h>
29
#include <glom/libglom/data_structure/layout/layoutitem_button.h>
30
#include <glom/libglom/data_structure/layout/layoutitem_text.h>
31
#include <glom/libglom/data_structure/field.h>
32
#include <glom/libglom/document/document_glom.h>
33
#include "../mode_data/box_data_list_related.h"
34
#include "layoutwidgetbase.h"
35
#include "../mode_data/treestore_layout.h" //Forthe enum.
44
class FlowTableWithFields
46
public View_Composite_Glom,
47
public LayoutWidgetBase
50
FlowTableWithFields(const Glib::ustring& table_name = Glib::ustring());
51
virtual ~FlowTableWithFields();
53
///The table name is needed to discover details of relationships.
54
virtual void set_table(const Glib::ustring& table_name);
57
* @param layoutitem_field The layout item that describes this field,
58
* @param table_name The table on which this layout appears.
60
virtual void add_field(const sharedptr<LayoutItem_Field>& layoutitem_field, const Glib::ustring& table_name);
61
virtual void remove_field(const Glib::ustring& id);
63
typedef std::map<int, Field> type_map_field_sequence;
64
//virtual void add_group(const Glib::ustring& group_name, const Glib::ustring& group_title, const type_map_field_sequence& fields);
66
virtual void add_layout_item(const sharedptr<LayoutItem>& item);
67
virtual void add_layout_group(const sharedptr<LayoutGroup>& group);
69
virtual void set_field_editable(const sharedptr<const LayoutItem_Field>& field, bool editable = true);
71
virtual Gnome::Gda::Value get_field_value(const sharedptr<const LayoutItem_Field>& field) const;
72
//virtual Gnome::Gda::Value get_field_value(const Glib::ustring& id) const;
73
virtual void set_field_value(const sharedptr<const LayoutItem_Field>& field, const Gnome::Gda::Value& value);
74
//virtual void set_field_value(const Glib::ustring& id, const Gnome::Gda::Value& value);
77
typedef std::list<Gtk::Widget*> type_list_widgets;
78
typedef std::list<const Gtk::Widget*> type_list_const_widgets;
80
virtual void change_group(const Glib::ustring& id, const Glib::ustring& new_group);
82
virtual void set_design_mode(bool value = true);
84
virtual void remove_all();
86
/** Get the layout structure, which might have changed in the child widgets since
87
* the whole widget structure was built.
88
* for instance, if the user chose a new field for a DataWidget,
89
* or a new relationship for a portal.
91
//void get_layout_groups(Document_Glom::type_mapLayoutGroupSequence& groups);
92
//sharedptr<LayoutGroup> get_layout_group();
95
* void on_flowtable_field_edited(const sharedptr<const LayoutItem_Field>& field, const Gnome::Gda::Value& value);
97
typedef sigc::signal<void, const sharedptr<const LayoutItem_Field>&, const Gnome::Gda::Value&> type_signal_field_edited;
98
type_signal_field_edited signal_field_edited();
101
* void on_flowtable_field_open_details_requested(const sharedptr<const LayoutItem_Field>& field, const Gnome::Gda::Value& value);
103
typedef sigc::signal<void, const sharedptr<const LayoutItem_Field>&, const Gnome::Gda::Value&> type_signal_field_open_details_requested;
104
type_signal_field_open_details_requested signal_field_open_details_requested();
107
* void on_related_record_changed(const Glib::ustring& relationship_name);
109
typedef sigc::signal<void, const Glib::ustring&> type_signal_related_record_changed;
110
type_signal_related_record_changed signal_related_record_changed();
113
* void on_requested_related_details(const Glib::ustring& table_name, Gnome::Gda::Value primary_key_value);
115
typedef sigc::signal<void, const Glib::ustring&, Gnome::Gda::Value> type_signal_requested_related_details;
116
type_signal_requested_related_details signal_requested_related_details();
119
* void on_script_button_clicked(const sharedptr<LayoutItem_Button>& layout_item>);
121
typedef sigc::signal<void, const sharedptr<LayoutItem_Button>&> type_signal_script_button_clicked;
122
type_signal_script_button_clicked signal_script_button_clicked();
126
virtual type_list_widgets get_field(const sharedptr<const LayoutItem_Field>& field);
127
virtual type_list_const_widgets get_field(const sharedptr<const LayoutItem_Field>& field) const;
129
///Get portals whose relationships have @a from_key as the from_key.
130
virtual type_list_widgets get_portals(const sharedptr<const LayoutItem_Field>& from_key);
132
//int get_suitable_width(Field::glom_field_type field_type);
134
void on_entry_edited(const Gnome::Gda::Value& value, sharedptr<const LayoutItem_Field> field);
135
void on_entry_open_details_requested(const Gnome::Gda::Value& value, sharedptr<const LayoutItem_Field> field);
136
void on_flowtable_entry_edited(const sharedptr<const LayoutItem_Field>& field, const Gnome::Gda::Value& value);
137
void on_flowtable_entry_open_details_requested(const sharedptr<const LayoutItem_Field>& field, const Gnome::Gda::Value& value);
139
void on_portal_record_changed(const Glib::ustring& relationship_name);
140
void on_flowtable_related_record_changed(const Glib::ustring& relationship_name);
141
void on_flowtable_requested_related_details(const Glib::ustring& table_name, Gnome::Gda::Value primary_key_value);
143
void on_script_button_clicked(const sharedptr<LayoutItem_Button>& layout_item);
145
/// Remember the layout widget so we can iterate through them later.
146
void on_layoutwidget_changed();
148
void on_datawidget_layout_item_added(LayoutWidgetBase::enumType item_type, DataWidget* pDataWidget);
150
void on_portal_user_requested_details(Gnome::Gda::Value primary_key_value, Box_Data_List_Related* portal_box);
157
sharedptr<const LayoutItem_Field> m_field; //Store the field information so we know the title, ID, and type.
158
Glib::ustring m_group;
161
DataWidget* m_second;
162
Gtk::CheckButton* m_checkbutton; //Used instead of first and second if it's a bool.
165
typedef std::list<Info> type_listFields; //Map of IDs to full info.
166
type_listFields m_listFields;
168
//Remember the nested FlowTables, so that we can search them for fields too:
169
typedef std::list< FlowTableWithFields* > type_sub_flow_tables;
170
type_sub_flow_tables m_sub_flow_tables;
172
typedef std::list< Box_Data_List_Related* > type_portals;
173
type_portals m_portals;
175
//Remember the sequence of LayoutWidgetBase widgets, so we can iterate over them later:
176
typedef std::list< LayoutWidgetBase* > type_list_layoutwidgets;
177
type_list_layoutwidgets m_list_layoutwidgets;
179
void add_field_at_position(const sharedptr<LayoutItem_Field>& layoutitem_field, const Glib::ustring& table_name, const type_list_layoutwidgets::iterator& add_before);
180
void add_button_at_position(const sharedptr<LayoutItem_Button>& layoutitem_button, const Glib::ustring& table_name, const type_list_layoutwidgets::iterator& add_before);
181
void add_textobject_at_position(const sharedptr<LayoutItem_Text>& layoutitem_text, const Glib::ustring& table_name, const type_list_layoutwidgets::iterator& add_before);
182
void add_imageobject_at_position(const sharedptr<LayoutItem_Image>& layoutitem_image, const Glib::ustring& table_name, const type_list_layoutwidgets::iterator& add_before);
184
void add_layoutwidgetbase(LayoutWidgetBase* layout_widget);
185
void add_layoutwidgetbase(LayoutWidgetBase* layout_widget, const type_list_layoutwidgets::iterator& add_before);
186
void add_layout_item_at_position(const sharedptr<LayoutItem>& item, const type_list_layoutwidgets::iterator& add_before);
187
void add_layout_group_at_position(const sharedptr<LayoutGroup>& group, const type_list_layoutwidgets::iterator& add_before);
188
void add_layout_notebook_at_position(const sharedptr<LayoutItem_Notebook>& notebook, const type_list_layoutwidgets::iterator& add_before);
189
void add_layout_related_at_position(const sharedptr<LayoutItem_Portal>& portal, const type_list_layoutwidgets::iterator& add_before);
191
Box_Data_List_Related* create_related(const sharedptr<LayoutItem_Portal>& portal, bool show_title = true);
193
Glib::ustring m_table_name;
195
type_signal_field_edited m_signal_field_edited;
196
type_signal_field_open_details_requested m_signal_field_open_details_requested;
198
//type_signal_related_record_added m_signal_related_record_added;
199
type_signal_related_record_changed m_signal_related_record_changed;
200
type_signal_requested_related_details m_signal_requested_related_details;
202
type_signal_script_button_clicked m_signal_script_button_clicked;
207
#endif //GLOM_UTILITYWIDGETS_FLOWTABLEWITHFIELDS_H