libs-gui/Source/NSPathControl.m

211 lines
4.3 KiB
Mathematica
Raw Normal View History

2020-04-23 04:43:15 +00:00
/* 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 "AppKit/NSPathControl.h"
2020-04-27 03:42:44 +00:00
#import "AppKit/NSPathCell.h"
2020-04-27 18:37:22 +00:00
#import "AppKit/NSGraphics.h"
2020-04-23 04:43:15 +00:00
@implementation NSPathControl
2020-04-27 03:42:44 +00:00
+ (void) initialize
{
if (self == [NSPathControl class])
{
[self setVersion: 1.0];
[self setCellClass: [NSPathCell class]];
}
}
- (void) setPathStyle: (NSPathStyle)style
{
2020-04-27 09:34:02 +00:00
[_cell setPathStyle: style];
2020-04-27 18:37:22 +00:00
[self setNeedsDisplay];
}
- (NSPathStyle) pathStyle
{
2020-04-27 09:34:02 +00:00
return [_cell pathStyle];
}
- (NSPathComponentCell *) clickedPathComponentCell
{
2020-04-27 09:34:02 +00:00
return [_cell clickedPathComponentCell];
}
- (NSArray *) pathComponentCells
{
2020-04-27 09:34:02 +00:00
return [_cell pathComponentCells];
}
- (void) setPathComponentCells: (NSArray *)cells
{
2020-04-27 09:34:02 +00:00
[_cell setPathComponentCells: cells];
2020-04-27 18:37:22 +00:00
[self setNeedsDisplay];
}
- (SEL) doubleAction;
{
2020-04-27 09:34:02 +00:00
return [_cell doubleAction];
}
- (void) setDoubleAction: (SEL)doubleAction
{
2020-04-27 09:34:02 +00:00
[_cell setDoubleAction: doubleAction];
}
- (NSURL *) URL
{
2020-04-27 09:34:02 +00:00
return [_cell URL];
}
- (void) setURL: (NSURL *)url
{
2020-04-27 09:34:02 +00:00
[_cell setURL: url];
2020-04-27 18:37:22 +00:00
[self setNeedsDisplay];
}
- (id<NSPathControlDelegate>) delegate
{
return _delegate;
}
- (void) setDelegate: (id<NSPathControlDelegate>) delegate
{
_delegate = delegate;
}
- (void) setDraggingSourceOperationMask: (NSDragOperation)mask
forLocal: (BOOL)local
{
}
- (NSMenu *) menu
{
return [super menu];
}
- (void) setMenu: (NSMenu *)menu
{
[super setMenu: menu];
}
- (NSArray *) allowedTypes;
{
2020-04-27 09:34:02 +00:00
return [_cell allowedTypes];
}
- (void) setAllowedTypes: (NSArray *)allowedTypes
{
2020-04-27 09:34:02 +00:00
[_cell setAllowedTypes: allowedTypes];
}
- (NSPathControlItem *) clickedPathItem
{
return nil;
}
- (NSArray *) pathItems
{
return _pathItems;
}
- (void) setPathItems: (NSArray *)items
{
ASSIGNCOPY(_pathItems, items);
}
- (NSAttributedString *) placeholderAttributedString
{
2020-04-27 09:34:02 +00:00
return [_cell placeholderAttributedString];
}
- (void) setPlaceholderAttributedString: (NSAttributedString *)string
{
2020-04-27 09:34:02 +00:00
[_cell setPlaceholderAttributedString: string];
2020-04-27 18:37:22 +00:00
[self setNeedsDisplay];
}
- (NSString *) placeholderString
{
2020-04-27 09:34:02 +00:00
return [_cell placeholderString];
}
- (void) setPlaceholderString: (NSString *)string
{
2020-04-27 09:34:02 +00:00
[_cell setPlaceholderString: string];
2020-04-27 18:37:22 +00:00
[self setNeedsDisplay];
}
- (NSColor *) backgroundColor
{
return _backgroundColor;
}
- (void) setBackgroundColor: (NSColor *)color
{
ASSIGN(_backgroundColor, color);
[self setNeedsDisplay];
}
- (void) drawRect: (NSRect)frame
{
[super drawRect: frame];
[_backgroundColor set];
NSRectFill(frame);
}
- (instancetype) initWithCoder: (NSKeyedUnarchiver *)coder
{
self = [super initWithCoder: coder];
if (self != nil)
{
if ([coder allowsKeyedCoding])
{
2020-04-28 15:59:38 +00:00
[self setBackgroundColor: [NSColor windowBackgroundColor]];
[self setPathStyle: NSPathStyleStandard];
2020-04-27 18:37:22 +00:00
if ([coder containsValueForKey: @"NSPathComponentCells"])
{
[self setPathComponentCells: [coder decodeObjectForKey: @"NSPathComponentCells"]];
}
if ([coder containsValueForKey: @"NSPathStyle"])
{
[self setPathStyle: [coder decodeIntegerForKey: @"NSPathStyle"]];
}
if ([coder containsValueForKey: @"NSBackgroundColor"])
{
[self setBackgroundColor: [coder decodeObjectForKey: @"NSBackgroundColor"]];
}
}
else
{
}
}
return self;
}
2020-04-23 04:43:15 +00:00
@end