diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2005-11-27 14:45:48 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2005-11-27 14:45:48 +0000 |
| commit | e321cb37bfe0379f54010eb42a36573ca561e71f (patch) | |
| tree | 8859d1296934461dc33abddc49701f5bbdc53124 /test | |
| parent | f9f2de35726988a6fd9d3b226dc683c394c1d65c (diff) | |
VC++ 2005 Support, drop old files, add icons for Sudoku
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4660 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test')
| -rw-r--r-- | test/.cvsignore | 86 | ||||
| -rw-r--r-- | test/demo.cxx | 4 | ||||
| -rw-r--r-- | test/menubar.cxx | 2 | ||||
| -rw-r--r-- | test/sudoku.cxx | 40 | ||||
| -rw-r--r-- | test/sudoku.rc | 72 | ||||
| -rw-r--r-- | test/sudoku.xbm | 14 | ||||
| -rw-r--r-- | test/sudokurc.h | 16 |
7 files changed, 138 insertions, 96 deletions
diff --git a/test/.cvsignore b/test/.cvsignore deleted file mode 100644 index fbe3bfefd..000000000 --- a/test/.cvsignore +++ /dev/null @@ -1,86 +0,0 @@ -CubeView -CubeViewUI.cxx -CubeViewUI.h -adjuster -arc -ask -bitmap -boxtype -browser -button -buttons -checkers -clock -colbrowser -color_chooser -cube -cursor -curve -demo -doublebuffer -editor -fast_slow -fast_slow.cxx -fast_slow.h -file_chooser -fonts -forms -fractals -fullscreen -gl_overlay -glpuzzle -hello -help -iconize -image -inactive -inactive.cxx -inactive.h -input -keyboard -keyboard_ui.cxx -keyboard_ui.h -label -line_style -list_visuals -mandelbrot -mandelbrot_ui.cxx -mandelbrot_ui.h -menubar -message -minimum -navigation -output -overlay -pack -pixmap -pixmap_browser -preferences -preferences.cxx -preferences.h -radio -radio.cxx -radio.h -resize -resize.cxx -resize.h -resizebox -scroll -shape -shiny -shiny_panel.cxx -shiny_panel.h -subwindow -symbols -tabs -tabs.cxx -tabs.h -threads -tile -tiled_image -unittests -valuators -valuators.cxx -valuators.h -*.bck -*.exe diff --git a/test/demo.cxx b/test/demo.cxx index a7e7f4ff3..9c3c5714e 100644 --- a/test/demo.cxx +++ b/test/demo.cxx @@ -30,6 +30,10 @@ #include <stdlib.h> #if defined(WIN32) && !defined(__CYGWIN__) # include <direct.h> +// Visual C++ 2005 incorrectly displays a warning about the use of POSIX APIs +// on Windows, which is supposed to be POSIX compliant... +# define chdir _chdir +# define putenv _putenv #else # include <unistd.h> #endif diff --git a/test/menubar.cxx b/test/menubar.cxx index 1fd4e7d88..e0de89a9b 100644 --- a/test/menubar.cxx +++ b/test/menubar.cxx @@ -34,7 +34,7 @@ #include <FL/Fl_Choice.H> #include <stdio.h> #include <stdlib.h> -#include <string.h> +#include "../src/flstring.h" #include <FL/fl_draw.H> void window_cb(Fl_Widget* w, void*) { diff --git a/test/sudoku.cxx b/test/sudoku.cxx index 4c2864a8b..503c5107a 100644 --- a/test/sudoku.cxx +++ b/test/sudoku.cxx @@ -35,11 +35,17 @@ #include <FL/Fl_Help_Dialog.H> #include <FL/Fl_Preferences.H> #include <FL/Fl_Sys_Menu_Bar.H> +#include <FL/x.H> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> +#ifdef WIN32 +# include "sudokurc.h" +#elif !defined(__APPLE__) +#endif // WIN32 + // // Default sizes... @@ -105,7 +111,7 @@ SudokuCell::draw() { else fl_draw_box(FL_DOWN_BOX, x(), y(), w(), h(), color()); // Draw the cell background... - if (Fl::focus() == this && !readonly()) { + if (Fl::focus() == this) { Fl_Color c = fl_color_average(FL_SELECTION_COLOR, color(), 0.5f); fl_color(c); fl_rectf(x() + 4, y() + 4, w() - 8, h() - 8); @@ -140,12 +146,9 @@ int SudokuCell::handle(int event) { switch (event) { case FL_FOCUS : - if (!readonly()) { - Fl::focus(this); - redraw(); - return 1; - } - break; + Fl::focus(this); + redraw(); + return 1; case FL_UNFOCUS : redraw(); @@ -153,7 +156,7 @@ SudokuCell::handle(int event) { break; case FL_PUSH : - if (!readonly() && Fl::event_inside(this)) { + if (Fl::event_inside(this)) { Fl::focus(this); redraw(); return 1; @@ -163,6 +166,11 @@ SudokuCell::handle(int event) { case FL_KEYDOWN : int key = Fl::event_key() - '0'; if (key > 0 && key <= 9) { + if (readonly()) { + fl_beep(FL_BEEP_ERROR); + return 1; + } + if (Fl::event_state() & FL_SHIFT) { int i; @@ -193,6 +201,11 @@ SudokuCell::handle(int event) { return 1; } else if (key == 0 || Fl::event_key() == FL_BackSpace || Fl::event_key() == FL_Delete) { + if (readonly()) { + fl_beep(FL_BEEP_ERROR); + return 1; + } + value(0); do_callback(); return 1; @@ -303,9 +316,18 @@ Sudoku::Sudoku() grid_cells_[i][j] = cell; } + // Set icon for window (MacOS uses app bundle for icon...) +#ifdef WIN32 + icon((char *)LoadIcon(fl_display, MAKEINTRESOURCE(IDI_ICON))); +#elif !defined(__APPLE__) +#endif // WIN32 + + // Catch window close events... callback(close_cb); + + // Make the window resizable... resizable(grid_); - size_range(3 * GROUP_SIZE, 3 * GROUP_SIZE + MENU_OFFSET, 0, 0, 1, 1, 1); + size_range(3 * GROUP_SIZE, 3 * GROUP_SIZE + MENU_OFFSET, 0, 0, 5, 5, 1); // Restore the previous window dimensions... int X, Y, W, H; diff --git a/test/sudoku.rc b/test/sudoku.rc new file mode 100644 index 000000000..107c9a69f --- /dev/null +++ b/test/sudoku.rc @@ -0,0 +1,72 @@ +//Microsoft Developer Studio generated resource script.
+//
+#include "sudokurc.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+//#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+//LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "icons.h\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ICON ICON DISCARDABLE "sudoku.ico"
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/test/sudoku.xbm b/test/sudoku.xbm new file mode 100644 index 000000000..68b37d1f2 --- /dev/null +++ b/test/sudoku.xbm @@ -0,0 +1,14 @@ +#define sudoku_width 32
+#define sudoku_height 32
+static unsigned char sudoku_bits[] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x0c, 0x30, 0xc0,
+ 0x63, 0xcc, 0x33, 0xcf, 0x63, 0x4c, 0x33, 0xcc, 0x63, 0x4c, 0x33, 0xcc,
+ 0x63, 0xcc, 0x33, 0xcc, 0x63, 0x0c, 0x33, 0xcc, 0x63, 0x0c, 0x33, 0xcc,
+ 0x03, 0x0c, 0x30, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x03, 0x0c, 0x30, 0xc0, 0xd3, 0xcc, 0x33, 0xcf, 0xd3, 0xcc, 0x30, 0xcc,
+ 0xd3, 0xcc, 0x33, 0xce, 0xf3, 0xcc, 0x32, 0xce, 0xc3, 0xcc, 0x32, 0xcc,
+ 0xc3, 0xcc, 0x33, 0xcf, 0x03, 0x0c, 0x30, 0xc0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x03, 0x0c, 0x30, 0xc0, 0xf3, 0xcc, 0x33, 0xcf,
+ 0x83, 0x4c, 0x33, 0xc1, 0xf3, 0xcc, 0x33, 0xcf, 0x33, 0x4c, 0x33, 0xcc,
+ 0x33, 0x4c, 0x33, 0xcc, 0xf3, 0xcc, 0x33, 0xcf, 0x03, 0x0c, 0x30, 0xc0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
diff --git a/test/sudokurc.h b/test/sudokurc.h new file mode 100644 index 000000000..9a6bc9079 --- /dev/null +++ b/test/sudokurc.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by icons.rc
+//
+#define IDI_ICON 101
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 105
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
|
