1 
2 /*
3 * This code is released under the GNU General Public License.  See COPYING for
4 * details.  Copyright 2005 P. Jordan, C. Lewis, J. Spray
5 * jcspray@icculus.org
6 */
7 
8 #ifndef GNUDOKU_H
9 #define GNUDOKU_H
10 
11 #include "sudoku.H"
12 using sudoku::Sudoku;
13 
14 #include <gtkmm.h>
15 
16 #define MARK_ERRORS_BY_COLOR
17 
18 
19 class GNUDoku {
20 	Gtk::Entry *box_[9][9];
21 	Gtk::Adjustment *difficultyadj_;
22 	Gtk::Window *mainwindow_;
23 	bool editupdateblock_;
24 	float orig_ratio_;
25 
26 #ifdef MARK_ERRORS_BY_COLOR
27 	Gdk::Color error_color_;
28 #else
29 	Pango::FontDescription bold_desc_;
30 	Pango::FontDescription plain_desc_;
31 #endif
32 
33 	void clearBoxes();
34 	void showAbout();
35 	void doQuit();
36 	void onBoxEdit();
37 	void onBoxFocus(Gtk::Entry *box);
38 	void fillBoxes(const Sudoku::attempt stack[], const char visited[]);
39 	int getFromBoxes(Sudoku::attempt *top, Sudoku::flags *flags, char visited[]);
40 	void generatePuzzleUI();
41 	void generatePuzzle(float const difficulty, int const seed);
42 
43 	void solvePuzzle();
44 	void mark_box_erroneous (Gtk::Entry *box, bool haserror);
45 	void mark_box_editable (Gtk::Entry *box, bool editable);
46 
47 	void onHBoxResize(Gdk::Rectangle &rect);
48 
49 	int setFromString (std::string puzzle);
50 	std::string dumpToString (void);
51 	int savePuzzle (std::string filename);
52 	void generatePuzzleFromNumberUI ();
53 	void openPuzzleUI ();
54 	void savePuzzleUI ();
55 	void updateWindowTitle (Glib::ustring);
56 
57 	// Sometimes a filename in the folder desired, GTK doesn't care.
58 	std::string working_folder;
59 
60 	public:
61 	GNUDoku();
62 	void guiSetup(Gtk::Window &window);
63 	int openPuzzle (std::string filename);
64 };
65 
66 #endif // GNUDOKU_H
67