Skip to content

Commit

Permalink
Generate FL/fl_config.h rather than FL/abi-version.h
Browse files Browse the repository at this point in the history
... as discussed in fltk.coredev in thread "RFC: introduce public
config header <FL/fl_config.h>", see:
https://groups.google.com/g/fltkcoredev/c/xLCs1AIXMVo/m/MHZpQggzAQAJ

- Rename abi-version.h to fl_config.h, rename input files,
  update dependencies, .gitignore, CMake, configure and Makefiles.

- Include Cairo options in FL/fl_config.h

- Rename FLTK_USE_CAIRO to FLTK_HAVE_CAIROEXT for consistency.

- Include <FL/fl_config.h> in config.h and wherever necessary,
  fix include order (move FL/Fl.H to the top) and more.

- Move USE_X11 to fl_config.h and rename to FLTK_USE_X11

- Do not include <config.h> in Cairo demo program which is no
  longer required in Cairo programs since FLTK 1.4.0
  • Loading branch information
Albrecht Schlosser committed Dec 18, 2021
1 parent 7976168 commit 5438954
Show file tree
Hide file tree
Showing 44 changed files with 848 additions and 501 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ etc/FLTKConfig.cmake
/TAGS

# /FL
/FL/abi-version.h
/FL/fl_config.h
/FL/Makefile
/FL/*.bck

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions CMake/android.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ configure_file(

# create a custom abi file for this setup
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/abi-version.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/AndroidStudio/FL/abi-version.h"
"${CMAKE_CURRENT_SOURCE_DIR}/fl_config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/AndroidStudio/FL/fl_config.h"
@ONLY
)

Expand Down
5 changes: 5 additions & 0 deletions CMake/fl_create_example.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ macro (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
set_target_properties (${TARGET_NAME} PROPERTIES OUTPUT_NAME ${NAME})
target_link_libraries (${TARGET_NAME} ${LIBRARIES})

# we must link all programs with fltk_cairo if option CAIROEXT is enabled
if (FLTK_HAVE_CAIROEXT)
target_link_libraries (${TARGET_NAME} fltk_cairo cairo)
endif ()

if (FLTK_HAVE_CAIRO)
fl_target_link_directories (${TARGET_NAME} PRIVATE "${PKG_CAIRO_LIBRARY_DIRS}")
endif ()
Expand Down
2 changes: 1 addition & 1 deletion CMake/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ install (DIRECTORY
DESTINATION ${FLTK_INCLUDEDIR} USE_SOURCE_PERMISSIONS
FILES_MATCHING
PATTERN "*.[hH]"
PATTERN "abi-version.h" EXCLUDE
PATTERN "fl_config.h" EXCLUDE
)

install (DIRECTORY
Expand Down
6 changes: 3 additions & 3 deletions CMake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ set (PATH_TO_XLIBS)
if ((NOT APPLE OR OPTION_APPLE_X11) AND NOT WIN32)
include (FindX11)
if (X11_FOUND)
set (USE_X11 1)
set (FLTK_USE_X11 1)
list (APPEND FLTK_LDLIBS -lX11)
if (X11_Xext_FOUND)
list (APPEND FLTK_LDLIBS -lXext)
Expand Down Expand Up @@ -164,7 +164,7 @@ option (OPTION_CAIROEXT
)

set (FLTK_HAVE_CAIRO 0)
set (FLTK_USE_CAIRO 0)
set (FLTK_HAVE_CAIROEXT 0)

if (OPTION_CAIRO OR OPTION_CAIROEXT)
pkg_search_module (PKG_CAIRO cairo)
Expand All @@ -174,7 +174,7 @@ if (OPTION_CAIRO OR OPTION_CAIROEXT)
if (PKG_CAIRO_FOUND)
set (FLTK_HAVE_CAIRO 1)
if (OPTION_CAIROEXT)
set (FLTK_USE_CAIRO 1)
set (FLTK_HAVE_CAIROEXT 1)
endif (OPTION_CAIROEXT)
add_subdirectory (cairo)

Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ include (CMake/variables.cmake)
include (CMake/export.cmake)

configure_file (
${CMAKE_CURRENT_SOURCE_DIR}/abi-version.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/FL/abi-version.h
${CMAKE_CURRENT_SOURCE_DIR}/fl_config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/FL/fl_config.h
@ONLY
)

Expand Down
4 changes: 2 additions & 2 deletions FL/Enumerations.H
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
/*
******************************************************************************
* FL_ABI_VERSION is defined by configure or CMake since FLTK 1.3.4.
* It is written to FL/abi-version.h and #included here.
* It is written to FL/fl_config.h and #included here.
******************************************************************************
* For more informations on FL_ABI_VERSION see README.abi-version.txt.
******************************************************************************
*/

#include <FL/abi-version.h>
#include <FL/fl_config.h>

# include "Fl_Export.H"
# include "fl_types.h"
Expand Down
1 change: 1 addition & 0 deletions FL/Fl.H
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#ifndef Fl_H
# define Fl_H

