Commit c0342369 authored by Jan Djärv's avatar Jan Djärv

Update the GNUStep port so it works OK. Redraw and sizing bugs remain.

* nextstep/templates/Info-gnustep.plist.in: Add NSDocumentClass EmacsDocument.

* src/nsfns.m (x_set_foreground_color, x_set_background_color): Use
EmacsCGFloat.
(ns_implicitly_set_icon_type, Fx_create_frame): Make static, remove
unused variables.
(Fns_read_file_name): Keep track if panel is for save.  Use
ns_filename_from_panel/ns_directory_from_panel.
(Fns_list_services): delegate only used for COCOA.
(Fns_convert_utf8_nfd_to_nfc): Remove warning for GNUStep.  Just
return the input if GNUStep.
(x_screen_planes): Remove.
(Fxw_color_values): Use EmacsCGFloat
(Fns_display_monitor_attributes_list): Only get screen number for
Cocoa.
(getDirectory, getFilename): Removed from EmacsOpenPanel and
EmacsSavePanel.
(EmacsOpenPanel:ok:): Use ns_filename_from_panel and
ns_directory_from_panel.

* src/nsfont.m (ns_attribute_fvalue, ns_spec_to_descriptor)
(ns_charset_covers, ns_get_covering_families, nsfont_open):
Use F suffix on floats.
(ns_char_width): Returns CGFloat.
(ns_ascii_average_width): w is CGFloat instead of float.
(nsfont_draw): cbuf and c are unsigned. Cast to char* in call to
DPSxshow.
(ns_glyph_metrics): CGFloat instead of float.

* src/nsimage.m (setXBMColor:, getPixelAtX:Y:): Use EmacsCGFloat.

* src/nsmenu.m (ns_update_menubar): Make static.
(x_activate_menubar): Surround with ifdef NS_IMPL_COCOA
(fillWithWidgetValue:): Add cast to SEL for setAction.
(addSubmenuWithTitle:forFrame:): Add cast to SEL for action.
(update_frame_tool_bar): Update code for GNUStep.
(clearAll): New method.
(addDisplayItemWithImage:idx:tag:helpText:enabled:): Handle new tag
argument. Call insertItemWithItemIdentifier when NS_IMPL_GNUSTEP. Move
identifierToItem setObject and activeIdentifiers addObject before
call to insertItemWithItemIdentifier.
(validateVisibleItems): Fix indentation.
(toolbarAllowedItemIdentifiers:): Return activeIdentifiers.
(initWithContentRect:styleMask:backing:defer:): Add ClosableWindow and
UtilityWindow to aStyle, remove call to setStyleMask.

* src/nsselect.m (ns_get_local_selection): Remove unused variable type.

* src/nsterm.h (EmacsCGFloat): Typedef for OSX and GNUStep when the size
of CGFloat differs.
(EmacsApp): New variable nextappdefined.  Declare sendFromMainThread
when NS_IMPL_GNUSTEP.
(EmacsDocument): Declare when NS_IMPL_GNUSTEP.
(EmacsView): Remove unlockFocusNeedsFlush, add windowDidMove.
(EmacsToolbar): Add clearAll.  Add tag argument to
addDisplayItemWithImage.
(EmacsSavePanel, EmacsOpenPanel): Remove getFilename and getDirectory.

