Merge in fixes etc from trunk

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_stable_20070311@24943 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2007-03-30 03:27:57 +00:00
parent b5f57a42f9
commit 2a2ba5b79a
21 changed files with 801 additions and 280 deletions

View file

@ -1,3 +1,92 @@
2007-03-26 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSAttributedString.m: Wrap excessively long lines
* Source/externs.m: Add new attributed string constants
* Headers/AppKit/NSAttributedString.h: Add constants from current
MacOS-X
2007-03-23 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSAffineTransform.m: Simplify code slightly.
2007-03-23 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSCell.m (-drawWithFrame:inView:): Extract helper methods
for border and focus drawing.
* Source/NSButtonCell.m: Override the border drawing method.
* Source/NSMenuItemCell.m: Override the border drawing method and
set default focus ring to none.
* Source/NSPopupButtonCell.m: Set default focus ring to default.
2007-03-23 Sergii Stoian <stoyan255@gmail.com>
* Source/NSAlert.m: (-_initWithoutGModel): Set selected text
background color to [NSColor controlLightHighlightColor].
2007-03-23 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSView.m: Replace calls to the now deprecated methods on
NSAffineTransform with correct ones.
2007-03-22 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSButtonCell.m (-drawWithFrame:inView:),
* Source/NSCell.m (-drawWithFrame:inView:): Respect focus ring
style when drawing first responder state.
* Source/NSBrowserCell.m (-drawInteriorWithFrame:inView:),
* Source/NSPopupButtonCell.m (-drawInteriorWithFrame:inView:),
* Source/NSImageCell.m (-drawInteriorWithFrame:inView:): Don't
draw focus ring.
2007-03-22 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSAffineTransform.m: Avoid accessing internals of the base
library class directly. Mark many methods as deprecated.
* Headers/AppKit/NSAffineTransform.h: Mark gnustep extensions as
deprecated. Perhaps we don't want to deprecate all of them though
need feedback on that.
2007-03-21 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSView.m (-gState): Generate a gstate if one is needed
and none has been set up to now.
2007-03-19 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSPrintOperation.m (NSView -_endSheet, NSView
-_displayPageInRect:atPlacement:withInfo:): Get graphics context
from the print operation.
* Source/NSView.m (-_lockFocusInContext:inRect:): When not set,
get graphics context either from window or from the print operation.
* Source/NSView.m (-lockFocusInRect, -lockFocusIfCanDraw): Don't
set the graphics context.
* Source/NSView.m: For all print methods get the context from
the print operation.
2007-03-17 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSView.m (-setBoundsRotation:): Adjust _bounds ivar to
the rotation.
* Source/NSView.m (-translateOriginToPoint:, -rotateByAngle:):
Implemented via setBoundsOrigin: and rotateByAngle:.
* Source/NSView.m (-_lockFocusInContext:inRect:): For rotated
views compute the actual clip region instead of using _bounds.
2007-03-17 Nicola Pero <nicola.pero@meta-innovation.com>
* GNUmakefile.postamble (before-uninstall): Uninstall gui.make.
* Panels/GNUmakefile.postamble (after-uninstall): Fixed uninstall
target.
* Source/CompatibilityHeaders.make (after-install): Use
ECHO_NOTHING and END_ECHO.
(after-uninstall): New target that uninstalls the compatibility
headers.
2007-03-12 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSAffineTransform.m: Set _isIdentity for all methods
changing the matrix of the affine transform.
2007-03-11 Fred Kiefer <FredKiefer@gmx.de> 2007-03-11 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSApplication.m (-abortModal): Call stopModalWithCode: to * Source/NSApplication.m (-abortModal): Call stopModalWithCode: to

View file

@ -57,7 +57,8 @@ before-install:: $(DESTDIR)$(GNUSTEP_MAKEFILES)/Additional
# after-install:: # after-install::
# Things to do before uninstalling # Things to do before uninstalling
# before-uninstall:: before-uninstall::
rm -f $(DESTDIR)$(GNUSTEP_MAKEFILES)/Additional/gui.make
# Things to do after uninstalling # Things to do after uninstalling
# after-uninstall:: # after-uninstall::

View file

@ -41,6 +41,7 @@
@end @end
#if OS_API_VERSION(GS_API_NONE, GS_API_NONE) #if OS_API_VERSION(GS_API_NONE, GS_API_NONE)
#if GS_API_VERSION(GS_API_NONE, 011500)
@interface NSAffineTransform (GNUstep) @interface NSAffineTransform (GNUstep)
- (void) translateToPoint: (NSPoint)point; - (void) translateToPoint: (NSPoint)point;
- (void) scaleTo: (float)sx : (float)sy; - (void) scaleTo: (float)sx : (float)sy;
@ -74,5 +75,6 @@
@end @end
#endif #endif
#endif
#endif /* _GNUstep_H_NSAffineTransform */ #endif /* _GNUstep_H_NSAffineTransform */

View file

@ -0,0 +1,129 @@
/*
* NSAnimation.h
*
* Created by Dr. H. Nikolaus Schaller on Sat Jan 07 2006.
* Copyright (c) 2005 DSITRI.
*
* This file used to be part of the mySTEP Library.
* This file now is part of the GNUstep GUI Library.
*
* 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; see the file COPYING.LIB.
* If not, write to the Free Software Foundation,
* 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef _NSAnimation_h_GNUstep_
#define _NSAnimation_h_GNUstep_
#include <Foundation/Foundation.h>
typedef enum _NSAnimationCurve
{
NSAnimationEaseInOut = 0, // default
NSAnimationEaseIn,
NSAnimationEaseOut,
NSAnimationLinear
} NSAnimationCurve;
typedef enum _NSAnimationBlockingMode
{
NSAnimationBlocking,
NSAnimationNonblocking,
NSAnimationNonblockingThreaded
} NSAnimationBlockingMode;
typedef float NSAnimationProgress;
extern NSString *NSAnimationProgressMarkNotification;
@interface NSAnimation : NSObject < NSCopying, NSCoding >
{
NSAnimationBlockingMode _animationBlockingMode;
NSAnimationCurve _animationCurve;
NSAnimationProgress _currentProgress;
NSMutableArray *_progressMarks;
id _delegate;
NSTimeInterval _duration;
float _currentValue;
float _frameRate;
BOOL _isAnimating; // ?or the NSThread *
}
- (void) addProgressMark: (NSAnimationProgress) progress;
- (NSAnimationBlockingMode) animationBlockingMode;
- (NSAnimationCurve) animationCurve;
- (void) clearStartAnimation;
- (void) clearStopAnimation;
- (NSAnimationProgress) currentProgress;
- (float) currentValue;
- (id) delegate;
- (NSTimeInterval) duration;
- (float) frameRate;
- (id) initWithDuration: (NSTimeInterval) duration animationCurve:
(NSAnimationCurve) curve;
- (BOOL) isAnimating;
- (NSArray *) progressMarks;
- (void) removeProgressMark: (NSAnimationProgress) progress;
- (NSArray *) runLoopModesForAnimating;
- (void) setAnimationBlockingMode: (NSAnimationBlockingMode) mode;
- (void) setAnimationCurve: (NSAnimationCurve) curve;
- (void) setCurrentProgress: (NSAnimationProgress) progress;
- (void) setDelegate: (id) delegate;
- (void) setDuration: (NSTimeInterval) duration;
- (void) setFrameRate: (float) fps;
- (void) setProgressMarks: (NSArray *) progress;
- (void) startAnimation;
- (void) startWhenAnimation: (NSAnimation *) animation reachesProgress:
(NSAnimationProgress) start;
- (void) stopAnimation;
- (void) stopWhenAnimation: (NSAnimation *) animation reachesProgress:
(NSAnimationProgress) stop;
@end
@interface NSObject (NSAnimation)
- (void) animation: (NSAnimation *) animation didReachProgressMark:
(NSAnimationProgress) progress;
- (float) animation: (NSAnimation *) animation valueForProgress:
(NSAnimationProgress) progress;
- (void) animationDidEnd: (NSAnimation *) animation;
- (void) animationDidStop: (NSAnimation *) animation;
- (BOOL) animationShouldStart: (NSAnimation *) animation;
@end
extern NSString *NSViewAnimationTargetKey;
extern NSString *NSViewAnimationStartFrameKey;
extern NSString *NSViewAnimationEndFrameKey;
extern NSString *NSViewAnimationEffectKey;
extern NSString *NSViewAnimationFadeInEffect;
extern NSString *NSViewAnimationFadeOutEffect;
@interface NSViewAnimation : NSAnimation
{
NSArray *_viewAnimations;
}
- (id) initWithViewAnimations: (NSArray *) animations;
- (void) setWithViewAnimations: (NSArray *) animations;
- (NSArray *) viewAnimations;
@end
#endif /* _NSAnimation_h_GNUstep_ */

