Backport patches from trunk

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_stable_20070311@25622 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2007-11-28 04:38:35 +00:00
parent 1068eb6393
commit 3813fd4365
23 changed files with 2783 additions and 2316 deletions

192
ChangeLog
View file

@ -1,3 +1,195 @@
2007-10-28 01:44-EDT Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSTableView.m: reverted change to validateEditing to
correct crashes.
* Backported from trunk.
2007-10-27 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTableHeaderView.m (-drawRect:): Switch drawing cases for
flipping.
* Source/NSTableView.m (GSTableCornerView): Made flipped and
adjust drawing code.
* Backported from trunk.
2007-10-02 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSWindow.m (-deminiaturize:, -miniaturize:): Try to
handle the case better, where GNUstep manages the mini window and
the window decoration itself.
Based on patch by Stefan Bidigaray <stefanbidi@gmail.com>.
* Backported from trunk.
2007-10-02 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSPopUpButtonCell.m (-cellSize): Don't return zero size,
when there are no items. Based on patch by Andreas Höschler
<ahoesch@smartsoft.de>.
* Backported from trunk.
2007-10-01 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSDocument.m (-setFileName:, -fileURL:, -setUndoManager:
-writeToURL:...error:): Small fixes of previous changes.
Patch by Wolfgang Lux <wolfgang.lux@gmail.com>.
* Backported from trunk.
2007-09-30 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSWindow.m (-cascadeTopLeftFromPoint:): Adopt the
resulting next point to visible screen. Based on patch by
Wolfgang Lux <wolfgang.lux@gmail.com>.
* Backported from trunk.
2007-09-13 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTableView.m (-validateEditing): Set object value to
nil, when formatting the string failed.
* Source/NSActionCell.m (-intValue): Check flag in_editing before
validating the editing.
* Backported from trunk.
2007-09-12 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSToolbarItem.m (GSToolbarButtonCell-drawInteriorWithFrame:inView:):
Made working for a flipped view.
* Backported from trunk.
2007-09-11 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSSplitView.m (-displayRectIgnoringOpacity:inContext:):
Implement this method instead of the two old display methods.
* Backported from trunk.
2007-09-11 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTextView.m (-drawRect:, -rectForCharacterRange:,
-firstRectForCharacterRange:): Protect againt layoutmanager being nil.
* Source/NSTableView.m (-validateEditing): Use setStringValue:
when converting the string failed.
* Source/NSTableView.m (-mouseDown:): Don't interrupt editing
another cell, if the current string isn't valid.
Patches partly by Andreas Höschler <ahoesch@smartsoft.de>.
* Backported from trunk.
2007-09-10 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSPopUpButtonCell.m (-insertItemWithTitle:atIndex:):
Select new item when there isn't any selection.
* Backported from trunk.
2007-09-10 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTableHeaderView.m,
* Source/NSSlider.m,
* Source/NSProgressIndicator.m,
* Source/NSButton.m (-isFlipped): Add fliiping.
* Source/NSTableHeaderView.m (-drawRect:): Adjust for flipping.
* Source/NSTabView.m: Mark as needing an isFlipped method.
* Backported from trunk.
2007-09-05 Nicolas Roard <nicolas@roard.com>
* Source/NSView.m (-scrollRect:by:): reversed the coordinates
of destPoint (substract instead of add), to match OSX behaviour.
* Source/NSClipView.m (-setBoundsOrigin): reversed the coordinates
of the call to scrollRect:by:, to match OSX behaviour.
* Backported from trunk.
2007-09-05 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSWindow.m (-sendEvent:, -selectKeyViewFollowingView:,
-selectKeyViewPrecedingView:, -selectNextKeyView:,
-selectPreviousKeyView:): Handle case when makeFirstResonder:
fails.
* Backported from trunk.
2007-09-05 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSLayoutManager.m
(-glyphIndexForPoint:...fractionOfDistanceThroughGlyph:): Don't
ignore invisible glyphs.
* Source/NSTextView.m (-_characterIndexForPoint:respectFraction:):
New helper method.
* Source/NSTextView.m (-characterIndexForPoint:): Correct to use
screen coordinates.
* Source/NSTextView.m (-draggingEntered:, -draggingUpdated:,
-mouseDown:): Use new helper method.
* Source/NSAlert.m (-_setupPanel): Check count of buttons.
* Source/NSDocument.m (-setFileName:, -setFileURL:): Set url and
file name always together.
* Source/NSDocument.m (-dataOfType:error:,
-fileWrapperOfType:error:, -readFromFileWrapper:ofType:error:,
-readFromURL:ofType:error:, -writeSafelyToURL:...error:,
-writeToURL:ofType:error:, -writeToURL:...error:,
-printOperationWithSettings:error:): Set error to nil.
Patches by Wolfgang Lux <wolfgang.lux@gmail.com>.
* Backported from trunk.
2007-09-04 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSActionCell.m (-objectValue, -attributedStringValue):
Add validation of editing.
* Backported from trunk.
2007-08-31 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSWindow.m (-makeFirstResponder:): When parameter is nil,
set self as first responder and return YES.
* Source/NSCell.m (-isEntryAcceptable:): Accept empty strings.
* Source/NSTableView.m (-validateEditing): Check if delegate
supports method, before calling it.
* Source/NSTextField.m (-validateEditing): Accept empty strings.
Patches partly by Andreas Höschler <ahoesch@smartsoft.de>.
* Backported from trunk.
2007-08-28 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSApplication.m (-_windowWillClose:): Don't call
resignKey on the window. Reorganise the code some more and add comments.
* Source/NSWindow.m (-_lossOfKeyOrMainWindow): Check all windows
whether they could take key or main status.
* Backported from trunk.
2007-08-21 Fred Kiefer <FredKiefe@gmx.de>
* Source/NSAttributedString.m (-fixFontAttributeInRange:): Ignore
characters below 31.
Patch by Yen-Ju Chen <yjchenx@gmail.com>
* Backported from trunk.
2007-08-20 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSWindow.m (-sendEvent:): For the left mouse down case
make sure that the affected view is still valid after activating
the application and making the window key.
* Backported from trunk.
2007-08-20 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSInputManager.m (-handleKeyboardEvents:client:): Set the
isFunctionKey boolean correctly. This was needed as the
NSFunctionKeyMask value doesn't fit in the first byte.
* Backported from trunk.
2007-08-19 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSButton.m ([performKeyEquivalent:]): Only test for modal
window when it isn't nil.
* Backported from trunk.
2007-08-12 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSAttributedString.m (-_substituteFontWithName:font:):
Let the font manager handle the font convertion.
* Backported from trunk.
2007-08-09 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSAttributedString.m (-fixFontAttributeInRange:):
First attempt at font attribute fixing.
* Backported from trunk.
2007-08-03 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSWorkspace.m: ([-launchedApplications]) complete and tidy

View file

@ -1566,30 +1566,31 @@ void NSBeginInformationalAlertSheet(NSString *title,
{
GSAlertPanel *panel;
NSString *title;
unsigned nbut = [_buttons count];
panel = [[GSAlertPanel alloc] init];
_window = panel;
switch (_style)
{
case NSCriticalAlertStyle:
title = @"Critical";
break;
case NSInformationalAlertStyle:
title = @"Information";
break;
case NSWarningAlertStyle:
default:
title = @"Alert";
break;
}
{
case NSCriticalAlertStyle:
title = @"Critical";
break;
case NSInformationalAlertStyle:
title = @"Information";
break;
case NSWarningAlertStyle:
default:
title = @"Alert";
break;
}
[panel setTitleBar: title
icon: _icon
title: _informative_text
message: _message_text
def: [[_buttons objectAtIndex: 0] title]
alt: [[_buttons objectAtIndex: 1] title]
other: [[_buttons objectAtIndex: 2] title]];
icon: _icon
title: _informative_text
message: _message_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];
}
}

View file

@ -509,46 +509,45 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
{
/* if not hidden raise windows which are possibly obscured. */
if ([NSApp isHidden] == NO)
{
NSArray *windows = RETAIN(GSOrderedWindows());
NSWindow *aWin;
NSEnumerator *iter = [windows reverseObjectEnumerator];
while ((aWin = [iter nextObject]))
{
if ([aWin isVisible] == YES && [aWin isMiniaturized] == NO
&& aWin != [NSApp keyWindow] && aWin != [NSApp mainWindow]
&& aWin != [self window]
&& ([aWin styleMask] & NSMiniWindowMask) == 0)
{
[aWin orderFrontRegardless];
}
}
{
NSArray *windows = RETAIN(GSOrderedWindows());
NSWindow *aWin;
NSEnumerator *iter = [windows reverseObjectEnumerator];
while ((aWin = [iter nextObject]))
{
if ([aWin isVisible] == YES && [aWin isMiniaturized] == NO
&& aWin != [NSApp keyWindow] && aWin != [NSApp mainWindow]
&& aWin != [self window]
&& ([aWin styleMask] & NSMiniWindowMask) == 0)
{
[aWin orderFrontRegardless];
}
}
if ([NSApp isActive] == YES)
{
if ([NSApp keyWindow] != nil)
{
[[NSApp keyWindow] orderFront: self];
}
else if ([NSApp mainWindow] != nil)
{
[[NSApp mainWindow] makeKeyAndOrderFront: self];
}
else
{
/* We need give input focus to some window otherwise we'll
never get keyboard events. FIXME: doesn't work. */
NSWindow *menu_window= [[NSApp mainMenu] window];
NSDebugLLog(@"Focus", @"No key on activation - make menu key");
[GSServerForWindow(menu_window) setinputfocus:
[menu_window windowNumber]];
}
}
if ([NSApp isActive] == YES)
{
if ([NSApp keyWindow] != nil)
{
[[NSApp keyWindow] orderFront: self];
}
else if ([NSApp mainWindow] != nil)
{
[[NSApp mainWindow] makeKeyAndOrderFront: self];
}
else
{
/* We need give input focus to some window otherwise we'll
never get keyboard events. FIXME: doesn't work. */
NSWindow *menu_window= [[NSApp mainMenu] window];
NSDebugLLog(@"Focus", @"No key on activation - make menu key");
[GSServerForWindow(menu_window) setinputfocus:
[menu_window windowNumber]];
}
}
RELEASE(windows);
}
}
[NSApp unhide: self]; // or activate or do nothing.
}
@ -1148,57 +1147,57 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
* visible when the application is active.
*/
[nc postNotificationName: NSApplicationWillBecomeActiveNotification
object: self];
object: self];
_app_is_active = YES;
/* Make sure to calculate count after the notification, since
inactive status might be changed by a notifiee. */
inactive status might be changed by a notifiee. */
count = [_inactive count];
for (i = 0; i < count; i++)
{
[[_inactive objectAtIndex: i] orderFrontRegardless];
}
{
[[_inactive objectAtIndex: i] orderFrontRegardless];
}
[_inactive removeAllObjects];
if (_unhide_on_activation)
{
[self unhide: nil];
}
{
[self unhide: nil];
}
if ([self keyWindow] == nil && _hidden_key != nil
&& [[self windows] indexOfObjectIdenticalTo: _hidden_key] != NSNotFound)
{
[_hidden_key makeKeyWindow];
_hidden_key = nil;
}
&& [[self windows] indexOfObjectIdenticalTo: _hidden_key] != NSNotFound)
{
[_hidden_key makeKeyWindow];
_hidden_key = nil;
}
if ([self keyWindow] != nil)
{
[[self keyWindow] orderFront: self];
}
{
[[self keyWindow] orderFront: self];
}
else if ([self mainWindow] != nil)
{
[[self mainWindow] makeKeyAndOrderFront: self];
}
{
[[self mainWindow] makeKeyAndOrderFront: self];
}
else
{
/* We need give input focus to some window otherwise we'll never get
keyboard events. FIXME: doesn't work. */
NSWindow *menu_window= [[self mainMenu] window];
NSDebugLLog(@"Focus", @"No key on activation - make menu key");
[GSServerForWindow(menu_window) setinputfocus:
[menu_window windowNumber]];
/* We need give input focus to some window otherwise we'll never get
keyboard events. FIXME: doesn't work. */
NSWindow *menu_window= [[self mainMenu] window];
NSDebugLLog(@"Focus", @"No key on activation - make menu key");
[GSServerForWindow(menu_window) setinputfocus:
[menu_window windowNumber]];
}
info = [self _notificationUserInfo];
[nc postNotificationName: NSApplicationDidBecomeActiveNotification
object: self
object: self
userInfo: info];
[[[NSWorkspace sharedWorkspace] notificationCenter]
postNotificationName: NSApplicationDidBecomeActiveNotification
postNotificationName: NSApplicationDidBecomeActiveNotification
object: [NSWorkspace sharedWorkspace]
userInfo: info];
userInfo: info];
}
}
@ -1216,16 +1215,15 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
NSEnumerator *iter;
[nc postNotificationName: NSApplicationWillResignActiveNotification
object: self];
object: self];
_app_is_active = NO;
if ([self keyWindow] != nil)
{
_hidden_key = [self keyWindow];
[_hidden_key resignKeyWindow];
}
{
_hidden_key = [self keyWindow];
[_hidden_key resignKeyWindow];
}
// FIXME: main window is not saved for when the app is activated again.
// This is not a problem if it is also key, and I'm not sure if it
// is a problem at all. May be annoying in the case of workspace switch.
@ -1235,47 +1233,47 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
iter = [windows_list reverseObjectEnumerator];
while ((win = [iter nextObject]))
{
NSModalSession theSession;
{
NSModalSession theSession;
if ([win isVisible] == NO)
{
continue; /* Already invisible */
}
if ([win canHide] == NO)
{
continue; /* Can't be hidden */
}
if (win == _app_icon_window)
{
continue; /* can't hide the app icon. */
}
/* Don't order out modal windows */
theSession = _session;
while (theSession != 0)
{
if (win == theSession->window)
break;
theSession = theSession->previous;
}
if (theSession)
continue;
if ([win hidesOnDeactivate] == YES)
{
[_inactive addObject: win];
[win orderOut: self];
}
}
if ([win isVisible] == NO)
{
continue; /* Already invisible */
}
if ([win canHide] == NO)
{
continue; /* Can't be hidden */
}
if (win == _app_icon_window)
{
continue; /* can't hide the app icon. */
}
/* Don't order out modal windows */
theSession = _session;
while (theSession != 0)
{
if (win == theSession->window)
break;
theSession = theSession->previous;
}
if (theSession)
continue;
if ([win hidesOnDeactivate] == YES)
{
[_inactive addObject: win];
[win orderOut: self];
}
}
info = [self _notificationUserInfo];
[nc postNotificationName: NSApplicationDidResignActiveNotification
object: self
object: self
userInfo: info];
[[[NSWorkspace sharedWorkspace] notificationCenter]
postNotificationName: NSApplicationDidResignActiveNotification
postNotificationName: NSApplicationDidResignActiveNotification
object: [NSWorkspace sharedWorkspace]
userInfo: info];
userInfo: info];
}
}
@ -2220,35 +2218,35 @@ image.</p><p>See Also: -applicationIconImage</p>
object: self];
if ([self keyWindow] != nil)
{
_hidden_key = [self keyWindow];
[_hidden_key resignKeyWindow];
}
{
_hidden_key = [self keyWindow];
[_hidden_key resignKeyWindow];
}
windows_list = GSOrderedWindows();
iter = [windows_list reverseObjectEnumerator];
while ((win = [iter nextObject]))
{
if ([win isVisible] == NO)
{
continue; /* Already invisible */
}
if ([win canHide] == NO)
{
continue; /* Not hideable */
}
if (win == _app_icon_window)
{
continue; /* can't hide the app icon. */
}
if (_app_is_active == YES && [win hidesOnDeactivate] == YES)
{
continue; /* Will be hidden by deactivation */
}
[_hidden addObject: win];
[win orderOut: self];
}
{
if ([win isVisible] == NO)
{
continue; /* Already invisible */
}
if ([win canHide] == NO)
{
continue; /* Not hideable */
}
if (win == _app_icon_window)
{
continue; /* can't hide the app icon. */
}
if (_app_is_active == YES && [win hidesOnDeactivate] == YES)
{
continue; /* Will be hidden by deactivation */
}
[_hidden addObject: win];
[win orderOut: self];
}
_app_is_hidden = YES;
[[_app_icon_window contentView] setNeedsDisplay: YES];
@ -3497,145 +3495,43 @@ image.</p><p>See Also: -applicationIconImage</p>
- (void) _windowWillClose: (NSNotification*) notification
{
NSWindow *win = [notification object];
NSArray *windows_list = GSOrderedWindows();
unsigned count = [windows_list count];
unsigned i;
NSMutableArray *list = [NSMutableArray arrayWithCapacity: count];
BOOL wasKey = [win isKeyWindow];
BOOL wasMain = [win isMainWindow];
NSEnumerator *iter = [windows_list objectEnumerator];
NSWindow *tmp;
while ((tmp = [iter nextObject]))
{
if ([tmp canBecomeMainWindow] == YES && [tmp isVisible] == YES)
{
[list addObject: tmp];
}
}
[list removeObjectIdenticalTo: win];
count = [list count];
/* If there's only one window left, and that's the one being closed,
then we ask the delegate if the app is to be terminated. */
if (wasMain && count == 0 && _app_is_running)
{
if ([_delegate respondsToSelector:
@selector(applicationShouldTerminateAfterLastWindowClosed:)])
{
if ([_delegate applicationShouldTerminateAfterLastWindowClosed: self])
{
[self terminate: self];
}
}
}
if (wasMain == YES)
{
[win resignMainWindow];
}
if (wasKey == YES)
{
[win resignKeyWindow];
}
NSWindow *win = [notification object];
BOOL wasMain = [win isMainWindow];
if (_app_is_running)
{
/*
* If we are not quitting, we may need to find a new key/main window.
*/
if (wasKey == YES && [self keyWindow] == nil)
{
win = [self mainWindow];
if (win != nil && [win canBecomeKeyWindow] == YES)
{
/*
* We have a main window that can become key, so do it.
*/
[win makeKeyAndOrderFront: self];
}
else if (win != nil)
{
/*
* We have a main window that can't become key, so we just
* find a new window to make into our key window.
*/
for (i = 0; i < count; i++)
{
win = [list objectAtIndex: i];
NSArray *windows_list = GSOrderedWindows();
unsigned count = [windows_list count];
NSEnumerator *iter = [windows_list objectEnumerator];
NSMutableArray *list = [NSMutableArray arrayWithCapacity: count];
NSWindow *tmp;
if ([win canBecomeKeyWindow] == YES)
{
[win makeKeyAndOrderFront: self];
}
}
}
else
{
/*
* Find a window that can be made key and main - and do it.
*/
for (i = 0; i < count; i++)
{
win = [list objectAtIndex: i];
if ([win canBecomeKeyWindow] && [win canBecomeMainWindow])
{
break;
}
}
if (i < count)
{
[win makeMainWindow];
[win makeKeyAndOrderFront: self];
}
else
{
/*
* No window we can use, so just find any candidate to
* be main window and another to be key window.
*/
for (i = 0; i < count; i++)
{
win = [list objectAtIndex: i];
if ([win canBecomeMainWindow] == YES)
{
[win makeMainWindow];
break;
}
}
for (i = 0; i < count; i++)
{
win = [list objectAtIndex: i];
if ([win canBecomeKeyWindow] == YES)
{
[win makeKeyAndOrderFront: self];
break;
}
}
}
}
}
else if ([self mainWindow] == nil)
{
win = [self keyWindow];
if ([win canBecomeMainWindow] == YES)
{
[win makeMainWindow];
}
else
{
for (i = 0; i < count; i++)
{
win = [list objectAtIndex: i];
if ([win canBecomeMainWindow] == YES)
{
[win makeMainWindow];
break;
}
}
}
}
/* FIXME: Why are non-visible windows not counted? When there are
minimized windows left over, this would still terminate the application.
*/
while ((tmp = [iter nextObject]))
{
if ([tmp canBecomeMainWindow] == YES && [tmp isVisible] == YES)
{
[list addObject: tmp];
}
}
[list removeObjectIdenticalTo: win];
count = [list count];
/* If there's only one window left, and that's the one being closed,
then we ask the delegate if the app is to be terminated. */
if (wasMain && count == 0)
{
if ([_delegate respondsToSelector:
@selector(applicationShouldTerminateAfterLastWindowClosed:)])
{
if ([_delegate applicationShouldTerminateAfterLastWindowClosed: self])
{
[self terminate: self];
}
}
}
}
}

