Skip to content

Commit

Permalink
New CMake option OPTION_PRINT_SUPPORT turned ON by default
Browse files Browse the repository at this point in the history
When the option is off, file config.h defines NO_PRINT_SUPPORT 
which in turn produces a library without print support, that is, 
class Fl_Printer does nothing.
When off, the FLTK library is somewhat smaller.
Can be turned off only when the X11 library is used.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11127 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Feb 5, 2016
1 parent 254cb01 commit a8a777f
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 9 deletions.
8 changes: 8 additions & 0 deletions CMake/options.cmake
Expand Up @@ -78,6 +78,7 @@ option(OPTION_BUILD_SHARED_LIBS

#######################################################################
option(OPTION_BUILD_EXAMPLES "build example programs" ON)
option(OPTION_PRINT_SUPPORT "allow print support" ON)

#######################################################################
if(DOXYGEN_FOUND)
Expand Down Expand Up @@ -354,6 +355,13 @@ else()
set(FLTK_XDBE_FOUND FALSE)
endif(OPTION_USE_XDBE AND HAVE_XDBE_H)

#######################################################################
set(NO_PRINT_SUPPORT FALSE)
if(X11_FOUND AND NOT OPTION_PRINT_SUPPORT)
set(NO_PRINT_SUPPORT TRUE)
endif(X11_FOUND AND NOT OPTION_PRINT_SUPPORT)
#######################################################################

#######################################################################
# prior to CMake 3.0 this feature was buggy
if(NOT CMAKE_VERSION VERSION_LESS 3.0.0)
Expand Down
10 changes: 7 additions & 3 deletions FL/Fl_Printer.H
Expand Up @@ -3,7 +3,7 @@
//
// Printing support for the Fast Light Tool Kit (FLTK).
//
// Copyright 2010-2014 by Bill Spitzak and others.
// Copyright 2010-2016 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 @@ -23,6 +23,7 @@
#ifndef Fl_Printer_H
#define Fl_Printer_H

#include "config.h"
#include <FL/x.H>
#include <FL/Fl_Paged_Device.H>
#include <FL/fl_draw.H>
Expand Down Expand Up @@ -191,6 +192,7 @@ public:
const char *class_name() {return class_id;};
/** \brief The constructor */
Fl_Printer(void);
#ifndef NO_PRINT_SUPPORT
int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
int start_page(void);
int printable_rect(int *w, int *h);
Expand All @@ -207,8 +209,6 @@ public:
void print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x=0, int delta_y=0);
void set_current(void);
Fl_Graphics_Driver* driver(void);
/** \brief The destructor */
~Fl_Printer(void);

/** \name These attributes are effective under the Xlib platform only.
\{
Expand All @@ -233,6 +233,9 @@ public:
static const char *property_save;
static const char *property_cancel;
/** \} */
/** \brief The destructor */
~Fl_Printer(void);

private:
#if defined(WIN32) || defined(__APPLE__)
Fl_System_Printer *printer;
Expand All @@ -242,6 +245,7 @@ private:
#else
Fl_PostScript_Printer *printer;
#endif
#endif // NO_PRINT_SUPPORT
};

#endif // Fl_Printer_H
Expand Down
6 changes: 6 additions & 0 deletions configh.cmake.in
Expand Up @@ -336,6 +336,12 @@
#cmakedefine01 HAVE_DLFCN_H
#cmakedefine01 HAVE_DLSYM

/*
* Do we want print support?
*/

#cmakedefine NO_PRINT_SUPPORT 1

/*
* End of "$Id$".
*/
16 changes: 12 additions & 4 deletions src/CMakeLists.txt
Expand Up @@ -46,9 +46,8 @@ set(CPPFILES
Fl_Paged_Device.cxx
Fl_Pixmap.cxx
Fl_Positioner.cxx
Fl_PostScript.cxx
Fl_Printer.cxx
Fl_Preferences.cxx
Fl_Printer.cxx
Fl_Progress.cxx
Fl_Repeat_Button.cxx
Fl_Return_Button.cxx
Expand Down Expand Up @@ -137,13 +136,22 @@ set(CPPFILES
fl_show_colormap.cxx
fl_symbols.cxx
fl_vertex.cxx
ps_image.cxx
screen_xywh.cxx
fl_utf8.cxx
fl_encoding_latin1.cxx
fl_encoding_mac_roman.cxx
)

if (USE_X11 AND NOT OPTION_PRINT_SUPPORT)
set(PSFILES
)
else()
set(PSFILES
Fl_PostScript.cxx
ps_image.cxx
)
endif(USE_X11 AND NOT OPTION_PRINT_SUPPORT)

set(DRIVER_FILES)

if (USE_X11)
Expand Down Expand Up @@ -280,7 +288,7 @@ else()
endif(APPLE AND NOT OPTION_APPLE_X11)

#######################################################################
FL_ADD_LIBRARY(fltk STATIC "${CPPFILES};${MMFILES};${CFILES};fl_call_main.c")
FL_ADD_LIBRARY(fltk STATIC "${CPPFILES};${PSFILES};${MMFILES};${CFILES};fl_call_main.c")

if(LIB_dl)
target_link_libraries(fltk ${LIB_dl})
Expand Down
13 changes: 11 additions & 2 deletions src/Fl_Printer.cxx
Expand Up @@ -4,7 +4,7 @@
// Encompasses platform-specific printing-support code and
// PostScript output code for the Fast Light Tool Kit (FLTK).
//
// Copyright 2010 by Bill Spitzak and others.
// Copyright 2010-2016 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 @@ -19,6 +19,15 @@

#include <FL/Fl_Printer.H>

const char *Fl_Printer::class_id = "Fl_Printer";

#ifdef NO_PRINT_SUPPORT

Fl_Printer::Fl_Printer(void) {
}

#else

#if defined(WIN32) || defined(__APPLE__)
#elif defined(FL_PORTING)
# pragma message "FL_PORTING: implement the printer device specifics"
Expand Down Expand Up @@ -69,7 +78,6 @@ const char *Fl_Printer::property_save = "Save";
/** [this text may be customized at run-time] */
const char *Fl_Printer::property_cancel = "Cancel";

const char *Fl_Printer::class_id = "Fl_Printer";
#if defined(__APPLE__) || defined(WIN32) || defined(FL_DOXYGEN)
const char *Fl_System_Printer::class_id = Fl_Printer::class_id;
#endif
Expand Down Expand Up @@ -207,6 +215,7 @@ Fl_Printer::~Fl_Printer(void)
delete printer;
}

#endif // NO_PRINT_SUPPORT

//
// End of "$Id$".
Expand Down

0 comments on commit a8a777f

Please sign in to comment.