bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#9176: [PATCH] 24.0.50: Tooltip windows on NextStep are sized incorre


From: Alp Aker
Subject: bug#9176: [PATCH] 24.0.50: Tooltip windows on NextStep are sized incorrectly
Date: Tue, 26 Jul 2011 16:13:04 -0400

A small aesthetic issue:  Currently on NS the dimensions of tooltip
windows are determined by a small hack that introduces superfluous
padding at the bottom and left (typically 10 pixels or more).  The
patch below sizes tooltip windows precisely.

I also took the liberty of making another purely aesthetic change.
Currently on NS tooltip windows have bezels and no shadows. The
standard appearance on Mac is to have shadows and no bezels.  So I
changed the implementation to use the default appearance as well.

2011-07-26  Alp Aker  <alp.tekin.aker@gmail.com>

        * nsmenu.m (EmacsTooltip -init): Remove bezels and add shadows to
        tooltip windows.
        (-setText): Size tooltip dimensions precisely to contents.

=== modified file 'src/nsmenu.m'
--- src/nsmenu.m        2011-07-08 10:04:23 +0000
+++ src/nsmenu.m        2011-07-26 19:50:47 +0000
@@ -1228,8 +1228,8 @@

   [textField setEditable: NO];
   [textField setSelectable: NO];
-  [textField setBordered: YES];
-  [textField setBezeled: YES];
+  [textField setBordered: NO];
+  [textField setBezeled: NO];
   [textField setDrawsBackground: YES];

   win = [[NSWindow alloc]
@@ -1237,6 +1237,7 @@
                       styleMask: 0
                         backing: NSBackingStoreBuffered
                           defer: YES];
+  [win setHasShadow: YES];
   [win setReleasedWhenClosed: NO];
   [win setDelegate: self];
   [[win contentView] addSubview: textField];
@@ -1257,17 +1258,15 @@
 - (void) setText: (char *)text
 {
   NSString *str = [NSString stringWithUTF8String: text];
-  NSRect r = [textField frame];
-  NSSize textSize = [str sizeWithAttributes:
-     [NSDictionary dictionaryWithObject: [[textField font] screenFont]
-                                forKey: NSFontAttributeName]];
-  NSSize padSize = [[[textField font] screenFont]
-                    boundingRectForFont].size;
-
-  r.size.width = textSize.width + padSize.width/2;
-  r.size.height = textSize.height + padSize.height/2;
+  NSRect r  = [textField frame];
+  NSSize tooltipDims;
+
+  [textField setStringValue: str];
+  tooltipDims = [[textField cell] cellSize];
+
+  r.size.width = tooltipDims.width;
+  r.size.height = tooltipDims.height;
   [textField setFrame: r];
-  [textField setStringValue: str];
 }

 - (void) showAtX: (int)x Y: (int)y for: (int)seconds





reply via email to

[Prev in Thread] Current Thread [Next in Thread]