/* NeXT/Open/GNUstep and MacOSX Cocoa menu and toolbar module.
- Copyright (C) 2007-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007-2016 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <sys/types.h>
#endif
-#if 0
-int menu_trace_num = 0;
-#define NSTRACE(x) fprintf (stderr, "%s:%d: [%d] " #x "\n", \
- __FILE__, __LINE__, ++menu_trace_num)
-#else
-#define NSTRACE(x)
-#endif
#if 0
/* Include lisp -> C common menu parsing code */
#include "nsmenu_common.c"
#endif
-extern Lisp_Object Qundefined, Qmenu_enable, Qmenu_bar_update_hook;
-extern Lisp_Object QCtoggle, QCradio;
-
-Lisp_Object Qdebug_on_next_call;
-extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map;
-
extern long context_menu_value;
EmacsMenu *mainMenu, *svcsMenu, *dockMenu;
long t;
#endif
- NSTRACE (ns_update_menubar);
+ NSTRACE ("ns_update_menubar");
if (f != SELECTED_FRAME ())
return;
menu = [[EmacsMenu alloc] initWithTitle: ns_app_name];
needsSet = YES;
}
- else
- { /* close up anything on there */
- id attMenu = [menu attachedMenu];
- if (attMenu != nil)
- [attMenu close];
- }
#if NSMENUPROFILE
ftime (&tb);
widget_value *wv, *first_wv = 0;
bool keymaps = (menuflags & MENU_KEYMAPS);
+ NSTRACE ("ns_menu_show");
+
block_input ();
p.x = x; p.y = y;
-------------------------------------------------------------------------- */
{
EmacsView *view = FRAME_NS_VIEW (f);
+
+ NSTRACE ("free_frame_tool_bar");
+
block_input ();
view->wait_for_tool_bar = NO;
- [[view toolbar] setVisible: NO];
+
FRAME_TOOLBAR_HEIGHT (f) = 0;
+
+ /* Note: This trigger an animation, which calls windowDidResize
+ repeatedly. */
+ f->output_data.ns->in_animation = 1;
+ [[view toolbar] setVisible: NO];
+ f->output_data.ns->in_animation = 0;
+
unblock_input ();
}
EmacsView *view = FRAME_NS_VIEW (f);
NSWindow *window = [view window];
EmacsToolbar *toolbar = [view toolbar];
+ int oldh;
+
+ NSTRACE ("update_frame_tool_bar");
if (view == nil || toolbar == nil) return;
block_input ();
+ oldh = FRAME_TOOLBAR_HEIGHT (f);
+
#ifdef NS_IMPL_COCOA
[toolbar clearActive];
#else
}
if (![toolbar isVisible])
+ {
+ f->output_data.ns->in_animation = 1;
[toolbar setVisible: YES];
+ f->output_data.ns->in_animation = 0;
+ }
#ifdef NS_IMPL_COCOA
if ([toolbar changed])
if (FRAME_TOOLBAR_HEIGHT (f) < 0) // happens if frame is fullscreen.
FRAME_TOOLBAR_HEIGHT (f) = 0;
+ if (oldh != FRAME_TOOLBAR_HEIGHT (f))
+ [view updateFrameSize:YES];
if (view->wait_for_tool_bar && FRAME_TOOLBAR_HEIGHT (f) > 0)
{
view->wait_for_tool_bar = NO;
- initForView: (EmacsView *)view withIdentifier: (NSString *)identifier
{
+ NSTRACE ("[EmacsToolbar initForView: withIdentifier:]");
+
self = [super initWithIdentifier: identifier];
emacsView = view;
[self setDisplayMode: NSToolbarDisplayModeIconOnly];
- (void)dealloc
{
+ NSTRACE ("[EmacsToolbar dealloc]");
+
[prevIdentifiers release];
[activeIdentifiers release];
[identifierToItem release];
- (void) clearActive
{
+ NSTRACE ("[EmacsToolbar clearActive]");
+
[prevIdentifiers release];
prevIdentifiers = [activeIdentifiers copy];
[activeIdentifiers removeAllObjects];
- (void) clearAll
{
+ NSTRACE ("[EmacsToolbar clearAll]");
+
[self clearActive];
while ([[self items] count] > 0)
[self removeItemAtIndex: 0];
- (BOOL) changed
{
+ NSTRACE ("[EmacsToolbar changed]");
+
return [activeIdentifiers isEqualToArray: prevIdentifiers] &&
enablement == prevEnablement ? NO : YES;
}
helpText: (const char *)help
enabled: (BOOL)enabled
{
+ NSTRACE ("[EmacsToolbar addDisplayItemWithImage: ...]");
+
/* 1) come up w/identifier */
NSString *identifier
= [NSString stringWithFormat: @"%lu", (unsigned long)[img hash]];
all items to enabled state (for some reason). */
- (void)validateVisibleItems
{
+ NSTRACE ("[EmacsToolbar validateVisibleItems]");
}
itemForItemIdentifier: (NSString *)itemIdentifier
willBeInsertedIntoToolbar: (BOOL)flag
{
+ NSTRACE ("[EmacsToolbar toolbar: ...]");
+
/* look up NSToolbarItem by identifier and return... */
return [identifierToItem objectForKey: itemIdentifier];
}
- (NSArray *)toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar
{
+ NSTRACE ("[EmacsToolbar toolbarDefaultItemIdentifiers:]");
+
/* return entire set.. */
return activeIdentifiers;
}
/* for configuration palette (not yet supported) */
- (NSArray *)toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar
{
+ NSTRACE ("[EmacsToolbar toolbarAllowedItemIdentifiers:]");
+
/* return entire set... */
return activeIdentifiers;
//return [identifierToItem allKeys];
}
+- (void)setVisible:(BOOL)shown
+{
+ NSTRACE ("[EmacsToolbar setVisible:%d]", shown);
+
+ [super setVisible:shown];
+}
+
+
/* optional and unneeded */
/* - toolbarWillAddItem: (NSNotification *)notification { } */
/* - toolbarDidRemoveItem: (NSNotification *)notification { } */
ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents)
{
id dialog;
- Lisp_Object window, tem, title;
+ Lisp_Object tem, title;
NSPoint p;
BOOL isQ;
NSAutoreleasePool *pool;
- NSTRACE (x-popup-dialog);
+ NSTRACE ("ns_popup_dialog");
isQ = NILP (header);
area.size.width = ICONSIZE;
area.size.height= ICONSIZE;
img = [[NSImage imageNamed: @"NSApplicationIcon"] copy];
+#ifdef NS_IMPL_COCOA
+#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
[img setScalesWhenResized: YES];
+#endif
+#endif
[img setSize: NSMakeSize (ICONSIZE, ICONSIZE)];
imgView = [[NSImageView alloc] initWithFrame: area];
[imgView setImage: img];
defsubr (&Sns_reset_menu);
defsubr (&Smenu_or_popup_active_p);
- Qdebug_on_next_call = intern_c_string ("debug-on-next-call");
- staticpro (&Qdebug_on_next_call);
+ DEFSYM (Qdebug_on_next_call, "debug-on-next-call");
}