#include "mywindow.h" #include #include MyWindow::MyWindow() { area = new MyArea(); mybox1 = new Gtk::Box(Gtk::ORIENTATION_VERTICAL); mybox2 = new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL); edita = new Gtk::Entry(); editb = new Gtk::Entry(); editc = new Gtk::Entry(); editx1 = new Gtk::Entry(); editx2 = new Gtk::Entry(); editm = new Gtk::Entry(); labela = new Gtk::Label("a:"); labelb = new Gtk::Label("b:"); labelc = new Gtk::Label("c:"); labelx1 = new Gtk::Label("x1:"); labelx2 = new Gtk::Label("x2:"); labelm = new Gtk::Label("m:"); buttonOK = new Gtk::Button("OK"); set_title("Random"); set_default_size(900, 400); mybox1->set_homogeneous(false); mybox2->set_homogeneous(false); add(*mybox1); mybox1->pack_start(*area); area->show(); mybox2->pack_start(*labela); labela->show(); mybox2->pack_start(*edita); edita->show(); mybox2->pack_start(*labelb); labelb->show(); mybox2->pack_start(*editb); editb->show(); mybox2->pack_start(*labelc); labelc->show(); mybox2->pack_start(*editc); editc->show(); mybox2->pack_start(*labelx1); labelx1->show(); mybox2->pack_start(*editx1); editx1->show(); mybox2->pack_start(*labelx2); labelx2->show(); mybox2->pack_start(*editm); editm->show(); mybox2->pack_start(*labelm); labelm->show(); mybox1->pack_start(*mybox2); mybox2->show(); buttonOK->signal_clicked().connect(sigc::bind<-1, Glib::ustring>( sigc::mem_fun(*this, &MyWindow::on_button_clicked), "buttonOK")); mybox1->pack_start(*buttonOK); buttonOK->show(); mybox1->show(); } MyWindow::~MyWindow() { delete buttonOK; delete labela; delete edita; delete labelb; delete editb; delete labelc; delete editc; delete labelx1; delete editx1; delete labelx2; delete editx2; delete labelm; delete editm; delete mybox2; delete mybox1; } void MyWindow::on_button_clicked(Glib::ustring data) { Glib::ustring sa = edita->get_text(); Glib::ustring sb = editb->get_text(); Glib::ustring sc = editc->get_text(); Glib::ustring sx1 = editx1->get_text(); Glib::ustring sx2 = editx2->get_text(); Glib::ustring sm = editm->get_text(); if(sa!="") { std::stringstream out(sa); out >> a; } else a = defa; if(sb!="") { std::stringstream out(sb); out >> b; } else b = defb; if(sc!="") { std::stringstream out(sc); out >> c; } else c = defc; if(sx1!="") { std::stringstream out(sx1); out >> x1; } else x1 = defx1; if(sx2!="") { std::stringstream out(sx2); out >> x2; } else x2 = defx2; if(sm!="") { std::stringstream out(sm); out >> m; } else m = defm; area->seta(a); area->setb(b); area->setc(c); area->setx1(x1); area->setx2(x2); area->setm(m); area->repaint(); }