diff options
| author | Matthias Melcher <github@matthiasm.com> | 2023-08-15 10:49:05 +0200 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2023-08-15 17:09:51 +0200 |
| commit | 3b093e895b320bd3718a3fecbba51bca1446c1f4 (patch) | |
| tree | e017cbfe91faeee8d1467e7411d15988a1b650db /test/sudoku.cxx | |
| parent | af22676abf694d2746269d5ec693b8109f7cfb93 (diff) | |
Lot's of changes, must rethink UI.
Diffstat (limited to 'test/sudoku.cxx')
| -rw-r--r-- | test/sudoku.cxx | 63 |
1 files changed, 48 insertions, 15 deletions
diff --git a/test/sudoku.cxx b/test/sudoku.cxx index 629dba3fb..fc2003dc3 100644 --- a/test/sudoku.cxx +++ b/test/sudoku.cxx @@ -27,7 +27,27 @@ // group." // - wikipedia.org +// Wishlist: +// - [ ] new easy to new hard, etc. +// - [ ] store current puzzle in preferences +// - [ ] undo, redo +// - [ ] update hints now +// - [ ] always update hints +// - [ ] highlight row, column, and box +// - [ ] highlight other cells with same value +// - [ ] verify current solution +// - [ ] hint/flag/note vs. solve mode and button 1..9, erase +// - [ ] gift one field +// - [ ] bg is white and bright blue +// - [ ] selected field bg is green, boxed +// - [ ] same number is yellow +// - [ ] conflicts can use arrows and crosses +// - [ ] fixed numbers are bold, user values are not +// - [ ] timer +// - [ ] game hamburge menu + #include "sudoku.h" +#include "sudoku_puzzle.h" #include "sudoku_cell.h" #include "sudoku_sound.h" #include "sudoku_generator.h" @@ -57,6 +77,7 @@ // Default sizes... // + #define GROUP_SIZE 160 #define CELL_SIZE 50 #define CELL_OFFSET 5 @@ -74,7 +95,9 @@ Fl_Preferences Sudoku::prefs_(Fl_Preferences::USER_L, "fltk.org", "sudoku"); // Create a Sudoku game window... Sudoku::Sudoku() - : Fl_Double_Window(GROUP_SIZE * 3, GROUP_SIZE * 3 + MENU_OFFSET, "Sudoku") + : Fl_Double_Window(kPuzzleSize + 2*kPadding, + kPuzzleSize + 2*kPadding + kMenuOffset, + "FLTK Sudoku") { int j, k; Fl_Group *g; @@ -120,28 +143,38 @@ Sudoku::Sudoku() menubar_->menu(items); // Create the grids... - grid_ = new Fl_Group(0, MENU_OFFSET, 3 * GROUP_SIZE, 3 * GROUP_SIZE); + grid_ = new SudokuPuzzle(kPadding, + kPadding + kMenuOffset, + kPuzzleSize, + kPuzzleSize); + Fl_Group *rsgrid = new Fl_Group(grid_->x()+1, grid_->y()+1, + grid_->w()-2, grid_->h()-2); + grid_->resizable(rsgrid); for (j = 0; j < 3; j ++) for (k = 0; k < 3; k ++) { - g = new Fl_Group(k * GROUP_SIZE, j * GROUP_SIZE + MENU_OFFSET, - GROUP_SIZE, GROUP_SIZE); - g->box(FL_BORDER_BOX); - if ((int)(j == 1) ^ (int)(k == 1)) g->color(FL_DARK3); - else g->color(FL_DARK2); - g->end(); - - grid_groups_[j][k] = g; + Fl_Group *group = new Fl_Group(grid_->x() + 1 + k*kGroupSize, + grid_->y() + 1 + j*kGroupSize, + kGroupSize, + kGroupSize); + group->box(FL_BORDER_BOX); + Fl_Group *rsgroup = new Fl_Group(group->x()+1, group->y()+1, + group->w()-2, group->h()-2); + rsgroup->box(FL_NO_BOX); + new Fl_Box(FL_BORDER_BOX, group->x()+1, group->y()+1, kCellSize, kCellSize, NULL); + new Fl_Box(FL_BORDER_BOX, group->x()+1+kCellSize, group->y()+1, kCellSize, kCellSize, NULL); + new Fl_Box(FL_BORDER_BOX, group->x()+1+2*kCellSize, group->y()+1, kCellSize, kCellSize, NULL); + group->resizable(rsgroup); + group->end(); } for (j = 0; j < 9; j ++) for (k = 0; k < 9; k ++) { - cell = new SudokuCell(k * CELL_SIZE + CELL_OFFSET + - (k / 3) * (GROUP_SIZE - 3 * CELL_SIZE), - j * CELL_SIZE + CELL_OFFSET + MENU_OFFSET + - (j / 3) * (GROUP_SIZE - 3 * CELL_SIZE), - CELL_SIZE, CELL_SIZE); + cell = new SudokuCell(grid_->x() + 2 + k*kCellSize + (k/3), + grid_->y() + 2 + j*kCellSize + (j/3), + kCellSize, kCellSize); cell->callback(reset_cb); + cell->hide(); grid_cells_[j][k] = cell; } |
