mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 02:04:20 +00:00
Backport changes from trunk
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/stable@27077 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c8d84e2c09
commit
73e4308b2b
18 changed files with 798 additions and 351 deletions
116
ChangeLog
116
ChangeLog
|
@ -1,3 +1,119 @@
|
|||
2008-11-16 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSView.m (-setBounds:, -setBoundsSize:): Fixed bug in
|
||||
last change not getting the _boundsMatrix correct.
|
||||
|
||||
2008-11-15 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/NSSavePanel.m (-_setupForDirectory:file:): Abort editing
|
||||
for the file name's text cell before setting the passed in file
|
||||
name.
|
||||
|
||||
* Source/NSDocument.m (-runModalSavePanel:withAccessoryView:):
|
||||
When the document has been saved already pass its file name to the
|
||||
save panel like on Mac OS X.
|
||||
|
||||
* Source/NSControl.m (-drawRect): Make sure the cell's control
|
||||
view is always set up.
|
||||
|
||||
2008-11-14 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSScrollView.m (-setContentView:): Replaced last change
|
||||
with one inside of setContentView:.
|
||||
* Source/NSView.m (-setFrame:): One more adjustment for bounds
|
||||
transformation.
|
||||
|
||||
2008-11-14 00:40-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Source/NSScrollView.m: Correct issue with tableviews when
|
||||
loading nib files, corrected bug #24782.
|
||||
|
||||
2008-11-13 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSView.m (-setBounds:, -setBoundsSize:, -setFrame:,
|
||||
-setFrameSize): Some more adjustments on the bounds transformation.
|
||||
|
||||
2008-11-12 05:31-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Source/GSNibCompatibility.m: Conditionally call setToolTip if it
|
||||
exists when doing establishConnection on an NSIBHelpConnector.
|
||||
* Source/NSDocumentController.m: Correction to prevent exception when
|
||||
NSDocumentClass isn't specified. This does not cause an issue on
|
||||
Mac OS X.
|
||||
|
||||
2008-11-11 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSView.m (-setBoundsOrigin:, -setBoundsRotation:,
|
||||
-translateOriginToPoint:, -scaleUnitSquareToSize:,
|
||||
-rotateByAngle:): Reimplemented correctly.
|
||||
* Source/NSView.m (-_computeScale): New method.
|
||||
* Source/NSView.m (-_updateBoundsMatrix:, -setBounds:,
|
||||
-setBoundsSize:): Small changes.
|
||||
|
||||
2008-11-09 10:24-EST Saso Kiselkov
|
||||
Committed by: Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Source/NSSecureTextField.m: Patch to make bullets output when
|
||||
setEchosBullets is set to yes in NSSecureTextField. Corrects
|
||||
bug #19761.
|
||||
|
||||
2008-11-08 10:09-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Source/NSDocument.m: Correction for bug#24758, add name and
|
||||
type information to the object before reading the file so that
|
||||
it is available during the readFile:ofType: method call.
|
||||
|
||||
2008-11-06 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSBitmapImageRep.m (-_convertToFormatBitsPerSample:...):
|
||||
Filled with some more code. The conversion within the same colour
|
||||
space and be between black/white and RGB should now be correct and
|
||||
faster.
|
||||
|
||||
2008-11-05 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/NSWorkspace.m (-isFilePackageAtPath:): Provide a working
|
||||
implementation.
|
||||
|
||||
* Source/NSApplication.m (-targetForAction:forWindow:): Make
|
||||
NSApplication's responder chain for action messages consistent
|
||||
with Apple's documentation and the Mac OS X implementation.
|
||||
|
||||
* Source/NSAlert.m (-_initWithoutGModel):
|
||||
* Source/NSSavePanel.m (-_initWithoutGModel): Fix key view loop so
|
||||
that all buttons become reachable with the Tab key. Make Escape
|
||||
key equivalent of the Cancel button of NSSavePanel.
|
||||
|
||||
* Source/NSButton.m (-keyDown):
|
||||
* Source/NSPopUpButton.m (-keyDown): Trigger action only after
|
||||
pressing the Space key.
|
||||
|
||||
2008-11-01 21:35-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Source/NSWindow.m: Reverted a previous change to miniaturize.
|
||||
This should correct bug #24707.
|
||||
|
||||
2008-10-31 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/GSNibCompatibility.m: Define the needed GSIARRAY
|
||||
constants, this helps against valgrind complaining.
|
||||
|
||||
2008-10-29 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSBrowser.m (-drawTitle:inRect:ofColumn:, -dealloc): Set
|
||||
and unset the ownership of the shared title cell.
|
||||
Patch by Matt Rice <ratmice@gmail.com>.
|
||||
|
||||
2008-10-24 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSMenu.m (-indexOfItemWithTarget:andAction:): Compare the
|
||||
target for identity not equality.
|
||||
* Source/NSApplication.m (-targetForAction:forWindow:): New helper
|
||||
method. Don't stop at the window itself, when going up the
|
||||
responder chain.
|
||||
* Source/NSApplication.m (-targetForAction:): Use the new helper
|
||||
method.
|
||||
|
||||
2008-10-21 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Source/NSBitmapImageRep+JPEG.m: Fix broken boolean definition.
|
||||
|
|
|
@ -51,7 +51,15 @@
|
|||
#include <Foundation/NSKeyedArchiver.h>
|
||||
#include "AppKit/AppKit.h"
|
||||
#include <GNUstepBase/GSObjCRuntime.h>
|
||||
|
||||
/*
|
||||
* Setup for inline operation of arrays.
|
||||
*/
|
||||
#define GSI_ARRAY_RETAIN(A, X) RETAIN((X).obj)
|
||||
#define GSI_ARRAY_RELEASE(A, X) RELEASE((X).obj)
|
||||
#define GSI_ARRAY_TYPES GSUNION_OBJ
|
||||
#include <GNUstepBase/GSIArray.h>
|
||||
|
||||
#include <GNUstepGUI/GSNibCompatibility.h>
|
||||
#include <GNUstepGUI/GSInstantiator.h>
|
||||
|
||||
|
@ -1558,7 +1566,10 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
|
||||
- (void) establishConnection
|
||||
{
|
||||
[_dst setToolTip: _marker];
|
||||
if([_dst respondsToSelector: @selector(setToolTip:)])
|
||||
{
|
||||
[_dst setToolTip: _marker];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setFile: (id)file
|
||||
|
|
|
@ -431,12 +431,9 @@ setControl(NSView* content, id control, NSString *title)
|
|||
[defButton setImagePosition: NSImageRight];
|
||||
[defButton setImage: [NSImage imageNamed: @"common_ret"]];
|
||||
[defButton setAlternateImage: [NSImage imageNamed: @"common_retH"]];
|
||||
[defButton setRefusesFirstResponder: YES];
|
||||
|
||||
altButton = [self _makeButtonWithRect: rect];
|
||||
[altButton setRefusesFirstResponder: YES];
|
||||
othButton = [self _makeButtonWithRect: rect];
|
||||
[othButton setRefusesFirstResponder: YES];
|
||||
|
||||
rect.size.height = 80.0;
|
||||
scroll = makeScrollViewWithRect(rect);
|
||||
|
@ -1510,11 +1507,11 @@ void NSBeginInformationalAlertSheet(NSString *title,
|
|||
else
|
||||
{
|
||||
[button setTag: NSAlertFirstButtonReturn + count];
|
||||
if ([aTitle isEqualToString: @"Cancel"])
|
||||
if ([aTitle isEqualToString: _(@"Cancel")])
|
||||
{
|
||||
[button setKeyEquivalent: @"\e"];
|
||||
}
|
||||
else if ([aTitle isEqualToString: @"Don't Save"])
|
||||
else if ([aTitle isEqualToString: _(@"Don't Save")])
|
||||
{
|
||||
[button setKeyEquivalent: @"D"];
|
||||
[button setKeyEquivalentModifierMask: NSCommandKeyMask];
|
||||
|
@ -1603,8 +1600,8 @@ void NSBeginInformationalAlertSheet(NSString *title,
|
|||
}
|
||||
[panel setTitleBar: title
|
||||
icon: _icon
|
||||
title: _informative_text
|
||||
message: _message_text
|
||||
title: _message_text != nil ? _message_text : _(@"Alert")
|
||||
message: _informative_text
|
||||
def: (nbut > 0) ? [[_buttons objectAtIndex: 0] title] : (NSString*)nil
|
||||
alt: (nbut > 1) ? [[_buttons objectAtIndex: 1] title] : (NSString*)nil
|
||||
other: (nbut > 2) ? [[_buttons objectAtIndex: 2] title] : (NSString*)nil];
|
||||
|
|
|
@ -2028,6 +2028,45 @@ IF_NO_GC(NSAssert([event retainCount] > 0, NSInternalInconsistencyException));
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper method to avoid duplicating code for key and main window
|
||||
*/
|
||||
- (id) targetForAction: (SEL)aSelector forWindow: (NSWindow *)window
|
||||
{
|
||||
id resp, delegate;
|
||||
|
||||
resp = [window firstResponder];
|
||||
while (resp != nil && resp != self)
|
||||
{
|
||||
if ([resp respondsToSelector: aSelector])
|
||||
{
|
||||
return resp;
|
||||
}
|
||||
if (resp == window)
|
||||
{
|
||||
delegate = [window delegate];
|
||||
if ([delegate respondsToSelector: aSelector])
|
||||
{
|
||||
return delegate;
|
||||
}
|
||||
}
|
||||
resp = [resp nextResponder];
|
||||
}
|
||||
|
||||
if ([NSDocumentController isDocumentBasedApplication])
|
||||
{
|
||||
resp = [[NSDocumentController sharedDocumentController]
|
||||
documentForWindow: window];
|
||||
|
||||
if (resp != nil && [resp respondsToSelector: aSelector])
|
||||
{
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Returns the target object that will respond to aSelector, if any. The
|
||||
|
@ -2039,43 +2078,19 @@ IF_NO_GC(NSAssert([event retainCount] > 0, NSInternalInconsistencyException));
|
|||
*/
|
||||
- (id) targetForAction: (SEL)aSelector
|
||||
{
|
||||
NSWindow *keyWindow;
|
||||
NSWindow *mainWindow;
|
||||
id resp;
|
||||
NSWindow *keyWindow;
|
||||
NSWindow *mainWindow;
|
||||
id resp;
|
||||
|
||||
if (aSelector == NULL)
|
||||
return nil;
|
||||
|
||||
keyWindow = [self keyWindow];
|
||||
if (keyWindow != nil)
|
||||
{
|
||||
resp = [keyWindow firstResponder];
|
||||
while (resp != nil && resp != keyWindow)
|
||||
{
|
||||
if ([resp respondsToSelector: aSelector])
|
||||
{
|
||||
return resp;
|
||||
}
|
||||
resp = [resp nextResponder];
|
||||
}
|
||||
if ([keyWindow respondsToSelector: aSelector])
|
||||
{
|
||||
return keyWindow;
|
||||
}
|
||||
|
||||
resp = [keyWindow delegate];
|
||||
if (resp != nil && [resp respondsToSelector: aSelector])
|
||||
{
|
||||
return resp;
|
||||
}
|
||||
|
||||
if ([NSDocumentController isDocumentBasedApplication])
|
||||
{
|
||||
resp = [[NSDocumentController sharedDocumentController]
|
||||
documentForWindow: keyWindow];
|
||||
|
||||
if (resp != nil && [resp respondsToSelector: aSelector])
|
||||
{
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
resp = [self targetForAction: aSelector forWindow: keyWindow];
|
||||
if (resp != nil)
|
||||
return resp;
|
||||
}
|
||||
|
||||
if (_session != 0)
|
||||
|
@ -2084,50 +2099,25 @@ IF_NO_GC(NSAssert([event retainCount] > 0, NSInternalInconsistencyException));
|
|||
mainWindow = [self mainWindow];
|
||||
if (keyWindow != mainWindow && mainWindow != nil)
|
||||
{
|
||||
resp = [mainWindow firstResponder];
|
||||
while (resp != nil && resp != mainWindow)
|
||||
{
|
||||
if ([resp respondsToSelector: aSelector])
|
||||
{
|
||||
return resp;
|
||||
}
|
||||
resp = [resp nextResponder];
|
||||
}
|
||||
if ([mainWindow respondsToSelector: aSelector])
|
||||
{
|
||||
return mainWindow;
|
||||
}
|
||||
|
||||
resp = [mainWindow delegate];
|
||||
if (resp != nil && [resp respondsToSelector: aSelector])
|
||||
{
|
||||
return resp;
|
||||
}
|
||||
|
||||
if ([NSDocumentController isDocumentBasedApplication])
|
||||
{
|
||||
resp = [[NSDocumentController sharedDocumentController]
|
||||
documentForWindow: mainWindow];
|
||||
|
||||
if (resp != nil && [resp respondsToSelector: aSelector])
|
||||
{
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
resp = [self targetForAction: aSelector forWindow: mainWindow];
|
||||
if (resp != nil)
|
||||
return resp;
|
||||
}
|
||||
|
||||
if ([self respondsToSelector: aSelector])
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
if (_delegate != nil && [_delegate respondsToSelector: aSelector])
|
||||
{
|
||||
return _delegate;
|
||||
}
|
||||
|
||||
if ([NSDocumentController isDocumentBasedApplication]
|
||||
&& [[NSDocumentController sharedDocumentController]
|
||||
respondsToSelector: aSelector])
|
||||
{
|
||||
&& [[NSDocumentController sharedDocumentController]
|
||||
respondsToSelector: aSelector])
|
||||
{
|
||||
return [NSDocumentController sharedDocumentController];
|
||||
}
|
||||
|
||||
|
|
|
@ -2134,17 +2134,251 @@ _set_bit_value(unsigned char *base, long msb_off, int bit_width,
|
|||
IMP setP = [new methodForSelector: setPSel];
|
||||
unsigned int pixelData[5];
|
||||
int x, y;
|
||||
float _scale;
|
||||
float scale;
|
||||
|
||||
NSDebugLLog(@"NSImage", @"Converting %@ bitmap data", colorSpaceName);
|
||||
if (_bitsPerSample != bps)
|
||||
{
|
||||
_scale = (float)((1 << _bitsPerSample) - 1);
|
||||
scale = (float)((1 << bps) - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_scale = 1.0;
|
||||
scale = 1.0;
|
||||
}
|
||||
|
||||
for (y = 0; y < _pixelsHigh; y++)
|
||||
{
|
||||
for (x = 0; x < _pixelsWide; x++)
|
||||
{
|
||||
//[self getPixel: pixelData atX: x y: y];
|
||||
getP(self, getPSel, pixelData, x, y);
|
||||
// FIXME: Here we may need to resort, scale, pre-multiply
|
||||
// the pixel data and add alpha. Or do the opposite :-)
|
||||
unsigned int iv[4], ia;
|
||||
float fv[4], fa;
|
||||
int i;
|
||||
|
||||
//[self getPixel: pixelData atX: x y: y];
|
||||
getP(self, getPSel, pixelData, x, y);
|
||||
|
||||
if (_hasAlpha)
|
||||
{
|
||||
// This order depends on the bitmap format
|
||||
if (_format & NSAlphaFirstBitmapFormat)
|
||||
{
|
||||
ia = pixelData[0];
|
||||
for (i = 0; i < _numColors - 1; i++)
|
||||
{
|
||||
iv[i] = pixelData[i + 1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < _numColors - 1; i++)
|
||||
{
|
||||
iv[i] = pixelData[i];
|
||||
}
|
||||
ia = pixelData[_numColors - 1];
|
||||
}
|
||||
|
||||
// Scale to [0.0 ... 1.0]
|
||||
for (i = 0; i < _numColors - 1; i++)
|
||||
{
|
||||
fv[i] = iv[i] / _scale;
|
||||
}
|
||||
fa = ia / _scale;
|
||||
|
||||
if ((_format & NSAlphaNonpremultipliedBitmapFormat) !=
|
||||
(bitmapFormat & NSAlphaNonpremultipliedBitmapFormat))
|
||||
{
|
||||
if (_format & NSAlphaNonpremultipliedBitmapFormat)
|
||||
{
|
||||
for (i = 0; i < _numColors - 1; i++)
|
||||
{
|
||||
fv[i] = fv[i] * fa;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < _numColors - 1; i++)
|
||||
{
|
||||
fv[i] = fv[i] / fa;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < _numColors; i++)
|
||||
{
|
||||
iv[i] = pixelData[i];
|
||||
}
|
||||
// Scale to [0.0 ... 1.0]
|
||||
for (i = 0; i < _numColors; i++)
|
||||
{
|
||||
fv[i] = iv[i] / _scale;
|
||||
}
|
||||
fa = 1.0;
|
||||
}
|
||||
|
||||
if (alpha)
|
||||
{
|
||||
// Scale from [0.0 ... 1.0]
|
||||
for (i = 0; i < _numColors; i++)
|
||||
{
|
||||
iv[i] = fv[i] * scale;
|
||||
}
|
||||
ia = fa * scale;
|
||||
|
||||
if (bitmapFormat & NSAlphaFirstBitmapFormat)
|
||||
{
|
||||
pixelData[0] = ia;
|
||||
for (i = 0; i < spp - 1; i++)
|
||||
{
|
||||
pixelData[i + 1] = iv[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < spp - 1; i++)
|
||||
{
|
||||
pixelData[i] = iv[i];
|
||||
}
|
||||
pixelData[spp -1] = ia;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Scale from [0.0 ... 1.0]
|
||||
for (i = 0; i < spp; i++)
|
||||
{
|
||||
pixelData[i] = fv[i] * scale;
|
||||
}
|
||||
}
|
||||
|
||||
//[new setPixel: pixelData atX: x y: y];
|
||||
setP(new, setPSel, pixelData, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (([colorSpaceName isEqualToString: NSDeviceRGBColorSpace] ||
|
||||
[colorSpaceName isEqualToString: NSCalibratedRGBColorSpace])
|
||||
&& ([_colorSpace isEqualToString: NSCalibratedWhiteColorSpace] ||
|
||||
[_colorSpace isEqualToString: NSCalibratedBlackColorSpace] ||
|
||||
[_colorSpace isEqualToString: NSDeviceWhiteColorSpace] ||
|
||||
[_colorSpace isEqualToString: NSDeviceBlackColorSpace]))
|
||||
{
|
||||
SEL getPSel = @selector(getPixel:atX:y:);
|
||||
SEL setPSel = @selector(setPixel:atX:y:);
|
||||
IMP getP = [self methodForSelector: getPSel];
|
||||
IMP setP = [new methodForSelector: setPSel];
|
||||
unsigned int pixelData[4];
|
||||
int x, y;
|
||||
float _scale;
|
||||
float scale;
|
||||
int max = (1 << bps) - 1;
|
||||
BOOL isWhite = [_colorSpace isEqualToString: NSCalibratedWhiteColorSpace]
|
||||
|| [_colorSpace isEqualToString: NSDeviceWhiteColorSpace];
|
||||
|
||||
NSDebugLLog(@"NSImage", @"Converting black/white bitmap data");
|
||||
|
||||
if (_bitsPerSample != bps)
|
||||
{
|
||||
_scale = (float)((1 << _bitsPerSample) - 1);
|
||||
scale = (float)((1 << bps) - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_scale = 1.0;
|
||||
scale = 1.0;
|
||||
}
|
||||
|
||||
for (y = 0; y < _pixelsHigh; y++)
|
||||
{
|
||||
for (x = 0; x < _pixelsWide; x++)
|
||||
{
|
||||
unsigned int iv, ia;
|
||||
float fv, fa;
|
||||
|
||||
//[self getPixel: pixelData atX: x y: y];
|
||||
getP(self, getPSel, pixelData, x, y);
|
||||
|
||||
if (_hasAlpha)
|
||||
{
|
||||
// This order depends on the bitmap format
|
||||
if (_format & NSAlphaFirstBitmapFormat)
|
||||
{
|
||||
ia = pixelData[0];
|
||||
if (isWhite)
|
||||
iv = pixelData[1];
|
||||
else
|
||||
iv = max - pixelData[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isWhite)
|
||||
iv = pixelData[0];
|
||||
else
|
||||
iv = max - pixelData[0];
|
||||
ia = pixelData[1];
|
||||
}
|
||||
|
||||
// Scale to [0.0 ... 1.0]
|
||||
fv = iv / _scale;
|
||||
fa = ia / _scale;
|
||||
|
||||
if ((_format & NSAlphaNonpremultipliedBitmapFormat) !=
|
||||
(bitmapFormat & NSAlphaNonpremultipliedBitmapFormat))
|
||||
{
|
||||
if (_format & NSAlphaNonpremultipliedBitmapFormat)
|
||||
{
|
||||
fv = fv * fa;
|
||||
}
|
||||
else
|
||||
{
|
||||
fv = fv / fa;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isWhite)
|
||||
iv = pixelData[0];
|
||||
else
|
||||
iv = max - pixelData[0];
|
||||
// Scale to [0.0 ... 1.0]
|
||||
fv = iv / _scale;
|
||||
fa = 1.0;
|
||||
}
|
||||
|
||||
if (alpha)
|
||||
{
|
||||
// Scale from [0.0 ... 1.0]
|
||||
iv = fv * scale;
|
||||
ia = fa * scale;
|
||||
|
||||
if (bitmapFormat & NSAlphaFirstBitmapFormat)
|
||||
{
|
||||
pixelData[0] = ia;
|
||||
pixelData[1] = iv;
|
||||
pixelData[2] = iv;
|
||||
pixelData[3] = iv;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixelData[0] = iv;
|
||||
pixelData[1] = iv;
|
||||
pixelData[2] = iv;
|
||||
pixelData[3] = ia;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Scale from [0.0 ... 1.0]
|
||||
iv = fv * scale;
|
||||
pixelData[0] = iv;
|
||||
pixelData[1] = iv;
|
||||
pixelData[2] = iv;
|
||||
}
|
||||
|
||||
//[new setPixel: pixelData atX: x y: y];
|
||||
setP(new, setPSel, pixelData, x, y);
|
||||
|
@ -2159,6 +2393,7 @@ _set_bit_value(unsigned char *base, long msb_off, int bit_width,
|
|||
IMP setC = [new methodForSelector: setCSel];
|
||||
int i, j;
|
||||
|
||||
NSDebugLLog(@"NSImage", @"Slow converting %@ bitmap data", colorSpaceName);
|
||||
for (j = 0; j < _pixelsHigh; j++)
|
||||
{
|
||||
CREATE_AUTORELEASE_POOL(pool);
|
||||
|
|
|
@ -1453,6 +1453,7 @@ static NSTextFieldCell *titleCell;
|
|||
if (!_isTitled || !NSBR_COLUMN_IS_VISIBLE(column))
|
||||
return;
|
||||
|
||||
[titleCell setControlView: self];
|
||||
[titleCell setStringValue: title];
|
||||
[titleCell drawWithFrame: aRect inView: self];
|
||||
}
|
||||
|
@ -2258,6 +2259,11 @@ static NSTextFieldCell *titleCell;
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
if ([titleCell controlView] == self)
|
||||
{
|
||||
[titleCell setControlView: nil];
|
||||
}
|
||||
|
||||
RELEASE(_browserCellPrototype);
|
||||
RELEASE(_pathSeparator);
|
||||
RELEASE(_horizontalScroller);
|
||||
|
|
|
@ -482,11 +482,8 @@ static id buttonCellClass = nil;
|
|||
character = [characters characterAtIndex: 0];
|
||||
}
|
||||
|
||||
// Handle SPACE or RETURN to perform a click
|
||||
if ((character == NSNewlineCharacter)
|
||||
|| (character == NSEnterCharacter)
|
||||
|| (character == NSCarriageReturnCharacter)
|
||||
|| ([characters isEqualToString: @" "]))
|
||||
/* Handle SPACE to perform a click */
|
||||
if ([characters isEqualToString: @" "])
|
||||
{
|
||||
[self performClick: self];
|
||||
return;
|
||||
|
|
|
@ -634,6 +634,11 @@ static NSNotificationCenter *nc;
|
|||
*/
|
||||
if ([self currentEditor] != nil)
|
||||
{
|
||||
/* Make sure the cell's control view is always set up.
|
||||
* FIXME Need to draw the cell's border which is not covered by
|
||||
* the field editor if the cell is bordered.
|
||||
*/
|
||||
[_cell setControlView: self];
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -671,7 +676,7 @@ static NSNotificationCenter *nc;
|
|||
{
|
||||
if (_cell == aCell)
|
||||
{
|
||||
[_cell setState: 1];
|
||||
[_cell setState: NSOnState];
|
||||
[self setNeedsDisplay: YES];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,12 +96,9 @@
|
|||
self = [self init];
|
||||
if (self != nil)
|
||||
{
|
||||
if ([self readFromFile: fileName ofType: fileType])
|
||||
{
|
||||
[self setFileType: fileType];
|
||||
[self setFileName: fileName];
|
||||
}
|
||||
else
|
||||
[self setFileType: fileType];
|
||||
[self setFileName: fileName];
|
||||
if (![self readFromFile: fileName ofType: fileType])
|
||||
{
|
||||
NSRunAlertPanel (_(@"Load failed"),
|
||||
_(@"Could not load file %@."),
|
||||
|
@ -122,12 +119,9 @@
|
|||
self = [self init];
|
||||
if (self != nil)
|
||||
{
|
||||
if ([self readFromURL: url ofType: fileType])
|
||||
{
|
||||
[self setFileType: fileType];
|
||||
[self setFileName: [url path]];
|
||||
}
|
||||
else
|
||||
[self setFileType: fileType];
|
||||
[self setFileName: [url path]];
|
||||
if (![self readFromURL: url ofType: fileType])
|
||||
{
|
||||
NSRunAlertPanel(_(@"Load failed"),
|
||||
_(@"Could not load URL %@."),
|
||||
|
@ -971,10 +965,18 @@ originalContentsURL: (NSURL *)orig
|
|||
- (int)runModalSavePanel: (NSSavePanel *)savePanel
|
||||
withAccessoryView: (NSView *)accessoryView
|
||||
{
|
||||
NSString *directory, *file;
|
||||
|
||||
if (accessoryView)
|
||||
{
|
||||
[savePanel setAccessoryView: accessoryView];
|
||||
}
|
||||
if ([self fileName])
|
||||
{
|
||||
directory = [[self fileName] stringByDeletingLastPathComponent];
|
||||
file = [[self fileName] lastPathComponent];
|
||||
return [savePanel runModalForDirectory: directory file: file];
|
||||
}
|
||||
return [savePanel runModal];
|
||||
}
|
||||
|
||||
|
|
|
@ -989,8 +989,17 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
|
|||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSDictionary *typeInfo = [_types objectAtIndex: i];
|
||||
|
||||
[classNames addObject: [typeInfo objectForKey: NSDocumentClassKey]];
|
||||
NSString *className = [typeInfo objectForKey: NSDocumentClassKey];
|
||||
|
||||
if(className != nil)
|
||||
{
|
||||
[classNames addObject: className];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"WARN: The entry does not have an NSDocumentClass name defined: %@",
|
||||
typeInfo);
|
||||
}
|
||||
}
|
||||
|
||||
return AUTORELEASE(classNames);
|
||||
|
|
|
@ -816,12 +816,13 @@ static BOOL menuBarVisible = YES;
|
|||
NSMenuItem *menuItem = [_items objectAtIndex: i];
|
||||
|
||||
if (actionSelector == 0 || sel_eq([menuItem action], actionSelector))
|
||||
{
|
||||
if ([[menuItem target] isEqual: anObject])
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
{
|
||||
// There are different possibilities to implement the check here
|
||||
if ([menuItem target] == anObject)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
@ -834,10 +835,10 @@ static BOOL menuBarVisible = YES;
|
|||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if ([[[_items objectAtIndex: i] representedObject]
|
||||
isEqual: anObject])
|
||||
{
|
||||
return i;
|
||||
}
|
||||
isEqual: anObject])
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
@ -852,10 +853,10 @@ static BOOL menuBarVisible = YES;
|
|||
id item = [_items objectAtIndex: i];
|
||||
|
||||
if ([item hasSubmenu] &&
|
||||
[[item submenu] isEqual: anObject])
|
||||
{
|
||||
return i;
|
||||
}
|
||||
[[item submenu] isEqual: anObject])
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
|
@ -452,6 +452,14 @@ this to return nil to indicate that we have no context menu.
|
|||
case NSNewlineCharacter:
|
||||
case NSEnterCharacter:
|
||||
case NSCarriageReturnCharacter:
|
||||
/* Handle Enter and Return keys only when the menu is visible.
|
||||
The button's action to pop up the menu is initiated only by
|
||||
the Space key similar to other buttons. */
|
||||
{
|
||||
NSMenuView *menuView = [[_cell menu] menuRepresentation];
|
||||
if ([[menuView window] isVisible] == NO)
|
||||
break;
|
||||
}
|
||||
case ' ':
|
||||
{
|
||||
int selectedIndex;
|
||||
|
|
|
@ -249,7 +249,6 @@ setPath(NSBrowser *browser, NSString *path)
|
|||
|
||||
r = NSMakeRect (43, 6, 27, 27);
|
||||
button = [[NSButton alloc] initWithFrame: r];
|
||||
[button setRefusesFirstResponder: YES];
|
||||
[button setBordered: YES];
|
||||
image = [NSImage imageNamed: @"common_Home"];
|
||||
[button setImage: image];
|
||||
|
@ -265,7 +264,6 @@ setPath(NSBrowser *browser, NSString *path)
|
|||
|
||||
r = NSMakeRect (78, 6, 27, 27);
|
||||
button = [[NSButton alloc] initWithFrame: r];
|
||||
[button setRefusesFirstResponder: YES];
|
||||
[button setBordered: YES];
|
||||
image = [NSImage imageNamed: @"common_Mount"];
|
||||
[button setImage: image];
|
||||
|
@ -281,7 +279,6 @@ setPath(NSBrowser *browser, NSString *path)
|
|||
|
||||
r = NSMakeRect (112, 6, 27, 27);
|
||||
button = [[NSButton alloc] initWithFrame: r];
|
||||
[button setRefusesFirstResponder: YES];
|
||||
[button setBordered: YES];
|
||||
image = [NSImage imageNamed: @"common_Unmount"];
|
||||
[button setImage: image];
|
||||
|
@ -297,7 +294,6 @@ setPath(NSBrowser *browser, NSString *path)
|
|||
|
||||
r = NSMakeRect (148, 6, 71, 27);
|
||||
button = [[NSButton alloc] initWithFrame: r];
|
||||
[button setRefusesFirstResponder: YES];
|
||||
[button setBordered: YES];
|
||||
[button setTitle: @"Cancel"];
|
||||
[button setImagePosition: NSNoImage];
|
||||
|
@ -305,6 +301,8 @@ setPath(NSBrowser *browser, NSString *path)
|
|||
[button setAction: @selector(cancel:)];
|
||||
[button setAutoresizingMask: NSViewMinXMargin];
|
||||
[button setTag: NSFileHandlingPanelCancelButton];
|
||||
[button setKeyEquivalent: @"\e"];
|
||||
[button setKeyEquivalentModifierMask: 0];
|
||||
[_bottomView addSubview: button];
|
||||
[lastKeyView setNextKeyView: button];
|
||||
lastKeyView = button;
|
||||
|
@ -312,7 +310,6 @@ setPath(NSBrowser *browser, NSString *path)
|
|||
|
||||
r = NSMakeRect (228, 6, 71, 27);
|
||||
_okButton = [[NSButton alloc] initWithFrame: r];
|
||||
[button setRefusesFirstResponder: YES];
|
||||
[_okButton setBordered: YES];
|
||||
[_okButton setTitle: @"OK"];
|
||||
[_okButton setImagePosition: NSImageRight];
|
||||
|
@ -567,6 +564,8 @@ selectCellWithString: (NSString*)title
|
|||
setPath(_browser, _fullFileName);
|
||||
|
||||
[self _selectCellName: filename];
|
||||
[_form abortEditing]; // FIXME This is necessary because we cannot set a
|
||||
// cell's value while it is being edited.
|
||||
[[_form cellAtIndex: 0] setStringValue: filename];
|
||||
[_form selectTextAtIndex: 0];
|
||||
[_form setNeedsDisplay: YES];
|
||||
|
|
|
@ -236,8 +236,10 @@ static float scrollerWidth;
|
|||
NSView *docView = [aView documentView];
|
||||
|
||||
[_contentView removeFromSuperview];
|
||||
[self addSubview: aView];
|
||||
// This must be done after adding it as a subview,
|
||||
// otherwise it will get unset again.
|
||||
_contentView = aView;
|
||||
[self addSubview: _contentView];
|
||||
|
||||
if (docView != nil)
|
||||
{
|
||||
|
|
|
@ -42,6 +42,9 @@
|
|||
#include "AppKit/NSTextView.h"
|
||||
#include "AppKit/NSWindow.h"
|
||||
|
||||
// the Unicode code point for a bullet
|
||||
#define BULLET 0x2022
|
||||
|
||||
/* 'Secure' subclasses */
|
||||
@interface NSSecureTextView : NSTextView
|
||||
{
|
||||
|
@ -121,20 +124,35 @@
|
|||
_echosBullets = flag;
|
||||
}
|
||||
|
||||
/* Substitute a fixed-pitch font for correct bullet drawing */
|
||||
- (void) setFont: (NSFont *) f
|
||||
{
|
||||
if (![f isFixedPitch])
|
||||
{
|
||||
f = [NSFont userFixedPitchFontOfSize: [f pointSize]];
|
||||
}
|
||||
|
||||
[super setFont: f];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)_replacementAttributedString
|
||||
{
|
||||
NSDictionary *attributes;
|
||||
NSMutableString *string;
|
||||
unsigned int length;
|
||||
unsigned int i;
|
||||
unichar *buf;
|
||||
|
||||
length = [[self stringValue] length];
|
||||
string = [[NSMutableString alloc] initWithCapacity: length];
|
||||
buf = NSZoneMalloc (NSDefaultMallocZone (), length * sizeof (unichar));
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
[string appendString: @"*"];
|
||||
buf[i] = BULLET;
|
||||
}
|
||||
AUTORELEASE(string);
|
||||
|
||||
string = [[NSMutableString alloc]
|
||||
initWithCharactersNoCopy: buf length: length freeWhenDone: YES];
|
||||
AUTORELEASE (string);
|
||||
|
||||
attributes = [self _nonAutoreleasedTypingAttributes];
|
||||
return AUTORELEASE([[NSAttributedString alloc] initWithString: string
|
||||
|
@ -225,14 +243,28 @@
|
|||
{
|
||||
if ([self echosBullets])
|
||||
{
|
||||
/*
|
||||
FIXME: Functionality not implemented.
|
||||
This also doesn't eblong into this method, rather
|
||||
we should do the replacement during the glyph generation.
|
||||
This gets currently done in [GSLayoutManager _generateGlyphsForRun:at:],
|
||||
but should be done in an NSTypesetter subclass. Only with this in place
|
||||
it seems possible to implement bullet echoing.
|
||||
*/
|
||||
/*
|
||||
* FIXME: Rather stupid way of drawing bullets, but better than nothing
|
||||
* at all. Works well enough for secure text fields.
|
||||
* This also doesn't belong into this method, rather we should do
|
||||
* the replacement during glyph generation. This gets currently done
|
||||
* in [GSLayoutManager _generateGlyphsForRun:at:], but should be done
|
||||
* in an NSTypesetter subclass. Only with this in place it seems
|
||||
* possible to implement bullet echoing.
|
||||
*/
|
||||
unichar buf[] = {BULLET};
|
||||
NSString *string = [NSString stringWithCharacters: buf length: 1];
|
||||
NSFont *font = [_typingAttributes objectForKey: NSFontAttributeName];
|
||||
double width = [font widthOfString: string];
|
||||
int i;
|
||||
|
||||
for (i = glyphRange.location; i <= NSMaxRange (glyphRange); i++)
|
||||
{
|
||||
NSPoint p = NSMakePoint (containerOrigin.x + (i - 1) * width,
|
||||
containerOrigin.y);
|
||||
|
||||
[string drawAtPoint: p withAttributes: _typingAttributes];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
451
Source/NSView.m
451
Source/NSView.m
|
@ -1017,45 +1017,56 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
- (void) willRemoveSubview: (NSView *)subview
|
||||
{}
|
||||
|
||||
- (void) _updateBoundsMatrix
|
||||
- (NSSize)_computeScale
|
||||
{
|
||||
float sx;
|
||||
float sy;
|
||||
|
||||
// FIXME: The computation here is wrong when there is a rotation involved.
|
||||
NSSize scale;
|
||||
|
||||
if (_bounds.size.width == 0)
|
||||
{
|
||||
if (_frame.size.width == 0)
|
||||
sx = 1;
|
||||
scale.width = 1;
|
||||
else
|
||||
sx = FLT_MAX;
|
||||
scale.width = FLT_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
sx = _frame.size.width / _bounds.size.width;
|
||||
scale.width = _frame.size.width / _bounds.size.width;
|
||||
}
|
||||
|
||||
if (_bounds.size.height == 0)
|
||||
{
|
||||
if (_frame.size.height == 0)
|
||||
sy = 1;
|
||||
scale.height = 1;
|
||||
else
|
||||
sy = FLT_MAX;
|
||||
scale.height = FLT_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
sy = _frame.size.height / _bounds.size.height;
|
||||
scale.height = _frame.size.height / _bounds.size.height;
|
||||
}
|
||||
|
||||
if (_boundsMatrix == nil)
|
||||
{
|
||||
_boundsMatrix = [NSAffineTransform new];
|
||||
}
|
||||
[_boundsMatrix scaleTo: sx : sy];
|
||||
|
||||
if (sx != 1 || sy != 1)
|
||||
return scale;
|
||||
}
|
||||
|
||||
- (void) _updateBoundsMatrix
|
||||
{
|
||||
NSSize scale;
|
||||
|
||||
NSDebugLLog(@"NSView", @"%@ updateBoundsMatrix", self);
|
||||
|
||||
// FIXME: The computation here is wrong when there is a rotation involved.
|
||||
if (_is_rotated_from_base)
|
||||
return;
|
||||
|
||||
scale = [self _computeScale];
|
||||
if (scale.width != 1 || scale.height != 1)
|
||||
{
|
||||
_is_rotated_or_scaled_from_base = YES;
|
||||
|
||||
if (_boundsMatrix == nil)
|
||||
{
|
||||
_boundsMatrix = [NSAffineTransform new];
|
||||
}
|
||||
[_boundsMatrix scaleTo: scale.width : scale.height];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1093,7 +1104,15 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
{
|
||||
if (_is_rotated_or_scaled_from_base == YES)
|
||||
{
|
||||
[self _updateBoundsMatrix];
|
||||
//[self _updateBoundsMatrix];
|
||||
NSAffineTransform *matrix;
|
||||
NSRect frame = _frame;
|
||||
|
||||
frame.origin = NSMakePoint(0, 0);
|
||||
matrix = [_boundsMatrix copy];
|
||||
[matrix invert];
|
||||
[matrix boundingRectFor: frame result: &_bounds];
|
||||
RELEASE(matrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1156,13 +1175,28 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
|
||||
if (_is_rotated_or_scaled_from_base)
|
||||
{
|
||||
float sx = _bounds.size.width / _frame.size.width;
|
||||
float sy = _bounds.size.height / _frame.size.height;
|
||||
|
||||
_frame.size = newSize;
|
||||
_bounds.size.width = _frame.size.width * sx;
|
||||
_bounds.size.height = _frame.size.height * sy;
|
||||
// FIXME: May need to update the bounds matrix.
|
||||
if (_boundsMatrix == nil)
|
||||
{
|
||||
float sx = _bounds.size.width / _frame.size.width;
|
||||
float sy = _bounds.size.height / _frame.size.height;
|
||||
|
||||
_frame.size = newSize;
|
||||
_bounds.size.width = _frame.size.width * sx;
|
||||
_bounds.size.height = _frame.size.height * sy;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSAffineTransform *matrix;
|
||||
NSRect frame;
|
||||
|
||||
_frame.size = newSize;
|
||||
frame = _frame;
|
||||
frame.origin = NSMakePoint(0, 0);
|
||||
matrix = [_boundsMatrix copy];
|
||||
[matrix invert];
|
||||
[matrix boundingRectFor: frame result: &_bounds];
|
||||
RELEASE(matrix);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1187,7 +1221,7 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
/* no frame matrix, create one since it is needed for rotation */
|
||||
if (_frameMatrix == nil)
|
||||
{
|
||||
// Map fromsuperview to frame
|
||||
// Map from superview to frame
|
||||
_frameMatrix = [NSAffineTransform new];
|
||||
}
|
||||
|
||||
|
@ -1240,6 +1274,165 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
}
|
||||
}
|
||||
|
||||
- (void) setBounds: (NSRect)aRect
|
||||
{
|
||||
NSDebugLLog(@"NSView", @"setBounds %@", NSStringFromRect(aRect));
|
||||
if (aRect.size.width < 0)
|
||||
{
|
||||
NSWarnMLog(@"given negative width", 0);
|
||||
aRect.size.width = 0;
|
||||
}
|
||||
if (aRect.size.height < 0)
|
||||
{
|
||||
NSWarnMLog(@"given negative height", 0);
|
||||
aRect.size.height = 0;
|
||||
}
|
||||
|
||||
if (_is_rotated_from_base || (NSEqualRects(_bounds, aRect) == NO))
|
||||
{
|
||||
NSAffineTransform *matrix;
|
||||
NSPoint oldOrigin;
|
||||
|
||||
if (_coordinates_valid)
|
||||
{
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
}
|
||||
if (_boundsMatrix == nil)
|
||||
{
|
||||
_boundsMatrix = [NSAffineTransform new];
|
||||
oldOrigin = NSMakePoint(NSMinX(_bounds), NSMinY(_bounds));
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix = [_boundsMatrix copy];
|
||||
[matrix invert];
|
||||
oldOrigin = [matrix transformPoint: NSMakePoint(0, 0)];
|
||||
RELEASE(matrix);
|
||||
}
|
||||
[_boundsMatrix translateXBy: oldOrigin.x - aRect.origin.x
|
||||
yBy: oldOrigin.y - aRect.origin.y];
|
||||
if (_is_rotated_from_base)
|
||||
{
|
||||
// Ignore scaling
|
||||
|
||||
// Adjust bounds
|
||||
NSRect frame = _frame;
|
||||
|
||||
frame.origin = NSMakePoint(0, 0);
|
||||
matrix = [_boundsMatrix copy];
|
||||
[matrix invert];
|
||||
[matrix boundingRectFor: frame result: &_bounds];
|
||||
RELEASE(matrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Adjust bounds
|
||||
_bounds = aRect;
|
||||
|
||||
// FIXME: Adjust scale
|
||||
[self _updateBoundsMatrix];
|
||||
}
|
||||
|
||||
[self resetCursorRects];
|
||||
if (_post_bounds_changes)
|
||||
{
|
||||
[nc postNotificationName: NSViewBoundsDidChangeNotification
|
||||
object: self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setBoundsOrigin: (NSPoint)newOrigin
|
||||
{
|
||||
NSPoint oldOrigin;
|
||||
|
||||
if (_boundsMatrix == nil)
|
||||
{
|
||||
oldOrigin = NSMakePoint(NSMinX(_bounds), NSMinY(_bounds));
|
||||
}
|
||||
else
|
||||
{
|
||||
NSAffineTransform *matrix = [_boundsMatrix copy];
|
||||
|
||||
[matrix invert];
|
||||
oldOrigin = [matrix transformPoint: NSMakePoint(0, 0)];
|
||||
RELEASE(matrix);
|
||||
}
|
||||
[self translateOriginToPoint: NSMakePoint(oldOrigin.x - newOrigin.x,
|
||||
oldOrigin.y - newOrigin.y)];
|
||||
}
|
||||
|
||||
- (void) setBoundsSize: (NSSize)newSize
|
||||
{
|
||||
NSDebugLLog(@"NSView", @"%@ setBoundsSize: %@", self,
|
||||
NSStringFromSize(newSize));
|
||||
|
||||
if (newSize.width < 0)
|
||||
{
|
||||
NSWarnMLog(@"given negative width", 0);
|
||||
newSize.width = 0;
|
||||
}
|
||||
if (newSize.height < 0)
|
||||
{
|
||||
NSWarnMLog(@"given negative height", 0);
|
||||
newSize.height = 0;
|
||||
}
|
||||
// This may seem strange, but Cocoa only adjusts the bounds, when there
|
||||
// is no rotation
|
||||
if (!_is_rotated_from_base)
|
||||
{
|
||||
if (_coordinates_valid)
|
||||
{
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
}
|
||||
_bounds.size = newSize;
|
||||
|
||||
// FIXME: Adjust scale
|
||||
[self _updateBoundsMatrix];
|
||||
|
||||
[self resetCursorRects];
|
||||
if (_post_bounds_changes)
|
||||
{
|
||||
[nc postNotificationName: NSViewBoundsDidChangeNotification
|
||||
object: self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setBoundsRotation: (float)angle
|
||||
{
|
||||
[self rotateByAngle: angle - [self boundsRotation]];
|
||||
}
|
||||
|
||||
- (void) translateOriginToPoint: (NSPoint)point
|
||||
{
|
||||
NSDebugLLog(@"NSView", @"%@ translateOriginToPoint: %@", self,
|
||||
NSStringFromPoint(point));
|
||||
if (NSEqualPoints(NSZeroPoint, point) == NO)
|
||||
{
|
||||
if (_coordinates_valid)
|
||||
{
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
}
|
||||
if (_boundsMatrix == nil)
|
||||
{
|
||||
_boundsMatrix = [NSAffineTransform new];
|
||||
}
|
||||
[_boundsMatrix translateXBy: point.x
|
||||
yBy: point.y];
|
||||
// Adjust bounds
|
||||
_bounds.origin.x -= point.x;
|
||||
_bounds.origin.y -= point.y;
|
||||
|
||||
[self resetCursorRects];
|
||||
if (_post_bounds_changes)
|
||||
{
|
||||
[nc postNotificationName: NSViewBoundsDidChangeNotification
|
||||
object: self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) scaleUnitSquareToSize: (NSSize)newSize
|
||||
{
|
||||
if (newSize.width != 1.0 || newSize.height != 1.0)
|
||||
|
@ -1264,30 +1457,15 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
_boundsMatrix = [NSAffineTransform new];
|
||||
}
|
||||
[_boundsMatrix scaleXBy: newSize.width yBy: newSize.height];
|
||||
|
||||
if (_is_rotated_from_base)
|
||||
{
|
||||
NSAffineTransform *matrix;
|
||||
NSRect frame = _frame;
|
||||
|
||||
frame.origin = NSMakePoint(0, 0);
|
||||
|
||||
// Adjust bounds
|
||||
matrix = [_boundsMatrix copy];
|
||||
[matrix invert];
|
||||
[matrix boundingRectFor: frame result: &_bounds];
|
||||
RELEASE(matrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
_bounds.origin.x = _bounds.origin.x / newSize.width;
|
||||
_bounds.origin.y = _bounds.origin.y / newSize.height;
|
||||
_bounds.size.width = _bounds.size.width / newSize.width;
|
||||
_bounds.size.height = _bounds.size.height / newSize.height;
|
||||
}
|
||||
// Adjust bounds
|
||||
_bounds.origin.x = _bounds.origin.x / newSize.width;
|
||||
_bounds.origin.y = _bounds.origin.y / newSize.height;
|
||||
_bounds.size.width = _bounds.size.width / newSize.width;
|
||||
_bounds.size.height = _bounds.size.height / newSize.height;
|
||||
|
||||
_is_rotated_or_scaled_from_base = YES;
|
||||
|
||||
[self resetCursorRects];
|
||||
if (_post_bounds_changes)
|
||||
{
|
||||
[nc postNotificationName: NSViewBoundsDidChangeNotification
|
||||
|
@ -1296,19 +1474,9 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
}
|
||||
}
|
||||
|
||||
- (void) setBounds: (NSRect)aRect
|
||||
- (void) rotateByAngle: (float)angle
|
||||
{
|
||||
if (aRect.size.width < 0)
|
||||
{
|
||||
NSWarnMLog(@"given negative width", 0);
|
||||
aRect.size.width = 0;
|
||||
}
|
||||
if (aRect.size.height < 0)
|
||||
{
|
||||
NSWarnMLog(@"given negative height", 0);
|
||||
aRect.size.height = 0;
|
||||
}
|
||||
if (_is_rotated_from_base)
|
||||
if (angle != 0.0)
|
||||
{
|
||||
NSAffineTransform *matrix;
|
||||
NSRect frame = _frame;
|
||||
|
@ -1322,157 +1490,15 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
{
|
||||
_boundsMatrix = [NSAffineTransform new];
|
||||
}
|
||||
[_boundsMatrix
|
||||
setFrameOrigin: NSMakePoint(-aRect.origin.x, -aRect.origin.y)];
|
||||
/*
|
||||
FIXME: We need to adjust the size as well, but the computation in
|
||||
_updateBoundsMatrix is wrong for this case.
|
||||
_bounds.size = aRect.size;
|
||||
[self _updateBoundsMatrix];
|
||||
*/
|
||||
|
||||
// Adjust bounds
|
||||
matrix = [_boundsMatrix copy];
|
||||
[matrix invert];
|
||||
[matrix boundingRectFor: frame result: &_bounds];
|
||||
RELEASE(matrix);
|
||||
[self resetCursorRects];
|
||||
if (_post_bounds_changes)
|
||||
{
|
||||
[nc postNotificationName: NSViewBoundsDidChangeNotification
|
||||
object: self];
|
||||
}
|
||||
}
|
||||
else if (NSEqualRects(_bounds, aRect) == NO)
|
||||
{
|
||||
if (_coordinates_valid)
|
||||
{
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
}
|
||||
_bounds = aRect;
|
||||
if (_boundsMatrix == nil)
|
||||
{
|
||||
_boundsMatrix = [NSAffineTransform new];
|
||||
}
|
||||
[_boundsMatrix
|
||||
setFrameOrigin: NSMakePoint(-_bounds.origin.x, -_bounds.origin.y)];
|
||||
[self _updateBoundsMatrix];
|
||||
[self resetCursorRects];
|
||||
if (_post_bounds_changes)
|
||||
{
|
||||
[nc postNotificationName: NSViewBoundsDidChangeNotification
|
||||
object: self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setBoundsOrigin: (NSPoint)newOrigin
|
||||
{
|
||||
if (_is_rotated_from_base)
|
||||
{
|
||||
NSAffineTransform *matrix;
|
||||
NSRect frame = _frame;
|
||||
|
||||
frame.origin = NSMakePoint(0, 0);
|
||||
if (_coordinates_valid)
|
||||
{
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
}
|
||||
if (_boundsMatrix == nil)
|
||||
{
|
||||
_boundsMatrix = [NSAffineTransform new];
|
||||
}
|
||||
[_boundsMatrix setFrameOrigin: NSMakePoint(-newOrigin.x, -newOrigin.y)];
|
||||
|
||||
// Adjust bounds
|
||||
matrix = [_boundsMatrix copy];
|
||||
[matrix invert];
|
||||
[matrix boundingRectFor: frame result: &_bounds];
|
||||
RELEASE(matrix);
|
||||
[self resetCursorRects];
|
||||
if (_post_bounds_changes)
|
||||
{
|
||||
[nc postNotificationName: NSViewBoundsDidChangeNotification
|
||||
object: self];
|
||||
}
|
||||
}
|
||||
else if (NSEqualPoints(_bounds.origin, newOrigin) == NO)
|
||||
{
|
||||
if (_coordinates_valid)
|
||||
{
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
}
|
||||
_bounds.origin = newOrigin;
|
||||
if (_boundsMatrix == nil)
|
||||
{
|
||||
_boundsMatrix = [NSAffineTransform new];
|
||||
}
|
||||
[_boundsMatrix setFrameOrigin: NSMakePoint(-newOrigin.x, -newOrigin.y)];
|
||||
[self resetCursorRects];
|
||||
if (_post_bounds_changes)
|
||||
{
|
||||
[nc postNotificationName: NSViewBoundsDidChangeNotification
|
||||
object: self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setBoundsSize: (NSSize)newSize
|
||||
{
|
||||
if (newSize.width < 0)
|
||||
{
|
||||
NSWarnMLog(@"given negative width", 0);
|
||||
newSize.width = 0;
|
||||
}
|
||||
if (newSize.height < 0)
|
||||
{
|
||||
NSWarnMLog(@"given negative height", 0);
|
||||
newSize.height = 0;
|
||||
}
|
||||
// FIXME: What to do in the rotation case?
|
||||
if (NSEqualSizes(_bounds.size, newSize) == NO)
|
||||
{
|
||||
if (_coordinates_valid)
|
||||
{
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
}
|
||||
|
||||
_bounds.size = newSize;
|
||||
[self _updateBoundsMatrix];
|
||||
[self resetCursorRects];
|
||||
if (_post_bounds_changes)
|
||||
{
|
||||
[nc postNotificationName: NSViewBoundsDidChangeNotification
|
||||
object: self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setBoundsRotation: (float)angle
|
||||
{
|
||||
float oldAngle = [self boundsRotation];
|
||||
|
||||
if (angle != oldAngle)
|
||||
{
|
||||
NSAffineTransform *matrix;
|
||||
NSRect frame = _frame;
|
||||
|
||||
frame.origin = NSMakePoint(0, 0);
|
||||
if (_coordinates_valid)
|
||||
{
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
}
|
||||
if (_boundsMatrix == nil)
|
||||
{
|
||||
_boundsMatrix = [NSAffineTransform new];
|
||||
}
|
||||
[_boundsMatrix rotateByDegrees: angle - oldAngle];
|
||||
_is_rotated_from_base = _is_rotated_or_scaled_from_base = YES;
|
||||
[_boundsMatrix rotateByDegrees: angle];
|
||||
// Adjust bounds
|
||||
matrix = [_boundsMatrix copy];
|
||||
[matrix invert];
|
||||
[matrix boundingRectFor: frame result: &_bounds];
|
||||
RELEASE(matrix);
|
||||
|
||||
_is_rotated_from_base = _is_rotated_or_scaled_from_base = YES;
|
||||
|
||||
[self resetCursorRects];
|
||||
if (_post_bounds_changes)
|
||||
{
|
||||
|
@ -1482,17 +1508,6 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
}
|
||||
}
|
||||
|
||||
- (void) translateOriginToPoint: (NSPoint)point
|
||||
{
|
||||
[self setBoundsOrigin: NSMakePoint(NSMinX(_bounds) - point.x,
|
||||
NSMinY(_bounds) - point.y)];
|
||||
}
|
||||
|
||||
- (void) rotateByAngle: (float)angle
|
||||
{
|
||||
[self setBoundsRotation: [self boundsRotation] + angle];
|
||||
}
|
||||
|
||||
- (NSRect) centerScanRect: (NSRect)aRect
|
||||
{
|
||||
NSAffineTransform *matrix;
|
||||
|
|
|
@ -2769,6 +2769,8 @@ resetCursorRectsForView(NSView *theView)
|
|||
{
|
||||
NSWindow *mini = GSWindowWithNumber(_counterpart);
|
||||
[mini orderFront: self];
|
||||
// If the window is still visible, order it out.
|
||||
[self orderOut: self];
|
||||
}
|
||||
[nc postNotificationName: NSWindowDidMiniaturizeNotification
|
||||
object: self];
|
||||
|
|
|
@ -1045,10 +1045,14 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
|
|||
{
|
||||
NSImage *image = nil;
|
||||
NSString *pathExtension = [[fullPath pathExtension] lowercaseString];
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
NSDictionary *attributes;
|
||||
NSString *fileType;
|
||||
|
||||
if ([self isFilePackageAtPath: fullPath])
|
||||
attributes = [mgr fileAttributesAtPath: fullPath traverseLink: YES];
|
||||
fileType = [attributes objectForKey: NSFileType];
|
||||
if ([fileType isEqual: NSFileTypeDirectory] == YES)
|
||||
{
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
NSString *iconPath = nil;
|
||||
BOOL isApplication = NO;
|
||||
|
||||
|
@ -1203,13 +1207,29 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
|
|||
{
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
NSDictionary *attributes;
|
||||
NSString *fileType;
|
||||
NSString *fileType, *extension;
|
||||
|
||||
attributes = [mgr fileAttributesAtPath: fullPath traverseLink: YES];
|
||||
fileType = [attributes objectForKey: NSFileType];
|
||||
if ([fileType isEqual: NSFileTypeDirectory] == YES)
|
||||
{
|
||||
return YES;
|
||||
/*
|
||||
* We return YES here exactly when getInfoForFile:application:type:
|
||||
* considers the directory an application or a plain file
|
||||
*/
|
||||
extension = [fullPath pathExtension];
|
||||
if ([extension isEqualToString: @"app"]
|
||||
|| [extension isEqualToString: @"debug"]
|
||||
|| [extension isEqualToString: @"profile"]
|
||||
|| [extension isEqualToString: @"bundle"])
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
else if ([extension length] > 0
|
||||
&& [self getBestAppInRole: nil forExtension: extension] != nil)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue