#include <FL/Fl.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Window.H>
#include "../../../std_lib_facilities.h"
#include "../../../Point.h"
#include "../../../Graph.h"
#include "../../../GUI.h"
#include "../../../Simple_window.h"
#include "../../../Window.h"
#include <conio.h>
using namespace Graph_lib;
struct Coulomb_window :Window{
Coulomb_window(Point xy, int w, int h, const string& title );
private:
Circle circle;
Button start_button;
static void cb_start(Address,Address);
void start();
};
Coulomb_window::Coulomb_window(Point xy, int w, int h, const string& title )
:Window(xy,w,h,title),
circle(Point(100,100),50),
start_button(Point(x_max()-150,5),40,20,"start",cb_start)
{
circle.set_fill_color(Color::red);
circle.set_color(Color::invisible);
attach(circle);
attach(start_button);
};
void Coulomb_window::cb_start(Address,Address pw)
{
reference_to<Coulomb_window>(pw).start();
};
//円を動かす
void Coulomb_window::start()
{
while(1){
if(_kbhit() && (_getch() == 'q')) { //qキーを押すと、ループから抜ける
break;
}else if(_kbhit() && (_getch() == 'a')){ //aキーを押すと、右へ10移動
circle.move(10,0);
redraw();
}
}
}
int main()
try{
Coulomb_window win(Point(100,100),600,400,"Coulomb's_law");
return gui_main();
}
catch(exception& e) {
cerr << "exception: " << e.what() << '\n';
return 1;
}
catch (...) {
cerr << "some exception\n";
return 2;
}