~cypheon/elfelli

ref: d62f0945c78677b2fe75fe2a71484afb4875f9a2 elfelli/src/Application.h -rw-r--r-- 2.6 KiB
d62f0945 — Johann Rudloff Try enabling Travis macOS build env. 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// -*- C++ -*-
/*
 * Application.h
 * Copyright (C) 2006  Johann Rudloff
 *
 * 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 Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include <gtkmm.h>

#include <libintl.h>
#define _(String) gettext(String)
#define N_(String) String

#include "SimulationCanvas.h"

namespace Elfelli
{

namespace Stock
{
using namespace Gtk::Stock;
extern const Gtk::StockID EXPORT_PNG;
extern const Gtk::StockID EXPORT_SVG;

extern const Gtk::StockID ADD_NEGATIVE;
extern const Gtk::StockID ADD_POSITIVE;
extern const Gtk::StockID ADD_NEGATIVE_PLATE;
extern const Gtk::StockID ADD_POSITIVE_PLATE;

}

class Application
{
public:
  Application(int argc, char **argv);
  int main();
  void quit();

  void load_file(std::string filename);

  static const std::string find_datafile(const std::string& fname);

  static const std::string appname;
  static const std::string version;
  static const std::string datadir;

private:
  void setup_gettext();

  Gtk::Widget *build_object_toolbar();
  bool build_gui();
  bool setup_ui_actions();
  void setup_file_chooser_dialogs();
  void setup_stock_items();

  void reset_simulation();
  void update_charge_spin();

  bool on_expose(GdkEventExpose *event);
  void on_remove_selected_activate();
  void on_add_positive_body_clicked();
  void on_add_negative_body_clicked();
  void on_add_positive_plate_clicked();
  void on_add_negative_plate_clicked();

  void on_about_activate();
  void on_quit_activate();
  void on_export_png_activate();
  void on_open_activate();
  void on_save_activate();

  void on_sim_selection_changed();
  void on_sim_selected_charge_changed();
  void on_charge_value_changed();

  Gtk::Main gtk_main;
  Gtk::Window main_win;
  Gtk::Statusbar sbar;
  Gtk::Widget *object_toolbar;
  Gtk::SpinButton *charge_spin;

  Gtk::FileChooserDialog export_png_dlg, save_dlg, open_dlg;
  Gtk::FileFilter elfelli_xml, all;

  Glib::RefPtr<Gtk::ActionGroup> general_actions, object_actions;
  Glib::RefPtr<Gtk::UIManager> ui_manager;

  SimulationCanvas sim_canvas;
};

}