Skip to content

Commit

Permalink
Change to use view based NSTableView's
Browse files Browse the repository at this point in the history
  • Loading branch information
benbaker76 committed Mar 1, 2020
1 parent 3be9e12 commit 53f22c2
Show file tree
Hide file tree
Showing 6 changed files with 699 additions and 173 deletions.
20 changes: 10 additions & 10 deletions PinConfigurator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
E25A0CFA22158DF600057B76 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = E25A0CF822158DF600057B76 /* Credits.rtf */; };
E28353B1220C835300454571 /* AudioNode.m in Sources */ = {isa = PBXBuildFile; fileRef = E28353B0220C835300454571 /* AudioNode.m */; };
E28353B5220C877D00454571 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E28353B4220C877D00454571 /* AppKit.framework */; };
E28353B8220C88C100454571 /* NSPinCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E28353B7220C88C100454571 /* NSPinCell.m */; };
E28353BB220C9CDB00454571 /* NSString+Pin.m in Sources */ = {isa = PBXBuildFile; fileRef = E28353BA220C9CDB00454571 /* NSString+Pin.m */; };
E28353C1220CAB2100454571 /* NSColor+Pin.m in Sources */ = {isa = PBXBuildFile; fileRef = E28353C0220CAB2100454571 /* NSColor+Pin.m */; };
E28B558B22130052004FCE24 /* Audio in Resources */ = {isa = PBXBuildFile; fileRef = E28B558A22130052004FCE24 /* Audio */; };
E2AEBFD9220CE9780037EA73 /* MiscTools.m in Sources */ = {isa = PBXBuildFile; fileRef = E2AEBFD8220CE9780037EA73 /* MiscTools.m */; };
E2B22A73221870C5003FC976 /* HdaCodec.m in Sources */ = {isa = PBXBuildFile; fileRef = E2B22A72221870C5003FC976 /* HdaCodec.m */; };
E2B848E0240B30AD00CD051F /* NSPinCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = E2B848DE240B30AD00CD051F /* NSPinCellView.m */; };
E2D61C6A22872E9D004A059A /* HdaCodecDump.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D61C6822872E9D004A059A /* HdaCodecDump.m */; };
/* End PBXBuildFile section */

Expand All @@ -42,8 +42,6 @@
E28353B0220C835300454571 /* AudioNode.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = AudioNode.m; sourceTree = "<group>"; };
E28353B2220C836700454571 /* AudioNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AudioNode.h; sourceTree = "<group>"; };
E28353B4220C877D00454571 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
E28353B6220C88C100454571 /* NSPinCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSPinCell.h; sourceTree = "<group>"; };
E28353B7220C88C100454571 /* NSPinCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSPinCell.m; sourceTree = "<group>"; };
E28353B9220C9CDB00454571 /* NSString+Pin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSString+Pin.h"; sourceTree = "<group>"; };
E28353BA220C9CDB00454571 /* NSString+Pin.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSString+Pin.m"; sourceTree = "<group>"; };
E28353BF220CAB2100454571 /* NSColor+Pin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSColor+Pin.h"; sourceTree = "<group>"; };
Expand All @@ -53,6 +51,8 @@
E2AEBFD8220CE9780037EA73 /* MiscTools.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = MiscTools.m; sourceTree = "<group>"; };
E2B22A72221870C5003FC976 /* HdaCodec.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = HdaCodec.m; sourceTree = "<group>"; };
E2B22A74221870D5003FC976 /* HdaCodec.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HdaCodec.h; sourceTree = "<group>"; };
E2B848DE240B30AD00CD051F /* NSPinCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSPinCellView.m; sourceTree = "<group>"; };
E2B848DF240B30AD00CD051F /* NSPinCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSPinCellView.h; sourceTree = "<group>"; };
E2D61C6822872E9D004A059A /* HdaCodecDump.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HdaCodecDump.m; sourceTree = "<group>"; };
E2D61C6922872E9D004A059A /* HdaCodecDump.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HdaCodecDump.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -112,8 +112,8 @@
E2AEBFD8220CE9780037EA73 /* MiscTools.m */,
E28353BF220CAB2100454571 /* NSColor+Pin.h */,
E28353C0220CAB2100454571 /* NSColor+Pin.m */,
E28353B6220C88C100454571 /* NSPinCell.h */,
E28353B7220C88C100454571 /* NSPinCell.m */,
E2B848DF240B30AD00CD051F /* NSPinCellView.h */,
E2B848DE240B30AD00CD051F /* NSPinCellView.m */,
E28353B9220C9CDB00454571 /* NSString+Pin.h */,
E28353BA220C9CDB00454571 /* NSString+Pin.m */,
);
Expand Down Expand Up @@ -212,11 +212,11 @@
E2275923220C77FB00377EF5 /* main.m in Sources */,
E2D61C6A22872E9D004A059A /* HdaCodecDump.m in Sources */,
E2B22A73221870C5003FC976 /* HdaCodec.m in Sources */,
E2B848E0240B30AD00CD051F /* NSPinCellView.m in Sources */,
E227591B220C77FA00377EF5 /* AppDelegate.m in Sources */,
E2AEBFD9220CE9780037EA73 /* MiscTools.m in Sources */,
E24E3F7B221352ED0079D7DB /* AudioDevice.m in Sources */,
E28353BB220C9CDB00454571 /* NSString+Pin.m in Sources */,
E28353B8220C88C100454571 /* NSPinCell.m in Sources */,
E28353B1220C835300454571 /* AudioNode.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -364,15 +364,15 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0221;
CURRENT_PROJECT_VERSION = 0222;
ENABLE_STRICT_OBJC_MSGSEND = NO;
INFOPLIST_FILE = PinConfigurator/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.8;
MARKETING_VERSION = 2.2.1;
MARKETING_VERSION = 2.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.Headsoft.PinConfigurator;
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand All @@ -388,15 +388,15 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0221;
CURRENT_PROJECT_VERSION = 0222;
ENABLE_STRICT_OBJC_MSGSEND = NO;
INFOPLIST_FILE = PinConfigurator/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.8;
MARKETING_VERSION = 2.2.1;
MARKETING_VERSION = 2.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.Headsoft.PinConfigurator;
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand Down
Binary file not shown.
76 changes: 41 additions & 35 deletions PinConfigurator/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import "AppDelegate.h"
#import "NSPinCell.h"
#import "NSPinCellView.h"
#import "NSString+Pin.h"
#import "AudioNode.h"
#import "AudioDevice.h"
Expand Down Expand Up @@ -76,9 +76,9 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
}

_nodeArray = [[NSMutableArray alloc] init];
NSPinCell *pinCell = [[[NSPinCell alloc] init] autorelease];
NSTableColumn *tableColumn = [_pinConfigOutlineView tableColumnWithIdentifier:@"1"];
[tableColumn setDataCell:pinCell];
//NSPinCellView *pinCellView = [[[NSPinCellView alloc] init] autorelease];
//NSTableColumn *tableColumn = [_pinConfigOutlineView tableColumnWithIdentifier:@"1"];
//[tableColumn setDataCell:pinCellView];
[_pinConfigOutlineView setDoubleAction:@selector(editNode:)];
[_pinConfigOutlineView setTarget:self];
[_portPopUpButton removeAllItems];
Expand Down Expand Up @@ -561,66 +561,70 @@ - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTabl
return 0;
}

- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
NSTableCellView *result = [outlineView makeViewWithIdentifier:tableColumn.identifier owner:self];

if (outlineView == _pinConfigOutlineView)
{
NSString *nid = [tableColumn identifier];

if ([nid intValue] == 1)
{
if (cell)
NSPinCellView *pinCellView = (NSPinCellView *)result;

if (pinCellView)
{
if (item)
[cell setItem:item isSelected:NO];
[pinCellView setItem:item isSelected:NO];
}
}
else
{
AudioNode *audioNode = item;
[cell setFont:[NSFont systemFontOfSize:12]];
[result.textField setFont:[NSFont systemFontOfSize:12]];

switch ([[tableColumn identifier] intValue])
{
case 2:
[cell setStringValue:audioNode.nodeString];
[cell setFont:[NSFont boldSystemFontOfSize:12]];
result.textField.stringValue = audioNode.nodeString;
[result.textField setFont:[NSFont boldSystemFontOfSize:12]];
break;
case 3:
[cell setStringValue:audioNode.pinDefaultString];
result.textField.stringValue = audioNode.pinDefaultString;
break;
case 4:
[cell setStringValue:audioNode.directionString];
result.textField.stringValue = audioNode.directionString;
break;
case 5:
[cell setStringValue:[NSString pinDefaultDevice:audioNode.device]];
result.textField.stringValue = [NSString pinDefaultDevice:audioNode.device];
break;
case 6:
[cell setStringValue:[NSString pinConnector:audioNode.connector]];
result.textField.stringValue = [NSString pinConnector:audioNode.connector];
break;
case 7:
[cell setStringValue:[NSString pinPort:audioNode.port]];
result.textField.stringValue = [NSString pinPort:audioNode.port];
break;
case 8:
[cell setStringValue:[NSString pinGrossLocation:audioNode.grossLocation]];
result.textField.stringValue = [NSString pinGrossLocation:audioNode.grossLocation];
break;
case 9:
[cell setStringValue:[NSString pinLocation:audioNode.grossLocation geometricLocation:audioNode.geometricLocation]];
result.textField.stringValue = [NSString pinLocation:audioNode.grossLocation geometricLocation:audioNode.geometricLocation];
break;
case 10:
[cell setStringValue:[NSString pinColor:[audioNode color]]];
result.textField.stringValue = [NSString pinColor:[audioNode color]];
break;
case 11:
[cell setIntValue:audioNode.group];
result.textField.intValue = audioNode.group;
break;
case 12:
[cell setIntValue:[audioNode index]];
result.textField.intValue = audioNode.index;
break;
case 13:
[cell setStringValue:audioNode.eapd & HDA_EAPD_BTL_ENABLE_EAPD ? [NSString stringWithFormat:@"0x%1X", audioNode.eapd] : @"-"];
result.textField.stringValue = (audioNode.eapd & HDA_EAPD_BTL_ENABLE_EAPD ? [NSString stringWithFormat:@"0x%1X", audioNode.eapd] : @"-");
break;
default:
return;
break;
}
}
}
Expand All @@ -631,26 +635,26 @@ - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTab
switch ([[tableColumn identifier] intValue])
{
case 0:
[cell setIntValue:(int)[_hdaConfigDefaultArray indexOfObject:hdaConfigDictionary]];
result.textField.intValue = (int)[_hdaConfigDefaultArray indexOfObject:hdaConfigDictionary];
break;
case 1:
[cell setStringValue:[NSString stringWithFormat:@"0x%08X", [[hdaConfigDictionary objectForKey:@"CodecID"] intValue]]];
result.textField.stringValue = [NSString stringWithFormat:@"0x%08X", [[hdaConfigDictionary objectForKey:@"CodecID"] intValue]];
break;
case 2:
[cell setIntValue:[[hdaConfigDictionary objectForKey:@"LayoutID"] intValue]];
result.textField.intValue = [[hdaConfigDictionary objectForKey:@"LayoutID"] intValue];
break;
case 3:
{
uint32_t codecID = [[hdaConfigDictionary objectForKey:@"CodecID"] intValue];
NSString *codecName;
[self getAudioCodecName:codecID revisionID:0 name:&codecName];
[cell setStringValue:codecName];
result.textField.stringValue = codecName;
break;
}
case 4:
{
NSString *codecName = [hdaConfigDictionary objectForKey:@"Codec"];
[cell setStringValue:codecName != nil ? codecName : @""];
result.textField.stringValue = (codecName != nil ? codecName : @"");
break;
}
}
Expand All @@ -663,31 +667,33 @@ - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTab
switch ([[tableColumn identifier] intValue])
{
case 0:
[cell setStringValue:[NSString stringWithFormat:@"0x%08X", audioDevice.deviceID]];
result.textField.stringValue = [NSString stringWithFormat:@"0x%08X", audioDevice.deviceID];
break;
case 1:
[cell setStringValue:[NSString stringWithFormat:@"0x%08X", audioDevice.revisionID]];
result.textField.stringValue = [NSString stringWithFormat:@"0x%08X", audioDevice.revisionID];
break;
case 2:
[cell setStringValue:(audioDevice.codecID != 0 ? [NSString stringWithFormat:@"%d", audioDevice.alcLayoutID] : @"-")];
result.textField.stringValue = (audioDevice.codecID != 0 ? [NSString stringWithFormat:@"%d", audioDevice.alcLayoutID] : @"-");
break;
case 3:
[cell setStringValue:[NSString stringWithFormat:@"0x%08X", audioDevice.subDeviceID]];
result.textField.stringValue = [NSString stringWithFormat:@"0x%08X", audioDevice.subDeviceID];
break;
case 4:
[cell setStringValue:[NSString stringWithFormat:@"0x%X", audioDevice.codecAddress]];
result.textField.stringValue = [NSString stringWithFormat:@"0x%X", audioDevice.codecAddress];
break;
case 5:
[cell setStringValue:(audioDevice.codecID != 0 ? [NSString stringWithFormat:@"0x%08X", audioDevice.codecID] : @"-")];
result.textField.stringValue = (audioDevice.codecID != 0 ? [NSString stringWithFormat:@"0x%08X", audioDevice.codecID] : @"-");
break;
case 6:
[cell setStringValue:(audioDevice.codecID != 0 ? [NSString stringWithFormat:@"0x%04X", audioDevice.codecRevisionID & 0xFFFF] : @"-")];
result.textField.stringValue = (audioDevice.codecID != 0 ? [NSString stringWithFormat:@"0x%04X", audioDevice.codecRevisionID & 0xFFFF] : @"-");
break;
case 7:
[cell setStringValue:(deviceName != nil ? deviceName : @"???")];
result.textField.stringValue = (deviceName != nil ? deviceName : @"???");
break;
}
}

return result;
}

- (void)outlineViewSelectionIsChanging:(NSNotification *)notification
Expand Down
Loading

0 comments on commit 53f22c2

Please sign in to comment.