diff --git a/CHANGES.txt b/CHANGES.txt index e3d7dbd71..b2ba3c98d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,4 @@ -Changes in FLTK 1.5.0 Released: xxx yy 2025 +Changes in FLTK 1.5.0 Released: xxx yy 2026 This is the first FLTK release that exclusively uses CMake to be built. autoconf/configure/Makefile support has been removed. If you believe you @@ -9,7 +9,7 @@ Changes in FLTK 1.5.0 Released: xxx yy 2025 Platform Specific Fixes and Build Procedure Improvements - + - macOS: required SDK version and deployment target changed to 10.5 or higher Wayland related Improvements and Fixes @@ -23,7 +23,7 @@ Changes in FLTK 1.5.0 Released: xxx yy 2025 Other Changes - Removed autotools (configure/make) support - + - Requires C++11 or higher Changes in FLTK 1.4 diff --git a/FL/mac.H b/FL/mac.H index b0a2b84f5..5133a6ce8 100644 --- a/FL/mac.H +++ b/FL/mac.H @@ -1,7 +1,7 @@ // // Mac header file for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2018 by Bill Spitzak and others. +// Copyright 1998-2026 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 @@ -114,10 +114,6 @@ typedef unsigned int NSUInteger; #endif #endif -#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4 -typedef CGImageAlphaInfo CGBitmapInfo; -#endif - struct flCocoaRegion { int count; CGRect *rects; diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 7f12390d2..c6d767990 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -47,6 +47,12 @@ extern "C" { #include #include +#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 || \ + MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 +# error macOS SDK and deployment target version 10.5 or higher is required. +// Note: change also the warning in Fl_Darwin_System_Driver::calc_mac_os_version() below +#endif + #import #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_15_0 # import @@ -198,10 +204,10 @@ const NSUInteger NSWindowStyleMaskFullScreen = NSFullScreenWindowMask; const NSUInteger NSEventMaskAny = NSAnyEventMask; const NSUInteger NSEventMaskSystemDefined = NSSystemDefinedMask; -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 const NSUInteger NSBitmapFormatAlphaFirst = NSAlphaFirstBitmapFormat; const NSUInteger NSBitmapFormatAlphaNonpremultiplied = NSAlphaNonpremultipliedBitmapFormat; -# endif +#define NSEventSubtypeTabletProximity NSTabletProximityEventSubtype +#define NSEventSubtypeTabletPoint NSTabletPointEventSubtype #endif /* @@ -569,10 +575,7 @@ void Fl_Cocoa_Screen_Driver::breakMacEventLoop() @end -@interface FLView : NSView = MAC_OS_X_VERSION_10_5 -, NSTextInputClient -#endif +@interface FLView : NSView = MAC_OS_X_VERSION_10_7 ,NSDraggingSource #endif @@ -617,15 +620,7 @@ void Fl_Cocoa_Screen_Driver::breakMacEventLoop() - (BOOL)performDragOperation:(id )sender; - (void)draggingExited:(id < NSDraggingInfo >)sender; - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal; -#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 -- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange; -- (void)setMarkedText:(id)aString selectedRange:(NSRange)newSelection replacementRange:(NSRange)replacementRange; -- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange; -- (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange; -- (NSInteger)windowLevel; -#else - (void)updateTrackingAreas; -#endif #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context; - (void)draggingSession:(NSDraggingSession *)session @@ -651,14 +646,12 @@ void Fl_Cocoa_Screen_Driver::breakMacEventLoop() #endif [[self standardWindowButton:NSWindowDocumentIconButton] setImage:nil]; [super close]; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - while (fl_mac_os_version >= 100500) { + while (true) { NSArray *a = [[self contentView] trackingAreas]; if ([a count] == 0) break; NSTrackingArea *ta = (NSTrackingArea*)[a objectAtIndex:0]; [[self contentView] removeTrackingArea:ta]; } -#endif // when a fullscreen window is closed, windowDidResize may be sent after the close message was sent // and before the FLWindow receives the final dealloc message w = NULL; @@ -1175,19 +1168,6 @@ static void cocoaMouseHandler(NSEvent *theEvent) } mods_to_e_state( mods ); update_e_xy_and_e_xy_root([theEvent window]); - if (fl_mac_os_version < 100500) { - // before 10.5, mouse moved events aren't sent to borderless windows such as tooltips - Fl_Window *tooltip = Fl_Tooltip::current_window(); - int inside = 0; - if (tooltip && tooltip->shown() ) { // check if a tooltip window is currently opened - // check if mouse is inside the tooltip - inside = (Fl::event_x_root() >= tooltip->x() && Fl::event_x_root() < tooltip->x() + tooltip->w() && - Fl::event_y_root() >= tooltip->y() && Fl::event_y_root() < tooltip->y() + tooltip->h() ); - } - // if inside, send event to tooltip window instead of background window - if (inside) - window = tooltip; - } Fl::handle( sendEvent, window ); } break; @@ -1292,28 +1272,6 @@ static void orderfront_subwindows(FLWindow *xid) } @end -@interface FLWindowDelegateBefore10_5 : FLWindowDelegateBefore10_6 --(void)windowDidDeminiaturize:(NSNotification *)notif; --(void)windowWillMiniaturize:(NSNotification *)notif; -@end -@implementation FLWindowDelegateBefore10_5 --(void)windowDidDeminiaturize:(NSNotification *)notif -{ - [super windowDidDeminiaturize:notif]; - fl_lock_function(); - orderfront_subwindows([notif object]); - fl_unlock_function(); -} --(void)windowWillMiniaturize:(NSNotification *)notif -{ - [super fl_windowMiniaturize:notif]; - NSArray *children = [(NSWindow*)[notif object] childWindows]; // 10.2 - NSEnumerator *enumerator = [children objectEnumerator]; - id child; - while ((child = [enumerator nextObject]) != nil) [child orderOut:self]; -} -@end - // compute coordinates of the win top left in FLTK units static void CocoatoFLTK(Fl_Window *win, int &x, int &y) { NSPoint ori; @@ -1337,8 +1295,7 @@ static FLWindowDelegate *flwindowdelegate_instance = nil; + (void)initialize { if (self == [FLWindowDelegate self]) { - if (fl_mac_os_version < 100500) flwindowdelegate_instance = [FLWindowDelegateBefore10_5 alloc]; - else if (fl_mac_os_version < 100600) flwindowdelegate_instance = [FLWindowDelegateBefore10_6 alloc]; + if (fl_mac_os_version < 100600) flwindowdelegate_instance = [FLWindowDelegateBefore10_6 alloc]; else flwindowdelegate_instance = [FLWindowDelegate alloc]; flwindowdelegate_instance = [flwindowdelegate_instance init]; } @@ -1569,7 +1526,7 @@ static FLWindowDelegate *flwindowdelegate_instance = nil; } - (void)windowDidMiniaturize:(NSNotification *)notif { - if (fl_mac_os_version >= 100500) [self fl_windowMiniaturize:notif]; + [self fl_windowMiniaturize:notif]; fl_lock_function(); FLWindow *nsw = (FLWindow*)[notif object]; Fl_Window *window = [nsw getFl_Window]; @@ -1822,25 +1779,6 @@ static FLWindowDelegate *flwindowdelegate_instance = nil; } @end -@interface FLAppDelegateBefore10_5 : FLAppDelegate -- (void)applicationDidUnhide:(NSNotification *)notify; -- (void)applicationDidUpdate:(NSNotification *)aNotification; -@end -@implementation FLAppDelegateBefore10_5 -- (void)applicationDidUnhide:(NSNotification *)notify -{ // before 10.5, subwindows are lost when application is unhidden - fl_lock_function(); - for (Fl_X *x = Fl_X::first; x; x = x->next) { - if (![(FLWindow*)x->xid parentWindow]) { - orderfront_subwindows((FLWindow*)x->xid); - } - } - fl_unlock_function(); -} -- (void)applicationDidUpdate:(NSNotification *)aNotification -{ -} -@end static void drain_dropped_files_list() { open_cb_f_type open_cb = ((FLAppDelegate*)[NSApp delegate])->open_cb; @@ -1951,7 +1889,7 @@ void Fl_Cocoa_Screen_Driver::open_display_platform() { if (need_new_nsapp) [NSApplication sharedApplication]; NSAutoreleasePool *localPool; localPool = [[NSAutoreleasePool alloc] init]; // never released - FLAppDelegate *delegate = (Fl_Darwin_System_Driver::calc_mac_os_version() < 100500 ? [FLAppDelegateBefore10_5 alloc] : [FLAppDelegate alloc]); + FLAppDelegate *delegate = [FLAppDelegate alloc]; [(NSApplication*)NSApp setDelegate:[delegate init]]; if (need_new_nsapp) { if (fl_mac_os_version >= 101300 && fl_mac_os_version < 140000 && is_bundled()) { @@ -2012,8 +1950,7 @@ static int input_method_startup() static int retval = -1; // -1: not initialized, 0: not usable, 1: ready for use if (retval == -1) { fl_open_display(); - if (fl_mac_os_version >= 100500) { - // These symbols are no longer visible in Apple doc. + // These symbols require 10.5. They are no longer visible in Apple doc. // They do exist in Carbon.framework --> HIToolbox.framework --> TextServices.h TSMGetActiveDocument = (TSMGetActiveDocument_type)Fl_Darwin_System_Driver::get_carbon_function("TSMGetActiveDocument"); TSMSetDocumentProperty = (TSMSetDocumentProperty_type)Fl_Darwin_System_Driver::get_carbon_function("TSMSetDocumentProperty"); @@ -2024,10 +1961,6 @@ static int input_method_startup() kTISTypeKeyboardLayout = (CFStringRef)Fl_Darwin_System_Driver::get_carbon_function("kTISTypeKeyboardLayout"); kTISPropertyInputSourceType = (CFStringRef)Fl_Darwin_System_Driver::get_carbon_function("kTISPropertyInputSourceType"); retval = (TSMGetActiveDocument && TSMSetDocumentProperty && TSMRemoveDocumentProperty && TISCreateInputSourceList && kTISTypeKeyboardLayout && kTISPropertyInputSourceType ? 1 : 0); - } else { - KeyScript = (KeyScript_type)Fl_Darwin_System_Driver::get_carbon_function("KeyScript"); - retval = (KeyScript? 1 : 0); - } } return retval; } @@ -2037,12 +1970,8 @@ void Fl_Cocoa_Screen_Driver::enable_im() { im_enabled = 1; - if (fl_mac_os_version >= 100500) { ((FLAppDelegate*)[NSApp delegate])->currentDoc = NULL; [NSApp updateWindows]; // triggers [FLAppDelegate applicationDidUpdate] - } - else - KeyScript(-7/*smKeyEnableKybds*/); } void Fl_Cocoa_Screen_Driver::disable_im() { @@ -2050,12 +1979,8 @@ void Fl_Cocoa_Screen_Driver::disable_im() { im_enabled = 0; - if (fl_mac_os_version >= 100500) { ((FLAppDelegate*)[NSApp delegate])->currentDoc = NULL; [NSApp updateWindows]; // triggers [FLAppDelegate applicationDidUpdate] - } - else - KeyScript(smEnableRomanKybdsOnly); } @@ -2578,6 +2503,9 @@ static FLTextInputContext* fltextinputcontext_instance = nil; NSUInteger mods = [theEvent modifierFlags]; NSString *pure = [theEvent charactersIgnoringModifiers]; // detect Function+e to open character palette +#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 +#define NSEventModifierFlagFunction NSFunctionKeyMask +#endif if ((mods & NSEventModifierFlagFunction) && [pure isEqualToString:@"e"] ) { [NSApp orderFrontCharacterPalette:self]; return YES; @@ -2664,9 +2592,7 @@ static FLTextInputContext* fltextinputcontext_instance = nil; cocoaTabletHandler(theEvent, true); } #endif -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - (void)updateTrackingAreas { - if (fl_mac_os_version >= 100500) { if (![[self window] parentWindow]) { while (true) { NSArray *a = [self trackingAreas]; // 10.5 @@ -2686,9 +2612,7 @@ static FLTextInputContext* fltextinputcontext_instance = nil; } } [super updateTrackingAreas]; - } } -#endif - (void)mouseDragged:(NSEvent *)theEvent { cocoaMouseHandler(theEvent); } @@ -3095,13 +3019,7 @@ static FLTextInputContext* fltextinputcontext_instance = nil; return [[self window] level]; } -- ( -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - NSInteger -#else - long -#endif -)conversationIdentifier { +- (NSInteger)conversationIdentifier { return identifier; } @@ -3866,9 +3784,7 @@ Fl_Quartz_Copy_Surface_Driver::~Fl_Quartz_Copy_Surface_Driver() { CGContextRestoreGState(gc); CGContextEndPage(gc); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if (fl_mac_os_version >= 100500) CGPDFContextClose(gc); // needs 10.5, necessary with macOS 10.15 -#endif + CGPDFContextClose(gc); // needs 10.5, necessary with macOS 10.15 CGContextRelease(gc); NSPasteboard *clip = [NSPasteboard generalPasteboard]; [clip declareTypes:[NSArray arrayWithObjects:PDF_pasteboard_type, TIFF_pasteboard_type, nil] owner:nil]; @@ -4331,7 +4247,6 @@ static void createAppleMenu(void) [print_with_titlebar_item setEnabled:YES]; [appleMenu addItem:[NSMenuItem separatorItem]]; } - if (fl_mac_os_version >= 100400) { // services+hide+quit already in menu in OS 10.3 // Services Menu services = [[NSMenu alloc] initWithTitle:@""]; menuItem = [appleMenu @@ -4366,7 +4281,7 @@ static void createAppleMenu(void) action:@selector(terminate:) keyEquivalent:@"q"]; [menuItem setTarget:about]; - } + /* Put menu into the menubar */ menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; [menuItem setSubmenu:appleMenu]; @@ -4574,8 +4489,7 @@ static void write_bitmap_inside(NSBitmapImageRep *to, int to_width, NSBitmapImag */ { const uchar *from_data = [from bitmapData]; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - if (fl_mac_os_version >= 100400) { // 10.4 required by the bitmapFormat message + // 10.4 required by the bitmapFormat message if (([to bitmapFormat] & NSBitmapFormatAlphaFirst) && !([from bitmapFormat] & NSBitmapFormatAlphaFirst) ) { // "to" is ARGB and "from" is RGBA --> convert "from" to ARGB @@ -4588,8 +4502,6 @@ static void write_bitmap_inside(NSBitmapImageRep *to, int to_width, NSBitmapImag // so ARGBARGB becomes RGBARGB(A) as needed from_data++; } - } -#endif int to_w = (int)[to pixelsWide]; // pixel width of "to" int from_w = (int)[from pixelsWide]; // pixel width of "from" int from_h = (int)[from pixelsHigh]; // pixel height of "from" @@ -4693,13 +4605,11 @@ static NSBitmapImageRep* rect_to_NSBitmapImageRep(Fl_Window *win, int x, int y, int view_h = [winview frame].size.height; rect = NSMakeRect(int(x*s), int(view_h-y*s-int(h*s)), int(w*s), int(h*s)); // lock focus to win's view - #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 if (fl_mac_os_version >= 101100) { NSGraphicsContext *ctxt = [fl_xid(win) performSelector:@selector(graphicsContext)]; [ctxt saveGraphicsState]; // necessary under 10.11 } - #endif [winview performSelector:@selector(lockFocus)]; } // The image depth is 3 until macOS 10.5 and 4 with 10.6 and above @@ -4710,13 +4620,11 @@ static NSBitmapImageRep* rect_to_NSBitmapImageRep(Fl_Window *win, int x, int y, #pragma clang diagnostic pop if ( !( through_Fl_X_flush && Fl_Window::current() == win) ) { [winview performSelector:@selector(unlockFocus)]; - #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 if (fl_mac_os_version >= 101100) { NSGraphicsContext *ctxt = [fl_xid(win) performSelector:@selector(graphicsContext)]; [ctxt restoreGraphicsState]; } - #endif } } return bitmap; @@ -4774,24 +4682,9 @@ CGImageRef Fl_Cocoa_Window_Driver::CGImage_from_window_rect(int x, int y, int w, { CGImageRef img; NSBitmapImageRep *bitmap = rect_to_NSBitmapImageRep_subwins(pWindow, x, y, w, h, capture_subwins); - if (fl_mac_os_version >= 100500) { img = (CGImageRef)[bitmap performSelector:@selector(CGImage)]; // requires Mac OS 10.5 CGImageRetain(img); [bitmap release]; - } else { - CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB(); - CGDataProviderRef provider = - CGDataProviderCreateWithData(bitmap, [bitmap bitmapData], - [bitmap bytesPerRow] * [bitmap pixelsHigh], - nsbitmapProviderReleaseData); - img = CGImageCreate([bitmap pixelsWide], [bitmap pixelsHigh], 8, [bitmap bitsPerPixel], - [bitmap bytesPerRow], cspace, - ([bitmap bitsPerPixel] == 32 ? kCGImageAlphaPremultipliedLast : - kCGImageAlphaNone) , - provider, NULL, false, kCGRenderingIntentDefault); - CGColorSpaceRelease(cspace); - CGDataProviderRelease(provider); - } return img; } @@ -4899,7 +4792,6 @@ static CGImageRef capture_decorated_window_SCK(NSWindow *nswin) { CGImageRef Fl_Cocoa_Window_Driver::capture_decorated_window_10_5(NSWindow *nswin) { // usable with 10.5 and above CGImageRef img = NULL; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 # if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_15_0 && defined(__BLOCKS__) if (fl_mac_os_version >= 150000) img = capture_decorated_window_SCK(nswin); @@ -4913,7 +4805,6 @@ CGImageRef Fl_Cocoa_Window_Driver::capture_decorated_window_10_5(NSWindow *nswin CFRelease(array); # endif } -#endif // >= MAC_OS_X_VERSION_10_5 return img; } @@ -4988,6 +4879,8 @@ int Fl_Darwin_System_Driver::calc_mac_os_version() { #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14 if (fl_mac_os_version >= 101400) views_use_CA = YES; #endif + if (fl_mac_os_version < 100500) + fprintf(stderr, "Warning: FLTK expects macOS version 10.5 or higher"); return fl_mac_os_version; } @@ -5059,7 +4952,6 @@ static NSImage* rgb_to_nsimage(const Fl_RGB_Image *rgb) { int ld = rgb->ld(); if (!ld) ld = rgb->data_w() * rgb->d(); NSImage *win_icon = nil; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 if (fl_mac_os_version >= 101000) { NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL @@ -5079,7 +4971,6 @@ static NSImage* rgb_to_nsimage(const Fl_RGB_Image *rgb) { [win_icon addRepresentation:bitmap]; [bitmap release]; } -#endif return win_icon; } diff --git a/src/Fl_get_key_mac.cxx b/src/Fl_get_key_mac.cxx index ef5ef1ae1..b9ad86dd1 100644 --- a/src/Fl_get_key_mac.cxx +++ b/src/Fl_get_key_mac.cxx @@ -1,7 +1,7 @@ // // MacOS keyboard state routines for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2023 by Bill Spitzak and others. +// Copyright 1998-2026 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 @@ -28,154 +28,7 @@ // The list of Mac OS virtual keycodes appears with OS 10.5 in // ...../Carbon.framework/Frameworks/HIToolbox.framework/Headers/Events.h -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 #include -#else -/* - * These constants are the virtual keycodes defined originally in - * Inside Mac Volume V, pg. V-191. They identify physical keys on a - * keyboard. Those constants with "ANSI" in the name are labeled - * according to the key position on an ANSI-standard US keyboard. - * For example, kVK_ANSI_A indicates the virtual keycode for the key - * with the letter 'A' in the US keyboard layout. Other keyboard - * layouts may have the 'A' key label on a different physical key; - * in this case, pressing 'A' will generate a different virtual - * keycode. - */ -enum { - kVK_ANSI_A = 0x00, - kVK_ANSI_S = 0x01, - kVK_ANSI_D = 0x02, - kVK_ANSI_F = 0x03, - kVK_ANSI_H = 0x04, - kVK_ANSI_G = 0x05, - kVK_ANSI_Z = 0x06, - kVK_ANSI_X = 0x07, - kVK_ANSI_C = 0x08, - kVK_ANSI_V = 0x09, - kVK_ANSI_B = 0x0B, - kVK_ANSI_Q = 0x0C, - kVK_ANSI_W = 0x0D, - kVK_ANSI_E = 0x0E, - kVK_ANSI_R = 0x0F, - kVK_ANSI_Y = 0x10, - kVK_ANSI_T = 0x11, - kVK_ANSI_1 = 0x12, - kVK_ANSI_2 = 0x13, - kVK_ANSI_3 = 0x14, - kVK_ANSI_4 = 0x15, - kVK_ANSI_6 = 0x16, - kVK_ANSI_5 = 0x17, - kVK_ANSI_Equal = 0x18, - kVK_ANSI_9 = 0x19, - kVK_ANSI_7 = 0x1A, - kVK_ANSI_Minus = 0x1B, - kVK_ANSI_8 = 0x1C, - kVK_ANSI_0 = 0x1D, - kVK_ANSI_RightBracket = 0x1E, - kVK_ANSI_O = 0x1F, - kVK_ANSI_U = 0x20, - kVK_ANSI_LeftBracket = 0x21, - kVK_ANSI_I = 0x22, - kVK_ANSI_P = 0x23, - kVK_ANSI_L = 0x25, - kVK_ANSI_J = 0x26, - kVK_ANSI_Quote = 0x27, - kVK_ANSI_K = 0x28, - kVK_ANSI_Semicolon = 0x29, - kVK_ANSI_Backslash = 0x2A, - kVK_ANSI_Comma = 0x2B, - kVK_ANSI_Slash = 0x2C, - kVK_ANSI_N = 0x2D, - kVK_ANSI_M = 0x2E, - kVK_ANSI_Period = 0x2F, - kVK_ANSI_Grave = 0x32, - kVK_ANSI_KeypadDecimal = 0x41, - kVK_ANSI_KeypadMultiply = 0x43, - kVK_ANSI_KeypadPlus = 0x45, - kVK_ANSI_KeypadClear = 0x47, - kVK_ANSI_KeypadDivide = 0x4B, - kVK_ANSI_KeypadEnter = 0x4C, - kVK_ANSI_KeypadMinus = 0x4E, - kVK_ANSI_KeypadEquals = 0x51, - kVK_ANSI_Keypad0 = 0x52, - kVK_ANSI_Keypad1 = 0x53, - kVK_ANSI_Keypad2 = 0x54, - kVK_ANSI_Keypad3 = 0x55, - kVK_ANSI_Keypad4 = 0x56, - kVK_ANSI_Keypad5 = 0x57, - kVK_ANSI_Keypad6 = 0x58, - kVK_ANSI_Keypad7 = 0x59, - kVK_ANSI_Keypad8 = 0x5B, - kVK_ANSI_Keypad9 = 0x5C -}; - -/* keycodes for keys that are independent of keyboard layout*/ -enum { - kVK_Return = 0x24, - kVK_Tab = 0x30, - kVK_Space = 0x31, - kVK_Delete = 0x33, - kVK_Escape = 0x35, - kVK_Command = 0x37, - kVK_Shift = 0x38, - kVK_CapsLock = 0x39, - kVK_Option = 0x3A, - kVK_Control = 0x3B, - kVK_RightShift = 0x3C, - kVK_RightOption = 0x3D, - kVK_RightControl = 0x3E, - kVK_Function = 0x3F, - kVK_F17 = 0x40, - kVK_VolumeUp = 0x48, - kVK_VolumeDown = 0x49, - kVK_Mute = 0x4A, - kVK_F18 = 0x4F, - kVK_F19 = 0x50, - kVK_F20 = 0x5A, - kVK_F5 = 0x60, - kVK_F6 = 0x61, - kVK_F7 = 0x62, - kVK_F3 = 0x63, - kVK_F8 = 0x64, - kVK_F9 = 0x65, - kVK_F11 = 0x67, - kVK_F13 = 0x69, - kVK_F16 = 0x6A, - kVK_F14 = 0x6B, - kVK_F10 = 0x6D, - kVK_F12 = 0x6F, - kVK_F15 = 0x71, - kVK_Help = 0x72, - kVK_Home = 0x73, - kVK_PageUp = 0x74, - kVK_ForwardDelete = 0x75, - kVK_F4 = 0x76, - kVK_End = 0x77, - kVK_F2 = 0x78, - kVK_PageDown = 0x79, - kVK_F1 = 0x7A, - kVK_LeftArrow = 0x7B, - kVK_RightArrow = 0x7C, - kVK_DownArrow = 0x7D, - kVK_UpArrow = 0x7E -}; - -/* ISO keyboards only*/ -enum { - kVK_ISO_Section = 0x0A -}; - -/* JIS keyboards only*/ -enum { - kVK_JIS_Yen = 0x5D, - kVK_JIS_Underscore = 0x5E, - kVK_JIS_KeypadComma = 0x5F, - kVK_JIS_Eisu = 0x66, - kVK_JIS_Kana = 0x68 -}; - -#endif // convert an FLTK (X) keysym to a MacOS symbol: // This table is in numeric order by FLTK symbol order for binary search. @@ -245,33 +98,5 @@ int Fl_Cocoa_Screen_Driver::event_key(int k) { //: returns true, if that key is pressed right now int Fl_Cocoa_Screen_Driver::get_key(int k) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - if (&CGEventSourceKeyState != NULL) { - return (int)CGEventSourceKeyState(kCGEventSourceStateCombinedSessionState, fltk2mac(k) ); - } - else -#endif - { - typedef UInt32 fl_KeyMap[4]; - fl_KeyMap foo; - // use the GetKeys Carbon function - typedef void (*keymap_f)(fl_KeyMap); - static keymap_f f = NULL; - if (!f) f = ( keymap_f )Fl_Darwin_System_Driver::get_carbon_function("GetKeys"); - (*f)(foo); -#ifdef MAC_TEST_FOR_KEYCODES - static int cnt = 0; - if (cnt++>1024) { - cnt = 0; - printf("%08x %08x %08x %08x\n", (ulong*)(foo)[3], (ulong*)(foo)[2], (ulong*)(foo)[1], (ulong*)(foo)[0]); - } -#endif - unsigned char *b = (unsigned char*)foo; - // KP_Enter can be at different locations for Powerbooks vs. desktop Macs - if (k==FL_KP_Enter) { - return (((b[0x34>>3]>>(0x34&7))&1)||((b[0x4c>>3]>>(0x4c&7))&1)); - } - int i = fltk2mac(k); - return (b[i>>3]>>(i&7))&1; - } + return (int)CGEventSourceKeyState(kCGEventSourceStateCombinedSessionState, fltk2mac(k) ); // 10.4 } diff --git a/src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.mm b/src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.mm index d286d46f3..6dff548f0 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.mm +++ b/src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.mm @@ -1,7 +1,7 @@ // // Class Fl_Cocoa_Gl_Window_Driver for the Fast Light Tool Kit (FLTK). // -// Copyright 2021-2022 by Bill Spitzak and others. +// Copyright 2021-2026 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 @@ -112,10 +112,8 @@ static NSOpenGLPixelFormat* mode_to_NSOpenGLPixelFormat(int m, const int *alistp //list[n++] = AGL_STEREO; attribs[n++] = 6/*NSOpenGLPFAStereo*/; } - if ((m & FL_MULTISAMPLE) && fl_mac_os_version >= 100400) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 + if (m & FL_MULTISAMPLE) { attribs[n++] = NSOpenGLPFAMultisample; // 10.4 -#endif attribs[n++] = NSOpenGLPFASampleBuffers; attribs[n++] = (NSOpenGLPixelFormatAttribute)1; attribs[n++] = NSOpenGLPFASamples; attribs[n++] = (NSOpenGLPixelFormatAttribute)4; } @@ -480,8 +478,6 @@ Fl_RGB_Image* Fl_Cocoa_Gl_Window_Driver::capture_gl_rectangle(int x, int y, int if (factor != 1) { w *= factor; h *= factor; x *= factor; y *= factor; } -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if (fl_mac_os_version >= 100500) { NSWindow *nswin = (NSWindow*)fl_mac_xid(pWindow); CGImageRef img_full = Fl_Cocoa_Window_Driver::capture_decorated_window_10_5(nswin); int bt = [nswin frame].size.height - [[nswin contentView] frame].size.height; @@ -492,8 +488,6 @@ Fl_RGB_Image* Fl_Cocoa_Gl_Window_Driver::capture_gl_rectangle(int x, int y, int Fl_RGB_Image *rgb = cgimage_to_rgb4(cgimg); CGImageRelease(cgimg); return rgb; - } -#endif [(NSOpenGLContext*)glw->context() makeCurrentContext]; // to capture also the overlay and for directGL demo [(NSOpenGLContext*)glw->context() flushBuffer]; diff --git a/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm b/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm index 0df98af7e..f1a769d75 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm +++ b/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm @@ -1,7 +1,7 @@ // // Mac OS X-specific printing support (objective-c++) for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2024 by Bill Spitzak and others. +// Copyright 2010-2026 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 @@ -107,8 +107,6 @@ int Fl_Cocoa_Printer_Driver::begin_job (int pagecount, int *frompage, int *topag OSStatus status = 0; fl_open_display(); Fl_Cocoa_Window_Driver::q_release_context(); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if (fl_mac_os_version >= 100500) { NSPrintInfo *info = [NSPrintInfo sharedPrintInfo]; NSPrintPanel *panel = [NSPrintPanel printPanel]; //from 10.5 @@ -143,59 +141,6 @@ int Fl_Cocoa_Printer_Driver::begin_job (int pagecount, int *frompage, int *topag if (*topage > pagecount && pagecount > 0) *topage = pagecount; } status = PMSessionBeginCGDocumentNoDialog(printSession, printSettings, pageFormat);//from 10.4 - } - else -#endif - { -#if !defined(__LP64__) || !__LP64__ - Boolean accepted; - status = PMCreateSession(&printSession); - if (status != noErr) return 1; - status = PMCreatePageFormat(&pageFormat); - status = PMSessionDefaultPageFormat(printSession, pageFormat); - if (status != noErr) return 1; - // get pointer to the PMSessionPageSetupDialog Carbon function - typedef OSStatus (*dialog_f)(PMPrintSession, PMPageFormat, Boolean *); - static dialog_f f = NULL; - if (!f) f = (dialog_f)Fl_Darwin_System_Driver::get_carbon_function("PMSessionPageSetupDialog"); - status = (*f)(printSession, pageFormat, &accepted); - if (status != noErr || !accepted) { - Fl::first_window()->show(); - return 1; - } - status = PMCreatePrintSettings(&printSettings); - if (status != noErr || printSettings == kPMNoPrintSettings) return 1; - status = PMSessionDefaultPrintSettings (printSession, printSettings); - if (status != noErr) return 1; - PMSetPageRange(printSettings, 1, (UInt32)kPMPrintAllPages); - // get pointer to the PMSessionPrintDialog Carbon function - typedef OSStatus (*dialog_f2)(PMPrintSession, PMPrintSettings, PMPageFormat, Boolean *); - static dialog_f2 f2 = NULL; - if (!f2) f2 = (dialog_f2)Fl_Darwin_System_Driver::get_carbon_function("PMSessionPrintDialog"); - status = (*f2)(printSession, printSettings, pageFormat, &accepted); - if (!accepted) status = kPMCancel; - if (status != noErr) { - Fl::first_window()->show(); - return 1; - } - UInt32 from32, to32; - PMGetFirstPage(printSettings, &from32); - if (frompage) *frompage = (int)from32; - PMGetLastPage(printSettings, &to32); - if (topage) *topage = (int)to32; - if(topage && *topage > pagecount) *topage = pagecount; - CFStringRef mystring[1]; - mystring[0] = kPMGraphicsContextCoreGraphics; - CFArrayRef array = CFArrayCreate(NULL, (const void **)mystring, 1, &kCFTypeArrayCallBacks); - PMSessionSetDocumentFormatGeneration_type PMSessionSetDocumentFormatGeneration = - (PMSessionSetDocumentFormatGeneration_type)Fl_Darwin_System_Driver::get_carbon_function("PMSessionSetDocumentFormatGeneration"); - status = PMSessionSetDocumentFormatGeneration(printSession, kPMDocumentFormatDefault, array, NULL); - CFRelease(array); - PMSessionBeginDocumentNoDialog_type PMSessionBeginDocumentNoDialog = - (PMSessionBeginDocumentNoDialog_type)Fl_Darwin_System_Driver::get_carbon_function("PMSessionBeginDocumentNoDialog"); - status = PMSessionBeginDocumentNoDialog(printSession, printSettings, pageFormat); -#endif //__LP64__ - } if (status != noErr) { if (perr_message) { @@ -309,19 +254,7 @@ int Fl_Cocoa_Printer_Driver::begin_page (void) { OSStatus status = PMSessionBeginPageNoDialog(printSession, pageFormat, NULL); CGContextRef gc; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - if ( &PMSessionGetCGGraphicsContext != NULL ) { - status = PMSessionGetCGGraphicsContext(printSession, &gc); - } - else -#endif - { -#if !defined(__LP64__) || !__LP64__ - PMSessionGetGraphicsContext_type PMSessionGetGraphicsContext = - (PMSessionGetGraphicsContext_type)Fl_Darwin_System_Driver::get_carbon_function("PMSessionGetGraphicsContext"); - status = PMSessionGetGraphicsContext(printSession, NULL, (void **)&gc); -#endif - } + status = PMSessionGetCGGraphicsContext(printSession, &gc); // 10.4 driver()->gc(gc); Fl_Surface_Device::push_current(this); PMRect pmRect; @@ -377,13 +310,6 @@ void Fl_Cocoa_Printer_Driver::end_job (void) fl_alert ("PM Session error %d", (int)status); } PMSessionEndDocumentNoDialog(printSession); -#if !defined(__LP64__) || !__LP64__ - if (fl_mac_os_version < 100500) { - PMRelease(printSettings); - PMRelease(pageFormat); - PMRelease(printSession); - } -#endif Fl_Window *w = Fl::first_window(); if (w) w->show(); } diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx index 15983032f..ac99ab70b 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx +++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx @@ -1,7 +1,7 @@ // // Definition of Apple Cocoa window driver. // -// Copyright 1998-2018 by Bill Spitzak and others. +// Copyright 1998-2026 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 @@ -75,12 +75,10 @@ void Fl_Cocoa_Window_Driver::draw_begin() if (!Fl_Surface_Device::surface()->driver()->has_feature(Fl_Graphics_Driver::NATIVE)) return; CGContextRef my_gc = (CGContextRef)Fl_Surface_Device::surface()->driver()->gc(); if (shape_data_) { -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - if (shape_data_->mask && (&CGContextClipToMask != NULL)) { + if (shape_data_->mask) { CGContextClipToMask(my_gc, CGRectMake(0,0,w(),h()), shape_data_->mask); // requires Mac OS 10.4 } CGContextSaveGState(my_gc); -# endif } } @@ -111,12 +109,10 @@ void Fl_Cocoa_Window_Driver::draw_end() } } } -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 if (Fl_Surface_Device::surface()->driver()->has_feature(Fl_Graphics_Driver::NATIVE)) { CGContextRef my_gc = (CGContextRef)Fl_Surface_Device::surface()->driver()->gc(); if (shape_data_) CGContextRestoreGState(my_gc); } -# endif } @@ -187,7 +183,6 @@ void Fl_Cocoa_Window_Driver::shape_alpha_(Fl_Image* img, int offset) { void Fl_Cocoa_Window_Driver::shape(const Fl_Image* img) { -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 if (shape_data_) { if (shape_data_->mask) { CGImageRelease(shape_data_->mask); } } @@ -203,7 +198,6 @@ void Fl_Cocoa_Window_Driver::shape(const Fl_Image* img) { else if (d == 0) shape_bitmap_((Fl_Image*)img); else if (d == 2 || d == 4) shape_alpha_((Fl_Image*)img, d - 1); else if ((d == 1 || d == 3) && img->count() == 1) shape_alpha_((Fl_Image*)img, 0); -#endif pWindow->border(false); } diff --git a/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx b/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx index 431e908a5..c11a95f94 100644 --- a/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx +++ b/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx @@ -1,7 +1,7 @@ // // Definition of Apple Darwin system driver. // -// Copyright 1998-2021 by Bill Spitzak and others. +// Copyright 1998-2026 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 @@ -24,9 +24,7 @@ #include #include "../../flstring.h" #include -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 -#include -#endif +#include // 10.4 #include #include #include @@ -66,61 +64,28 @@ int Fl_Darwin_System_Driver::arg_and_value(const char *name, const char *value) return strcmp(name, "NSDocumentRevisionsDebugMode") == 0; } -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 static locale_t postscript_locale = NULL; -#endif int Fl_Darwin_System_Driver::clocale_vprintf(FILE *output, const char *format, va_list args) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - if (fl_mac_os_version >= 100400) { - if (!postscript_locale) - postscript_locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0); - return vfprintf_l(output, postscript_locale, format, args); - } -#endif - char *saved_locale = setlocale(LC_NUMERIC, NULL); - setlocale(LC_NUMERIC, "C"); - int retval = vfprintf(output, format, args); - setlocale(LC_NUMERIC, saved_locale); - return retval; + if (!postscript_locale) + postscript_locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0); + return vfprintf_l(output, postscript_locale, format, args); // 10.4 } int Fl_Darwin_System_Driver::clocale_vsnprintf(char *output, size_t output_size, const char *format, va_list args) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - if (fl_mac_os_version >= 100400) { - if (!postscript_locale) - postscript_locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0); - return vsnprintf_l(output, output_size, postscript_locale, format, args); - } -#endif - char *saved_locale = setlocale(LC_NUMERIC, NULL); - setlocale(LC_NUMERIC, "C"); - int retval = vsnprintf(output, output_size, format, args); - setlocale(LC_NUMERIC, saved_locale); - return retval; + if (!postscript_locale) + postscript_locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0); + return vsnprintf_l(output, output_size, postscript_locale, format, args); // 10.4 } int Fl_Darwin_System_Driver::clocale_vsscanf(const char *input, const char *format, va_list args) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - if (fl_mac_os_version >= 100400) { - if (!postscript_locale) - postscript_locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0); - return vsscanf_l(input, postscript_locale, format, args); - } -#endif - char *saved_locale = setlocale(LC_NUMERIC, NULL); - setlocale(LC_NUMERIC, "C"); - int retval = vsscanf(input, format, args); - setlocale(LC_NUMERIC, saved_locale); - return retval; + if (!postscript_locale) + postscript_locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0); + return vsscanf_l(input, postscript_locale, format, args); // 10.4 } -/* Returns the address of a Carbon function after dynamically loading the Carbon library if needed. - Supports old Mac OS X versions that may use a couple of Carbon calls: - GetKeys used by OS X 10.3 or before (in Fl::get_key()) - PMSessionPageSetupDialog and PMSessionPrintDialog used by 10.4 or before (in Fl_Printer::begin_job()) - */ +// Returns the address of a Carbon function after dynamically loading the Carbon library if needed. void *Fl_Darwin_System_Driver::get_carbon_function(const char *function_name) { static void *carbon = ::dlopen("/System/Library/Frameworks/Carbon.framework/Carbon", RTLD_LAZY); return (carbon ? dlsym(carbon, function_name) : NULL); diff --git a/src/drivers/Quartz/Fl_Font.H b/src/drivers/Quartz/Fl_Font.H index c700568a2..f1a710eea 100644 --- a/src/drivers/Quartz/Fl_Font.H +++ b/src/drivers/Quartz/Fl_Font.H @@ -1,7 +1,7 @@ // // Font definitions for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2018 by Bill Spitzak and others. +// Copyright 1998-2026 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 @@ -31,15 +31,9 @@ class Fl_Quartz_Font_Descriptor : public Fl_Font_Descriptor { public: Fl_Quartz_Font_Descriptor(const char* fontname, Fl_Fontsize size); virtual FL_EXPORT ~Fl_Quartz_Font_Descriptor(); -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 CTFontRef fontref; // the unicode span is divided in 512 blocks of 128 characters float *width[512]; // array of arrays of character widths -# endif -# if HAS_ATSU - ATSUTextLayout layout; - ATSUStyle style; -# endif short q_width; }; diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H index ca1ffce04..0afc7369e 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H @@ -2,7 +2,7 @@ // Definition of Apple Quartz graphics driver // for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2022 by Bill Spitzak and others. +// Copyright 2010-2026 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 @@ -27,16 +27,6 @@ #include #include -// condition for the ATSU API to be available at compile time -#if ( (!defined(__LP64__) || !__LP64__) \ - && MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11 \ - && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 \ - ) -#define HAS_ATSU 1 -#else -#define HAS_ATSU 0 -#endif - struct Fl_Fontdesc; class Fl_Quartz_Font_Descriptor; @@ -143,30 +133,7 @@ protected: void set_fontname_in_fontdesc(Fl_Fontdesc *f); void uncache_pixmap(fl_uintptr_t p) FL_OVERRIDE; -#if HAS_ATSU && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - enum {use_CoreText = 1, use_ATSU}; - static int CoreText_or_ATSU; - static void init_CoreText_or_ATSU(); - void draw_CoreText(const char *str, int n, float x, float y); - double width_CoreText(const UniChar* txt, int n); - void descriptor_init_CoreText(const char* name, Fl_Fontsize Size, Fl_Quartz_Font_Descriptor *d); - void text_extents_CoreText(const char*, int n, int& dx, int& dy, int& w, int& h); - Fl_Font set_fonts_CoreText(const char* xstarname); - - void draw_ATSU(const char *str, int n, float x, float y); - double width_ATSU(const UniChar* txt, int n); - void descriptor_init_ATSU(const char* name, Fl_Fontsize Size, Fl_Quartz_Font_Descriptor *d); - void text_extents_ATSU(const char*, int n, int& dx, int& dy, int& w, int& h); - Fl_Font set_fonts_ATSU(const char* xstarname); - - // define 2 kinds of pointers to member function - typedef void (Fl_Quartz_Graphics_Driver::*pter_to_draw_member)(const char *str, int n, float x, float y); - typedef double (Fl_Quartz_Graphics_Driver::*pter_to_width_member)(const UniChar *str, int n); - static pter_to_draw_member CoreText_or_ATSU_draw; - static pter_to_width_member CoreText_or_ATSU_width; -#else void descriptor_init(const char* name, Fl_Fontsize Size, Fl_Quartz_Font_Descriptor *d); -#endif void overlay_rect(int x, int y, int w , int h) FL_OVERRIDE; float override_scale() FL_OVERRIDE; void restore_scale(float) FL_OVERRIDE; diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx index 7ee610d24..21c5eda4c 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx @@ -1,7 +1,7 @@ // // Rectangle drawing routines for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2018 by Bill Spitzak and others. +// Copyright 1998-2026 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 @@ -22,27 +22,6 @@ #include #include -#if HAS_ATSU && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 -Fl_Quartz_Graphics_Driver::pter_to_draw_member Fl_Quartz_Graphics_Driver::CoreText_or_ATSU_draw; -Fl_Quartz_Graphics_Driver::pter_to_width_member Fl_Quartz_Graphics_Driver::CoreText_or_ATSU_width; - -int Fl_Quartz_Graphics_Driver::CoreText_or_ATSU = 0; - -void Fl_Quartz_Graphics_Driver::init_CoreText_or_ATSU() -{ - if (Fl_Darwin_System_Driver::calc_mac_os_version() < 100500) { - // before Mac OS 10.5, only ATSU is available - CoreText_or_ATSU = use_ATSU; - CoreText_or_ATSU_draw = &Fl_Quartz_Graphics_Driver::draw_ATSU; - CoreText_or_ATSU_width = &Fl_Quartz_Graphics_Driver::width_ATSU; - } else { - CoreText_or_ATSU = use_CoreText; - CoreText_or_ATSU_draw = &Fl_Quartz_Graphics_Driver::draw_CoreText; - CoreText_or_ATSU_width = &Fl_Quartz_Graphics_Driver::width_CoreText; - } -} -#endif - void Fl_Quartz_Graphics_Driver::antialias(int state) { } @@ -58,9 +37,6 @@ Fl_Quartz_Graphics_Driver::Fl_Quartz_Graphics_Driver() : Fl_Graphics_Driver(), g quartz_line_pattern = 0; quartz_line_pattern_size = 0; high_resolution_ = false; -#if HAS_ATSU && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if (!CoreText_or_ATSU) init_CoreText_or_ATSU(); -#endif } char Fl_Quartz_Graphics_Driver::can_do_alpha_blending() { @@ -91,26 +67,10 @@ CGContextRef fl_mac_gc() { return fl_gc; } void Fl_Quartz_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen osrc, int srcx, int srcy) { // draw portion srcx,srcy,w,h of osrc to position x,y (top-left) of the graphics driver's surface CGContextRef src = (CGContextRef)osrc; - void *data = CGBitmapContextGetData(src); int sw = (int)CGBitmapContextGetWidth(src); int sh = (int)CGBitmapContextGetHeight(src); CGImageRef img; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - if (fl_mac_os_version >= 100400) img = CGBitmapContextCreateImage(src); // requires 10.4 - else -#endif - { - CGImageAlphaInfo alpha = CGBitmapContextGetAlphaInfo(src); - CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB(); - // when output goes to a Quartz printercontext, release of the bitmap must be - // delayed after the end of the printed page - CFRetain(src); - CGDataProviderRef src_bytes = CGDataProviderCreateWithData( src, data, sw*sh*4, bmProviderRelease); - img = CGImageCreate( sw, sh, 8, 4*8, 4*sw, lut, alpha, - src_bytes, 0L, false, kCGRenderingIntentDefault); - CGDataProviderRelease(src_bytes); - CGColorSpaceRelease(lut); - } + img = CGBitmapContextCreateImage(src); // requires 10.4 CGAffineTransform at = CGContextGetCTM(src); float s = at.a; draw_CGImage(img, x, y, w, h, srcx, srcy, sw/s, sh/s); diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx index a277010e3..d373c1768 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx @@ -14,61 +14,6 @@ // https://www.fltk.org/bugs.php // -/* Implementation of support for two text drawing APIs: Core Text (current) and ATSU (legacy) - - The HAS_ATSU macro (defined in Fl_Quartz_Graphics_Driver.H) is true - if and only if ATSU is available at compile time. - The condition - #if HAS_ATSU && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - is true if and only if both APIs are available at compile time. - Depending on what MacOS SDK and what deployment target are used, the code can be - compiled in 2 ways: - 1) both APIs are available at compile time and which one is used - is determined at runtime, - or - 2) only one API is available. - - When both APIs are compiled in, the choice of which one is used at runtime is done - the first time the Fl_Quartz_Graphics_Driver constructor runs, and remains unchanged. - Core Text is selected if the running Mac OS version is ≥ 10.5. - The static function init_CoreText_or_ATSU() does this by setting the value - of the class variable CoreText_or_ATSU to either use_CoreText or use_ATSU. - - If both APIs are available, several member functions come in groups of 3. - For example, functions draw(), draw_CoreText() and draw_ATSU() are defined. The only - task of draw() is to call either draw_CoreText() or draw_ATSU() depending on - what API has been selected at program start. - - If the compilation condition authorizes a single API, one member function - is defined instead of 3 in the other case. For example, a single draw() function - is compiled, and contains the same code as what is called either draw_CoreText() - or draw_ATSU() in the other case. - - The ADD_SUFFIX(name, suffix) macro is used so that each function has the - short (e.g., draw) or long (e.g., draw_CoreText) name adequate for - each compilation condition. - - The 2 most often used text functions are draw() and width(). Two pointers to member - function are defined. Function init_CoreText_or_ATSU() assigns one with either - draw_CoreText() or draw_ATSU(), and the other with either width_CoreText() or width_ATSU(). - The draw() and width() functions only have to dereference one pointer to member - function to call the adequate code. - - If the compilation condition authorizes a single text API, only the code related - to this API (say, CoreText) is compiled whereas all code related to the other API - (thus, ATSU) is excluded from compilation. Furthermore, none of the code to - choose API at runtime and to select which member function is called is compiled. - Consequently, no pointer to member function is used. - - The condition for both APIs to be compiled-in is - - target i386 or ppc architectures - and - - use SDK ≥ 10.5 and < 10.11 - and - - set MacOS deployment target < 10.5 (through the -mmacosx-version-min= compilation option) - - */ - #include "Fl_Quartz_Graphics_Driver.H" #include "Fl_Font.H" #include @@ -87,13 +32,6 @@ static CGAffineTransform font_mx = { 1, 0, 0, -1, 0, 0 }; static int fl_free_font = FL_FREE_FONT; -#if HAS_ATSU && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 -# define ADD_SUFFIX(name, suffix) name##suffix -#else -# define ADD_SUFFIX(name, suffix) name -#endif - -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 static CFMutableDictionaryRef attributes = NULL; @@ -115,28 +53,7 @@ static Fl_Fontdesc built_in_table_PS[] = { // PostScript font names preferred wh {"AndaleMono"}, // there is no bold Monaco font on standard Mac {"ZapfDingbatsITC"} }; -#endif -#if HAS_ATSU -static Fl_Fontdesc built_in_table_full[] = { // full font names used before 10.5 - {"Arial"}, - {"Arial Bold"}, - {"Arial Italic"}, - {"Arial Bold Italic"}, - {"Courier"}, - {"Courier Bold"}, - {"Courier New Italic"}, - {"Courier New Bold Italic"}, - {"Times New Roman"}, - {"Times New Roman Bold"}, - {"Times New Roman Italic"}, - {"Times New Roman Bold Italic"}, - {"Symbol"}, - {"Monaco"}, - {"Andale Mono"}, // there is no bold Monaco font on standard Mac - {"Webdings"} -}; -#endif // Bug: older versions calculated the value for *ap as a side effect of // making the name, and then forgot about it. To avoid having to change @@ -178,22 +95,9 @@ int Fl_Quartz_Graphics_Driver::get_font_sizes(Fl_Font fnum, int*& sizep) { } Fl_Quartz_Font_Descriptor::Fl_Quartz_Font_Descriptor(const char* name, Fl_Fontsize Size) : Fl_Font_Descriptor(name, Size) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 fontref = NULL; -#endif -#if HAS_ATSU - layout = NULL; -#endif Fl_Quartz_Graphics_Driver *driver = (Fl_Quartz_Graphics_Driver*)&Fl_Graphics_Driver::default_driver(); -#if HAS_ATSU && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if (Fl_Quartz_Graphics_Driver::CoreText_or_ATSU == Fl_Quartz_Graphics_Driver::use_ATSU) { - driver->descriptor_init_ATSU(name, size, this); - return; - } - driver->descriptor_init_CoreText(name, size, this); -#else driver->descriptor_init(name, size, this); -#endif } @@ -207,20 +111,12 @@ Fl_Quartz_Font_Descriptor::~Fl_Quartz_Font_Descriptor() { #endif */ if (this == fl_graphics_driver->font_descriptor()) fl_graphics_driver->font_descriptor(NULL); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 if (fontref) { CFRelease(fontref); for (unsigned i = 0; i < sizeof(width)/sizeof(float*); i++) { if (width[i]) free(width[i]); } } -#endif -#if HAS_ATSU - if (layout) { - ATSUDisposeTextLayout(layout); - ATSUDisposeStyle(style); - } -#endif } @@ -332,9 +228,7 @@ double Fl_Quartz_Graphics_Driver::width(unsigned int wc) { return width(utf16, l); } - -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 -static void set_fontname_CoreText(Fl_Fontdesc *f) { +void Fl_Quartz_Graphics_Driver::set_fontname_in_fontdesc(Fl_Fontdesc *f) { CFStringRef cfname = CFStringCreateWithCString(NULL, f->name, kCFStringEncodingUTF8); CTFontRef ctfont = cfname ? CTFontCreateWithName(cfname, 0, NULL) : NULL; if (cfname) { CFRelease(cfname); cfname = NULL; } @@ -348,20 +242,6 @@ static void set_fontname_CoreText(Fl_Fontdesc *f) { } if (!cfname) strlcpy(f->fontname, f->name, ENDOFBUFFER); } -#endif - -void Fl_Quartz_Graphics_Driver::set_fontname_in_fontdesc(Fl_Fontdesc *f) { -#if HAS_ATSU && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if (CoreText_or_ATSU == use_ATSU) - strlcpy(f->fontname, f->name, ENDOFBUFFER); - else - set_fontname_CoreText(f); -#elif HAS_ATSU - strlcpy(f->fontname, f->name, ENDOFBUFFER); -#else - set_fontname_CoreText(f); -#endif -} const char *Fl_Quartz_Graphics_Driver::font_name(int num) { if (!fl_fonts) fl_fonts = calc_fl_fonts(); @@ -385,49 +265,11 @@ void Fl_Quartz_Graphics_Driver::font_name(int num, const char *name) { Fl_Fontdesc* Fl_Quartz_Graphics_Driver::calc_fl_fonts(void) { -#if HAS_ATSU && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if (CoreText_or_ATSU == use_ATSU) return built_in_table_full; return built_in_table_PS; -#elif HAS_ATSU - return built_in_table_full; -#else - return built_in_table_PS; -#endif } -#if HAS_ATSU && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - -void Fl_Quartz_Graphics_Driver::draw(const char *str, int n, float x, float y) { - (this->*CoreText_or_ATSU_draw)(str, n, x, y); -} - -double Fl_Quartz_Graphics_Driver::width(const UniChar* txt, int n) { - return (this->*CoreText_or_ATSU_width)(txt, n); -} - -Fl_Font Fl_Quartz_Graphics_Driver::set_fonts(const char* xstarname) -{ - if (CoreText_or_ATSU == use_ATSU) return set_fonts_ATSU(xstarname); - return set_fonts_CoreText(xstarname); -} - -void Fl_Quartz_Graphics_Driver::text_extents(const char* txt, int n, int& dx, int& dy, int& w, int& h) -{ - if (CoreText_or_ATSU == use_ATSU) { - text_extents_ATSU(txt, n, dx, dy, w, h); - return; - } - text_extents_CoreText(txt, n, dx, dy, w, h); -} - -#endif - - -/// CoreText-based code -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - -void Fl_Quartz_Graphics_Driver::ADD_SUFFIX(descriptor_init, _CoreText)(const char* name, +void Fl_Quartz_Graphics_Driver::descriptor_init(const char* name, Fl_Fontsize size, Fl_Quartz_Font_Descriptor *d) { CFStringRef str = CFStringCreateWithCString(NULL, name, kCFStringEncodingUTF8); @@ -510,7 +352,7 @@ static CGFloat variation_selector_width(CFStringRef str16, Fl_Quartz_Font_Descri return retval; } -double Fl_Quartz_Graphics_Driver::ADD_SUFFIX(width, _CoreText)(const UniChar* txt, int n) +double Fl_Quartz_Graphics_Driver::width(const UniChar* txt, int n) { double retval = 0; UniChar uni; @@ -581,7 +423,7 @@ double Fl_Quartz_Graphics_Driver::ADD_SUFFIX(width, _CoreText)(const UniChar* tx // text extent calculation -void Fl_Quartz_Graphics_Driver::ADD_SUFFIX(text_extents, _CoreText)(const char *str8, int n, +void Fl_Quartz_Graphics_Driver::text_extents(const char *str8, int n, int &dx, int &dy, int &w, int &h) { Fl_Quartz_Font_Descriptor *fl_fontsize = valid_font_descriptor(); UniChar *txt = mac_Utf8_to_Utf16(str8, n, &n); @@ -615,7 +457,7 @@ static CGColorRef flcolortocgcolor(Fl_Color i) return CGColorCreate(cspace, components); } -void Fl_Quartz_Graphics_Driver::ADD_SUFFIX(draw, _CoreText)(const char *str, int n, float x, float y) +void Fl_Quartz_Graphics_Driver::draw(const char *str, int n, float x, float y) { Fl_Quartz_Font_Descriptor *fl_fontsize = valid_font_descriptor(); // convert to UTF-16 first @@ -680,7 +522,7 @@ static int name_compare(const void *a, const void *b) } } -Fl_Font Fl_Quartz_Graphics_Driver::ADD_SUFFIX(set_fonts, _CoreText)(const char* xstarname) +Fl_Font Fl_Quartz_Graphics_Driver::set_fonts(const char* xstarname) { #pragma unused ( xstarname ) if (fl_free_font > FL_FREE_FONT) return (Fl_Font)fl_free_font; // if already called @@ -717,187 +559,3 @@ Fl_Font Fl_Quartz_Graphics_Driver::ADD_SUFFIX(set_fonts, _CoreText)(const char* delete[] tabfontnames; return (Fl_Font)fl_free_font; } - - -#endif // >= 10.5 - - - -/// ATSU-based code to support Mac OS < 10.5 -#if HAS_ATSU - -void Fl_Quartz_Graphics_Driver::ADD_SUFFIX(descriptor_init, _ATSU)(const char* name, - Fl_Fontsize size, Fl_Quartz_Font_Descriptor *d) -{ - OSStatus err; - // fill our structure with a few default values - d->ascent = size*3/4.; - d->descent = size-d->ascent; - d->q_width = size*2/3.; - // now we allocate everything needed to render text in this font later - // get us the default layout and style - err = ATSUCreateTextLayout(&d->layout); - UniChar mTxt[2] = { 65, 0 }; - err = ATSUSetTextPointerLocation(d->layout, mTxt, kATSUFromTextBeginning, 1, 1); - err = ATSUCreateStyle(&d->style); - err = ATSUSetRunStyle(d->layout, d->style, kATSUFromTextBeginning, kATSUToTextEnd); - // now set the actual font, size and attributes. We also set the font matrix to - // render our font up-side-down, so when rendered through our inverted CGContext, - // text will appear normal again. - Fixed fsize = IntToFixed(size); - ATSUFontID fontID; - ATSUFindFontFromName(name, strlen(name), kFontFullName, kFontMacintoshPlatform, kFontNoScriptCode, kFontEnglishLanguage, &fontID); - - // draw the font upside-down... Compensate for fltk/OSX origin differences - ATSUAttributeTag sTag[] = { kATSUFontTag, kATSUSizeTag, kATSUFontMatrixTag }; - ByteCount sBytes[] = { sizeof(ATSUFontID), sizeof(Fixed), sizeof(CGAffineTransform) }; - ATSUAttributeValuePtr sAttr[] = { &fontID, &fsize, &font_mx }; - if (fontID != kATSUInvalidFontID) err = ATSUSetAttributes(d->style, 1, sTag, sBytes, sAttr); // set the font attribute - err = ATSUSetAttributes(d->style, 2, sTag + 1, sBytes + 1, sAttr + 1); // then the size and matrix attributes - // next, make sure that Quartz will only render at integer coordinates - ATSLineLayoutOptions llo = kATSLineUseDeviceMetrics | kATSLineDisableAllLayoutOperations; - ATSUAttributeTag aTag[] = { kATSULineLayoutOptionsTag }; - ByteCount aBytes[] = { sizeof(ATSLineLayoutOptions) }; - ATSUAttributeValuePtr aAttr[] = { &llo }; - err = ATSUSetLineControls (d->layout, kATSUFromTextBeginning, 1, aTag, aBytes, aAttr); - // now we are finally ready to measure some letter to get the bounding box - Fixed bBefore, bAfter, bAscent, bDescent; - err = ATSUGetUnjustifiedBounds(d->layout, kATSUFromTextBeginning, 1, &bBefore, &bAfter, &bAscent, &bDescent); - // Requesting a certain height font on Mac does not guarantee that ascent+descent - // equal the requested height. fl_height will reflect the actual height that we got. - // The font "Apple Chancery" is a pretty extreme example of overlapping letters. - float fa = -FixedToFloat(bAscent), fd = -FixedToFloat(bDescent); - if (fa>0.0f && fd>0.0f) { - //float f = Size/(fa+fd); - d->ascent = int(fa); //int(fa*f+0.5f); - d->descent = int(fd); //Size - ascent; - } - int w = FixedToInt(bAfter); - if (w) - d->q_width = FixedToInt(bAfter); - - // Now, by way of experiment, try enabling Transient Font Matching, this will - // cause ATSU to find a suitable font to render any chars the current font can't do... - ATSUSetTransientFontMatching (d->layout, true); -} - -void Fl_Quartz_Graphics_Driver::ADD_SUFFIX(draw, _ATSU)(const char *str, int n, float x, float y) -{ - Fl_Quartz_Font_Descriptor *fl_fontsize = valid_font_descriptor(); - // convert to UTF-16 first - UniChar *uniStr = mac_Utf8_to_Utf16(str, n, &n); - CGContextRef gc = (CGContextRef)this->gc(); - OSStatus err; - // now collect our ATSU resources - ATSUTextLayout layout = fl_fontsize->layout; - - ByteCount iSize = sizeof(CGContextRef); - ATSUAttributeTag iTag = kATSUCGContextTag; - ATSUAttributeValuePtr iValuePtr=&gc; - ATSUSetLayoutControls(layout, 1, &iTag, &iSize, &iValuePtr); - - err = ATSUSetTextPointerLocation(layout, uniStr, kATSUFromTextBeginning, n, n); - CGContextSetShouldAntialias(gc, true); - err = ATSUDrawText(layout, kATSUFromTextBeginning, n, FloatToFixed(x), FloatToFixed(y)); - CGContextSetShouldAntialias(gc, false); -} - -double Fl_Quartz_Graphics_Driver::ADD_SUFFIX(width, _ATSU)(const UniChar* txt, int n) { - OSStatus err; - Fixed bBefore, bAfter, bAscent, bDescent; - ATSUTextLayout layout; - ByteCount iSize; - ATSUAttributeTag iTag; - ATSUAttributeValuePtr iValuePtr; - - Fl_Quartz_Font_Descriptor *fl_fontsize = valid_font_descriptor(); - // Here's my ATSU text measuring attempt... This seems to do the Right Thing - // now collect our ATSU resources and measure our text string - layout = fl_fontsize->layout; - // activate the current GC - iSize = sizeof(CGContextRef); - iTag = kATSUCGContextTag; - CGContextRef value = (CGContextRef)fl_graphics_driver->gc(); - iValuePtr = &value; - ATSUSetLayoutControls(layout, 1, &iTag, &iSize, &iValuePtr); - // now measure the bounding box - err = ATSUSetTextPointerLocation(layout, txt, kATSUFromTextBeginning, n, n); - err = ATSUGetUnjustifiedBounds(layout, kATSUFromTextBeginning, n, &bBefore, &bAfter, &bAscent, &bDescent); - // If err is OK then return length, else return 0. Or something... - int len = FixedToInt(bAfter); - return len; -} - -void Fl_Quartz_Graphics_Driver::ADD_SUFFIX(text_extents, _ATSU)(const char *str8, int n, - int &dx, int &dy, int &w, int &h) -{ - Fl_Quartz_Font_Descriptor *fl_fontsize = valid_font_descriptor(); - UniChar *txt = mac_Utf8_to_Utf16(str8, n, &n); - OSStatus err; - ATSUTextLayout layout; - ByteCount iSize; - ATSUAttributeTag iTag; - ATSUAttributeValuePtr iValuePtr; - - // Here's my ATSU text measuring attempt... This seems to do the Right Thing - // now collect our ATSU resources and measure our text string - layout = fl_fontsize->layout; - // activate the current GC - iSize = sizeof(CGContextRef); - iTag = kATSUCGContextTag; - CGContextRef value = (CGContextRef)gc(); - iValuePtr = &value; - ATSUSetLayoutControls(layout, 1, &iTag, &iSize, &iValuePtr); - // now measure the bounding box - err = ATSUSetTextPointerLocation(layout, txt, kATSUFromTextBeginning, n, n); - Rect bbox; - err = ATSUMeasureTextImage(layout, kATSUFromTextBeginning, n, 0, 0, &bbox); - w = bbox.right - bbox.left; - h = bbox.bottom - bbox.top; - dx = bbox.left; - dy = -bbox.bottom; - //printf("r: %d l: %d t: %d b: %d w: %d h: %d\n", bbox.right, bbox.left, bbox.top, bbox.bottom, w, h); -} - -Fl_Font Fl_Quartz_Graphics_Driver::ADD_SUFFIX(set_fonts, _ATSU)(const char* xstarname) -{ -#pragma unused ( xstarname ) - if (fl_free_font > FL_FREE_FONT) return (Fl_Font)fl_free_font; // if already called - - ItemCount oFontCount, oCountAgain; - ATSUFontID *oFontIDs; - // How many fonts? - ATSUFontCount (&oFontCount); - // now allocate space for them... - oFontIDs = (ATSUFontID *)malloc((oFontCount+1) * sizeof(ATSUFontID)); - ATSUGetFontIDs (oFontIDs, oFontCount, &oCountAgain); - // Now oFontIDs should contain a list of all the available Unicode fonts - // Iterate through the list to get each font name - for (ItemCount idx = 0; idx < oFontCount; idx++) - { - // ByteCount actualLength = 0; - // Ptr oName; - // How to get the name - Apples docs say call this twice, once to get the length, then again - // to get the actual name... - // ATSUFindFontName (oFontIDs[idx], kFontFullName, kFontMacintoshPlatform, kFontRomanScript, kFontEnglishLanguage, - // 0, NULL, &actualLength, NULL); - // Now actualLength tells us the length of buffer we need - // oName = (Ptr)malloc(actualLength + 8); - // But who's got time for that nonsense? Let's just hard code a fixed buffer (urgh!) - ByteCount actualLength = 511; - char oName[512]; - ATSUFindFontName (oFontIDs[idx], kFontFullName, kFontMacintoshPlatform, kFontRomanScript, kFontEnglishLanguage, - actualLength, oName, &actualLength, &oCountAgain); - // bounds check and terminate the returned name - if(actualLength > 511) - oName[511] = 0; - else - oName[actualLength] = 0; - Fl::set_font((Fl_Font)(fl_free_font++), fl_strdup(oName)); - // free(oName); - } - free(oFontIDs); - return (Fl_Font)fl_free_font; -} - -#endif // HAS_ATSU diff --git a/src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.H b/src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.H index 69e00dfd0..3849ea4df 100644 --- a/src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.H +++ b/src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.H @@ -1,7 +1,7 @@ // // Draw-to-image code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2021 by Bill Spitzak and others. +// Copyright 1998-2026 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 @@ -22,10 +22,8 @@ class Fl_Quartz_Image_Surface_Driver : public Fl_Image_Surface_Driver { private: -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 CGImageRef mask_; void mask(const Fl_RGB_Image *) FL_OVERRIDE; -#endif void end_current() FL_OVERRIDE; public: FLWindow *pre_window; diff --git a/src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx index 1e3d6b927..4615ba475 100644 --- a/src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx @@ -1,7 +1,7 @@ // // Draw-to-image code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2023 by Bill Spitzak and others. +// Copyright 1998-2026 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 @@ -23,9 +23,7 @@ Fl_Quartz_Image_Surface_Driver::Fl_Quartz_Image_Surface_Driver(int w, int h, int high_res, Fl_Offscreen off) : Fl_Image_Surface_Driver(w, h, high_res, off) { -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 mask_ = NULL; -#endif int W = w, H = h; float s = 1; if (high_res) { @@ -53,11 +51,9 @@ Fl_Quartz_Image_Surface_Driver::Fl_Quartz_Image_Surface_Driver(int w, int h, int } Fl_Quartz_Image_Surface_Driver::~Fl_Quartz_Image_Surface_Driver() { -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 if (mask_) { CGImageRelease(mask_); } -#endif if (offscreen) CGContextRestoreGState((CGContextRef)offscreen); if (offscreen && !external_offscreen) { void *data = CGBitmapContextGetData((CGContextRef)offscreen); @@ -74,7 +70,6 @@ void Fl_Quartz_Image_Surface_Driver::set_current() { driver()->gc((CGContextRef)offscreen); fl_window = 0; ((Fl_Quartz_Graphics_Driver*)driver())->high_resolution( CGBitmapContextGetWidth((CGContextRef)offscreen) > (size_t)width ); -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 if (mask_) { int W, H; printable_rect(&W, &H); @@ -82,7 +77,6 @@ void Fl_Quartz_Image_Surface_Driver::set_current() { CGContextClipToMask((CGContextRef)offscreen, CGRectMake(0,0,W,H), mask_); // 10.4 CGContextSaveGState((CGContextRef)offscreen); } -# endif } void Fl_Quartz_Image_Surface_Driver::translate(int x, int y) { @@ -99,13 +93,11 @@ void Fl_Quartz_Image_Surface_Driver::untranslate() { Fl_RGB_Image* Fl_Quartz_Image_Surface_Driver::image() { CGContextFlush((CGContextRef)offscreen); -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 if (mask_) { CGContextRestoreGState((CGContextRef)offscreen); CGImageRelease(mask_); mask_ = NULL; } -#endif int W = (int)CGBitmapContextGetWidth((CGContextRef)offscreen); int H = (int)CGBitmapContextGetHeight((CGContextRef)offscreen); int bpr = (int)CGBitmapContextGetBytesPerRow((CGContextRef)offscreen); @@ -128,19 +120,15 @@ Fl_RGB_Image* Fl_Quartz_Image_Surface_Driver::image() void Fl_Quartz_Image_Surface_Driver::end_current() { -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 if (mask_) { CGContextRestoreGState((CGContextRef)offscreen); CGContextRestoreGState((CGContextRef)offscreen); } -# endif fl_window = pre_window; Fl_Surface_Device::end_current(); } -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - static void MyProviderReleaseData (void *info, const void *data, size_t size) { delete[] (uchar*)data; } @@ -177,5 +165,3 @@ void Fl_Quartz_Image_Surface_Driver::mask(const Fl_RGB_Image *img) { CFRelease(provider); if (using_copy) delete img; } - -#endif diff --git a/test/blocks.cxx b/test/blocks.cxx index b2ab76435..8b943b734 100644 --- a/test/blocks.cxx +++ b/test/blocks.cxx @@ -1,7 +1,7 @@ // // "Block Attack!" scrolling blocks game using the Fast Light Tool Kit (FLTK). // -// Copyright © 2006-2021 by Michael Sweet. +// Copyright © 2006-2026 by Michael Sweet. // // 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 @@ -150,12 +150,7 @@ class BlockSound { // Private, OS-specific data... #ifdef __APPLE__ AudioDeviceID device; -#ifndef MAC_OS_X_VERSION_10_5 -#define MAC_OS_X_VERSION_10_5 1050 -#endif -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 AudioDeviceIOProcID audio_proc_id; -# endif AudioStreamBasicDescription format; short *data; int remaining; @@ -225,13 +220,8 @@ BlockSound::BlockSound() { if (format.mFormatID != kAudioFormatLinearPCM) return; // Attach the callback and start the device -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 if (AudioDeviceCreateIOProcID(device, audio_cb, (void *)this, &audio_proc_id) != noErr) return; AudioDeviceStart(device, audio_proc_id); -# else - if (AudioDeviceAddIOProc(device, audio_cb, (void *)this) != noErr) return; - AudioDeviceStart(device, audio_cb); -# endif sample_size = (int)format.mSampleRate; @@ -323,13 +313,8 @@ BlockSound::BlockSound() { BlockSound::~BlockSound() { #ifdef __APPLE__ if (sample_size) { -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 AudioDeviceStop(device, audio_proc_id); AudioDeviceDestroyIOProcID(device, audio_proc_id); -# else - AudioDeviceStop(device, audio_cb); - AudioDeviceRemoveIOProc(device, audio_cb); -# endif } #elif defined(_WIN32) diff --git a/test/sudoku.cxx b/test/sudoku.cxx index c0d6bfd43..f6e78c170 100644 --- a/test/sudoku.cxx +++ b/test/sudoku.cxx @@ -2,7 +2,7 @@ // Sudoku game using the Fast Light Tool Kit (FLTK). // // Copyright 2005-2018 by Michael Sweet. -// Copyright 2019-2021 by Bill Spitzak and others. +// Copyright 2019-2026 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 @@ -90,9 +90,7 @@ class SudokuSound { // Private, OS-specific data... #ifdef __APPLE__ AudioDeviceID device; -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 AudioDeviceIOProcID audio_proc_id; -# endif AudioStreamBasicDescription format; short *data; int remaining; @@ -263,13 +261,8 @@ SudokuSound::SudokuSound() { if (format.mFormatID != kAudioFormatLinearPCM) return; // Attach the callback and start the device -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 if (AudioDeviceCreateIOProcID(device, audio_cb, (void *)this, &audio_proc_id) != noErr) return; AudioDeviceStart(device, audio_proc_id); -# else - if (AudioDeviceAddIOProc(device, audio_cb, (void *)this) != noErr) return; - AudioDeviceStart(device, audio_cb); -# endif sample_size = (int)format.mSampleRate / 20; @@ -369,13 +362,8 @@ SudokuSound::SudokuSound() { SudokuSound::~SudokuSound() { #ifdef __APPLE__ if (sample_size) { -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 AudioDeviceStop(device, audio_proc_id); AudioDeviceDestroyIOProcID(device, audio_proc_id); -# else - AudioDeviceStop(device, audio_cb); - AudioDeviceRemoveIOProc(device, audio_cb); -# endif } #elif defined(_WIN32)