diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/CMakeLists.txt | 129 | ||||
| -rw-r--r-- | examples/fltk-versions.cxx | 78 |
2 files changed, 129 insertions, 78 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 000000000..6dadb17af --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,129 @@ +# +# CMakeLists.txt used to build example apps by the CMake build system +# +# Copyright 2020 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: +# +# https://www.fltk.org/COPYING.php +# +# Please see the following page on how to report bugs and issues: +# +# https://www.fltk.org/bugs.php +# +################################################################################ + +include (../CMake/fl_create_example.cmake) + +set (EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../bin/examples) +file (MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) + +################################################################################ + +# create separate lists of all source (.cxx) files +# depending on the required FLTK and system libraries + +############################################################ +# simple examples w/o extra libs +############################################################ + +set (SIMPLE_SOURCES + browser-simple + draggable-group + howto-add_fd-and-popen + howto-browser-with-icons + howto-drag-and-drop + howto-draw-an-x + howto-menu-with-images + howto-parse-args + howto-remap-numpad-keyboard-keys + howto-text-over-image-button + menubar-add + nativefilechooser-simple-app + nativefilechooser-simple + progress-simple + shapedwindow + simple-terminal + table-as-container + table-simple + table-sort + table-spreadsheet + table-spreadsheet-with-keyboard-nav + table-with-keynav + table-with-right-column-stretch-fit + tabs-simple + textdisplay-with-colors + texteditor-simple + texteditor-with-dynamic-colors + tree-as-container + tree-custom-draw-items + tree-custom-sort + tree-of-tables + tree-simple + wizard-simple +) + +############################################################ +# examples requiring fltk_images +############################################################ + +set (IMAGE_SOURCES + clipboard + howto-simple-svg +) + +############################################################ +# examples requiring OpenGL + libGLEW +############################################################ + +set (OPENGL_SOURCES + OpenGL3-glut-test + OpenGL3test +) + +############################################################ +# create simple example programs +############################################################ + +foreach (src ${SIMPLE_SOURCES}) + CREATE_EXAMPLE (${src} ${src}.cxx fltk) +endforeach (src) + +############################################################ +# create example programs with fltk_images library +############################################################ + +foreach (src ${IMAGE_SOURCES}) + CREATE_EXAMPLE (${src} ${src}.cxx "fltk_images;fltk") +endforeach (src) + +############################################################ +# create example programs with OpenGL + libGLEW +############################################################ + +# Note: macOS does not need libGLEW + +if (APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL)) + if (NOT LIB_GLEW) + set (LIB_GLEW TRUE) + endif () + set (REQUIRED_LIBS fltk_gl fltk ${OPENGL_LIBRARIES}) +else () + set (REQUIRED_LIBS fltk_gl fltk ${OPENGL_LIBRARIES} GLEW) +endif () + +if (OPENGL_FOUND AND LIB_GLEW) + foreach (src ${OPENGL_SOURCES}) + CREATE_EXAMPLE (${src} ${src}.cxx "${REQUIRED_LIBS}") + endforeach (src) +else () + message (STATUS + "OpenGL or libGLEW not present: OpenGL example programs will not be built.") + fl_debug_var (OPENGL_FOUND) + fl_debug_var (LIB_GLEW) + message ("") +endif (OPENGL_FOUND AND LIB_GLEW) + +unset (REQUIRED_LIBS) diff --git a/examples/fltk-versions.cxx b/examples/fltk-versions.cxx deleted file mode 100644 index ed80c7b1f..000000000 --- a/examples/fltk-versions.cxx +++ /dev/null @@ -1,78 +0,0 @@ -// -// Library version test program for the Fast Light Tool Kit (FLTK). -// -// Copyright 1998-2017 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: -// -// https://www.fltk.org/COPYING.php -// -// Please see the following page on how to report bugs and issues: -// -// https://www.fltk.org/bugs.php -// - -#include <FL/Fl.H> -#include <FL/Fl_Window.H> -#include <FL/Fl_Box.H> -#include <FL/fl_ask.H> - -#include <stdio.h> - -static char version[8][80] = { "","","","","","","","" }; - -int main(int argc, char **argv) { - - int versions = 0; - - sprintf(version[versions++],"FL_VERSION = %6.4f",FL_VERSION); - sprintf(version[versions++],"Fl::version() = %6.4f %s",Fl::version(), - (FL_VERSION == Fl::version()) ? "" : "***"); - -#ifdef FL_API_VERSION - sprintf(version[versions++],"FL_API_VERSION = %6d",FL_API_VERSION); - sprintf(version[versions++],"Fl::api_version() = %6d %s",Fl::api_version(), - (FL_API_VERSION == Fl::api_version()) ? "" : "***"); -#endif - -#ifdef FL_ABI_VERSION - sprintf(version[versions++],"FL_ABI_VERSION = %6d",FL_ABI_VERSION); - sprintf(version[versions++],"Fl::abi_version() = %6d %s",Fl::abi_version(), - (FL_ABI_VERSION == Fl::abi_version()) ? "" : "***"); -#endif - - for (int i=0; i<versions; i++) { - printf("%s\n",version[i]); - } - fflush(stdout); - -#ifdef FL_ABI_VERSION - if (FL_ABI_VERSION != Fl::abi_version()) { - printf("*** FLTK ABI version mismatch: headers = %d, lib = %d ***\n", - FL_ABI_VERSION, Fl::abi_version()); - fflush(stdout); - fl_message("*** FLTK ABI version mismatch: headers = %d, lib = %d ***", - FL_ABI_VERSION, Fl::abi_version()); - // exit(1); - } -#endif - - Fl_Window *window = new Fl_Window(670,300); - - Fl_Box *box[8]; - for (int i=0; i<4; i++) { - box[2*i] = new Fl_Box( 10,40+40*i,320,30,version[2*i]); - box[2*i+1] = new Fl_Box(340,40+40*i,320,30,version[2*i+1]); - } - - for (int i=0; i<8; i++) { - box[i]->labelfont(FL_COURIER); - box[i]->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE); - } - - window->end(); - window->show(argc, argv); - return Fl::run(); -} |
