mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 05:10:58 +00:00
(-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:
parent
2f222d7aa5
commit
d0b49085b6
1 changed files with 335 additions and 317 deletions
|
@ -147,11 +147,6 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
// Create an array to store our menu item cells.
|
// Create an array to store our menu item cells.
|
||||||
_itemCells = [NSMutableArray new];
|
_itemCells = [NSMutableArray new];
|
||||||
|
|
||||||
// Create title view and add it. CHECKME, should we do this here?
|
|
||||||
_titleView = [[NSMenuWindowTitleView alloc] init];
|
|
||||||
|
|
||||||
[self addSubview: _titleView];
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +210,7 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
name: NSMenuDidRemoveItemNotification
|
name: NSMenuDidRemoveItemNotification
|
||||||
object: _menu];
|
object: _menu];
|
||||||
|
|
||||||
[_titleView setMenu: _menu]; // WO CHECKME does this needs reorganizing?
|
[self update];
|
||||||
// Force menu view's layout to be recalculated.
|
// Force menu view's layout to be recalculated.
|
||||||
[self setNeedsSizing: YES];
|
[self setNeedsSizing: YES];
|
||||||
}
|
}
|
||||||
|
@ -472,7 +467,24 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
*/
|
*/
|
||||||
- (void) update
|
- (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])
|
if ([_menu isTornOff] && ![_menu isTransient])
|
||||||
{
|
{
|
||||||
|
@ -482,9 +494,6 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
{
|
{
|
||||||
[_titleView removeCloseButton];
|
[_titleView removeCloseButton];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_needsSizing)
|
|
||||||
[self sizeToFit];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setNeedsSizing: (BOOL)flag
|
- (void) setNeedsSizing: (BOOL)flag
|
||||||
|
@ -502,7 +511,7 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
unsigned i;
|
unsigned i;
|
||||||
unsigned howMany = [_itemCells count];
|
unsigned howMany = [_itemCells count];
|
||||||
unsigned wideTitleView = 1;
|
unsigned wideTitleView = 1;
|
||||||
float neededImageAndTitleWidth = [_titleView titleSize].width;
|
float neededImageAndTitleWidth = 0.0;
|
||||||
float neededKeyEquivalentWidth = 0.0;
|
float neededKeyEquivalentWidth = 0.0;
|
||||||
float neededStateImageWidth = 0.0;
|
float neededStateImageWidth = 0.0;
|
||||||
float accumulatedOffset = 0.0;
|
float accumulatedOffset = 0.0;
|
||||||
|
@ -510,10 +519,15 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
float menuBarHeight = 0.0;
|
float menuBarHeight = 0.0;
|
||||||
|
|
||||||
// Popup menu doesn't need title bar
|
// Popup menu doesn't need title bar
|
||||||
if (![_menu _ownedByPopUp])
|
if (![_menu _ownedByPopUp] && _titleView)
|
||||||
|
{
|
||||||
menuBarHeight = [[self class] menuBarHeight];
|
menuBarHeight = [[self class] menuBarHeight];
|
||||||
|
neededStateImageWidth = [_titleView titleSize].width;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
menuBarHeight += _leftBorderOffset;
|
menuBarHeight += _leftBorderOffset;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Optimize this loop.
|
// TODO: Optimize this loop.
|
||||||
for (i = 0; i < howMany; i++)
|
for (i = 0; i < howMany; i++)
|
||||||
|
@ -850,8 +864,6 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
NSRect screenFrame;
|
NSRect screenFrame;
|
||||||
int items = [_itemCells count];
|
int items = [_itemCells count];
|
||||||
|
|
||||||
[_titleView removeFromSuperview];
|
|
||||||
|
|
||||||
// Convert the screen rect to our view
|
// Convert the screen rect to our view
|
||||||
cellFrame.size = screenRect.size;
|
cellFrame.size = screenRect.size;
|
||||||
cellFrame.origin = [_window convertScreenToBase: screenRect.origin];
|
cellFrame.origin = [_window convertScreenToBase: screenRect.origin];
|
||||||
|
@ -1430,13 +1442,19 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
[super init];
|
self = [super init];
|
||||||
|
|
||||||
attr = nil;
|
attr = nil;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
RELEASE (button);
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL) acceptsFirstMouse: (NSEvent *)theEvent
|
- (BOOL) acceptsFirstMouse: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue