home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Palettes / MiscClipTextPalette / MiscClipText.subproj / MiscPathField.m < prev    next >
Encoding:
Text File  |  1995-07-12  |  2.3 KB  |  123 lines

  1. //
  2. //    MiscPathField.h -- a MiscClipTextField subclass for displaying long 
  3. //                       pathnames
  4. //        Written and Copyright (c) 1995 by Balazs Pataki. 
  5. //                Version 1.0.  All rights reserved.
  6. //
  7. //        This notice may not be removed from this source code.
  8. //
  9. //    This object is included in the MiscKit by permission from the author
  10. //    and its use is governed by the MiscKit license, found in the file
  11. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  12. //    for a list of all applicable permissions and restrictions.
  13. //    
  14.  
  15. #import <appkit/appkit.h>
  16. #import    <misckit/MiscString.h>
  17. #import <objc/objc-runtime.h>
  18. #import "MiscPathField.h"
  19. #import "MiscClipTextFieldCell.h"
  20.  
  21.  
  22. #define    CLASS_NAME        "MiscPathField"
  23. #define    CLASS_VERSION    1
  24.  
  25.  
  26.  
  27. /*
  28.                         ********************************
  29.                         *                              *
  30.                         *        MiscPathField         *
  31.                         *                              *
  32.                         ********************************
  33. */
  34.  
  35. @implementation MiscPathField
  36.  
  37. + initialize
  38. // Set class version
  39. {
  40.     if (self == objc_lookUpClass(CLASS_NAME))  {
  41.         [self setVersion:CLASS_VERSION];
  42.     }
  43.     return self;
  44. }
  45.  
  46. - initFrame:(const NXRect *)rect
  47. // Initializes a newly allocated MiscPathField for clipping its string value
  48. // using '/' (slash) as clipping delimiter and sets clipping to happen on the
  49. // left
  50. {
  51.     [super initFrame:rect];
  52.     
  53.     [self setClipDelimiters:"/"];
  54.     [self setClipOnRight:NO];
  55.     [[self cell] setDelegate:self];
  56.     shouldUseTilde = YES;    
  57.     
  58.     return self;
  59. }
  60.  
  61. - stringWillBeClipped:theString
  62. {
  63.     if ( shouldUseTilde )
  64.         [theString replaceHomeWithTilde];
  65.  
  66.     return self;
  67. }
  68.  
  69.  
  70. - setReplaceHomeWithTilde:(BOOL) flag
  71. // If flag is YES and the current string value is a user path, then replaces
  72. // the home part of the path with a '~' (tilde) 
  73. {
  74.     shouldUseTilde = flag;
  75.     //[self setStringValue:[self fullStringValue]];
  76.     
  77.     return self;
  78. }
  79.  
  80. - (BOOL)doesReplacesHomeWithTilde
  81. {
  82.     return shouldUseTilde;
  83. }
  84.  
  85. - write:(NXTypedStream *)stream
  86. {
  87.     [super write:stream];
  88.     
  89.     NXWriteType(stream, @encode(BOOL), &shouldUseTilde);
  90.    
  91.     return self;
  92. }
  93.  
  94.  
  95. - read:(NXTypedStream *)stream
  96. {
  97.     [super read:stream];
  98.    
  99.     NXReadType(stream, @encode(BOOL), &shouldUseTilde);
  100.  
  101.     return self;
  102. }
  103.  
  104. - awake
  105. {
  106.     [[self cell] setDelegate:self];
  107.     return self;
  108. }
  109.  
  110.  
  111. @end
  112.  
  113.  
  114.  
  115. @implementation MiscPathField(IBStuff)
  116.  
  117. - (const char *)getInspectorClassName
  118. {
  119.     return "MiscPathFieldInspector";
  120. }
  121.  
  122. @end
  123.