Add Quartz-like interface. Fix focus problems.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@14678 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2002-10-09 02:47:40 +00:00
parent 5975f63b9a
commit 1323d17420
12 changed files with 1371 additions and 20 deletions

View file

@ -1,3 +1,23 @@
2002-10-08 Adam Fedor <fedor@gnu.org>
* Fix window focus problems.
* Source/NSApplication.m ([NSIconWindow -canBecomeKeyWindow]):
return YES.
(-finishLaunching): Don't make main menu key.
([NSApplication -deactivate]): Don't setinputfocus to the
icon window.
* Add Quartz-like interface and overridable passing of
colorspaces and fonts to backend.
* Headers/gnustep/gui/NSFont.h (_fontRef): New ivar.
* Source/NSFont (-fontRef): New method.
(GSSetFont): Use it.
* Source/GSFontInfo (-matrix): New method.
* Headers/gnustep/gui/GSFusedSilica.h: New header
* Headers/gnustep/gui/GSFusedSilicaContext.h: Idem.
* GSFusedSilica.m: New file.
* GSFusedSilicaContext.m: Idem.
Tue Oct 8 19:15:24 2002 Nicola Pero <n.pero@mi.flashnet.it>
* Source/NSSecureTextField.m: Mostly rewritten. Main changes -

View file

@ -90,6 +90,7 @@
- (NSString *)familyName;
- (NSString *)fontName;
- (NSString *)encodingScheme;
- (const float*) matrix;
- (BOOL)isFixedPitch;
- (BOOL)isBaseFont;
- (float)ascender;

View file

@ -0,0 +1,68 @@
/** <title>GSFusedSilicaContext</title>
<abstract>Extention to NSGraphicsContext for necessary methods</abstract>
Copyright (C) 2002 Free Software Foundation, Inc.
Author: Adam Fedor <fedor@gnu.org>
Date: Oct 2002
This file is part of the GNUStep
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#ifndef _GSFusedSilicaContext_h_INCLUDE
#define _GSFusedSilicaContext_h_INCLUDE
#include <AppKit/NSGraphicsContext.h>
#include <gnustep/gui/GSFusedSilica.h>
@interface NSGraphicsContext (FusedSilica)
/* Colorspaces */
+ (CGColorSpaceRef) CGColorSpaceCreateDeviceGray;
+ (CGColorSpaceRef) CGColorSpaceCreateDeviceRGB;
+ (CGColorSpaceRef) CGColorSpaceCreateDeviceCMYK;
+ (CGColorSpaceRef) CGColorSpaceCreateCalibratedGray: (const float *)whitePoint
: (const float *)blackPoint
: (float)gamma;
+ (CGColorSpaceRef) CGColorSpaceCreateCalibratedRGB: (const float *)whitePoint
: (const float *)blackPoint
: (const float *)gamma
: (const float *)matrix;
+ (CGColorSpaceRef) CGColorSpaceCreateLab: (const float *)whitePoint
: (const float *)blackPoint
: (const float *)range;
+ (CGColorSpaceRef) CGColorSpaceCreateICCBased: (size_t)nComponents
: (const float *)range
: (CGDataProviderRef)profile
: (CGColorSpaceRef)alternateSpace;
+ (CGColorSpaceRef) CGColorSpaceCreateIndexed: (CGColorSpaceRef)baseSpace
: (size_t) lastIndex
: (const unsigned short int *)colorTable;
+ (size_t) CGColorSpaceGetNumberOfComponents: (CGColorSpaceRef)cs;
+ (CGColorSpaceRef) CGColorSpaceRetain: (CGColorSpaceRef)cs;
+ (void) CGColorSpaceRelease: (CGColorSpaceRef)cs;
/* Fonts */
+ (CGFontRef) CGFontReferenceFromFont: (NSFont *)font;
+ (CGFontRef) CGFontRetain: (CGFontRef) font;
+ (void) CGFontRelease: (CGFontRef) font;
@end
#endif

View file

