diff --git a/ChangeLog b/ChangeLog index 4c0ee174c..0a1b37201 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2000-04-20 Adam Fedor + + * Headers/gnustep/gui/GSMethodTable.h: Added methods to get + current server device (X display) and current window device (X window). + * Headers/gnustep/gui/DPSOperators.h: Likewise + * Headers/gnustep/gui/NSGraphicsContext.h: Likewise + * Headers/gnustep/gui/PSOperators.h: Likewise + * Source/NSGraphicsContext.m: Likewise + * Source/NSBrowser.m (-setDelegate:): + browser:willDisplayCell:atRow:column: is only requiired for a + passive browser delegate. + + * Source/NSFont.m (-fontInfo): New private method. + * Source/NSFontManager.m (-traitsOfFont): Use it. + (-weightOfFont): Likewise. + 2000-04-18 Adam Fedor * Hooks for using backend libraries to read images. diff --git a/Headers/gnustep/gui/DPSOperators.h b/Headers/gnustep/gui/DPSOperators.h index 0513e8e34..f1798ae30 100644 --- a/Headers/gnustep/gui/DPSOperators.h +++ b/Headers/gnustep/gui/DPSOperators.h @@ -955,6 +955,14 @@ static inline void DPSsetinputstate(GSCTXT *ctxt, int window, int state) __attribute__((unused)); +static inline void +DPScurrentserverdevice(GSCTXT *ctxt, void **serverptr) +__attribute__((unused)); + +static inline void +DPScurrentwindowdevice(GSCTXT *ctxt, int win, void **windowptr) +__attribute__((unused)); + /* ----------------------------------------------------------------------- */ /* Color operations */ /* ----------------------------------------------------------------------- */ @@ -2550,4 +2558,18 @@ DPSsetinputstate(GSCTXT *ctxt, int window, int state) (ctxt, @selector(DPSsetinputstate::), window, state); } +static inline void +DPScurrentserverdevice(GSCTXT *ctxt, void **serverptr) +{ + (ctxt->methods->DPScurrentserverdevice_) + (ctxt, @selector(DPScurrentserverdevice:), serverptr); +} + +static inline void +DPScurrentwindowdevice(GSCTXT *ctxt, int win, void **windowptr) +{ + (ctxt->methods->DPScurrentwindowdevice__) + (ctxt, @selector(DPScurrentwindowdevice::), win, windowptr); +} + #endif diff --git a/Headers/gnustep/gui/GSMethodTable.h b/Headers/gnustep/gui/GSMethodTable.h index 95775782e..bc79665ee 100644 --- a/Headers/gnustep/gui/GSMethodTable.h +++ b/Headers/gnustep/gui/GSMethodTable.h @@ -517,6 +517,11 @@ typedef struct { void (*DPSsetinputstate__) (NSGraphicsContext*, SEL, int, int); + void (*DPScurrentserverdevice_) + (NSGraphicsContext*, SEL, void **); + void (*DPScurrentwindowdevice__) + (NSGraphicsContext*, SEL, int, void **); + } gsMethodTable; #endif diff --git a/Headers/gnustep/gui/NSGraphicsContext.h b/Headers/gnustep/gui/NSGraphicsContext.h index 1968999ce..34026f25e 100644 --- a/Headers/gnustep/gui/NSGraphicsContext.h +++ b/Headers/gnustep/gui/NSGraphicsContext.h @@ -434,6 +434,10 @@ NSGraphicsContext *GSCurrentContext(); - (void) DPSPostEvent: (NSEvent*)anEvent atStart: (BOOL)flag; - (void) DPSmouselocation: (float*)x : (float*)y; - (void) DPSsetinputstate: (int)window : (int)state; + +- (void) DPScurrentserverdevice: (void **)serverptr; +- (void) DPScurrentwindowdevice: (int)win : (void **)windowptr; + @end #endif /* _NSGraphicsContext_h_INCLUDE */ diff --git a/Source/NSBrowser.m b/Source/NSBrowser.m index 69c1476d0..26ea514b9 100644 --- a/Source/NSBrowser.m +++ b/Source/NSBrowser.m @@ -475,8 +475,10 @@ return aCell; else { - [_browserDelegate browser: self willDisplayCell: aCell - atRow: row column: column]; + if (_passiveDelegate || [_browserDelegate respondsToSelector: + @selector(browser:willDisplayCell:atRow:column:)]) + [_browserDelegate browser: self willDisplayCell: aCell + atRow: row column: column]; [aCell setLoaded: YES]; } @@ -1827,7 +1829,7 @@ // Sets the NSBrowser's delegate to anObject. // Raises NSBrowserIllegalDelegateException if the delegate specified // by anObject doesn't respond to browser:willDisplayCell:atRow:column: -// and either of the methods browser:numberOfRowsInColumn: +// (if passive) and either of the methods browser:numberOfRowsInColumn: // or browser:createRowsForColumn:inMatrix:. // @@ -1840,12 +1842,6 @@ fprintf(stderr, "NSBrowser - (void)setDelegate\n"); #endif - if (![anObject respondsToSelector: - @selector(browser:willDisplayCell:atRow:column:)]) - [NSException raise: NSBrowserIllegalDelegateException - format: @"Delegate does not respond to %s\n", - "browser: willDisplayCell: atRow: column: "]; - if ([anObject respondsToSelector: @selector(browser:numberOfRowsInColumn:)]) { @@ -1866,6 +1862,12 @@ flag = YES; } + if (_passiveDelegate && ![anObject respondsToSelector: + @selector(browser:willDisplayCell:atRow:column:)]) + [NSException raise: NSBrowserIllegalDelegateException + format: @"(Passive) Delegate does not respond to %s\n", + "browser: willDisplayCell: atRow: column: "]; + if (!flag) [NSException raise: NSBrowserIllegalDelegateException format: @"Delegate does not respond to %s or %s\n", @@ -1878,9 +1880,7 @@ "browser: numberOfRowsInColumn: ", "browser: createRowsForColumn: inMatrix: "]; - [anObject retain]; - [_browserDelegate release]; - _browserDelegate = anObject; + ASSIGN(_browserDelegate, anObject); } diff --git a/Source/NSFont.m b/Source/NSFont.m index 7bd412d92..b22951ebb 100644 --- a/Source/NSFont.m +++ b/Source/NSFont.m @@ -200,6 +200,14 @@ void setNSFont(NSString* key, NSFont* font) [super dealloc]; } +// +// Private method for NSFontManager +// +- (GSFontInfo *) fontInfo +{ + return fontInfo; +} + // // NSCopying Protocol // diff --git a/Source/NSFontManager.m b/Source/NSFontManager.m index 3c813196c..9b3f0381a 100644 --- a/Source/NSFontManager.m +++ b/Source/NSFontManager.m @@ -49,6 +49,10 @@ static NSFontPanel *fontPanel = nil; static Class fontManagerClass = Nil; static Class fontPanelClass = Nil; +@interface NSFont (Private) +- (GSFontInfo *) fontInfo; +@end + @implementation NSFontManager /* @@ -61,7 +65,7 @@ static Class fontPanelClass = Nil; NSDebugLog(@"Initialize NSFontManager class\n"); // Initial version - [self setVersion: 1]; + [self setVersion: 1]; // Set the factories [self setFontManagerFactory: [NSFontManager class]]; @@ -665,25 +669,12 @@ static Class fontPanelClass = Nil; // - (NSFontTraitMask) traitsOfFont: (NSFont*)fontObject { - GSFontInfo *info; - NSFontTraitMask mask = 0; - - info = [GSFontInfo fontInfoForFontName: [fontObject fontName] - matrix: [fontObject matrix]]; - - if (info) - mask = [info traits]; - return mask; + return [[fontObject fontInfo] traits]; } - (int) weightOfFont: (NSFont*)fontObject { - GSFontInfo *info; - - info = [GSFontInfo fontInfoForFontName: [fontObject fontName] - matrix: [fontObject matrix]]; - - return [info weight]; + return [[fontObject fontInfo] weight]; } - (BOOL) fontNamed: (NSString*)typeface diff --git a/Source/NSGraphicsContext.m b/Source/NSGraphicsContext.m index ae20ce4d0..791d65af8 100644 --- a/Source/NSGraphicsContext.m +++ b/Source/NSGraphicsContext.m @@ -829,6 +829,11 @@ NSGraphicsContext *GSCurrentContext() methodTable.DPSsetinputstate__ = GET_IMP(@selector(DPSsetinputstate::)); + methodTable.DPScurrentserverdevice_ = + GET_IMP(@selector(DPScurrentserverdevice:)); + methodTable.DPScurrentwindowdevice__ = + GET_IMP(@selector(DPScurrentwindowdevice::)); + mptr = NSZoneMalloc(_globalGSZone, sizeof(gsMethodTable)); memcpy(mptr, &methodTable, sizeof(gsMethodTable)); return mptr; @@ -2283,4 +2288,15 @@ NSGraphicsContext *GSCurrentContext() { [self subclassResponsibility: _cmd]; } + +- (void) DPScurrentserverdevice: (void **)serverptr +{ + [self subclassResponsibility: _cmd]; +} + +- (void) DPScurrentwindowdevice: (int)win : (void **)windowptr +{ + [self subclassResponsibility: _cmd]; +} + @end