mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 12:50:40 +00:00
Tidyups
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@9186 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fed0aac0a6
commit
b5801d88f8
3 changed files with 69 additions and 41 deletions
|
@ -139,11 +139,10 @@
|
||||||
return _window;
|
return _window;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)draw
|
- (BOOL) draw
|
||||||
{
|
{
|
||||||
PScomposite(NSMinX(_rect), NSMinY(_rect), NSWidth(_rect), NSHeight(_rect),
|
PScomposite(NSMinX(_rect), NSMinY(_rect), NSWidth(_rect), NSHeight(_rect),
|
||||||
[_window gState], 0, 0,
|
[_window gState], 0, 0, NSCompositeSourceOver);
|
||||||
NSCompositeSourceOver);
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -629,12 +629,13 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
|
||||||
y -= rect.size.height;
|
y -= rect.size.height;
|
||||||
// FIXME This should be able to cut out part of the image
|
// FIXME This should be able to cut out part of the image
|
||||||
PScomposite(NSMinX(rect), NSMinY(rect), NSWidth(rect), NSHeight(rect),
|
PScomposite(NSMinX(rect), NSMinY(rect), NSWidth(rect), NSHeight(rect),
|
||||||
[[(NSCachedImageRep *)rep window] gState], aPoint.x, y, op);
|
[[(NSCachedImageRep *)rep window] gState], aPoint.x, y, op);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSRect rect = NSMakeRect(aPoint.x, aPoint.y, _size.width, _size.height);
|
NSRect rect;
|
||||||
|
|
||||||
|
rect = NSMakeRect(aPoint.x, aPoint.y, _size.width, _size.height);
|
||||||
[self drawRepresentation: rep inRect: rect];
|
[self drawRepresentation: rep inRect: rect];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -682,12 +683,13 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
|
||||||
y -= rect.size.height;
|
y -= rect.size.height;
|
||||||
// FIXME This should be able to cut out part of the image
|
// FIXME This should be able to cut out part of the image
|
||||||
PSdissolve(NSMinX(rect), NSMinY(rect), NSWidth(rect), NSHeight(rect),
|
PSdissolve(NSMinX(rect), NSMinY(rect), NSWidth(rect), NSHeight(rect),
|
||||||
[[(NSCachedImageRep *)rep window] gState], aPoint.x, y, aFloat);
|
[[(NSCachedImageRep *)rep window] gState], aPoint.x, y, aFloat);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSRect rect = NSMakeRect(aPoint.x, aPoint.y, _size.width, _size.height);
|
NSRect rect;
|
||||||
|
|
||||||
|
rect = NSMakeRect(aPoint.x, aPoint.y, _size.width, _size.height);
|
||||||
[self drawRepresentation: rep inRect: rect];
|
[self drawRepresentation: rep inRect: rect];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -706,7 +708,7 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
|
||||||
NS_ENDHANDLER
|
NS_ENDHANDLER
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)drawRepresentation: (NSImageRep *)imageRep inRect: (NSRect)aRect
|
- (BOOL) drawRepresentation: (NSImageRep *)imageRep inRect: (NSRect)aRect
|
||||||
{
|
{
|
||||||
if (!_flags.scalable)
|
if (!_flags.scalable)
|
||||||
return [imageRep drawAtPoint: aRect.origin];
|
return [imageRep drawAtPoint: aRect.origin];
|
||||||
|
|
|
@ -568,16 +568,19 @@ static NSMapTable *mimeMap = NULL;
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)writeFileWrapper:(NSFileWrapper *)wrapper
|
- (BOOL) writeFileWrapper: (NSFileWrapper *)wrapper
|
||||||
{
|
{
|
||||||
NSString *filename = [wrapper preferredFilename];
|
NSString *filename = [wrapper preferredFilename];
|
||||||
NSData *data;
|
NSData *data;
|
||||||
NSString *type;
|
NSString *type;
|
||||||
BOOL ok = NO;
|
BOOL ok = NO;
|
||||||
|
|
||||||
if (filename == nil)
|
if (filename == nil)
|
||||||
[NSException raise: NSInvalidArgumentException
|
{
|
||||||
format: @"Cannot put file on pastboard with no preferred filename"];
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"Cannot put file on pastboard with "
|
||||||
|
@"no preferred filename"];
|
||||||
|
}
|
||||||
|
|
||||||
data = [wrapper serializedRepresentation];
|
data = [wrapper serializedRepresentation];
|
||||||
type = NSCreateFileContentsPboardType([filename pathExtension]);
|
type = NSCreateFileContentsPboardType([filename pathExtension]);
|
||||||
|
@ -731,7 +734,8 @@ static NSMapTable *mimeMap = NULL;
|
||||||
if (d == nil)
|
if (d == nil)
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
return AUTORELEASE([[NSFileWrapper alloc] initWithSerializedRepresentation: d]);
|
return
|
||||||
|
AUTORELEASE([[NSFileWrapper alloc] initWithSerializedRepresentation: d]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString*) stringForType: (NSString*)dataType
|
- (NSString*) stringForType: (NSString*)dataType
|
||||||
|
@ -791,53 +795,76 @@ static NSMapTable *mimeMap = NULL;
|
||||||
+ (void) _initMimeMappings
|
+ (void) _initMimeMappings
|
||||||
{
|
{
|
||||||
mimeMap = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
mimeMap = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||||
NSObjectMapValueCallBacks, 0);
|
NSObjectMapValueCallBacks, 0);
|
||||||
NSMapInsert(mimeMap, (void *)NSStringPboardType, (void *)@"text/plain");
|
|
||||||
|
NSMapInsert(mimeMap, (void *)NSStringPboardType,
|
||||||
|
(void *)@"text/plain");
|
||||||
NSMapInsert(mimeMap, (void *)NSFileContentsPboardType,
|
NSMapInsert(mimeMap, (void *)NSFileContentsPboardType,
|
||||||
(void *)@"text/plain");
|
(void *)@"text/plain");
|
||||||
NSMapInsert(mimeMap, (void *)NSFilenamesPboardType,
|
NSMapInsert(mimeMap, (void *)NSFilenamesPboardType,
|
||||||
(void *)@"text/uri-list");
|
(void *)@"text/uri-list");
|
||||||
NSMapInsert(mimeMap, (void *)NSPostScriptPboardType,
|
NSMapInsert(mimeMap, (void *)NSPostScriptPboardType,
|
||||||
(void *)@"application/postscript");
|
(void *)@"application/postscript");
|
||||||
NSMapInsert(mimeMap, (void *)NSTabularTextPboardType,
|
NSMapInsert(mimeMap, (void *)NSTabularTextPboardType,
|
||||||
(void *)@"text/tab-separated-values");
|
(void *)@"text/tab-separated-values");
|
||||||
NSMapInsert(mimeMap, (void *)NSRTFPboardType, (void *)@"text/richtext");
|
NSMapInsert(mimeMap, (void *)NSRTFPboardType,
|
||||||
NSMapInsert(mimeMap, (void *)NSTIFFPboardType, (void *)@"image/tiff");
|
(void *)@"text/richtext");
|
||||||
NSMapInsert(mimeMap, (void *)NSGeneralPboardType, (void *)@"text/plain");
|
NSMapInsert(mimeMap, (void *)NSTIFFPboardType,
|
||||||
|
(void *)@"image/tiff");
|
||||||
|
NSMapInsert(mimeMap, (void *)NSGeneralPboardType,
|
||||||
|
(void *)@"text/plain");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the mapping for pasteboard->mime, or return the original pasteboard
|
/*
|
||||||
type if no mapping is found */
|
* Return the mapping for pasteboard->mime, or return the original pasteboard
|
||||||
|
* type if no mapping is found
|
||||||
|
*/
|
||||||
+ (NSString *) mimeTypeForPasteboardType: (NSString *)type
|
+ (NSString *) mimeTypeForPasteboardType: (NSString *)type
|
||||||
{
|
{
|
||||||
NSString *mime;
|
NSString *mime;
|
||||||
|
|
||||||
if (mimeMap == NULL)
|
if (mimeMap == NULL)
|
||||||
[self _initMimeMappings];
|
{
|
||||||
|
[self _initMimeMappings];
|
||||||
|
}
|
||||||
mime = NSMapGet(mimeMap, (void *)type);
|
mime = NSMapGet(mimeMap, (void *)type);
|
||||||
if (mime == nil)
|
if (mime == nil)
|
||||||
mime = type;
|
{
|
||||||
|
mime = type;
|
||||||
|
}
|
||||||
return mime;
|
return mime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the mapping for mime->pasteboard, or return the original pasteboard
|
/*
|
||||||
type if no mapping is found. This method may not have a one-to-one
|
* Return the mapping for mime->pasteboard, or return the original pasteboard
|
||||||
mapping */
|
* type if no mapping is found. This method may not have a one-to-one
|
||||||
|
* mapping
|
||||||
|
*/
|
||||||
+ (NSString *) pasteboardTypeForMimeType: (NSString *)mimeType
|
+ (NSString *) pasteboardTypeForMimeType: (NSString *)mimeType
|
||||||
{
|
{
|
||||||
BOOL found;
|
BOOL found;
|
||||||
NSString *type, *mime;
|
NSString *type;
|
||||||
NSMapEnumerator enumerator;
|
NSString *mime;
|
||||||
|
NSMapEnumerator enumerator;
|
||||||
|
|
||||||
if (mimeMap == NULL)
|
if (mimeMap == NULL)
|
||||||
[self _initMimeMappings];
|
{
|
||||||
|
[self _initMimeMappings];
|
||||||
|
}
|
||||||
enumerator = NSEnumerateMapTable(mimeMap);
|
enumerator = NSEnumerateMapTable(mimeMap);
|
||||||
while ((found = NSNextMapEnumeratorPair(&enumerator,
|
while ((found = NSNextMapEnumeratorPair(&enumerator,
|
||||||
(void **)(&type), (void **)(&mime))))
|
(void **)(&type), (void **)(&mime))))
|
||||||
if ([mimeType isEqual: mime])
|
{
|
||||||
break;
|
if ([mimeType isEqual: mime])
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (found == NO)
|
if (found == NO)
|
||||||
type = mimeType;
|
{
|
||||||
|
type = mimeType;
|
||||||
|
}
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue