- Added automated little helpers to Sudoku
(Menu Difficulty->add helpers) - Added example code for Wizard with the Tabs demo (STR #1564) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5638 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
f8d84949c4
commit
ecdd893933
3
CHANGES
3
CHANGES
@ -1,5 +1,8 @@
|
||||
CHANGES IN FLTK 1.1.8
|
||||
|
||||
- Added automated little helpers to Sudoku
|
||||
- Added example code for Wizard with the
|
||||
Tabs demo (STR #1564)
|
||||
- Optimized Fl_Tabs drawing for speed (STR #1520)
|
||||
- OS X resource fork now obsolete (STR #1453)
|
||||
- Added chapter 10 about multithreading (STR #1532,
|
||||
|
@ -416,6 +416,10 @@ The <tt>tabs</tt> tool was created with <i>fluid</i>. It tests
|
||||
correct hiding and redisplaying of tabs, navigation across tabs,
|
||||
resize behavior, and no unneeded redrawing of invisible widgets.
|
||||
|
||||
<P>The <tt>tabs</tt> application shows the <tt>Fl_Tabs</tt> widget
|
||||
on the left and the <tt>Fl_Wizard</tt> widget on the right side
|
||||
for direct comparison of these two panel management widgets.
|
||||
|
||||
<h3><a name="threads">threads</h3>
|
||||
FLTK can be used in a multithreading environment. There are some
|
||||
limitations, mostly due to the underlying operating system.
|
||||
|
@ -378,8 +378,8 @@ Fl_Color fl_contrast(Fl_Color fg, Fl_Color bg) {
|
||||
l2 = ((c2 >> 24) * 31 + ((c2 >> 16) & 255) * 61 + ((c2 >> 8) & 255) * 8) / 100;
|
||||
|
||||
// Compare and return the contrasting color...
|
||||
if ((l1 - l2) > 85) return fg;
|
||||
else if ((l2 - l1) > 85) return fg;
|
||||
if ((l1 - l2) > 90) return fg;
|
||||
else if ((l2 - l1) > 90) return fg;
|
||||
else if (l2 > 127) return FL_BLACK;
|
||||
else return FL_WHITE;
|
||||
}
|
||||
|
@ -175,6 +175,7 @@ class Sudoku : public Fl_Window {
|
||||
static void check_cb(Fl_Widget *widget, void *);
|
||||
static void close_cb(Fl_Widget *widget, void *);
|
||||
static void diff_cb(Fl_Widget *widget, void *d);
|
||||
static void update_helpers_cb(Fl_Widget *, void *);
|
||||
static void help_cb(Fl_Widget *, void *);
|
||||
static void new_cb(Fl_Widget *widget, void *);
|
||||
static void reset_cb(Fl_Widget *widget, void *);
|
||||
@ -196,6 +197,7 @@ class Sudoku : public Fl_Window {
|
||||
void resize(int X, int Y, int W, int H);
|
||||
void save_game();
|
||||
void solve_game();
|
||||
void update_helpers();
|
||||
};
|
||||
|
||||
|
||||
@ -642,7 +644,8 @@ Sudoku::Sudoku()
|
||||
{ "&Easy", 0, diff_cb, (void *)"0", FL_MENU_RADIO },
|
||||
{ "&Medium", 0, diff_cb, (void *)"1", FL_MENU_RADIO },
|
||||
{ "&Hard", 0, diff_cb, (void *)"2", FL_MENU_RADIO },
|
||||
{ "&Impossible", 0, diff_cb, (void *)"3", FL_MENU_RADIO },
|
||||
{ "&Impossible", 0, diff_cb, (void *)"3", FL_MENU_RADIO | FL_MENU_DIVIDER },
|
||||
{ "&Update Helpers", 0, update_helpers_cb, 0, 0 },
|
||||
{ 0 },
|
||||
{ "&Help", 0, 0, 0, FL_SUBMENU },
|
||||
{ "&About Sudoku", FL_F + 1, help_cb, 0, 0 },
|
||||
@ -860,6 +863,63 @@ Sudoku::diff_cb(Fl_Widget *widget, void *d) {
|
||||
}
|
||||
}
|
||||
|
||||
// Update the little marker numbers in all cells
|
||||
void
|
||||
Sudoku::update_helpers_cb(Fl_Widget *widget, void *) {
|
||||
Sudoku *s = (Sudoku *)(widget->window() ? widget->window() : widget);
|
||||
s->update_helpers();
|
||||
}
|
||||
|
||||
void
|
||||
Sudoku::update_helpers() {
|
||||
int i, j, k;
|
||||
// first we delete any entries that the user may have made
|
||||
for (i=0; i<9; i++) {
|
||||
for (j=0; j<9; j++) {
|
||||
SudokuCell *cell = grid_cells_[i][j];
|
||||
for (k = 0; k < 8; k++) {
|
||||
cell->test_value(0, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
// now go through all cells and find out, what we can not be
|
||||
for (i=0; i<81; i++) {
|
||||
char taken[10] = { 0 };
|
||||
// find our destination cell
|
||||
int row = i/9;
|
||||
int col = i%9;
|
||||
SudokuCell *dst_cell = grid_cells_[row][col];
|
||||
if (dst_cell->value()) continue;
|
||||
// find all values already taken in this row
|
||||
for (j=0; j<9; j++) {
|
||||
SudokuCell *cell = grid_cells_[row][j];
|
||||
int v = cell->value();
|
||||
if (v) taken[v] = 1;
|
||||
}
|
||||
// find all values already taken in this column
|
||||
for (j=0; j<9; j++) {
|
||||
SudokuCell *cell = grid_cells_[j][col];
|
||||
int v = cell->value();
|
||||
if (v) taken[v] = 1;
|
||||
}
|
||||
// now find all values already taken in this sqare
|
||||
int ro = (row/3) * 3;
|
||||
int co = (col/3) * 3;
|
||||
for (j=0; j<3; j++) {
|
||||
for (k=0; k<3; k++) {
|
||||
SudokuCell *cell = grid_cells_[ro+j][co+k];
|
||||
int v = cell->value();
|
||||
if (v) taken[v] = 1;
|
||||
}
|
||||
}
|
||||
// transfer our findings to the markers
|
||||
for (k = 1, j = 0; k <= 9; k++) {
|
||||
if (!taken[k])
|
||||
dst_cell->test_value(k, j++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Show the on-line help...
|
||||
void
|
||||
|
212
test/tabs.fl
212
test/tabs.fl
@ -4,139 +4,285 @@ header_name {.h}
|
||||
code_name {.cxx}
|
||||
Function {} {open
|
||||
} {
|
||||
Fl_Window foo_window {open
|
||||
xywh {423 205 320 331} type Double resizable visible
|
||||
Fl_Window foo_window {
|
||||
label {Comparison of Fl_Tab (left) vs. Fl_Wizard (right)} open
|
||||
xywh {423 205 642 337} type Double resizable visible
|
||||
} {
|
||||
Fl_Tabs {} {open
|
||||
tooltip {the various index cards test different aspects of the Fl_Tabs widget} xywh {10 10 300 200} selection_color 4 labelcolor 7 resizable
|
||||
Fl_Box {} {
|
||||
label {class Fl_Tabs}
|
||||
xywh {95 5 130 30} labeltype ENGRAVED_LABEL labelfont 1
|
||||
}
|
||||
Fl_Tabs {} {
|
||||
tooltip {the various index cards test different aspects of the Fl_Tabs widget} xywh {10 40 300 200} selection_color 4 labelcolor 7 resizable
|
||||
} {
|
||||
Fl_Group {} {
|
||||
label Label1 open
|
||||
tooltip {this Tab tests correct keyboard navigation between text input fields} xywh {10 30 300 180} selection_color 1 resizable
|
||||
tooltip {this Tab tests correct keyboard navigation between text input fields} xywh {10 60 300 180} selection_color 1 resizable
|
||||
} {
|
||||
Fl_Input {} {
|
||||
label {input:}
|
||||
tooltip {This is the first input field} xywh {60 50 240 40}
|
||||
tooltip {This is the first input field} xywh {60 80 240 40}
|
||||
}
|
||||
Fl_Input {} {
|
||||
label {input2:}
|
||||
xywh {60 90 240 30}
|
||||
xywh {60 120 240 30}
|
||||
code0 {o->tooltip("");}
|
||||
}
|
||||
Fl_Input {} {
|
||||
label {input3:} selected
|
||||
xywh {60 120 240 80}
|
||||
label {input3:}
|
||||
xywh {60 150 240 80}
|
||||
}
|
||||
}
|
||||
Fl_Group {} {
|
||||
label tab2 open
|
||||
tooltip {tab2 tests among other things the cooperation of modal windows and tabs} xywh {10 30 300 180} selection_color 2 hide
|
||||
tooltip {tab2 tests among other things the cooperation of modal windows and tabs} xywh {10 60 300 180} selection_color 2 hide
|
||||
} {
|
||||
Fl_Button {} {
|
||||
label button1
|
||||
callback {fl_message("Test to see if this modal window prevents you from "
|
||||
"changing the tabs. It should.");}
|
||||
xywh {20 60 100 30}
|
||||
xywh {20 90 100 30}
|
||||
code0 {\#include <FL/fl_ask.H>}
|
||||
}
|
||||
Fl_Input {} {
|
||||
label {input in box2}
|
||||
xywh {140 100 100 30}
|
||||
xywh {140 130 100 30}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label {This is stuff inside the Fl_Group "tab2"}
|
||||
xywh {30 140 260 30}
|
||||
xywh {30 170 260 30}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label {Test event blocking by modal window}
|
||||
callback {fl_message("Make sure you cannot change the tabs while this modal window is up");}
|
||||
xywh {30 170 260 30}
|
||||
xywh {30 200 260 30}
|
||||
code0 {\#include <FL/fl_ask.H>}
|
||||
}
|
||||
}
|
||||
Fl_Group {} {
|
||||
label tab3 open
|
||||
tooltip {tab3 checks for correct keyboard navigation} xywh {10 30 300 180} selection_color 3 hide
|
||||
tooltip {tab3 checks for correct keyboard navigation} xywh {10 60 300 180} selection_color 3 hide
|
||||
} {
|
||||
Fl_Button {} {
|
||||
label button2
|
||||
xywh {20 60 60 80}
|
||||
xywh {20 90 60 80}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label button
|
||||
xywh {80 60 60 80}
|
||||
xywh {80 90 60 80}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label button
|
||||
xywh {140 60 60 80}
|
||||
xywh {140 90 60 80}
|
||||
}
|
||||
}
|
||||
Fl_Group {} {
|
||||
label tab4 open
|
||||
tooltip {this tab show the issue of indicating a selcted tab if the tab layouts are very similar} xywh {10 30 300 180} selection_color 5 labelfont 2 hide
|
||||
tooltip {this tab show the issue of indicating a selcted tab if the tab layouts are very similar} xywh {10 60 300 180} selection_color 5 labelfont 2 hide
|
||||
} {
|
||||
Fl_Button {} {
|
||||
label button2
|
||||
xywh {20 50 60 110}
|
||||
xywh {20 80 60 110}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label button
|
||||
xywh {80 50 60 110}
|
||||
xywh {80 80 60 110}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label button
|
||||
xywh {140 50 60 110}
|
||||
xywh {140 80 60 110}
|
||||
}
|
||||
}
|
||||
Fl_Group {} {
|
||||
label { tab5 } open
|
||||
tooltip {tab5 verifies if visibility requests are handled correctly} xywh {10 30 300 180} labeltype ENGRAVED_LABEL hide
|
||||
tooltip {tab5 verifies if visibility requests are handled correctly} xywh {10 60 300 180} labeltype ENGRAVED_LABEL hide
|
||||
} {
|
||||
Fl_Button {} {
|
||||
label button2
|
||||
tooltip {button2 has a different tooltp than tab5} xywh {20 45 60 80}
|
||||
tooltip {button2 has a different tooltp than tab5} xywh {20 75 60 80}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label button
|
||||
xywh {90 45 60 80}
|
||||
xywh {90 75 60 80}
|
||||
}
|
||||
Fl_Clock {} {
|
||||
label {Make sure this clock does not use processor time when this tab is hidden or window is iconized}
|
||||
xywh {160 50 100 100} box OSHADOW_BOX color 238 selection_color 0 labelfont 8 labelsize 10 align 130
|
||||
xywh {160 75 100 100} box OSHADOW_BOX color 238 selection_color 0 labelfont 8 labelsize 10 align 130
|
||||
}
|
||||
Fl_Group {} {open
|
||||
xywh {20 145 40 55} box THIN_DOWN_BOX color 173 align 16
|
||||
xywh {20 175 40 55} box THIN_DOWN_BOX color 173 align 16
|
||||
class Fl_Window
|
||||
} {}
|
||||
Fl_Group {} {
|
||||
label {subwindows:} open
|
||||
xywh {65 145 40 55} box THIN_DOWN_BOX color 167
|
||||
xywh {65 175 40 55} box THIN_DOWN_BOX color 167
|
||||
class Fl_Window
|
||||
} {}
|
||||
Fl_Group {} {open
|
||||
xywh {110 145 40 55} box THIN_DOWN_BOX color 239 align 16
|
||||
xywh {110 175 40 55} box THIN_DOWN_BOX color 239 align 16
|
||||
class Fl_Window
|
||||
} {}
|
||||
}
|
||||
}
|
||||
Fl_Box {} {
|
||||
label {class Fl_Wizard}
|
||||
xywh {410 5 130 30} labeltype ENGRAVED_LABEL labelfont 1
|
||||
}
|
||||
Fl_Wizard wWizard {
|
||||
xywh {325 60 300 180}
|
||||
} {
|
||||
Fl_Group {} {
|
||||
label Label1 open
|
||||
tooltip {this Tab tests correct keyboard navigation between text input fields} xywh {325 60 300 180} selection_color 1 resizable
|
||||
} {
|
||||
Fl_Input {} {
|
||||
label {input:}
|
||||
tooltip {This is the first input field} xywh {375 80 240 40}
|
||||
}
|
||||
Fl_Input {} {
|
||||
label {input2:}
|
||||
xywh {375 120 240 30}
|
||||
code0 {o->tooltip("");}
|
||||
}
|
||||
Fl_Input {} {
|
||||
label {input3:}
|
||||
xywh {375 150 240 80}
|
||||
}
|
||||
}
|
||||
Fl_Group {} {
|
||||
label tab2 open
|
||||
tooltip {tab2 tests among other things the cooperation of modal windows and tabs} xywh {325 60 300 180} selection_color 2 hide
|
||||
} {
|
||||
Fl_Button {} {
|
||||
label button1
|
||||
callback {fl_message("Test to see if this modal window prevents you from "
|
||||
"changing the tabs. It should.");}
|
||||
xywh {335 90 100 30}
|
||||
code0 {\#include <FL/fl_ask.H>}
|
||||
}
|
||||
Fl_Input {} {
|
||||
label {input in box2}
|
||||
xywh {455 130 100 30}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label {This is stuff inside the Fl_Group "tab2"}
|
||||
xywh {345 170 260 30}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label {Test event blocking by modal window}
|
||||
callback {fl_message("Make sure you cannot change the tabs while this modal window is up");}
|
||||
xywh {345 200 260 30}
|
||||
code0 {\#include <FL/fl_ask.H>}
|
||||
}
|
||||
}
|
||||
Fl_Group {} {
|
||||
label tab3 open
|
||||
tooltip {tab3 checks for correct keyboard navigation} xywh {325 60 300 180} selection_color 3 hide
|
||||
} {
|
||||
Fl_Button {} {
|
||||
label button2
|
||||
xywh {335 90 60 80}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label button
|
||||
xywh {395 90 60 80}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label button
|
||||
xywh {455 90 60 80}
|
||||
}
|
||||
}
|
||||
Fl_Group {} {
|
||||
label tab4 open
|
||||
tooltip {this tab show the issue of indicating a selcted tab if the tab layouts are very similar} xywh {325 60 300 180} selection_color 5 labelfont 2 hide
|
||||
} {
|
||||
Fl_Button {} {
|
||||
label button2
|
||||
xywh {335 80 60 110}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label button
|
||||
xywh {395 80 60 110}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label button
|
||||
xywh {455 80 60 110}
|
||||
}
|
||||
}
|
||||
Fl_Group {} {
|
||||
label { tab5 } open
|
||||
tooltip {tab5 verifies if visibility requests are handled correctly} xywh {325 60 300 180} labeltype ENGRAVED_LABEL hide
|
||||
} {
|
||||
Fl_Button {} {
|
||||
label button2
|
||||
tooltip {button2 has a different tooltp than tab5} xywh {335 75 60 80}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label button
|
||||
xywh {405 75 60 80}
|
||||
}
|
||||
Fl_Clock {} {
|
||||
label {Make sure this clock does not use processor time when this tab is hidden or window is iconized}
|
||||
xywh {475 75 100 100} box OSHADOW_BOX color 238 selection_color 0 labelfont 8 labelsize 10 align 130
|
||||
}
|
||||
Fl_Group {} {open
|
||||
xywh {335 175 40 55} box THIN_DOWN_BOX color 173 align 16
|
||||
class Fl_Window
|
||||
} {}
|
||||
Fl_Group {} {
|
||||
label {subwindows:} open
|
||||
xywh {380 175 40 55} box THIN_DOWN_BOX color 167
|
||||
class Fl_Window
|
||||
} {}
|
||||
Fl_Group {} {open
|
||||
xywh {425 175 40 55} box THIN_DOWN_BOX color 239 align 16
|
||||
class Fl_Window
|
||||
} {}
|
||||
}
|
||||
}
|
||||
Fl_Group {} {
|
||||
xywh {410 245 130 25}
|
||||
} {
|
||||
Fl_Button {} {
|
||||
label {@|<}
|
||||
callback {wWizard->value(wWizard->child(0));}
|
||||
tooltip {go to first page [Home]} xywh {410 245 30 25} shortcut 0xff50
|
||||
}
|
||||
Fl_Button {} {
|
||||
label {@<}
|
||||
callback {wWizard->prev();} selected
|
||||
tooltip {go to previous page [left arrow]} xywh {440 245 30 25} shortcut 0xff51
|
||||
}
|
||||
Fl_Button {} {
|
||||
label {@>}
|
||||
callback {wWizard->next();}
|
||||
tooltip {go to next page in wizard [right arrow]} xywh {480 245 30 25} shortcut 0xff53
|
||||
}
|
||||
Fl_Button {} {
|
||||
label {@>|}
|
||||
callback {int last = wWizard->children()-1;
|
||||
wWizard->value(wWizard->child(last));}
|
||||
tooltip {go to last page [End]} xywh {510 245 30 25} shortcut 0xff57
|
||||
}
|
||||
}
|
||||
Fl_Input {} {
|
||||
label {inputA:}
|
||||
xywh {60 220 130 30}
|
||||
xywh {60 255 130 25}
|
||||
}
|
||||
Fl_Input {} {
|
||||
label {inputB:}
|
||||
xywh {60 250 250 30}
|
||||
xywh {60 285 250 25}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label cancel
|
||||
callback {exit(1);}
|
||||
xywh {180 290 60 30}
|
||||
xywh {475 295 70 30}
|
||||
code0 {\#include <stdlib.h>}
|
||||
}
|
||||
Fl_Return_Button {} {
|
||||
label OK
|
||||
callback {exit(0);}
|
||||
xywh {250 290 60 30}
|
||||
xywh {555 295 70 30}
|
||||
code0 {\#include <stdlib.h>}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user