macOS: remove a bunch of deprecation warnings

This commit is contained in:
ManoloFLTK
2023-10-09 11:16:36 +02:00
parent d1436f4f63
commit bb7e1635ad
7 changed files with 290 additions and 136 deletions
+1 -1
View File
@@ -17,7 +17,7 @@
/** \file Fl_Graphics_Driver.cxx
\brief Implementation of class Fl_Graphics_Driver.
*/
#include <config.h> // for HAVE_GL
#include <FL/Fl_Graphics_Driver.H>
/** Points to the driver that currently receives all graphics requests */
FL_EXPORT Fl_Graphics_Driver *fl_graphics_driver;
+19 -8
View File
@@ -43,6 +43,17 @@ static void move_tab_cb(Fl_Widget *, void *data);
static void merge_all_windows_cb(Fl_Widget *, void *data);
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13
const NSInteger NSControlStateValueOn = NSOnState;
const NSInteger NSControlStateValueOff = NSOffState;
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
const NSUInteger NSEventModifierFlagCommand = NSCommandKeyMask;
const NSUInteger NSEventModifierFlagOption = NSAlternateKeyMask;
const NSUInteger NSEventModifierFlagControl = NSControlKeyMask;
const NSUInteger NSEventModifierFlagShift = NSShiftKeyMask;
#endif
void Fl_MacOS_Sys_Menu_Bar_Driver::draw() {
bar->deactivate(); // prevent Fl_Sys_Menu_Bar object from receiving events
@@ -114,7 +125,7 @@ const char *Fl_Mac_App_Menu::quit = "Quit %@";
menu->picked(item);
Fl::flush();
if ( item->flags & FL_MENU_TOGGLE ) { // update the menu toggle symbol
[self setState:(item->value() ? NSOnState : NSOffState)];
[self setState:(item->value() ? NSControlStateValueOn : NSControlStateValueOff)];
}
else if ( item->flags & FL_MENU_RADIO ) { // update the menu radio symbols
NSMenu* this_menu = [self menu];
@@ -136,7 +147,7 @@ const char *Fl_Mac_App_Menu::quit = "Quit %@";
}
for(int i = from; i <= to; i++) {
NSMenuItem *nsitem = [this_menu itemAtIndex:i];
[nsitem setState:(nsitem != self ? NSOffState : NSOnState)];
[nsitem setState:(nsitem != self ? NSControlStateValueOff : NSControlStateValueOn)];
}
}
}
@@ -162,10 +173,10 @@ const char *Fl_Mac_App_Menu::quit = "Quit %@";
- (void) setKeyEquivalentModifierMask:(int)value
{
NSUInteger macMod = 0;
if ( value & FL_META ) macMod = NSCommandKeyMask;
if ( value & FL_SHIFT || isupper(value) ) macMod |= NSShiftKeyMask;
if ( value & FL_ALT ) macMod |= NSAlternateKeyMask;
if ( value & FL_CTRL ) macMod |= NSControlKeyMask;
if ( value & FL_META ) macMod = NSEventModifierFlagCommand;
if ( value & FL_SHIFT || isupper(value) ) macMod |= NSEventModifierFlagShift;
if ( value & FL_ALT ) macMod |= NSEventModifierFlagOption;
if ( value & FL_CTRL ) macMod |= NSEventModifierFlagControl;
[super setKeyEquivalentModifierMask:macMod];
}
- (void) setFltkShortcut:(int)key
@@ -309,11 +320,11 @@ static void setMenuFlags( NSMenu* mh, int miCnt, const Fl_Menu_Item *m )
if ( m->flags & FL_MENU_TOGGLE )
{
NSMenuItem *menuItem = [mh itemAtIndex:miCnt];
[menuItem setState:(m->flags & FL_MENU_VALUE ? NSOnState : NSOffState)];
[menuItem setState:(m->flags & FL_MENU_VALUE ? NSControlStateValueOn : NSControlStateValueOff)];
}
else if ( m->flags & FL_MENU_RADIO ) {
NSMenuItem *menuItem = [mh itemAtIndex:miCnt];
[menuItem setState:(m->flags & FL_MENU_VALUE ? NSOnState : NSOffState)];
[menuItem setState:(m->flags & FL_MENU_VALUE ? NSControlStateValueOn : NSControlStateValueOff)];
}
}
+17 -5
View File
@@ -29,6 +29,14 @@
#define MAXFILTERS 80
#import <Cocoa/Cocoa.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9
const NSInteger NSModalResponseOK = NSFileHandlingPanelOKButton;
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
const NSUInteger NSControlSizeRegular = NSRegularControlSize;
#endif
class Fl_Quartz_Native_File_Chooser_Driver : public Fl_Native_File_Chooser_Driver {
private:
int _btype; // kind-of browser to show()
@@ -562,7 +570,11 @@ static char *prepareMacFilter(int count, const char *filter, char **patterns) {
@end
@implementation FLHiddenFilesAction
- (void)action {
[panel setShowsHiddenFiles:[button intValue]];
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
if (fl_mac_os_version >= 100600) {
[panel setShowsHiddenFiles:[button intValue]]; // 10.6
}
#endif
}
@end
@@ -603,7 +615,7 @@ static NSPopUpButton *createPopupAccessory(NSSavePanel *panel, const char *filte
NSString *nstitle = [[NSString alloc] initWithUTF8String:title];
[box setTitle:nstitle];
[nstitle release];
NSFont *font = [NSFont controlContentFontOfSize:NSRegularControlSize];
NSFont *font = [NSFont controlContentFontOfSize:NSControlSizeRegular];
[box setTitleFont:font];
[box sizeToFit];
// horizontally move box to fit the locale-dependent width of its title
@@ -675,12 +687,12 @@ int Fl_Quartz_Native_File_Chooser_Driver::runmodal()
}
else
#endif
{
retval = [(id)_panel runModalForDirectory:dir file:fname];
{ // the deprecation warning can be ignored because runs only for macOS < 10.6
retval = [_panel runModalForDirectory:dir file:fname];
}
[dir release];
[preset release];
return (retval == NSFileHandlingPanelOKButton ? 1 : 0);
return (retval == NSModalResponseOK ? 1 : 0);
}
// POST BROWSER
+239 -115
View File
File diff suppressed because it is too large Load Diff
@@ -106,7 +106,7 @@ static NSOpenGLPixelFormat* mode_to_NSOpenGLPixelFormat(int m, const int *alistp
}
if (m & FL_STEREO) {
//list[n++] = AGL_STEREO;
attribs[n++] = NSOpenGLPFAStereo;
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
+4 -1
View File
@@ -126,7 +126,10 @@ int Fl_Cocoa_Printer_Driver::begin_job (int pagecount, int *frompage, int *topag
[main makeKeyAndOrderFront:nil];
} else
retval = [panel runModalWithPrintInfo:info]; //from 10.5
if (retval != NSOKButton) return 1;
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9
const NSInteger NSModalResponseOK = NSOKButton;
#endif
if (retval != NSModalResponseOK) return 1;
printSession = (PMPrintSession)[info PMPrintSession];//from 10.5
pageFormat = (PMPageFormat)[info PMPageFormat];//from 10.5
printSettings = (PMPrintSettings)[info PMPrintSettings];//from 10.5
@@ -77,6 +77,10 @@
#include <FL/fl_utf8.h> // for fl_utf8toUtf16()
#include <FL/fl_string_functions.h> // fl_strdup()
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8
const NSUInteger kCTFontOrientationHorizontal = kCTFontHorizontalOrientation;
#endif
Fl_Fontdesc* fl_fonts = NULL;
static CGAffineTransform font_mx = { 1, 0, 0, -1, 0, 0 };
@@ -418,14 +422,14 @@ void Fl_Quartz_Graphics_Driver::ADD_SUFFIX(descriptor_init, _CoreText)(const cha
CTFontGetGlyphsForCharacters(d->fontref, A, glyph, 2);
CGSize advances[2];
double w;
CTFontGetAdvancesForGlyphs(d->fontref, kCTFontHorizontalOrientation, glyph, advances, 2);
CTFontGetAdvancesForGlyphs(d->fontref, kCTFontOrientationHorizontal, glyph, advances, 2);
w = advances[0].width;
if ( fabs(advances[0].width - advances[1].width) < 1E-2 ) {//this is a fixed-width font
// slightly rescale fixed-width fonts so the character width has an integral value
CFRelease(d->fontref);
CGFloat fsize = size / ( w/floor(w + 0.5) );
d->fontref = CTFontCreateWithName(str, fsize, NULL);
w = CTFontGetAdvancesForGlyphs(d->fontref, kCTFontHorizontalOrientation, glyph, NULL, 1);
w = CTFontGetAdvancesForGlyphs(d->fontref, kCTFontOrientationHorizontal, glyph, NULL, 1);
}
CFRelease(str);
d->ascent = (short)(CTFontGetAscent(d->fontref) + 0.5);
@@ -473,7 +477,7 @@ static CGFloat surrogate_width(const UniChar *txt, Fl_Quartz_Font_Descriptor *fl
CFRelease(str);
b = CTFontGetGlyphsForCharacters(font2, txt, glyphs, 2);
}
if (b) CTFontGetAdvancesForGlyphs(font2, kCTFontHorizontalOrientation, glyphs, &a, 1);
if (b) CTFontGetAdvancesForGlyphs(font2, kCTFontOrientationHorizontal, glyphs, &a, 1);
else a.width = fl_fontsize->q_width;
if(must_release) CFRelease(font2);
return a.width;
@@ -525,7 +529,7 @@ double Fl_Quartz_Graphics_Driver::ADD_SUFFIX(width, _CoreText)(const UniChar* tx
// ii spans all characters of this block
bool b = CTFontGetGlyphsForCharacters(fl_fontsize->fontref, &ii, &glyph, 1);
if (b)
CTFontGetAdvancesForGlyphs(fl_fontsize->fontref, kCTFontHorizontalOrientation, &glyph, &advance_size, 1);
CTFontGetAdvancesForGlyphs(fl_fontsize->fontref, kCTFontOrientationHorizontal, &glyph, &advance_size, 1);
else
advance_size.width = -1e9; // calculate this later
// the width of one character of this block of characters
@@ -549,7 +553,7 @@ double Fl_Quartz_Graphics_Driver::ADD_SUFFIX(width, _CoreText)(const UniChar* tx
CFRelease(str);
b = CTFontGetGlyphsForCharacters(font2, &uni, &glyph, 1);
}
if (b) CTFontGetAdvancesForGlyphs(font2, kCTFontHorizontalOrientation, &glyph, &advance_size, 1);
if (b) CTFontGetAdvancesForGlyphs(font2, kCTFontOrientationHorizontal, &glyph, &advance_size, 1);
else advance_size.width = 0.;
// the width of the 'uni' character
wdt = fl_fontsize->width[r][uni & (block-1)] = advance_size.width;