#include <FL/fl_config.h> // build configuration
#include <FL/Fl_Export.H>
#include <FL/platform_types.h> // for FL_SOCKET
#include <FL/fl_casts.H> // experimental
Expand Down
9 changes: 7 additions & 2 deletions FL/Fl_Cairo.H
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Main header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2016 by Bill Spitzak and others.
// Copyright 1998-2021 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
Expand All @@ -20,6 +20,9 @@

#ifndef FL_CAIRO_H
# define FL_CAIRO_H

# include <FL/fl_config.h> // build configuration

# ifdef FLTK_HAVE_CAIRO

// Cairo is currently supported for the following platforms:
Expand All @@ -39,7 +42,9 @@
A private internal & unique corresponding object is created to
permit cairo context state handling while keeping it opaque.
For internal use only.
\note Only available when configure has the --enable-cairo option
\note Only available when configure has the --enable-cairo or
--enable-cairoext option or one or both of the CMake options
OPTION_CAIRO or OPTION_CAIROEXT is set (ON)
*/
class FL_EXPORT Fl_Cairo_State {
public:
Expand Down
7 changes: 5 additions & 2 deletions FL/Fl_Cairo_Window.H
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Main header file for the Fast Light Tool Kit (FLTK).
// Cairo Window header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2018 by Bill Spitzak and others.
// Copyright 1998-2021 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
Expand All @@ -20,6 +20,9 @@

#ifndef FL_CAIRO_WINDOW_H
# define FL_CAIRO_WINDOW_H

#include <FL/fl_config.h>

# ifdef FLTK_HAVE_CAIRO

// Cairo is currently supported for the following platforms:
Expand Down
8 changes: 3 additions & 5 deletions FL/platform.H
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Platform header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2020 by Bill Spitzak and others.
// Copyright 1998-2021 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
Expand All @@ -28,6 +28,7 @@
#if !defined(FL_PLATFORM_H) && !defined(FL_DOXYGEN)
# define FL_PLATFORM_H

# include <FL/fl_config.h>
# include <FL/Fl_Export.H>
# include <FL/platform_types.h>
# include <FL/fl_types.h> // for uchar
Expand All @@ -42,9 +43,6 @@ class Fl_Window;
# else // X11
# include <FL/fl_types.h>
# include <FL/Enumerations.H>
# if !defined(USE_X11)
# define USE_X11 1
# endif
# if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files
# pragma set woff 3322
# endif
Expand Down Expand Up @@ -125,7 +123,7 @@ public:
// static variables, static functions and member functions
static Fl_X* first;
static Fl_X* i(const Fl_Window* w) {return (Fl_X*)w->i;}
# if defined(USE_X11) // for backward compatibility
# if defined(FLTK_USE_X11) // for backward compatibility
static void make_xid(Fl_Window*, XVisualInfo* =fl_visual, Colormap=fl_colormap);
static Fl_X* set_xid(Fl_Window*, Window);
# endif
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ distclean: clean
$(RM) fltk-config fltk.list makeinclude
$(RM) fltk.spec
$(RM) FL/Makefile
$(RM) FL/abi-version.h
$(RM) FL/fl_config.h
$(RM) documentation/*.$(CAT1EXT)
$(RM) documentation/*.$(CAT3EXT)
$(RM) documentation/*.$(CAT6EXT)
Expand Down
30 changes: 0 additions & 30 deletions README.Cairo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,36 +83,6 @@ For more details, please have a look to the doxygen documentation,
in the Modules section.


Future considerations
-----------------------

From Bill:
First there is the FLTK_HAVE_CAIRO configuration option. This indicates that
any Cairo calls are available. In this case you get something like this:

// static variable holding the last Cairo context FLTK set:
cairo_t* Fl::cr;

// Make cr draw in this window. This hides the ugly platform-dependent
// part of getting Cairo going:
void Fl::cairo_make_current(Fl_Window*)

*** POST 1.3 potential Cairo use:
// Set cr to something you made yourself. This lets you reuse functions
// that use cr, and also tells FLTK that cr is not one of its own and
// thus cannot be destroyed or reused for a different window:
void Fl::cairo_make_current(cairo_t*)

Second there is the FLTK_USE_CAIRO configuration option. This means that all
drawing is done using Cairo. In this case when a widget draw() method is
called, it is exactly as though cairo_make_current(window) has been done.
***

Note that it should be possible to compile so FLTK_HAVE_CAIRO works even
if FLTK_USE_CAIRO does not, and so that turning on FLTK_USE_CAIRO does not
break any programs written for FLTK_HAVE_CAIRO.


PLATFORM SPECIFIC NOTES
=========================

Expand Down
14 changes: 11 additions & 3 deletions README.Windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
------------------------------------------------------------




––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
*** CAUTION: This file is outdated. This needs a major rework! ***
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––




CONTENTS
==========

Expand Down Expand Up @@ -413,10 +422,9 @@ without adding link and include paths to the solution.

copy the entire FL directory into the include path

add all files from ide\VisualC2008\FL to the FL directory copied above
(this is currently only one file: abi-version.h)
add <build_dir>/FL/fl_config.h

copy all .lib files from the fltk lib directory to the VC lib directory
copy all .lib files from the fltk build directory to the VC lib directory

copy fluid.exe in the fluid directory to the bin directory

Expand Down
6 changes: 3 additions & 3 deletions README.abi-version.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ and '1' is the major version number.
The default ABI version for all FLTK 1.4.x versions is 10400 (the binary
version of FLTK 1.4.0), but you can configure another version, e.g.
10401 for FLTK 1.4.1 to enable the ABI features of FLTK 1.4.1 and all
previous versions. See CHANGES file.
previous versions. See CHANGES.txt file.


Depending on how you build FLTK, there are two different ways to configure
Expand All @@ -57,7 +57,7 @@ the version number.
./configure --with-abiversion=10401
make

This will generate FL/abi-version.h and build FLTK as usual.
This will generate FL/fl_config.h and build FLTK as usual.

Note: you should always make sure that you compile everything from
scratch if you change the ABI version or any other configuration
Expand Down Expand Up @@ -110,7 +110,7 @@ the version number.
General note on CMake:
----------------------

CMake generates FL/abi-version.h in the build tree. You may run
CMake generates FL/fl_config.h in the build tree. You may run
'make install' to install the FLTK library including all headers in
the chosen installation directory, although this is not necessary.

Expand Down
11 changes: 0 additions & 11 deletions abi-version.cmake.in

This file was deleted.

11 changes: 0 additions & 11 deletions abi-version.in

This file was deleted.

14 changes: 7 additions & 7 deletions cairo/Fl_Cairo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
// Cairo is currently supported for the following platforms:
// Win32, Apple Quartz, X11

#if defined(USE_X11) // X11
#if defined(FLTK_USE_X11) // X11
# include <cairo-xlib.h>
#elif defined(_WIN32)
#elif defined(_WIN32) // Windows
# include <cairo-win32.h>
#elif defined(__APPLE_QUARTZ__) // PORTME: Cairo Support
#elif defined(__APPLE_QUARTZ__) // macOS
# include <cairo-quartz.h>
#else
# error Cairo is not supported on this platform.
Expand All @@ -43,7 +43,7 @@ Fl_Cairo_State Fl::cairo_state_; ///< contains all necessary info for cur
// Fl_Cairo_State class impl

void Fl_Cairo_State::autolink(bool b) {
#ifdef FLTK_USE_CAIRO
#ifdef FLTK_HAVE_CAIROEXT
autolink_ = b;
#else
Fl::fatal("In Fl::autolink(bool) : Cairo autolink() feature is only "
Expand Down Expand Up @@ -86,7 +86,7 @@ cairo_t * Fl::cairo_make_current(Fl_Window* wi) {
#ifndef __APPLE__
float scale = Fl::screen_scale(wi->screen_num()); // get the screen scaling factor
#endif
#if defined(USE_X11)
#if defined(FLTK_USE_X11)
cairo_ctxt = Fl::cairo_make_current(0, wi->w() * scale, wi->h() * scale);
#else
// on macOS, scaling is done before by Fl_Window::make_current(), on Windows, the size is not used
Expand All @@ -105,7 +105,7 @@ cairo_t * Fl::cairo_make_current(Fl_Window* wi) {
*/

static cairo_surface_t * cairo_create_surface(void * gc, int W, int H) {
# if defined(USE_X11)
# if defined(FLTK_USE_X11)
return cairo_xlib_surface_create(fl_display, fl_window, fl_visual->visual, W, H);
# elif defined(_WIN32)
return cairo_win32_surface_create((HDC) gc);
Expand All @@ -123,7 +123,7 @@ static cairo_surface_t * cairo_create_surface(void * gc, int W, int H) {
*/
cairo_t * Fl::cairo_make_current(void *gc) {
int W=0,H=0;
#if defined(USE_X11)
#if defined(FLTK_USE_X11)
// FIXME X11 get W,H
// gc will be the window handle here
// # warning FIXME get W,H for cairo_make_current(void*)
Expand Down
2 changes: 1 addition & 1 deletion cairo/makedepend
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# DO NOT DELETE THIS LINE -- make depend depends on it.

Fl_Cairo.o: ../config.h
Fl_Cairo.o: ../FL/abi-version.h
Fl_Cairo.o: ../FL/Enumerations.H
Fl_Cairo.o: ../FL/Fl.H
Fl_Cairo.o: ../FL/Fl_Bitmap.H
Fl_Cairo.o: ../FL/Fl_Cairo.H
Fl_Cairo.o: ../FL/fl_casts.H
Fl_Cairo.o: ../FL/fl_config.h
Fl_Cairo.o: ../FL/Fl_Export.H
Fl_Cairo.o: ../FL/Fl_Group.H
Fl_Cairo.o: ../FL/Fl_Image.H
Expand Down
Loading

0 comments on commit 5438954

Please sign in to comment.