View file

@ -28,6 +28,7 @@
*/
#include <Foundation/NSArray.h>
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSBundle.h>
#include <Foundation/NSCharacterSet.h>
#include <Foundation/NSDebug.h>
@ -46,6 +47,7 @@
#include "AppKit/NSColor.h"
#include "AppKit/NSFileWrapper.h"
#include "AppKit/NSFont.h"
#include "AppKit/NSFontManager.h"
// For the colour name spaces
#include "AppKit/NSGraphics.h"
@ -887,20 +889,163 @@ documentAttributes: (NSDictionary **)dict
[self fixAttachmentAttributeInRange: range];
}
static NSString *lastFont = nil;
static NSCharacterSet *lastSet = nil;
static NSMutableDictionary *cachedCSets = nil;
- (NSFont*)_substituteFontWithName: (NSString*)fontName font: (NSFont*)baseFont
{
return [[NSFontManager sharedFontManager] convertFont: baseFont toFace: fontName];
}
- (NSFont*)_substituteFontFor: (unichar)uchar font: (NSFont*)baseFont fromList: (NSArray *)fonts
{
unsigned int count;
unsigned int i;
count = [fonts count];
for (i = 0; i < count; i++)
{
NSFont *newFont;
NSString *fName;
NSCharacterSet *newSet;
fName = [fonts objectAtIndex: i];
newSet = [cachedCSets objectForKey: fName];
if (newSet == nil)
{
newFont = [self _substituteFontWithName: fName font: baseFont];
newSet = [newFont coveredCharacterSet];
if (newSet != nil)
{
[cachedCSets setObject: newSet forKey: fName];
}
}
else
{
newFont = nil;
}
if ([newSet characterIsMember: uchar])
{
ASSIGN(lastFont, fName);
ASSIGN(lastSet, newSet);
if (newFont != nil)
{
return newFont;
}
else
{
return [self _substituteFontWithName: fName font: baseFont];
}
}
}
return nil;
}
- (NSFont*)_substituteFontFor: (unichar)uchar font: (NSFont*)baseFont
{
NSFont *subFont;
// Caching one font may lead to the selected substitution font not being
// from the prefered list, although there is one there with this character.
if (lastSet && [lastSet characterIsMember: uchar])
{
return [self _substituteFontWithName: lastFont font: baseFont];
}
if (cachedCSets == nil)
{
cachedCSets = [NSMutableDictionary new];
}
subFont = [self _substituteFontFor: uchar font: baseFont fromList:
[NSFont preferredFontNames]];
if (subFont != nil)
{
return subFont;
}
subFont = [self _substituteFontFor: uchar font: baseFont fromList:
[[NSFontManager sharedFontManager] availableFonts]];
if (subFont != nil)
{
return subFont;
}
return nil;
}
- (void) fixFontAttributeInRange: (NSRange)range
{
NSString *string;
NSFont *font;
NSCharacterSet *charset = nil;
NSRange fontRange = NSMakeRange(NSNotFound, 0);
unsigned int i;
unsigned int lastMax;
unsigned int start;
unichar chars[64];
CREATE_AUTORELEASE_POOL(pool);
if (NSMaxRange (range) > [self length])
{
[NSException raise: NSRangeException
format: @"RangeError in method -fixFontAttributeInRange: "];
}
// FIXME: Should check for each character if it is supported by the
// Check for each character if it is supported by the
// assigned font
/*
Note that this needs to be done on a script basis. Per-character checks
are difficult to do at all, don't give reasonable results, and would have
really poor performance.
*/
string = [self string];
lastMax = range.location;
start = lastMax;
for (i = range.location; i < NSMaxRange(range); i++)
{
unichar uchar;
if (i >= lastMax)
{
unsigned int dist;
start = lastMax;
dist = MIN(64, NSMaxRange(range) - start);
lastMax = start + dist;
[string getCharacters: chars range: NSMakeRange(start, dist)];
}
uchar = chars[i - start];
if (!NSLocationInRange(i, fontRange))
{
font = [self attribute: NSFontAttributeName
atIndex: i
effectiveRange: &fontRange];
charset = [font coveredCharacterSet];
}
if (charset != nil && ![charset characterIsMember: uchar]
&& (uchar > 31))
{
// Find a replacement font
NSFont *subFont;
subFont = [self _substituteFontFor: uchar font: font];
if (subFont != nil)
{
// Set substitution font permanently
[self addAttribute: NSFontAttributeName
value: subFont
range: NSMakeRange(i, 1)];
}
}
}
RELEASE(pool);
}
- (void) fixParagraphStyleAttributeInRange: (NSRange)range

View file

@ -80,6 +80,11 @@ static id buttonCellClass = nil;
return YES;
}
- (BOOL) isFlipped
{
return YES;
}
/** <p>Sets the NSButtonCell's type to <var>aType</var> and marks self for
display.See <ref type="type" id="NSButtonType">NSButtonType</ref> for more
information.</p><p>See Also: [NSButtonCell-setButtonType:]</p>
@ -471,19 +476,19 @@ static id buttonCellClass = nil;
unichar character = 0;
if ([characters length] > 0)
{
character = [characters characterAtIndex: 0];
}
{
character = [characters characterAtIndex: 0];
}
// Handle SPACE or RETURN to perform a click
if ((character == NSNewlineCharacter)
|| (character == NSEnterCharacter)
|| (character == NSCarriageReturnCharacter)
|| ([characters isEqualToString: @" "]))
{
[self performClick: self];
return;
}
{
[self performClick: self];
return;
}
}
[super keyDown: theEvent];
@ -506,22 +511,23 @@ static id buttonCellClass = nil;
*/
- (BOOL) performKeyEquivalent: (NSEvent *)anEvent
{
NSWindow *w = [self window];
NSWindow *w = [self window];
NSWindow *mw = [NSApp modalWindow];
if ([self isEnabled] && ([w worksWhenModal] || [NSApp modalWindow] == w))
if ([self isEnabled] && (mw == nil || [w worksWhenModal] || mw == w))
{
NSString *key = [self keyEquivalent];
if (key != nil && [key isEqual: [anEvent charactersIgnoringModifiers]])
{
unsigned int mask = [self keyEquivalentModifierMask];
{
unsigned int mask = [self keyEquivalentModifierMask];
if (([anEvent modifierFlags] & mask) == mask)
{
[self performClick: self];
return YES;
}
}
if (([anEvent modifierFlags] & mask) == mask)
{
[self performClick: self];
return YES;
}
}
}
return NO;
}

View file