View file

@ -49,17 +49,26 @@
/* Global NSString attribute names used in accessing the respective /* Global NSString attribute names used in accessing the respective
property in a text attributes dictionary. if the key is not in the property in a text attributes dictionary. if the key is not in the
dictionary the default value is assumed. */ dictionary the default value is assumed. */
APPKIT_EXPORT NSString *NSFontAttributeName;
APPKIT_EXPORT NSString *NSParagraphStyleAttributeName;
APPKIT_EXPORT NSString *NSForegroundColorAttributeName;
APPKIT_EXPORT NSString *NSUnderlineStyleAttributeName;
APPKIT_EXPORT NSString *NSSuperscriptAttributeName;
APPKIT_EXPORT NSString *NSBackgroundColorAttributeName;
APPKIT_EXPORT NSString *NSAttachmentAttributeName; APPKIT_EXPORT NSString *NSAttachmentAttributeName;
APPKIT_EXPORT NSString *NSLigatureAttributeName; APPKIT_EXPORT NSString *NSBackgroundColorAttributeName;
APPKIT_EXPORT NSString *NSBaselineOffsetAttributeName; APPKIT_EXPORT NSString *NSBaselineOffsetAttributeName;
APPKIT_EXPORT NSString *NSCursorAttributeName;
APPKIT_EXPORT NSString *NSExpansionAttributeName;
APPKIT_EXPORT NSString *NSFontAttributeName;
APPKIT_EXPORT NSString *NSForegroundColorAttributeName;
APPKIT_EXPORT NSString *NSKernAttributeName; APPKIT_EXPORT NSString *NSKernAttributeName;
APPKIT_EXPORT NSString *NSLigatureAttributeName;
APPKIT_EXPORT NSString *NSLinkAttributeName; APPKIT_EXPORT NSString *NSLinkAttributeName;
APPKIT_EXPORT NSString *NSObliquenessAttributeName;
APPKIT_EXPORT NSString *NSParagraphStyleAttributeName;
APPKIT_EXPORT NSString *NSShadowAttributeName;
APPKIT_EXPORT NSString *NSStrikethroughColorAttributeName;
APPKIT_EXPORT NSString *NSStrokeColorAttributeName;
APPKIT_EXPORT NSString *NSStrokeWidthAttributeName;
APPKIT_EXPORT NSString *NSSuperscriptAttributeName;
APPKIT_EXPORT NSString *NSToolTipAttributeName;
APPKIT_EXPORT NSString *NSUnderlineColorAttributeName;
APPKIT_EXPORT NSString *NSUnderlineStyleAttributeName;
/* Currently supported values for NSUnderlineStyleAttributeName. */ /* Currently supported values for NSUnderlineStyleAttributeName. */
enum enum

View file

@ -62,7 +62,7 @@ endif
# Things to do after uninstalling # Things to do after uninstalling
after-uninstall:: after-uninstall::
ifneq ($(strip $(LOCALIZED_RESOURCE_FILES)),) ifneq ($(strip $(LOCALIZED_RESOURCE_FILES)$(LOCALIZED_RESOURCE_COMPONENTS)),)
$(ECHO_NOTHING)for l in $(LANGUAGES); do \ $(ECHO_NOTHING)for l in $(LANGUAGES); do \
if [ -d $$l.lproj ]; then \ if [ -d $$l.lproj ]; then \
rm -rf $(POSTAMBLE_INSTALL_DIR)/$$l.lproj; \ rm -rf $(POSTAMBLE_INSTALL_DIR)/$$l.lproj; \
@ -70,3 +70,4 @@ ifneq ($(strip $(LOCALIZED_RESOURCE_FILES)),)
done$(END_ECHO) done$(END_ECHO)
endif endif

View file

@ -30,20 +30,35 @@
after-install:: after-install::
@echo Installing compatibility headers... @echo Installing compatibility headers...
@OLD_DIR=AppKit; NEW_DIR=GNUstepGUI; \ $(ECHO_NOTHING)OLD_DIR=AppKit; NEW_DIR=GNUstepGUI; \
LIST="$(GUI_HEADERS)" ;\ LIST="$(GUI_HEADERS)" ;\
$(MKDIRS) $(GNUSTEP_HEADERS)/$$OLD_DIR; \ $(MKDIRS) $(GNUSTEP_HEADERS)/$$OLD_DIR; \
for I in $$LIST ; do \ for I in $$LIST ; do \
(echo "#warning $$I is now included using the path <$$NEW_DIR/$$I>";\ (echo "#warning $$I is now included using the path <$$NEW_DIR/$$I>";\
echo "#include <$$NEW_DIR/$$I>" ) \ echo "#include <$$NEW_DIR/$$I>" ) \
> $(GNUSTEP_HEADERS)/$$OLD_DIR/$$I; \ > $(GNUSTEP_HEADERS)/$$OLD_DIR/$$I; \
done done$(END_ECHO)
@OLD_DIR=gnustep/gui; NEW_DIR=GNUstepGUI; \ $(ECHO_NOTHING)OLD_DIR=gnustep/gui; NEW_DIR=GNUstepGUI; \
LIST="$(GUI_HEADERS)" ;\ LIST="$(GUI_HEADERS)" ;\
$(MKDIRS) $(GNUSTEP_HEADERS)/$$OLD_DIR; \ $(MKDIRS) $(GNUSTEP_HEADERS)/$$OLD_DIR; \
for I in $$LIST ; do \ for I in $$LIST ; do \
(echo "#warning $$I is now included using the path <$$NEW_DIR/$$I>";\ (echo "#warning $$I is now included using the path <$$NEW_DIR/$$I>";\
echo "#include <$$NEW_DIR/$$I>" ) \ echo "#include <$$NEW_DIR/$$I>" ) \
> $(GNUSTEP_HEADERS)/$$OLD_DIR/$$I; \ > $(GNUSTEP_HEADERS)/$$OLD_DIR/$$I; \
done done$(END_ECHO)
after-uninstall::
@echo Uninstalling compatibility headers...
$(ECHO_NOTHING)OLD_DIR=AppKit; \
LIST="$(GUI_HEADERS)" ;\
for I in $$LIST ; do \
rm -f $(GNUSTEP_HEADERS)/$$OLD_DIR/$$I; \
done$(END_ECHO)
$(ECHO_NOTHING)OLD_DIR=gnustep/gui; \
LIST="$(GUI_HEADERS)" ;\
for I in $$LIST ; do \
rm -f $(GNUSTEP_HEADERS)/$$OLD_DIR/$$I; \
done$(END_ECHO)

View file

@ -50,6 +50,7 @@ libgnustep-gui_OBJC_FILES = Functions.m \
NSActionCell.m \ NSActionCell.m \
NSAffineTransform.m \ NSAffineTransform.m \
NSAlert.m \ NSAlert.m \
NSAnimation.m \
NSApplication.m \ NSApplication.m \
NSArrayController.m \ NSArrayController.m \
NSAttributedString.m \ NSAttributedString.m \
@ -234,6 +235,7 @@ AppKitExceptions.h \
NSActionCell.h \ NSActionCell.h \
NSAffineTransform.h \ NSAffineTransform.h \
NSAlert.h \ NSAlert.h \
NSAnimation.h \
NSApplication.h \ NSApplication.h \
NSArrayController.h \ NSArrayController.h \
NSBezierPath.h \ NSBezierPath.h \

View file

@ -40,13 +40,7 @@
#include "AppKit/NSBezierPath.h" #include "AppKit/NSBezierPath.h"
#include "AppKit/PSOperators.h" #include "AppKit/PSOperators.h"
typedef struct internal
{
@defs(NSAffineTransform)
} *iptr;
/* Private definitions */ /* Private definitions */
#define matrix (((iptr)self)->_matrix)
#define A matrix.m11 #define A matrix.m11
#define B matrix.m12 #define B matrix.m12
#define C matrix.m21 #define C matrix.m21
@ -64,24 +58,6 @@ typedef struct internal
static const float pi = 3.1415926535897932384626434; static const float pi = 3.1415926535897932384626434;
/* Quick function to multiply two coordinate matrices. C = AB */
static inline NSAffineTransformStruct
matrix_multiply (NSAffineTransformStruct MA, NSAffineTransformStruct MB)
{
NSAffineTransformStruct MC;
MC.m11 = MA.m11 * MB.m11 + MA.m12 * MB.m21;
MC.m12 = MA.m11 * MB.m12 + MA.m12 * MB.m22;
MC.m21 = MA.m21 * MB.m11 + MA.m22 * MB.m21;
MC.m22 = MA.m21 * MB.m12 + MA.m22 * MB.m22;
MC.tX = MA.tX * MB.m11 + MA.tY * MB.m21 + MB.tX;
MC.tY = MA.tX * MB.m12 + MA.tY * MB.m22 + MB.tY;
return MC;
}
static NSAffineTransformStruct identityTransform = {
1.0, 0.0, 0.0, 1.0, 0.0, 0.0
};
@implementation NSAffineTransform (GUIAdditions) @implementation NSAffineTransform (GUIAdditions)
/** /**
@ -90,14 +66,9 @@ static NSAffineTransformStruct identityTransform = {
*/ */
- (void) concat - (void) concat
{ {
float m[6]; NSAffineTransformStruct matrix = [self transformStruct];
m[0] = matrix.m11;
m[1] = matrix.m12; PSconcat((float*)&matrix);
m[2] = matrix.m21;
m[3] = matrix.m22;
m[4] = matrix.tX;
m[5] = matrix.tY;
PSconcat(m);
} }
@ -130,6 +101,8 @@ static NSAffineTransformStruct identityTransform = {
- (void) scaleTo: (float)sx : (float)sy - (void) scaleTo: (float)sx : (float)sy
{ {
NSAffineTransformStruct matrix = [self transformStruct];
/* If it's rotated. */ /* If it's rotated. */
if (B != 0 || C != 0) if (B != 0 || C != 0)
{ {
@ -145,26 +118,34 @@ static NSAffineTransformStruct identityTransform = {
A = sx; B = 0; A = sx; B = 0;
C = 0; D = sy; C = 0; D = sy;
} }
[self setTransformStruct: matrix];
} }
- (void) translateToPoint: (NSPoint)point - (void) translateToPoint: (NSPoint)point
{ {
NSAffineTransformStruct matrix = [self transformStruct];
float newTX, newTY; float newTX, newTY;
newTX = point.x * A + point.y * C + TX; newTX = point.x * A + point.y * C + TX;
newTY = point.x * B + point.y * D + TY; newTY = point.x * B + point.y * D + TY;
TX = newTX; TX = newTX;
TY = newTY; TY = newTY;
[self setTransformStruct: matrix];
} }
- (void) makeIdentityMatrix - (void) makeIdentityMatrix
{ {
matrix = identityTransform; static NSAffineTransformStruct identityTransform = {
1.0, 0.0, 0.0, 1.0, 0.0, 0.0
};
[self setTransformStruct: identityTransform];
} }
- (void) setFrameOrigin: (NSPoint)point - (void) setFrameOrigin: (NSPoint)point
{ {
NSAffineTransformStruct matrix = [self transformStruct];
float dx = point.x - TX; float dx = point.x - TX;
float dy = point.y - TY; float dy = point.y - TY;
[self translateToPoint: NSMakePoint(dx, dy)]; [self translateToPoint: NSMakePoint(dx, dy)];
@ -177,7 +158,9 @@ static NSAffineTransformStruct identityTransform = {
- (float) rotationAngle - (float) rotationAngle
{ {
NSAffineTransformStruct matrix = [self transformStruct];
float rotationAngle = atan2(-C, A); float rotationAngle = atan2(-C, A);
rotationAngle *= 180.0 / pi; rotationAngle *= 180.0 / pi;
if (rotationAngle < 0.0) if (rotationAngle < 0.0)
rotationAngle += 360.0; rotationAngle += 360.0;
@ -187,28 +170,38 @@ static NSAffineTransformStruct identityTransform = {
- (void) concatenateWith: (NSAffineTransform*)anotherMatrix - (void) concatenateWith: (NSAffineTransform*)anotherMatrix
{ {
GSOnceMLog(@"deprecated ... use -prependTransform:");
[self prependTransform: anotherMatrix]; [self prependTransform: anotherMatrix];
} }
- (void) concatenateWithMatrix: (const float[6])anotherMatrix - (void) concatenateWithMatrix: (const float[6])anotherMatrix
{ {
NSAffineTransformStruct amat; NSAffineTransformStruct amat;
NSAffineTransform *other;
GSOnceMLog(@"deprecated ... use -prependTransform:");
amat.m11 = anotherMatrix[0]; amat.m11 = anotherMatrix[0];
amat.m12 = anotherMatrix[1]; amat.m12 = anotherMatrix[1];
amat.m21 = anotherMatrix[2]; amat.m21 = anotherMatrix[2];
amat.m22 = anotherMatrix[3]; amat.m22 = anotherMatrix[3];
amat.tX = anotherMatrix[4]; amat.tX = anotherMatrix[4];
amat.tY = anotherMatrix[5]; amat.tY = anotherMatrix[5];
matrix = matrix_multiply(amat, matrix); other = [NSAffineTransform new];
[other setTransformStruct: amat];
[self prependTransform: other];
RELEASE(other);
} }
- (void)inverse - (void)inverse
{ {
GSOnceMLog(@"deprecated ... use -invert:");
[self invert]; [self invert];
} }
- (BOOL) isRotated - (BOOL) isRotated
{ {
NSAffineTransformStruct matrix = [self transformStruct];
if (B == 0 && C == 0) if (B == 0 && C == 0)
{ {
return NO; return NO;
@ -221,6 +214,7 @@ static NSAffineTransformStruct identityTransform = {
- (void) boundingRectFor: (NSRect)rect result: (NSRect*)newRect - (void) boundingRectFor: (NSRect)rect result: (NSRect*)newRect
{ {
NSAffineTransformStruct matrix = [self transformStruct];
/* Shortcuts of the usual rect values */ /* Shortcuts of the usual rect values */
float x = rect.origin.x; float x = rect.origin.x;
float y = rect.origin.y; float y = rect.origin.y;
@ -267,16 +261,13 @@ static NSAffineTransformStruct identityTransform = {
- (NSPoint) pointInMatrixSpace: (NSPoint)point - (NSPoint) pointInMatrixSpace: (NSPoint)point
{ {
NSPoint new; GSOnceMLog(@"deprecated ... use -transformPoint:");
return [self transformPoint: point];
new.x = A * point.x + C * point.y + TX;
new.y = B * point.x + D * point.y + TY;
return new;
} }
- (NSPoint) deltaPointInMatrixSpace: (NSPoint)point - (NSPoint) deltaPointInMatrixSpace: (NSPoint)point
{ {
NSAffineTransformStruct matrix = [self transformStruct];
NSPoint new; NSPoint new;
new.x = A * point.x + C * point.y; new.x = A * point.x + C * point.y;
@ -287,20 +278,13 @@ static NSAffineTransformStruct identityTransform = {
- (NSSize) sizeInMatrixSpace: (NSSize)size - (NSSize) sizeInMatrixSpace: (NSSize)size
{ {
NSSize new; GSOnceMLog(@"deprecated ... use -transformSize:");
return [self transformSize: size];
new.width = A * size.width + C * size.height;
if (new.width < 0)
new.width = - new.width;
new.height = B * size.width + D * size.height;
if (new.height < 0)
new.height = - new.height;
return new;
} }
- (NSRect) rectInMatrixSpace: (NSRect)rect - (NSRect) rectInMatrixSpace: (NSRect)rect
{ {
NSAffineTransformStruct matrix = [self transformStruct];
NSRect new; NSRect new;
new.origin.x = A * rect.origin.x + C * rect.origin.y + TX; new.origin.x = A * rect.origin.x + C * rect.origin.y + TX;
@ -324,16 +308,23 @@ static NSAffineTransformStruct identityTransform = {
- (void) setMatrix: (const float[6])replace - (void) setMatrix: (const float[6])replace
{ {
NSAffineTransformStruct matrix;
GSOnceMLog(@"deprecated ... use -setTransformStruct:");
matrix.m11 = replace[0]; matrix.m11 = replace[0];
matrix.m12 = replace[1]; matrix.m12 = replace[1];
matrix.m21 = replace[2]; matrix.m21 = replace[2];
matrix.m22 = replace[3]; matrix.m22 = replace[3];
matrix.tX = replace[4]; matrix.tX = replace[4];
matrix.tY = replace[5]; matrix.tY = replace[5];
[self setTransformStruct: matrix];
} }
- (void) getMatrix: (float[6])replace - (void) getMatrix: (float[6])replace
{ {
NSAffineTransformStruct matrix = [self transformStruct];
GSOnceMLog(@"deprecated ... use -transformStruct");
replace[0] = matrix.m11; replace[0] = matrix.m11;
replace[1] = matrix.m12; replace[1] = matrix.m12;
replace[2] = matrix.m21; replace[2] = matrix.m21;
@ -344,7 +335,11 @@ static NSAffineTransformStruct identityTransform = {
- (void) takeMatrixFromTransform: (NSAffineTransform *)aTransform - (void) takeMatrixFromTransform: (NSAffineTransform *)aTransform
{ {
NSAffineTransformStruct matrix;
GSOnceMLog(@"deprecated ... use -transformStruct and setTransformStruct:");
matrix = [aTransform transformStruct]; matrix = [aTransform transformStruct];
[self setTransformStruct: matrix];
} }

View file

@ -407,7 +407,7 @@ setControl(NSView* content, id control, NSString *title)
be selectable for a copy-and-paste. Hence, setSelectable: YES. be selectable for a copy-and-paste. Hence, setSelectable: YES.
*/ */
selectedAttrs = [NSDictionary dictionaryWithObjectsAndKeys: selectedAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
[NSColor whiteColor], [NSColor controlLightHighlightColor],
NSBackgroundColorAttributeName, NSBackgroundColorAttributeName,
nil]; nil];
[(NSTextView *)fieldEditor setSelectedTextAttributes: selectedAttrs]; [(NSTextView *)fieldEditor setSelectedTextAttributes: selectedAttrs];

241
Source/NSAnimation.m Normal file
View file

@ -0,0 +1,241 @@
/*
* NSAnimation.m
*
* Created by Dr. H. Nikolaus Schaller on Sat Mar 06 2006.
* Copyright (c) 2005 DSITRI.
*
* This file used to be part of the mySTEP Library.
* This file now is part of the GNUstep GUI Library.
*
* 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; see the file COPYING.LIB.
* If not, write to the Free Software Foundation,
* 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <AppKit/NSAnimation.h>
NSString *NSAnimationProgressMarkNotification
= @"NSAnimationProgressMarkNotification";
NSString *NSViewAnimationTargetKey = @"NSViewAnimationTargetKey";
NSString *NSViewAnimationStartFrameKey = @"NSViewAnimationStartFrameKey";
NSString *NSViewAnimationEndFrameKey = @"NSViewAnimationEndFrameKey";
NSString *NSViewAnimationEffectKey = @"NSViewAnimationEffectKey";
NSString *NSViewAnimationFadeInEffect = @"NSViewAnimationFadeInEffect";
NSString *NSViewAnimationFadeOutEffect = @"NSViewAnimationFadeOutEffect";
@implementation NSAnimation
- (void) addProgressMark: (NSAnimationProgress) progress
{
[self notImplemented: _cmd];
}
- (NSAnimationBlockingMode) animationBlockingMode
{
return _animationBlockingMode;
}
- (NSAnimationCurve) animationCurve
{
return _animationCurve;
}
- (void) clearStartAnimation
{
[self notImplemented: _cmd];
}
- (void) clearStopAnimation
{
[self notImplemented: _cmd];
}
- (NSAnimationProgress) currentProgress
{
return _currentProgress;
}
- (float) currentValue
{
return _currentValue;
}
- (id) delegate
{
return _delegate;
}
- (NSTimeInterval) duration
{
return _duration;
}
- (float) frameRate
{
return _frameRate;
}
- (id) initWithDuration: (NSTimeInterval) duration animationCurve:
(NSAnimationCurve) curve
{
if ((self = [super init]))
{
_duration = duration;
_animationCurve = curve;
}
return self;
}
- (id) copyWithZone: (NSZone *) zone
{
return [self notImplemented: _cmd];
}
- (void) dealloc
{
[_progressMarks release];
[super dealloc];
}
- (BOOL) isAnimating
{
return _isAnimating;
}
- (NSArray *) progressMarks
{
return _progressMarks;
}
- (void) removeProgressMark: (NSAnimationProgress) progress
{
[self notImplemented: _cmd];
}
- (NSArray *) runLoopModesForAnimating
{
return nil;
}
- (void) setAnimationBlockingMode: (NSAnimationBlockingMode) mode
{
_animationBlockingMode = mode;
}
- (void) setAnimationCurve: (NSAnimationCurve) curve
{
_animationCurve = curve;
}
- (void) setCurrentProgress: (NSAnimationProgress) progress
{
_currentProgress = progress;
}
- (void) setDelegate: (id) delegate
{
_delegate = delegate;
}
- (void) setDuration: (NSTimeInterval) duration
{
_duration = duration;
}
- (void) setFrameRate: (float) fps
{
_frameRate = fps;
}
- (void) setProgressMarks: (NSArray *) progress
{
ASSIGN(_progressMarks, progress) ;
}
- (void) _animate
{
[self notImplemented: _cmd];
// call delegate
// estimate delay to keep fps
// create new timer
}
- (void) startAnimation
{
_isAnimating = YES;
[self _animate];
}
- (void) startWhenAnimation: (NSAnimation *) animation reachesProgress:
(NSAnimationProgress) start
{
[self notImplemented: _cmd];
}
- (void) stopAnimation
{
[self notImplemented: _cmd];
// remove any timer
_isAnimating = NO;
}
- (void) stopWhenAnimation: (NSAnimation *) animation reachesProgress:
(NSAnimationProgress) stop
{
[self notImplemented: _cmd];
}
- (void) encodeWithCoder: (NSCoder *) coder
{
[self notImplemented: _cmd];
}
- (id) initWithCoder: (NSCoder *) coder
{
return [self notImplemented: _cmd];
}
@end
@implementation NSViewAnimation
- (id) initWithViewAnimations: (NSArray *) animations
{
if ((self = [super init]))
{
_viewAnimations = [animations retain];
}
return self;
}
- (void) dealloc
{
[_viewAnimations release];
[super dealloc];
}
- (void) setWithViewAnimations: (NSArray *) animations
{
ASSIGN(_viewAnimations, animations) ;
}
- (NSArray *) viewAnimations
{
return _viewAnimations;
}
@end

View file

@ -152,9 +152,15 @@ Class converter_bundles(NSString *format, BOOL producer)
{ {
NSString *converter_name; NSString *converter_name;
if (producer) if (producer)
converter_name = [format stringByAppendingString: @"Producer"]; {
converter_name
= [format stringByAppendingString: @"Producer"];
}
else else
converter_name = [format stringByAppendingString: @"Consumer"]; {
converter_name
= [format stringByAppendingString: @"Consumer"];
}
converter_class = [aBundle classNamed: converter_name]; converter_class = [aBundle classNamed: converter_name];
} }
} }
@ -355,7 +361,7 @@ static Class converter_class(NSString *format, BOOL producer)
if (NSMaxRange (aRange) > length || location > length) if (NSMaxRange (aRange) > length || location > length)
{ {
[NSException raise: NSRangeException [NSException raise: NSRangeException
format: @"RangeError in method -lineBreakBeforeIndex: withinRange: "]; format: @"RangeError in method -lineBreakBeforeIndex: withinRange: "];
} }
if (!NSLocationInRange (location, aRange)) if (!NSLocationInRange (location, aRange))
@ -485,7 +491,7 @@ static Class converter_class(NSString *format, BOOL producer)
if (location > length) if (location > length)
{ {
[NSException raise: NSRangeException [NSException raise: NSRangeException
format: @"RangeError in method -nextWordFromIndex: forward: "]; format: @"RangeError in method -nextWordFromIndex: forward: "];
} }
/* Please note that we consider ' a valid word separator. This is /* Please note that we consider ' a valid word separator. This is
@ -906,7 +912,7 @@ documentAttributes: (NSDictionary **)dict
if (NSMaxRange (range) > [self length]) if (NSMaxRange (range) > [self length])
{ {
[NSException raise: NSRangeException [NSException raise: NSRangeException
format: @"RangeError in method -fixParagraphStyleAttributeInRange: "]; format: @"RangeError in method -fixParagraphStyleAttributeInRange: "];
} }
while (loc < NSMaxRange (range)) while (loc < NSMaxRange (range))

View file

@ -323,9 +323,6 @@ static NSFont *_leafFont;
// Draw the body of the cell // Draw the body of the cell
[self _drawAttributedText: [self attributedStringValue] [self _drawAttributedText: [self attributedStringValue]
inFrame: title_rect]; inFrame: title_rect];
if (_cell.shows_first_responder == YES)
NSDottedFrameRect(cellFrame);
} }
- (BOOL) isOpaque - (BOOL) isOpaque

View file

@ -920,37 +920,13 @@ typedef struct _GSButtonCellFlags
inFrame: frame]; inFrame: frame];
} }
// Private helper method overridden in subclasses
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView - (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
{ {
// Save last view drawn to
if (_control_view != controlView)
_control_view = controlView;
// transparent buttons never draw
if (_buttoncell_is_transparent)
return;
// do nothing if cell's frame rect is zero
if (NSIsEmptyRect(cellFrame))
return;
// draw the border if needed
if ((_cell.is_bordered) if ((_cell.is_bordered)
&& (!_shows_border_only_while_mouse_inside || _mouse_inside)) && (!_shows_border_only_while_mouse_inside || _mouse_inside))
{ {
[self drawBezelWithFrame: cellFrame inView: controlView]; [self drawBezelWithFrame: cellFrame inView: controlView];
}
[self drawInteriorWithFrame: cellFrame inView: controlView];
// Draw first responder
if (_cell.shows_first_responder
&& [[controlView window] firstResponder] == controlView)
{
// FIXME: Should depend on _cell.focus_ring_type
[[GSTheme theme] drawFocusFrame: [self drawingRectForBounds: cellFrame]
view: controlView];
} }
} }

View file

@ -1994,15 +1994,9 @@ static NSColor *shadowCol;
// prettyfying // prettyfying
} }
/**<p>Draws the cell in <var>controlView</var></p> // Private helper method overridden in subclasses
*/ - (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
{ {
// do nothing if cell's frame rect is zero
if (NSIsEmptyRect(cellFrame))
return;
// draw the border if needed
if (_cell.is_bordered) if (_cell.is_bordered)
{ {
[shadowCol set]; [shadowCol set];
@ -2012,19 +2006,48 @@ static NSColor *shadowCol;
{ {
[[GSTheme theme] drawWhiteBezel: cellFrame withClip: NSZeroRect]; [[GSTheme theme] drawWhiteBezel: cellFrame withClip: NSZeroRect];
} }
}
[self drawInteriorWithFrame: cellFrame inView: controlView]; // Private helper method
- (void) _drawFocusRingWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
// Draw first responder {
if (_cell.shows_first_responder if (_cell.shows_first_responder
&& [[controlView window] firstResponder] == controlView) && [[controlView window] firstResponder] == controlView)
{ {
// FIXME: Should depend on _cell.focus_ring_type switch (_cell.focus_ring_type)
[[GSTheme theme] drawFocusFrame: [self drawingRectForBounds: cellFrame] {
view: controlView]; case NSFocusRingTypeDefault:
[[GSTheme theme] drawFocusFrame: [self drawingRectForBounds:
cellFrame]
view: controlView];
break;
case NSFocusRingTypeExterior:
[[GSTheme theme] drawFocusFrame: cellFrame
view: controlView];
break;
case NSFocusRingTypeNone:
default:
break;
}
} }
} }
/**<p>Draws the cell in <var>controlView</var></p>
*/
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
{
// do nothing if cell's frame rect is zero
if (NSIsEmptyRect(cellFrame))
return;
// draw the border if needed
[self _drawBorderAndBackgroundWithFrame: cellFrame inView: controlView];
// draw interior
[self drawInteriorWithFrame: cellFrame inView: controlView];
// Draw first responder
[self _drawFocusRingWithFrame: cellFrame inView: controlView];
}
/**<p>Sets whether the NSCell is highlighted.</p> /**<p>Sets whether the NSCell is highlighted.</p>
<p>See Also: -isHighlighted</p> <p>See Also: -isHighlighted</p>
*/ */

View file

@ -301,9 +301,6 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
realImageSize.height) realImageSize.height)
operation: NSCompositeSourceOver operation: NSCompositeSourceOver
fraction: 1.0]; fraction: 1.0];
if (_cell.shows_first_responder)
NSDottedFrameRect(cellFrame);
} }
- (NSSize) cellSize - (NSSize) cellSize

View file

@ -59,6 +59,11 @@ static NSImage *arrowImage = nil; /* Cache arrow image. */
} }
} }
+ (NSFocusRingType) defaultFocusRingType
{
return NSFocusRingTypeNone;
}
- (id) init - (id) init
{ {
[super init]; [super init];
@ -742,24 +747,9 @@ static NSImage *arrowImage = nil; /* Cache arrow image. */
} }
} }
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView - (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
{ {
// Save last view drawn to
if (_control_view != controlView)
_control_view = controlView;
// Transparent buttons never draw
if (_buttoncell_is_transparent)
return;
// Do nothing if cell's frame rect is zero
if (NSIsEmptyRect(cellFrame))
return;
// Draw the border if needed
[self drawBorderAndBackgroundWithFrame: cellFrame inView: controlView]; [self drawBorderAndBackgroundWithFrame: cellFrame inView: controlView];
[self drawInteriorWithFrame: cellFrame inView: controlView];
} }
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView - (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView

View file

@ -56,6 +56,11 @@ static NSImage *_pbc_image[2];
return YES; return YES;
} }
+ (NSFocusRingType) defaultFocusRingType
{
return NSFocusRingTypeDefault;
}
// Initialization // Initialization
/** /**
* Initialize a blank cell. * Initialize a blank cell.
@ -888,12 +893,6 @@ static NSImage *_pbc_image[2];
[self calcSize]; [self calcSize];
[super drawInteriorWithFrame: cellFrame inView: controlView]; [super drawInteriorWithFrame: cellFrame inView: controlView];
if (_cell.shows_first_responder)
{
cellFrame = [self drawingRectForBounds: cellFrame];
NSDottedFrameRect(cellFrame);
}
/* Unset the item to restore balance if a new was created */ /* Unset the item to restore balance if a new was created */
if (new) if (new)
{ {

View file

@ -1063,8 +1063,8 @@ scaleRect(NSRect rect, double scale)
int currentPage; int currentPage;
float xoffset, yoffset, scale; float xoffset, yoffset, scale;
NSString *label; NSString *label;
NSGraphicsContext *ctxt = GSCurrentContext();
NSPrintOperation *printOp = [NSPrintOperation currentOperation]; NSPrintOperation *printOp = [NSPrintOperation currentOperation];
NSGraphicsContext *ctxt = [printOp context];
currentPage = [printOp currentPage]; currentPage = [printOp currentPage];
@ -1141,12 +1141,13 @@ scaleRect(NSRect rect, double scale)
- (void) _endSheet - (void) _endSheet
{ {
NSGraphicsContext *ctxt = GSCurrentContext();
NSPrintOperation *printOp = [NSPrintOperation currentOperation]; NSPrintOperation *printOp = [NSPrintOperation currentOperation];
NSGraphicsContext *ctxt = [printOp context];
if ([printOp isEPSOperation] == NO) if ([printOp isEPSOperation] == NO)
DPSPrintf(ctxt, "showpage\n"); DPSPrintf(ctxt, "showpage\n");
DPSPrintf(ctxt, "%%%%PageTrailer\n"); DPSPrintf(ctxt, "%%%%PageTrailer\n");
DPSPrintf(ctxt, "\n"); DPSPrintf(ctxt, "\n");
} }
@end
@end

View file

@ -53,6 +53,7 @@
#include "AppKit/NSAffineTransform.h" #include "AppKit/NSAffineTransform.h"
#include "AppKit/NSApplication.h" #include "AppKit/NSApplication.h"
#include "AppKit/NSBezierPath.h"
#include "AppKit/NSCursor.h" #include "AppKit/NSCursor.h"
#include "AppKit/NSDocumentController.h" #include "AppKit/NSDocumentController.h"
#include "AppKit/NSDocument.h" #include "AppKit/NSDocument.h"
@ -971,22 +972,6 @@ GSSetDragTypes(NSView* obj, NSArray *types)
- (void) willRemoveSubview: (NSView *)subview - (void) willRemoveSubview: (NSView *)subview
{} {}
- (void) rotateByAngle: (float)angle
{
if (_coordinates_valid)
{
(*invalidateImp)(self, invalidateSel);
}
[_boundsMatrix rotateByDegrees: angle];
_is_rotated_from_base = _is_rotated_or_scaled_from_base = YES;
if (_post_bounds_changes)
{
[nc postNotificationName: NSViewBoundsDidChangeNotification
object: self];
}
}
- (void) _updateBoundsMatrix - (void) _updateBoundsMatrix
{ {
float sx; float sx;
@ -1243,12 +1228,11 @@ GSSetDragTypes(NSView* obj, NSArray *types)
- (void) setBoundsOrigin: (NSPoint)newOrigin - (void) setBoundsOrigin: (NSPoint)newOrigin
{ {
_bounds.origin = newOrigin;
if (_coordinates_valid) if (_coordinates_valid)
{ {
(*invalidateImp)(self, invalidateSel); (*invalidateImp)(self, invalidateSel);
} }
_bounds.origin = newOrigin;
[_boundsMatrix setFrameOrigin: NSMakePoint(-newOrigin.x, -newOrigin.y)]; [_boundsMatrix setFrameOrigin: NSMakePoint(-newOrigin.x, -newOrigin.y)];
if (_post_bounds_changes) if (_post_bounds_changes)
@ -1287,12 +1271,19 @@ GSSetDragTypes(NSView* obj, NSArray *types)
- (void) setBoundsRotation: (float)angle - (void) setBoundsRotation: (float)angle
{ {
NSAffineTransform *matrix;
if (_coordinates_valid) if (_coordinates_valid)
{ {
(*invalidateImp)(self, invalidateSel); (*invalidateImp)(self, invalidateSel);
} }
[_boundsMatrix setFrameRotation: angle]; [_boundsMatrix rotateByDegrees: angle - [_boundsMatrix rotationAngle]];
_is_rotated_from_base = _is_rotated_or_scaled_from_base = YES; _is_rotated_from_base = _is_rotated_or_scaled_from_base = YES;
// Adjust bounds
matrix = [_boundsMatrix copy];
[matrix invert];
[matrix boundingRectFor: _frame result: &_bounds];
RELEASE(matrix);
if (_post_bounds_changes) if (_post_bounds_changes)
{ {
@ -1303,17 +1294,13 @@ GSSetDragTypes(NSView* obj, NSArray *types)
- (void) translateOriginToPoint: (NSPoint)point - (void) translateOriginToPoint: (NSPoint)point
{ {
if (_coordinates_valid) [self setBoundsOrigin: NSMakePoint(NSMinX(_bounds) - point.x,
{ NSMinY(_bounds) - point.y)];
(*invalidateImp)(self, invalidateSel); }
}
[_boundsMatrix translateToPoint: point];
if (_post_bounds_changes) - (void) rotateByAngle: (float)angle
{ {
[nc postNotificationName: NSViewBoundsDidChangeNotification [self setBoundsRotation: [self boundsRotation] + angle];
object: self];
}
} }
- (NSRect) centerScanRect: (NSRect)aRect - (NSRect) centerScanRect: (NSRect)aRect
@ -1326,8 +1313,8 @@ GSSetDragTypes(NSView* obj, NSArray *types)
* Plus - this is all pretty meaningless is we are not in a window! * Plus - this is all pretty meaningless is we are not in a window!
*/ */
matrix = [self _matrixToWindow]; matrix = [self _matrixToWindow];
aRect.origin = [matrix pointInMatrixSpace: aRect.origin]; aRect.origin = [matrix transformPoint: aRect.origin];
aRect.size = [matrix sizeInMatrixSpace: aRect.size]; aRect.size = [matrix transformSize: aRect.size];
aRect.origin.x = floor(aRect.origin.x); aRect.origin.x = floor(aRect.origin.x);
aRect.origin.y = floor(aRect.origin.y); aRect.origin.y = floor(aRect.origin.y);
@ -1335,8 +1322,8 @@ GSSetDragTypes(NSView* obj, NSArray *types)
aRect.size.height = floor(aRect.size.height); aRect.size.height = floor(aRect.size.height);
matrix = [self _matrixFromWindow]; matrix = [self _matrixFromWindow];
aRect.origin = [matrix pointInMatrixSpace: aRect.origin]; aRect.origin = [matrix transformPoint: aRect.origin];
aRect.size = [matrix sizeInMatrixSpace: aRect.size]; aRect.size = [matrix transformSize: aRect.size];
return aRect; return aRect;
} }
@ -1353,7 +1340,7 @@ GSSetDragTypes(NSView* obj, NSArray *types)
NSAssert(_window == [aView window], NSInvalidArgumentException); NSAssert(_window == [aView window], NSInvalidArgumentException);
matrix = [aView _matrixToWindow]; matrix = [aView _matrixToWindow];
new = [matrix pointInMatrixSpace: aPoint]; new = [matrix transformPoint: aPoint];
if (_coordinates_valid) if (_coordinates_valid)
{ {
@ -1363,7 +1350,7 @@ GSSetDragTypes(NSView* obj, NSArray *types)
{ {
matrix = [self _matrixFromWindow]; matrix = [self _matrixFromWindow];
} }
new = [matrix pointInMatrixSpace: new]; new = [matrix transformPoint: new];
return new; return new;
} }
@ -1391,9 +1378,9 @@ GSSetDragTypes(NSView* obj, NSArray *types)
{ {
matrix = [self _matrixToWindow]; matrix = [self _matrixToWindow];
} }
new = [matrix pointInMatrixSpace: aPoint]; new = [matrix transformPoint: aPoint];
matrix = [aView _matrixFromWindow]; matrix = [aView _matrixFromWindow];
new = [matrix pointInMatrixSpace: new]; new = [matrix transformPoint: new];
return new; return new;
} }
@ -1415,12 +1402,12 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
p[3].y += aRect.size.height; p[3].y += aRect.size.height;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
p[i] = [matrix1 pointInMatrixSpace: p[i]]; p[i] = [matrix1 transformPoint: p[i]];
min = max = p[0] = [matrix2 pointInMatrixSpace: p[0]]; min = max = p[0] = [matrix2 transformPoint: p[0]];
for (i = 1; i < 4; i++) for (i = 1; i < 4; i++)
{ {
p[i] = [matrix2 pointInMatrixSpace: p[i]]; p[i] = [matrix2 transformPoint: p[i]];
min.x = MIN(min.x, p[i].x); min.x = MIN(min.x, p[i].x);
min.y = MIN(min.y, p[i].y); min.y = MIN(min.y, p[i].y);
max.x = MAX(max.x, p[i].x); max.x = MAX(max.x, p[i].x);
@ -1521,7 +1508,7 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
} }
NSAssert(_window == [aView window], NSInvalidArgumentException); NSAssert(_window == [aView window], NSInvalidArgumentException);
matrix = [aView _matrixToWindow]; matrix = [aView _matrixToWindow];
new = [matrix sizeInMatrixSpace: aSize]; new = [matrix transformSize: aSize];
if (_coordinates_valid) if (_coordinates_valid)
{ {
@ -1531,7 +1518,7 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
{ {
matrix = [self _matrixFromWindow]; matrix = [self _matrixFromWindow];
} }
new = [matrix sizeInMatrixSpace: new]; new = [matrix transformSize: new];
return new; return new;
} }
@ -1558,10 +1545,10 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
{ {
matrix = [self _matrixToWindow]; matrix = [self _matrixToWindow];
} }
new = [matrix sizeInMatrixSpace: aSize]; new = [matrix transformSize: aSize];
matrix = [aView _matrixFromWindow]; matrix = [aView _matrixFromWindow];
new = [matrix sizeInMatrixSpace: new]; new = [matrix transformSize: new];
return new; return new;
} }
@ -1694,68 +1681,7 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
[self setFrame: newFrame]; [self setFrame: newFrame];
} }
/** - (void) _lockFocusInContext: (NSGraphicsContext *)ctxt inRect: (NSRect)rect
<p> Tell the view to maintain a private gstate object which
encapsulates all the information about drawing, such as coordinate
transforms, line widths, etc. If you do not invoke this method, a
gstate object is constructed each time the view is lockFocused.
Allocating a private gstate may improve the performance of views
that are focused a lot and have a lot of customized drawing
parameters. </p>
<p> View subclasses should override the
setUpGstate method to set these custom parameters.
</p>
*/
- (void) allocateGState
{
// FIXME: This should create an actual gState
_allocate_gstate = 1;
_renew_gstate = 1;
}
/**
Frees the gstate object, if there is one.
*/
- (void) releaseGState
{
if (_allocate_gstate && _gstate)
GSUndefineGState(GSCurrentContext(), _gstate);
_gstate = 0;
_allocate_gstate = 0;
}
/**
Returns an identifier that represents the view's gstate object,
which is used to encapsulate drawing information about the view.
Most of the time a gstate object is created from scratch when the
view is focused, so if the view is not currently focused or
allocateGState has not been called, then this method will return 0.
FIXME: The above is what the OpenStep and Cocoa specification say, but
gState is 0 unless allocateGState has been called.
*/
- (int) gState
{
return _gstate;
}
/**
Invalidates the view's gstate object so it will be set up again
using setUpGState the next time the view is focused. */
- (void) renewGState
{
_renew_gstate = 1;
/* Note that the next time we lock focus, we'll realloc a gstate (if
_allocate_gstate). This seems to make sense, and also allows us
to call this method each time we invalidate the coordinates */
}
/* Overridden by subclasses to setup custom gstate */
- (void) setUpGState
{
}
- (void) _lockFocusInContext: ctxt inRect: (NSRect)rect
{ {
NSRect wrect; NSRect wrect;
int window_gstate = 0; int window_gstate = 0;
@ -1770,7 +1696,21 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
} }
} }
// FIXME: Set current context? if (ctxt == nil)
{
if (viewIsPrinting != nil)
{
NSPrintOperation *printOp = [NSPrintOperation currentOperation];
ctxt = [printOp context];
}
else
{
ctxt = [_window graphicsContext];
}
}
// FIXME: Set current context
[ctxt lockFocusView: self inRect: rect]; [ctxt lockFocusView: self inRect: rect];
wrect = [self convertRect: rect toView: nil]; wrect = [self convertRect: rect toView: nil];
@ -1817,20 +1757,19 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
if (_renew_gstate) if (_renew_gstate)
{ {
[self setUpGState]; [self setUpGState];
_renew_gstate = NO;
} }
_renew_gstate = 0;
DPSgsave(ctxt); DPSgsave(ctxt);
} }
else else
{ {
DPSsetgstate(ctxt, window_gstate); DPSsetgstate(ctxt, window_gstate);
DPSgsave(ctxt); DPSgsave(ctxt);
[matrix concat]; [matrix concat];
/* Allow subclases to make other modifications */ /* Allow subclases to make other modifications */
[self setUpGState]; [self setUpGState];
_renew_gstate = 0; _renew_gstate = NO;
if (_allocate_gstate) if (_allocate_gstate)
{ {
_gstate = GSDefineGState(ctxt); _gstate = GSDefineGState(ctxt);
@ -1845,12 +1784,28 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
if ([self wantsDefaultClipping]) if ([self wantsDefaultClipping])
{ {
/* Clip to the visible rectangle - which will never be greater /*
* than the bounds of the view. This prevents drawing outside * Clip to the visible rectangle - which will never be greater
* our bounds * than the bounds of the view. This prevents drawing outside
* our bounds.
*/ */
DPSrectclip(ctxt, NSMinX(rect), NSMinY(rect), if (_is_rotated_from_base)
NSWidth(rect), NSHeight(rect)); {
// When the view is rotated, more complex clipping is needed.
NSAffineTransform *matrix;
NSBezierPath *bp = [NSBezierPath bezierPathWithRect: _frame];
matrix = [_boundsMatrix copy];
[matrix invert];
[bp transformUsingAffineTransform: matrix];
[bp addClip];
RELEASE(matrix);
}
else
{
DPSrectclip(ctxt, NSMinX(rect), NSMinY(rect),
NSWidth(rect), NSHeight(rect));
}
} }
/* Tell backends that images are drawn upside down. /* Tell backends that images are drawn upside down.
@ -1898,9 +1853,76 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
[ctxt unlockFocusView: self needsFlush: YES ]; [ctxt unlockFocusView: self needsFlush: YES ];
} }
/**
<p> Tell the view to maintain a private gstate object which
encapsulates all the information about drawing, such as coordinate
transforms, line widths, etc. If you do not invoke this method, a
gstate object is constructed each time the view is lockFocused.
Allocating a private gstate may improve the performance of views
that are focused a lot and have a lot of customized drawing
parameters. </p>
<p> View subclasses should override the
setUpGstate method to set these custom parameters.
</p>
*/
- (void) allocateGState
{
_allocate_gstate = YES;
_renew_gstate = YES;
}
/**
Frees the gstate object, if there is one.
*/
- (void) releaseGState
{
if (_allocate_gstate && _gstate)
GSUndefineGState(GSCurrentContext(), _gstate);
_gstate = 0;
_allocate_gstate = NO;
}
/**
Returns an identifier that represents the view's gstate object,
which is used to encapsulate drawing information about the view.
Most of the time a gstate object is created from scratch when the
view is focused, so if the view is not currently focused or
allocateGState has not been called, then this method will return 0.
FIXME: The above is what the OpenStep and Cocoa specification say, but
gState is 0 unless allocateGState has been called.
*/
- (int) gState
{
if (_allocate_gstate && (!_gstate || _renew_gstate))
{
// Set the gstate by locking and unlocking focus.
[self lockFocus];
[self unlockFocusNeedsFlush: NO];
}
return _gstate;
}
/**
Invalidates the view's gstate object so it will be set up again
using setUpGState the next time the view is focused. */
- (void) renewGState
{
_renew_gstate = YES;
/* Note that the next time we lock focus, we'll realloc a gstate (if
_allocate_gstate). This seems to make sense, and also allows us
to call this method each time we invalidate the coordinates */
}
/* Overridden by subclasses to setup custom gstate */
- (void) setUpGState
{
}
- (void) lockFocusInRect: (NSRect)rect - (void) lockFocusInRect: (NSRect)rect
{ {
[self _lockFocusInContext: [_window graphicsContext] inRect: rect]; [self _lockFocusInContext: nil inRect: rect];
} }
- (void) lockFocus - (void) lockFocus
@ -1915,7 +1937,7 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
- (BOOL) lockFocusIfCanDraw - (BOOL) lockFocusIfCanDraw
{ {
return [self lockFocusIfCanDrawInContext: [_window graphicsContext]]; return [self lockFocusIfCanDrawInContext: nil];
} }
- (BOOL) lockFocusIfCanDrawInContext: (NSGraphicsContext *)context; - (BOOL) lockFocusIfCanDrawInContext: (NSGraphicsContext *)context;
@ -3740,7 +3762,8 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
bBox: (NSRect)pageRect bBox: (NSRect)pageRect
fonts: (NSString*)fontNames fonts: (NSString*)fontNames
{ {
NSGraphicsContext *ctxt = GSCurrentContext(); NSPrintOperation *printOp = [NSPrintOperation currentOperation];
NSGraphicsContext *ctxt = [printOp context];
if (aString == nil) if (aString == nil)
aString = [[NSNumber numberWithInt: ordinalNum] description]; aString = [[NSNumber numberWithInt: ordinalNum] description];
@ -3767,8 +3790,8 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
pages: (int)numPages pages: (int)numPages
title: (NSString*)aTitle title: (NSString*)aTitle
{ {
NSGraphicsContext *ctxt = GSCurrentContext();
NSPrintOperation *printOp = [NSPrintOperation currentOperation]; NSPrintOperation *printOp = [NSPrintOperation currentOperation];
NSGraphicsContext *ctxt = [printOp context];
NSPrintingOrientation orient; NSPrintingOrientation orient;
BOOL epsOp; BOOL epsOp;
@ -3826,13 +3849,17 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
- (void) beginSetup - (void) beginSetup
{ {
NSGraphicsContext *ctxt = GSCurrentContext(); NSPrintOperation *printOp = [NSPrintOperation currentOperation];
NSGraphicsContext *ctxt = [printOp context];
DPSPrintf(ctxt, "%%%%BeginSetup\n"); DPSPrintf(ctxt, "%%%%BeginSetup\n");
} }
- (void) beginTrailer - (void) beginTrailer
{ {
NSGraphicsContext *ctxt = GSCurrentContext(); NSPrintOperation *printOp = [NSPrintOperation currentOperation];
NSGraphicsContext *ctxt = [printOp context];
DPSPrintf(ctxt, "%%%%Trailer\n"); DPSPrintf(ctxt, "%%%%Trailer\n");
} }
@ -3846,33 +3873,41 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
- (void) endHeaderComments - (void) endHeaderComments
{ {
NSGraphicsContext *ctxt = GSCurrentContext(); NSPrintOperation *printOp = [NSPrintOperation currentOperation];
NSGraphicsContext *ctxt = [printOp context];
DPSPrintf(ctxt, "%%%%EndComments\n\n"); DPSPrintf(ctxt, "%%%%EndComments\n\n");
} }
- (void) endPrologue - (void) endPrologue
{ {
NSGraphicsContext *ctxt = GSCurrentContext(); NSPrintOperation *printOp = [NSPrintOperation currentOperation];
NSGraphicsContext *ctxt = [printOp context];
DPSPrintf(ctxt, "%%%%EndProlog\n\n"); DPSPrintf(ctxt, "%%%%EndProlog\n\n");
} }
- (void) endSetup - (void) endSetup
{ {
NSGraphicsContext *ctxt = GSCurrentContext(); NSPrintOperation *printOp = [NSPrintOperation currentOperation];
NSGraphicsContext *ctxt = [printOp context];
DPSPrintf(ctxt, "%%%%EndSetup\n\n"); DPSPrintf(ctxt, "%%%%EndSetup\n\n");
} }
- (void) endPageSetup - (void) endPageSetup
{ {
NSGraphicsContext *ctxt = GSCurrentContext(); NSPrintOperation *printOp = [NSPrintOperation currentOperation];
NSGraphicsContext *ctxt = [printOp context];
DPSPrintf(ctxt, "%%%%EndPageSetup\n"); DPSPrintf(ctxt, "%%%%EndPageSetup\n");
} }
- (void) endPage - (void) endPage
{ {
int nup; int nup;
NSGraphicsContext *ctxt = GSCurrentContext();
NSPrintOperation *printOp = [NSPrintOperation currentOperation]; NSPrintOperation *printOp = [NSPrintOperation currentOperation];
NSGraphicsContext *ctxt = [printOp context];
NSDictionary *dict = [[printOp printInfo] dictionary]; NSDictionary *dict = [[printOp printInfo] dictionary];
nup = [[dict objectForKey: NSPrintPagesPerSheet] intValue]; nup = [[dict objectForKey: NSPrintPagesPerSheet] intValue];
@ -3886,7 +3921,9 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
- (void) endTrailer - (void) endTrailer
{ {
NSGraphicsContext *ctxt = GSCurrentContext(); NSPrintOperation *printOp = [NSPrintOperation currentOperation];
NSGraphicsContext *ctxt = [printOp context];
DPSPrintf(ctxt, "%%%%EOF\n"); DPSPrintf(ctxt, "%%%%EOF\n");
} }
@ -3943,10 +3980,10 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
{ {
int first, last, pages, nup; int first, last, pages, nup;
NSRect bbox; NSRect bbox;
NSDictionary *dict;
NSGraphicsContext *ctxt = GSCurrentContext();
NSPrintOperation *printOp = [NSPrintOperation currentOperation]; NSPrintOperation *printOp = [NSPrintOperation currentOperation];
dict = [[printOp printInfo] dictionary]; NSGraphicsContext *ctxt = [printOp context];
NSDictionary *dict = [[printOp printInfo] dictionary];
if (printOp == nil) if (printOp == nil)
{ {
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInternalInconsistencyException
@ -4048,8 +4085,8 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
{ {
int first, last, current, pages; int first, last, current, pages;
NSSet *fontNames; NSSet *fontNames;
NSGraphicsContext *ctxt = GSCurrentContext();
NSPrintOperation *printOp = [NSPrintOperation currentOperation]; NSPrintOperation *printOp = [NSPrintOperation currentOperation];
NSGraphicsContext *ctxt = [printOp context];
NSDictionary *dict = [[printOp printInfo] dictionary]; NSDictionary *dict = [[printOp printInfo] dictionary];
first = [[dict objectForKey: NSPrintFirstPage] intValue]; first = [[dict objectForKey: NSPrintFirstPage] intValue];

View file

@ -429,19 +429,30 @@ NSString *NSWorkspaceWillUnmountNotification =
@"NSWorkspaceWillUnmountNotification"; @"NSWorkspaceWillUnmountNotification";
/* /*
* NSStringDrawing NSString additions * NSStringDrawing NSAttributedString additions
*/ */
NSString *NSFontAttributeName = @"NSFontAttributeName";
NSString *NSParagraphStyleAttributeName = @"NSParagraphStyleAttributeName";
NSString *NSForegroundColorAttributeName = @"NSForegroundColorAttributeName";
NSString *NSUnderlineStyleAttributeName = @"NSUnderlineStyleAttributeName";
NSString *NSSuperscriptAttributeName = @"NSSuperscriptAttributeName";
NSString *NSBackgroundColorAttributeName = @"NSBackgroundColorAttributeName";
NSString *NSAttachmentAttributeName = @"NSAttachmentAttributeName"; NSString *NSAttachmentAttributeName = @"NSAttachmentAttributeName";
NSString *NSLigatureAttributeName = @"NSLigatureAttributeName"; NSString *NSBackgroundColorAttributeName = @"NSBackgroundColorAttributeName";
NSString *NSBaselineOffsetAttributeName = @"NSBaselineOffsetAttributeName"; NSString *NSBaselineOffsetAttributeName = @"NSBaselineOffsetAttributeName";
NSString *NSCursorAttributeName = @"NSCursorAttributeName";
NSString *NSExpansionAttributeName = @"NSExpansionAttributeName";
NSString *NSFontAttributeName = @"NSFontAttributeName";
NSString *NSForegroundColorAttributeName = @"NSForegroundColorAttributeName";
NSString *NSKernAttributeName = @"NSKernAttributeName"; NSString *NSKernAttributeName = @"NSKernAttributeName";
NSString *NSLigatureAttributeName = @"NSLigatureAttributeName";
NSString *NSLinkAttributeName = @"NSLinkAttributeName"; NSString *NSLinkAttributeName = @"NSLinkAttributeName";
NSString *NSObliquenessAttributeName = @"NSObliquenessAttributeName";
NSString *NSParagraphStyleAttributeName = @"NSParagraphStyleAttributeName";
NSString *NSShadowAttributeName = @"NSShadowAttributeName";
NSString *NSStrikethroughColorAttributeName
= @"NSStrikethroughColorAttributeName";
NSString *NSStrokeColorAttributeName = @"NSStrokeColorAttributeName";
NSString *NSStrokeWidthAttributeName = @"NSStrokeWidthAttributeName";
NSString *NSSuperscriptAttributeName = @"NSSuperscriptAttributeName";
NSString *NSToolTipAttributeName = @"NSToolTipAttributeName";
NSString *NSUnderlineColorAttributeName = @"NSUnderlineColorAttributeName";
NSString *NSUnderlineStyleAttributeName = @"NSUnderlineStyleAttributeName";
// NSToolbar notifications // NSToolbar notifications
NSString *NSToolbarDidRemoveItemNotification = @"NSToolbarDidRemoveItemNotification"; NSString *NSToolbarDidRemoveItemNotification = @"NSToolbarDidRemoveItemNotification";