-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexception.cxx
55 lines (46 loc) · 1.03 KB
/
exception.cxx
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
#include <fltk/run.h>
#include <fltk/Button.h>
#include <fltk/Window.h>
#include <fltk/ask.h>
#include <config.h>
#include <stdio.h>
using namespace fltk;
#ifdef HAVE_EXCEPTIONS
#include <exception>
class my_exception : public std::exception {
public:
const char* what() const throw() {return "my exception";}
};
void throwit(Widget*, void*) {
throw my_exception();
}
int main(int argc, char** argv) {
Window window(200,100);
window.begin();
Button button(25,50,150,24,"Throw Exception");
button.callback(throwit);
window.end();
window.show(argc, argv);
for (;;) {
try {
return run();
} catch (std::exception& e) {
message("Exception was thrown!\nIt was \"%s\"", e.what());
}
}
}
#else
void quit(Widget *w, void*) {
w->window()->hide();
}
int main(int argc, char** argv) {
Window window(200,100);
window.begin();
Button button(25,25,150,50,"This demo needs exceptions!");
button.align(ALIGN_WRAP);
button.callback(quit);
window.end();
window.show(argc, argv);
return run();
}
#endif