summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/mac.H5
-rw-r--r--documentation/src/osissues.dox6
-rw-r--r--src/Fl_cocoa.mm20
-rw-r--r--src/fl_dnd_mac.cxx4
-rw-r--r--src/fl_font_mac.cxx16
-rw-r--r--src/fl_set_fonts_mac.cxx7
6 files changed, 27 insertions, 31 deletions
diff --git a/FL/mac.H b/FL/mac.H
index 9c26e6dd7..8309827bb 100644
--- a/FL/mac.H
+++ b/FL/mac.H
@@ -185,6 +185,11 @@ extern void fl_open_callback(void (*cb)(const char *));
* \param shortcut optional shortcut to attach to the "About myprog" menu item (e.g., FL_META+'a')
*/
extern void fl_mac_set_about( Fl_Callback *cb, void *user_data, int shortcut = 0);
+
+/** The version number of the running Mac OS X (e.g., 0x1064 for 10.6.4)
+ */
+extern int fl_mac_os_version;
+
/** @} */
//
diff --git a/documentation/src/osissues.dox b/documentation/src/osissues.dox
index 655e1b4cc..ed87a1163 100644
--- a/documentation/src/osissues.dox
+++ b/documentation/src/osissues.dox
@@ -687,7 +687,7 @@ Returns the Fl_Window that corresponds to the given window reference,
or \c NULL if not found. FLTK windows that are children of top-level
windows share the \c Window of the top-level window.
-void fl_open_callback(void (*cb)(const char *))
+void \ref fl_open_callback(void (*cb)(const char *))
\par
\c cb will be called with a single Unix-style file name and path.
@@ -749,7 +749,9 @@ handle the Resource Fork correctly.
\par Mac File Paths
-FLTK uses UNIX-style filenames and paths.
+FLTK uses UTF-8-encoded UNIX-style filenames and paths.
+
+\sa group_macosx
\htmlonly
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 1a2e18e0e..788bb47d1 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -130,19 +130,16 @@ void *fl_system_menu; // this is really a NSMenu*
Fl_Sys_Menu_Bar *fl_sys_menu_bar = 0;
void *fl_default_cursor; // this is really a NSCursor*
void *fl_capture = 0; // (NSWindow*) we need this to compensate for a missing(?) mouse capture
-//ulong fl_event_time; // the last timestamp from an x event
char fl_key_vector[32]; // used by Fl::get_key()
bool fl_show_iconic; // true if called from iconize() - shows the next created window in collapsed state
int fl_disable_transient_for; // secret method of removing TRANSIENT_FOR
-//const Fl_Window* fl_modal_for; // parent of modal() window
Window fl_window;
Fl_Window *Fl_Window::current_;
-//EventRef fl_os_event; // last (mouse) event
+int fl_mac_os_version = 0; // the version number of the running Mac OS X (e.g., 0x1064 for 10.6.4)
// forward declarations of variables in this file
static int got_events = 0;
static Fl_Window* resize_from_system;
-static SInt32 MACsystemVersion;
#if CONSOLIDATE_MOTION
static Fl_Window* send_motion;
@@ -1371,8 +1368,10 @@ void fl_open_display() {
while (ign_event);
fl_default_cursor = [NSCursor arrowCursor];
- Gestalt(gestaltSystemVersion, &MACsystemVersion);
-
+ SInt32 version;
+ Gestalt(gestaltSystemVersion, &version);
+ fl_mac_os_version = (int)version;
+
// bring the application into foreground without a 'CARB' resource
Boolean same_psn;
ProcessSerialNumber cur_psn, front_psn;
@@ -2757,7 +2756,7 @@ int MACscreen_init(XRectangle screens[])
{
NSDictionary *options;
options = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSString stringWithFormat:@" FLTK %d.%d Cocoa", FL_MAJOR_VERSION,
+ [NSString stringWithFormat:@" GUI with FLTK %d.%d", FL_MAJOR_VERSION,
FL_MINOR_VERSION ], @"Copyright",
nil];
[NSApp orderFrontStandardAboutPanelWithOptions:options];
@@ -2815,13 +2814,12 @@ static void createAppleMenu(void)
FLaboutItemTarget *about = [[FLaboutItemTarget alloc] init];
[menuItem setTarget:about];
[appleMenu addItem:[NSMenuItem separatorItem]];
-// temporary for testing Fl_Printer. Contains also printPanel of class FLaboutItemTarget.
+ // Print front window
menuItem = [appleMenu addItemWithTitle:@"Print front window" action:@selector(printPanel) keyEquivalent:@""];
[menuItem setTarget:about];
[appleMenu setAutoenablesItems:NO];
[menuItem setEnabled:YES];
[appleMenu addItem:[NSMenuItem separatorItem]];
-// end of temporary for testing Fl_Printer
// Services Menu
services = [[NSMenu alloc] init];
[appleMenu addItemWithTitle:@"Services" action:nil keyEquivalent:@""];
@@ -2844,7 +2842,7 @@ static void createAppleMenu(void)
[menuItem setSubmenu:appleMenu];
mainmenu = [[NSMenu alloc] initWithTitle:@""];
[mainmenu addItem:menuItem];
- if (MACsystemVersion < 0x1060) {
+ if (fl_mac_os_version < 0x1060) {
// [NSApp setAppleMenu:appleMenu];
// to avoid compiler warning raised by use of undocumented setAppleMenu :
[NSApp performSelector:@selector(setAppleMenu:) withObject:appleMenu];
@@ -3208,7 +3206,7 @@ unsigned char *MACbitmapFromRectOfWindow(Fl_Window *win, int x, int y, int w, in
win = win->window();
}
CGFloat epsilon = 0;
- if (MACsystemVersion >= 0x1060) epsilon = 0.001;
+ if (fl_mac_os_version >= 0x1060) epsilon = 0.001;
// 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.
// Under 10.5, we want no offset.
diff --git a/src/fl_dnd_mac.cxx b/src/fl_dnd_mac.cxx
index c3d28a7af..d601f5402 100644
--- a/src/fl_dnd_mac.cxx
+++ b/src/fl_dnd_mac.cxx
@@ -33,10 +33,6 @@
#include <FL/x.H>
#include <FL/Fl_Window.H>
-// warning: this function is only implemented in Quickdraw. The function
-// below may not work if FLTK is compiled with Quartz enabled
-
-extern EventRef fl_os_event;
extern char *fl_selection_buffer;
extern int fl_selection_length;
diff --git a/src/fl_font_mac.cxx b/src/fl_font_mac.cxx
index e1e4bead6..e87bad9d7 100644
--- a/src/fl_font_mac.cxx
+++ b/src/fl_font_mac.cxx
@@ -34,9 +34,6 @@ extern unsigned fl_utf8toUtf16(const char* src, unsigned srclen, unsigned short*
#define check_default_font() {if (!fl_fontsize) fl_font(0, 12);}
static const CGAffineTransform font_mx = { 1, 0, 0, -1, 0, 0 };
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-static SInt32 MACsystemVersion = 0;
-#endif
Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize Size) {
next = 0;
@@ -50,9 +47,8 @@ Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize Size) {
size = Size;
minsize = maxsize = Size;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- if(MACsystemVersion == 0) Gestalt(gestaltSystemVersion, &MACsystemVersion);
-
-if(MACsystemVersion >= 0x1050) {//unfortunately, CTFontCreateWithName != NULL on 10.4 also!
+if(fl_mac_os_version == 0) fl_open_display();
+if(fl_mac_os_version >= 0x1050) {//unfortunately, CTFontCreateWithName != NULL on 10.4 also!
CFStringRef str = CFStringCreateWithCString(NULL, name, kCFStringEncodingUTF8);
fontref = CTFontCreateWithName(str, size, NULL);
CGGlyph glyph[2];
@@ -170,7 +166,7 @@ Fl_Font_Descriptor::~Fl_Font_Descriptor() {
*/
if (this == fl_fontsize) fl_fontsize = 0;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- if(MACsystemVersion >= 0x1050) CFRelease(fontref);
+ if(fl_mac_os_version >= 0x1050) CFRelease(fontref);
#else
/* ATSUDisposeTextLayout(layout);
ATSUDisposeStyle(style); */
@@ -273,7 +269,7 @@ double fl_width(const UniChar* txt, int n) {
return 8*n; // user must select a font first!
}
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-if(MACsystemVersion >= 0x1050) {
+if(fl_mac_os_version >= 0x1050) {
CTFontRef fontref = fl_fontsize->fontref;
CFStringRef str = CFStringCreateWithBytes(NULL, (const UInt8*)txt, n * sizeof(UniChar), kCFStringEncodingUTF16, false);
CFAttributedStringRef astr = CFAttributedStringCreate(NULL, str, NULL);
@@ -342,7 +338,7 @@ void fl_text_extents(const UniChar* txt, int n, int &dx, int &dy, int &w, int &h
return;
}
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-if(MACsystemVersion >= 0x1050) {
+if(fl_mac_os_version >= 0x1050) {
CTFontRef fontref = fl_fontsize->fontref;
CFStringRef str16 = CFStringCreateWithBytes(NULL, (const UInt8*)txt, n *sizeof(UniChar), kCFStringEncodingUTF16, false);
CFAttributedStringRef astr = CFAttributedStringCreate(NULL, str16, NULL);
@@ -435,7 +431,7 @@ void fl_draw(const char *str, int n, float x, float y) {
// convert to UTF-16 first
UniChar *uniStr = mac_Utf8_to_Utf16(str, n, &n);
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- if(MACsystemVersion >= 0x1050) {
+ if(fl_mac_os_version >= 0x1050) {
CFStringRef keys[2];
CFTypeRef values[2];
CFStringRef str16 = CFStringCreateWithBytes(NULL, (const UInt8*)uniStr, n * sizeof(UniChar), kCFStringEncodingUTF16, false);
diff --git a/src/fl_set_fonts_mac.cxx b/src/fl_set_fonts_mac.cxx
index 2b86c6bb9..1099b3819 100644
--- a/src/fl_set_fonts_mac.cxx
+++ b/src/fl_set_fonts_mac.cxx
@@ -63,9 +63,8 @@ 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 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-static SInt32 MACsystemVersion = 0;
-if(MACsystemVersion == 0) Gestalt(gestaltSystemVersion, &MACsystemVersion);
-if(MACsystemVersion >= 0x1050) {
+ if(fl_mac_os_version == 0) fl_open_display();
+if(fl_mac_os_version >= 0x1050) {
//if(CTFontCreateWithFontDescriptor != NULL) {// CTFontCreateWithFontDescriptor != NULL on 10.4 also!
int value[1] = {1};
CFDictionaryRef dict = CFDictionaryCreate(NULL,
@@ -131,7 +130,7 @@ else {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
}
#endif
- return 0; // FIXME: I do not understand the shuffeling of the above ifdef's and why they are here!
+ return 0;
}
static int array[128];