@ -1238,13 +1238,13 @@ static NSColor *shadowCol;
- (BOOL) isEntryAcceptable: (NSString*)aString
{
if (_formatter != nil)
if ((_formatter != nil) && ![aString isEqualToString: @""])
{
id newObjectValue;
return [_formatter getObjectValue: &newObjectValue
forString: aString
errorDescription: NULL];
forString: aString
errorDescription: NULL];
}
else
{

View file

@ -290,7 +290,7 @@ static inline NSRect integralRect (NSRect rect, NSView *view)
NSRect redrawRect;
/* Copy the intersection to the new position */
[self scrollRect: intersection by: NSMakeSize(dx, dy)];
[self scrollRect: intersection by: NSMakeSize(-dx, -dy)];
/* Change coordinate system to the new one */
[super setBoundsOrigin: newBounds.origin];

File diff suppressed because it is too large Load diff

View file

@ -164,39 +164,39 @@ static NSInputManager *currentInputManager = nil;
NSString *modifier = [components objectAtIndex: i];
if ([modifier isEqualToString: @"Control"]
|| [modifier isEqualToString: @"Ctrl"]
|| [modifier isEqualToString: @"C"])
{
flags |= NSControlKeyMask;
}
|| [modifier isEqualToString: @"Ctrl"]
|| [modifier isEqualToString: @"C"])
{
flags |= NSControlKeyMask;
}
else if ([modifier isEqualToString: @"Alternate"]
|| [modifier isEqualToString: @"Alt"]
|| [modifier isEqualToString: @"A"]
|| [modifier isEqualToString: @"Meta"]
|| [modifier isEqualToString: @"M"])
{
flags |= NSAlternateKeyMask;
}
|| [modifier isEqualToString: @"Alt"]
|| [modifier isEqualToString: @"A"]
|| [modifier isEqualToString: @"Meta"]
|| [modifier isEqualToString: @"M"])
{
flags |= NSAlternateKeyMask;
}
/* The Shift modifier is only meaningful when used in
* conjunction with function keys. 'Shift-LeftArrow' is
* meaningful; 'Control-Shift-g' is not - you should use
* 'Control-G' instead. */
else if ([modifier isEqualToString: @"Shift"]
|| [modifier isEqualToString: @"S"])
{
flags |= NSShiftKeyMask;
}
|| [modifier isEqualToString: @"S"])
{
flags |= NSShiftKeyMask;
}
else if ([modifier isEqualToString: @"NumericPad"]
|| [modifier isEqualToString: @"Numeric"]
|| [modifier isEqualToString: @"N"])
{
flags |= NSNumericPadKeyMask;
}
|| [modifier isEqualToString: @"Numeric"]
|| [modifier isEqualToString: @"N"])
{
flags |= NSNumericPadKeyMask;
}
else
{
NSLog (@"NSInputManager - unknown modifier '%@' ignored", modifier);
return NO;
}
{
NSLog (@"NSInputManager - unknown modifier '%@' ignored", modifier);
return NO;
}
}
/* Now, parse the actual key. */
@ -216,19 +216,19 @@ static NSInputManager *currentInputManager = nil;
{
/* A descriptive string, such as Tab or Home. */
for (i = 0; i < CHARACTER_TABLE_SIZE; i++)
{
if ([name isEqualToString: (character_table[i]).name])
{
c = (character_table[i]).character;
flags |= NSFunctionKeyMask;
break;
}
}
{
if ([name isEqualToString: (character_table[i]).name])
{
c = (character_table[i]).character;
flags |= NSFunctionKeyMask;
break;
}
}
if (i == CHARACTER_TABLE_SIZE)
{
NSLog (@"NSInputManager - unknown character '%@' ignored", name);
return NO;
}
{
NSLog (@"NSInputManager - unknown character '%@' ignored", name);
return NO;
}
}
if (character != NULL)
{
@ -244,7 +244,7 @@ static NSInputManager *currentInputManager = nil;
}
+ (NSString *) describeKeyStroke: (unichar)character
withModifiers: (unsigned int)modifiers
withModifiers: (unsigned int)modifiers
{
NSMutableString *description = [NSMutableString new];
int i;
@ -277,10 +277,10 @@ static NSInputManager *currentInputManager = nil;
for (i = 0; i < CHARACTER_TABLE_SIZE; i++)
{
if (character == ((character_table[i]).character))
{
[description appendString: character_table[i].name];
break;
}
{
[description appendString: character_table[i].name];
break;
}
}
if (i == CHARACTER_TABLE_SIZE)
@ -314,7 +314,7 @@ static NSInputManager *currentInputManager = nil;
NSFileManager *fileManager = [NSFileManager defaultManager];
paths = NSSearchPathForDirectoriesInDomains (NSLibraryDirectory,
NSAllDomainsMask, YES);
NSAllDomainsMask, YES);
/* paths are in the order - user, network, local, root. Instead we
want to load keybindings in the order root, local, network, user
- so that user can override root - for this reason we use a
@ -324,18 +324,18 @@ static NSInputManager *currentInputManager = nil;
{
NSString *fullPath;
fullPath =
[[[libraryPath stringByAppendingPathComponent: @"KeyBindings"]
stringByAppendingPathComponent: fileName]
stringByAppendingPathExtension: @"dict"];
[[[libraryPath stringByAppendingPathComponent: @"KeyBindings"]
stringByAppendingPathComponent: fileName]
stringByAppendingPathExtension: @"dict"];
if ([fileManager fileExistsAtPath: fullPath])
{
[self loadBindingsFromFile: fullPath];
}
{
[self loadBindingsFromFile: fullPath];
}
}
}
- (NSInputManager *) initWithName: (NSString *)inputServerName
host: (NSString *)hostName
host: (NSString *)hostName
{
NSUserDefaults *defaults;
CREATE_AUTORELEASE_POOL (pool);
@ -352,23 +352,23 @@ static NSInputManager *currentInputManager = nil;
if (abortKey == nil)
{
_abortCharacter = 'g';
_abortFlags = NSControlKeyMask;
_abortCharacter = 'g';
_abortFlags = NSControlKeyMask;
}
else if (![NSInputManager parseKey: abortKey
intoCharacter: &_abortCharacter
andModifiers: &_abortFlags])
intoCharacter: &_abortCharacter
andModifiers: &_abortFlags])
{
NSLog (@"Could not parse GSAbortKey - using Control-g");
_abortCharacter = 'g';
_abortFlags = NSControlKeyMask;
NSLog (@"Could not parse GSAbortKey - using Control-g");
_abortCharacter = 'g';
_abortFlags = NSControlKeyMask;
}
}
/* Read if we should insert Control- keystrokes into the text.
This defaults to NO. */
_insertControlKeystrokes = [defaults boolForKey:
@"GSInsertControlKeystrokes"];
@"GSInsertControlKeystrokes"];
/* Read the quote key from the user defaults. */
{
@ -379,7 +379,7 @@ static NSInputManager *currentInputManager = nil;
if (quoteKey == nil)
{
quoteKey = @"Control-q";
quoteKey = @"Control-q";
}
[_rootBindingTable bindKey: quoteKey toAction: quoteAction];
@ -433,7 +433,7 @@ static NSInputManager *currentInputManager = nil;
if (keyBindingsFiles == nil)
{
keyBindingsFiles = [NSArray arrayWithObject: @"DefaultKeyBindings"];
keyBindingsFiles = [NSArray arrayWithObject: @"DefaultKeyBindings"];
}
{
@ -441,14 +441,14 @@ static NSInputManager *currentInputManager = nil;
unsigned int i;
for (i = 0; i < [keyBindingsFiles count]; i++)
{
NSString *filename = [keyBindingsFiles objectAtIndex: i];
if ([filename isKindOfClass: string])
{
[self loadBindingsWithName: filename];
}
}
{
NSString *filename = [keyBindingsFiles objectAtIndex: i];
if ([filename isKindOfClass: string])
{
[self loadBindingsWithName: filename];
}
}
}
}
@ -458,7 +458,7 @@ static NSInputManager *currentInputManager = nil;
if ([keyBindings isKindOfClass: [NSDictionary class]])
{
[_rootBindingTable loadBindingsFromDictionary: keyBindings];
[_rootBindingTable loadBindingsFromDictionary: keyBindings];
}
}
@ -475,7 +475,7 @@ static NSInputManager *currentInputManager = nil;
}
- (void) handleKeyboardEvents: (NSArray *)eventArray
client: (id)client
client: (id)client
{
NSEvent *theEvent;
NSEnumerator *eventEnum = [eventArray objectEnumerator];
@ -495,184 +495,185 @@ static NSInputManager *currentInputManager = nil;
NSString *unmodifiedCharacters = [theEvent charactersIgnoringModifiers];
unichar character = 0;
unsigned flags = [theEvent modifierFlags] & (NSShiftKeyMask
| NSAlternateKeyMask
| NSControlKeyMask
| NSNumericPadKeyMask);
BOOL isFunctionKey = [theEvent modifierFlags] & NSFunctionKeyMask;
| NSAlternateKeyMask
| NSControlKeyMask
| NSNumericPadKeyMask);
BOOL isFunctionKey = ([theEvent modifierFlags] & NSFunctionKeyMask)
== NSFunctionKeyMask;
if ([unmodifiedCharacters length] > 0)
{
character = [unmodifiedCharacters characterAtIndex: 0];
}
{
character = [unmodifiedCharacters characterAtIndex: 0];
}
if (!_interpretNextKeyStrokeLiterally)
{
GSKeyBindingAction *action;
GSKeyBindingTable *table;
BOOL found;
unsigned adaptedFlags;
{
GSKeyBindingAction *action;
GSKeyBindingTable *table;
BOOL found;
unsigned adaptedFlags;
/* If the keystroke is a function key, then we need to use
* the full modifier flags to compare it against stored
* keybindings, so that we can make a difference for example
* between Shift-LeftArrow and LeftArrow. But if it's not a
* function key, then we should ignore the shift modifier -
* for example Control-g is a keystroke, and Control-G is
* another one. The shift modifier flag is not used to
* match these keystrokes - the fact that it's 'G' rather
* than 'g' already contains the fact that it's typed in
* with Shift. */
if (!isFunctionKey)
{
adaptedFlags = flags & (~NSShiftKeyMask);
}
else
{
adaptedFlags = flags;
}
/* If the keystroke is a function key, then we need to use
* the full modifier flags to compare it against stored
* keybindings, so that we can make a difference for example
* between Shift-LeftArrow and LeftArrow. But if it's not a
* function key, then we should ignore the shift modifier -
* for example Control-g is a keystroke, and Control-G is
* another one. The shift modifier flag is not used to
* match these keystrokes - the fact that it's 'G' rather
* than 'g' already contains the fact that it's typed in
* with Shift. */
if (!isFunctionKey)
{
adaptedFlags = flags & (~NSShiftKeyMask);
}
else
{
adaptedFlags = flags;
}
/* Special keybinding recognized in all contexts - abort -
normally bound to Control-g. The user is confused and
wants to go home. Abort whatever train of thoughts we
were following, discarding whatever pending keystrokes we
have, and return into default state. */
if (character == _abortCharacter && adaptedFlags == _abortFlags)
{
[self resetInternalState];
break;
}
/* Special keybinding recognized in all contexts - abort -
normally bound to Control-g. The user is confused and
wants to go home. Abort whatever train of thoughts we
were following, discarding whatever pending keystrokes we
have, and return into default state. */
if (character == _abortCharacter && adaptedFlags == _abortFlags)
{
[self resetInternalState];
break;
}
/* Look up the character in the current keybindings table. */
found = [_currentBindingTable lookupKeyStroke: character
modifiers: adaptedFlags
returningActionIn: &action
tableIn: &table];
if (found)
{
if (action != nil)
{
/* First reset our internal state - we are done
interpreting this keystroke sequence. */
[self resetInternalState];
/* Then perform the action. The action might actually
modify our internal state, which is why we reset it
before calling the action! (for example, performing
the action might cause us to interpret the next
keystroke literally). */
[action performActionWithInputManager: self];
break;
}
else if (table != nil)
{
/* It's part of a composite multi-stroke
keybinding. */
_currentBindingTable = table;
[_pendingKeyEvents addObject: theEvent];
break;
}
/* Else it is as if we didn't find it! */
}
/* Ok - the keybinding wasn't found. If we were tracking a
multi-stroke keybinding, it means we were on a false
track. */
if ([_pendingKeyEvents count] > 0)
{
NSEvent *e;
/* Look up the character in the current keybindings table. */
found = [_currentBindingTable lookupKeyStroke: character
modifiers: adaptedFlags
returningActionIn: &action
tableIn: &table];
if (found)
{
if (action != nil)
{
/* First reset our internal state - we are done
interpreting this keystroke sequence. */
[self resetInternalState];
/* Then perform the action. The action might actually
modify our internal state, which is why we reset it
before calling the action! (for example, performing
the action might cause us to interpret the next
keystroke literally). */
[action performActionWithInputManager: self];
break;
}
else if (table != nil)
{
/* It's part of a composite multi-stroke
keybinding. */
_currentBindingTable = table;
[_pendingKeyEvents addObject: theEvent];
break;
}
/* Else it is as if we didn't find it! */
}
/* Ok - the keybinding wasn't found. If we were tracking a
multi-stroke keybinding, it means we were on a false
track. */
if ([_pendingKeyEvents count] > 0)
{
NSEvent *e;
/* Save the pending events locally in this stack
frame. */
NSMutableArray *a = _pendingKeyEvents;
RETAIN (a);
/* Reset our internal state. */
[self resetInternalState];
/* Take the very first event we received and which we
tried to interpret as a key binding, which now we
know was the wrong thing to do. */
e = [a objectAtIndex: 0];
/* Save the pending events locally in this stack
frame. */
NSMutableArray *a = _pendingKeyEvents;
RETAIN (a);
/* Reset our internal state. */
[self resetInternalState];
/* Take the very first event we received and which we
tried to interpret as a key binding, which now we
know was the wrong thing to do. */
e = [a objectAtIndex: 0];
/* Interpret it literally, since interpreting it as a
keybinding failed. */
_interpretNextKeyStrokeLiterally = YES;
[self handleKeyboardEvents: [NSArray arrayWithObject: e]
client: client];
/* Interpret it literally, since interpreting it as a
keybinding failed. */
_interpretNextKeyStrokeLiterally = YES;
[self handleKeyboardEvents: [NSArray arrayWithObject: e]
client: client];
/* Now feed the remaining pending key events to
ourselves for interpretation - again from
scratch. */
[a removeObjectAtIndex: 0];
[a addObject: theEvent];
[self handleKeyboardEvents: a
client: client];
/* Now feed the remaining pending key events to
ourselves for interpretation - again from
scratch. */
[a removeObjectAtIndex: 0];
[a addObject: theEvent];
[self handleKeyboardEvents: a
client: client];
RELEASE (a);
break;
}
}
RELEASE (a);
break;
}
}
/* We couldn't (or shouldn't) find the keybinding ... perform
the default action - literally interpreting the
keystroke. */
the default action - literally interpreting the
keystroke. */
/* If this was a forced literal interpretation, make sure the
next one is interpreted normally. */
next one is interpreted normally. */
_interpretNextKeyStrokeLiterally = NO;
/* During literal interpretation, function keys are ignored.
Trying to insert 'PageUp' literally makes simply no sense. */
Trying to insert 'PageUp' literally makes simply no sense. */
if (isFunctionKey)
{
NSBeep ();
break;
}
{
NSBeep ();
break;
}
/* During literal interpretation, control characters are ignored
if GSInsertControlKeystrokes was NO. */
if GSInsertControlKeystrokes was NO. */
if (_insertControlKeystrokes == NO)
{
if (flags & NSControlKeyMask)
{
NSBeep ();
break;
}
}
{
if (flags & NSControlKeyMask)
{
NSBeep ();
break;
}
}
switch (character)
{
case NSBackspaceCharacter:
[self doCommandBySelector: @selector (deleteBackward:)];
break;
case NSTabCharacter:
if (flags & NSShiftKeyMask)
{
[self doCommandBySelector: @selector (insertBacktab:)];
}
else
{
[self doCommandBySelector: @selector (insertTab:)];
}
break;
case NSEnterCharacter:
case NSFormFeedCharacter:
case NSCarriageReturnCharacter:
[self doCommandBySelector: @selector (insertNewline:)];
break;
case NSHelpFunctionKey:
[NSHelpManager setContextHelpModeActive: YES];
break;
{
case NSBackspaceCharacter:
[self doCommandBySelector: @selector (deleteBackward:)];
break;
case NSTabCharacter:
if (flags & NSShiftKeyMask)
{
[self doCommandBySelector: @selector (insertBacktab:)];
}
else
{
[self doCommandBySelector: @selector (insertTab:)];
}
break;
case NSEnterCharacter:
case NSFormFeedCharacter:
case NSCarriageReturnCharacter:
[self doCommandBySelector: @selector (insertNewline:)];
break;
case NSHelpFunctionKey:
[NSHelpManager setContextHelpModeActive: YES];
break;
default:
[self insertText: characters];
break;
}
default:
[self insertText: characters];
break;
}
}
}
@ -708,7 +709,7 @@ static NSInputManager *currentInputManager = nil;
{}
- (void) markedTextSelectionChanged: (NSRange)newSel
client: (id)client
client: (id)client
{}
- (BOOL) wantsToDelayTextChangeNotifications
@ -727,7 +728,7 @@ static NSInputManager *currentInputManager = nil;
}
- (void) setMarkedText: (id)aString
selectedRange: (NSRange)selRange
selectedRange: (NSRange)selRange
{}
- (BOOL) hasMarkedText

