mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 22:10:47 +00:00
Adding implementation for NSSelection and skeletal implementation for NSOutlineView. GJC
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@11248 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2bc4e57f82
commit
dab1ab0c88
7 changed files with 493 additions and 11 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
Thu Oct 25 16:42:00 2001 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* Source/NSSelection.m implemented bodies of methods for NSSelection.
|
||||||
|
The behaviour implemented is identical to that observed when testing
|
||||||
|
NSSelection under OPENSTEP with the exception that I have replaced
|
||||||
|
the word "NeXT" with "GNUstep" in the selection marker descriptions.
|
||||||
|
* Source/NSOutlineView.m implelemented a skeletal version of this
|
||||||
|
class to be filled in later.
|
||||||
|
* Headers/NSOutlineView.h created a skeletal version of this header
|
||||||
|
to be filled in later.
|
||||||
|
* Headers/AppKit.h added #include for NSOutlineView.h.
|
||||||
|
* Source/GNUmakefile added reference to NSOutlineView.h and
|
||||||
|
NSOutlineView.m
|
||||||
|
|
||||||
Wed Oct 24 11:01:33 2001 Nicola Pero <nicola@brainstorm.co.uk>
|
Wed Oct 24 11:01:33 2001 Nicola Pero <nicola@brainstorm.co.uk>
|
||||||
|
|
||||||
* Source/NSBrowser.m ([NSBrowser -_getTitleOfColumn:]): Make sure
|
* Source/NSBrowser.m ([NSBrowser -_getTitleOfColumn:]): Make sure
|
||||||
|
|
|
@ -93,6 +93,7 @@
|
||||||
#include <AppKit/NSMenuView.h>
|
#include <AppKit/NSMenuView.h>
|
||||||
#include <AppKit/NSNibLoading.h>
|
#include <AppKit/NSNibLoading.h>
|
||||||
#include <AppKit/NSOpenPanel.h>
|
#include <AppKit/NSOpenPanel.h>
|
||||||
|
#include <AppKit/NSOutlineView.h>
|
||||||
#include <AppKit/NSPageLayout.h>
|
#include <AppKit/NSPageLayout.h>
|
||||||
#include <AppKit/NSPanel.h>
|
#include <AppKit/NSPanel.h>
|
||||||
#include <AppKit/NSParagraphStyle.h>
|
#include <AppKit/NSParagraphStyle.h>
|
||||||
|
|
153
Headers/gnustep/gui/NSOutlineView.h
Normal file
153
Headers/gnustep/gui/NSOutlineView.h
Normal file
|
@ -0,0 +1,153 @@
|
||||||
|
/*
|
||||||
|
NSOutlineView.h
|
||||||
|
|
||||||
|
The outline class.
|
||||||
|
|
||||||
|
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
Date: October 2001
|
||||||
|
|
||||||
|
This file is part of the GNUstep GUI Library.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; see the file COPYING.LIB.
|
||||||
|
If not, write to the Free Software Foundation,
|
||||||
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GNUstep_H_NSOutlineView
|
||||||
|
#define _GNUstep_H_NSOutlineView
|
||||||
|
|
||||||
|
#include <AppKit/NSTableView.h>
|
||||||
|
|
||||||
|
@interface NSOutlineView : NSTableView
|
||||||
|
{
|
||||||
|
BOOL _resize;
|
||||||
|
BOOL _followsCell;
|
||||||
|
BOOL _autosave;
|
||||||
|
float _indentLevel;
|
||||||
|
NSTableColumn *_outlineTableColumn;
|
||||||
|
BOOL _shouldCollapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Instance methods
|
||||||
|
- (BOOL)autoResizesOutlineColumn;
|
||||||
|
- (BOOL)autosaveExpandedItems;
|
||||||
|
- (void)collapseItem: (id)item;
|
||||||
|
- (void)collapseItem: (id)item collapseChildren: (BOOL)collapseChildren;
|
||||||
|
- (void)expandItem: (id)item;
|
||||||
|
- (void)expandItem:(id)item expandChildren:(BOOL)expandChildren;
|
||||||
|
- (BOOL)indentationMarkerFollowsCell;
|
||||||
|
- (float)indentationPerLevel;
|
||||||
|
- (BOOL)isExpandable: (id)item;
|
||||||
|
- (BOOL)isItemExpanded: (id)item;
|
||||||
|
- (id)itemAtRow: (int)row;
|
||||||
|
- (int)levelForItem: (id)item;
|
||||||
|
- (int)levelForRow:(int)row;
|
||||||
|
- (NSTableColumn *)outlineTableColumn;
|
||||||
|
- (void)reloadItem: (id)item;
|
||||||
|
- (void)reloadItem: (id)item reloadChildren: (BOOL)reloadChildren;
|
||||||
|
- (int)rowForItem: (id)item;
|
||||||
|
- (void)setAutoresizesOutlineColumn: (BOOL)resize;
|
||||||
|
- (void)setAutosaveExpandedItems: (BOOL)flag;
|
||||||
|
- (void)setDropItem:(id)item dropChildIndex: (int)index;
|
||||||
|
- (void)setIndentationMarkerFollowsCell: (BOOL)followsCell;
|
||||||
|
- (void)setIndentationPerLevel: (float)newIndentLevel;
|
||||||
|
- (void)setOutlineTableColumn: (NSTableColumn *)outlineTableColumn;
|
||||||
|
- (BOOL)shouldCollapseAutoExpandedItemsForDeposited: (BOOL)deposited;
|
||||||
|
|
||||||
|
@end /* interface of NSTableView */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Informal protocol NSOutlineViewDataSource
|
||||||
|
*/
|
||||||
|
@interface NSObject (NSOutlineViewDataSource)
|
||||||
|
- (BOOL)outlineView: (NSOutlineView *)outlineView
|
||||||
|
acceptDrop: (id <NSDraggingInfo>)info
|
||||||
|
item: (id)item
|
||||||
|
childIndex: (int)index;
|
||||||
|
|
||||||
|
- (id)outlineView: (NSOutlineView *)outlineView
|
||||||
|
child: (int)index
|
||||||
|
ofItem:(id)item;
|
||||||
|
|
||||||
|
- (BOOL)outlineView: (NSOutlineView *)outlineView
|
||||||
|
isItemExpandable: (id)item;
|
||||||
|
|
||||||
|
- (id)outlineView: (NSOutlineView *)outlineView
|
||||||
|
itemForPersistentObject:(id)object;
|
||||||
|
|
||||||
|
- (int)outlineView: (NSOutlineView *)outlineView
|
||||||
|
numberOfChildrenOfItem: (id)item;
|
||||||
|
|
||||||
|
- (id)outlineView: (NSOutlineView *)outlineView
|
||||||
|
objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||||
|
byItem:(id)item;
|
||||||
|
|
||||||
|
- (id)outlineView: (NSOutlineView *)outlineView
|
||||||
|
persistentObjectForItem: (id)item;
|
||||||
|
|
||||||
|
- (void)outlineView: (NSOutlineView *)outlineView
|
||||||
|
setObjectView: (id)object
|
||||||
|
forTableColumn: (NSTableColumn *)tableColumn;
|
||||||
|
|
||||||
|
- (NSDragOperation)outlineView: (NSOutlineView*)outlineView
|
||||||
|
validateDrop: (id <NSDraggingInfo>)info
|
||||||
|
proposedItem: (id)item proposedChildIndex:(int)index;
|
||||||
|
|
||||||
|
- (BOOL)outlineView: (NSOutlineView *)outlineView
|
||||||
|
writeItems: (NSArray*)items
|
||||||
|
toPasteboard: (NSPasteboard*)pboard;
|
||||||
|
@end
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Constants
|
||||||
|
*/
|
||||||
|
enum { NSOutlineViewDropOnItemIndex = -1 };
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Notifications
|
||||||
|
*/
|
||||||
|
APPKIT_EXPORT NSString *NSOutlineViewColumnDidMoveNotification;
|
||||||
|
APPKIT_EXPORT NSString *NSOutlineViewColumnDidResizeNotification;
|
||||||
|
APPKIT_EXPORT NSString *NSOutlineViewSelectionDidChangeNotification;
|
||||||
|
APPKIT_EXPORT NSString *NSOutlineViewSelectionIsChangingNotification;
|
||||||
|
APPKIT_EXPORT NSString *NSOutlineViewItemDidExpandNotification;
|
||||||
|
APPKIT_EXPORT NSString *NSOutlineViewItemDidCollapseNotification;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Methods Implemented by the Delegate
|
||||||
|
*/
|
||||||
|
@interface NSObject (NSOutlineViewDelegate)
|
||||||
|
|
||||||
|
- (BOOL) outlineView: (NSOutlineView *)aOutlineView
|
||||||
|
shouldEditTableColumn: (NSTableColumn *)aTableColumn
|
||||||
|
row: (int)rowIndex;
|
||||||
|
- (BOOL) outlineView: (NSOutlineView *)aOutlineView
|
||||||
|
shouldSelectRow: (int)rowIndex;
|
||||||
|
- (BOOL) outlineView: (NSOutlineView *)aOutlineView
|
||||||
|
shouldSelectTableColumn: (NSTableColumn *)aTableColumn;
|
||||||
|
- (void) outlineView: (NSOutlineView *)aOutlineView
|
||||||
|
willDisplayCell: (id)aCell
|
||||||
|
forTableColumn: (NSTableColumn *)aTableColumn
|
||||||
|
row: (int)rowIndex;
|
||||||
|
- (void) outlineViewColumnDidMove: (NSNotification *)aNotification;
|
||||||
|
- (void) outlineViewColumnDidResize: (NSNotification *)aNotification;
|
||||||
|
- (void) outlineViewSelectionDidChange: (NSNotification *)aNotification;
|
||||||
|
- (void) outlineViewSelectionIsChanging: (NSNotification *)aNotification;
|
||||||
|
- (void) outlineViewItemDidExpand: (NSNotification *)aNotification;
|
||||||
|
- (void) outlineViewItemDidCollapse: (NSNotification *)aNotification;
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif /* _GNUstep_H_NSOutlineView */
|
|
@ -37,6 +37,10 @@
|
||||||
@interface NSSelection : NSObject <NSCoding>
|
@interface NSSelection : NSObject <NSCoding>
|
||||||
{
|
{
|
||||||
// Attributes
|
// Attributes
|
||||||
|
@private
|
||||||
|
NSData *_descriptionData;
|
||||||
|
BOOL _isWellKnownSelection;
|
||||||
|
int _selectionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -99,6 +99,7 @@ NSMenuView.m \
|
||||||
NSMenuItem.m \
|
NSMenuItem.m \
|
||||||
NSMenuItemCell.m \
|
NSMenuItemCell.m \
|
||||||
NSOpenPanel.m \
|
NSOpenPanel.m \
|
||||||
|
NSOutlineView.m \
|
||||||
NSObjectProtocols.m \
|
NSObjectProtocols.m \
|
||||||
NSPageLayout.m \
|
NSPageLayout.m \
|
||||||
NSPanel.m \
|
NSPanel.m \
|
||||||
|
@ -251,6 +252,7 @@ NSNibConnector.h \
|
||||||
NSNibDeclarations.h \
|
NSNibDeclarations.h \
|
||||||
NSNibLoading.h \
|
NSNibLoading.h \
|
||||||
NSOpenPanel.h \
|
NSOpenPanel.h \
|
||||||
|
NSOutlineView.h \
|
||||||
NSPageLayout.h \
|
NSPageLayout.h \
|
||||||
NSPanel.h \
|
NSPanel.h \
|
||||||
NSParagraphStyle.h \
|
NSParagraphStyle.h \
|
||||||
|
|
174
Source/NSOutlineView.m
Normal file
174
Source/NSOutlineView.m
Normal file
|
@ -0,0 +1,174 @@
|
||||||
|
/*
|
||||||
|
NSOutlineView.h
|
||||||
|
|
||||||
|
The outline class.
|
||||||
|
|
||||||
|
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
Date: October 2001
|
||||||
|
|
||||||
|
This file is part of the GNUstep GUI Library.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; see the file COPYING.LIB.
|
||||||
|
If not, write to the Free Software Foundation,
|
||||||
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <AppKit/NSOutlineView.h>
|
||||||
|
|
||||||
|
@implementation NSOutlineView
|
||||||
|
|
||||||
|
// Instance methods
|
||||||
|
- (id)init
|
||||||
|
{
|
||||||
|
[super init];
|
||||||
|
_resize = NO;
|
||||||
|
_followsCell = NO;
|
||||||
|
_autosave = NO;
|
||||||
|
_indentLevel = 0.0;
|
||||||
|
_outlineTableColumn = nil;
|
||||||
|
_shouldCollapse = NO;
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)autoResizesOutlineColumn
|
||||||
|
{
|
||||||
|
return _resize;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)autosaveExpandedItems
|
||||||
|
{
|
||||||
|
return _autosave;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)collapseItem: (id)item
|
||||||
|
{
|
||||||
|
// Nothing yet...
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)collapseItem: (id)item collapseChildren: (BOOL)collapseChildren
|
||||||
|
{
|
||||||
|
// Nothing yet...
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)expandItem: (id)item
|
||||||
|
{
|
||||||
|
// Nothing yet...
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)expandItem:(id)item expandChildren:(BOOL)expandChildren
|
||||||
|
{
|
||||||
|
// Nothing yet...
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)indentationMarkerFollowsCell
|
||||||
|
{
|
||||||
|
return _followsCell;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (float)indentationPerLevel
|
||||||
|
{
|
||||||
|
return _indentLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isExpandable: (id)item
|
||||||
|
{
|
||||||
|
// Nothing yet...
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isItemExpanded: (id)item
|
||||||
|
{
|
||||||
|
// Nothing yet...
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)itemAtRow: (int)row
|
||||||
|
{
|
||||||
|
// Nothing yet...
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (int)levelForItem: (id)item
|
||||||
|
{
|
||||||
|
// Nothing yet...
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (int)levelForRow: (int)row
|
||||||
|
{
|
||||||
|
// Nothing yet...
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSTableColumn *)outlineTableColumn
|
||||||
|
{
|
||||||
|
return _outlineTableColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)reloadItem: (id)item
|
||||||
|
{
|
||||||
|
// Nothing yet...
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)reloadItem: (id)item reloadChildren: (BOOL)reloadChildren
|
||||||
|
{
|
||||||
|
// Nothing yet...
|
||||||
|
}
|
||||||
|
|
||||||
|
- (int)rowForItem: (id)item
|
||||||
|
{
|
||||||
|
// Nothing yet...
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setAutoresizesOutlineColumn: (BOOL)resize
|
||||||
|
{
|
||||||
|
_resize = resize;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setAutosaveExpandedItems: (BOOL)flag
|
||||||
|
{
|
||||||
|
_autosave = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setDropItem:(id)item dropChildIndex: (int)index
|
||||||
|
{
|
||||||
|
// Nothing yet...
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setIndentationMarkerFollowsCell: (BOOL)followsCell
|
||||||
|
{
|
||||||
|
_followsCell = followsCell;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setIndentationPerLevel: (float)newIndentLevel
|
||||||
|
{
|
||||||
|
_indentLevel = newIndentLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setOutlineTableColumn: (NSTableColumn *)outlineTableColumn
|
||||||
|
{
|
||||||
|
_outlineTableColumn = outlineTableColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)shouldCollapseAutoExpandedItemsForDeposited: (BOOL)deposited
|
||||||
|
{
|
||||||
|
return _shouldCollapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end /* implementation of NSTableView */
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
/*
|
/*
|
||||||
NSSelection.m
|
NSSelection.m
|
||||||
|
|
||||||
Description...
|
Description: NSSelection is used by NSDataLink to refer to a
|
||||||
|
selection within a document.
|
||||||
|
|
||||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
Date: 2001
|
||||||
|
|
||||||
Author: Scott Christley <scottc@net-community.com>
|
Author: Scott Christley <scottc@net-community.com>
|
||||||
Date: 1996
|
Date: 1996
|
||||||
|
|
||||||
|
@ -27,10 +31,64 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gnustep/gui/config.h>
|
#include <gnustep/gui/config.h>
|
||||||
|
#include <Foundation/NSCoder.h>
|
||||||
|
#include <Foundation/NSData.h>
|
||||||
#include <AppKit/NSSelection.h>
|
#include <AppKit/NSSelection.h>
|
||||||
|
#include <AppKit/NSPasteboard.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// Global instances of these selections
|
||||||
|
//
|
||||||
|
static NSSelection *_sharedAllSelection = nil;
|
||||||
|
static NSSelection *_sharedCurrentSelection = nil;
|
||||||
|
static NSSelection *_sharedEmptySelection = nil;
|
||||||
|
|
||||||
|
// Private methods and variables for NSSelection
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
GSCustomSelection,
|
||||||
|
GSAllSelection,
|
||||||
|
GSCurrentSelection,
|
||||||
|
GSEmptySelection
|
||||||
|
} GSSelectionType;
|
||||||
|
|
||||||
|
@interface NSSelection (PrivateMethods)
|
||||||
|
- (void)_setIsWellKnownSelection: (BOOL)wellknown;
|
||||||
|
- (GSSelectionType)_selectionType;
|
||||||
|
- (void)_setSelectionType: (GSSelectionType)type;
|
||||||
|
+ (NSSelection *)_wellKnownSelection: (char *)description;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NSSelection (PrivateMethods)
|
||||||
|
- (void)_setIsWellKnownSelection: (BOOL)wellknown
|
||||||
|
{
|
||||||
|
_isWellKnownSelection = wellknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_setSelectionType: (GSSelectionType)type
|
||||||
|
{
|
||||||
|
_selectionType = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (GSSelectionType)_selectionType
|
||||||
|
{
|
||||||
|
return _selectionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSSelection *)_wellKnownSelection: (char *)description
|
||||||
|
{
|
||||||
|
NSData *selectionData = [NSData dataWithBytes: description
|
||||||
|
length: strlen(description)];
|
||||||
|
NSSelection *selection =
|
||||||
|
[NSSelection selectionWithDescriptionData: selectionData];
|
||||||
|
|
||||||
|
[selection _setIsWellKnownSelection: YES];
|
||||||
|
|
||||||
|
return selection;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation NSSelection
|
@implementation NSSelection
|
||||||
|
|
||||||
//
|
//
|
||||||
// Class methods
|
// Class methods
|
||||||
//
|
//
|
||||||
|
@ -46,19 +104,41 @@
|
||||||
//
|
//
|
||||||
// Returning Special Selection Shared Instances
|
// Returning Special Selection Shared Instances
|
||||||
//
|
//
|
||||||
|
//
|
||||||
|
// NOTE: The description returned for each of these is similar to the one
|
||||||
|
// returned under OPENSTEP.
|
||||||
|
//
|
||||||
+ (NSSelection *)allSelection
|
+ (NSSelection *)allSelection
|
||||||
{
|
{
|
||||||
return nil;
|
if(!_sharedAllSelection)
|
||||||
|
{
|
||||||
|
_sharedAllSelection =
|
||||||
|
[NSSelection _wellKnownSelection: "GNUstep All selection marker"];
|
||||||
|
[_sharedEmptySelection _setSelectionType: GSAllSelection];
|
||||||
|
}
|
||||||
|
return _sharedAllSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSSelection *)currentSelection
|
+ (NSSelection *)currentSelection
|
||||||
{
|
{
|
||||||
return nil;
|
if(!_sharedCurrentSelection)
|
||||||
|
{
|
||||||
|
_sharedCurrentSelection =
|
||||||
|
[NSSelection _wellKnownSelection: "GNUstep Current selection marker"];
|
||||||
|
[_sharedCurrentSelection _setSelectionType: GSCurrentSelection];
|
||||||
|
}
|
||||||
|
return _sharedCurrentSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSSelection *)emptySelection
|
+ (NSSelection *)emptySelection
|
||||||
{
|
{
|
||||||
return nil;
|
if(!_sharedEmptySelection)
|
||||||
|
{
|
||||||
|
_sharedEmptySelection =
|
||||||
|
[NSSelection _wellKnownSelection: "GNUstep Empty selection marker"];
|
||||||
|
[_sharedEmptySelection _setSelectionType: GSEmptySelection];
|
||||||
|
}
|
||||||
|
return _sharedEmptySelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -66,7 +146,9 @@
|
||||||
//
|
//
|
||||||
+ (NSSelection *)selectionWithDescriptionData:(NSData *)data
|
+ (NSSelection *)selectionWithDescriptionData:(NSData *)data
|
||||||
{
|
{
|
||||||
return nil;
|
NSSelection *selection =
|
||||||
|
AUTORELEASE([[NSSelection alloc] initWithDescriptionData: data]);
|
||||||
|
return selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -78,12 +160,21 @@
|
||||||
//
|
//
|
||||||
- (id)initWithDescriptionData:(NSData *)newData
|
- (id)initWithDescriptionData:(NSData *)newData
|
||||||
{
|
{
|
||||||
return nil;
|
[super init];
|
||||||
|
ASSIGN(_descriptionData, newData);
|
||||||
|
_isWellKnownSelection = NO;
|
||||||
|
_selectionType = GSCustomSelection;
|
||||||
|
|
||||||
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithPasteboard:(NSPasteboard *)pasteboard
|
- (id)initWithPasteboard:(NSPasteboard *)pasteboard
|
||||||
{
|
{
|
||||||
return nil;
|
[super init];
|
||||||
|
ASSIGN(_descriptionData, [pasteboard dataForType: NSGeneralPboardType]);
|
||||||
|
_isWellKnownSelection = NO;
|
||||||
|
|
||||||
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -91,29 +182,72 @@
|
||||||
//
|
//
|
||||||
- (NSData *)descriptionData
|
- (NSData *)descriptionData
|
||||||
{
|
{
|
||||||
return nil;
|
return _descriptionData;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isWellKnownSelection
|
- (BOOL)isWellKnownSelection
|
||||||
{
|
{
|
||||||
return NO;
|
return _isWellKnownSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Writing a Selection to the Pasteboard
|
// Writing a Selection to the Pasteboard
|
||||||
//
|
//
|
||||||
- (void)writeToPasteboard:(NSPasteboard *)pasteboard
|
- (void)writeToPasteboard:(NSPasteboard *)pasteboard
|
||||||
{}
|
{
|
||||||
|
[pasteboard setData: _descriptionData
|
||||||
|
forType: NSGeneralPboardType];
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// NSCoding protocol
|
// NSCoding protocol
|
||||||
//
|
//
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(BOOL)
|
||||||
|
at: &_isWellKnownSelection];
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(int)
|
||||||
|
at: &_selectionType];
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(id)
|
||||||
|
at: _descriptionData];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||||
{
|
{
|
||||||
|
[super init];
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(BOOL)
|
||||||
|
at: &_isWellKnownSelection];
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(int)
|
||||||
|
at: &_selectionType];
|
||||||
|
|
||||||
|
// if it's a well known selection then determine which one it is.
|
||||||
|
if(_isWellKnownSelection)
|
||||||
|
{
|
||||||
|
switch(_selectionType)
|
||||||
|
{
|
||||||
|
case GSAllSelection:
|
||||||
|
RELEASE(self);
|
||||||
|
self = RETAIN([NSSelection allSelection]);
|
||||||
|
break;
|
||||||
|
case GSCurrentSelection:
|
||||||
|
RELEASE(self);
|
||||||
|
self = RETAIN([NSSelection currentSelection]);
|
||||||
|
break;
|
||||||
|
case GSEmptySelection:
|
||||||
|
RELEASE(self);
|
||||||
|
self = RETAIN([NSSelection emptySelection]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Shouldn't get here.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(id)
|
||||||
|
at: _descriptionData];
|
||||||
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue