Adding the ITMultilineTextFieldCell work I've done so far...
authorJoseph Spiros <joseph.spiros@ithinksw.com>
Sat, 6 Mar 2004 07:03:45 +0000 (07:03 +0000)
committerJoseph Spiros <joseph.spiros@ithinksw.com>
Sat, 6 Mar 2004 07:03:45 +0000 (07:03 +0000)
ITKit.xcode/project.pbxproj
ITMultilineTextFieldCell.h [new file with mode: 0755]
ITMultilineTextFieldCell.m [new file with mode: 0755]
Showcase/Controller.h
Showcase/Controller.m
Showcase/English.lproj/MainMenu.nib/classes.nib
Showcase/English.lproj/MainMenu.nib/info.nib
Showcase/English.lproj/MainMenu.nib/keyedobjects.nib

index 422bfdf..7beefb5 100755 (executable)
                        refType = 4;
                        sourceTree = "<group>";
                };
+               7C4BBADA05F98C9900734027 = {
+                       fileEncoding = 4;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
+                       path = ITMultilineTextFieldCell.h;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               7C4BBADB05F98C9900734027 = {
+                       fileEncoding = 4;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.objc;
+                       path = ITMultilineTextFieldCell.m;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               7C4BBADC05F98C9900734027 = {
+                       fileRef = 7C4BBADA05F98C9900734027;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
+               7C4BBADD05F98C9900734027 = {
+                       fileRef = 7C4BBADB05F98C9900734027;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
                7C5B7C93054F6EC9008379B6 = {
                        fileRef = 8DC2EF5B0486A6940098B216;
                        isa = PBXBuildFile;
                                7C992DF8054F5179000B93EA,
                                2AC8319B056D037700A7D7E2,
                                2AC8319C056D037700A7D7E2,
+                               7C4BBADA05F98C9900734027,
+                               7C4BBADB05F98C9900734027,
                        );
                        isa = PBXGroup;
                        name = Cells;
                                2AC83141056D00F700A7D7E2,
                                2AC8319D056D037700A7D7E2,
                                3710912805C0825900ED0F36,
+                               7C4BBADC05F98C9900734027,
                        );
                        isa = PBXHeadersBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
                                2AC83142056D00F700A7D7E2,
                                2AC8319E056D037700A7D7E2,
                                3710912305C0821000ED0F36,
+                               7C4BBADD05F98C9900734027,
                        );
                        isa = PBXSourcesBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
diff --git a/ITMultilineTextFieldCell.h b/ITMultilineTextFieldCell.h
new file mode 100755 (executable)
index 0000000..59ca9c0
--- /dev/null
@@ -0,0 +1,15 @@
+//
+//  ITMultilineTextFieldCell.h
+//  ITKit
+//
+//  Created by Joseph Spiros on Fri Mar 05 2004.
+//  Copyright (c) 2004 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface ITMultilineTextFieldCell : NSCell {
+}
+
+@end
diff --git a/ITMultilineTextFieldCell.m b/ITMultilineTextFieldCell.m
new file mode 100755 (executable)
index 0000000..74b4749
--- /dev/null
@@ -0,0 +1,108 @@
+//
+//  ITMultilineTextFieldCell.m
+//  ITKit
+//
+//  Created by Joseph Spiros on Fri Mar 05 2004.
+//  Copyright (c) 2004 __MyCompanyName__. All rights reserved.
+//
+
+#import "ITMultilineTextFieldCell.h"
+
+
+@implementation ITMultilineTextFieldCell
+
+- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
+{
+    /*
+        Okay, here's the different possibilities for the objectValue of this cell, and how they're displayed:
+        
+            NSArray of NSStrings - Draw first line with System Font, following lines with Small System Font
+            NSArray of NSAttributedStrings - Draw as given
+            NSArray of both - Draw each line as above!
+        
+        The number of lines is determined by the contents of the array...
+    */
+    
+    NSColor *defaultColor;
+    NSMutableParagraphStyle *paragraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
+    [paragraphStyle setLineBreakMode:NSLineBreakByTruncatingTail];
+    NSPoint cellPoint = cellFrame.origin;
+    NSSize cellSize = cellFrame.size;
+    
+    NSRect secondaryLineRect;
+    
+    if ([self isHighlighted] && ([self highlightColorWithFrame:cellFrame inView:controlView]!=[NSColor secondarySelectedControlColor])) {
+        defaultColor = [NSColor whiteColor];
+    } else {
+        defaultColor = [NSColor blackColor];
+    }
+    
+    // Process the first line...
+    {
+        NSDictionary *firstLineAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont boldSystemFontOfSize:[NSFont systemFontSize]], NSFontAttributeName, defaultColor, NSForegroundColorAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil];
+        
+        NSRect firstLineRect = NSMakeRect(cellPoint.x+5, cellPoint.y+1, cellSize.width-5, cellSize.height);
+        
+        id firstString = [[self objectValue] objectAtIndex:0];
+        NSMutableAttributedString *firstAttrString;
+        
+        if ([firstString isKindOfClass:[NSAttributedString class]]) {
+            firstAttrString = [[[NSMutableAttributedString alloc] initWithAttributedString:firstString] autorelease];
+            [firstAttrString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0,[firstAttrString length])];
+            if ([defaultColor isEqual:[NSColor whiteColor]]) {
+            [firstAttrString addAttribute:NSForegroundColorAttributeName value:defaultColor range:NSMakeRange(0,[firstAttrString length])];
+            }
+        } else if ([firstString isKindOfClass:[NSString class]]) {
+            firstAttrString = [[[NSMutableAttributedString alloc] initWithString:firstString attributes:firstLineAttributes] autorelease];
+        } else {
+            firstAttrString = [[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"Object (%@) is not a string", firstString] attributes:firstLineAttributes] autorelease];
+        }
+        
+        [controlView lockFocus];
+        
+        [firstAttrString drawInRect:firstLineRect];
+        
+        [controlView unlockFocus];
+        
+        secondaryLineRect = NSMakeRect(cellPoint.x+5, (cellPoint.y+1+[firstAttrString size].height), cellSize.width-5, cellSize.height);
+    }
+    
+    // Process the secondary lines
+    {
+        NSDictionary *secondaryLineAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]], NSFontAttributeName, defaultColor, NSForegroundColorAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil];
+        
+        NSMutableArray *tMArray = [NSMutableArray arrayWithArray:[self objectValue]];
+        [tMArray removeObjectAtIndex:0]; // Remove the first line string... already handled that above!
+        
+        NSEnumerator *enumerator = [tMArray objectEnumerator];
+        id secondaryString;
+        
+        while (secondaryString = [enumerator nextObject]) {
+            
+            NSMutableAttributedString *secondaryAttrString;
+            
+            if ([secondaryString isKindOfClass:[NSAttributedString class]]) {
+                secondaryAttrString = [[[NSMutableAttributedString alloc] initWithAttributedString:secondaryString] autorelease];
+                [secondaryAttrString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0,[secondaryAttrString length])];
+                if ([defaultColor isEqual:[NSColor whiteColor]]) {
+                [secondaryAttrString addAttribute:NSForegroundColorAttributeName value:defaultColor range:NSMakeRange(0,[secondaryAttrString length])];
+                }
+            } else if ([secondaryString isKindOfClass:[NSString class]]) {
+                secondaryAttrString = [[[NSMutableAttributedString alloc] initWithString:secondaryString attributes:secondaryLineAttributes] autorelease];
+            } else {
+                secondaryAttrString = [[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"Object (%@) is not a string", secondaryString] attributes:secondaryLineAttributes] autorelease];
+            }
+            
+            [controlView lockFocus];
+            
+            [secondaryAttrString drawInRect:secondaryLineRect];
+            
+            [controlView unlockFocus];
+            
+            secondaryLineRect.origin.y = secondaryLineRect.origin.y+[secondaryAttrString size].height; // modify the rect for the next loop, based on the size and location of the most recently processed line.
+        
+        }
+    }
+}
+
+@end
index 18ea801..399b3c9 100755 (executable)
@@ -35,6 +35,9 @@
     IBOutlet NSTextField        *swShadowSaturation;
     IBOutlet NSSlider           *swEntrySpeedSlider;
     IBOutlet NSSlider           *swExitSpeedSlider;
