GUI Money Conversion

I need to create a GUI program that converts different currencies (5). I basically already created the skeleton of the program with menus with in and out boxes. I just need now to put in the code to calculate the different currencies and I don't really know where to put them or how.If anyone could help me with one conversion and tell where exactly to put in the code I would appreciate it and learn to finish the rest of it. :)


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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#include "GUI.h"

using namespace Graph_lib;

class My_window : Window {

public:
	My_window(Point xy, int w, int h, const string& title);

private:

	Menu current_menu;
	Menu final_menu;
	Button menu_button_a;
	Button menu_button_b;

	static void cb_menu(Address, Address);
	static void cb_US(Address, Address);
	static void cb_Euro(Address, Address);
	static void cb_Yen(Address, Address);
	static void cb_Peso(Address, Address);
	static void cb_Canadian(Address, Address);

	void menu_pressed();
	void US_pressed();
	void Euro_pressed();
	void Yen_pressed();
	void Peso_pressed();
	void Canadian_pressed();

	void hide_menu();

	Text t1;

	Button convert_button;
	static void cb_convert(Address, Address);
	void convert();
	
	In_box from_box;
	Out_box to_box;

};

My_window::My_window(Point xy, int w, int h, const string& title)
:Window(xy, w, h, title),t1(Point(20,40), "Money Convertion"), 
current_menu(Point(150,255), 70, 30, Menu::vertical, "Current Currency"), 
final_menu(Point(550, 255), 90, 30, Menu::vertical, "New Currency"), 
menu_button_a(Point(150,250), 120,30, "Current Currency", cb_menu), 
menu_button_b(Point(550,250), 100, 30, "New Currency", cb_menu),
convert_button(Point(350,500),80,30,"Convert", cb_convert),
from_box(Point(150,200), 100,30,"From Currency: "),to_box(Point(550,200),100,30,"To Currency: ")

{

	current_menu.attach(new Button(Point(0,0),0,0, "US", cb_US));
	current_menu.attach(new Button(Point(0,0),0,0, "Euro", cb_Euro));
	current_menu.attach(new Button(Point(0,0),0,0, "Yen", cb_Yen));
	current_menu.attach(new Button(Point(0,0),0,0, "Peso", cb_Peso));
	current_menu.attach(new Button(Point(0,0),0,0, "Canadian", cb_Canadian));

	final_menu.attach(new Button(Point(0,0),0,0, "US", cb_US));
	final_menu.attach(new Button(Point(0,0),0,0, "Euro", cb_Euro));
	final_menu.attach(new Button(Point(0,0),0,0, "Yen", cb_Yen));
	final_menu.attach(new Button(Point(0,0),0,0, "Peso", cb_Peso));
	final_menu.attach(new Button(Point(0,0),0,0, "Canadian", cb_Canadian));

	attach(current_menu);
	attach(final_menu);
	attach(menu_button_a);
	attach(menu_button_b);
	attach(convert_button);
	attach(from_box);
	attach(to_box);
	current_menu.hide();
	final_menu.hide();

	t1.set_font_size(20);

	attach(t1);

}

double str_to_double(string s)
{
	istringstream is(s);
	double d;
	is>>d;
	//if(!is) error("double format error: ",s);
	return d;
}

void My_window::cb_menu(Address,Address pw)
{
	reference_to<My_window>(pw).menu_pressed();
}
void My_window::menu_pressed()
{
	menu_button_a.hide();
	menu_button_b.hide();
	current_menu.show();
	final_menu.show();
	redraw();
}
void My_window::hide_menu()
{
	current_menu.hide();
	final_menu.hide();
	menu_button_a.show();
	menu_button_b.show();
}
void My_window::US_pressed()
{
}
void My_window::Euro_pressed()
{
}
void My_window::Yen_pressed()
{
}
void My_window::Peso_pressed()
{
}
void My_window::Canadian_pressed()
{
}

void My_window::cb_US(Address,Address pw)
{
	reference_to<My_window>(pw).US_pressed();
}
void My_window::cb_Euro(Address,Address pw)
{
	reference_to<My_window>(pw).Euro_pressed();
}
void My_window::cb_Yen(Address,Address pw)
{
	reference_to<My_window>(pw).Yen_pressed();
}
void My_window::cb_Peso(Address,Address pw)
{
	reference_to<My_window>(pw).Peso_pressed();
}
void My_window::cb_Canadian(Address,Address pw)
{
	reference_to<My_window>(pw).Canadian_pressed();
}
void My_window::cb_convert(Address,Address pw)
{
	//reference_to<My_window>(pw).convert_button();
}

void My_window::convert()
{
	
}

int main()
	{

	My_window w1(Point(100,100),800, 600, "My window");
	

	return gui_main();
	}
Topic archived. No new replies allowed.