Allow wrapping of native windows into NSWindow.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@22851 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2006-05-03 21:09:08 +00:00
parent 79a2f5656d
commit 1c35ab4487
4 changed files with 68 additions and 12 deletions

View file

@ -1,3 +1,12 @@
2006-05-03 Fred Kiefer <FredKiefer@gmx.de>
* Headers/Additions/GNUstepGUI/GSDisplayServer.h (-nativeWindow:::::):
Added new method.
* Source/GSDisplayServer.m (-nativeWindow:::::):
Implemented this method as subclassResponsibility.
* Source/NSWindow.m (-initWithWindowRef:], -windowRef):
Implemented these methods to wrap native window into GNUstep windows.
2006-05-01 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSMatrix..m: ([performKeyEquivalent:]) Check modifier flags

View file

@ -116,6 +116,8 @@ APPKIT_EXPORT NSString * GSScreenNumber;
- (int) window: (NSRect)frame : (NSBackingStoreType)type : (unsigned int)style
: (int)screen;
- (void) termwindow: (int) win;
- (int) nativeWindow: (void *)winref : (NSRect*)frame : (NSBackingStoreType*)type
: (unsigned int*)style : (int*)screen;
/* Only if handlesWindowDecorations returns YES. */
- (void) stylewindow: (unsigned int) style : (int) win;

View file

@ -547,6 +547,15 @@ GSCurrentServer(void)
[self subclassResponsibility: _cmd];
}
/** Create all the backend structures for a reference to a native window and
return the extend, backing type, style and screen for that window. */
- (int) nativeWindow: (void *)winref : (NSRect*)frame : (NSBackingStoreType*)type
: (unsigned int*)style : (int*)screen
{
[self subclassResponsibility: _cmd];
return 0;
}
/** Sets the style of the window. See [NSWindow-styleMask] for a
description of the available styles */
- (void) stylewindow: (unsigned int) style : (int) win

View file

@ -984,6 +984,51 @@ many times.
return self;
}
- (id) initWithWindowRef: (void *)windowRef
{
NSRect contentRect;
unsigned int aStyle;
NSBackingStoreType bufferingType;
NSScreen* aScreen;
int screen;
int winNum;
NSGraphicsContext *context = GSCurrentContext();
GSDisplayServer *srv = GSCurrentServer();
// Get the properties for the underlying window
winNum = [srv nativeWindow: windowRef : &contentRect : &bufferingType
: &aStyle : &screen];
// FIXME: Get the screen for the right screen number.
aScreen = nil;
// Set up a NSWindow with the same properties
self = [self initWithContentRect: contentRect
styleMask: aStyle
backing: bufferingType
defer: YES
screen: aScreen];
// Fake the initialisation of the backend
_windowNum = winNum;
NSMapInsert (windowmaps, (void*)(intptr_t)_windowNum, self);
// Set window in new _gstate
DPSgsave(context);
[srv windowdevice: _windowNum];
_gstate = GSDefineGState(context);
DPSgrestore(context);
{
NSRect frame = _frame;
frame.origin = NSZeroPoint;
[_wv setFrame: frame];
[_wv setNeedsDisplay: YES];
[_wv setWindowNumber: _windowNum];
}
return self;
}
-(void) colorListChanged:(NSNotification*)notif
{
if ([[notif object] isEqual: [NSColorList colorListNamed:@"System"]])
@ -4222,20 +4267,11 @@ resetCursorRectsForView(NSView *theView)
return nil;
}
- (id) initWithWindowRef: (void *)windowRef
{
// TODO
NSLog(@"Method %s is not implemented for class %s",
"initWithWindowRef:", "NSWindow");
return nil;
}
- (void *)windowRef
{
// TODO
NSLog(@"Method %s is not implemented for class %s",
"windowRef", "NSWindow");
return (void *) 0;
GSDisplayServer *srv = GSServerForWindow(self);
return [srv windowDevice: _windowNum];
}
- (void *) windowHandle