Merged changes from gnustep_testplant_branch branch and cleaned them up

a bit.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@35417 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2012-08-17 13:16:12 +00:00
parent 58fa0b0126
commit ac6909e871
12 changed files with 209 additions and 40 deletions

View file

@ -1,3 +1,59 @@
2012-08-17 Fred Kiefer <FredKiefer@gmx.de>
Merged changes from gnustep_testplant_branch branch.
* Source/NSImage.m (-initWithCoder:): Adopt to coding standard.
* Source/NSScreen.m (-description): Simplify code.
* Source/NSWindow.m (-screen): Only recompute the screen if the
frame isn't fully covered by the current screen.
* Headers/AppKit/NSFontPanel.h: Import NSTextField to have the
NSTextFieldDelegate protocol defined.
* Headers/AppKit/NSControl.h: remove the three now duplicated
methods from NSControlTextEditingDelegate.
2012-08-14 Marcian Lytwyn <marcian.lytwyn@advcsi.com>
* Source/NSImage.m (-initWithCoder:): Fix bug in last commit.
* Source/NSWindow.m (-
2012-06-28 Marcian Lytwyn <marcian.lytwyn@advcsi.com>
* ColorPickers/GSNamedColorPicker.m
GSNamedColorPicker needs to conform to NSTtextFieldDelegate
* ColorPickers/GSStandardColorPicker.h
GSStandardCSColorPicker needs to conform to NSTextFieldDelegate
2012-06-27 Marcian Lytwyn <marcian.lytwyn@advcsi.com>
* Source/NSWindow.m - Fix [NSWindow screen] method according
to documented behavior (return screen that window show up
the most or nil). Fix [NSWindow setFrameFromString] to account for
possible nil screen on input frame and throw window on main screen
in this case. This is to fix an issue with windows not properly
showing up when moved to another monitor during multi-monitor
usage and then the extra monitor(s) are removed.
* Source/NSScreen.m - Added -description method for more information.
2012-06-27 Marcian Lytwyn <marcian.lytwyn@advcsi.com>
*** NSOpenSavePanelDelegate ***
* Headers/AppKit/NSSavePanel.h - Added NSOpenSavePanelDelegate
protocol definition
* Source/NSSavePanel.m - Qualify delegate method(s) with
id<NSOpenSavePanelDelegate>
*** NSControlTextEditingDelegate ***
* Headers/AppKit/NSControl.h - Added NSControlTextEditingDelegate
protocol definition
* Headers/AppKit/NSTextField.h - Added NSTextFieldDelegate
protocol definition
* Source/NSTextField.m - Qualify delegate method(s) with
id<NSTextFieldDelegate>
* Headers/AppKit/NSFontPanel.h - NSFontPanel assigns itself as a
delegate to a NSTextField object and must declare that it
conforms to NSTextFieldDelegate protocol. Added a forward
declaration for NSTextFieldDelegate and added NSTextFieldDelegate
on class interface definition.
2012-08-10 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSColorList.m:

View file

@ -27,7 +27,7 @@
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
@interface GSNamedColorPicker: NSColorPicker <NSColorPickingCustom>
@interface GSNamedColorPicker: NSColorPicker <NSColorPickingCustom, NSTextFieldDelegate>
{
NSView *baseView;
NSComboBox *cb;

View file

@ -35,6 +35,8 @@
@class GSTable, NSSlider, NSTextField;
@class NSBox, NSButtonCell, NSMatrix;
@protocol NSTextFieldDelegate;
@interface GSStandardColorPicker: NSColorPicker <NSColorPickingCustom>
{
GSTable *baseView;
@ -50,7 +52,7 @@
@end
@interface GSStandardCSColorPicker: NSColorPicker <NSColorPickingCustom>
@interface GSStandardCSColorPicker: NSColorPicker <NSColorPickingCustom, NSTextFieldDelegate>
{
GSTable *baseView;;

View file

@ -200,7 +200,13 @@ APPKIT_EXPORT NSString *NSControlTextDidChangeNotification;
//
// Methods Implemented by the Delegate
//
@interface NSObject (NSControlDelegate)
@protocol NSControlTextEditingDelegate <NSObject>
#ifdef __OBJC2__
@optional
#else
@end
@interface NSObject (NSControlTextEditingDelegate)
#endif
- (BOOL) control: (NSControl *)control isValidObject:(id)object;
- (BOOL) control: (NSControl *)control
@ -209,12 +215,6 @@ APPKIT_EXPORT NSString *NSControlTextDidChangeNotification;
- (BOOL) control: (NSControl *)control
textShouldEndEditing: (NSText *)fieldEditor;
- (void) controlTextDidBeginEditing: (NSNotification *)aNotification;
- (void) controlTextDidEndEditing: (NSNotification *)aNotification;
- (void) controlTextDidChange: (NSNotification *)aNotification;
- (BOOL) control: (NSControl *)control
didFailToFormatString: (NSString *)string
errorDescription: (NSString *)error;
@ -237,5 +237,10 @@ APPKIT_EXPORT NSString *NSControlTextDidChangeNotification;
@end
@interface NSObject (NSControlDelegate)
- (void) controlTextDidBeginEditing: (NSNotification *)aNotification;
- (void) controlTextDidEndEditing: (NSNotification *)aNotification;
- (void) controlTextDidChange: (NSNotification *)aNotification;
@end
#endif // _GNUstep_H_NSControl

View file

@ -33,6 +33,7 @@
#import <AppKit/NSPanel.h>
#import <AppKit/NSFontManager.h>
#import <AppKit/NSTextField.h> // needed for NSTextFieldDelegate
@class NSFont;
@class NSView;
@ -55,7 +56,7 @@ enum {
NSFPSizeBrowser
};
@interface NSFontPanel : NSPanel <NSCoding>
@interface NSFontPanel : NSPanel <NSCoding, NSTextFieldDelegate>
{
// Attributes
NSFont *_panelFont;

View file

@ -56,6 +56,31 @@ enum {
NSFileHandlingPanelDiskButton,
NSFileHandlingPanelDiskEjectButton
};
@protocol NSOpenSavePanelDelegate <NSObject>
#ifdef __OBJC2__
@optional
#else
@end
@interface NSObject (NSOpenSavePanelDelegate)
#endif
- (BOOL)panel:(id)sender shouldEnableURL:(NSURL*)url;
- (BOOL)panel:(id)sender validateURL:(NSURL*)url error:(NSError **)error;
- (void)panel:(id)sender didChangeToDirectoryURL:(NSURL*)url;
- (NSString *)panel:(id)sender userEnteredFilename:(NSString*)filename confirmed:(BOOL)flag;
- (void)panel:(id)sender willExpand:(BOOL)expand;
- (void)panelSelectionDidChange:(id)sender;
// Deprecated in 10.6...
- (BOOL)panel:(id)sender isValidFilename:(NSString*)filename;
- (void)panel:(id)sender directoryDidChange:(NSString*)path;
- (NSComparisonResult)panel:(id)sender
compareFilename:(NSString*)name1
with:(NSString*)name2
caseSensitive:(BOOL)caseSensitive;
- (BOOL)panel:(id)sender shouldShowFilename:(NSString*)filename;
@end
@interface NSSavePanel : NSPanel
{

View file

@ -40,6 +40,9 @@
@class NSText;
@class NSCursor;
@protocol NSTextFieldDelegate <NSControlTextEditingDelegate>
@end
@interface NSTextField : NSControl
{
// Attributes
@ -72,8 +75,8 @@
//
// Assigning a Delegate
//
- (void)setDelegate:(id)anObject;
- (id)delegate;
- (void)setDelegate:(id<NSTextFieldDelegate>)anObject;
- (id<NSTextFieldDelegate>)delegate;
//
// Modifying Graphic Attributes

View file

@ -1653,27 +1653,28 @@ static NSSize GSResolutionOfImageRep(NSImageRep *rep)
reps = [coder decodeObjectForKey: @"NSReps"];
reps = [reps objectAtIndex: 0];
id rep = [reps objectAtIndex: 1];
if([rep isKindOfClass:[NSImageRep class]])
if ([rep isKindOfClass: [NSImageRep class]])
{
[self addRepresentation: rep];
}
else
{
if([rep isKindOfClass:[NSURL class]])
if ([rep isKindOfClass: [NSURL class]])
{
rep = [NSImageRep imageRepWithContentsOfURL:rep];
NSURL *tmp = (NSURL*)rep;
rep = [NSImageRep imageRepWithContentsOfURL: rep];
// If we are unable to resolved the URL, try to get it from the
// resources folder.
if(rep == nil)
if (rep == nil)
{
NSString *fileName = [[rep absoluteString] lastPathComponent];
NSString *path = [[NSBundle mainBundle] pathForImageResource:fileName];
rep = [NSImageRep imageRepWithContentsOfFile:path];
NSString *fileName = [[tmp absoluteString] lastPathComponent];
NSString *path = [[NSBundle mainBundle] pathForImageResource: fileName];
rep = [NSImageRep imageRepWithContentsOfFile: path];
}
// If the representation was found, add it...
if(rep != nil)
if (rep != nil)
{
[self addRepresentation: rep];
}

View file

@ -1407,7 +1407,12 @@ selectCellWithString: (NSString*)title
}
}
- (void) setDelegate: (id)aDelegate
- (id<NSOpenSavePanelDelegate>) delegate
{
return [super delegate];
}
- (void) setDelegate: (id<NSOpenSavePanelDelegate>)aDelegate
{
if ([aDelegate respondsToSelector:
@selector(panel:compareFilename:with:caseSensitive:)])

View file

@ -258,6 +258,14 @@ static NSMutableArray *screenArray = nil;
return _frame;
}
- (NSString*) description
{
return [NSString stringWithFormat: @"%@ number: %ld frame: %@",
[super description], (long)_screenNumber,
NSStringFromRect(_frame)];
}
/**
* <p>
* This method generates a dictionary containing information

View file

@ -246,7 +246,7 @@ static Class textFieldCellClass;
/** <p>Sets the delegate to <var>anObject</var>.</p>
<p>See Also: -delegate</p>
*/
- (void) setDelegate: (id)anObject
- (void) setDelegate: (id<NSTextFieldDelegate>)anObject
{
if (_delegate)
[nc removeObserver: _delegate name: nil object: self];
@ -266,7 +266,7 @@ static Class textFieldCellClass;
/** <p>Returns the delegate object.</p>
<p>See Also: -setDelegate:</p>
*/
- (id) delegate
- (id<NSTextFieldDelegate>) delegate
{
return _delegate;
}

View file

@ -164,6 +164,7 @@ static GSWindowAnimationDelegate *animationDelegate;
- (void) _lossOfKeyOrMainWindow;
- (NSView *) _windowView;
- (NSScreen *) _screenForFrame: (NSRect)frame;
@end
@implementation NSWindow (GNUstepPrivate)
@ -378,12 +379,41 @@ has blocked and waited for events.
{
return _wv;
}
/* Support method to properly implement the 'screen' method for NSWindow.
According to documentation the 'screen' method should return the screen
that the window "show up the most or nil". This method supports the 'screen'
method and internal requests for the correct 'screen' based on the
supplied frame request.
*/
- (NSScreen *) _screenForFrame: (NSRect)frame
{
NSInteger largest = 0;
NSArray *screens = [NSScreen screens];
NSInteger index = 0;
NSScreen *theScreen = nil;
for (index = 0; index < [screens count]; ++index)
{
NSScreen *screen = [screens objectAtIndex: index];
NSRect sframe = [screen frame];
NSRect iframe = NSIntersectionRect(frame, sframe);
NSInteger isize = NSWidth(iframe) * NSHeight(iframe);
if (isize > largest)
{
largest = isize;
theScreen = screen;
}
}
NSDebugLLog(@"NSWindow", @"%s: frame: %@ screen: %@ size: %ld\n", __PRETTY_FUNCTION__,
NSStringFromRect(frame), theScreen, (long)largest);
return theScreen;
}
@end
@interface NSMiniWindow : NSWindow
@end
@ -1073,9 +1103,9 @@ many times.
if (style == NSWindows95InterfaceStyle)
{
if([self canBecomeMainWindow])
{
[self setMenu: [NSApp mainMenu]];
}
{
[self setMenu: [NSApp mainMenu]];
}
}
NSDebugLLog(@"NSWindow", @"NSWindow end of init\n");
@ -2553,6 +2583,18 @@ many times.
/** Returns the screen the window is on. */
- (NSScreen *) screen
{
// Only recompute the screen if the current screen
// doesn't contain the whole window.
// FIXME: Containing half the window would be enough
if (_screen != nil)
{
NSRect sframe = [_screen frame];
if (NSContainsRect(sframe, _frame))
{
return _screen;
}
}
ASSIGN(_screen, [self _screenForFrame: _frame]);
return _screen;
}
@ -4603,6 +4645,7 @@ current key view.<br />
NSRect sRect;
NSRect fRect;
int value;
NSScreen *screen;
/*
* Scan in the window frame (flipped coordinate system).
@ -4638,11 +4681,13 @@ current key view.<br />
/*
* Check that the window will come up on screen
*/
#if 0 // Not valid since screen frame x/y values can be negative...
if (fRect.origin.x + fRect.size.width < 0)
{
NSLog(@"Bad screen frame - window is off screen");
return;
return;
}
#endif
// if toolbar is showing, adjust saved frame to add the toolbar back in
if ([_toolbar isVisible])
@ -4694,8 +4739,19 @@ current key view.<br />
* The screen rectangle gives the area of the screen in which
* the window could be placed (ie a rectangle excluding the dock).
*/
nRect = [[self screen] visibleFrame];
screen = [self _screenForFrame: fRect];
// Check whether a portion is showing somewhere...
if (screen == nil)
{
// If the window doesn't show up on any screen then we need
// to move it so it can be seen and assign it to the main
// screen...
screen = [NSScreen mainScreen];
NSDebugLLog(@"NSWindow", @"%s: re-assigning to main screen\n", __PRETTY_FUNCTION__);
}
nRect = [screen visibleFrame];
/*
* If the new screen drawable area has moved relative to the one in
* which the window was saved, adjust the window position accordingly.
@ -4725,9 +4781,9 @@ current key view.<br />
* If height of the window goes above the screen height, then adjust the window down.
*/
if ((fRect.size.height + fRect.origin.y) > nRect.size.height)
{
fRect.origin.y = nRect.size.height - fRect.size.height;
}
{
fRect.origin.y = nRect.size.height - fRect.size.height;
}
}
// FIXME: Is this check needed?
@ -4745,6 +4801,9 @@ current key view.<br />
}
}
// Make sure we are using the new screen we are applying to...
ASSIGN(_screen, screen);
/*
* Set frame.
*/
@ -4781,6 +4840,7 @@ current key view.<br />
{
NSRect fRect;
NSRect sRect;
NSString *autosaveString;
fRect = _frame;
@ -4804,12 +4864,15 @@ current key view.<br />
* the window could be placed (ie a rectangle excluding the dock).
*/
sRect = [[self screen] visibleFrame];
autosaveString = [NSString stringWithFormat: @"%d %d %d %d %d %d % d %d ",
(int)fRect.origin.x, (int)fRect.origin.y,
(int)fRect.size.width, (int)fRect.size.height,
(int)sRect.origin.x, (int)sRect.origin.y,
(int)sRect.size.width, (int)sRect.size.height];
NSDebugLLog(@"NSWindow", @"%s:autosaveName: %@ frame string: %@", __PRETTY_FUNCTION__,
_autosaveName, autosaveString);
return [NSString stringWithFormat: @"%d %d %d %d %d %d % d %d ",
(int)fRect.origin.x, (int)fRect.origin.y,
(int)fRect.size.width, (int)fRect.size.height,
(int)sRect.origin.x, (int)sRect.origin.y,
(int)sRect.size.width, (int)sRect.size.height];
return autosaveString;
}
/*