New backend access methods

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6489 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2000-04-20 22:17:42 +00:00
parent c604091e89
commit b734a85d04
8 changed files with 90 additions and 28 deletions

View file

@ -1,3 +1,19 @@
2000-04-20 Adam Fedor <fedor@gnu.org>
* 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 <fedor@gnu.org>
* Hooks for using backend libraries to read images.

View file

@ -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

View file

@ -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

View file

@ -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 */

View file

@ -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);
}

View file

@ -200,6 +200,14 @@ void setNSFont(NSString* key, NSFont* font)
[super dealloc];
}
//
// Private method for NSFontManager
//
- (GSFontInfo *) fontInfo
{
return fontInfo;
}
//
// NSCopying Protocol
//

View file

@ -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

View file

@ -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