allow messages to take multiple rows in message

This commit is contained in:
Mitchell Livingston 2007-10-28 03:10:11 +00:00
parent 69df8105a7
commit cbffc0589f
6 changed files with 115 additions and 23 deletions

View File

@ -1,18 +1,69 @@
{
IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{
ACTIONS = {changeLevel = id; clearLog = id; writeToFile = id; };
CLASS = MessageWindowController;
LANGUAGE = ObjC;
OUTLETS = {
fDebugWarningField = NSTextField;
fDebugWarningIcon = NSImageView;
fLevelButton = NSPopUpButton;
fMessageTable = NSTableView;
};
SUPERCLASS = NSWindowController;
}
);
IBVersion = 1;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBClasses</key>
<array>
<dict>
<key>CLASS</key>
<string>NSApplication</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSResponder</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSMenu</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>FirstResponder</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSObject</string>
<key>LANGUAGE</key>
<string>ObjC</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>changeLevel</key>
<string>id</string>
<key>clearLog</key>
<string>id</string>
<key>writeToFile</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>MessageWindowController</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>fDebugWarningField</key>
<string>NSTextField</string>
<key>fDebugWarningIcon</key>
<string>NSImageView</string>
<key>fLevelButton</key>
<string>NSPopUpButton</string>
<key>fMessageTable</key>
<string>NSTableView</string>
</dict>
<key>SUPERCLASS</key>
<string>NSWindowController</string>
</dict>
</array>
<key>IBVersion</key>
<string>1</string>
</dict>
</plist>

View File

@ -1,16 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>42 94 356 240 0 0 1680 1028 </string>
<key>IBFramework Version</key>
<string>446.1</string>
<string>629</string>
<key>IBLastKnownRelativeProjectPath</key>
<string>../../../Transmission.xcodeproj</string>
<key>IBOldestOS</key>
<integer>5</integer>
<key>IBOpenObjects</key>
<array>
<integer>5</integer>
</array>
<key>IBSystem Version</key>
<string>8R4031</string>
<string>9A581</string>
<key>targetFramework</key>
<string>IBCocoaFramework</string>
</dict>
</plist>

View File

@ -32,6 +32,8 @@
NSMutableArray * fMessages;
NSDictionary * fAttributes;
NSTimer * fTimer;
NSImage * fErrorImage, * fInfoImage, * fDebugImage;

View File

@ -34,6 +34,7 @@
@interface MessageWindowController (Private)
- (void) resizeColumn;
- (NSString *) stringForMessage: (NSDictionary *) message;
- (void) setDebugWarningHidden: (BOOL) hide;
@ -61,6 +62,8 @@
[fTimer invalidate];
[fMessages release];
[fAttributes release];
[super dealloc];
}
@ -70,6 +73,9 @@
[window setFrameAutosaveName: @"MessageWindowFrame"];
[window setFrameUsingName: @"MessageWindowFrame"];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(resizeColumn)
name: @"NSTableViewColumnDidResizeNotification" object: fMessageTable];
//initially sort peer table by IP
if ([[fMessageTable sortDescriptors] count] == 0)
{
@ -128,6 +134,8 @@
[descriptors release];
[fMessages removeObjectsInRange: NSMakeRange(0, total-MAX_MESSAGES)];
[fMessageTable noteHeightOfRowsWithIndexesChanged: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, MAX_MESSAGES)]];
}
[fMessages sortUsingDescriptors: [fMessageTable sortDescriptors]];
@ -165,6 +173,26 @@
return [message objectForKey: @"Message"];
}
- (float) tableView: (NSTableView *) tableView heightOfRow: (int) row
{
NSTableColumn * column = [tableView tableColumnWithIdentifier: @"Message"];
int count = 0;
float width = [column width];
if (width > 0)
{
if (!fAttributes)
fAttributes = [[[[column dataCell] attributedStringValue] attributesAtIndex: 0 effectiveRange: NULL] retain];
NSAttributedString * string = [[NSAttributedString alloc] initWithString: [[fMessages objectAtIndex: row]
objectForKey: @"Message"] attributes: fAttributes];
count = [string size].width / width;
[string release];
}
return [tableView rowHeight] * (float)(count+1);
}
- (NSString *) tableView: (NSTableView *) tableView toolTipForCell: (NSCell *) cell rect: (NSRectPointer) rect
tableColumn: (NSTableColumn *) column row: (int) row mouseLocation: (NSPoint) mouseLocation
{
@ -286,6 +314,12 @@
@implementation MessageWindowController (Private)
- (void) resizeColumn
{
[fMessageTable noteHeightOfRowsWithIndexesChanged: [NSIndexSet indexSetWithIndexesInRange:
NSMakeRange(0, [fMessageTable numberOfRows])]];
}
- (NSString *) stringForMessage: (NSDictionary *) message
{
NSString * level;

View File

@ -26,6 +26,7 @@
@implementation PeerProgressIndicatorCell
#warning exists in 10.5
- (BOOL) hidden
{
return fIsHidden;