Merge pull request #62 from gnustep/NSPathControl_branch

NSPathControl branch
This commit is contained in:
Gregory Casamento 2020-05-08 04:10:04 -04:00 committed by GitHub
commit 36ad37071c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 1668 additions and 21 deletions

View file

@ -1,3 +1,26 @@
2020-05-06 Gregory John Casamento <greg.casamento@gmail.com>
* Headers/Additions/GNUstepGUI/GSTheme.h: Add declarations
for new drawing methods.
* Headers/AppKit/AppKit.h: Add headers to main header
* Headers/AppKit/NSMenu.h: Add method to draw the popup in
the appropriate positin
* Headers/AppKit/NSPathCell.h: Implementation of path cell header
* Headers/AppKit/NSPathComponentCell.h: Component cell
* Headers/AppKit/NSPathControl.h: Control
* Headers/AppKit/NSPathControlItem.h: Control item
* MISSING: Remove NSPath* classes since they have been implemented
* Source/GNUmakefile: Add files to compile and copy
* Source/GSThemeDrawing.m: Add new drawing methods.
* Source/GSXib5KeyedUnarchiver.m: Add new decoding methods
* Source/NSMenu.m: Implement method to position popup
* Source/NSPathCell.m: Implementation path cell.
* Source/NSPathComponentCell.m: Cell representation of each
component
* Source/NSPathControlItem.m: Path items
* Source/NSPathControl.m: Path control to contain path cell and
components.
2020-04-26 Gregory John Casamento <greg.casamento@gmail.com>
* Headers/Additions/GNUstepGUI/GSTheme.h: Add declarations

View file

@ -252,6 +252,8 @@
@class NSProgressIndicator;
@class NSTableHeaderCell;
@class NSTabViewItem;
@class NSPathControl;
@class NSPathComponentCell;
@class GSDrawTiles;
@class GSTitleView;
@ -972,6 +974,13 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
forState: (NSControlStateValue)state
enabled: (BOOL)enabled;
// NSPathComponentCell
- (void) drawPathComponentCellWithFrame: (NSRect)f
inView: (NSPathControl *)pc
withCell: (NSPathComponentCell *)cell
isLastComponent: (BOOL)last;
// NSSegmentedControl drawing methods
- (void) drawSegmentedControlSegment: (NSCell *)cell

View file

@ -192,6 +192,10 @@
#import <AppKit/NSOpenGLView.h>
#import <AppKit/NSOutlineView.h>
#import <AppKit/NSParagraphStyle.h>
#import <AppKit/NSPathControl.h>
#import <AppKit/NSPathCell.h>
#import <AppKit/NSPathComponentCell.h>
#import <AppKit/NSPathControlItem.h>
#import <AppKit/NSPickerTouchBarItem.h>
#import <AppKit/NSPredicateEditor.h>
#import <AppKit/NSPredicateEditorRowTemplate.h>

View file

@ -434,6 +434,12 @@
withFont: (NSFont *)font;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
- (void) popUpMenuPositionItem: (NSMenuItem *)item
atLocation: (NSPoint) point
inView: (NSView *) view;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
+ (BOOL) menuBarVisible;
+ (void) setMenuBarVisible: (BOOL)flag;

128
Headers/AppKit/NSPathCell.h Normal file
View file

@ -0,0 +1,128 @@
/* Definition of class NSPathCell
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: Wed Apr 22 18:19:07 EDT 2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _NSPathCell_h_GNUSTEP_GUI_INCLUDE
#define _NSPathCell_h_GNUSTEP_GUI_INCLUDE
#import <AppKit/NSActionCell.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
#if defined(__cplusplus)
extern "C" {
#endif
enum {
NSPathStyleStandard,
NSPathStyleNavigationBar, // deprecated
NSPathStylePopUp
};
typedef NSUInteger NSPathStyle;
@protocol NSPathCellDelegate;
@class NSEvent, NSView, NSArray, NSString, NSAttributeString, NSColor, NSPathComponentCell, NSOpenPanel, NSURL;
@interface NSPathCell : NSActionCell
{
NSPathStyle _pathStyle;
NSColor *_backgroundColor;
NSAttributedString *_placeholderAttributedString;
NSArray *_allowedTypes;
id<NSPathCellDelegate> _delegate;
NSURL *_url;
SEL _doubleAction;
NSArray *_pathComponentCells;
NSPathComponentCell *_clickedPathComponentCell;
id _objectValue;
}
- (void)mouseEntered:(NSEvent *)event
withFrame:(NSRect)frame
inView:(NSView *)view;
- (void)mouseExited:(NSEvent *)event
withFrame:(NSRect)frame
inView:(NSView *)view;
- (void) setAllowedTypes: (NSArray *)types;
- (NSArray *) allowedTypes;
- (NSPathStyle) pathStyle;
- (void) setPathStyle: (NSPathStyle)pathStyle;
- (NSAttributedString *) placeholderAttributedString;
- (void) setPlaceholderAttributedString: (NSAttributedString *)string;
- (NSString *) placeholderString;
- (void) setPlaceholderString: (NSString *)string;
- (NSColor *) backgroundColor;
- (void) setBackgroundColor: (NSColor *)color;
+ (Class) pathComponentCellClass;
+ (void) setPathComponentCellClass: (Class)clz;
- (NSRect)rectOfPathComponentCell:(NSPathComponentCell *)cell
withFrame:(NSRect)frame
inView:(NSView *)view;
- (NSPathComponentCell *)pathComponentCellAtPoint:(NSPoint)point
withFrame:(NSRect)frame
inView:(NSView *)view;
- (NSPathComponentCell *) clickedPathComponentCell;
- (NSArray *) pathComponentCells;
- (void) setPathComponentCells: (NSArray *)cells;
- (SEL) doubleAction;
- (void) setDoubleAction: (SEL)action;
- (NSURL *) URL;
- (void) setURL: (NSURL *)url;
- (id<NSPathCellDelegate>) delegate;
- (void) setDelegate: (id<NSPathCellDelegate>)delegate;
@end
@protocol NSPathCellDelegate
- (void)pathCell:(NSPathCell *)pathCell
willDisplayOpenPanel:(NSOpenPanel *)openPanel;
- (void)pathCell:(NSPathCell *)pathCell
willPopUpMenu:(NSMenu *)menu;
@end
#if defined(__cplusplus)
}
#endif
#endif /* GS_API_MACOSX */
#endif /* _NSPathCell_h_GNUSTEP_GUI_INCLUDE */