View file

@ -609,28 +609,28 @@ anything visible
{
/* The point is inside a rect; we're done. */
if (NSPointInRect(point, lf->rect))
break;
break;
/* If the current line frag rect is below the point, the point must
be between the line with the current line frag rect and the line
with the previous line frag rect. */
if (NSMinY(lf->rect) > point.y)
{
/* If this is not the first line frag rect in the text container,
we consider the point to be after the last glyph on the previous
line. Otherwise, we consider it to be before the first glyph on
the current line. */
if (i > 0)
{
*partialFraction = 1.0;
return lf->pos - 1;
}
else
{
*partialFraction = 0.0;
return lf->pos;
}
}
{
/* If this is not the first line frag rect in the text container,
we consider the point to be after the last glyph on the previous
line. Otherwise, we consider it to be before the first glyph on
the current line. */
if (i > 0)
{
*partialFraction = 1.0;
return lf->pos - 1;
}
else
{
*partialFraction = 0.0;
return lf->pos;
}
}
/* We know that NSMinY(lf->rect) <= point.y. If the point is on the
current line and to the left of the current line frag rect, we
consider the point to be before the first glyph in the current line
@ -645,10 +645,10 @@ anything visible
two lines' case, or by the 'after all line frags' code below.)
*/
if (NSMaxY(lf->rect) >= point.y && NSMinX(lf->rect) > point.x)
{
*partialFraction = 0.0;
return lf->pos;
}
{
*partialFraction = 0.0;
return lf->pos;
}
}
/* Point is after all line frags. */
@ -683,9 +683,9 @@ anything visible
unsigned j;
if (i < lf->num_points)
next = lp->p.x;
next = lp->p.x;
else
next = NSMinX(lf->rect);
next = NSMinX(lf->rect);
lp--; /* Valid since we checked for !i above. */
r = run_for_glyph_index(lp->pos, glyphs, &glyph_pos, &char_pos);
@ -694,29 +694,30 @@ anything visible
last_visible = lf->pos;
for (j = lp->pos - glyph_pos; j + glyph_pos < lp->pos + lp->length;)
{
if (r->glyphs[j].isNotShown || r->glyphs[j].g == NSControlGlyph ||
!r->glyphs[j].g)
{
GLYPH_STEP_FORWARD(r, j, glyph_pos, char_pos)
continue;
}
last_visible = j + glyph_pos;
{
// Don't ignore invisble glyphs.
// if (r->glyphs[j].isNotShown || r->glyphs[j].g == NSControlGlyph ||
if (!r->glyphs[j].g)
{
GLYPH_STEP_FORWARD(r, j, glyph_pos, char_pos)
continue;
}
last_visible = j + glyph_pos;
cur = prev + [r->font advancementForGlyph: r->glyphs[j].g].width;
if (j + glyph_pos + 1 == lp->pos + lp->length && next > cur)
cur = next;
cur = prev + [r->font advancementForGlyph: r->glyphs[j].g].width;
if (j + glyph_pos + 1 == lp->pos + lp->length && next > cur)
cur = next;
if (cur >= point.x)
{
*partialFraction = (point.x - prev) / (cur - prev);
if (*partialFraction < 0)
*partialFraction = 0;
return j + glyph_pos;
}
prev = cur;
GLYPH_STEP_FORWARD(r, j, glyph_pos, char_pos)
}
if (cur >= point.x)
{
*partialFraction = (point.x - prev) / (cur - prev);
if (*partialFraction < 0)
*partialFraction = 0;
return j + glyph_pos;
}
prev = cur;
GLYPH_STEP_FORWARD(r, j, glyph_pos, char_pos)
}
*partialFraction = 1;
return last_visible;
}

View file

@ -543,13 +543,13 @@ enum {
- (void) okButtonClicked: (id)sender
{
[self writePrintInfo];
[NSApp stopModalWithCode: NSPLOKButton];
[NSApp stopModalWithCode: NSOKButton];
}
- (void) cancelButtonClicked: (id)sender
{
[NSApp stopModalWithCode: NSPLCancelButton];
[NSApp stopModalWithCode: NSCancelButton];
}

View file

@ -358,6 +358,12 @@ static NSImage *_pbc_image[2];
// FIXME: The documentation is unclear what to set here.
//[anItem setAction: [self action]];
//[anItem setTarget: [self target]];
// Select the new item if there isn't any selection.
if (_selectedItem == nil)
{
[self selectItem: anItem];
}
}
/**
@ -914,21 +920,29 @@ static NSImage *_pbc_image[2];
count = [_menu numberOfItems];
if (count == 0)
return NSZeroSize;
imageSize = [_pbc_image[_pbcFlags.pullsDown] size];
s = NSMakeSize(0, imageSize.height);
if (count == 0)
{
title = [self title];
titleSize = [self _sizeText: title];
if (titleSize.width > s.width)
s.width = titleSize.width;
if (titleSize.height > s.height)
s.height = titleSize.height;
}
for (i = 0; i < count; i++)
{
title = [[_menu itemAtIndex: i] title];
titleSize = [self _sizeText: title];
if (titleSize.width > s.width)
s.width = titleSize.width;
s.width = titleSize.width;
if (titleSize.height > s.height)
s.height = titleSize.height;
s.height = titleSize.height;
}
s.width += imageSize.width;

View file

@ -68,6 +68,11 @@ static NSColor *fillColour = nil;
[super dealloc];
}
- (BOOL) isFlipped
{
return YES;
}
- (void)animate:(id)sender
{
if (!_isIndeterminate)

View file

@ -97,6 +97,11 @@ static Class cellClass;
return self;
}
- (BOOL) isFlipped
{
return YES;
}
/**<p>Returns the value by which the slider will be incremented if the
user holds down the ALT key.</p><p>See Also: -setAltIncrementValue:</p> */
- (double) altIncrementValue

View file

@ -834,24 +834,8 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
[_window invalidateCursorRectsForView: self];
}
- (void) displayIfNeededInRectIgnoringOpacity: (NSRect)aRect
{
if (_window == nil)
{
return;
}
if (_never_displayed_before == YES)
{
_never_displayed_before = NO;
[self _adjustSubviews: _frame.size];
}
[super displayIfNeededInRectIgnoringOpacity: aRect];
}
- (void) displayRectIgnoringOpacity: (NSRect)aRect
inContext: (NSGraphicsContext *)context
{
if (_window == nil)
{
@ -864,7 +848,7 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
[self _adjustSubviews: _frame.size];
}
[super displayRectIgnoringOpacity: aRect];
[super displayRectIgnoringOpacity: aRect inContext: context];
}
- (id) delegate

View file