+    
+    // ITMultilineTextFieldCell Support
+    IBOutlet NSTableView        *tableView;
 }
 
 // ITStatusItem Support
index 49e9e35..ba9c278 100755 (executable)
@@ -9,6 +9,7 @@
 #import "ITSlideHorizontallyWindowEffect.h"
 #import "ITSlideVerticallyWindowEffect.h"
 #import "ITPivotWindowEffect.h"
+#import "ITMultilineTextFieldCell.h"
 
 
 #define SW_PAD    24.0
     [[statusWindow exitEffect]  setEffectTime:[swExitSpeedSlider floatValue]];
 //  [tabView setAllowsDragging:YES];
     [[NSColorPanel sharedColorPanel] setShowsAlpha:YES];
+    
+    [tableView setRowHeight:200];
+    [[tableView tableColumnWithIdentifier:@"custom"] setDataCell:[[[ITMultilineTextFieldCell alloc] init] autorelease]];
+    [[tableView tableColumnWithIdentifier:@"image"] setDataCell:[[[NSImageCell alloc] init] autorelease]];
 }
 
 /*************************************************************************/
     [[note object] setMiniwindowImage:[NSImage imageNamed:@"ITStatusItem"]];
 }
 
+/*************************************************************************/
+#pragma mark -
+#pragma mark ITMultilineTextFieldCell SUPPORT
+/*************************************************************************/
+
+- (int)numberOfRowsInTableView:(NSTableView *)aTableView {
+    return 50;
+}
+
+- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex {
+    if ([[aTableColumn dataCell] isKindOfClass:[ITMultilineTextFieldCell class]]) {
+        if (rowIndex%2) {
+            return [NSArray arrayWithObjects:@"Foo", @"Bar", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", nil];
+        } else {
+            return [NSArray arrayWithObjects:[[[NSAttributedString alloc] initWithString:@"This is a demo of ITMultilineTextFieldCell" attributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSFont fontWithName:@"Gill Sans" size:48], NSFontAttributeName, [NSColor purpleColor], NSForegroundColorAttributeName, nil]] autorelease], [[[NSAttributedString alloc] initWithString:@"Bar" attributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSFont fontWithName:@"Gadget" size:20], NSFontAttributeName, nil]] autorelease], [[[NSObject alloc] init] autorelease], nil];
+        }
+    } else if ([[aTableColumn dataCell] isKindOfClass:[NSImageCell class]]) {
+        return [NSImage imageNamed:@"NSApplicationIcon"];
+    } else {
+        return @"I like cheese";
+    }
+}
+
 
 @end
index a9358a8..512782e 100755 (executable)
@@ -35,6 +35,7 @@
                 swVanishDelay = NSTextField; 
                 swVanishModePopup = NSPopUpButton; 
                 tabView = ITTabView; 
+                tableView = NSTableView; 
                 testTextField = ITTextField; 
                 useInvertedCheckBox = NSButton; 
                 window = NSWindow; 
index 42842c4..03db0ad 100755 (executable)
@@ -7,7 +7,7 @@
        <key>IBEditorPositions</key>
        <dict>
                <key>197</key>
-               <string>564 424 153 118 0 0 1056 770 </string>
+               <string>624 471 153 118 0 0 1152 842 </string>
                <key>29</key>
                <string>1 271 349 44 0 0 1056 770 </string>
        </dict>
        <string>349.0</string>
        <key>IBOpenObjects</key>
        <array>
+               <integer>21</integer>
                <integer>197</integer>
        </array>
        <key>IBSystem Version</key>
-       <string>7C107</string>
+       <string>7D24</string>
 </dict>
 </plist>
index 240f29a..a0b1e18 100755 (executable)
Binary files a/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib and b/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib differ