window_relationships_overview.h 3.44 KB
Newer Older
Murray Cumming's avatar
Murray Cumming committed
1 2
/* Glom
 *
3
 * Copyright (C) 2001-2013 Murray Cumming
Murray Cumming's avatar
Murray Cumming committed
4 5 6 7 8 9 10 11 12 13 14 15 16
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
17 18
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA.
Murray Cumming's avatar
Murray Cumming committed
19 20
 */

21 22
#ifndef GLOM_WINDOW_RELATIONSHIPS_OVERVIEW
#define GLOM_WINDOW_RELATIONSHIPS_OVERVIEW
Murray Cumming's avatar
Murray Cumming committed
23

24
#include <libglom/document/view.h>
25 26
#include "glom/utility_widgets/canvas/canvas_editable.h"
#include "canvas_group_dbtable.h"
Murray Cumming's avatar
Murray Cumming committed
27
#include <gtkmm/dialog.h>
28
#include <gtkmm/applicationwindow.h>
29 30
#include <gtkmm/menubar.h>
#include <gtkmm/printoperation.h>
31
#include <gtkmm/scrolledwindow.h>
32
#include <gtkmm/toggleaction.h>
33
#include <gtkmm/builder.h>
34
#include <glibmm/weakref.h>
35
#include <goocanvasmm/canvas.h>
36
#include <unordered_map>
37 38
#include <vector>

39
//#include "relationships_canvas.h"
Murray Cumming's avatar
Murray Cumming committed
40

41 42
namespace Glom
{
Murray Cumming's avatar
Murray Cumming committed
43

44
class Window_RelationshipsOverview
45
 : public Gtk::ApplicationWindow,
Murray Cumming's avatar
Murray Cumming committed
46
   public View_Composite_Glom
47
{
Murray Cumming's avatar
Murray Cumming committed
48
public:
49 50 51
  static const char* glade_id;
  static const bool glade_developer;

52 53
  Window_RelationshipsOverview(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder);
  virtual ~Window_RelationshipsOverview();
Murray Cumming's avatar
Murray Cumming committed
54

55
  void load_from_document() override;
56

57
private:
58
  class TableView;
Murray Cumming's avatar
Murray Cumming committed
59

60 61 62
  void draw_tables();
  void draw_lines();
  void setup_context_menu();
63
  void print_or_preview(Gtk::PrintOperationAction print_action);
64
  void on_button_close();
65

66 67 68 69
  void on_menu_file_print();
  void on_menu_file_page_setup();
  void on_menu_file_save();
  void on_menu_view_showgrid(const Glib::VariantBase& /* parameter */);
70

71
  void on_table_moved(const Glib::RefPtr<CanvasItemMovable>& item, double x_offset, double y_offset);
72
  void on_table_show_context(GdkEventButton* event, const Glib::WeakRef<CanvasGroupDbTable>& table);
73

74 75
  void on_context_menu_edit_fields(const Glib::VariantBase& parameter, const Glib::WeakRef<CanvasGroupDbTable>& table);
  void on_context_menu_edit_relationships(const Glib::VariantBase& parameter, const Glib::WeakRef<CanvasGroupDbTable>& table);
76

77 78
  void on_scroll_value_changed();

79
  Glib::RefPtr<CanvasGroupDbTable> get_table_group(const Glib::ustring& table_name);
80

81
  Glib::RefPtr<Gtk::Builder> m_builder;
82
  Glib::RefPtr<Gio::SimpleAction> m_action_showgrid;
83

84
  bool m_modified;
85
  CanvasEditable m_canvas;
86
  Gtk::ScrolledWindow* m_scrolledwindow_canvas;
Murray Cumming's avatar
Murray Cumming committed
87

88
  //typedef std::unordered_map<Glib::RefPtr<Goocanvas::Item>, TableView*> type_map_item_tables;
89
  //type_map_item_tables m_tables;
Murray Cumming's avatar
Murray Cumming committed
90

91
  static int m_last_size_x, m_last_size_y;
92

93 94 95 96
  Glib::RefPtr<Goocanvas::Group> m_group_tables;
  Glib::RefPtr<Goocanvas::Group> m_group_lines;

  //Context menu:
97
  std::unique_ptr<Gtk::Menu> m_context_menu;
98
  Glib::RefPtr<Gio::SimpleAction> m_action_edit_fields, m_action_edit_relationships;
99 100 101
  sigc::connection m_connection_edit_fields, m_connection_edit_relationships;

  //Printing:
102 103
  Glib::RefPtr<Gtk::PrintSettings> m_settings;
  Glib::RefPtr<Gtk::PageSetup> m_page_setup;
Murray Cumming's avatar
Murray Cumming committed
104 105
};

106
} //namespace Glom
107

108
#endif //GLOM_WINDOW_RELATIONSHIPS_OVERVIEW