Browse Source

Mac OS: modified the definition of the fl_mac_os_version global variable to allow v 10.10.10

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8504 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
pull/49/head
Manolo Gouy 14 years ago
parent
commit
1d038565c1
  1. 2
      src/Fl.cxx
  2. 10
      src/Fl_Device.cxx
  3. 6
      src/Fl_cocoa.mm
  4. 10
      src/fl_font_mac.cxx
  5. 2
      src/fl_set_fonts_mac.cxx

2
src/Fl.cxx

@ -1140,7 +1140,7 @@ int Fl::handle_(int e, Fl_Window* window)
{ int ret; { int ret;
Fl_Widget* pbm = belowmouse(); Fl_Widget* pbm = belowmouse();
#ifdef __APPLE__ #ifdef __APPLE__
if (fl_mac_os_version < 0x1050) { if (fl_mac_os_version < 100500) {
// before 10.5, mouse moved events aren't sent to borderless windows such as tooltips // before 10.5, mouse moved events aren't sent to borderless windows such as tooltips
Fl_Window *tooltip = Fl_Tooltip::current_window(); Fl_Window *tooltip = Fl_Tooltip::current_window();
int inside = 0; int inside = 0;

10
src/Fl_Device.cxx

@ -74,9 +74,13 @@ void Fl_Graphics_Driver::text_extents(const char*t, int n, int& dx, int& dy, int
Fl_Display_Device::Fl_Display_Device(Fl_Graphics_Driver *graphics_driver) : Fl_Surface_Device( graphics_driver) { Fl_Display_Device::Fl_Display_Device(Fl_Graphics_Driver *graphics_driver) : Fl_Surface_Device( graphics_driver) {
#ifdef __APPLE__ #ifdef __APPLE__
SInt32 version; SInt32 versionMajor = 0;
Gestalt(gestaltSystemVersion, &version); SInt32 versionMinor = 0;
fl_mac_os_version = (int)version; SInt32 versionBugFix = 0;
Gestalt( gestaltSystemVersionMajor, &versionMajor );
Gestalt( gestaltSystemVersionMinor, &versionMinor );
Gestalt( gestaltSystemVersionBugFix, &versionBugFix );
fl_mac_os_version = versionMajor * 10000 + versionMinor * 100 + versionBugFix;
#endif #endif
}; };

6
src/Fl_cocoa.mm

@ -113,7 +113,7 @@ bool fl_show_iconic; // true if called from iconize() - shows
//int fl_disable_transient_for; // secret method of removing TRANSIENT_FOR //int fl_disable_transient_for; // secret method of removing TRANSIENT_FOR
Window fl_window; Window fl_window;
Fl_Window *Fl_Window::current_; Fl_Window *Fl_Window::current_;
int fl_mac_os_version = 0; // the version number of the running Mac OS X (e.g., 0x1064 for 10.6.4) int fl_mac_os_version = 0; // the version number of the running Mac OS X (e.g., 100604 for 10.6.4)
// forward declarations of variables in this file // forward declarations of variables in this file
static int got_events = 0; static int got_events = 0;
@ -2868,7 +2868,7 @@ static void createAppleMenu(void)
[menuItem setSubmenu:appleMenu]; [menuItem setSubmenu:appleMenu];
mainmenu = [[NSMenu alloc] initWithTitle:@""]; mainmenu = [[NSMenu alloc] initWithTitle:@""];
[mainmenu addItem:menuItem]; [mainmenu addItem:menuItem];
if (fl_mac_os_version < 0x1060) { if (fl_mac_os_version < 100600) {
// [NSApp setAppleMenu:appleMenu]; // [NSApp setAppleMenu:appleMenu];
// to avoid compiler warning raised by use of undocumented setAppleMenu : // to avoid compiler warning raised by use of undocumented setAppleMenu :
[NSApp performSelector:@selector(setAppleMenu:) withObject:appleMenu]; [NSApp performSelector:@selector(setAppleMenu:) withObject:appleMenu];
@ -3228,7 +3228,7 @@ unsigned char *Fl_X::bitmap_from_window_rect(Fl_Window *win, int x, int y, int w
win = win->window(); win = win->window();
} }
CGFloat epsilon = 0; CGFloat epsilon = 0;
if (fl_mac_os_version >= 0x1060) epsilon = 0.001; if (fl_mac_os_version >= 100600) epsilon = 0.001;
// The epsilon offset is absolutely necessary under 10.6. Without it, the top pixel row and // The epsilon offset is absolutely necessary under 10.6. Without it, the top pixel row and
// left pixel column are not read, and bitmap is read shifted by one pixel in both directions. // left pixel column are not read, and bitmap is read shifted by one pixel in both directions.
// Under 10.5, we want no offset. // Under 10.5, we want no offset.

10
src/fl_font_mac.cxx

@ -46,7 +46,7 @@ Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize Size) {
q_name = strdup(name); q_name = strdup(name);
size = Size; size = Size;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
if (fl_mac_os_version >= 0x1050) {//unfortunately, CTFontCreateWithName != NULL on 10.4 also! if (fl_mac_os_version >= 100500) {//unfortunately, CTFontCreateWithName != NULL on 10.4 also!
CFStringRef str = CFStringCreateWithCString(NULL, name, kCFStringEncodingUTF8); CFStringRef str = CFStringCreateWithCString(NULL, name, kCFStringEncodingUTF8);
fontref = CTFontCreateWithName(str, size, NULL); fontref = CTFontCreateWithName(str, size, NULL);
CGGlyph glyph[2]; CGGlyph glyph[2];
@ -174,7 +174,7 @@ Fl_Font_Descriptor::~Fl_Font_Descriptor() {
*/ */
if (this == fl_graphics_driver->font_descriptor()) fl_graphics_driver->font_descriptor(NULL); 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 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
if (fl_mac_os_version >= 0x1050) { if (fl_mac_os_version >= 100500) {
CFRelease(fontref); CFRelease(fontref);
for (unsigned i = 0; i < sizeof(width)/sizeof(float*); i++) { for (unsigned i = 0; i < sizeof(width)/sizeof(float*); i++) {
if (width[i]) free(width[i]); if (width[i]) free(width[i]);
@ -278,7 +278,7 @@ static CGFloat surrogate_width(const UniChar *txt, Fl_Font_Descriptor *fl_fontsi
static double fl_mac_width(const UniChar* txt, int n, Fl_Font_Descriptor *fl_fontsize) { static double fl_mac_width(const UniChar* txt, int n, Fl_Font_Descriptor *fl_fontsize) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
if (fl_mac_os_version >= 0x1050) { if (fl_mac_os_version >= 100500) {
double retval = 0; double retval = 0;
UniChar uni; UniChar uni;
int i; int i;
@ -373,7 +373,7 @@ void Fl_Quartz_Graphics_Driver::text_extents(const char *str8, int n, int &dx, i
if (!font_descriptor()) font(FL_HELVETICA, FL_NORMAL_SIZE); if (!font_descriptor()) font(FL_HELVETICA, FL_NORMAL_SIZE);
Fl_Font_Descriptor *fl_fontsize = font_descriptor(); Fl_Font_Descriptor *fl_fontsize = font_descriptor();
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
if (fl_mac_os_version >= 0x1050) { if (fl_mac_os_version >= 100500) {
CFStringRef str16 = CFStringCreateWithBytes(NULL, (const UInt8*)str8, n, kCFStringEncodingUTF8, false); CFStringRef str16 = CFStringCreateWithBytes(NULL, (const UInt8*)str8, n, kCFStringEncodingUTF8, false);
CFDictionarySetValue (attributes, kCTFontAttributeName, fl_fontsize->fontref); CFDictionarySetValue (attributes, kCTFontAttributeName, fl_fontsize->fontref);
CFAttributedStringRef mastr = CFAttributedStringCreate(kCFAllocatorDefault, str16, attributes); CFAttributedStringRef mastr = CFAttributedStringCreate(kCFAllocatorDefault, str16, attributes);
@ -442,7 +442,7 @@ static void fl_mac_draw(const char *str, int n, float x, float y, Fl_Graphics_Dr
// convert to UTF-16 first // convert to UTF-16 first
UniChar *uniStr = mac_Utf8_to_Utf16(str, n, &n); UniChar *uniStr = mac_Utf8_to_Utf16(str, n, &n);
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
if (fl_mac_os_version >= 0x1050) { if (fl_mac_os_version >= 100500) {
CFStringRef str16 = CFStringCreateWithCharactersNoCopy(NULL, uniStr, n, kCFAllocatorNull); CFStringRef str16 = CFStringCreateWithCharactersNoCopy(NULL, uniStr, n, kCFAllocatorNull);
if (str16 == NULL) return; // shd not happen if (str16 == NULL) return; // shd not happen
CGColorRef color = flcolortocgcolor(driver->color()); CGColorRef color = flcolortocgcolor(driver->color());

2
src/fl_set_fonts_mac.cxx

@ -70,7 +70,7 @@ Fl_Font Fl::set_fonts(const char* xstarname) {
if (fl_free_font > FL_FREE_FONT) return (Fl_Font)fl_free_font; // if already called if (fl_free_font > FL_FREE_FONT) return (Fl_Font)fl_free_font; // if already called
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
if(fl_mac_os_version >= 0x1050) { if(fl_mac_os_version >= 100500) {
//if(CTFontCreateWithFontDescriptor != NULL) {// CTFontCreateWithFontDescriptor != NULL on 10.4 also! //if(CTFontCreateWithFontDescriptor != NULL) {// CTFontCreateWithFontDescriptor != NULL on 10.4 also!
int value[1] = {1}; int value[1] = {1};
CFDictionaryRef dict = CFDictionaryCreate(NULL, CFDictionaryRef dict = CFDictionaryCreate(NULL,

Loading…
Cancel
Save