/* Graphical user interface functions for Mac OS.
Copyright (C) 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007 Free Software Foundation, Inc.
+ 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This file is part of GNU Emacs.
BLOCK_INPUT;
XSetBackground (dpy, mac->normal_gc, bg);
XSetForeground (dpy, mac->reverse_gc, bg);
- XSetWindowBackground (dpy, FRAME_MAC_WINDOW (f), bg);
+ mac_set_frame_window_background (f, bg);
XSetForeground (dpy, mac->cursor_gc, bg);
UNBLOCK_INPUT;
if (nlines)
{
FRAME_EXTERNAL_TOOL_BAR (f) = 1;
- if (FRAME_MAC_P (f) && !IsWindowToolbarVisible (FRAME_MAC_WINDOW (f)))
+ if (FRAME_MAC_P (f)
+ && !mac_is_window_toolbar_visible (FRAME_MAC_WINDOW (f)))
/* Make sure next redisplay shows the tool bar. */
XWINDOW (FRAME_SELECTED_WINDOW (f))->update_mode_line = Qt;
}
CFStringRef windowTitle =
cfstring_create_with_utf8_cstring (SDATA (name));
- SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle);
+ mac_set_window_title (FRAME_MAC_WINDOW (f), windowTitle);
CFRelease (windowTitle);
#else
Str255 windowTitle;
#endif
}
-#if TARGET_API_MAC_CARBON
-static void
-mac_update_proxy_icon (f)
- struct frame *f;
-{
- OSStatus err;
- Lisp_Object file_name =
- XBUFFER (XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer)->filename;
- Window w = FRAME_MAC_WINDOW (f);
- AliasHandle alias = NULL;
-
- BLOCK_INPUT;
-
- err = GetWindowProxyAlias (w, &alias);
- if (err == errWindowDoesNotHaveProxy && !STRINGP (file_name))
- goto out;
-
- if (STRINGP (file_name))
- {
- AEDesc desc;
-#ifdef MAC_OSX
- FSRef fref, fref_proxy;
-#else
- FSSpec fss, fss_proxy;
-#endif
- Boolean changed;
- Lisp_Object encoded_file_name = ENCODE_FILE (file_name);
-
-#ifdef MAC_OSX
- err = AECoercePtr (TYPE_FILE_NAME, SDATA (encoded_file_name),
- SBYTES (encoded_file_name), typeFSRef, &desc);
-#else
- SetPortWindowPort (w);
- err = AECoercePtr (TYPE_FILE_NAME, SDATA (encoded_file_name),
- SBYTES (encoded_file_name), typeFSS, &desc);
-#endif
- if (err == noErr)
- {
-#ifdef MAC_OSX
- err = AEGetDescData (&desc, &fref, sizeof (FSRef));
-#else
- err = AEGetDescData (&desc, &fss, sizeof (FSSpec));
-#endif
- AEDisposeDesc (&desc);
- }
- if (err == noErr)
- {
- if (alias)
- {
- /* (FS)ResolveAlias never sets `changed' to true if
- `alias' is minimal. */
-#ifdef MAC_OSX
- err = FSResolveAlias (NULL, alias, &fref_proxy, &changed);
- if (err == noErr)
- err = FSCompareFSRefs (&fref, &fref_proxy);
-#else
- err = ResolveAlias (NULL, alias, &fss_proxy, &changed);
- if (err == noErr)
- err = !(fss.vRefNum == fss_proxy.vRefNum
- && fss.parID == fss_proxy.parID
- && EqualString (fss.name, fss_proxy.name,
- false, true));
-#endif
- }
- if (err != noErr || alias == NULL)
- {
- if (alias)
- DisposeHandle ((Handle) alias);
-#ifdef MAC_OSX
- err = FSNewAliasMinimal (&fref, &alias);
-#else
- err = NewAliasMinimal (&fss, &alias);
-#endif
- changed = true;
- }
- }
- if (err == noErr)
- if (changed)
- err = SetWindowProxyAlias (w, alias);
- }
-
- if (alias)
- DisposeHandle ((Handle) alias);
-
- if (err != noErr || !STRINGP (file_name))
- RemoveWindowProxy (w);
-
- out:
- UNBLOCK_INPUT;
-}
-#endif
-
void
mac_update_title_bar (f, save_match_data)
struct frame *f;
|| (!MINI_WINDOW_P (w)
&& (modified_p != !NILP (w->last_had_star))))
{
- SetWindowModified (FRAME_MAC_WINDOW (f),
- !MINI_WINDOW_P (w) && modified_p);
+ BLOCK_INPUT;
+ mac_set_window_modified (FRAME_MAC_WINDOW (f),
+ !MINI_WINDOW_P (w) && modified_p);
mac_update_proxy_icon (f);
+ UNBLOCK_INPUT;
}
#endif
}
/* Create and set up the Mac window for frame F. */
static void
-mac_window (f, window_prompting, minibuffer_only)
+mac_window (f)
struct frame *f;
- long window_prompting;
- int minibuffer_only;
{
- Rect r;
-
BLOCK_INPUT;
- SetRect (&r, f->left_pos, f->top_pos,
- f->left_pos + FRAME_PIXEL_WIDTH (f),
- f->top_pos + FRAME_PIXEL_HEIGHT (f));
-#if TARGET_API_MAC_CARBON
- CreateNewWindow (kDocumentWindowClass,
- kWindowStandardDocumentAttributes
-#ifdef MAC_OSX
- | kWindowToolbarButtonAttribute
-#endif
- , &r, &FRAME_MAC_WINDOW (f));
- if (FRAME_MAC_WINDOW (f))
- {
- SetWRefCon (FRAME_MAC_WINDOW (f), (long) f->output_data.mac);
- if (install_window_handler (FRAME_MAC_WINDOW (f)) != noErr)
- {
- DisposeWindow (FRAME_MAC_WINDOW (f));
- FRAME_MAC_WINDOW (f) = NULL;
- }
- }
-#else /* !TARGET_API_MAC_CARBON */
- FRAME_MAC_WINDOW (f)
- = NewCWindow (NULL, &r, "\p", false, zoomDocProc,
- (WindowRef) -1, 1, (long) f->output_data.mac);
-#endif /* !TARGET_API_MAC_CARBON */
- /* so that update events can find this mac_output struct */
- f->output_data.mac->mFP = f; /* point back to emacs frame */
-
-#ifndef MAC_OSX
- if (FRAME_MAC_WINDOW (f))
- {
- ControlRef root_control;
+ mac_create_frame_window (f, 0);
- if (CreateRootControl (FRAME_MAC_WINDOW (f), &root_control) != noErr)
- {
- DisposeWindow (FRAME_MAC_WINDOW (f));
- FRAME_MAC_WINDOW (f) = NULL;
- }
- }
-#endif
if (FRAME_MAC_WINDOW (f))
- XSetWindowBackground (FRAME_MAC_DISPLAY(f), FRAME_MAC_WINDOW (f),
- FRAME_BACKGROUND_PIXEL (f));
+ mac_set_frame_window_background (f, FRAME_BACKGROUND_PIXEL (f));
#if USE_MAC_TOOLBAR
/* At the moment, the size of the tool bar is not yet known. We
DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
1, 1, 0,
doc: /* Make a new window, which is called a "frame" in Emacs terms.
-Returns an Emacs frame object.
+Return an Emacs frame object.
PARAMETERS is an alist of frame parameters.
If the parameters specify that the frame should not have a minibuffer,
and do not specify a specific minibuffer window to use,
check_mac ();
+ parms = Fcopy_alist (parms);
+
/* Use this general default value to start with
until we know if this frame has a specified name. */
Vx_resource_name = Vinvocation_name;
if (EQ (display, Qunbound))
display = Qnil;
dpyinfo = check_x_display_info (display);
-#ifdef MULTI_KBOARD
kb = dpyinfo->terminal->kboard;
-#else
- kb = &the_only_kboard;
-#endif
name = mac_get_arg (parameters, Qname, "name", "Name", RES_TYPE_STRING);
if (!STRINGP (name)
/* With FRAME_MAC_DISPLAY_INFO set up, this unwind-protect is safe. */
#if GLYPH_DEBUG
- image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
+ image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount;
dpyinfo_refcount = dpyinfo->reference_count;
#endif /* GLYPH_DEBUG */
-#ifdef MULTI_KBOARD
FRAME_KBOARD (f) = kb;
-#endif
/* Specify the parent under which to make this window. */
{
tem = Fquery_fontset (font, Qnil);
if (STRINGP (tem))
- font = x_new_fontset (f, SDATA (tem));
+ font = x_new_fontset (f, tem);
else
font = x_new_font (f, SDATA (font));
}
font = x_new_font (f, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1");
/* If those didn't work, look for something which will at least work. */
if (! STRINGP (font))
- font = x_new_fontset (f, "fontset-standard");
+ font = x_new_fontset (f, build_string ("fontset-standard"));
if (! STRINGP (font))
font = x_new_font (f, "-*-monaco-*-12-*-mac-roman");
if (! STRINGP (font))
tem = mac_get_arg (parameters, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
f->no_split = minibuffer_only || EQ (tem, Qt);
- mac_window (f, window_prompting, minibuffer_only);
+ mac_window (f);
x_icon (f, parameters);
x_make_gc (f);
if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
f->param_alist = Fcons (XCAR (tem), f->param_alist);
- store_frame_param (f, Qwindow_system, Qmac);
-
UNGCPRO;
/* Make sure windows on this frame appear in calls to next-window
if (!front_p)
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
- if (FrontNonFloatingWindow () == FRAME_MAC_WINDOW (f))
+ if (mac_front_non_floating_window () == FRAME_MAC_WINDOW (f))
SetFrontProcessWithOptions (¤t_psn,
kSetFrontProcessFrontWindowOnly);
else
}
#ifdef MAC_OSX
- ActivateWindow (ActiveNonFloatingWindow (), false);
- ActivateWindow (FRAME_MAC_WINDOW (f), true);
+ mac_activate_window (mac_active_non_floating_window (), false);
+ mac_activate_window (FRAME_MAC_WINDOW (f), true);
#else
#if !TARGET_API_MAC_CARBON
/* SelectWindow (Non-Carbon) does not issue deactivate events if the
DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width,
0, 1, 0,
- doc: /* Returns the width in pixels of DISPLAY.
+ doc: /* Return the width in pixels of DISPLAY.
The optional argument DISPLAY specifies which display to ask about.
DISPLAY should be either a frame or a display name (a string).
If omitted or nil, that stands for the selected frame's display. */)
DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
Sx_display_pixel_height, 0, 1, 0,
- doc: /* Returns the height in pixels of DISPLAY.
+ doc: /* Return the height in pixels of DISPLAY.
The optional argument DISPLAY specifies which display to ask about.
DISPLAY should be either a frame or a display name (a string).
If omitted or nil, that stands for the selected frame's display. */)
DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
0, 1, 0,
- doc: /* Returns the number of bitplanes of DISPLAY.
+ doc: /* Return the number of bitplanes of DISPLAY.
The optional argument DISPLAY specifies which display to ask about.
DISPLAY should be either a frame or a display name (a string).
If omitted or nil, that stands for the selected frame's display. */)
DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells,
0, 1, 0,
- doc: /* Returns the number of color cells of DISPLAY.
+ doc: /* Return the number of color cells of DISPLAY.
The optional argument DISPLAY specifies which display to ask about.
DISPLAY should be either a frame or a display name (a string).
If omitted or nil, that stands for the selected frame's display. */)
DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
Sx_server_max_request_size,
0, 1, 0,
- doc: /* Returns the maximum request size of the server of DISPLAY.
+ doc: /* Return the maximum request size of the server of DISPLAY.
The optional argument DISPLAY specifies which display to ask about.
DISPLAY should be either a frame or a display name (a string).
If omitted or nil, that stands for the selected frame's display. */)
}
DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
- doc: /* Returns the "vendor ID" string of the Mac OS system (Apple).
+ doc: /* Return the "vendor ID" string of the Mac OS system (Apple).
The optional argument DISPLAY specifies which display to ask about.
DISPLAY should be either a frame or a display name (a string).
If omitted or nil, that stands for the selected frame's display. */)
}
DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
- doc: /* Returns the version numbers of the Mac OS system.
+ doc: /* Return the version numbers of the Mac OS system.
The value is a list of three integers: the major and minor
version numbers, and the vendor-specific release
number. See also the function `x-server-vendor'.
DEFUN ("x-display-backing-store", Fx_display_backing_store,
Sx_display_backing_store, 0, 1, 0,
- doc: /* Returns an indication of whether DISPLAY does backing store.
+ doc: /* Return an indication of whether DISPLAY does backing store.
The value may be `always', `when-mapped', or `not-useful'.
The optional argument DISPLAY specifies which display to ask about.
DISPLAY should be either a frame or a display name (a string).
DEFUN ("x-display-visual-class", Fx_display_visual_class,
Sx_display_visual_class, 0, 1, 0,
- doc: /* Returns the visual class of DISPLAY.
+ doc: /* Return the visual class of DISPLAY.
The value is one of the symbols `static-gray', `gray-scale',
`static-color', `pseudo-color', `true-color', or `direct-color'.
DEFUN ("x-display-save-under", Fx_display_save_under,
Sx_display_save_under, 0, 1, 0,
- doc: /* Returns t if DISPLAY supports the save-under feature.
+ doc: /* Return t if DISPLAY supports the save-under feature.
The optional argument DISPLAY specifies which display to ask about.
DISPLAY should be either a frame or a display name (a string).
If omitted or nil, that stands for the selected frame's display. */)
if (FRAME_LIVE_P (f) && FRAME_MAC_P (f)
&& FRAME_MAC_WINDOW (f) != tip_window)
- {
-#if USE_CG_DRAWING
- mac_prepare_for_quickdraw (f);
-#endif
- if (!f->output_data.mac->hourglass_control)
- {
- Window w = FRAME_MAC_WINDOW (f);
- Rect r;
- ControlRef c;
-
- GetWindowPortBounds (w, &r);
- r.left = r.right - HOURGLASS_WIDTH;
- r.bottom = r.top + HOURGLASS_HEIGHT;
- if (CreateChasingArrowsControl (w, &r, &c) == noErr)
- f->output_data.mac->hourglass_control = c;
- }
-
- if (f->output_data.mac->hourglass_control)
- ShowControl (f->output_data.mac->hourglass_control);
- }
+ mac_show_hourglass (f);
}
hourglass_shown_p = 1;
{
struct frame *f = XFRAME (frame);
- if (FRAME_MAC_P (f)
- /* Watch out for newly created frames. */
- && f->output_data.mac->hourglass_control)
- {
-#if USE_CG_DRAWING
- mac_prepare_for_quickdraw (f);
-#endif
- HideControl (f->output_data.mac->hourglass_control);
- }
+ if (FRAME_MAC_P (f))
+ mac_hide_hourglass (f);
}
hourglass_shown_p = 0;
parms = Fcopy_alist (parms);
-#ifdef MULTI_KBOARD
kb = dpyinfo->terminal->kboard;
-#else
- kb = &the_only_kboard;
-#endif
/* Get the name of the frame to use for resource lookup. */
name = mac_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING);
f->icon_name = Qnil;
/* FRAME_X_DISPLAY_INFO (f) = dpyinfo; */
#if GLYPH_DEBUG
- image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
+ image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount;
dpyinfo_refcount = dpyinfo->reference_count;
#endif /* GLYPH_DEBUG */
-#ifdef MULTI_KBOARD
FRAME_KBOARD (f) = kb;
-#endif
f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
f->output_data.mac->explicit_parent = 0;
{
tem = Fquery_fontset (font, Qnil);
if (STRINGP (tem))
- font = x_new_fontset (f, SDATA (tem));
+ font = x_new_fontset (f, tem);
else
font = x_new_font (f, SDATA (font));
}
font = x_new_font (f, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1");
/* If those didn't work, look for something which will at least work. */
if (! STRINGP (font))
- font = x_new_fontset (f, "fontset-standard");
+ font = x_new_fontset (f, build_string ("fontset-standard"));
if (! STRINGP (font))
font = x_new_font (f, "-*-monaco-*-12-*-mac-roman");
if (! STRINGP (font))
window_prompting = x_figure_window_size (f, parms, 0);
- {
- Rect r;
+ BLOCK_INPUT;
- BLOCK_INPUT;
- SetRect (&r, 0, 0, 1, 1);
-#if TARGET_API_MAC_CARBON
- if (CreateNewWindow (kHelpWindowClass,
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
- kWindowIgnoreClicksAttribute |
-#endif
- kWindowNoUpdatesAttribute |
- kWindowNoActivatesAttribute,
- &r, &tip_window) == noErr)
-#else
- if (tip_window = NewCWindow (NULL, &r, "\p", false, plainDBox,
- NULL, false, 0L))
-#endif
- {
- FRAME_MAC_WINDOW (f) = tip_window;
- XSetWindowBackground (FRAME_MAC_DISPLAY(f), tip_window,
- FRAME_BACKGROUND_PIXEL (f));
- SetWRefCon (tip_window, (long) f->output_data.mac);
- /* so that update events can find this mac_output struct */
- f->output_data.mac->mFP = f;
- }
- UNBLOCK_INPUT;
- }
+ mac_create_frame_window (f, 1);
+
+ if (FRAME_MAC_WINDOW (f))
+ {
+ mac_set_frame_window_background (f, FRAME_BACKGROUND_PIXEL (f));
+ tip_window = FRAME_MAC_WINDOW (f);
+ }
+
+ UNBLOCK_INPUT;
x_make_gc (f);
BLOCK_INPUT;
#if TARGET_API_MAC_CARBON
- GetGlobalMouse (&mouse_pos);
+ mac_get_global_mouse (&mouse_pos);
#else
GetMouse (&mouse_pos);
LocalToGlobal (&mouse_pos);
BLOCK_INPUT;
compute_tip_xy (f, parms, dx, dy, FRAME_PIXEL_WIDTH (f),
FRAME_PIXEL_HEIGHT (f), &root_x, &root_y);
- MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false);
+ mac_move_window (FRAME_MAC_WINDOW (f), root_x, root_y, false);
UNBLOCK_INPUT;
goto start_timer;
}
compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y);
BLOCK_INPUT;
- MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false);
- SizeWindow (FRAME_MAC_WINDOW (f), width, height, true);
- ShowWindow (FRAME_MAC_WINDOW (f));
- BringToFront (FRAME_MAC_WINDOW (f));
+ mac_move_window (FRAME_MAC_WINDOW (f), root_x, root_y, false);
+ mac_size_window (FRAME_MAC_WINDOW (f), width, height, true);
+ mac_show_window (FRAME_MAC_WINDOW (f));
+ mac_bring_window_to_front (FRAME_MAC_WINDOW (f));
UNBLOCK_INPUT;
FRAME_PIXEL_WIDTH (f) = width;
\f
-#if TARGET_API_MAC_CARBON
/***********************************************************************
File selection dialog
***********************************************************************/
-static pascal void mac_nav_event_callback P_ ((NavEventCallbackMessage,
- NavCBRecPtr, void *));
-
-/**
- There is a relatively standard way to do this using applescript to run
- a (choose file) method. However, this doesn't do "the right thing"
- by working only if the find-file occurred during a menu or toolbar
- click. So we must do the file dialog by hand, using the navigation
- manager. This also has more flexibility in determining the default
- directory and whether or not we are going to choose a file.
- **/
-
-extern Lisp_Object Qfile_name_history;
-
+#if TARGET_API_MAC_CARBON
DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,
doc: /* Read file name, prompting with PROMPT in directory DIR.
Use a file selection dialog.
(prompt, dir, default_filename, mustmatch, only_dir_p)
Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p;
{
- Lisp_Object file = Qnil;
- int count = SPECPDL_INDEX ();
- struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
- char filename[MAXPATHLEN];
- static NavEventUPP mac_nav_event_callbackUPP = NULL;
-
- check_mac ();
-
- GCPRO6 (prompt, dir, default_filename, mustmatch, file, only_dir_p);
- CHECK_STRING (prompt);
- CHECK_STRING (dir);
-
- /* Create the dialog with PROMPT as title, using DIR as initial
- directory and using "*" as pattern. */
- dir = Fexpand_file_name (dir, Qnil);
-
- {
- OSStatus status;
- NavDialogCreationOptions options;
- NavDialogRef dialogRef;
- NavTypeListHandle fileTypes = NULL;
- NavUserAction userAction;
- CFStringRef message=NULL, saveName = NULL;
-
- BLOCK_INPUT;
- /* No need for a callback function because we are modal */
- NavGetDefaultDialogCreationOptions(&options);
- options.modality = kWindowModalityAppModal;
- options.location.h = options.location.v = -1;
- options.optionFlags = kNavDefaultNavDlogOptions;
- options.optionFlags |= kNavAllFilesInPopup; /* All files allowed */
- options.optionFlags |= kNavSelectAllReadableItem;
- options.optionFlags &= ~kNavAllowMultipleFiles;
- if (!NILP(prompt))
- {
- message = cfstring_create_with_string (prompt);
- options.message = message;
- }
- /* Don't set the application, let it use default.
- options.clientName = CFSTR ("Emacs");
- */
-
- if (mac_nav_event_callbackUPP == NULL)
- mac_nav_event_callbackUPP = NewNavEventUPP (mac_nav_event_callback);
-
- if (!NILP (only_dir_p))
- status = NavCreateChooseFolderDialog(&options, mac_nav_event_callbackUPP,
- NULL, NULL, &dialogRef);
- else if (NILP (mustmatch))
- {
- /* This is a save dialog */
- options.optionFlags |= kNavDontConfirmReplacement;
- options.actionButtonLabel = CFSTR ("Ok");
- options.windowTitle = CFSTR ("Enter name");
-
- if (STRINGP (default_filename))
- {
- Lisp_Object utf8 = ENCODE_UTF_8 (default_filename);
- char *begPtr = SDATA(utf8);
- char *filePtr = begPtr + SBYTES(utf8);
- while (filePtr != begPtr && !IS_DIRECTORY_SEP(filePtr[-1]))
- filePtr--;
- saveName = cfstring_create_with_utf8_cstring (filePtr);
- options.saveFileName = saveName;
- options.optionFlags |= kNavSelectDefaultLocation;
- }
- status = NavCreatePutFileDialog(&options,
- 'TEXT', kNavGenericSignature,
- mac_nav_event_callbackUPP, NULL,
- &dialogRef);
- }
- else
- {
- /* This is an open dialog*/
- status = NavCreateChooseFileDialog(&options, fileTypes,
- mac_nav_event_callbackUPP, NULL,
- NULL, NULL, &dialogRef);
- }
-
- /* Set the default location and continue*/
- if (status == noErr)
- {
- Lisp_Object encoded_dir = ENCODE_FILE (dir);
- AEDesc defLocAed;
-
- status = AECreateDesc (TYPE_FILE_NAME, SDATA (encoded_dir),
- SBYTES (encoded_dir), &defLocAed);
- if (status == noErr)
- {
- NavCustomControl(dialogRef, kNavCtlSetLocation, (void*) &defLocAed);
- AEDisposeDesc(&defLocAed);
- }
- status = NavDialogRun(dialogRef);
- }
-
- if (saveName) CFRelease(saveName);
- if (message) CFRelease(message);
-
- if (status == noErr) {
- userAction = NavDialogGetUserAction(dialogRef);
- switch (userAction)
- {
- case kNavUserActionNone:
- case kNavUserActionCancel:
- break; /* Treat cancel like C-g */
- case kNavUserActionOpen:
- case kNavUserActionChoose:
- case kNavUserActionSaveAs:
- {
- NavReplyRecord reply;
- Size len;
-
- status = NavDialogGetReply(dialogRef, &reply);
- if (status != noErr)
- break;
- status = AEGetNthPtr (&reply.selection, 1, TYPE_FILE_NAME,
- NULL, NULL, filename,
- sizeof (filename) - 1, &len);
- if (status == noErr)
- {
- len = min (len, sizeof (filename) - 1);
- filename[len] = '\0';
- if (reply.saveFileName)
- {
- /* If it was a saved file, we need to add the file name */
- if (len && len < sizeof (filename) - 1
- && filename[len-1] != '/')
- filename[len++] = '/';
- CFStringGetCString(reply.saveFileName, filename+len,
- sizeof (filename) - len,
-#ifdef MAC_OSX
- kCFStringEncodingUTF8
-#else
- CFStringGetSystemEncoding ()
-#endif
- );
- }
- file = DECODE_FILE (make_unibyte_string (filename,
- strlen (filename)));
- }
- NavDisposeReply(&reply);
- }
- break;
- }
- NavDialogDispose(dialogRef);
- UNBLOCK_INPUT;
- }
- else {
- UNBLOCK_INPUT;
- /* Fall back on minibuffer if there was a problem */
- file = Fcompleting_read (prompt, intern ("read-file-name-internal"),
- dir, mustmatch, dir, Qfile_name_history,
- default_filename, Qnil);
- }
- }
-
- UNGCPRO;
-
- /* Make "Cancel" equivalent to C-g. */
- if (NILP (file))
- Fsignal (Qquit, Qnil);
-
- return unbind_to (count, file);
-}
-
-
-/* Need to register some event callback function for enabling drag and
- drop in Navigation Service dialogs. */
-static pascal void
-mac_nav_event_callback (selector, parms, data)
- NavEventCallbackMessage selector;
- NavCBRecPtr parms;
- void *data ;
-{
+ return mac_file_dialog (prompt, dir, default_filename, mustmatch, only_dir_p);
}
#endif
+
\f
/***********************************************************************
Fonts
Lisp_Object result;
check_mac ();
- CHECK_NUMBER_OR_FLOAT(id);
- font_id = NUMBERP (id) ? XINT (id) : (ATSUFontID) XFLOAT (id);
+ CHECK_NUMBER_OR_FLOAT (id);
+ font_id = INTEGERP (id) ? XINT (id) : XFLOAT_DATA (id);
BLOCK_INPUT;
result = mac_atsu_font_face_attributes (font_id);
UNBLOCK_INPUT;