mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-29 22:27:38 +00:00
Clean up and addition of cut/copy/paste methods, based on code
by Nikolaus Schaller <hns@computer.org>. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29178 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c444ae92d2
commit
a7a8c31c4c
3 changed files with 125 additions and 38 deletions
46
ChangeLog
46
ChangeLog
|
@ -1,3 +1,9 @@
|
|||
2009-12-29 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/AppKit/NSImageView.h: Clean up.
|
||||
* Source/NSImageView.m: Clean up and addition of cut/copy/paste
|
||||
methods, based on code by Nikolaus Schaller <hns@computer.org>.
|
||||
|
||||
2009-12-27 Quentin Mathe <quentin.mathe@gmail.com>
|
||||
|
||||
* Headers/NSTableView.h
|
||||
|
@ -66,7 +72,7 @@
|
|||
panel is requested.
|
||||
|
||||
2009-12-21 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
|
||||
* Source/GSIconManager.h,
|
||||
* Source/GSIconManager.m: New files. Allows to get icon placement
|
||||
from separate process.
|
||||
|
@ -102,7 +108,7 @@
|
|||
occurred to an instance variable.
|
||||
|
||||
2009-12-21 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
|
||||
* Source/NSTableColumn.m (-initWithCoder:, -encodeWithCoder:): Add
|
||||
the keyed encoding/decoding code for Quentin's extensions.
|
||||
|
||||
|
@ -444,7 +450,7 @@
|
|||
* Source/NSSlider.m: Clean up.
|
||||
* Source/NSSliderCell.m: Remove isFlipped method, correct
|
||||
copyWithZone:, clean up.
|
||||
|
||||
|
||||
2009-11-16 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSCell.m (-setObjectValue:, -setStringValue:): Handle a
|
||||
|
@ -465,7 +471,7 @@
|
|||
in NSTextView_actions.m.
|
||||
|
||||
2009-11-15 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
|
||||
* Source/NSButtonCell.m: Change default value for
|
||||
keyEquivalentModifierMask to 0. Add keyed decoding and encoding of
|
||||
keyEquivalentModifierMask.
|
||||
|
@ -549,7 +555,7 @@
|
|||
* Source/NSTextFieldCell.m: White space changes.
|
||||
* Headers/AppKit/NSTableHeaderCell.h,
|
||||
* Source/NSTableHeaderCell.m: Add new 10.3 methods.
|
||||
|
||||
|
||||
2009-11-09 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSControl.m,
|
||||
|
@ -573,7 +579,7 @@
|
|||
* Headers/AppKit/NSAnimation.h: Change to new MacOSX type definitions.
|
||||
* Source/NSAnimation.m: Remove externs and white space changes.
|
||||
* Source/externs.m: Move externs from NSAnimation to here.
|
||||
|
||||
|
||||
2009-11-08 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSApplication.m (-finishLaunching): Only activate the
|
||||
|
@ -616,7 +622,7 @@
|
|||
|
||||
* Source/NSColor.m (-colorUsingColorSpace): Support more color spaces.
|
||||
* Source/NSColorSpace.m (COLORSPACE): Initialize the static variable.
|
||||
|
||||
|
||||
2009-11-03 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/GSThemeDrawing.m: Add more includes to apeace Riccardo's compiler.
|
||||
|
@ -630,7 +636,7 @@
|
|||
|
||||
* Source/NSApplication.m (-nextEventMatchingMask:...): Only set
|
||||
the current event when dequeuing and never return the null_event.
|
||||
|
||||
|
||||
2009-11-02 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/GSTheme.m: Remove some compiler warnings.
|
||||
|
@ -639,7 +645,7 @@
|
|||
* Source/GSThemeDrawing.m,
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h: New theme methods for
|
||||
toolbar and menu item drawing.
|
||||
|
||||
|
||||
2009-11-01 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSImage.m: Switch to the new shared composite and
|
||||
|
@ -663,7 +669,7 @@
|
|||
* Images/common_ProgressIndeterminate_?.tiff
|
||||
New image files by Uli Kusterer <witness.of.teachtext@gmx.net>.
|
||||
* Images/GNUmakefile: Add the new images.
|
||||
|
||||
|
||||
2009-10-27 Thomas Gamper <icicle@cg.tuwien.ac.at>
|
||||
|
||||
* Source/GSDisplayServer.m
|
||||
|
@ -689,11 +695,11 @@
|
|||
at geometry maths.
|
||||
|
||||
2009-10-23 Riccardo Mottola <rmottola@users.sf.net>
|
||||
|
||||
|
||||
* Headers/AppKit/NSBezierPath.h: added some documentation
|
||||
|
||||
2009-10-22 Riccardo Mottola <rmottola@users.sf.net>
|
||||
|
||||
|
||||
* Images/common_3DArrowRightH.tiff: Made background transparent,
|
||||
allows for better theming
|
||||
|
||||
|
@ -713,7 +719,7 @@
|
|||
colour gradients.
|
||||
* Headers/AppKit/AppKit.h: Add include for NSGradient.h
|
||||
* Source/GNUmakefile: Add new files.
|
||||
|
||||
|
||||
2009-10-20 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/NSDocumentController.m(-openDocumentWithContentsOfURL:display:,
|
||||
|
@ -886,13 +892,13 @@
|
|||
into GSTheme.
|
||||
|
||||
2009-10-10 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
|
||||
* Source/NSEvent.m,
|
||||
* Source/NSImage.m,
|
||||
* Source/GSTextStorage.m: Remove usage of NSDeallocateObject.
|
||||
|
||||
2009-10-10 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
|
||||
* Source/NSApplication.m (-endModalSession:): Bring the window of
|
||||
the next modal session to the front.
|
||||
* Source/NSApplication.m (-runModalSession:): Better check whether
|
||||
|
@ -901,25 +907,25 @@
|
|||
|
||||
2009-09-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSImage.m: ([-setName:]) fix bug which was removing the
|
||||
* Source/NSImage.m: ([-setName:]) fix bug which was removing the
|
||||
wrong name when given an image which already had a name.
|
||||
Make named images thread-safe using a lock.
|
||||
Add private method to update names on theme change.
|
||||
* Source/GSTheme.m: Use new method to update theme images.
|
||||
|
||||
|
||||
2009-09-26 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
|
||||
* Source/NSApplication.m (-setApplicationIconImage:,
|
||||
-finishLaunching): Move the set name code to finishLaunching, as
|
||||
the image called NSApplicationIcon should stay the same all the time.
|
||||
|
||||
2009-09-26 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
|
||||
* Source/NSTextContainer.m (init): Add this method as suggested
|
||||
by Derek Fawcus <dfawcus@cisco.com>.
|
||||
|
||||
2009-09-21 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
|
||||
* Source/NSWindow.m (+standardWindowButton:forStyleMask:): Add
|
||||
support for toolbar button.
|
||||
* Source/NSWindow.m (-toggleToolbarShown:): Reorder the code.
|
||||
|
|
|
@ -29,14 +29,14 @@
|
|||
#define _GNUstep_H_NSImageView
|
||||
#import <GNUstepBase/GSVersionMacros.h>
|
||||
|
||||
#include <AppKit/NSControl.h>
|
||||
#include <AppKit/NSImageCell.h>
|
||||
#import <AppKit/NSControl.h>
|
||||
#import <AppKit/NSImageCell.h>
|
||||
|
||||
@interface NSImageView : NSControl
|
||||
{
|
||||
id _target;
|
||||
SEL _action;
|
||||
BOOL _allowsCutCopyPaste;
|
||||
BOOL _allowsCutCopyPaste;
|
||||
}
|
||||
|
||||
- (NSImage *)image;
|
||||
|
|
|
@ -26,13 +26,14 @@
|
|||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "AppKit/NSDragging.h"
|
||||
#include "AppKit/NSEvent.h"
|
||||
#include "AppKit/NSImage.h"
|
||||
#include "AppKit/NSImageCell.h"
|
||||
#include "AppKit/NSImageView.h"
|
||||
#include "AppKit/NSPasteboard.h"
|
||||
#include "AppKit/NSWindow.h"
|
||||
#import "AppKit/NSDragging.h"
|
||||
#import "AppKit/NSEvent.h"
|
||||
#import "AppKit/NSImage.h"
|
||||
#import "AppKit/NSImageCell.h"
|
||||
#import "AppKit/NSImageView.h"
|
||||
#import "AppKit/NSMenuItem.h"
|
||||
#import "AppKit/NSPasteboard.h"
|
||||
#import "AppKit/NSWindow.h"
|
||||
|
||||
/*
|
||||
* Class variables
|
||||
|
@ -69,14 +70,11 @@ static Class imageCellClass;
|
|||
}
|
||||
|
||||
|
||||
- (id) init
|
||||
{
|
||||
return [self initWithFrame: NSZeroRect];
|
||||
}
|
||||
|
||||
- (id) initWithFrame: (NSRect)aFrame
|
||||
{
|
||||
[super initWithFrame: aFrame];
|
||||
self = [super initWithFrame: aFrame];
|
||||
if (!self)
|
||||
return self;
|
||||
|
||||
// set the default values
|
||||
[self setImageAlignment: NSImageAlignCenter];
|
||||
|
@ -170,9 +168,86 @@ static Class imageCellClass;
|
|||
_allowsCutCopyPaste = flag;
|
||||
}
|
||||
|
||||
@end
|
||||
- (void) delete: (id)sender
|
||||
{
|
||||
if (_allowsCutCopyPaste)
|
||||
[self setImage: nil];
|
||||
}
|
||||
|
||||
@implementation NSImageView (NSDraggingDestination)
|
||||
- (void) deleteBackward: (id)sender
|
||||
{
|
||||
if (_allowsCutCopyPaste)
|
||||
[self setImage: nil];
|
||||
}
|
||||
|
||||
- (void) cut: (id)sender
|
||||
{
|
||||
if (_allowsCutCopyPaste)
|
||||
{
|
||||
[self copy];
|
||||
[self setImage: nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) copy: (id)sender
|
||||
{
|
||||
if (_allowsCutCopyPaste)
|
||||
{
|
||||
NSImage *anImage = [self image];
|
||||
|
||||
if (anImage != nil)
|
||||
{
|
||||
// copy to pasteboard
|
||||
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
|
||||
|
||||
[pboard declareTypes: [NSArray arrayWithObject: NSTIFFPboardType]
|
||||
owner: self];
|
||||
[pboard setData: [anImage TIFFRepresentation]
|
||||
forType: NSTIFFPboardType];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) paste: (id)sender
|
||||
{
|
||||
if (_allowsCutCopyPaste)
|
||||
{
|
||||
// paste from pasteboard
|
||||
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
|
||||
NSImage *image = [[NSImage alloc] initWithPasteboard: pboard];
|
||||
|
||||
if (image != nil)
|
||||
{
|
||||
[self setImage: image];
|
||||
RELEASE(image);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) validateUserInterfaceItem: (id <NSValidatedUserInterfaceItem>)anItem
|
||||
{
|
||||
SEL action = [anItem action];
|
||||
|
||||
if (_allowsCutCopyPaste)
|
||||
{
|
||||
if (sel_eq(action, @selector(cut:)) ||
|
||||
sel_eq(action, @selector(copy:)) ||
|
||||
sel_eq(action, @selector(deleteBackward:)) ||
|
||||
sel_eq(action, @selector(delete:)))
|
||||
return [self image] != nil;
|
||||
if (sel_eq(action, @selector(paste:)))
|
||||
{
|
||||
return [NSImage canInitWithPasteboard:
|
||||
[NSPasteboard generalPasteboard]];
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) validateMenuItem: (NSMenuItem *)anItem
|
||||
{
|
||||
return [self validateUserInterfaceItem: anItem];
|
||||
}
|
||||
|
||||
- (NSDragOperation) draggingEntered: (id <NSDraggingInfo>)sender
|
||||
{
|
||||
|
@ -188,6 +263,8 @@ static Class imageCellClass;
|
|||
}
|
||||
}
|
||||
|
||||
// NSDraggingDestination protocol
|
||||
|
||||
- (void) draggingExited: (id <NSDraggingInfo>)sender
|
||||
{
|
||||
[_cell setHighlighted: NO];
|
||||
|
@ -303,6 +380,8 @@ static Class imageCellClass;
|
|||
[super encodeWithCoder: aCoder];
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
[aCoder encodeObject: [NSImage imagePasteboardTypes]
|
||||
forKey: @"NSDragTypes"];
|
||||
[aCoder encodeBool: [self isEditable] forKey: @"NSEditable"];
|
||||
}
|
||||
else
|
||||
|
@ -315,6 +394,8 @@ static Class imageCellClass;
|
|||
- (id) initWithCoder: (NSCoder *)aDecoder
|
||||
{
|
||||
self = [super initWithCoder: aDecoder];
|
||||
if (!self)
|
||||
return self;
|
||||
|
||||
if ([aDecoder allowsKeyedCoding])
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue