#include "GUI.h" #include "std_lib_facilities.h" #include using namespace Graph_lib; void Button::attach(Graph_lib::Window& win) { pw = new Fl_Button(loc.x, loc.y, width, height, label.c_str()); // pass the window pw->callback(reinterpret_cast(do_it), &win); own = &win; } int In_box::get_int() { Fl_Input& pi = reference_to(pw); // return atoi(pi.value()); const char* p = pi.value(); if (!isdigit(p[0])) return -999999; return atoi(p); } string In_box::get_string() { Fl_Input& pi = reference_to(pw); return string(pi.value()); } void In_box::attach(Graph_lib::Window& win) { pw = new Fl_Input(loc.x, loc.y, width, height, label.c_str()); own = &win; } void Out_box::put(int i) { Fl_Output& po = reference_to(pw); std::stringstream ss; ss << i; po.value(ss.str().c_str()); } void Out_box::put(const string& s) { reference_to(pw).value(s.c_str()); } void Out_box::attach(Graph_lib::Window& win) { pw = new Fl_Output(loc.x, loc.y, width, height, label.c_str()); own = &win; } Menu::Menu(Point xy, int w, int h, Kind kk, const string& s) :Widget(xy,w,h,s,0), k{kk}, offset{0} { } int Menu::attach(Button& b) { b.width = width; b.height = height; switch(k) { case horizontal: b.loc = Point(loc.x+offset,loc.y); offset+=b.width; break; case vertical: b.loc = Point(loc.x,loc.y+offset); offset+=b.height; break; } selection.push_back(&b); return int(selection.size()-1); } int Menu::attach(Button* p) { // owned.push_back(p); return attach(*p); }