//#include "examplewindow.h" //#include #include "sudmat.h" void OnSudokuClicked( int mat ) { std::cout << mat << "but" << std::endl; } class Cstep : public Gtk::Window { friend class Hole; friend class Csud; public: Cstep(); virtual ~Cstep(); Csud Game; static void OnButtonClicked(int); void LabelAllButtons( bool ShowPro ); void LabelOneButton( int mat, bool ShowPro ); private: // Signal handlers: void on_button_numbered(const Glib::ustring& data); // Child widgets: Gtk::Grid m_grid; //Gtk::Button Jbut[81]; Gtk::Button Jbut[81]; //The sudoku game to be displayed (which has buttons) Gtk::Label Jlab[81]; // for holding the background color Gtk::EventBox Jbox[81]; //bool orig; // colors Gdk::RGBA BgDry; //white Gdk::RGBA BgDull; //?? Gdk::RGBA BgNot; //?? Gdk::RGBA BgMay; //?? Gdk::RGBA BgYes; //yellow Gdk::RGBA FgDry; //black Gdk::RGBA FgNot; //Navy blue Gdk::RGBA FgMay; //dark yellow Gdk::RGBA FgYes; //yellow }; void Cstep::OnButtonClicked(int mat) { std::cout << mat << std::endl ; } Cstep::Cstep() { int FixB[] = { //hidden quad Klaus Brenner 9,0,1,5,0,0,0,4,6, 4,2,5,0,9,0,0,8,1, 8,6,0,0,1,0,0,2,0, 5,0,2,0,0,0,0,0,0, 0,1,9,0,0,0,4,6,0, 6,0,0,0,0,0,0,0,2, 1,9,6,0,4,0,2,5,3, 2,0,0,0,6,0,8,1,7, 0,0,0,0,0,1,6,9,4 }; BgDry.set_red(1.0); BgDry.set_green(1.0); BgDry.set_blue(1.0); BgDry.set_alpha(1.0); //opaque BgDull.set_red(0.9); BgDull.set_green(0.9); BgDull.set_blue(1.0); BgDull.set_alpha(1.0); //opaque BgNot.set_red(0.5); BgNot.set_green(0.5); BgNot.set_blue(1.0); BgNot.set_alpha(1.0); //opaque BgMay.set_red(1.0); BgMay.set_green(1.0); BgMay.set_blue(0.8); BgMay.set_alpha(1.0); //opaque BgYes.set_red(1.0); BgYes.set_green(1.0); BgYes.set_blue(0.7); BgYes.set_alpha(1.0); //opaque FgDry.set_red(0.0); FgDry.set_green(0.0); FgDry.set_blue(0.0); FgDry.set_alpha(1.0); //opaque FgNot.set_red(0.4); FgNot.set_green(0.4); FgNot.set_blue(0.0); FgNot.set_alpha(1.0); //opaque FgMay.set_red(0.1); FgMay.set_green(0.1); FgMay.set_blue(0.8); FgMay.set_alpha(1.0); //opaque FgYes.set_red(0.0); FgYes.set_green(0.0); FgYes.set_blue(1.0); FgYes.set_alpha(1.0); //opaque /** Gdk::RGBA("#C0C0FF") BgDull;//?? Gdk::RGBA("#8080FF") BgNot; //?? Gdk::RGBA("#C0C0FF") BgMay; //?? Gdk::RGBA("#FFFF00") BgYes; //yellow Gdk::RGBA("#000000") FgDry; //black Gdk::RGBA("#000080") FgNot; //Navy blue Gdk::RGBA("#404000") FgMay; //dark yellow Gdk::RGBA("#606000") FgYes; //yellow **/ // This just sets the title of our new window. set_title("Gran Sudoku!"); // sets the border width of the window. set_border_width(10); // put the grid into the main window. add( m_grid ); //prepare the game Game.Setup( FixB ); //Game.Solve(); //attach all game buttons to grid container int r, c; for( int mat=0; mat<81; mat++) //for all buttons { Jlab[mat].set_markup("Gtk"); //define starting label Jlab[mat].set_use_markup(); //Jlab[mat].set_justify(JUSTIFY_CENTER); //first line to 2nd line Jlab[mat].show(); //Jlab[mat].set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_START); Jbox[mat].add(Jlab[mat]); Jbox[mat].override_background_color(BgMay); Jbox[mat].show(); Jbut[mat].add(Jbox[mat]); Jbut[mat].signal_clicked().connect( sigc::bind( sigc::ptr_fun(&Cstep::OnButtonClicked), mat) ); r = r_m(mat); //row position c = c_m(mat); //column position m_grid.attach( Jbut[mat],c,r,1,1 ); //attach button to grid } LabelAllButtons( true ); //ShowAllButtons for( int mat=0; mat<81; mat++) Jbut[mat].show(); //show button m_grid.set_row_homogeneous( true ); m_grid.set_column_homogeneous(true); m_grid.show(); } Cstep::Cstep::~Cstep() { } void Cstep::LabelAllButtons( bool ShowPro ) { for( int mat=0; mat<81; mat++) LabelOneButton( mat, ShowPro ); } void Cstep::LabelOneButton( int mat, bool ShowPro ) { std::string S = Game.ButtonLabel( mat, ShowPro ); //S = "12345\n6789"; Jbut[mat].set_label( S ); if( mat == 15 ) { //Jbut[mat].set_label( "99" ); // Jbut[mat].set_color( BgMay ); Jbox[mat].override_background_color(Gdk::RGBA("red")); Jbox[mat].show(); Jlab[mat].set_label( "99" ); Jlab[mat].show(); } } // Our new improved signal handler. The data passed to this method is // printed to stdout. //void Cstep::Cstep::on_button_clicked(Glib::ustring data) //{ // std::cout << "Hello World - " << data << " was pressed" << std::endl; //} int main(int argc, char *argv[]) { Glib::RefPtr app = Gtk::Application::create(argc, argv, "play.example"); Cstep SudokuWindow; return app->run(SudokuWindow); }