Removed more backend code.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4666 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Michael Silva 1999-07-28 10:50:30 +00:00
parent 0820add291
commit b5876d7de0
4 changed files with 98 additions and 0 deletions

View file

@ -2,6 +2,8 @@
* Source/NSMenu.m: merge in all backend code. All that remains in
the backend is NSMenuWindow.
* Source/NSPopUpButton.m: merged in all backend code. Relies on
NSMenuWindow now.
1999-07-27 Michael Hanni <mhanni@sprintmail.com>

View file

@ -36,6 +36,7 @@
#include <AppKit/NSImage.h>
#include <AppKit/NSMenuView.h>
#include <AppKit/PSOperators.h>
#include <AppKit/NSWindow.h>
@class NSString;
@class NSEvent;

View file

@ -56,6 +56,8 @@
BOOL is_up;
BOOL pulls_down;
NSMenuWindow *popb_win;
// Reserved for back-end use
void *be_pub_reserved;
}

View file

@ -84,9 +84,23 @@
pulls_down = flag;
selected_item = 0;
[super setTarget: self];
popb_win = [[NSMenuWindow alloc] initWithContentRect: frameRect
styleMask: NSBorderlessWindowMask
backing: NSBackingStoreRetained
defer: NO];
[popb_win setContentView: popb_view];
return self;
}
- (void) close
{
[popb_win orderOut: self];
}
- (void) dealloc
{
[list_items release];
@ -337,15 +351,94 @@
- (void)mouseDown:(NSEvent *)theEvent
{
NSNotificationCenter *nc;
NSPoint cP;
NSRect butf;
NSRect winf;
nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName: NSPopUpButtonWillPopUpNotification
object: self
userInfo: nil];
/*
* Get frame of this button in window coordinates,
* and origin in screen coordinates.
*/
butf = [self frame];
butf = [[self superview] convertRect: butf toView: nil];
butf.origin = [[self window] convertBaseToScreen: butf.origin];
/*
* Determine frame size for a popup window capable of containing the
* menu view.
*/
[popb_view sizeToFitForPopUpButton];
[popb_view setFrameOrigin: NSMakePoint(0,0)];
winf = [NSMenuWindow frameRectForContentRect: [popb_view frame]
styleMask: [popb_win styleMask]];
/*
* Set popup window frame origin so that the top-left corner of the
* window lines up with the top-left corner of this button.
*/
winf.origin = butf.origin;
winf.origin.y += butf.size.height - winf.size.height;
/*
* Small hack to fix line up.
*/
winf.origin.x += 1;
winf.origin.y -= 1;
//NSLog(@"butf %@", NSStringFromRect(butf));
//NSLog(@"winf %@", NSStringFromRect(winf));
if (pulls_down == NO)
{
winf.origin.y += (selected_item * butf.size.height);
}
[popb_win setFrame: winf display: YES];
[popb_win orderFrontRegardless];
[popb_win display];
cP = [theEvent locationInWindow];
cP = [[self window] convertBaseToScreen: cP];
cP = [popb_win convertScreenToBase: cP];
[popb_view mouseDown:
[NSEvent mouseEventWithType: NSLeftMouseDragged
location: cP
modifierFlags: [theEvent modifierFlags]
timestamp: [theEvent timestamp]
windowNumber: [popb_win windowNumber]
context: [theEvent context]
eventNumber: [theEvent eventNumber]
clickCount: [theEvent clickCount]
pressure: [theEvent pressure]]];
}
- (void)mouseUp:(NSEvent *)theEvent
{
NSPoint cP;
cP = [[self window] convertBaseToScreen: [theEvent locationInWindow]];
cP = [popb_win convertScreenToBase: cP];
//NSLog(@"location x = %d, y = %d\n", (int)cP.x, (int)cP.y);
[popb_view mouseUp:
[NSEvent mouseEventWithType: NSLeftMouseUp
location: cP
modifierFlags: [theEvent modifierFlags]
timestamp: [theEvent timestamp]
windowNumber: [popb_win windowNumber]
context: [theEvent context]
eventNumber: [theEvent eventNumber]
clickCount: [theEvent clickCount]
pressure: [theEvent pressure]]];
[popb_win orderOut: nil];
}
- (void)mouseMoved:(NSEvent *)theEvent