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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
#include "GUI.h"
#include "Simple_window.h"
#include "Graph.h"
using namespace Graph_lib;
using namespace std;
struct project_window : Graph_lib::Window {
project_window(Point xy, int width, int height, const string& title);
private:
Button a_button;
Button b_button;
Button c_button;
Button d_button;
Button e_button;
Image choose {Point{300, 20}, "choose.jpg"};
static void callback_a(Address, Address);
static void callback_b(Address, Address);
static void callback_c(Address, Address);
static void callback_d(Address, Address);
static void callback_e(Address, Address);
void a();
void b();
void c();
void d();
void e();
};
//----------------------------------------------------------------------------------
project_window::project_window(Point xy, int width, int height, const string& title)
:Window(xy, width, height, title),
a_button(Point(400,200), 90, 40, "1", callback_a),
b_button(Point(400,250), 90, 40, "2", callback_b),
c_button(Point(400,300), 90, 40, "3", callback_c),
d_button(Point(400,350), 90, 40, "4", callback_d),
e_button(Point(400,400), 90, 40, "5", callback_e)
{
attach (choose);
attach(a_button); // Attach next button
attach(b_button);
attach(c_button);
attach(d_button);
attach(e_button);
Fl::redraw();
}
//..........................................
//1
void project_window::callback_a(Address , Address pw)
{
reference_to<project_window>(pw).a();
}
void project_window::a()
{
redraw();
}
//----------------------------------------------------------------------------------
//2
void project_window::callback_b(Address , Address pw)
{
reference_to<project_window>(pw).b();
}
void project_window::b()
{
redraw();
}
//............................................
//3
void project_window::callback_c(Address, Address pw)
{
reference_to<project_window>(pw).c();
}
void project_window::c()
{
redraw();
}
//..................................
//4
void project_window::callback_d(Address, Address pw)
{
reference_to<project_window>(pw).d();
}
void project_window::d()
{
redraw();
}
//..............................
//5
void project_window::callback_e(Address, Address pw)
{
reference_to<project_window>(pw).e();
}
void project_window::e()
{
redraw();
}
int main()
try {
project_window win(Point(100,100), 1080, 720,"Outsmart the computer");
return gui_main();
}
catch (exception& e) {
cerr << "error: " << e.what() << "\n\n";
keep_window_open();
return 1;
}
catch (...){
cerr << "Oops: unknown exception!\n\n";
keep_window_open();
return 2;
}
|