(-initWithFrame:): Removed creation of titleView

([NSMenuView -setMenu:]): call update to handle new situation
([NSMenuView -update]): Removed call to _menu update, handle the
adding/removing of the title view.
([NSMenuView -sizeToFit]): reformatted to conform to coding standard,
handle missing titleView.
([NSMenuView -setWindowFrameForAttachingToRect:onScreen:preferredEdge:popUpSelectedItem:]):
Reformatted to conform to coding standard.  Removed the code that removed the titleView.
That is handled by update.
([NSMenuView -drawRect:]): Reformatted to conform to coding standards.
([NSMenuWindowTitleView -init]): Reformatted to conform to coding standards.
([NSMenuWindowTitleView -dealloc]): new method to prevent leaking the close button.
([NSMenuWindowTitleView -titleSize]): Reformatted to conform to coding standard
([NSMenuWindowTitleView -drawRect:]): idem
([NSMenuWindowTitleView -mouseDown:]): idem
([NSMenuWindowTitleView -createButton]): idem


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16222 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
wim 2003-03-22 16:30:04 +00:00
parent 2f222d7aa5
commit d0b49085b6

View file

@ -147,11 +147,6 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
// Create an array to store our menu item cells.
_itemCells = [NSMutableArray new];
// Create title view and add it. CHECKME, should we do this here?
_titleView = [[NSMenuWindowTitleView alloc] init];
[self addSubview: _titleView];
return self;
}
@ -215,7 +210,7 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
name: NSMenuDidRemoveItemNotification
object: _menu];
[_titleView setMenu: _menu]; // WO CHECKME does this needs reorganizing?
[self update];
// Force menu view's layout to be recalculated.
[self setNeedsSizing: YES];
}
@ -472,7 +467,24 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
*/
- (void) update
{
[_menu update];
NSDebugLLog (@"NSMenu", @"update called on menu view");
if ([_menu _ownedByPopUp] && _titleView)
{
[_titleView removeFromSuperview];
_titleView = nil;
}
if (![_menu _ownedByPopUp] && !_titleView)
{
_titleView = [[NSMenuWindowTitleView alloc] init];
[_titleView setMenu: _menu];
[self addSubview: _titleView];
[_titleView release];
}
[_titleView setMenu: _menu];
if (_needsSizing)
[self sizeToFit];
if ([_menu isTornOff] && ![_menu isTransient])
{
@ -482,9 +494,6 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
{
[_titleView removeCloseButton];
}
if (_needsSizing)
[self sizeToFit];
}
- (void) setNeedsSizing: (BOOL)flag
@ -502,7 +511,7 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
unsigned i;
unsigned howMany = [_itemCells count];
unsigned wideTitleView = 1;
float neededImageAndTitleWidth = [_titleView titleSize].width;
float neededImageAndTitleWidth = 0.0;
float neededKeyEquivalentWidth = 0.0;
float neededStateImageWidth = 0.0;
float accumulatedOffset = 0.0;
@ -510,10 +519,15 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
float menuBarHeight = 0.0;
// Popup menu doesn't need title bar
if (![_menu _ownedByPopUp])
if (![_menu _ownedByPopUp] && _titleView)
{
menuBarHeight = [[self class] menuBarHeight];
neededStateImageWidth = [_titleView titleSize].width;
}
else
{
menuBarHeight += _leftBorderOffset;
}
// TODO: Optimize this loop.
for (i = 0; i < howMany; i++)
@ -850,8 +864,6 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
NSRect screenFrame;
int items = [_itemCells count];
[_titleView removeFromSuperview];
// Convert the screen rect to our view
cellFrame.size = screenRect.size;
cellFrame.origin = [_window convertScreenToBase: screenRect.origin];
@ -1430,13 +1442,19 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
- (id) init
{
[super init];
self = [super init];
attr = nil;
return self;
}
- (void) dealloc
{
RELEASE (button);
[super dealloc];
}
- (BOOL) acceptsFirstMouse: (NSEvent *)theEvent
{
return YES;