ftp.nice.ch/pub/next/developer/resources/classes/misckit/MiscKit.1.10.0.s.gnutar.gz#/MiscKit/Palettes/MiscClipTextPalette/MiscClipText.subproj/MiscPathField.m

This is MiscPathField.m in view mode; [Download] [Up]

//
//	MiscPathField.h -- a MiscClipTextField subclass for displaying long 
//					   pathnames
//		Written and Copyright (c) 1995 by Balazs Pataki. 
//				Version 1.0.  All rights reserved.
//
//		This notice may not be removed from this source code.
//
//	This object is included in the MiscKit by permission from the author
//	and its use is governed by the MiscKit license, found in the file
//	"LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
//	for a list of all applicable permissions and restrictions.
//	

#import <appkit/appkit.h>
#import	<misckit/MiscString.h>
#import <objc/objc-runtime.h>
#import "MiscPathField.h"
#import "MiscClipTextFieldCell.h"


#define	CLASS_NAME		"MiscPathField"
#define	CLASS_VERSION	1



/*
						********************************
						*                              *
						*        MiscPathField         *
						*                              *
						********************************
*/

@implementation MiscPathField

+ initialize
// Set class version
{
	if (self == objc_lookUpClass(CLASS_NAME))  {
		[self setVersion:CLASS_VERSION];
	}
	return self;
}

- initFrame:(const NXRect *)rect
// Initializes a newly allocated MiscPathField for clipping its string value
// using '/' (slash) as clipping delimiter and sets clipping to happen on the
// left
{
	[super initFrame:rect];
	
	[self setClipDelimiters:"/"];
	[self setClipOnRight:NO];
	[[self cell] setDelegate:self];
	shouldUseTilde = YES;	
	
	return self;
}

- stringWillBeClipped:theString
{
	if ( shouldUseTilde )
		[theString replaceHomeWithTilde];

	return self;
}


- setReplaceHomeWithTilde:(BOOL) flag
// If flag is YES and the current string value is a user path, then replaces
// the home part of the path with a '~' (tilde) 
{
	shouldUseTilde = flag;
	//[self setStringValue:[self fullStringValue]];
	
	return self;
}

- (BOOL)doesReplacesHomeWithTilde
{
	return shouldUseTilde;
}

- write:(NXTypedStream *)stream
{
    [super write:stream];
    
    NXWriteType(stream, @encode(BOOL), &shouldUseTilde);
   
    return self;
}


- read:(NXTypedStream *)stream
{
    [super read:stream];
   
	NXReadType(stream, @encode(BOOL), &shouldUseTilde);

	return self;
}

- awake
{
	[[self cell] setDelegate:self];
	return self;
}


@end



@implementation MiscPathField(IBStuff)

- (const char *)getInspectorClassName
{
	return "MiscPathFieldInspector";
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.