@ -16,7 +16,7 @@
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
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
@ -74,6 +74,14 @@
[super dealloc];
}
/*
// FIXME: This should be defined
- (BOOL) isFlipped
{
return YES;
}
*/
// tab management.
- (void) addTabViewItem: (NSTabViewItem*)tabViewItem
@ -82,7 +90,7 @@
}
- (void) insertTabViewItem: (NSTabViewItem*)tabViewItem
atIndex: (int)index
atIndex: (int)index
{
[tabViewItem _setTabView: self];
[_items insertObject: tabViewItem atIndex: index];
@ -142,8 +150,8 @@
- (int) indexOfTabViewItemWithIdentifier: (id)identifier
{
unsigned howMany = [_items count];
unsigned i;
unsigned howMany = [_items count];
unsigned i;
for (i = 0; i < howMany; i++)
{
@ -213,7 +221,7 @@
@selector(tabView: shouldSelectTabViewItem:)])
{
canSelect = [_delegate tabView: self
shouldSelectTabViewItem: tabViewItem];
shouldSelectTabViewItem: tabViewItem];
}
if (canSelect)
@ -224,16 +232,16 @@
{
[_selected _setTabState: NSBackgroundTab];
/* NB: If [_selected view] is nil this does nothing, which
/* NB: If [_selected view] is nil this does nothing, which
is fine. */
[[_selected view] removeFromSuperview];
}
[[_selected view] removeFromSuperview];
}
if ([_delegate respondsToSelector:
@selector(tabView: willSelectTabViewItem:)])
{
[_delegate tabView: self willSelectTabViewItem: tabViewItem];
}
@selector(tabView: willSelectTabViewItem:)])
{
[_delegate tabView: self willSelectTabViewItem: tabViewItem];
}
_selected = tabViewItem;
_selected_item = [_items indexOfObject: _selected];
@ -242,20 +250,20 @@
selectedView = [_selected view];
if (selectedView != nil)
{
[self addSubview: selectedView];
[selectedView setFrame: [self contentRect]];
[_window makeFirstResponder: [_selected initialFirstResponder]];
}
{
[self addSubview: selectedView];
[selectedView setFrame: [self contentRect]];
[_window makeFirstResponder: [_selected initialFirstResponder]];
}
/* Will need to redraw tabs and content area. */
[self setNeedsDisplay: YES];
if ([_delegate respondsToSelector:
@selector(tabView: didSelectTabViewItem:)])
{
[_delegate tabView: self didSelectTabViewItem: _selected];
}
@selector(tabView: didSelectTabViewItem:)])
{
[_delegate tabView: self didSelectTabViewItem: _selected];
}
}
}
@ -276,7 +284,7 @@
- (void) takeSelectedTabViewItemFromSender: (id)sender
{
int index = -1;
int index = -1;
if ([sender respondsToSelector: @selector(indexOfSelectedItem)] == YES)
{
@ -284,14 +292,14 @@
}
else if ([sender isKindOfClass: [NSMatrix class]] == YES)
{
int cols = [sender numberOfColumns];
int row = [sender selectedRow];
int col = [sender selectedColumn];
int cols = [sender numberOfColumns];
int row = [sender selectedRow];
int col = [sender selectedColumn];
if (row >= 0 && col >= 0)
{
index = row * cols + col;
}
{
index = row * cols + col;
}
}
[self selectTabViewItemAtIndex: index];
}
@ -354,20 +362,20 @@
switch (_type)
{
case NSTopTabsBezelBorder:
return NSMakeSize(2, 19.5);
return NSMakeSize(2, 19.5);
case NSNoTabsBezelBorder:
return NSMakeSize(2, 3);
return NSMakeSize(2, 3);
case NSNoTabsLineBorder:
return NSMakeSize(2, 3);
return NSMakeSize(2, 3);
case NSBottomTabsBezelBorder:
return NSMakeSize(2, 16);
return NSMakeSize(2, 16);
case NSLeftTabsBezelBorder:
return NSMakeSize(16, 3);
return NSMakeSize(16, 3);
case NSRightTabsBezelBorder:
return NSMakeSize(16, 3);
return NSMakeSize(16, 3);
case NSNoTabsNoBorder:
default:
return NSZeroSize;
return NSZeroSize;
}
}
@ -384,37 +392,37 @@
switch (_type)
{
case NSTopTabsBezelBorder:
cRect.origin.y += 1;
cRect.origin.x += 0.5;
cRect.size.width -= 2;
cRect.size.height -= 18.5;
break;
cRect.origin.y += 1;
cRect.origin.x += 0.5;
cRect.size.width -= 2;
cRect.size.height -= 18.5;
break;
case NSNoTabsBezelBorder:
cRect.origin.y += 1;
cRect.origin.x += 0.5;
cRect.size.width -= 2;
cRect.size.height -= 2;
break;
cRect.origin.y += 1;
cRect.origin.x += 0.5;
cRect.size.width -= 2;
cRect.size.height -= 2;
break;
case NSNoTabsLineBorder:
cRect.origin.y += 1;
cRect.origin.x += 0.5;
cRect.size.width -= 2;
cRect.size.height -= 2;
break;
case NSBottomTabsBezelBorder:
cRect.size.height -= 8;
cRect.origin.y = 8;
break;
cRect.origin.y += 1;
cRect.origin.x += 0.5;
cRect.size.width -= 2;
cRect.size.height -= 2;
break;
case NSBottomTabsBezelBorder:
cRect.size.height -= 8;
cRect.origin.y = 8;
break;
case NSLeftTabsBezelBorder:
cRect.size.width -= 16;
cRect.origin.x += 16;
break;
cRect.size.width -= 16;
cRect.origin.x += 16;
break;
case NSRightTabsBezelBorder:
cRect.size.width -= 16;
break;
cRect.size.width -= 16;
break;
case NSNoTabsNoBorder:
default:
break;
break;
}
return cRect;
@ -424,12 +432,12 @@
- (void) drawRect: (NSRect)rect
{
NSGraphicsContext *ctxt = GSCurrentContext();
GSTheme *theme = [GSTheme theme];
int howMany = [_items count];
int i;
int previousState = 0;
NSRect aRect = _bounds;
NSGraphicsContext *ctxt = GSCurrentContext();
GSTheme *theme = [GSTheme theme];
int howMany = [_items count];
int i;
int previousState = 0;
NSRect aRect = _bounds;
NSColor *lineColour = [NSColor highlightColor];
NSColor *backgroundColour = [[self window] backgroundColor];
BOOL truncate = [self allowsTruncatedLabels];
@ -444,39 +452,39 @@
{
default:
case NSTopTabsBezelBorder:
aRect.size.height -= 16;
[theme drawButton: aRect withClip: rect];
break;
aRect.size.height -= 16;
[theme drawButton: aRect withClip: rect];
break;
case NSBottomTabsBezelBorder:
aRect.size.height -= 16;
aRect.origin.y += 16;
[theme drawButton: aRect withClip: rect];
aRect.origin.y -= 16;
break;
aRect.size.height -= 16;
aRect.origin.y += 16;
[theme drawButton: aRect withClip: rect];
aRect.origin.y -= 16;
break;
case NSLeftTabsBezelBorder:
aRect.size.width -= 18;
aRect.origin.x += 18;
[theme drawButton: aRect withClip: rect];
break;
aRect.size.width -= 18;
aRect.origin.x += 18;
[theme drawButton: aRect withClip: rect];
break;
case NSRightTabsBezelBorder:
aRect.size.width -= 18;
[theme drawButton: aRect withClip: rect];
break;
aRect.size.width -= 18;
[theme drawButton: aRect withClip: rect];
break;
case NSNoTabsBezelBorder:
[theme drawButton: aRect withClip: rect];
break;
[theme drawButton: aRect withClip: rect];
break;
case NSNoTabsLineBorder:
[[NSColor controlDarkShadowColor] set];
NSFrameRect(aRect);
break;
[[NSColor controlDarkShadowColor] set];
NSFrameRect(aRect);
break;
case NSNoTabsNoBorder:
break;
break;
}
if (_type == NSBottomTabsBezelBorder)
@ -485,119 +493,119 @@
iP.x = _bounds.origin.x;
iP.y = _bounds.origin.y;
for (i = 0; i < howMany; i++)
{
NSRect r;
NSRect fRect;
NSTabViewItem *anItem = [_items objectAtIndex: i];
NSTabState itemState = [anItem tabState];
NSSize s = [anItem sizeOfLabel: truncate];
[backgroundColour set];
{
NSRect r;
NSRect fRect;
NSTabViewItem *anItem = [_items objectAtIndex: i];
NSTabState itemState = [anItem tabState];
NSSize s = [anItem sizeOfLabel: truncate];
[backgroundColour set];
if (i == 0)
{
if (itemState == NSSelectedTab)
{
iP.y += 1;
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed: @"common_TabDownSelectedLeft"]
compositeToPoint: iP operation: NSCompositeSourceOver];
iP.y -= 1;
}
else if (itemState == NSBackgroundTab)
{
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed: @"common_TabDownUnSelectedLeft"]
compositeToPoint: iP operation: NSCompositeSourceOver];
}
else
NSLog(@"Not finished yet. Luff ya.\n");
}
else
{
if (itemState == NSSelectedTab)
{
iP.y += 1;
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed:
@"common_TabDownUnSelectedToSelectedJunction"]
compositeToPoint: iP operation: NSCompositeSourceOver];
iP.y -= 1;
}
else if (itemState == NSBackgroundTab)
{
if (previousState == NSSelectedTab)
{
iP.y += 1;
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed:
@"common_TabDownSelectedToUnSelectedJunction"]
compositeToPoint: iP operation: NSCompositeSourceOver];
iP.y -= 1;
}
else
{
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed:
@"common_TabDownUnSelectedJunction"]
compositeToPoint: iP operation: NSCompositeSourceOver];
}
}
else
NSLog(@"Not finished yet. Luff ya.\n");
}
if (i == 0)
{
if (itemState == NSSelectedTab)
{
iP.y += 1;
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed: @"common_TabDownSelectedLeft"]
compositeToPoint: iP operation: NSCompositeSourceOver];
iP.y -= 1;
}
else if (itemState == NSBackgroundTab)
{
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed: @"common_TabDownUnSelectedLeft"]
compositeToPoint: iP operation: NSCompositeSourceOver];
}
else
NSLog(@"Not finished yet. Luff ya.\n");
}
else
{
if (itemState == NSSelectedTab)
{
iP.y += 1;
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed:
@"common_TabDownUnSelectedToSelectedJunction"]
compositeToPoint: iP operation: NSCompositeSourceOver];
iP.y -= 1;
}
else if (itemState == NSBackgroundTab)
{
if (previousState == NSSelectedTab)
{
iP.y += 1;
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed:
@"common_TabDownSelectedToUnSelectedJunction"]
compositeToPoint: iP operation: NSCompositeSourceOver];
iP.y -= 1;
}
else
{
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed:
@"common_TabDownUnSelectedJunction"]
compositeToPoint: iP operation: NSCompositeSourceOver];
}
}
else
NSLog(@"Not finished yet. Luff ya.\n");
}
r.origin.x = iP.x + 13;
r.origin.y = iP.y + 2;
r.size.width = s.width;
r.size.height = 15;
r.origin.x = iP.x + 13;
r.origin.y = iP.y + 2;
r.size.width = s.width;
r.size.height = 15;
fRect = r;
if (itemState == NSSelectedTab)
{
// Undraw the line that separates the tab from its view.
fRect.origin.y += 1;
fRect.size.height += 1;
}
NSRectFill(fRect);
fRect = r;
if (itemState == NSSelectedTab)
{
// Undraw the line that separates the tab from its view.
fRect.origin.y += 1;
fRect.size.height += 1;
}
NSRectFill(fRect);
// Draw the line at the bottom of the item
[lineColour set];
DPSsetlinewidth(ctxt, 1);
DPSmoveto(ctxt, r.origin.x, r.origin.y - 1);
DPSrlineto(ctxt, r.size.width, 0);
DPSstroke(ctxt);
// Label
[anItem drawLabel: truncate inRect: r];
iP.x += s.width + 13;
previousState = itemState;
// Draw the line at the bottom of the item
[lineColour set];
DPSsetlinewidth(ctxt, 1);
DPSmoveto(ctxt, r.origin.x, r.origin.y - 1);
DPSrlineto(ctxt, r.size.width, 0);
DPSstroke(ctxt);
// Label
[anItem drawLabel: truncate inRect: r];
iP.x += s.width + 13;
previousState = itemState;
if (i == howMany - 1)
{
[backgroundColour set];
if (i == howMany - 1)
{
[backgroundColour set];
if ([anItem tabState] == NSSelectedTab)
{
iP.y += 1;
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed: @"common_TabDownSelectedRight"]
compositeToPoint: iP operation: NSCompositeSourceOver];
iP.y -= 1;
}
else if ([anItem tabState] == NSBackgroundTab)
{
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed: @"common_TabDownUnSelectedRight"]
compositeToPoint: iP operation: NSCompositeSourceOver];
}
else
NSLog(@"Not finished yet. Luff ya.\n");
}
}
if ([anItem tabState] == NSSelectedTab)
{
iP.y += 1;
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed: @"common_TabDownSelectedRight"]
compositeToPoint: iP operation: NSCompositeSourceOver];
iP.y -= 1;
}
else if ([anItem tabState] == NSBackgroundTab)
{
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed: @"common_TabDownUnSelectedRight"]
compositeToPoint: iP operation: NSCompositeSourceOver];
}
else
NSLog(@"Not finished yet. Luff ya.\n");
}
}
}
else if (_type == NSTopTabsBezelBorder)
{
@ -608,117 +616,117 @@
iP.y = _bounds.size.height - 16;
for (i = 0; i < howMany; i++)
{
NSRect r;
NSRect fRect;
NSTabViewItem *anItem = [_items objectAtIndex: i];
NSTabState itemState = [anItem tabState];
NSSize s = [anItem sizeOfLabel: truncate];
{
NSRect r;
NSRect fRect;
NSTabViewItem *anItem = [_items objectAtIndex: i];
NSTabState itemState = [anItem tabState];
NSSize s = [anItem sizeOfLabel: truncate];
[backgroundColour set];
if (i == 0)
{
if (itemState == NSSelectedTab)
{
iP.y -= 1;
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed: @"common_TabSelectedLeft"]
compositeToPoint: iP operation: NSCompositeSourceOver];
iP.y += 1;
}
else if (itemState == NSBackgroundTab)
{
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed: @"common_TabUnSelectedLeft"]
compositeToPoint: iP operation: NSCompositeSourceOver];
}
else
NSLog(@"Not finished yet. Luff ya.\n");
}
else
{
if (itemState == NSSelectedTab)
{
iP.y -= 1;
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed:
@"common_TabUnSelectToSelectedJunction"]
compositeToPoint: iP operation: NSCompositeSourceOver];
iP.y += 1;
}
else if (itemState == NSBackgroundTab)
{
if (previousState == NSSelectedTab)
{
iP.y -= 1;
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed:
@"common_TabSelectedToUnSelectedJunction"]
compositeToPoint: iP operation: NSCompositeSourceOver];
iP.y += 1;
}
else
{
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed:
@"common_TabUnSelectedJunction"]
compositeToPoint: iP operation: NSCompositeSourceOver];
}
}
else
NSLog(@"Not finished yet. Luff ya.\n");
}
[backgroundColour set];
if (i == 0)
{
if (itemState == NSSelectedTab)
{
iP.y -= 1;
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed: @"common_TabSelectedLeft"]
compositeToPoint: iP operation: NSCompositeSourceOver];
iP.y += 1;
}
else if (itemState == NSBackgroundTab)
{
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed: @"common_TabUnSelectedLeft"]
compositeToPoint: iP operation: NSCompositeSourceOver];
}
else
NSLog(@"Not finished yet. Luff ya.\n");
}
else
{
if (itemState == NSSelectedTab)
{
iP.y -= 1;
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed:
@"common_TabUnSelectToSelectedJunction"]
compositeToPoint: iP operation: NSCompositeSourceOver];
iP.y += 1;
}
else if (itemState == NSBackgroundTab)
{
if (previousState == NSSelectedTab)
{
iP.y -= 1;
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed:
@"common_TabSelectedToUnSelectedJunction"]
compositeToPoint: iP operation: NSCompositeSourceOver];
iP.y += 1;
}
else
{
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed:
@"common_TabUnSelectedJunction"]
compositeToPoint: iP operation: NSCompositeSourceOver];
}
}
else
NSLog(@"Not finished yet. Luff ya.\n");
}
r.origin.x = iP.x + 13;
r.origin.y = iP.y;
r.size.width = s.width;
r.size.height = 15;
fRect = r;
if (itemState == NSSelectedTab)
{
// Undraw the line that separates the tab from its view.
fRect.origin.y -= 1;
fRect.size.height += 1;
}
NSRectFill(fRect);
r.origin.x = iP.x + 13;
r.origin.y = iP.y;
r.size.width = s.width;
r.size.height = 15;
fRect = r;
if (itemState == NSSelectedTab)
{
// Undraw the line that separates the tab from its view.
fRect.origin.y -= 1;
fRect.size.height += 1;
}
NSRectFill(fRect);
// Draw the line at the top of the item
[lineColour set];
DPSsetlinewidth(ctxt, 1);
DPSmoveto(ctxt, r.origin.x, r.origin.y + 16);
DPSrlineto(ctxt, r.size.width, 0);
DPSstroke(ctxt);
// Label
[anItem drawLabel: truncate inRect: r];
iP.x += s.width + 13;
previousState = itemState;
// Draw the line at the top of the item
[lineColour set];
DPSsetlinewidth(ctxt, 1);
DPSmoveto(ctxt, r.origin.x, r.origin.y + 16);
DPSrlineto(ctxt, r.size.width, 0);
DPSstroke(ctxt);
// Label
[anItem drawLabel: truncate inRect: r];
iP.x += s.width + 13;
previousState = itemState;
if (i == howMany - 1)
{
[backgroundColour set];
if ([anItem tabState] == NSSelectedTab)
{
iP.y -= 1;
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed: @"common_TabSelectedRight"]
compositeToPoint: iP operation: NSCompositeSourceOver];
iP.y += 1;
}
else if ([anItem tabState] == NSBackgroundTab)
{
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed: @"common_TabUnSelectedRight"]
compositeToPoint: iP operation: NSCompositeSourceOver];
}
else
NSLog(@"Not finished yet. Luff ya.\n");
}
}
if (i == howMany - 1)
{
[backgroundColour set];
if ([anItem tabState] == NSSelectedTab)
{
iP.y -= 1;
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed: @"common_TabSelectedRight"]
compositeToPoint: iP operation: NSCompositeSourceOver];
iP.y += 1;
}
else if ([anItem tabState] == NSBackgroundTab)
{
NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17));
[[NSImage imageNamed: @"common_TabUnSelectedRight"]
compositeToPoint: iP operation: NSCompositeSourceOver];
}
else
NSLog(@"Not finished yet. Luff ya.\n");
}
}
}
// FIXME: Missing drawing code for other cases
@ -746,7 +754,7 @@
NSTabViewItem *anItem = [_items objectAtIndex: i];
if (NSPointInRect(point, [anItem _tabRect]))
return anItem;
return anItem;
}
return nil;
@ -755,7 +763,7 @@
- (void) mouseDown: (NSEvent *)theEvent
{
NSPoint location = [self convertPoint: [theEvent locationInWindow]
fromView: nil];
fromView: nil];
NSTabViewItem *anItem = [self tabViewItemAtPoint: location];
if (anItem != nil && ![anItem isEqual: _selected])
@ -829,35 +837,35 @@
{
if ([aDecoder containsValueForKey: @"NSAllowTruncatedLabels"])
{
[self setAllowsTruncatedLabels: [aDecoder decodeBoolForKey:
@"NSAllowTruncatedLabels"]];
}
[self setAllowsTruncatedLabels: [aDecoder decodeBoolForKey:
@"NSAllowTruncatedLabels"]];
}
if ([aDecoder containsValueForKey: @"NSDrawsBackground"])
{
[self setDrawsBackground: [aDecoder decodeBoolForKey:
@"NSDrawsBackground"]];
}
[self setDrawsBackground: [aDecoder decodeBoolForKey:
@"NSDrawsBackground"]];
}
if ([aDecoder containsValueForKey: @"NSFont"])
{
[self setFont: [aDecoder decodeObjectForKey: @"NSFont"]];
}
[self setFont: [aDecoder decodeObjectForKey: @"NSFont"]];
}
if ([aDecoder containsValueForKey: @"NSTabViewItems"])
{
ASSIGN(_items, [aDecoder decodeObjectForKey: @"NSTabViewItems"]);
}
ASSIGN(_items, [aDecoder decodeObjectForKey: @"NSTabViewItems"]);
}
if ([aDecoder containsValueForKey: @"NSSelectedTabViewItem"])
{
[self selectTabViewItem: [aDecoder decodeObjectForKey:
@"NSSelectedTabViewItem"]];
}
[self selectTabViewItem: [aDecoder decodeObjectForKey:
@"NSSelectedTabViewItem"]];
}
if ([aDecoder containsValueForKey: @"NSTvFlags"])
{
int vFlags = [aDecoder decodeIntForKey: @"NSTvFlags"];
int vFlags = [aDecoder decodeIntForKey: @"NSTvFlags"];
[self setControlTint: ((vFlags & 0x70000000) >> 28)];
[self setControlSize: ((vFlags & 0x0c000000) >> 26)];
[self setTabViewType: (vFlags & 0x00000007)];
}
[self setControlTint: ((vFlags & 0x70000000) >> 28)];
[self setControlSize: ((vFlags & 0x0c000000) >> 26)];
[self setTabViewType: (vFlags & 0x00000007)];
}
}
else
{
@ -868,33 +876,33 @@
[aDecoder decodeValueOfObjCType: @encode(NSTabViewType) at: &_type];
if (version < 2)
{
switch(_type)
{
case 0:
_type = NSTopTabsBezelBorder;
break;
case 5:
_type = NSLeftTabsBezelBorder;
break;
case 1:
_type = NSBottomTabsBezelBorder;
break;
case 6:
_type = NSRightTabsBezelBorder;
break;
case 2:
_type = NSNoTabsBezelBorder;
break;
case 3:
_type = NSNoTabsLineBorder;
break;
case 4:
_type = NSNoTabsNoBorder;
break;
default:
break;
}
}
switch(_type)
{
case 0:
_type = NSTopTabsBezelBorder;
break;
case 5:
_type = NSLeftTabsBezelBorder;
break;
case 1:
_type = NSBottomTabsBezelBorder;
break;
case 6:
_type = NSRightTabsBezelBorder;
break;
case 2:
_type = NSNoTabsBezelBorder;
break;
case 3:
_type = NSNoTabsLineBorder;
break;
case 4:
_type = NSNoTabsNoBorder;
break;
default:
break;
}
}
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_draws_background];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_truncated_label];
_delegate = [aDecoder decodeObject];

