#pragma once
#include <FLstd.h>
#include "cppstd.h"
class BoxXY : public Fl_Box {
Fl_Input* input_line1;
Fl_Input* input_line2;
Fl_Input* input_line3;
Fl_Input* input_line4;
public:
BoxXY(int x, int y, int width_input, int height_input, Fl_Input* input1,Fl_Input* input2, Fl_Input* input3,Fl_Input* input4);
private:
int handle(int);
};
#include "BoxXY.h"
BoxXY::BoxXY(int x, int y, int width_input, int height_input, Fl_Input* input1,Fl_Input* input2, Fl_Input* input3,Fl_Input* input4) : Fl_Box(FL_NO_BOX, x, y, width_input, height_input, "")
{
this->input_line1 = input1;
this->input_line2 = input2;
this->input_line3 = input3;
this->input_line4 = input4;
}
int BoxXY::handle(int event){
switch (event) {
case FL_PUSH:{ // Box左上の座標は(65,190)
int x1 = Fl::event_x() - 65;
int y1 = Fl::event_y() - 190;
input_line1->value(to_string(x1).c_str());
input_line1->textsize(12);
input_line2->value(to_string(y1).c_str());
input_line2->textsize(12);
return 1;
}
case FL_RELEASE:{
int x2 = Fl::event_x() - 65;
int y2 = Fl::event_y() - 190;
input_line3->value(to_string(x2).c_str());
input_line3->textsize(12);
input_line4->value(to_string(y2).c_str());
input_line4->textsize(12);
return 1;
}
default:
return Fl_Box::handle(event);
}
}