* src/nsterm.m: Include src/process.h if NS_IMPL_GNUSTEP.
(ns_menu_bar_is_hidden, menu_will_open_state): Define only if
NS_IMPL_COCOA.
(x_set_cursor_type): Remove declaration.
(ns_update_begin): Only use r and bp if NS_IMPL_COCOA.
(ns_update_end, ns_focus, ns_unfocus): Remove GNUStep specific code.
(x_set_window_size): Remove 3 pixels from toolbar if NS_IMPL_GNUSTEP.
(ns_get_color): Use F suffix on float.
(ns_color_to_lisp, ns_query_color): Use EmacsCGFloat.
(ns_get_rgb_color): Remove.
(x_set_frame_alpha): Move view inside NS_IMPL_COCOA.
(note_mouse_movement): x and y are CGFloat.
(ns_draw_fringe_bitmap): Remove unused rowY.
Change #if to COCOA && >= 10_6.
(ns_draw_window_cursor): Remove unused overspill.
(ns_draw_underwave): width and x are EamcsCGFloat.
(ns_draw_box): thickness is CGFloat.
(ns_dumpglyphs_image): Change #if to COCOA && >= 10_6.
(ns_send_appdefined): When NS_IMPL_GNUSTEP, redirect to main thread
if not in main thread.
(ns_get_pending_menu_title, ns_check_menu_open)
(ns_check_pending_open_menu): Put inside #if COCOA && >= 10_5.
(ns_term_init): Call catch_child_signal if NS_IMPL_GNUSTEP && SIGCHLD.
(sendFromMainThread:): New method.
(changeFont:): size is CGFloat.
(keyDown:): Check for Delete when NS_IMPL_GNUSTEP.
Disable warning about permanent text.
(characterIndexForPoint:): Adjust return type depending on GNUStep
version.
(mouseDown:): delta is CGFloat.
(updateFrameSize): Remove unised variable f.
(initFrameFromEmacs): Move toggleButton inside NS_IMPL_COCOA.
Cast float to EmacsCGFloat.
(windowWillUseStandardFrame:defaultFrame:): Set maximized_height
also to -1 when restoring.
(windowDidExitFullScreen:): Put call to updateCollectionBehaviour
inside NS_IMPL_COCOA.
(toggleFullScreen:): Put call to toggleFullScreen inside
NS_IMPL_COCOA.  Cast float to EmacsCGFloat.
(setPosition:portion:whole:): por is CGFloat.
(getMouseMotionPart:window:x:y:): Add F suffix to float.
(mouseDown:): Use CGFloat.
(mouseDragged:): Remove unised variable edge.
(EmacsDocument): Implement for NS_IMPL_GNUSTEP.

* src/process.c (catch_child_signal): New function.
(init_process_emacs): Call it.

* src/process.h (catch_child_signal): Declare.
parent a2d98946
2013-06-02 Jan Djärv <jan.h.d@swipnet.se>
* templates/Info-gnustep.plist.in: Add NSDocumentClass EmacsDocument.
2013-03-16 Jan Djärv <jan.h.d@swipnet.se>
* Makefile.in (${ns_appdir}): Add touch.
......
......@@ -20,7 +20,7 @@
NSRole = Application;
NSTypes = (
{
NSDocumentClass = "";
NSDocumentClass = "EmacsDocument";
NSHumanReadableName = "";
NSIcon = "";
NSName = "";
......@@ -30,7 +30,7 @@
);
},
{
NSDocumentClass = "";
NSDocumentClass = "EmacsDocument";
NSHumanReadableName = "";
NSIcon = "";
NSName = "";
......@@ -41,7 +41,7 @@
);
},
{
NSDocumentClass = "";
NSDocumentClass = "EmacsDocument";
NSHumanReadableName = "";
NSIcon = "";
NSName = "";
......@@ -51,7 +51,7 @@
);
},
{
NSDocumentClass = "";
NSDocumentClass = "EmacsDocument";
NSHumanReadableName = "";
NSIcon = "";
NSName = "";
......@@ -64,7 +64,7 @@
);
},
{
NSDocumentClass = "";
NSDocumentClass = "EmacsDocument";
NSHumanReadableName = "";
NSIcon = "";
NSName = "";
......@@ -74,7 +74,7 @@
);
},
{
NSDocumentClass = "";
NSDocumentClass = "EmacsDocument";
NSHumanReadableName = "";
NSIcon = "";
NSName = "";
......@@ -84,7 +84,7 @@
);
},
{
NSDocumentClass = "";
NSDocumentClass = "EmacsDocument";
NSHumanReadableName = "";
NSIcon = "";
NSName = "";
......
2013-06-02 Jan Djärv <jan.h.d@swipnet.se>
* process.h (catch_child_signal): Declare.
* process.c (catch_child_signal): New function.
(init_process_emacs): Call it.
* nsterm.m: Include process.h if NS_IMPL_GNUSTEP.
(ns_menu_bar_is_hidden, menu_will_open_state): Define only if
NS_IMPL_COCOA.
(x_set_cursor_type): Remove declaration.
(ns_update_begin): Only use r and bp if NS_IMPL_COCOA.
(ns_update_end, ns_focus, ns_unfocus): Remove GNUStep specific code.
(x_set_window_size): Remove 3 pixels from toolbar if NS_IMPL_GNUSTEP.
(ns_get_color): Use F suffix on float.
(ns_color_to_lisp, ns_query_color): Use EmacsCGFloat.
(ns_get_rgb_color): Remove.
(x_set_frame_alpha): Move view inside NS_IMPL_COCOA.
(note_mouse_movement): x and y are CGFloat.
(ns_draw_fringe_bitmap): Remove unused rowY.
Change #if to COCOA && >= 10_6.
(ns_draw_window_cursor): Remove unused overspill.
(ns_draw_underwave): width and x are EamcsCGFloat.
(ns_draw_box): thickness is CGFloat.
(ns_dumpglyphs_image): Change #if to COCOA && >= 10_6.
(ns_send_appdefined): When NS_IMPL_GNUSTEP, redirect to main thread
if not in main thread.
(ns_get_pending_menu_title, ns_check_menu_open)
(ns_check_pending_open_menu): Put inside #if COCOA && >= 10_5.
(ns_term_init): Call catch_child_signal if NS_IMPL_GNUSTEP && SIGCHLD.
(sendFromMainThread:): New method.
(changeFont:): size is CGFloat.
(keyDown:): Check for Delete when NS_IMPL_GNUSTEP.
Disable warning about permanent text.
(characterIndexForPoint:): Adjust return type depending on GNUStep
version.
(mouseDown:): delta is CGFloat.
(updateFrameSize): Remove unised variable f.
(initFrameFromEmacs): Move toggleButton inside NS_IMPL_COCOA.
Cast float to EmacsCGFloat.
(windowWillUseStandardFrame:defaultFrame:): Set maximized_height
also to -1 when restoring.
(windowDidExitFullScreen:): Put call to updateCollectionBehaviour
inside NS_IMPL_COCOA.
(toggleFullScreen:): Put call to toggleFullScreen inside
NS_IMPL_COCOA. Cast float to EmacsCGFloat.
(setPosition:portion:whole:): por is CGFloat.
(getMouseMotionPart:window:x:y:): Add F suffix to float.
(mouseDown:): Use CGFloat.
(mouseDragged:): Remove unised variable edge.
(EmacsDocument): Implement for NS_IMPL_GNUSTEP.
* nsterm.h (EmacsCGFloat): Typedef for OSX and GNUStep when the size
of CGFloat differs.
(EmacsApp): New variable nextappdefined. Declare sendFromMainThread
when NS_IMPL_GNUSTEP.
(EmacsDocument): Declare when NS_IMPL_GNUSTEP.
(EmacsView): Remove unlockFocusNeedsFlush, add windowDidMove.
(EmacsToolbar): Add clearAll. Add tag argument to
addDisplayItemWithImage.
(EmacsSavePanel, EmacsOpenPanel): Remove getFilename and getDirectory.
* nsselect.m (ns_get_local_selection): Remove unused variable type.
* nsmenu.m (ns_update_menubar): Make static.
(x_activate_menubar): Surround with ifdef NS_IMPL_COCOA
(fillWithWidgetValue:): Add cast to SEL for setAction.
(addSubmenuWithTitle:forFrame:): Add cast to SEL for action.
(update_frame_tool_bar): Update code for GNUStep.
(clearAll): New method.
(addDisplayItemWithImage:idx:tag:helpText:enabled:): Handle new tag
argument. Call insertItemWithItemIdentifier when NS_IMPL_GNUSTEP. Move
identifierToItem setObject and activeIdentifiers addObject before
call to insertItemWithItemIdentifier.
(validateVisibleItems): Fix indentation.
(toolbarAllowedItemIdentifiers:): Return activeIdentifiers.
(initWithContentRect:styleMask:backing:defer:): Add ClosableWindow and
UtilityWindow to aStyle, remove call to setStyleMask.
* nsimage.m (setXBMColor:, getPixelAtX:Y:): Use EmacsCGFloat.
* nsfont.m (ns_attribute_fvalue, ns_spec_to_descriptor)
(ns_charset_covers, ns_get_covering_families, nsfont_open):
Use F suffix on floats.
(ns_char_width): Returns CGFloat.
(ns_ascii_average_width): w is CGFloat instead of float.
(nsfont_draw): cbuf and c are unsigned. Cast to char* in call to
DPSxshow.
(ns_glyph_metrics): CGFloat instead of float.
* nsfns.m (x_set_foreground_color, x_set_background_color): Use
EmacsCGFloat.
(ns_implicitly_set_icon_type, Fx_create_frame): Make static, remove
unused variables.
(Fns_read_file_name): Keep track if panel is for save. Use
ns_filename_from_panel/ns_directory_from_panel.
(Fns_list_services): delegate only used for COCOA.
(Fns_convert_utf8_nfd_to_nfc): Remove warning for GNUStep. Just
return the input if GNUStep.
(x_screen_planes): Remove.
(Fxw_color_values): Use EmacsCGFloat
(Fns_display_monitor_attributes_list): Only get screen number for
Cocoa.
(getDirectory, getFilename): Removed from EmacsOpenPanel and
EmacsSavePanel.
(EmacsOpenPanel:ok:): Use ns_filename_from_panel and
ns_directory_from_panel.
2013-06-01 Paul Eggert <eggert@cs.ucla.edu>
* process.c (handle_child_signal): Also use WCONTINUED.
......
......@@ -287,7 +287,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
NSColor *col;
CGFloat r, g, b, alpha;
EmacsCGFloat r, g, b, alpha;
if (ns_lisp_to_color (arg, &col))
{
......@@ -319,7 +319,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
struct face *face;
NSColor *col;
NSView *view = FRAME_NS_VIEW (f);
CGFloat r, g, b, alpha;
EmacsCGFloat r, g, b, alpha;
if (ns_lisp_to_color (arg, &col))
{
......@@ -344,7 +344,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
{
[[view window] setBackgroundColor: col];
if (alpha != 1.0)
if (alpha != (EmacsCGFloat) 1.0)
[[view window] setOpaque: NO];
else
[[view window] setOpaque: YES];
......@@ -714,7 +714,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
}
void
static void
ns_implicitly_set_icon_type (struct frame *f)
{
Lisp_Object tem;
......@@ -859,7 +859,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
}
/* This is the same as the xfns.c definition. */
void
static void
x_set_cursor_type (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
{
set_frame_cursor_types (f, arg);
......@@ -1082,7 +1082,6 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
struct ns_display_info *dpyinfo = NULL;
Lisp_Object parent;
struct kboard *kb;
Lisp_Object tfont, tfontsize;
static int desc_ctr = 1;
/* x_get_arg modifies parms. */
......@@ -1189,10 +1188,10 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
{
/* use for default font name */
id font = [NSFont userFixedPitchFontOfSize: -1.0]; /* default */
tfontsize = x_default_parameter (f, parms, Qfontsize,
x_default_parameter (f, parms, Qfontsize,
make_number (0 /*(int)[font pointSize]*/),
"fontSize", "FontSize", RES_TYPE_NUMBER);
tfont = x_default_parameter (f, parms, Qfont,
x_default_parameter (f, parms, Qfont,
build_string ([[font fontName] UTF8String]),
"font", "Font", RES_TYPE_STRING);
}
......@@ -1410,6 +1409,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
{
static id fileDelegate = nil;
BOOL ret;
BOOL isSave = NILP (mustmatch) && NILP (dir_only_p);
id panel;
Lisp_Object fname;
......@@ -1431,7 +1431,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
if ([dirS characterAtIndex: 0] == '~')
dirS = [dirS stringByExpandingTildeInPath];
panel = NILP (mustmatch) && NILP (dir_only_p) ?
panel = isSave ?
(id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel];
[panel setTitle: promptS];
......@@ -1446,7 +1446,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
[panel setCanChooseDirectories: YES];
[panel setCanChooseFiles: NO];
}
else
else if (! isSave)
{
/* This is not quite what the documentation says, but it is compatible
with the Gtk+ code. Also, the menu entry says "Open File...". */
......@@ -1481,8 +1481,8 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
if (ret)
{
NSString *str = [panel getFilename];
if (! str) str = [panel getDirectory];
NSString *str = ns_filename_from_panel (panel);
if (! str) str = ns_directory_from_panel (panel);
if (! str) ret = NO;
else fname = build_string ([str UTF8String]);
}
......@@ -1909,7 +1909,9 @@ and GNUstep implementations ("distributor-specific release
#else
Lisp_Object ret = Qnil;
NSMenu *svcs;
#ifdef NS_IMPL_COCOA
id delegate;
#endif
check_window_system (NULL);
svcs = [[NSMenu alloc] initWithTitle: @"Services"];
......@@ -1992,15 +1994,9 @@ and GNUstep implementations ("distributor-specific release
CHECK_STRING (str);
utfStr = [NSString stringWithUTF8String: SSDATA (str)];
if (![utfStr respondsToSelector:
@selector (precomposedStringWithCanonicalMapping)])
{
message1
("Warning: ns-convert-utf8-nfd-to-nfc unsupported under GNUstep.\n");
return Qnil;
}
else
#ifdef NS_IMPL_COCOA
utfStr = [utfStr precomposedStringWithCanonicalMapping];
#endif
return build_string ([utfStr UTF8String]);
}
......@@ -2155,6 +2151,9 @@ and GNUstep implementations ("distributor-specific release
}
extern const char *x_get_string_resource (XrmDatabase, char *, char *);
/* terms impl this instead of x-get-resource directly */
const char *
x_get_string_resource (XrmDatabase rdb, char *name, char *class)
......@@ -2203,13 +2202,6 @@ and GNUstep implementations ("distributor-specific release
}
int
x_screen_planes (struct frame *f)
{
return FRAME_NS_DISPLAY_INFO (f)->n_planes;
}
void
x_sync (struct frame *f)
{
......@@ -2242,7 +2234,7 @@ and GNUstep implementations ("distributor-specific release
(Lisp_Object color, Lisp_Object frame)
{
NSColor * col;
CGFloat red, green, blue, alpha;
EmacsCGFloat red, green, blue, alpha;
check_window_system (NULL);
CHECK_STRING (color);
......@@ -2434,11 +2426,10 @@ and GNUstep implementations ("distributor-specific release
struct MonitorInfo *m = &monitors[i];
NSRect fr = [s frame];
NSRect vfr = [s visibleFrame];
NSDictionary *dict = [s deviceDescription];
NSValue *resval = [dict valueForKey:NSDeviceResolution];
short y, vy;
#ifdef NS_IMPL_COCOA
NSDictionary *dict = [s deviceDescription];
NSNumber *nid = [dict objectForKey:@"NSScreenNumber"];
CGDirectDisplayID did = [nid unsignedIntValue];
#endif
......@@ -2776,14 +2767,6 @@ - (void) cancel: (id)sender
[NSApp stop: self];
}
#endif
- (NSString *) getFilename
{
return ns_filename_from_panel (self);
}
- (NSString *) getDirectory
{
return ns_directory_from_panel (self);
}
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
{
......@@ -2807,8 +2790,8 @@ - (void) ok: (id)sender
[super ok: sender];
// If not choosing directories, and Open is pressed on a directory, return.
if (! [self canChooseDirectories] && [self getDirectory] &&
! [self getFilename])
if (! [self canChooseDirectories] && ns_directory_from_panel (self) &&
! ns_filename_from_panel (self))
return;
panelOK = 1;
......@@ -2821,14 +2804,6 @@ - (void) cancel: (id)sender
}
#endif
- (NSString *) getFilename
{
return ns_filename_from_panel (self);
}
- (NSString *) getDirectory
{
return ns_directory_from_panel (self);
}
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
{
// NSOpenPanel inherits NSSavePanel, so passing self is OK.
......
......@@ -119,7 +119,7 @@ static void ns_glyph_metrics (struct nsfont_info *font_info,
{
NSDictionary *tdict = [fdesc objectForKey: NSFontTraitsAttribute];
NSNumber *val = [tdict objectForKey: trait];
return val == nil ? 0.0 : [val floatValue];
return val == nil ? 0.0F : [val floatValue];
}
......@@ -138,15 +138,15 @@ static void ns_glyph_metrics (struct nsfont_info *font_info,
/* add each attr in font_spec to fdAttrs.. */
n = min (FONT_WEIGHT_NUMERIC (font_spec), 200);
if (n != -1 && n != STYLE_REF)
[tdict setObject: [NSNumber numberWithFloat: (n - 100.0) / 100.0]
[tdict setObject: [NSNumber numberWithFloat: (n - 100.0F) / 100.0F]
forKey: NSFontWeightTrait];
n = min (FONT_SLANT_NUMERIC (font_spec), 200);
if (n != -1 && n != STYLE_REF)
[tdict setObject: [NSNumber numberWithFloat: (n - 100.0) / 100.0]
[tdict setObject: [NSNumber numberWithFloat: (n - 100.0F) / 100.0F]
forKey: NSFontSlantTrait];
n = min (FONT_WIDTH_NUMERIC (font_spec), 200);
if (n > -1 && (n > STYLE_REF + 10 || n < STYLE_REF - 10))
[tdict setObject: [NSNumber numberWithFloat: (n - 100.0) / 100.0]
[tdict setObject: [NSNumber numberWithFloat: (n - 100.0F) / 100.0F]
forKey: NSFontWidthTrait];
if ([tdict count] > 0)
[fdAttrs setObject: tdict forKey: NSFontTraitsAttribute];
......@@ -240,10 +240,10 @@ static void ns_glyph_metrics (struct nsfont_info *font_info,
/* Utility: get width of a char c in screen font SFONT */
static float
static CGFloat
ns_char_width (NSFont *sfont, int c)
{
float w = -1.0;
CGFloat w = -1.0;
NSString *cstr = [NSString stringWithFormat: @"%c", c];
#ifdef NS_IMPL_COCOA
......@@ -269,7 +269,7 @@ static void ns_glyph_metrics (struct nsfont_info *font_info,
static int
ns_ascii_average_width (NSFont *sfont)
{
float w = -1.0;
CGFloat w = -1.0;
if (!ascii_printable)
{
......@@ -288,14 +288,14 @@ static void ns_glyph_metrics (struct nsfont_info *font_info,
w = [sfont advancementForGlyph: glyph].width;
#endif
if (w < 0.0)
if (w < (CGFloat) 0.0)
{
NSDictionary *attrsDictionary =
[NSDictionary dictionaryWithObject: sfont forKey: NSFontAttributeName];
w = [ascii_printable sizeWithAttributes: attrsDictionary].width;
}
return lrint (w / 95.0);
return lrint (w / (CGFloat) 95.0);
}
......@@ -323,7 +323,7 @@ static void ns_glyph_metrics (struct nsfont_info *font_info,
off++;
}
//fprintf(stderr, "off = %d\ttot = %d\n", off,tot);
return (float)off / tot < 1.0 - pct;
return (float)off / tot < 1.0F - pct;
}
......@@ -514,8 +514,8 @@ but also for ascii (which causes unnecessary font substitution). */
if (ns_charset_covers(fset, charset, pct))
[families addObject: family];
}
pct -= 0.2;
if ([families count] > 0 || pct < 0.05)
pct -= 0.2F;
if ([families count] > 0 || pct < 0.05F)
break;
}
[charset release];
......@@ -763,9 +763,9 @@ Properties to be considered are same as for list(). */
family = [[NSFont userFixedPitchFontOfSize: 0] familyName];
/* Should be > 0.23 as some font descriptors (e.g. Terminus) set to that
when setting family in ns_spec_to_descriptor(). */
if (ns_attribute_fvalue (fontDesc, NSFontWeightTrait) > 0.50)
if (ns_attribute_fvalue (fontDesc, NSFontWeightTrait) > 0.50F)
traits |= NSBoldFontMask;
if (fabs (ns_attribute_fvalue (fontDesc, NSFontSlantTrait) > 0.05))
if (fabs (ns_attribute_fvalue (fontDesc, NSFontSlantTrait) > 0.05F))
traits |= NSItalicFontMask;
/* see http://cocoadev.com/forums/comments.php?DiscussionID=74 */
......@@ -880,7 +880,7 @@ when setting family in ns_spec_to_descriptor(). */
font_info->max_bounds.width = lrint (font_info->width);
font_info->max_bounds.lbearing = lrint (brect.origin.x);
font_info->max_bounds.rbearing =
lrint (brect.size.width - font_info->width);
lrint (brect.size.width - (CGFloat) font_info->width);
#ifdef NS_IMPL_COCOA
/* set up synthItal and the CG font */
......@@ -1041,8 +1041,8 @@ is false when (FROM > 0 || TO < S->nchars). */
/* NOTE: focus and clip must be set
also, currently assumed (true in nsterm.m call) from ==0, to ==nchars */
{
static char cbuf[1024];
char *c = cbuf;
static unsigned char cbuf[1024];
unsigned char *c = cbuf;
#ifdef NS_IMPL_GNUSTEP
static float advances[1024];
float *adv = advances;
......@@ -1209,7 +1209,7 @@ is false when (FROM > 0 || TO < S->nchars). */
[bgCol set];
DPSmoveto (context, r.origin.x, r.origin.y);
/*[context GSSetTextDrawingMode: GSTextFillStroke]; /// not implemented yet */
DPSxshow (context, cbuf, advances, len);
DPSxshow (context, (const char *) cbuf, advances, len);
DPSstroke (context);
[col set];
/*[context GSSetTextDrawingMode: GSTextFill]; /// not implemented yet */
......@@ -1219,7 +1219,7 @@ is false when (FROM > 0 || TO < S->nchars). */
/* draw with DPSxshow () */
DPSmoveto (context, r.origin.x, r.origin.y);
DPSxshow (context, cbuf, advances, len);
DPSxshow (context, (const char *) cbuf, advances, len);
DPSstroke (context);
DPSgrestore (context);
......@@ -1407,7 +1407,7 @@ is false when (FROM > 0 || TO < S->nchars). */
metrics = font_info->metrics[block];
for (g = block<<8, i =0; i<0x100 && g < numGlyphs; g++, i++, metrics++)
{
float w, lb, rb;
CGFloat w, lb, rb;
NSRect r = [sfont boundingRectForGlyph: g];
w = max ([sfont advancementForGlyph: g].width, 2.0);
......@@ -1419,7 +1419,7 @@ is false when (FROM > 0 || TO < S->nchars). */
if (lb < 0)
metrics->lbearing = round (lb - LCD_SMOOTHING_MARGIN);
if (font_info->ital)
rb += 0.22 * font_info->height;
rb += (CGFloat) (0.22F * font_info->height);
metrics->rbearing = lrint (w + rb + LCD_SMOOTHING_MARGIN);
metrics->descent = r.origin.y < 0 ? -r.origin.y : 0;
......
......@@ -334,7 +334,7 @@ - (void)dealloc
{
NSSize s = [self size];
unsigned char *planes[5];
CGFloat r, g, b, a;
EmacsCGFloat r, g, b, a;
NSColor *rgbColor;
if (bmRep == nil || color == nil)
......@@ -437,7 +437,7 @@ - (unsigned long) getPixelAtX: (int)x Y: (int)y
else
{
NSColor *color = [bmRep colorAtX: x y: y];
CGFloat r, g, b, a;
EmacsCGFloat r, g, b, a;
[color getRed: &r green: &g blue: &b alpha: &a];
return ((int)(a * 255.0) << 24)
| ((int)(r * 255.0) << 16) | ((int)(g * 255.0) << 8)
......
......@@ -45,8 +45,6 @@
#include <sys/types.h>
#endif
#define MenuStagger 10.0
#if 0
int menu_trace_num = 0;
#define NSTRACE(x) fprintf (stderr, "%s:%d: [%d] " #x "\n", \
......@@ -112,7 +110,7 @@
2) deep_p, submenu = nil: Recompute all submenus.
3) deep_p, submenu = non-nil: Update contents of a single submenu.
-------------------------------------------------------------------------- */
void
static void
ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu)
{
NSAutoreleasePool *pool;
......@@ -505,6 +503,7 @@
void
x_activate_menubar (struct frame *f)
{
#ifdef NS_IMPL_COCOA
NSArray *a = [[NSApp mainMenu] itemArray];
/* Update each submenu separately so ns_update_menubar doesn't reset
the delegate. */
......@@ -521,6 +520,7 @@
++i;
}
ns_check_pending_open_menu ();
#endif
}
......@@ -740,7 +740,7 @@ - (void)fillWithWidgetValue: (void *)wvptr
[self setSubmenu: submenu forItem: item];
[submenu fillWithWidgetValue: wv->contents];
[submenu release];
[item setAction: nil];
[item setAction: (SEL)nil];
}
}
......@@ -757,7 +757,7 @@ - (EmacsMenu *)addSubmenuWithTitle: (const char *)title forFrame: (struct frame
{
NSString *titleStr = [NSString stringWithUTF8String: title];
NSMenuItem *item = [self addItemWithTitle: titleStr
action: nil /*@selector (menuDown:) */
action: (SEL)nil /*@selector (menuDown:) */
keyEquivalent: @""];
EmacsMenu *submenu = [[EmacsMenu alloc] initWithTitle: titleStr frame: f];
[self setSubmenu: submenu forItem: item];
......@@ -1045,13 +1045,18 @@ - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
Update toolbar contents
-------------------------------------------------------------------------- */
{
int i;
int i, k = 0;
EmacsView *view = FRAME_NS_VIEW (f);
NSWindow *window = [view window];
EmacsToolbar *toolbar = [view toolbar];
block_input ();
#ifdef NS_IMPL_COCOA
[toolbar clearActive];
#else
[toolbar clearAll];
#endif
/* update EmacsToolbar as in GtkUtils, build items list */
for (i = 0; i < f->n_tool_bar_items; ++i)
......@@ -1067,6 +1072,15 @@ - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
Lisp_Object helpObj;
const char *helpText;
/* Check if this is a separator. */
if (EQ (TOOLPROP (TOOL_BAR_ITEM_TYPE), Qt))
{
/* Skip separators. Newer OSX don't show them, and on GNUStep they
are wide as a button, thus overflowing the toolbar most of
the time. */
continue;
}
/* If image is a vector, choose the image according to the
button state. */
image = TOOLPROP (TOOL_BAR_ITEM_IMAGES);
......@@ -1103,7 +1117,10 @@ - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
continue;
}
[toolbar addDisplayItemWithImage: img->pixmap idx: i helpText: helpText
[toolbar addDisplayItemWithImage: img->pixmap
idx: k++
tag: i
helpText: helpText
enabled: enabled_p];
#undef TOOLPROP
}
......@@ -1111,6 +1128,7 @@ - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
if (![toolbar isVisible])
[toolbar setVisible: YES];
#ifdef NS_IMPL_COCOA
if ([toolbar changed])
{
/* inform app that toolbar has changed */
......@@ -1132,6 +1150,7 @@ - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f