ns_fd_data.panel = nil;
}
+#ifdef NS_IMPL_COCOA
+#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_9
+#define MODAL_OK_RESPONSE NSModalResponseOK
+#endif
+#endif
+#ifndef MODAL_OK_RESPONSE
+#define MODAL_OK_RESPONSE NSOKButton
+#endif
+
DEFUN ("ns-read-file-name", Fns_read_file_name, Sns_read_file_name, 1, 5, 0,
doc: /* Use a graphical panel to read a file name, using prompt PROMPT.
Optional arg DIR, if non-nil, supplies a default directory.
while (ns_fd_data.panel != nil)
[NSApp run];
- ret = (ns_fd_data.ret == NSOKButton);
+ ret = (ns_fd_data.ret == MODAL_OK_RESPONSE);
if (ret)
{
pt.y = dpyinfo->last_mouse_motion_y;
/* Convert to screen coordinates */
pt = [view convertPoint: pt toView: nil];
+#if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
pt = [[view window] convertBaseToScreen: pt];
+#else
+ {
+ NSRect r = NSMakeRect (pt.x, pt.y, 0, 0);
+ r = [[view window] convertRectToScreen: r];
+ pt.x = r.origin.x;
+ pt.y = r.origin.y;
+ }
+#endif
}
else
{
return;
}
+static void
+ns_copy_bits (struct frame *f, NSRect src, NSRect dest)
+{
+ if (FRAME_NS_VIEW (f))
+ {
+ ns_focus (f, &dest, 1);
+ [FRAME_NS_VIEW (f) scrollRect: src
+ by: NSMakeSize (dest.origin.x - src.origin.x,
+ dest.origin.y - src.origin.y)];
+ ns_unfocus (f);
+ }
+}
static void
ns_scroll_run (struct window *w, struct run *run)
{
NSRect srcRect = NSMakeRect (x, from_y, width, height);
NSRect dstRect = NSMakeRect (x, to_y, width, height);
- NSPoint dstOrigin = NSMakePoint (x, to_y);
- ns_focus (f, &dstRect, 1);
- NSCopyBits (0, srcRect , dstOrigin);
- ns_unfocus (f);
+ ns_copy_bits (f, srcRect , dstRect);
}
unblock_input ();
{
NSRect srcRect = NSMakeRect (x, y, width, height);
NSRect dstRect = NSMakeRect (x+shift_by, y, width, height);
- NSPoint dstOrigin = dstRect.origin;
NSTRACE (ns_shift_glyphs_for_insert);
- ns_focus (f, &dstRect, 1);
- NSCopyBits (0, srcRect, dstOrigin);
- ns_unfocus (f);
+ ns_copy_bits (f, srcRect, dstRect);
}
EV_TRAILER ((id)nil);
}
+static bool
+runAlertPanel(NSString *title,
+ NSString *msgFormat,
+ NSString *defaultButton,
+ NSString *alternateButton)
+{
+#if !defined (NS_IMPL_COCOA) || \
+ MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9
+ return NSRunAlertPanel(title, msgFormat, defaultButton, alternateButton, nil)
+ == NSAlertDefaultReturn;
+#else
+ NSAlert *alert = [[NSAlert alloc] init];
+ [alert setAlertStyle: NSCriticalAlertStyle];
+ [alert setMessageText: msgFormat];
+ [alert addButtonWithTitle: defaultButton];
+ [alert addButtonWithTitle: alternateButton];
+ NSInteger ret = [alert runModal];
+ [alert release];
+ return ret == NSAlertFirstButtonReturn;
+#endif
+}
+
- (NSApplicationTerminateReply)applicationShouldTerminate: (id)sender
{
- int ret;
+ bool ret;
if (NILP (ns_confirm_quit)) // || ns_shutdown_properly --> TO DO
return NSTerminateNow;
- ret = NSRunAlertPanel(ns_app_name,
- @"Exit requested. Would you like to Save Buffers and Exit, or Cancel the request?",
- @"Save Buffers and Exit", @"Cancel", nil);
+ ret = runAlertPanel(ns_app_name,
+ @"Exit requested. Would you like to Save Buffers and Exit, or Cancel the request?",
+ @"Save Buffers and Exit", @"Cancel");
- if (ret == NSAlertDefaultReturn)
+ if (ret)
return NSTerminateNow;
- else if (ret == NSAlertAlternateReturn)
+ else
return NSTerminateCancel;
return NSTerminateNow; /* just in case */
}
[win setAcceptsMouseMovedEvents: YES];
[win setDelegate: self];
+#if !defined (NS_IMPL_COCOA) || \
+ MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9
[win useOptimizedDrawing: YES];
-
+#endif
sz.width = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f);
sz.height = frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (f);
[win setResizeIncrements: sz];
if ([col alphaComponent] != (EmacsCGFloat) 1.0)
[win setOpaque: NO];
+#if !defined (NS_IMPL_COCOA) || \
+ MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9
[self allocateGState];
-
+#endif
[NSApp registerServicesMenuSendTypes: ns_send_types
returnTypes: nil];
}
else if (next_maximized == FULLSCREEN_HEIGHT
|| (next_maximized == -1
- && abs (defaultFrame.size.height - result.size.height)
+ && abs ((int)(defaultFrame.size.height - result.size.height))
> FRAME_LINE_HEIGHT (emacsframe)))
{
/* first click */
}
else if (next_maximized == FULLSCREEN_MAXIMIZED
|| (next_maximized == -1
- && abs (defaultFrame.size.width - result.size.width)
+ && abs ((int)(defaultFrame.size.width - result.size.width))
> FRAME_COLUMN_WIDTH (emacsframe)))
{
result = defaultFrame; /* second click */
[fw setTitle:[w title]];
[fw setDelegate:self];
[fw setAcceptsMouseMovedEvents: YES];
+#if !defined (NS_IMPL_COCOA) || \
+ MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9
[fw useOptimizedDrawing: YES];
+#endif
[fw setResizeIncrements: sz];
[fw setBackgroundColor: col];
if ([col alphaComponent] != (EmacsCGFloat) 1.0)
/* NSDraggingDestination protocol methods. Actually this is not really a
protocol, but a category of Object. O well... */
--(NSUInteger) draggingEntered: (id <NSDraggingInfo>) sender
+-(NSDragOperation) draggingEntered: (id <NSDraggingInfo>) sender
{
NSTRACE (draggingEntered);
return NSDragOperationGeneric;
{
/* TODO: if we want to allow variable widths, this is the place to do it,
however neither GNUstep nor Cocoa support it very well */
- return [NSScroller scrollerWidth];
+ CGFloat r;
+#if !defined (NS_IMPL_COCOA) || \
+ MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
+ r = [NSScroller scrollerWidth];
+#else
+ r = [NSScroller scrollerWidthForControlSize: NSRegularControlSize
+ scrollerStyle: NSScrollerStyleLegacy];
+#endif
+ return r;
}