-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.cpp
48 lines (40 loc) · 1.18 KB
/
application.cpp
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
#ifndef _APPLICATION_CPP_
#define _APPLICATION_CPP_
#include "application.h"
#include "my_drawing_area.h"
Application::Application(int argc, char **argv) :
main(new Gtk::Main(argc, argv)),
topLevel(0),
builder(Gtk::Builder::create())
{
try
{
builder->add_from_file("resources/mainwindow.glade");
}
catch(const Glib::FileError& ex)
{
std::cerr << "FileError: " << ex.what() << std::endl;
}
catch(const Gtk::BuilderError& ex)
{
std::cerr << "BuilderError: " << ex.what() << std::endl;
}
};
int Application::run()
{
if(!builder)
{
return -1;
}
Glib::RefPtr<Gtk::Adjustment> adj_x = Glib::RefPtr<Gtk::Adjustment>::cast_dynamic(builder->get_object("adjustment2"));
Glib::RefPtr<Gtk::Adjustment> adj_y = Glib::RefPtr<Gtk::Adjustment>::cast_dynamic(builder->get_object("adjustment1"));
MyDrawingArea *area = new MyDrawingArea(adj_x, adj_y);
Gtk::AspectFrame *frame = 0;
builder->get_widget("aspectframe1", frame);
frame->add(*area);
area->show();
builder->get_widget("window1", topLevel);
main->run(*topLevel);
return 0;
};
#endif // _APPLICATION_CPP_