View file

@ -0,0 +1,60 @@
/* Definition of class NSPathComponentCell
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: Wed Apr 22 18:19:21 EDT 2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _NSPathComponentCell_h_GNUSTEP_GUI_INCLUDE
#define _NSPathComponentCell_h_GNUSTEP_GUI_INCLUDE
#import <AppKit/NSTextFieldCell.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
#if defined(__cplusplus)
extern "C" {
#endif
@class NSImage, NSURL;
@interface NSPathComponentCell : NSTextFieldCell
{
NSImage *_image;
NSURL *_url;
BOOL _lastComponent;
}
- (NSImage *) image;
- (void) setImage: (NSImage *)image;
- (NSURL *) URL;
- (void) setURL: (NSURL *)url;
@end
#if defined(__cplusplus)
}
#endif
#endif /* GS_API_MACOSX */
#endif /* _NSPathComponentCell_h_GNUSTEP_GUI_INCLUDE */

View file

@ -0,0 +1,122 @@
/* Definition of class NSPathControl
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: Wed Apr 22 18:19:40 EDT 2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _NSPathControl_h_GNUSTEP_GUI_INCLUDE
#define _NSPathControl_h_GNUSTEP_GUI_INCLUDE
#import <AppKit/NSControl.h>
#import <AppKit/NSDragging.h>
#import <AppKit/NSPathCell.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
#if defined(__cplusplus)
extern "C" {
#endif
@protocol NSPathControlDelegate;
@class NSColor, NSPathComponentCell, NSArray, NSURL, NSAttributedString, NSString,
NSMenu, NSPasteboard, NSOpenPanel, NSPathControlItem;
@interface NSPathControl : NSControl
{
NSArray *_pathItems;
id<NSPathControlDelegate> _delegate;
NSDragOperation _localMask;
NSDragOperation _remoteMask;
NSTrackingRectTag _trackingTag;
}
- (void) setPathStyle: (NSPathStyle)style;
- (NSPathStyle) pathStyle;
- (NSColor *) backgroundColor;
- (void) setBackgroundColor: (NSColor *)backgroundColor;
- (NSPathComponentCell *) clickedPathComponentCell;
- (NSArray *) pathComponentCells;
- (void) setPathComponentCells: (NSArray *)cells;
- (SEL) doubleAction;
- (void) setDoubleAction: (SEL)doubleAction;
- (NSURL *) URL;
- (void) setURL: (NSURL *)url;
- (id<NSPathControlDelegate>) delegate;
- (void) setDelegate: (id<NSPathControlDelegate>) delegate;
- (void) setDraggingSourceOperationMask: (NSDragOperation)mask
forLocal: (BOOL)local;
- (NSArray *) allowedTypes;
- (void) setAllowedTypes: (NSArray *)allowedTypes;
- (NSPathControlItem *) clickedPathItem;
- (NSArray *) pathItems;
- (void) setPathItems: (NSArray *)items;
- (NSAttributedString *) placeholderAttributedString;
- (void) setPlaceholderAttributedString: (NSAttributedString *)string;
- (NSString *) placeholderString;
- (void) setPlaceholderString: (NSString *)string;
@end
@protocol NSPathControlDelegate
- (BOOL)pathControl: (NSPathControl *)pathControl
shouldDragPathComponentCell: (NSPathComponentCell *)pathComponentCell
withPasteboard: (NSPasteboard *)pasteboard;
- (NSDragOperation) pathControl: (NSPathControl *)pathControl
validateDrop: (id<NSDraggingInfo>)info;
- (BOOL) pathControl: (NSPathControl *)pathControl
acceptDrop: (id<NSDraggingInfo>)info;
- (void) pathControl: (NSPathControl *)pathControl
willDisplayOpenPanel: (NSOpenPanel *)openPanel;
- (void) pathControl: (NSPathControl *)pathControl
willPopUpMenu: (NSMenu *)menu;
- (BOOL) pathControl: (NSPathControl *)pathControl
shouldDragItem: (NSPathControlItem *)pathItem
withPasteboard: (NSPasteboard *)pasteboard;
@end
#if defined(__cplusplus)
}
#endif
#endif /* GS_API_MACOSX */
#endif /* _NSPathControl_h_GNUSTEP_GUI_INCLUDE */

View file

