diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2020-01-18 13:03:29 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2020-01-18 13:03:29 +0100 |
| commit | ef48a0ddb9e773a3d5e79d9b33b2efe2a087571a (patch) | |
| tree | 99c8785e8358739e40b68d0a1687705b0eb01d14 /test | |
| parent | ae29e4d0e401d15c77952461aa069034111fa880 (diff) | |
Use cross-platform code to set the window icon.
Diffstat (limited to 'test')
| -rw-r--r-- | test/sudoku.cxx | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/test/sudoku.cxx b/test/sudoku.cxx index 174061515..2204b65cb 100644 --- a/test/sudoku.cxx +++ b/test/sudoku.cxx @@ -27,17 +27,15 @@ #include <FL/Fl_Preferences.H> #include <FL/Fl_Sys_Menu_Bar.H> #include <FL/platform.H> +#include <FL/Fl_Image_Surface.H> +#include <FL/Fl_Bitmap.H> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <FL/math.h> -#ifdef _WIN32 -# include "sudokurc.h" -#elif !defined(__APPLE__) -# include "pixmaps/sudoku.xbm" -#endif // _WIN32 +#include "pixmaps/sudoku.xbm" // Audio headers... #include <config.h> @@ -704,16 +702,17 @@ Sudoku::Sudoku() grid_cells_[j][k] = cell; } - // Set icon for window (MacOS uses app bundle for icon...) -#ifdef _WIN32 - icon((char *)LoadIcon(fl_display, MAKEINTRESOURCE(IDI_ICON))); -#elif !defined(__APPLE__) - fl_open_display(); - icon((char *)XCreateBitmapFromData(fl_display, DefaultRootWindow(fl_display), - (char *)sudoku_bits, sudoku_width, - sudoku_height)); -#endif // _WIN32 - + // Set icon for window + Fl_Bitmap bm(sudoku_bits, sudoku_width, sudoku_height); + Fl_Image_Surface surf(sudoku_width, sudoku_height, 1); + Fl_Surface_Device::push_current(&surf); + fl_color(FL_WHITE); + fl_rectf(0, 0, sudoku_width, sudoku_height); + fl_color(FL_BLACK); + bm.draw(0, 0); + Fl_Surface_Device::pop_current(); + icon(surf.image()); + // Catch window close events... callback(close_cb); |