File diff suppressed because it is too large Load diff

View file

@ -1923,18 +1923,30 @@ static void computeNewSelection
@implementation GSTableCornerView
- (BOOL) isFlipped
{
return YES;
}
- (void) drawRect: (NSRect)aRect
{
NSRect divide = NSMakeRect (aRect.origin.x, aRect.origin.y, aRect.size.width, 1);
NSRect rect = aRect;
rect.origin.y += 1;
rect.size.height -= 1;
NSRect divide;
NSRect rect;
if ([self isFlipped])
{
NSDivideRect(aRect, &divide, &rect, 1.0, NSMaxYEdge);
}
else
{
NSDivideRect(aRect, &divide, &rect, 1.0, NSMinYEdge);
}
[[NSColor blackColor] set];
NSRectFill (divide);
NSRectFill(divide);
rect = [[GSTheme theme] drawDarkButton: rect withClip: aRect];
[[NSColor controlShadowColor] set];
NSRectFill (rect);
NSRectFill(rect);
}
@end
@ -3154,54 +3166,67 @@ byExtendingSelection: (BOOL)flag
{
NSFormatter *formatter;
NSString *string;
id newObjectValue;
id newObjectValue = nil;
BOOL validatedOK = YES;
formatter = [_editedCell formatter];
string = AUTORELEASE ([[_textObject text] copy]);
string = AUTORELEASE([[_textObject text] copy]);
if (formatter == nil)
{
newObjectValue = string;
}
else
{
NSString *error;
if (formatter != nil)
{
NSString *error;
if ([formatter getObjectValue: &newObjectValue
forString: string
errorDescription: &error] == NO)
{
if ([_delegate control: self
didFailToFormatString: string
errorDescription: error] == NO)
{
validatedOK = NO;
}
else
{
newObjectValue = string;
}
}
}
if (validatedOK == YES)
{
[_editedCell setObjectValue: newObjectValue];
if (_dataSource_editable)
{
NSTableColumn *tb;
tb = [_tableColumns objectAtIndex: _editedColumn];
[self _setObjectValue: newObjectValue
forTableColumn: tb
row: _editedRow];
if ([formatter getObjectValue: &newObjectValue
forString: string
errorDescription: &error] == YES)
{
[_editedCell setObjectValue: newObjectValue];
if (_dataSource_editable)
{
NSTableColumn *tb;
tb = [_tableColumns objectAtIndex: _editedColumn];
[self _setObjectValue: newObjectValue
forTableColumn: tb
row: _editedRow];
}
return;
}
else
{
SEL sel = @selector(control:didFailToFormatString:errorDescription:);
//[_dataSource tableView: self setObjectValue: newObjectValue
// forTableColumn: tb row: _editedRow];
}
}
if ([_delegate respondsToSelector: sel])
{
validatedOK = [_delegate control: self
didFailToFormatString: string
errorDescription: error];
}
// Allow an empty string to fall through
else if (![string isEqualToString: @""])
{
validatedOK = NO;
}
}
}
if (validatedOK)
{
[_editedCell setStringValue: string];
if (_dataSource_editable)
{
NSTableColumn *tb;
tb = [_tableColumns objectAtIndex: _editedColumn];
[self _setObjectValue: string // newObjectValue
forTableColumn: tb
row: _editedRow];
}
}
}
}
@ -3471,6 +3496,12 @@ static inline float computePeriod(NSPoint mouseLocationWin,
/* Stop editing if any */
if (_textObject != nil)
{
if (_editedCell != nil
&& [_editedCell isEntryAcceptable:[_textObject text]] == NO)
{
NSBeep();
return;
}
[self validateEditing];
[self abortEditing];
}

View file

@ -376,22 +376,22 @@ static Class textFieldCellClass;
* was in use by another control.
*/
if ([_window makeFirstResponder: self])
{
NSText *t = [_window fieldEditor: YES forObject: self];
{
NSText *t = [_window fieldEditor: YES forObject: self];
if ([t superview] != nil)
{
/* Can't take the field editor ... give up. */
return;
}
_text_object = [_cell setUpFieldEditorAttributes: t];
[_cell editWithFrame: _bounds
inView: self
editor: _text_object
delegate: self
event: theEvent];
}
if ([t superview] != nil)
{
/* Can't take the field editor ... give up. */
return;
}
_text_object = [_cell setUpFieldEditorAttributes: t];
[_cell editWithFrame: _bounds
inView: self
editor: _text_object
delegate: self
event: theEvent];
}
}
}
@ -457,39 +457,44 @@ static Class textFieldCellClass;
{
NSFormatter *formatter;
NSString *string;
BOOL validatedOK = YES;
formatter = [_cell formatter];
string = AUTORELEASE ([[_text_object text] copy]);
if (formatter == nil)
{
[_cell setStringValue: string];
}
else
{
id newObjectValue;
NSString *error;
if ([formatter getObjectValue: &newObjectValue
forString: string
errorDescription: &error] == YES)
{
[_cell setObjectValue: newObjectValue];
}
else
{
SEL sel = @selector(control:didFailToFormatString:errorDescription:);
if (formatter != nil)
{
id newObjectValue;
NSString *error;
if ([formatter getObjectValue: &newObjectValue
forString: string
errorDescription: &error] == YES)
{
[_cell setObjectValue: newObjectValue];
return;
}
else
{
SEL sel = @selector(control:didFailToFormatString:errorDescription:);
if ([_delegate respondsToSelector: sel])
{
validatedOK = [_delegate control: self
didFailToFormatString: string
errorDescription: error];
}
else if (![string isEqualToString: @""])
{
validatedOK = NO;
}
}
}
if ([_delegate respondsToSelector: sel] &&
[_delegate control: self
didFailToFormatString: string
errorDescription: error] == YES)
{
[_cell setStringValue: string];
}
}
}
if (validatedOK)
{
[_cell setStringValue: string];
}
}
}

View file