@ -0,0 +1,65 @@
/* Interface of class NSPathControlItem
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: Wed Apr 22 18:20:16 EDT 2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _NSPathControlItem_h_GNUSTEP_GUI_INCLUDE
#define _NSPathControlItem_h_GNUSTEP_GUI_INCLUDE
#import <Foundation/NSObject.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST)
#if defined(__cplusplus)
extern "C" {
#endif
@class NSURL, NSAttributedString, NSImage, NSString;
@interface NSPathControlItem : NSObject
{
NSURL *_url;
NSAttributedString *_attributedTitle;
NSImage *_image;
}
- (NSURL *) URL;
- (void) setURL: (NSURL *)url;
- (NSAttributedString *) attributedTitle;
- (void) setAttributedTitle: (NSAttributedString *)attributedTitle;
- (NSImage *) image;
- (void) setImage: (NSImage *)image;
- (NSString *) title;
- (void) setTitle: (NSString *)title;
@end
#if defined(__cplusplus)
#endif
#endif /* GS_API_MACOSX */
#endif /* _NSPathControlItem_h_GNUSTEP_GUI_INCLUDE */

19
MISSING
View file

@ -24,10 +24,6 @@ MISSING HEADERS
> NSMenuToolbarItem.h
> NSOpenGLLayer.h
> NSPageController.h
> NSPathCell.h
> NSPathComponentCell.h
> NSPathControl.h
> NSPathControlItem.h
> NSPersistentDocument.h
> NSRuleEditor.h
> NSSliderAccessory.h
@ -52,21 +48,6 @@ MISSING HEADERS
> NSWindowTab.h
> NSWindowTabGroup.h
Completed
---
> NSCIIImageRep.h
> NSPDFImageRep.h
> NSPDFInfo.h
> NSPDFPanel.h
> NSPICTImageRep.h
> NSDockTile.h
> NSAppearance.h
> NSDataAsset.h
> NSTouch.h
> NSTouchBar.h
> NSSpeechRecognizer.h
> NSColorSampler.h
Mac Specific
---
> NSButtonTouchBarItem.h

View file

@ -115,6 +115,10 @@ NSFormCell.m \
NSGroupTouchBarItem.m \
NSMagnificationGestureRecognizer.m \
NSPanGestureRecognizer.m \
NSPathCell.m \
NSPathComponentCell.m \
NSPathControl.m \
NSPathControlItem.m \
NSPickerTouchBarItem.m \
NSPopoverTouchBarItem.m \
NSPressGestureRecognizer.m \
@ -450,6 +454,10 @@ NSOutlineView.h \
NSPageLayout.h \
NSPanel.h \
NSPanGestureRecognizer.h \
NSPathCell.h \
NSPathComponentCell.h \
NSPathControl.h \
NSPathControlItem.h \
NSParagraphStyle.h \
NSPasteboard.h \
NSPasteboardItem.h \

View file

@ -59,7 +59,9 @@
#import "AppKit/NSTabViewItem.h"
#import "AppKit/PSOperators.h"
#import "AppKit/NSSliderCell.h"
#import "AppKit/NSPathCell.h"
#import "AppKit/NSPathControl.h"
#import "AppKit/NSPathComponentCell.h"
#import "GNUstepGUI/GSToolbarView.h"
#import "GNUstepGUI/GSTitleView.h"
@ -949,6 +951,89 @@
}
// NSPathComponentCell
- (void) drawPathComponentCellWithFrame: (NSRect)frame
inView: (NSPathControl *)pc
withCell: (NSPathComponentCell *)cell
isLastComponent: (BOOL)last
{
NSImage *img = [cell image];
NSURL *url = [cell URL];
NSString *string = [[url path] lastPathComponent];
NSRect textFrame = frame;
NSRect imgFrame = frame;
NSRect arrowFrame = frame;
NSImage *arrowImage = [NSImage imageNamed: @"NSMenuArrow"];
NSPathStyle style= [pc pathStyle];
NSRect newFrame = frame;
if (style == NSPathStylePopUp)
{
newFrame = [pc frame];
// Reset coodinates.
newFrame.origin.x = 0.0;
newFrame.origin.y = 0.0;
// Use control frame...
textFrame = newFrame;
imgFrame = newFrame;
arrowFrame = newFrame;
}
// Modify positions...
imgFrame.size.width = 17.0;
imgFrame.size.height = 17.0;
imgFrame.origin.x += 2.0;
imgFrame.origin.y += 2.0;
textFrame.origin.x += imgFrame.size.width + 5.0; // the width of the image plus a few pixels.
textFrame.origin.y += 5.0; // center with the image...
arrowFrame.origin.x += newFrame.size.width - 17.0;
arrowFrame.size.width = 8.0;
arrowFrame.size.height = 8.0;
arrowFrame.origin.y += 5.0;
if (style== NSPathStyleStandard || style== NSPathStyleNavigationBar)
{
// Draw the image...
[img drawInRect: imgFrame];
// Draw the text...
[[NSColor textColor] set];
[string drawAtPoint: textFrame.origin
withAttributes: nil];
// Draw the arrow...
if (last == NO)
{
[arrowImage drawInRect: arrowFrame];
}
}
else if (style == NSPathStylePopUp)
{
if (last == YES)
{
arrowImage = [NSImage imageNamed: @"common_ArrowDown"];
// Draw border...
[[NSColor controlShadowColor] set];
NSFrameRectWithWidth(newFrame, 1.0);
// Draw the image...
[img drawInRect: imgFrame];
// Draw the text...
[[NSColor textColor] set];
[string drawAtPoint: textFrame.origin
withAttributes: nil];
// Draw the arrow...
[arrowImage drawInRect: arrowFrame];
}
}
}
// NSSegmentedControl drawing methods
- (void) drawSegmentedControlSegment: (NSCell *)cell

View file

