bug-gnustep
[Top][All Lists]
Advanced

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

[semi-PATCH] menu title bar sizing & menu close button


From: Michael Hanni
Subject: [semi-PATCH] menu title bar sizing & menu close button
Date: Thu, 13 Mar 2003 17:00:26 -0800 (PST)

Here are a few modifications for NSMenuView.m.

=====
First: menus without items have a titlebar sized to just the title of the menu.
However, when you tear such a menu off the close button gets plopped on there.
This first fix adds some space in the NSMenuView -sizeToFit to account for our
button.
=====

(once again, I can't reach the CVS server so this is ugly, sorry.)

In NSMenuView sizeToFit (around line 511):

>>>>>
// the close button is 15 pixels, 4 for padding.
float    neededImageAndTitleWidth = [_font widthOfString: [_menu title]] + 15.0
+ 4.0;
<<<<<

This is based on the formula for the close button placement later in the code.

Issues: this makes even the toplevel menu somewhat wider in certain cases...
was that the case in OS?

======
Second: the menu close button really sucks. It is a relic from the days of no
transparency so I made a few changes.
======

In NSMenuView.m createButton (around line 1531):

>>>>>
- (void) createButton
{
  // create the menu's close button
  // We want a 15x15 square to match visually what one sees with OS and Window
Maker.
  NSImage* closeX = [NSImage imageNamed: @"common_CloseX"];
  NSRect rect = { { _frame.size.width - 15 - 4,
                    (_frame.size.height - 15) / 2},
                  { 15, 15 } };
  
  button = [[NSButton alloc] initWithFrame: rect];
  [button setButtonType: NSMomentaryLight];
  [button setImagePosition: NSImageOnly];
  [button setImage: closeX];
  [button setTarget: menu];
<<<<
(the rest of the method can stay)

Attached is common_closeX.tiff.

Issues:

* NSButton does not honor (NSControl) setRefusesFirstResponder:. I'm not sure
if thats correct or a bug. However, it does cause the dottedRect to appear in
the close button -- ugly.

* MomentaryLight is not quite the correct effect and NSMomentaryPushButton
looks weird (the button recesses very deep.)

* common_CloseBroke.tiff?

Cheers,

Michael

=====

TIFF image


reply via email to

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