mirror of
https://github.com/fltk/fltk.git
synced 2026-05-31 05:35:29 +08:00
macOS: remove a bunch of deprecation warnings
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
/** \file Fl_Graphics_Driver.cxx
|
/** \file Fl_Graphics_Driver.cxx
|
||||||
\brief Implementation of class Fl_Graphics_Driver.
|
\brief Implementation of class Fl_Graphics_Driver.
|
||||||
*/
|
*/
|
||||||
|
#include <config.h> // for HAVE_GL
|
||||||
#include <FL/Fl_Graphics_Driver.H>
|
#include <FL/Fl_Graphics_Driver.H>
|
||||||
/** Points to the driver that currently receives all graphics requests */
|
/** Points to the driver that currently receives all graphics requests */
|
||||||
FL_EXPORT Fl_Graphics_Driver *fl_graphics_driver;
|
FL_EXPORT Fl_Graphics_Driver *fl_graphics_driver;
|
||||||
|
|||||||
@@ -43,6 +43,17 @@ static void move_tab_cb(Fl_Widget *, void *data);
|
|||||||
static void merge_all_windows_cb(Fl_Widget *, void *data);
|
static void merge_all_windows_cb(Fl_Widget *, void *data);
|
||||||
#endif
|
#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() {
|
void Fl_MacOS_Sys_Menu_Bar_Driver::draw() {
|
||||||
bar->deactivate(); // prevent Fl_Sys_Menu_Bar object from receiving events
|
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);
|
menu->picked(item);
|
||||||
Fl::flush();
|
Fl::flush();
|
||||||
if ( item->flags & FL_MENU_TOGGLE ) { // update the menu toggle symbol
|
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
|
else if ( item->flags & FL_MENU_RADIO ) { // update the menu radio symbols
|
||||||
NSMenu* this_menu = [self menu];
|
NSMenu* this_menu = [self menu];
|
||||||
@@ -136,7 +147,7 @@ const char *Fl_Mac_App_Menu::quit = "Quit %@";
|
|||||||
}
|
}
|
||||||
for(int i = from; i <= to; i++) {
|
for(int i = from; i <= to; i++) {
|
||||||
NSMenuItem *nsitem = [this_menu itemAtIndex: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
|
- (void) setKeyEquivalentModifierMask:(int)value
|
||||||
{
|
{
|
||||||
NSUInteger macMod = 0;
|
NSUInteger macMod = 0;
|
||||||
if ( value & FL_META ) macMod = NSCommandKeyMask;
|
if ( value & FL_META ) macMod = NSEventModifierFlagCommand;
|
||||||
if ( value & FL_SHIFT || isupper(value) ) macMod |= NSShiftKeyMask;
|
if ( value & FL_SHIFT || isupper(value) ) macMod |= NSEventModifierFlagShift;
|
||||||
if ( value & FL_ALT ) macMod |= NSAlternateKeyMask;
|
if ( value & FL_ALT ) macMod |= NSEventModifierFlagOption;
|
||||||
if ( value & FL_CTRL ) macMod |= NSControlKeyMask;
|
if ( value & FL_CTRL ) macMod |= NSEventModifierFlagControl;
|
||||||
[super setKeyEquivalentModifierMask:macMod];
|
[super setKeyEquivalentModifierMask:macMod];
|
||||||
}
|
}
|
||||||
- (void) setFltkShortcut:(int)key
|
- (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 )
|
if ( m->flags & FL_MENU_TOGGLE )
|
||||||
{
|
{
|
||||||
NSMenuItem *menuItem = [mh itemAtIndex:miCnt];
|
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 ) {
|
else if ( m->flags & FL_MENU_RADIO ) {
|
||||||
NSMenuItem *menuItem = [mh itemAtIndex:miCnt];
|
NSMenuItem *menuItem = [mh itemAtIndex:miCnt];
|
||||||
[menuItem setState:(m->flags & FL_MENU_VALUE ? NSOnState : NSOffState)];
|
[menuItem setState:(m->flags & FL_MENU_VALUE ? NSControlStateValueOn : NSControlStateValueOff)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,14 @@
|
|||||||
#define MAXFILTERS 80
|
#define MAXFILTERS 80
|
||||||
#import <Cocoa/Cocoa.h>
|
#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 {
|
class Fl_Quartz_Native_File_Chooser_Driver : public Fl_Native_File_Chooser_Driver {
|
||||||
private:
|
private:
|
||||||
int _btype; // kind-of browser to show()
|
int _btype; // kind-of browser to show()
|
||||||
@@ -562,7 +570,11 @@ static char *prepareMacFilter(int count, const char *filter, char **patterns) {
|
|||||||
@end
|
@end
|
||||||
@implementation FLHiddenFilesAction
|
@implementation FLHiddenFilesAction
|
||||||
- (void)action {
|
- (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
|
@end
|
||||||
|
|
||||||
@@ -603,7 +615,7 @@ static NSPopUpButton *createPopupAccessory(NSSavePanel *panel, const char *filte
|
|||||||
NSString *nstitle = [[NSString alloc] initWithUTF8String:title];
|
NSString *nstitle = [[NSString alloc] initWithUTF8String:title];
|
||||||
[box setTitle:nstitle];
|
[box setTitle:nstitle];
|
||||||
[nstitle release];
|
[nstitle release];
|
||||||
NSFont *font = [NSFont controlContentFontOfSize:NSRegularControlSize];
|
NSFont *font = [NSFont controlContentFontOfSize:NSControlSizeRegular];
|
||||||
[box setTitleFont:font];
|
[box setTitleFont:font];
|
||||||
[box sizeToFit];
|
[box sizeToFit];
|
||||||
// horizontally move box to fit the locale-dependent width of its title
|
// 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
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{ // the deprecation warning can be ignored because runs only for macOS < 10.6
|
||||||
retval = [(id)_panel runModalForDirectory:dir file:fname];
|
retval = [_panel runModalForDirectory:dir file:fname];
|
||||||
}
|
}
|
||||||
[dir release];
|
[dir release];
|
||||||
[preset release];
|
[preset release];
|
||||||
return (retval == NSFileHandlingPanelOKButton ? 1 : 0);
|
return (retval == NSModalResponseOK ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST BROWSER
|
// POST BROWSER
|
||||||
|
|||||||
+239
-115
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) {
|
if (m & FL_STEREO) {
|
||||||
//list[n++] = AGL_STEREO;
|
//list[n++] = AGL_STEREO;
|
||||||
attribs[n++] = NSOpenGLPFAStereo;
|
attribs[n++] = 6/*NSOpenGLPFAStereo*/;
|
||||||
}
|
}
|
||||||
if ((m & FL_MULTISAMPLE) && fl_mac_os_version >= 100400) {
|
if ((m & FL_MULTISAMPLE) && fl_mac_os_version >= 100400) {
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||||
|
|||||||
@@ -126,7 +126,10 @@ int Fl_Cocoa_Printer_Driver::begin_job (int pagecount, int *frompage, int *topag
|
|||||||
[main makeKeyAndOrderFront:nil];
|
[main makeKeyAndOrderFront:nil];
|
||||||
} else
|
} else
|
||||||
retval = [panel runModalWithPrintInfo:info]; //from 10.5
|
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
|
printSession = (PMPrintSession)[info PMPrintSession];//from 10.5
|
||||||
pageFormat = (PMPageFormat)[info PMPageFormat];//from 10.5
|
pageFormat = (PMPageFormat)[info PMPageFormat];//from 10.5
|
||||||
printSettings = (PMPrintSettings)[info PMPrintSettings];//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_utf8.h> // for fl_utf8toUtf16()
|
||||||
#include <FL/fl_string_functions.h> // fl_strdup()
|
#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;
|
Fl_Fontdesc* fl_fonts = NULL;
|
||||||
|
|
||||||
static CGAffineTransform font_mx = { 1, 0, 0, -1, 0, 0 };
|
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);
|
CTFontGetGlyphsForCharacters(d->fontref, A, glyph, 2);
|
||||||
CGSize advances[2];
|
CGSize advances[2];
|
||||||
double w;
|
double w;
|
||||||
CTFontGetAdvancesForGlyphs(d->fontref, kCTFontHorizontalOrientation, glyph, advances, 2);
|
CTFontGetAdvancesForGlyphs(d->fontref, kCTFontOrientationHorizontal, glyph, advances, 2);
|
||||||
w = advances[0].width;
|
w = advances[0].width;
|
||||||
if ( fabs(advances[0].width - advances[1].width) < 1E-2 ) {//this is a fixed-width font
|
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
|
// slightly rescale fixed-width fonts so the character width has an integral value
|
||||||
CFRelease(d->fontref);
|
CFRelease(d->fontref);
|
||||||
CGFloat fsize = size / ( w/floor(w + 0.5) );
|
CGFloat fsize = size / ( w/floor(w + 0.5) );
|
||||||
d->fontref = CTFontCreateWithName(str, fsize, NULL);
|
d->fontref = CTFontCreateWithName(str, fsize, NULL);
|
||||||
w = CTFontGetAdvancesForGlyphs(d->fontref, kCTFontHorizontalOrientation, glyph, NULL, 1);
|
w = CTFontGetAdvancesForGlyphs(d->fontref, kCTFontOrientationHorizontal, glyph, NULL, 1);
|
||||||
}
|
}
|
||||||
CFRelease(str);
|
CFRelease(str);
|
||||||
d->ascent = (short)(CTFontGetAscent(d->fontref) + 0.5);
|
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);
|
CFRelease(str);
|
||||||
b = CTFontGetGlyphsForCharacters(font2, txt, glyphs, 2);
|
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;
|
else a.width = fl_fontsize->q_width;
|
||||||
if(must_release) CFRelease(font2);
|
if(must_release) CFRelease(font2);
|
||||||
return a.width;
|
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
|
// ii spans all characters of this block
|
||||||
bool b = CTFontGetGlyphsForCharacters(fl_fontsize->fontref, &ii, &glyph, 1);
|
bool b = CTFontGetGlyphsForCharacters(fl_fontsize->fontref, &ii, &glyph, 1);
|
||||||
if (b)
|
if (b)
|
||||||
CTFontGetAdvancesForGlyphs(fl_fontsize->fontref, kCTFontHorizontalOrientation, &glyph, &advance_size, 1);
|
CTFontGetAdvancesForGlyphs(fl_fontsize->fontref, kCTFontOrientationHorizontal, &glyph, &advance_size, 1);
|
||||||
else
|
else
|
||||||
advance_size.width = -1e9; // calculate this later
|
advance_size.width = -1e9; // calculate this later
|
||||||
// the width of one character of this block of characters
|
// 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);
|
CFRelease(str);
|
||||||
b = CTFontGetGlyphsForCharacters(font2, &uni, &glyph, 1);
|
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.;
|
else advance_size.width = 0.;
|
||||||
// the width of the 'uni' character
|
// the width of the 'uni' character
|
||||||
wdt = fl_fontsize->width[r][uni & (block-1)] = advance_size.width;
|
wdt = fl_fontsize->width[r][uni & (block-1)] = advance_size.width;
|
||||||
|
|||||||
Reference in New Issue
Block a user