@ -47,6 +47,8 @@
#import "AppKit/NSMenuItem.h"
#import "AppKit/NSNib.h"
#import "AppKit/NSParagraphStyle.h"
#import "AppKit/NSPathCell.h"
#import "AppKit/NSPathComponentCell.h"
#import "AppKit/NSPopUpButton.h"
#import "AppKit/NSPopUpButtonCell.h"
#import "AppKit/NSScroller.h"
@ -155,6 +157,9 @@ static NSString *ApplicationClass = nil;
@end
@interface NSPathCell (Private)
+ (NSArray *) _generateCellsForURL: (NSURL *)url;
@end
@implementation GSXib5KeyedUnarchiver
@ -382,6 +387,7 @@ static NSArray *XmlBoolDefaultYes = nil;
@"decodeToolbarIdentifiedItemsForElement:", @"NSToolbarIBIdentifiedItems",
@"decodeToolbarImageForElement:", @"NSToolbarItemImage",
@"decodeControlContentsForElement:", @"NSControlContents",
@"decodePathStyle:", @"NSPathStyle",
nil];
RETAIN(XmlKeyToDecoderSelectorMap);
@ -1428,6 +1434,8 @@ didStartElement: (NSString*)elementName
size = [NSFont labelFontSize];
else if ([metaFont containsString: @"system"])
size = [NSFont systemFontSize];
else if ([metaFont containsString: @"toolTip"])
size = [NSFont smallSystemFontSize];
else if (metaFont)
NSWarnMLog(@"unknown meta font value: %@", metaFont);
}
@ -2192,6 +2200,11 @@ didStartElement: (NSString*)elementName
{
object = [element attributeForKey: @"stringValue"];
}
else if ([class isSubclassOfClass: [NSPathCell class]])
{
GSXibElement *el = [element elementForKey: @"url"];
object = [NSURL URLWithString: [el attributeForKey: @"string"]];
}
else
{
// Try the title attribute first as it is the more common encoding...
@ -2740,6 +2753,31 @@ didStartElement: (NSString*)elementName
return num;
}
- (id) decodePathStyle: (GSXibElement *)element
{
NSNumber *num = [NSNumber numberWithInteger: 0];
id obj = [element attributeForKey: @"pathStyle"];
if ([obj isEqualToString: @"standard"])
{
num = [NSNumber numberWithInteger: NSPathStyleStandard];
}
else if ([obj isEqualToString: @"popUp"])
{
num = [NSNumber numberWithInteger: NSPathStylePopUp];
}
else if ([obj isEqualToString: @"navigationBar"])
{
num = [NSNumber numberWithInteger: NSPathStyleNavigationBar];
}
else // if not specified then assume standard...
{
num = [NSNumber numberWithInteger: NSPathStyleStandard];
}
return num;
}
- (id) objectForXib: (GSXibElement*)element
{
id object = [super objectForXib: element];
@ -3166,6 +3204,7 @@ didStartElement: (NSString*)elementName
{
hasValue = [currentElement attributeForKey: @"title"] != nil;
hasValue |= [currentElement attributeForKey: @"image"] != nil;
hasValue |= [currentElement attributeForKey: @"string"] != nil;
}
else if ([@"NSControlContents" isEqualToString: key])
{

View file

@ -1619,13 +1619,33 @@ static BOOL menuBarVisible = YES;
}
+ (void) popUpContextMenu: (NSMenu *)menu
withEvent: (NSEvent *)event
withEvent: (NSEvent *)event
forView: (NSView *)view
withFont: (NSFont *)font
{
[menu _rightMouseDisplay: event];
}
- (void) popUpMenuPositionItem: (NSMenuItem *)item
atLocation: (NSPoint) point
inView: (NSView *) view
{
NSRect cellFrame = [view convertRect: [view bounds] toView: nil];
NSWindow *w = [view window];
NSMenuView *mr = [self menuRepresentation];
NSUInteger selectedItem = [self indexOfItem: item];
cellFrame = [[view window] convertRectToScreen: cellFrame];
cellFrame.origin.x += point.x;
cellFrame.origin.y += point.y;
[[GSTheme theme] displayPopUpMenu: mr
withCellFrame: cellFrame
controlViewWindow: w
preferredEdge: NSMinYEdge
selectedItem: selectedItem];
}
/*
* NSObject Protocol
*/

365
Source/NSPathCell.m Normal file
View file

@ -0,0 +1,365 @@
/* Implementation of class NSPathCell
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: Wed Apr 22 18:19:07 EDT 2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#import "AppKit/NSPathCell.h"
#import "AppKit/NSWorkspace.h"
#import "AppKit/NSImage.h"
#import "AppKit/NSPathComponentCell.h"
static Class pathComponentCellClass;
@interface NSPathCell (Private)
+ (NSArray *) _generateCellsForURL: (NSURL *)url;
@end
@interface NSPathComponentCell (Private)
- (void) _setLastComponent: (BOOL)f;
@end
@implementation NSPathCell
+ (void) initialize
{
if (self == [NSPathCell class])
{
[self setVersion: 1.0];
[self setPathComponentCellClass: [NSPathComponentCell class]];
}
}
- (void) dealloc
{
RELEASE(_backgroundColor);
RELEASE(_placeholderAttributedString);
RELEASE(_allowedTypes);
RELEASE(_url);
RELEASE(_pathComponentCells);
[super dealloc];
}
- (void)mouseEntered:(NSEvent *)event
withFrame:(NSRect)frame
inView:(NSView *)view
{
// This is the method where the expansion of the cell happens
// if the path component cells are shortened.
// This is currently not implemented.
}
- (void)mouseExited:(NSEvent *)event
withFrame:(NSRect)frame
inView:(NSView *)view
{
// This is the method where the contraction of the cell happens
// if the path component cells are shortened.
// This is currently not implemented.
}
- (void) setAllowedTypes: (NSArray *)types
{
ASSIGNCOPY(_allowedTypes, types);
}
- (NSArray *) allowedTypes
{
return _allowedTypes;
}
- (NSPathStyle) pathStyle
{
return _pathStyle;
}
- (void) setPathStyle: (NSPathStyle)pathStyle
{
_pathStyle = pathStyle;
}
- (NSAttributedString *) placeholderAttributedString
{
return _placeholderAttributedString;
}
- (void) setPlaceholderAttributedString: (NSAttributedString *)string
{
ASSIGNCOPY(_placeholderAttributedString, string);
}
- (NSString *) placeholderString
{
return [_placeholderAttributedString string];
}
- (void) setPlaceholderString: (NSString *)string
{
NSAttributedString *as = [[NSAttributedString alloc] initWithString: string];
[self setPlaceholderAttributedString: as];
RELEASE(as);
}
- (NSColor *) backgroundColor
{
return _backgroundColor;
}
- (void) setBackgroundColor: (NSColor *)color
{
ASSIGNCOPY(_backgroundColor, color);
}
+ (Class) pathComponentCellClass
{
return pathComponentCellClass;
}
+ (void) setPathComponentCellClass: (Class)clz
{
pathComponentCellClass = clz;
}
- (NSRect)rectOfPathComponentCell:(NSPathComponentCell *)cell
withFrame:(NSRect)frame
inView:(NSView *)view
{
NSUInteger index = [_pathComponentCells indexOfObject: cell];
CGFloat cellWidth = (frame.size.width / (CGFloat)[_pathComponentCells count]);
return NSMakeRect(frame.origin.x + (cellWidth * (CGFloat)index),
frame.origin.y,
cellWidth,
frame.size.height);
}
- (NSPathComponentCell *)pathComponentCellAtPoint:(NSPoint)point
withFrame:(NSRect)frame
inView:(NSView *)view
{
NSUInteger c = [_pathComponentCells count];
NSUInteger woc = frame.size.width / c;
NSUInteger item = (NSUInteger)point.x / woc;
return [_pathComponentCells objectAtIndex: item];
}
- (NSPathComponentCell *) clickedPathComponentCell
{
return _clickedPathComponentCell;
}
- (NSArray *) pathComponentCells
{
return _pathComponentCells;
}
- (void) setPathComponentCells: (NSArray *)cells
{
ASSIGNCOPY(_pathComponentCells, cells);
}
- (SEL) doubleAction
{
return _doubleAction;
}
- (void) setDoubleAction: (SEL)action
{
_doubleAction = action;
}
- (id) objectValue
{
return _objectValue;
}
- (void) setObjectValue: (id)obj
{
ASSIGN(_objectValue, obj);
[self setPathComponentCells:
[NSPathCell _generateCellsForURL: (NSURL *)_objectValue]];
}
- (NSURL *) URL
{
return [self objectValue];
}
- (void) setURL: (NSURL *)url
{
[self setObjectValue: url];
}
- (id<NSPathCellDelegate>) delegate
{
return _delegate;
}
- (void) setDelegate: (id<NSPathCellDelegate>)delegate
{
_delegate = delegate;
}
- (void) drawInteriorWithFrame: (NSRect)frame inView: (NSView *)controlView
{
NSUInteger count = [_pathComponentCells count];
[super drawInteriorWithFrame: frame
inView: controlView];
NSEnumerator *en = [_pathComponentCells objectEnumerator];
NSPathComponentCell *cell = nil;
while ((cell = (NSPathComponentCell *)[en nextObject]) != nil)
{
NSRect f = [self rectOfPathComponentCell: cell
withFrame: frame
inView: controlView];
[cell drawInteriorWithFrame: f
inView: controlView];
}
}
- (id) initWithCoder: (NSCoder *)coder
{
self = [super initWithCoder: coder];
if ([coder allowsKeyedCoding])
{
[self setPathStyle: NSPathStyleStandard];
if ([coder containsValueForKey: @"NSPathStyle"])
{
[self setPathStyle: [coder decodeIntegerForKey: @"NSPathStyle"]];
}
}
else
{
[coder decodeValueOfObjCType: @encode(NSUInteger)
at: &_pathStyle];
[self setPathComponentCells: [coder decodeObject]];
}
return self;
}
- (void) encodeWithCoder: (NSCoder *)coder
{
[super encodeWithCoder: coder];
if ([coder allowsKeyedCoding])
{
[coder encodeInteger: [self pathStyle]
forKey: @"NSPathStyle"];
[coder encodeObject: [self pathComponentCells]
forKey: @"NSPathComponentCells"];
}
else
{
[coder encodeValueOfObjCType: @encode(NSUInteger)
at: &_pathStyle];
[coder encodeObject: [self pathComponentCells]];
}
}
@end
@implementation NSPathCell (Private)
// Private...
+ (NSArray *) _generateCellsForURL: (NSURL *)url
{
NSMutableArray *array = [NSMutableArray arrayWithCapacity: 10];
// Create cells
if (url != nil)
{
BOOL isDir = NO;
BOOL at_root = NO;
NSFileManager *fm = [NSFileManager defaultManager];
NSURL *u = url;
// Decompose string...
while (at_root == NO)
{
NSPathComponentCell *cell = [[NSPathComponentCell alloc] init];
NSImage *image = nil;
NSString *string = [u path];
[cell setURL: u];
[fm fileExistsAtPath: string
isDirectory: &isDir];
if ([string isEqualToString: @"/"])
{
at_root = YES;
}
if (isDir && at_root == NO)
{
image = [NSImage imageNamed: @"NSFolder"];
}
else if (isDir == YES && at_root == YES)
{
image = [NSImage imageNamed: @"NSComputer"];
}
else
{
image = [[NSWorkspace sharedWorkspace] iconForFile: [[url path] lastPathComponent]];
}
[cell setImage: image];
if ([array count] == 0) // the element we are adding is the last component that will show
{
[cell _setLastComponent: YES];
}
else
{
[cell _setLastComponent: NO];
}
[array insertObject: cell
atIndex: 0];
RELEASE(cell);
string = [string stringByDeletingLastPathComponent];
u = [NSURL URLWithString: string
relativeToURL: nil];
if (u == nil && at_root == NO)
{
// Because when we remove the last path component
// all that is left is a blank... so we add the "/" so that
// it is shown.
u = [NSURL URLWithString: @"/"];
}
}
}
return [array copy];
}
@end
@implementation NSPathComponentCell (Private)
- (void) _setLastComponent: (BOOL)f
{
_lastComponent = f;
}
@end

View file

@ -0,0 +1,73 @@
/* Implementation of class NSPathComponentCell
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: Wed Apr 22 18:19:21 EDT 2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#import <Foundation/NSURL.h>
#import <Foundation/NSGeometry.h>
#import "AppKit/NSPathComponentCell.h"
#import "AppKit/NSImage.h"
#import "GNUstepGUI/GSTheme.h"
@implementation NSPathComponentCell
- (void) dealloc
{
RELEASE(_image);
RELEASE(_url);
[super dealloc];
}
- (NSImage *) image
{
return _image;
}
- (void) setImage: (NSImage *)image
{
ASSIGNCOPY(_image, image);
}
- (NSURL *) URL
{
return _url;
}
- (void) setURL: (NSURL *)url
{
ASSIGNCOPY(_url, url);
}
- (void) drawInteriorWithFrame: (NSRect)f
inView: (NSView *)v
{
[super drawInteriorWithFrame: f inView: v];
[[GSTheme theme] drawPathComponentCellWithFrame: f
inView: (NSPathControl *)v
withCell: self
isLastComponent: _lastComponent];
}
@end

575
Source/NSPathControl.m Normal file
View file

@ -0,0 +1,575 @@
/* Implementation of class NSPathControl
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: Wed Apr 22 18:19:40 EDT 2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#import <Foundation/NSNotification.h>
#import "AppKit/NSPathControl.h"
#import "AppKit/NSPathCell.h"
#import "AppKit/NSGraphics.h"
#import "AppKit/NSDragging.h"
#import "AppKit/NSPasteboard.h"
#import "AppKit/NSMenu.h"
#import "AppKit/NSOpenPanel.h"
#import "AppKit/NSPathComponentCell.h"
#import "AppKit/NSPathControlItem.h"
#import "AppKit/NSEvent.h"
#import "AppKit/NSTrackingArea.h"
static NSNotificationCenter *nc = nil;
static Class pathCellClass;
@interface NSPathCell (PathControlPrivate)
- (void) _setClickedPathComponentCell: (NSPathComponentCell *)c;
@end
@interface NSPathComponentCell (PathControlPrivate)
- (NSPathControlItem *) _pathControlItem;
@end
@implementation NSPathControl
+ (void) initialize
{
if (self == [NSPathControl class])
{
[self setVersion: 1.0];
[self setCellClass: [NSPathCell class]];
nc = [NSNotificationCenter defaultCenter];
}
}
+ (Class) cellClass
{
return pathCellClass;
}
+ (void) setCellClass: (Class)classId
{
pathCellClass = classId;
}
- (void) resetCursorRects
{
[[self superview] removeTrackingRect: _trackingTag];
_trackingTag = [[self superview] addTrackingRect: [self frame]
owner: self
userData: nil
assumeInside: YES];
}
- (instancetype) init
{
self = [super init];
if (self != nil)
{
[self setPathStyle: NSPathStyleStandard];
[self setURL: nil];
[self setDelegate: nil];
[self setAllowedTypes: [NSArray arrayWithObject: NSFilenamesPboardType]];
}
return self;
}
- (void) dealloc
{
[[self superview] removeTrackingRect: _trackingTag];
[super dealloc];
}
- (void) mouseEntered: (NSEvent *)event
{
[_cell mouseEntered: event
withFrame: [self frame]
inView: self];
}
- (void) mouseExited: (NSEvent *)event
{
[_cell mouseExited: event
withFrame: [self frame]
inView: self];
}
- (void) setPathStyle: (NSPathStyle)style
{
[_cell setPathStyle: style];
[self setNeedsDisplay];
}
- (NSPathStyle) pathStyle
{
return [_cell pathStyle];
}
- (NSPathComponentCell *) clickedPathComponentCell
{
return [_cell clickedPathComponentCell];
}
- (NSArray *) pathComponentCells
{
return [_cell pathComponentCells];
}
- (void) setPathComponentCells: (NSArray *)cells
{
[_cell setPathComponentCells: cells];
[self setNeedsDisplay];
}
- (SEL) doubleAction;
{
return [_cell doubleAction];
}
- (void) setDoubleAction: (SEL)doubleAction
{
[_cell setDoubleAction: doubleAction];
}
- (void) _createPathItems
{
NSArray *a = [_cell pathComponentCells];
NSEnumerator *en = [a objectEnumerator];
NSPathComponentCell *c = nil;
NSMutableArray *items = [NSMutableArray arrayWithCapacity: [a count]];
while ((c = [en nextObject]) != nil)
{
NSPathControlItem *pi = [c _pathControlItem];
[items addObject: pi];
}
[self setPathItems: [items copy]];
}
- (NSURL *) URL
{
return [_cell URL];
}
- (void) setURL: (NSURL *)url
{
[_cell setURL: url];
[self _createPathItems];
[self setNeedsDisplay];
}
- (id<NSPathControlDelegate>) delegate
{
return _delegate;
}
- (void) setDelegate: (id<NSPathControlDelegate>) delegate
{
_delegate = delegate;
}
- (NSDragOperation) draggingSourceOperationMaskForLocal: (BOOL)flag
{
if (flag)
{
return _localMask;
}
return _remoteMask;
}
- (void) setDraggingSourceOperationMask: (NSDragOperation)mask
forLocal: (BOOL)local
{
if (local)
{
_localMask = mask;
}
else
{
_remoteMask = mask;
}
}
- (NSArray *) allowedTypes;
{
return [_cell allowedTypes];
}
- (void) setAllowedTypes: (NSArray *)allowedTypes
{
[_cell setAllowedTypes: allowedTypes];
[self registerForDraggedTypes: allowedTypes];
}
- (NSPathControlItem *) clickedPathItem
{
return [[self clickedPathComponentCell] _pathControlItem];
}
- (NSArray *) pathItems
{
return _pathItems;
}
- (void) setPathItems: (NSArray *)items
{
NSEnumerator *en = [items objectEnumerator];
NSMutableArray *array = [NSMutableArray arrayWithCapacity: [items count]];
NSPathControlItem *item = nil;
while ((item = [en nextObject]) != nil)
{
NSPathComponentCell *cell = [[NSPathComponentCell alloc] init];
[cell setImage: [item image]];
[cell setURL: [item URL]];
[array addObject: cell];
}
[self setPathComponentCells: array];
ASSIGNCOPY(_pathItems, items);
[self setNeedsDisplay];
}
- (NSAttributedString *) placeholderAttributedString
{
return [_cell placeholderAttributedString];
}
- (void) setPlaceholderAttributedString: (NSAttributedString *)string
{
[_cell setPlaceholderAttributedString: string];
[self setNeedsDisplay];
}
- (NSString *) placeholderString
{
return [_cell placeholderString];
}
- (void) setPlaceholderString: (NSString *)string
{
[_cell setPlaceholderString: string];
[self setNeedsDisplay];
}
- (NSColor *) backgroundColor
{
return [_cell backgroundColor];
}
- (void) setBackgroundColor: (NSColor *)color
{
[_cell setBackgroundColor: color];
[self setNeedsDisplay];
}
- (void) _doMenuAction: (id)sender
{
NSPathComponentCell *cc = (NSPathComponentCell *)[sender representedObject];
[_cell _setClickedPathComponentCell: cc];
if ([[self cell] action])
{
[self sendAction: [[self cell] action]
to: [[self cell] target]];
}
[[sender menu] close];
}
- (void) _doChooseMenuAction: (id)sender
{
NSOpenPanel *op = [NSOpenPanel openPanel];
int result = 0;
NSFileManager *fm = [NSFileManager defaultManager];
BOOL isDir = NO;
NSString *path = nil;
NSString *file = nil;
[fm fileExistsAtPath: [[self URL] path]
isDirectory: &isDir];
if (isDir)
{
path = [[self URL] path];
}
else
{
path = [[[self URL] path] stringByDeletingLastPathComponent];
file = [[[self URL] path] lastPathComponent];
}
[op setAllowsMultipleSelection: NO];
[op setCanChooseFiles: YES];
[op setCanChooseDirectories: YES];
if ([(id)_delegate respondsToSelector: @selector(pathCell:willPopUpMenu:)])
{
[_delegate pathControl: self
willDisplayOpenPanel: op];
}
if ([(id)[_cell delegate] respondsToSelector: @selector(pathCell:willPopUpMenu:)])
{
[[_cell delegate] pathCell: _cell
willDisplayOpenPanel: op];
}
result = [op runModalForDirectory: path
file: file
types: nil];
if (result == NSOKButton)
{
NSArray *urls = [op URLs];
NSURL *url = [urls objectAtIndex: 0];
[self setURL: url];
}
[[sender menu] close];
}
- (void) mouseDown: (NSEvent *)event
{
if (![self isEnabled])
{
[super mouseDown: event];
return;
}
if ([self pathStyle] == NSPathStylePopUp)
{
NSPathCell *acell = (NSPathCell *)[self cell];
NSArray *array = [acell pathComponentCells];
NSMenu *menu = AUTORELEASE([[NSMenu alloc] initWithTitle: nil]);
NSPathComponentCell *c = nil;
NSEnumerator *en = [array objectEnumerator];
while ((c = [en nextObject]) != nil)
{
NSURL *u = [c URL];
NSString *s = [[u path] lastPathComponent];
NSMenuItem *i = [[NSMenuItem alloc] init];
[i setTitle: s];
[i setTarget: self];
[i setAction: @selector(_doMenuAction:)];
[i setRepresentedObject: c];
[menu insertItem: i
atIndex: 0];
RELEASE(i);
}
// Add separator
[menu insertItem: [NSMenuItem separatorItem]
atIndex: 0];
// Add choose menu option
NSMenuItem *i = [[NSMenuItem alloc] init];
[i setTitle: _(@"Choose...")];
[i setTarget: self];
[i setAction: @selector(_doChooseMenuAction:)];
[menu insertItem: i
atIndex: 0];
RELEASE(i);
[self setMenu: menu];
if (_delegate)
{
if ([(id)_delegate respondsToSelector: @selector(pathControl:willPopUpMenu:)])
{
[_delegate pathControl: self
willPopUpMenu: menu];
}
}
if ([_cell delegate])
{
if ([(id)[_cell delegate] respondsToSelector: @selector(pathCell:willPopUpMenu:)])
{
[[_cell delegate] pathCell: _cell
willPopUpMenu: menu];
}
}
[menu popUpMenuPositionItem: [menu itemAtIndex: 0]
atLocation: NSMakePoint(0.0, 0.0)
inView: self];
}
else
{
NSPathComponentCell *pcc = [_cell pathComponentCellAtPoint: [event locationInWindow]
withFrame: [self frame]
inView: self];
[_cell _setClickedPathComponentCell: pcc];
if ([[self cell] action])
{
[self sendAction: [[self cell] action]
to: [[self cell] target]];
}
}
}
- (NSDragOperation) draggingEntered: (id<NSDraggingInfo>)sender
{
if (_delegate != nil)
{
NSDragOperation dop = [_delegate pathControl: self
validateDrop: sender];
return dop;
}
return NSDragOperationCopy;
}
- (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
{
NSPasteboard *pb = [sender draggingPasteboard];
if ([[pb types] containsObject: NSFilenamesPboardType])
{
NSArray *files = [pb propertyListForType: NSFilenamesPboardType];
if ([files count] > 0)
{
NSString *file = [files objectAtIndex: 0];
NSURL *u = [NSURL URLWithString: file];
BOOL accept = NO;
if ([self delegate])
{
accept = [_delegate pathControl: self
acceptDrop: sender];
}
else
{
accept = YES;
}
if (accept)
{
[self setURL: u];
}
}
}
return YES;
}
- (instancetype) initWithCoder: (NSKeyedUnarchiver *)coder
{
self = [super initWithCoder: coder];
if (self != nil)
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"NSBackgroundColor"])
{
[self setBackgroundColor: [coder decodeObjectForKey: @"NSBackgroundColor"]];
}
else
{
[self setBackgroundColor: [NSColor windowBackgroundColor]];
}
if ([coder containsValueForKey: @"NSDragTypes"])
{
[self setAllowedTypes: [coder decodeObjectForKey: @"NSDragTypes"]];
}
else
{
[self setAllowedTypes: [NSArray arrayWithObject: NSFilenamesPboardType]];
}
if ([coder containsValueForKey: @"NSControlAction"])
{
NSString *s = [coder decodeObjectForKey: @"NSControlAction"];
[self setAction: NSSelectorFromString(s)];
}
if ([coder containsValueForKey: @"NSControlTarget"])
{
id t = [coder decodeObjectForKey: @"NSControlTarget"];
[self setTarget: t];
}
}
else
{
[self setBackgroundColor: [coder decodeObject]];
[self setAllowedTypes: [coder decodeObject]];
[self setAction: NSSelectorFromString([coder decodeObject])];
[self setTarget: [coder decodeObject]];
}
}
return self;
}
- (void) encodeWithCoder: (NSCoder *)coder
{
[super encodeWithCoder: coder];
if ([coder allowsKeyedCoding])
{
[coder encodeObject: [self backgroundColor]
forKey: @"NSBackgroundColor"];
[coder encodeObject: [self allowedTypes]
forKey: @"NSDragTypes"];
[coder encodeObject: NSStringFromSelector([self action])
forKey: @"NSControlAction"];
[coder encodeObject: [self target]
forKey: @"NSControlTarget"];
}
else
{
[coder encodeObject: [self backgroundColor]];
[coder encodeObject: [self allowedTypes]];
[coder encodeObject: NSStringFromSelector([self action])];
[coder encodeObject: [self target]];
}
}
@end
@implementation NSPathCell (PathControlPrivate)
- (void) _setClickedPathComponentCell: (NSPathComponentCell *)c
{
_clickedPathComponentCell = c;
}
@end
@implementation NSPathComponentCell (PathControlPrivate)
- (NSPathControlItem *) _pathControlItem
{
NSPathControlItem *pi = [[NSPathControlItem alloc] init];
NSURL *u = [self URL];
NSString *path = [u path];
[pi setImage: [self image]];
[pi setURL: u];
[pi setTitle: [path lastPathComponent]];
AUTORELEASE(pi);
return pi;
}
@end

View file

@ -0,0 +1,84 @@
/* Implementation of class NSPathControlItem
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: Wed Apr 22 18:20:16 EDT 2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#import <Foundation/NSString.h>
#import <Foundation/NSURL.h>
#import <Foundation/NSAttributedString.h>
#import "AppKit/NSPathControlItem.h"
#import "AppKit/NSImage.h"
@implementation NSPathControlItem
- (NSAttributedString *) attributedTitle
{
return _attributedTitle;
}
- (void) setAttributedTitle: (NSAttributedString *)attributedTitle
{
ASSIGNCOPY(_attributedTitle, attributedTitle);
}
- (NSImage *) image
{
return _image;
}
- (void) setImage: (NSImage *)image
{
ASSIGNCOPY(_image, image);
}
- (NSURL *) URL
{
return _url;
}
- (void) setURL: (NSURL *)url
{
ASSIGNCOPY(_url, url);
}
- (NSString *) title
{
return [_attributedTitle string];
}
- (void) setTitle: (NSString *)title
{
NSAttributedString *attrTitle = [[NSAttributedString alloc] initWithString: title];
[self setAttributedTitle: attrTitle];
RELEASE(attrTitle);
}
- (void) dealloc
{
RELEASE(_attributedTitle);
RELEASE(_image);
RELEASE(_url);
[super dealloc];
}
@end