@ -67,6 +67,7 @@ APPKIT_EXPORT const float*NSFontIdentityMatrix;
BOOL matrixExplicitlySet;
id fontInfo;
void *_fontRef;
}
//
@ -176,6 +177,7 @@ APPKIT_EXPORT const float*NSFontIdentityMatrix;
@interface NSFont (GNUstep)
- (GSFontInfo*) fontInfo;
- (void *) fontRef;
@end
int NSConvertGlyphsToPackedGlyphs(NSGlyph*glBuf,

View file

@ -229,8 +229,8 @@ APPKIT_EXPORT NSGraphicsContext *GSCurrentContext();
- (void) GSSetFillColorspace: (void *)spaceref;
- (void) GSSetStrokeColorspace: (void *)spaceref;
- (void) GSSetFillColor: (float *)values;
- (void) GSSetStrokeColor: (float *)values;
- (void) GSSetFillColor: (const float *)values;
- (void) GSSetStrokeColor: (const float *)values;
/* ----------------------------------------------------------------------- */
/* Text operations */

View file

@ -152,6 +152,8 @@ NSWindowController.m \
NSWorkspace.m \
GSComboSupport.m \
GSDisplayServer.m \
GSFusedSilica.m \
GSFusedSilicaContext.m \
GSHelpManagerPanel.m \
GSInfoPanel.m \
GSMemoryPanel.m \
@ -195,6 +197,7 @@ Gui_AGSDOC_FLAGS = \
# These are gui headers that are also classes documented with autogsdoc
AUTOGSDOC_HEADERS = \
GSDisplayServer.h \
GSFusedSilica.h \
GSTable.h \
GSHbox.h \
GSVbox.h \

View file

@ -341,6 +341,11 @@ static GSFontEnumerator *sharedEnumerator = nil;
return familyName;
}
- (const float*) matrix
{
return matrix;
}
- (float) pointSize
{
return matrix[0];

1093
Source/GSFusedSilica.m Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,163 @@
/** <title>GSFusedSilicaContext</title>
<abstract>Extention to NSGraphicsContext for necessary methods</abstract>
Copyright (C) 2002 Free Software Foundation, Inc.
Author: Adam Fedor <fedor@gnu.org>
Date: Oct 2002
This file is part of the GNUStep
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#include <gnustep/gui/GSFusedSilicaContext.h>
#include <gnustep/gui/GSFontInfo.h>
#include <AppKit/NSGraphics.h>
#include <Foundation/NSData.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSValue.h>
#define NUMBER(num) \
[NSNumber numberWithInt: num]
#define FLOAT_ARRAY(ptr, count) \
[NSData dataWithBytes: ptr length: count*sizeof(float)]
@implementation NSGraphicsContext (FusedSilica)
/* Colorspaces */
+ (CGColorSpaceRef) CGColorSpaceCreateDeviceGray
{
NSMutableDictionary *space;
space = [NSDictionary dictionaryWithObject: NSDeviceWhiteColorSpace
forKey: GSColorSpaceName];
[space setObject: NUMBER(1) forKey: GSColorSpaceComponents];
return space;
}
+ (CGColorSpaceRef) CGColorSpaceCreateDeviceRGB
{
NSMutableDictionary *space;
space = [NSDictionary dictionaryWithObject: NSDeviceRGBColorSpace
forKey: GSColorSpaceName];
[space setObject: NUMBER(3) forKey: GSColorSpaceComponents];
return space;
}
+ (CGColorSpaceRef) CGColorSpaceCreateDeviceCMYK
{
NSMutableDictionary *space;
space = [NSDictionary dictionaryWithObject: NSDeviceCMYKColorSpace
forKey: GSColorSpaceName];
[space setObject: NUMBER(4) forKey: GSColorSpaceComponents];
return space;
}
+ (CGColorSpaceRef) CGColorSpaceCreateCalibratedGray: (const float *)whitePoint
: (const float *)blackPoint
: (float)gamma
{
NSMutableDictionary *space;
space = [NSDictionary dictionaryWithObject: NSCalibratedWhiteColorSpace
forKey: GSColorSpaceName];
[space setObject: FLOAT_ARRAY(whitePoint, 3) forKey: GSColorSpaceWhitePoint];
[space setObject: FLOAT_ARRAY(blackPoint, 3) forKey: GSColorSpaceBlackPoint];
[space setObject: NUMBER(1) forKey: GSColorSpaceComponents];
return space;
}
+ (CGColorSpaceRef) CGColorSpaceCreateCalibratedRGB: (const float *)whitePoint
: (const float *)blackPoint
: (const float *)gamma
: (const float *)matrix
{
NSMutableDictionary *space;
space = [NSDictionary dictionaryWithObject: NSCalibratedRGBColorSpace
forKey: GSColorSpaceName];
[space setObject: FLOAT_ARRAY(whitePoint, 3) forKey: GSColorSpaceWhitePoint];
[space setObject: FLOAT_ARRAY(blackPoint, 3) forKey: GSColorSpaceBlackPoint];
[space setObject: FLOAT_ARRAY(gamma, 3) forKey: GSColorSpaceGamma];
[space setObject: FLOAT_ARRAY(matrix, 9) forKey: GSColorSpaceMatrix];
[space setObject: NUMBER(3) forKey: GSColorSpaceComponents];
return space;
}
+ (CGColorSpaceRef) CGColorSpaceCreateLab: (const float *)whitePoint
: (const float *)blackPoint
: (const float *) range
{
NSMutableDictionary *space;
space = [NSDictionary dictionaryWithObject: @"NSLabColorSpace"
forKey: GSColorSpaceName];
[space setObject: FLOAT_ARRAY(whitePoint, 3) forKey: GSColorSpaceWhitePoint];
[space setObject: FLOAT_ARRAY(blackPoint, 3) forKey: GSColorSpaceBlackPoint];
[space setObject: FLOAT_ARRAY(range, 4) forKey: GSColorSpaceRange];
[space setObject: NUMBER(3) forKey: GSColorSpaceComponents];
return space;
}
+ (CGColorSpaceRef) CGColorSpaceCreateICCBased: (size_t) nComponents
: (const float *)range
: (CGDataProviderRef)profile
: (CGColorSpaceRef)alternateSpace
{
//FIXME
return nil;
}
+ (CGColorSpaceRef) CGColorSpaceCreateIndexed: (CGColorSpaceRef)baseSpace
: (size_t)lastIndex
: (const unsigned short int *)colorTable
{
//FIXME
return nil;
}
+ (size_t) CGColorSpaceGetNumberOfComponents: (CGColorSpaceRef)cs
{
return [[(NSDictionary *)cs objectForKey: GSColorSpaceComponents] intValue];
}
+ (CGColorSpaceRef) CGColorSpaceRetain: (CGColorSpaceRef)cs
{
return [(NSDictionary *)cs retain];
}
+ (void) CGColorSpaceRelease: (CGColorSpaceRef)cs
{
return [(NSDictionary *)cs release];
}
/* Fonts */
+ (CGFontRef) CGFontReferenceFromFont: (NSFont *)font
{
return [font fontInfo];
}
+ (CGFontRef) CGFontRetain: (CGFontRef) font
{
return [(GSFontInfo *)font retain];
}
+ (void) CGFontRelease: (CGFontRef) font
{
[(GSFontInfo *)font release];
}
@end

View file

@ -265,7 +265,7 @@ NSApplication *NSApp = nil;
- (BOOL) canBecomeKeyWindow
{
return NO;
return YES;
}
- (BOOL) worksWhenModal
@ -733,17 +733,6 @@ static NSCell* tileCell = nil;
}
}
/*
* If there is no main or key window, we need to make the main menu key
* so it can respond to menu shortcuts and deactivate the app properly
* when it looses focus.
*/
if (_key_window == nil && _main_window == nil)
{
_key_window = [[self mainMenu] window];
[_key_window becomeKeyWindow];
}
/*
* If there was more than one window set as key or main, we must make sure
* that the one we have recorded is the real one by making it become key/main
@ -932,8 +921,6 @@ static NSCell* tileCell = nil;
{
_hidden_key = [self keyWindow];
[_hidden_key resignKeyWindow];
[GSServerForWindow(_app_icon_window)
setinputfocus: [_app_icon_window windowNumber]];
}
for (i = 0; i < count; i++)
{

View file

@ -38,6 +38,7 @@
#include <AppKit/NSFontManager.h>
#include <AppKit/GSFontInfo.h>
#include <AppKit/NSView.h>
#include <gnustep/gui/GSFusedSilicaContext.h>
/* We cache all the 4 default fonts after we first get them.
But when a default font is changed, the variable is set to YES
@ -700,9 +701,9 @@ setNSFont(NSString* key, NSFont* font)
NSGraphicsContext *ctxt = GSCurrentContext();
if (matrixExplicitlySet == NO && [[NSView focusView] isFlipped])
[ctxt GSSetFont: [self _flippedViewFont]];
[ctxt GSSetFont: [[self _flippedViewFont] fontRef]];
else
[ctxt GSSetFont: self];
[ctxt GSSetFont: [self fontRef]];
[ctxt useFont: fontName];
}
@ -906,6 +907,14 @@ setNSFont(NSString* key, NSFont* font)
return fontInfo;
}
- (void *) fontRef
{
if (_fontRef == nil)
_fontRef = [NSGraphicsContext CGFontReferenceFromFont: self];
return _fontRef;
}
@end

View file

@ -789,7 +789,7 @@ NSGraphicsContext *GSCurrentContext()
should have n components, where n corresponds to the number of
color components required to specify the color in the current
colorspace (Quartz). */
- (void) GSSetFillColor: (float *)values
- (void) GSSetFillColor: (const float *)values
{
[self subclassResponsibility: _cmd];
}
@ -798,7 +798,7 @@ NSGraphicsContext *GSCurrentContext()
should have n components, where n corresponds to the number of
color components required to specify the color in the current
colorspace (Quartz). */
- (void) GSSetStrokeColor: (float *)values
- (void) GSSetStrokeColor: (const float *)values
{
[self subclassResponsibility: _cmd];
}