@ -1792,7 +1792,8 @@ here. */
TODO: make sure this is only called when _layoutManager is known non-nil,
or add guards
*/
- (unsigned int) characterIndexForPoint: (NSPoint)point
- (unsigned int) _characterIndexForPoint: (NSPoint)point
respectFraction: (BOOL)respectFraction
{
unsigned index;
float fraction;
@ -1807,13 +1808,22 @@ or add guards
return (unsigned int)-1;
index = [_layoutManager characterIndexForGlyphAtIndex: index];
if (fraction > 0.5 && index < [_textStorage length])
if (respectFraction && fraction > 0.5 && index < [_textStorage length] &&
[[_textStorage string] characterAtIndex:index] != '\n')
{
index++;
}
return index;
}
// This method takes screen coordinates as input.
- (unsigned int) characterIndexForPoint: (NSPoint)point
{
point = [[self window] convertScreenToBase: point];
point = [self convertPoint:point fromView: nil];
return [self _characterIndexForPoint: point respectFraction: NO];
}
- (NSRange) markedRange
{
return NSMakeRange(NSNotFound, 0);
@ -1844,8 +1854,13 @@ or add guards
- (NSRect) firstRectForCharacterRange: (NSRange)theRange
{
unsigned int rectCount = 0; /* If there's no layout manager, it'll be 0 after the call too. */
NSRect *rects = [_layoutManager
unsigned int rectCount = 0;
NSRect *rects;
if (!_layoutManager)
return NSZeroRect;
rects = [_layoutManager
rectArrayForCharacterRange: theRange
withinSelectedCharacterRange: NSMakeRange(NSNotFound, 0)
inTextContainer: _textContainer
@ -2497,6 +2512,9 @@ Scroll so that the beginning of the range is visible.
*/
[self sizeToFit];
if (_layoutManager == nil)
return;
if (aRange.length > 0)
{
aRange.length = 1;
@ -2848,7 +2866,7 @@ This method is for user changes; see NSTextView_actions.m.
- (void) updateFontPanel
{
/* Update fontPanel only if told so */
if (_tf.uses_font_panel)
if (_tf.uses_font_panel && _layoutManager)
{
NSRange longestRange;
NSFontManager *fm = [NSFontManager sharedFontManager];
@ -3313,8 +3331,15 @@ Figure out how the additional layout stuff is supposed to work.
containerRect.origin.x -= _textContainerOrigin.x;
containerRect.origin.y -= _textContainerOrigin.y;
drawnRange = [_layoutManager glyphRangeForBoundingRect: containerRect
inTextContainer: _textContainer];
if (_layoutManager)
{
drawnRange = [_layoutManager glyphRangeForBoundingRect: containerRect
inTextContainer: _textContainer];
}
else
{
drawnRange = NSMakeRange(0, 0);
}
if (_tf.draws_background)
{
@ -4259,14 +4284,15 @@ other than copy/paste or dragging. */
NSRange range;
if (_tf.isDragTarget == NO)
{
_tf.isDragTarget = YES;
_dragTargetSelectionRange = [self selectedRange];
}
{
_tf.isDragTarget = YES;
_dragTargetSelectionRange = [self selectedRange];
}
dragPoint = [sender draggingLocation];
dragPoint = [self convertPoint: dragPoint fromView: nil];
dragIndex = [self characterIndexForPoint: dragPoint];
dragIndex = [self _characterIndexForPoint: dragPoint
respectFraction: YES];
dragRange = NSMakeRange (dragIndex, 0);
range = [self selectionRangeForProposedRange: dragRange
@ -4294,14 +4320,15 @@ other than copy/paste or dragging. */
NSRange range;
if (_tf.isDragTarget == NO)
{
_tf.isDragTarget = YES;
_dragTargetSelectionRange = [self selectedRange];
}
{
_tf.isDragTarget = YES;
_dragTargetSelectionRange = [self selectedRange];
}
dragPoint = [sender draggingLocation];
dragPoint = [self convertPoint: dragPoint fromView: nil];
dragIndex = [self characterIndexForPoint: dragPoint];
dragIndex = [self _characterIndexForPoint: dragPoint
respectFraction: YES];
dragRange = NSMakeRange (dragIndex, 0);
range = [self selectionRangeForProposedRange: dragRange
@ -4415,7 +4442,8 @@ other than copy/paste or dragging. */
possible) */
startPoint = [self convertPoint: [theEvent locationInWindow] fromView: nil];
startIndex = [self characterIndexForPoint: startPoint];
startIndex = [self _characterIndexForPoint: startPoint
respectFraction: [theEvent clickCount] == 1];
if (startIndex == (unsigned int)-1)
{
@ -4619,8 +4647,9 @@ other than copy/paste or dragging. */
point = [self convertPoint: [lastEvent locationInWindow]
fromView: nil];
proposedRange = MakeRangeFromAbs([self characterIndexForPoint: point],
startIndex);
proposedRange = MakeRangeFromAbs([self _characterIndexForPoint: point
respectFraction: YES],
startIndex);
chosenRange = [self selectionRangeForProposedRange: proposedRange
granularity: granularity];
[self setSelectedRange: chosenRange affinity: affinity
@ -4700,7 +4729,7 @@ configuation! */
NSRange glyphRange;
NSRect rect;
if (!aRange.length)
if (!aRange.length || !_layoutManager)
return NSZeroRect;
glyphRange = [_layoutManager glyphRangeForCharacterRange: aRange
actualCharacterRange: NULL];

View file

@ -391,6 +391,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
@end
// FIXME: Why does this class exists at all?
@implementation GSToolbarButtonCell
/* Overriden NSButtonCell method to handle cell type in a basic way which avoids
@ -412,29 +413,64 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
}
}
// Overriden NSButtonCell method
// Overriden NSButtonCell method to make sure all test is at the same height.
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
{
NSSize titleSize = [[self attributedTitle] size];
BOOL flippedView = [controlView isFlipped];
NSCellImagePosition ipos = _cell.image_position;
// We ignore alternateAttributedTitle, it is not needed
NSSize titleSize = [[self attributedTitle] size];
if (flippedView == YES)
{
if (ipos == NSImageAbove)
{
ipos = NSImageBelow;
}
else if (ipos == NSImageBelow)
{
ipos = NSImageAbove;
}
}
/* We store the values we need to customize the drawing into titleRect and
imageRect. */
titleRect.origin.x = cellFrame.origin.x;
titleRect.origin.y = cellFrame.origin.y + InsetItemTextY;
titleRect.size.width = cellFrame.size.width;
titleRect.size.height = titleSize.height;
imageRect.origin.x = cellFrame.origin.x;
imageRect.origin.y = cellFrame.origin.y;
if ([self imagePosition] != NSImageOnly)
imageRect.origin.y += titleRect.size.height;
imageRect.size.width = cellFrame.size.width;
imageRect.size.height = cellFrame.size.height;
if ([self imagePosition] != NSImageOnly)
imageRect.size.height -= titleRect.size.height;
switch (ipos)
{
case NSNoImage:
titleRect = cellFrame;
break;
case NSImageOnly:
imageRect = cellFrame;
break;
default:
case NSImageBelow:
titleRect.origin.x = cellFrame.origin.x;
titleRect.origin.y = NSMaxY(cellFrame) - titleSize.height - InsetItemTextY;
titleRect.size.width = cellFrame.size.width;
titleRect.size.height = titleSize.height;
imageRect.origin.x = cellFrame.origin.x;
imageRect.origin.y = cellFrame.origin.y;
imageRect.size.width = cellFrame.size.width;
imageRect.size.height = cellFrame.size.height - titleRect.size.height;
break;
case NSImageAbove:
titleRect.origin.x = cellFrame.origin.x;
titleRect.origin.y = cellFrame.origin.y + InsetItemTextY;
titleRect.size.width = cellFrame.size.width;
titleRect.size.height = titleSize.height;
imageRect.origin.x = cellFrame.origin.x;
imageRect.origin.y = cellFrame.origin.y + titleRect.size.height;
imageRect.size.width = cellFrame.size.width;
imageRect.size.height = cellFrame.size.height - titleRect.size.height;
break;
}
[super drawInteriorWithFrame: cellFrame inView: controlView];
}
@ -1085,16 +1121,16 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
button = [[GSToolbarButton alloc] initWithToolbarItem: self];
cell = [button cell];
[button setTitle: @""];
[button setEnabled: NO];
[button setTitle: @""];
[button setEnabled: NO];
[button setBordered: NO];
[button setImagePosition: NSImageAbove];
[cell setBezeled: YES];
[cell setBezeled: YES];
[cell setHighlightsBy:
NSChangeGrayCellMask | NSChangeBackgroundCellMask];
NSChangeGrayCellMask | NSChangeBackgroundCellMask];
[cell setFont: [NSFont systemFontOfSize: 11]];
/* [NSFont smallSystemFontSize] or better should be
controlContentFontSize. */
/* [NSFont smallSystemFontSize] or better should be
controlContentFontSize. */
[_backView release];
_backView = button;

View file

@ -2725,8 +2725,8 @@ in the main thread.
aRect = NSIntersectionRect(aRect, _bounds); // Don't copy stuff outside.
destPoint = aRect.origin;
destPoint.x -= delta.width;
destPoint.y -= delta.height;
destPoint.x += delta.width;
destPoint.y += delta.height;
[self lockFocus];
NSCopyBits(0, aRect, destPoint);

View file

@ -235,70 +235,91 @@ has blocked and waited for events.
- (void) _lossOfKeyOrMainWindow
{
NSArray *windowList = GSOrderedWindows();
unsigned pos = [windowList indexOfObjectIdenticalTo: self];
unsigned c = [windowList count];
unsigned i,ti;
NSWindow *w;
unsigned pos = [windowList indexOfObjectIdenticalTo: self];
unsigned c = [windowList count];
unsigned i;
// Don't bother when application is closing.
if ([NSApp isRunning] == NO)
return;
if (!c)
return;
i = pos + 1;
if (pos >= c || pos + 1 == c)
if (pos == NSNotFound)
{
pos = c - 1;
i = 0;
pos = c;
}
ti = i;
if ([self isKeyWindow])
{
NSWindow *menu_window = [[NSApp mainMenu] window];
NSWindow *w = [NSApp mainWindow];
[self resignKeyWindow];
if (w != nil && w != self
&& [w canBecomeKeyWindow])
{
[w makeKeyWindow];
}
else
{
NSWindow *menu_window = [[NSApp mainMenu] window];
for (; i != pos && i < c; i++)
{
w = [windowList objectAtIndex: i];
if ([w isVisible] && [w canBecomeKeyWindow] && w != menu_window)
{
[w makeKeyWindow];
break;
}
}
/*
* if we didn't find a possible key window - use the main menu window
*/
if (i == c)
{
if (menu_window != nil)
{
[GSServerForWindow(menu_window) setinputfocus:
[menu_window windowNumber]];
}
}
// try all windows front to back except self and menu
for (i = 0; i < c; i++)
{
if (i != pos)
{
w = [windowList objectAtIndex: i];
if ([w isVisible] && [w canBecomeKeyWindow]
&& w != menu_window)
{
[w makeKeyWindow];
break;
}
}
}
/*
* if we didn't find a possible key window - use the main menu window
*/
if (i == c)
{
if (menu_window != nil)
{
// FIXME: Why this call and not makeKeyWindow?
[GSServerForWindow(menu_window) setinputfocus:
[menu_window windowNumber]];
}
}
}
}
if ([self isMainWindow])
{
NSWindow *w = [NSApp keyWindow];
NSWindow *w = [NSApp keyWindow];
[self resignMainWindow];
if (w != nil && [w canBecomeMainWindow])
{
[w makeMainWindow];
}
{
[w makeMainWindow];
}
else
{
for (i = ti; i != pos && i < c; i++)
{
w = [windowList objectAtIndex: i];
if ([w isVisible] && [w canBecomeMainWindow])
{
[w makeMainWindow];
break;
}
}
}
{
// try all windows front to back except self
for (i = 0; i < c; i++)
{
if (i != pos)
{
w = [windowList objectAtIndex: i];
if ([w isVisible] && [w canBecomeMainWindow])
{
[w makeMainWindow];
break;
}
}
}
}
}
}
@ -1335,19 +1356,19 @@ many times.
_f.is_key = YES;
if ((!_firstResponder) || (_firstResponder == self))
{
if (_initialFirstResponder)
{
[self makeFirstResponder: _initialFirstResponder];
}
}
{
if (_initialFirstResponder)
{
[self makeFirstResponder: _initialFirstResponder];
}
}
[_firstResponder becomeFirstResponder];
if ((_firstResponder != self)
&& [_firstResponder respondsToSelector: @selector(becomeKeyWindow)])
{
[_firstResponder becomeKeyWindow];
}
&& [_firstResponder respondsToSelector: @selector(becomeKeyWindow)])
{
[_firstResponder becomeKeyWindow];
}
[_wv setInputState: GSTitleBarKey];
[GSServerForWindow(self) setinputfocus: _windowNum];
@ -1547,8 +1568,8 @@ many times.
{
if (_windowNum == 0)
{
return; /* This deferred window was never ordered in. */
}
return; /* This deferred window was never ordered in. */
}
_f.visible = NO;
/*
* Don't keep trying to update the window while it is ordered out
@ -1559,23 +1580,23 @@ many times.
else
{
/* Windows need to be constrained when displayed or resized - but only
titled windows are constrained. Also, and this is the tricky part,
titled windows are constrained. Also, and this is the tricky part,
don't constrain if we are merely unhidding the window or if it's
already visible and is just being reordered. */
if ((_styleMask & NSTitledWindowMask)
&& [NSApp isHidden] == NO
&& _f.visible == NO)
{
NSRect nframe = [self constrainFrameRect: _frame
toScreen: [self screen]];
[self setFrame: nframe display: NO];
}
&& [NSApp isHidden] == NO
&& _f.visible == NO)
{
NSRect nframe = [self constrainFrameRect: _frame
toScreen: [self screen]];
[self setFrame: nframe display: NO];
}
// create deferred window
if (_windowNum == 0)
{
[self _initBackendWindow];
display = YES;
}
{
[self _initBackendWindow];
display = YES;
}
}
// Draw content before backend window ordering
@ -1605,32 +1626,32 @@ many times.
[isa _addAutodisplayedWindow: self];
if (_f.has_closed == YES)
{
_f.has_closed = NO; /* A closed window has re-opened */
}
{
_f.has_closed = NO; /* A closed window has re-opened */
}
if (_f.has_opened == NO)
{
_f.has_opened = YES;
if (_f.menu_exclude == NO)
{
BOOL isFileName;
NSString *aString;
aString = [NSString stringWithFormat: @"%@ -- %@",
[_representedFilename lastPathComponent],
[_representedFilename stringByDeletingLastPathComponent]];
isFileName = [_windowTitle isEqual: aString];
{
_f.has_opened = YES;
if (_f.menu_exclude == NO)
{
BOOL isFileName;
NSString *aString;
aString = [NSString stringWithFormat: @"%@ -- %@",
[_representedFilename lastPathComponent],
[_representedFilename stringByDeletingLastPathComponent]];
isFileName = [_windowTitle isEqual: aString];
[NSApp addWindowsItem: self
title: _windowTitle
filename: isFileName];
}
}
[NSApp addWindowsItem: self
title: _windowTitle
filename: isFileName];
}
}
if ([self isKeyWindow] == YES)
{
[_wv setInputState: GSTitleBarKey];
[srv setinputfocus: _windowNum];
}
{
[_wv setInputState: GSTitleBarKey];
[srv setinputfocus: _windowNum];
}
_f.visible = YES;
}
else if ([self isOneShot])
@ -1644,19 +1665,19 @@ many times.
if (_f.is_key == YES)
{
if ((_firstResponder != self)
&& [_firstResponder respondsToSelector: @selector(resignKeyWindow)])
[_firstResponder resignKeyWindow];
&& [_firstResponder respondsToSelector: @selector(resignKeyWindow)])
[_firstResponder resignKeyWindow];
_f.is_key = NO;
if (_f.is_main == YES)
{
[_wv setInputState: GSTitleBarMain];
}
{
[_wv setInputState: GSTitleBarMain];
}
else
{
[_wv setInputState: GSTitleBarNormal];
}
{
[_wv setInputState: GSTitleBarNormal];
}
[self discardCursorRects];
[nc postNotificationName: NSWindowDidResignKeyNotification object: self];
@ -1669,13 +1690,13 @@ many times.
{
_f.is_main = NO;
if (_f.is_key == YES)
{
[_wv setInputState: GSTitleBarKey];
}
{
[_wv setInputState: GSTitleBarKey];
}
else
{
[_wv setInputState: GSTitleBarNormal];
}
{
[_wv setInputState: GSTitleBarNormal];
}
[nc postNotificationName: NSWindowDidResignMainNotification object: self];
}
}
@ -1707,13 +1728,30 @@ many times.
if (NSEqualPoints(topLeftPoint, NSZeroPoint) == YES)
{
topLeftPoint.x = _frame.origin.x;
topLeftPoint.y = _frame.origin.y + _frame.size.height;
topLeftPoint.x = NSMinX(_frame);
topLeftPoint.y = NSMaxY(_frame);
}
[self setFrameTopLeftPoint: topLeftPoint];
cRect = [isa contentRectForFrameRect: _frame styleMask: _styleMask];
topLeftPoint.x = cRect.origin.x;
topLeftPoint.y = cRect.origin.y + cRect.size.height;
topLeftPoint.x = NSMinX(cRect);
topLeftPoint.y = NSMaxY(cRect);
/* make sure the new point is inside the screen */
if ([self screen])
{
NSRect screenRect;
screenRect = [[self screen] visibleFrame];
if (topLeftPoint.x >= NSMaxX(screenRect))
{
topLeftPoint.x = NSMinX(screenRect);
}
if (topLeftPoint.y <= NSMinY(screenRect))
{
topLeftPoint.y = NSMaxY(screenRect);
}
}
return topLeftPoint;
}
@ -2129,10 +2167,10 @@ many times.
if (NSIsEmptyRect(_rectNeedingFlush))
{
if ([_rectsBeingDrawn count] == 0)
{
_f.needs_flush = NO;
return;
}
{
_f.needs_flush = NO;
return;
}
}
/*
@ -2442,9 +2480,9 @@ resetCursorRectsForView(NSView *theView)
we close).
*/
if (!_f.is_released_when_closed)
{
RETAIN(self);
}
{
RETAIN(self);
}
[nc postNotificationName: NSWindowWillCloseNotification object: self];
_f.has_opened = NO;
@ -2477,7 +2515,6 @@ resetCursorRectsForView(NSView *theView)
if (!_f.is_miniaturized)
return;
#if 0
/* At least with X-Windows, the counterpart is tied to us, so it will
automatically be ordered out when we are deminiaturized */
if (_counterpart != 0)
@ -2486,7 +2523,7 @@ resetCursorRectsForView(NSView *theView)
[mini orderOut: self];
}
#endif
_f.is_miniaturized = NO;
[self makeKeyAndOrderFront: self];
[self _didDeminiaturize: sender];
@ -2568,6 +2605,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];
@ -2774,10 +2813,12 @@ resetCursorRectsForView(NSView *theView)
if (aResponder != nil)
{
if (![aResponder isKindOfClass: responderClass])
return NO;
return NO;
if (![aResponder acceptsFirstResponder])
return NO;
{
return NO;
}
}
/* So that the implementation of -resignFirstResponder in
@ -2790,14 +2831,16 @@ resetCursorRectsForView(NSView *theView)
* Change only if it replies YES.
*/
if ((_firstResponder) && (![_firstResponder resignFirstResponder]))
return NO;
{
return NO;
}
_firstResponder = aResponder;
if (![_firstResponder becomeFirstResponder])
if ((aResponder == nil) || ![_firstResponder becomeFirstResponder])
{
_firstResponder = self;
_firstResponder = self;
[_firstResponder becomeFirstResponder];
return NO;
return (aResponder == nil);
}
return YES;
@ -2846,9 +2889,9 @@ resetCursorRectsForView(NSView *theView)
if (character == NSTabCharacter)
{
if ([theEvent modifierFlags] & NSShiftKeyMask)
[self selectPreviousKeyView: self];
[self selectPreviousKeyView: self];
else
[self selectNextKeyView: self];
[self selectNextKeyView: self];
return;
}
@ -2856,10 +2899,10 @@ resetCursorRectsForView(NSView *theView)
if (character == 0x001b)
{
if ([NSApp modalWindow] == self)
{
// NB: The following *never* returns.
[NSApp abortModal];
}
{
// NB: The following *never* returns.
[NSApp abortModal];
}
return;
}
@ -2868,16 +2911,17 @@ resetCursorRectsForView(NSView *theView)
|| character == NSCarriageReturnCharacter)
{
if (_defaultButtonCell && _f.default_button_cell_key_disabled == NO)
{
[_defaultButtonCell performClick: self];
return;
}
{
[_defaultButtonCell performClick: self];
return;
}
}
// Discard null character events such as a Shift event after a tab key
if ([characters length] == 0)
return;
// FIXME: Why is this here, is the code still needed or a left over hack?
// Try to process the event as a key equivalent
// without Command having being pressed
{
@ -3218,193 +3262,204 @@ resetCursorRectsForView(NSView *theView)
switch (type)
{
case NSLeftMouseDown:
{
BOOL wasKey = _f.is_key;
{
BOOL wasKey = _f.is_key;
if (_f.has_closed == NO)
{
v = [_wv hitTest: [theEvent locationInWindow]];
if (_f.is_key == NO && _windowLevel != NSDesktopWindowLevel)
{
/* NSPanel modification: check becomesKeyOnlyIfNeeded. */
if (![self becomesKeyOnlyIfNeeded]
|| [v needsPanelToBecomeKey])
[self makeKeyAndOrderFront: self];
}
/* Activate the app *after* making the receiver key, as app
activation tries to make the previous key window key. */
if ([NSApp isActive] == NO && self != [NSApp iconWindow])
{
[NSApp activateIgnoringOtherApps: YES];
}
if (_firstResponder != v)
{
[self makeFirstResponder: v];
}
if (_lastView)
{
DESTROY(_lastView);
}
if (wasKey == YES || [v acceptsFirstMouse: theEvent] == YES)
{
if ([NSHelpManager isContextHelpModeActive])
{
[v helpRequested: theEvent];
}
else
{
ASSIGN(_lastView, v);
if (toolTipVisible != nil)
{
/* Inform the tooltips system that we have had
* a mouse down so it should stop displaying.
*/
[toolTipVisible mouseDown: theEvent];
}
[v mouseDown: theEvent];
}
}
else
{
[self mouseDown: theEvent];
}
}
_lastPoint = [theEvent locationInWindow];
break;
}
if (_f.has_closed == NO)
{
v = [_wv hitTest: [theEvent locationInWindow]];
if (_f.is_key == NO && _windowLevel != NSDesktopWindowLevel)
{
/* NSPanel modification: check becomesKeyOnlyIfNeeded. */
if (![self becomesKeyOnlyIfNeeded]
|| [v needsPanelToBecomeKey])
{
v = nil;
[self makeKeyAndOrderFront: self];
}
}
/* Activate the app *after* making the receiver key, as app
activation tries to make the previous key window key. */
if ([NSApp isActive] == NO && self != [NSApp iconWindow])
{
v = nil;
[NSApp activateIgnoringOtherApps: YES];
}
// Activating the app may change the window layout.
if (v == nil)
{
v = [_wv hitTest: [theEvent locationInWindow]];
}
if (_lastView)
{
DESTROY(_lastView);
}
if (_firstResponder != v)
{
// Only try to set first responder, when the view wants it.
if ([v acceptsFirstResponder] && ![self makeFirstResponder: v])
{
return;
}
}
if (wasKey == YES || [v acceptsFirstMouse: theEvent] == YES)
{
if ([NSHelpManager isContextHelpModeActive])
{
[v helpRequested: theEvent];
}
else
{
ASSIGN(_lastView, v);
if (toolTipVisible != nil)
{
/* Inform the tooltips system that we have had
* a mouse down so it should stop displaying.
*/
[toolTipVisible mouseDown: theEvent];
}
[v mouseDown: theEvent];
}
}
else
{
[self mouseDown: theEvent];
}
}
_lastPoint = [theEvent locationInWindow];
break;
}
case NSLeftMouseUp:
v = AUTORELEASE(RETAIN(_lastView));
DESTROY(_lastView);
if (v == nil)
break;
[v mouseUp: theEvent];
_lastPoint = [theEvent locationInWindow];
break;
v = AUTORELEASE(RETAIN(_lastView));
DESTROY(_lastView);
if (v == nil)
break;
[v mouseUp: theEvent];
_lastPoint = [theEvent locationInWindow];
break;
case NSOtherMouseDown:
v = [_wv hitTest: [theEvent locationInWindow]];
[v otherMouseDown: theEvent];
_lastPoint = [theEvent locationInWindow];
break;
v = [_wv hitTest: [theEvent locationInWindow]];
[v otherMouseDown: theEvent];
_lastPoint = [theEvent locationInWindow];
break;
case NSOtherMouseUp:
v = [_wv hitTest: [theEvent locationInWindow]];
[v otherMouseUp: theEvent];
_lastPoint = [theEvent locationInWindow];
break;
v = [_wv hitTest: [theEvent locationInWindow]];
[v otherMouseUp: theEvent];
_lastPoint = [theEvent locationInWindow];
break;
case NSRightMouseDown:
{
v = [_wv hitTest: [theEvent locationInWindow]];
[v rightMouseDown: theEvent];
_lastPoint = [theEvent locationInWindow];
}
break;
v = [_wv hitTest: [theEvent locationInWindow]];
[v rightMouseDown: theEvent];
_lastPoint = [theEvent locationInWindow];
break;
case NSRightMouseUp:
v = [_wv hitTest: [theEvent locationInWindow]];
[v rightMouseUp: theEvent];
_lastPoint = [theEvent locationInWindow];
break;
v = [_wv hitTest: [theEvent locationInWindow]];
[v rightMouseUp: theEvent];
_lastPoint = [theEvent locationInWindow];
break;
case NSLeftMouseDragged:
case NSOtherMouseDragged:
case NSRightMouseDragged:
case NSMouseMoved:
switch (type)
{
case NSLeftMouseDragged:
[_lastView mouseDragged: theEvent];
break;
case NSOtherMouseDragged:
[_lastView otherMouseDragged: theEvent];
break;
case NSRightMouseDragged:
[_lastView rightMouseDragged: theEvent];
break;
default:
if (_f.accepts_mouse_moved)
{
/*
* If the window is set to accept mouse movements, we need to
* forward the mouse movement to the correct view.
*/
v = [_wv hitTest: [theEvent locationInWindow]];
switch (type)
{
case NSLeftMouseDragged:
[_lastView mouseDragged: theEvent];
break;
case NSOtherMouseDragged:
[_lastView otherMouseDragged: theEvent];
break;
case NSRightMouseDragged:
[_lastView rightMouseDragged: theEvent];
break;
default:
if (_f.accepts_mouse_moved)
{
/*
* If the window is set to accept mouse movements, we need to
* forward the mouse movement to the correct view.
*/
v = [_wv hitTest: [theEvent locationInWindow]];
/* If the view is displaying a tooltip, we should
* send mouse movements to the tooltip system so
* that the window can track the mouse.
*/
if (toolTipVisible != nil)
{
[toolTipVisible mouseMoved: theEvent];
}
else
{
[v mouseMoved: theEvent];
}
}
break;
}
/*
* We need to go through all of the views, and if there is any with
* a tracking rectangle then we need to determine if we should send
* a NSMouseEntered or NSMouseExited event.
*/
(*ctImp)(self, ctSel, _wv, theEvent);
if (_f.is_key)
{
/*
* We need to go through all of the views, and if there is any with
* a cursor rectangle then we need to determine if we should send a
* cursor update event.
*/
if (_f.cursor_rects_enabled)
(*ccImp)(self, ccSel, _wv, theEvent);
}
_lastPoint = [theEvent locationInWindow];
break;
/* If the view is displaying a tooltip, we should
* send mouse movements to the tooltip system so
* that the window can track the mouse.
*/
if (toolTipVisible != nil)
{
[toolTipVisible mouseMoved: theEvent];
}
else
{
[v mouseMoved: theEvent];
}
}
break;
}
/*
* We need to go through all of the views, and if there is any with
* a tracking rectangle then we need to determine if we should send
* a NSMouseEntered or NSMouseExited event.
*/
(*ctImp)(self, ctSel, _wv, theEvent);
if (_f.is_key)
{
/*
* We need to go through all of the views, and if there is any with
* a cursor rectangle then we need to determine if we should send a
* cursor update event.
*/
if (_f.cursor_rects_enabled)
(*ccImp)(self, ccSel, _wv, theEvent);
}
_lastPoint = [theEvent locationInWindow];
break;
case NSMouseEntered:
case NSMouseExited:
break;
break;
case NSKeyDown:
[_firstResponder keyDown: theEvent];
break;
[_firstResponder keyDown: theEvent];
break;
case NSKeyUp:
[_firstResponder keyUp: theEvent];
break;
[_firstResponder keyUp: theEvent];
break;
case NSFlagsChanged:
[_firstResponder flagsChanged: theEvent];
break;
[_firstResponder flagsChanged: theEvent];
break;
case NSCursorUpdate:
{
GSTrackingRect *r =(GSTrackingRect*)[theEvent userData];
NSCursor *c = (NSCursor*)[r owner];
if ([theEvent trackingNumber]) // It's a mouse entered
{
[c mouseEntered: theEvent];
}
else // it is a mouse exited
{
[c mouseExited: theEvent];
}
}
break;
{
GSTrackingRect *r =(GSTrackingRect*)[theEvent userData];
NSCursor *c = (NSCursor*)[r owner];
if ([theEvent trackingNumber]) // It's a mouse entered
{
[c mouseEntered: theEvent];
}
else // it is a mouse exited
{
[c mouseExited: theEvent];
}
}
break;
case NSScrollWheel:
v = [_wv hitTest: [theEvent locationInWindow]];
[v scrollWheel: theEvent];
break;
v = [_wv hitTest: [theEvent locationInWindow]];
[v scrollWheel: theEvent];
break;
case NSAppKitDefined:
{
@ -3510,31 +3565,31 @@ resetCursorRectsForView(NSView *theView)
case GSAppKitWindowFocusIn:
if (_f.is_miniaturized)
{
/* Window Manager just deminiaturized us */
[self deminiaturize: self];
}
{
/* Window Manager just deminiaturized us */
[self deminiaturize: self];
}
if ([NSApp modalWindow]
&& self != [NSApp modalWindow])
{
/* Ignore this request. We're in a modal loop and the
user pressed on the title bar of another window. */
break;
}
&& self != [NSApp modalWindow])
{
/* Ignore this request. We're in a modal loop and the
user pressed on the title bar of another window. */
break;
}
if ([self canBecomeKeyWindow] == YES)
{
NSDebugLLog(@"Focus", @"Making %d key", _windowNum);
[self makeKeyWindow];
[self makeMainWindow];
[NSApp activateIgnoringOtherApps: YES];
}
{
NSDebugLLog(@"Focus", @"Making %d key", _windowNum);
[self makeKeyWindow];
[self makeMainWindow];
[NSApp activateIgnoringOtherApps: YES];
}
if (self == [[NSApp mainMenu] window])
{
/* We should really find another window that can become
key (if possible)
*/
[self _lossOfKeyOrMainWindow];
}
{
/* We should really find another window that can become
key (if possible)
*/
[self _lossOfKeyOrMainWindow];
}
break;
case GSAppKitWindowFocusOut:
@ -3803,12 +3858,15 @@ resetCursorRectsForView(NSView *theView)
theView = [aView nextValidKeyView];
if (theView)
{
[self makeFirstResponder: theView];
if (![self makeFirstResponder: theView])
{
return;
}
if ([theView respondsToSelector:@selector(selectText:)])
{
_selectionDirection = NSSelectingNext;
[(id)theView selectText: self];
_selectionDirection = NSDirectSelection;
{
_selectionDirection = NSSelectingNext;
[(id)theView selectText: self];
_selectionDirection = NSDirectSelection;
}
}
}
@ -3824,13 +3882,16 @@ resetCursorRectsForView(NSView *theView)
theView = [aView previousValidKeyView];
if (theView)
{
[self makeFirstResponder: theView];
if (![self makeFirstResponder: theView])
{
return;
}
if ([theView respondsToSelector:@selector(selectText:)])
{
_selectionDirection = NSSelectingPrevious;
[(id)theView selectText: self];
_selectionDirection = NSDirectSelection;
}
{
_selectionDirection = NSSelectingPrevious;
[(id)theView selectText: self];
_selectionDirection = NSDirectSelection;
}
}
}
@ -3853,20 +3914,23 @@ resetCursorRectsForView(NSView *theView)
if ((theView == nil) && (_initialFirstResponder))
{
if ([_initialFirstResponder acceptsFirstResponder])
theView = _initialFirstResponder;
theView = _initialFirstResponder;
else
theView = [_initialFirstResponder nextValidKeyView];
theView = [_initialFirstResponder nextValidKeyView];
}
if (theView)
{
[self makeFirstResponder: theView];
if (![self makeFirstResponder: theView])
{
return;
}
if ([theView respondsToSelector:@selector(selectText:)])
{
_selectionDirection = NSSelectingNext;
[(id)theView selectText: self];
_selectionDirection = NSDirectSelection;
}
{
_selectionDirection = NSSelectingNext;
[(id)theView selectText: self];
_selectionDirection = NSDirectSelection;
}
}
}
@ -3889,20 +3953,23 @@ resetCursorRectsForView(NSView *theView)
if ((theView == nil) && (_initialFirstResponder))
{
if ([_initialFirstResponder acceptsFirstResponder])
theView = _initialFirstResponder;
theView = _initialFirstResponder;
else
theView = [_initialFirstResponder previousValidKeyView];
theView = [_initialFirstResponder previousValidKeyView];
}
if (theView)
{
[self makeFirstResponder: theView];
if ([theView respondsToSelector:@selector(selectText:)])
{
_selectionDirection = NSSelectingPrevious;
[(id)theView selectText: self];
_selectionDirection = NSDirectSelection;
}
if (![self makeFirstResponder: theView])
{
return;
}
if ([theView respondsToSelector:@selector(selectText:)])
{
_selectionDirection = NSSelectingPrevious;
[(id)theView selectText: self];
_selectionDirection = NSDirectSelection;
}
}
}