From f58b1a91b37e5ad758b3d0a3d9be950e8feb5d0c Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 16 Jun 2014 11:39:32 +0000 Subject: Add ability to set custom icons for windows. STR #2816. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10197 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- test/CMakeLists.txt | 1 + test/Makefile | 4 ++++ test/icon.cxx | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 test/icon.cxx (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a2cba8840..1ec27d35e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -82,6 +82,7 @@ CREATE_EXAMPLE(fonts fonts.cxx fltk) CREATE_EXAMPLE(forms forms.cxx "fltk;fltk_forms") CREATE_EXAMPLE(hello hello.cxx fltk) CREATE_EXAMPLE(help help.cxx "fltk;fltk_images") +CREATE_EXAMPLE(icon icon.cxx fltk) CREATE_EXAMPLE(iconize iconize.cxx fltk) CREATE_EXAMPLE(image image.cxx fltk) CREATE_EXAMPLE(inactive inactive.fl fltk) diff --git a/test/Makefile b/test/Makefile index 5f4597bd8..4570df628 100644 --- a/test/Makefile +++ b/test/Makefile @@ -53,6 +53,7 @@ CPPFILES =\ glpuzzle.cxx \ hello.cxx \ help.cxx \ + icon.cxx \ iconize.cxx \ image.cxx \ inactive.cxx \ @@ -121,6 +122,7 @@ ALL = \ forms$(EXEEXT) \ hello$(EXEEXT) \ help$(EXEEXT) \ + icon$(EXEEXT) \ iconize$(EXEEXT) \ image$(EXEEXT) \ inactive$(EXEEXT) \ @@ -355,6 +357,8 @@ help$(EXEEXT): help.o $(IMGLIBNAME) $(CXX) $(ARCHFLAGS) $(CXXFLAGS) $(LDFLAGS) help.o -o $@ $(LINKFLTKIMG) $(LDLIBS) $(OSX_ONLY) ../fltk-config --post $@ +icon$(EXEEXT): icon.o + iconize$(EXEEXT): iconize.o image$(EXEEXT): image.o diff --git a/test/icon.cxx b/test/icon.cxx new file mode 100644 index 000000000..75c43ab39 --- /dev/null +++ b/test/icon.cxx @@ -0,0 +1,51 @@ +// +// Icon test program for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// http://www.fltk.org/COPYING.php +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +#include +#include +#include +#include + +static Fl_Double_Window *win; + +void choice_cb(Fl_Widget *, void *v) { + Fl_Color c = (Fl_Color)(fl_intptr_t)v; + uchar buffer[32*32*3]; + Fl_RGB_Image icon(buffer, 32, 32, 3); + icon.color_average(c, 0.0); + win->icon(&icon); +} + +Fl_Menu_Item choices[] = { + {"Red",0,choice_cb,(void*)FL_RED}, + {"Green",0,choice_cb,(void*)FL_GREEN}, + {"Blue",0,choice_cb,(void*)FL_BLUE}, + {0} +}; + +int main(int argc, char **argv) { + Fl_Double_Window window(400,300); + win = &window; + + Fl_Choice choice(80,100,200,25,"Colour:"); + choice.menu(choices); + choice.callback(choice_cb); + choice.when(FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED); + + window.end(); + window.show(argc,argv); + return Fl::run(); +} -- cgit v1.2.3