Adopted use of FL_LIBRARY #define symbol under Mac OS X. This allows to compile

client applications without including Mac OS system headers, with a gain in speed of 
compilation and portability. The source files of all FLTK libraries must now be compiled with 
-DFL_LIBRARY under Mac OS X. Make, CMake and Xcode project support files
have been modified accordingly.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8113 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2010-12-23 14:24:29 +00:00
parent 122c0e6859
commit a8530c73fa
10 changed files with 70 additions and 71 deletions

View File

@ -58,9 +58,9 @@ private:
float scale_x;
float scale_y;
float angle; // rotation angle in radians
PMPrintSession printSession;
PMPageFormat pageFormat;
PMPrintSettings printSettings;
Fl_PMPrintSession printSession;
Fl_PMPageFormat pageFormat;
Fl_PMPrintSettings printSettings;
#elif defined(WIN32)
int abortPrint;
PRINTDLG pd;

View File

@ -34,8 +34,28 @@
# error "Never use <FL/mac.H> directly; include <FL/x.H> instead."
#endif // !Fl_X_H
typedef void* Window; // this is really a pointer to the subclass FLWindow of NSWindow
typedef void* Fl_Offscreen; // this is really a CGContextRef
typedef void* Fl_Bitmask; // this is really a CGImageRef
#ifndef FL_LIBRARY // this part is used when compiling an application program
typedef void* Fl_Region;
typedef void* Fl_CGContextRef;
typedef void* Fl_PMPrintSettings;
typedef void* Fl_PMPageFormat;
typedef void* Fl_PMPrintSession;
#else // this part must be compiled when building the FLTK libraries
// Standard MacOS Carbon API includes...
#include <Carbon/Carbon.h>
#undef check // because of Fl::check()
typedef CGContextRef Fl_CGContextRef;
typedef PMPrintSettings Fl_PMPrintSettings;
typedef PMPageFormat Fl_PMPageFormat;
typedef PMPrintSession Fl_PMPrintSession;
#ifndef MAC_OS_X_VERSION_10_3
#define MAC_OS_X_VERSION_10_3 1030
@ -53,6 +73,16 @@
#define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_3
#endif
typedef struct flCocoaRegion {
int count;
CGRect *rects;
} *Fl_Region; // a region is the union of a series of rectangles
# include "Fl_Window.H"
// Some random X equivalents
struct XPoint { int x, y; };
struct XRectangle {int x, y, width, height;};
#ifndef CGFLOAT_DEFINED //appears with 10.5 in CGBase.h
#if defined(__LP64__) && __LP64__
typedef double CGFloat;
@ -61,21 +91,7 @@ typedef float CGFloat;
#endif
#endif // CGFLOAT_DEFINED
// Now make some fixes to the headers...
#undef check // Dunno where this comes from...
// Some random X equivalents
struct XPoint { int x, y; };
struct XRectangle {int x, y, width, height;};
typedef void *Window; // this is really a pter to the subclass FLWindow of NSWindow
typedef struct flCocoaRegion {
int count;
CGRect *rects;
} *Fl_Region; // a region is the union of a series of rectangles
extern CGRect fl_cgrectmake_cocoa(int x, int y, int w, int h);
inline Fl_Region XRectangleRegion(int x, int y, int w, int h) {
Fl_Region R = (Fl_Region)malloc(sizeof(*R));
R->count = 1;
@ -85,18 +101,12 @@ inline Fl_Region XRectangleRegion(int x, int y, int w, int h) {
}
inline void XDestroyRegion(Fl_Region r) {
if(r) {
free(r->rects);
free(r);
}
free(r->rects);
free(r);
}
}
extern void *fl_default_cursor;
extern void *fl_system_menu;
typedef CGContextRef Fl_Offscreen;
typedef CGImageRef Fl_Bitmask;
void fl_clip_region(Fl_Region);
# include "Fl_Window.H"
extern void *fl_default_cursor;
// This object contains all mac-specific stuff about a window:
// WARNING: this object is highly subject to change!
@ -104,7 +114,7 @@ class Fl_X
{
public:
Window xid; // pointer to the Cocoa window object (FLWindow*)
Fl_Offscreen other_xid; // pointer for offscreen bitmaps (doublebuffer)
Fl_Offscreen other_xid; // pointer for offscreen bitmaps (overlay window)
Fl_Window *w; // FLTK window for
Fl_Region region;
Fl_Region subRegion; // region for this specific subwindow
@ -147,36 +157,32 @@ private:
static void relink(Fl_Window*, Fl_Window*);
};
inline Window fl_xid(const Fl_Window*w)
{
return Fl_X::i(w)->xid;
}
extern struct Fl_XMap {
RGBColor rgb;
ulong pen;
} *fl_current_xmap;
extern FL_EXPORT void *fl_display;
extern FL_EXPORT Window fl_window;
extern FL_EXPORT CGContextRef fl_gc;
#endif // FL_LIBRARY
extern FL_EXPORT Fl_CGContextRef fl_gc;
extern FL_EXPORT class Fl_Sys_Menu_Bar *fl_sys_menu_bar;
extern Window fl_xid(const Fl_Window*);
void fl_clip_region(Fl_Region);
extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
extern Fl_Offscreen fl_create_offscreen(int w, int h);
extern void fl_copy_offscreen(int x,int y,int w,int h, Fl_Offscreen gWorld, int srcx,int srcy);
extern void fl_delete_offscreen(Fl_Offscreen gWorld);
extern void fl_begin_offscreen(Fl_Offscreen gWorld);
extern void fl_end_offscreen();
extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
extern void fl_open_display();
extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
#endif // FL_DOXYGEN
/** \defgroup group_macosx Mac OS X-specific functions

View File

@ -10999,6 +10999,7 @@
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
GCC_PREPROCESSOR_DEFINITIONS = FL_LIBRARY;
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
../../,
@ -11873,8 +11874,6 @@
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
GCC_PREPROCESSOR_DEFINITIONS = "USING_XCODE=1";
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
@ -12065,8 +12064,6 @@
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
GCC_PREPROCESSOR_DEFINITIONS = "USING_XCODE=1";
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
@ -12561,8 +12558,6 @@
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
../../,
@ -12594,6 +12589,7 @@
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
GCC_PREPROCESSOR_DEFINITIONS = FL_LIBRARY;
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
@ -12660,8 +12656,6 @@
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
../../,
@ -12975,8 +12969,6 @@
ALWAYS_SEARCH_USER_PATHS = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
GCC_PREPROCESSOR_DEFINITIONS = "USING_XCODE=1";
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
@ -13047,6 +13039,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
GCC_PREPROCESSOR_DEFINITIONS = FL_LIBRARY;
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
@ -13108,8 +13101,6 @@
FRAMEWORK_VERSION = A;
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
../../,
@ -13447,8 +13438,6 @@
FRAMEWORK_VERSION = A;
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
../../,
@ -13791,8 +13780,6 @@
ALWAYS_SEARCH_USER_PATHS = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
GCC_PREPROCESSOR_DEFINITIONS = "USING_XCODE=1";
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
@ -13913,8 +13900,6 @@
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
GCC_PREPROCESSOR_DEFINITIONS = "USING_XCODE=1";
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
@ -14074,6 +14059,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
GCC_PREPROCESSOR_DEFINITIONS = FL_LIBRARY;
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
../../,
@ -14290,12 +14276,12 @@
AC3226B9FE17327A0476ACA0 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ONLY_ACTIVE_ARCH_PRE_XCODE_3_1)";
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH_PRE_XCODE_3_1 = "$(NATIVE_ARCH_ACTUAL)";
ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
};
@ -14770,6 +14756,7 @@
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
GCC_PREPROCESSOR_DEFINITIONS = FL_LIBRARY;
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
@ -14801,8 +14788,6 @@
FRAMEWORK_VERSION = A;
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
../../,
@ -15639,8 +15624,6 @@
ALWAYS_SEARCH_USER_PATHS = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
GCC_PREPROCESSOR_DEFINITIONS = "USING_XCODE=1";
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
@ -15769,6 +15752,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
GCC_PREPROCESSOR_DEFINITIONS = FL_LIBRARY;
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
@ -15925,8 +15909,6 @@
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fltk.pch;
HEADER_SEARCH_PATHS = (
../../ide/XCode3/,
../../,

View File

@ -6,3 +6,6 @@
#import <Cocoa/Cocoa.h>
#endif
#ifdef FL_LIBRARY
#include <Carbon/Carbon.h>
#endif

View File

@ -60,7 +60,7 @@ RC = @RC@
ARCHFLAGS = @ARCHFLAGS@
OPTIM = @OPTIM@
CFLAGS = $(OPTIM) @LARGEFILE@ @PTHREAD_FLAGS@ @CPPFLAGS@ @CFLAGS@
CXXFLAGS = $(OPTIM) @LARGEFILE@ @PTHREAD_FLAGS@ @CPPFLAGS@ @CXXFLAGS@
CXXFLAGS = $(OPTIM) @LARGEFILE@ @PTHREAD_FLAGS@ @CPPFLAGS@ @CXXFLAGS@ $(FLTKFLAGS)
# program to make the archive:
LIBNAME = @LIBNAME@

View File

@ -194,6 +194,7 @@ set(CFILES
)
if(APPLE)
add_definitions(-DFL_LIBRARY)
set(MMFILES
Fl_cocoa.mm
Fl_Quartz_Printer.mm

View File

@ -667,7 +667,7 @@ Fl_Window* Fl::next_window(const Fl_Window* window) {
*/
void Fl::first_window(Fl_Window* window) {
if (!window || !window->shown()) return;
fl_find(fl_xid(window));
fl_find( Fl_X::i(window)->xid );
}
/**

View File

@ -3266,6 +3266,11 @@ CGRect fl_cgrectmake_cocoa(int x, int y, int w, int h) {
return CGRectMake(x, y, w > 0 ? w - 0.9 : 0, h > 0 ? h - 0.9 : 0);
}
Window fl_xid(const Fl_Window* w)
{
return Fl_X::i(w)->xid;
}
#endif // __APPLE__
//

View File

@ -217,7 +217,7 @@ UTF8CFILES = \
xutf8/utf8Wrap.c
################################################################
FLTKFLAGS = -DFL_LIBRARY
include ../makeinclude
MMFILES = $(shell if test $(USEMMFILES) = Yes; then echo $(OBJCPPFILES); fi)

View File

@ -136,6 +136,8 @@ const char *default_menu[] = {
# define chdir _chdir
# define putenv _putenv
# endif // !__WATCOMC__
#elif defined USING_XCODE
#include <Carbon/Carbon.h>
#else
# include <unistd.h>
#endif