Skip to content

Commit

Permalink
ADDED SOME ICONS TO THE FILTER BAR. WHAT A PRODUCTIVE DAY!
Browse files Browse the repository at this point in the history
  • Loading branch information
atg committed Apr 15, 2010
1 parent 6a22a46 commit 3c5d3b9
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 34 deletions.
30 changes: 20 additions & 10 deletions CHDocumentationBrowser.xib
Expand Up @@ -23,13 +23,13 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="189"/>
<integer value="716"/>
<integer value="590"/>
<integer value="765"/>
<integer value="63"/>
<integer value="743"/>
<integer value="232"/>
<integer value="590"/>
<integer value="189"/>
<integer value="370"/>
<integer value="19"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -3316,6 +3316,7 @@
<string key="NSContents">Text Cell</string>
<reference key="NSSupport" ref="369575145"/>
<reference key="NSControlView" ref="342947104"/>
<int key="NSTag">-2</int>
<reference key="NSBackgroundColor" ref="936577122"/>
<reference key="NSTextColor" ref="923575253"/>
</object>
Expand Down Expand Up @@ -5722,9 +5723,11 @@ ZQCUhAEqhIQLe0NHU2l6ZT1kZH2aAIOQAAAAAAAAAIaGA</bytes>
<string>759.IBPluginDependency</string>
<string>760.IBPluginDependency</string>
<string>761.IBPluginDependency</string>
<string>762.CustomClassName</string>
<string>762.IBPluginDependency</string>
<string>764.IBPluginDependency</string>
<string>765.IBPluginDependency</string>
<string>766.CustomClassName</string>
<string>766.IBPluginDependency</string>
<string>768.IBPluginDependency</string>
<string>83.IBEditorWindowLastContentRect</string>
Expand Down Expand Up @@ -5758,7 +5761,7 @@ ZQCUhAEqhIQLe0NHU2l6ZT1kZH2aAIOQAAAAAAAAAIaGA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>IGKEaseInOutAnimatedView</string>
<string>{{310, 394}, {756, 602}}</string>
<string>{{261, 394}, {756, 602}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{593, 365}, {247, 404}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand Down Expand Up @@ -5796,7 +5799,7 @@ ZQCUhAEqhIQLe0NHU2l6ZT1kZH2aAIOQAAAAAAAAAIaGA</bytes>
<integer value="0"/>
<string>{{458, 388}, {166, 60}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{236, 156}, {830, 530}}</string>
<string>{{187, 156}, {830, 530}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand All @@ -5809,7 +5812,7 @@ ZQCUhAEqhIQLe0NHU2l6ZT1kZH2aAIOQAAAAAAAAAIaGA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.brandonwalkin.BWToolkit</string>
<string>{{418, 390}, {635, 466}}</string>
<string>{{382, 390}, {635, 466}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.brandonwalkin.BWToolkit</string>
<string>com.brandonwalkin.BWToolkit</string>
Expand Down Expand Up @@ -5849,7 +5852,7 @@ ZQCUhAEqhIQLe0NHU2l6ZT1kZH2aAIOQAAAAAAAAAIaGA</bytes>
<reference ref="239672116"/>
<real value="0.0"/>
<real value="0.0"/>
<string>{{824, 452}, {247, 404}}</string>
<string>{{770, 452}, {247, 404}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{1072, 597}, {93, 22}}</string>
<string>{{1119, 170}, {187, 242}}</string>
Expand Down Expand Up @@ -5904,12 +5907,14 @@ ZQCUhAEqhIQLe0NHU2l6ZT1kZH2aAIOQAAAAAAAAAIaGA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>IGKShyTableView</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>IGKSometimesCenteredTextCell2</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{431, 51}, {635, 466}}</string>
<string>{{382, 51}, {635, 466}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.brandonwalkin.BWToolkit</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand Down Expand Up @@ -6075,11 +6080,16 @@ ZQCUhAEqhIQLe0NHU2l6ZT1kZH2aAIOQAAAAAAAAAIaGA</bytes>
<object class="IBPartialClassDescription">
<string key="className">IGKSometimesCenteredTextCell</string>
<string key="superclassName">NSTextFieldCell</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<object class="IBClassDescriptionSource" key="sourceIdentifier" id="519005926">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">IGKSometimesCenteredTextCell.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">IGKSometimesCenteredTextCell2</string>
<string key="superclassName">NSTextFieldCell</string>
<reference key="sourceIdentifier" ref="519005926"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">IGKTableOfContentsView</string>
<string key="superclassName">IGKEaseInOutAnimatedView</string>
Expand Down
3 changes: 3 additions & 0 deletions IGKDocRecordManagedObject.h
Expand Up @@ -9,6 +9,7 @@
#import <Cocoa/Cocoa.h>
#import "IGKHTMLGenerator.h"
#import "IGKManagedObject.h"
#import "CHSymbolButtonImage.h"

//Priorities of different objects when sorting the list in case of a tiebreak. From lowest priority to highest
typedef enum {
Expand Down Expand Up @@ -42,4 +43,6 @@ typedef enum {
- (NSString *)xcontainername;
- (IGKDocRecordManagedObject *)xcontainer;

+ (CHSymbolButtonImageMask)iconMaskForEntity:(NSString *)entityName isInstanceMethod:(BOOL)instanceMethod;

@end
10 changes: 6 additions & 4 deletions IGKDocRecordManagedObject.m
Expand Up @@ -8,7 +8,6 @@

#import "IGKDocRecordManagedObject.h"
#import "IGKDocSetManagedObject.h"
#import "CHSymbolButtonImage.h"

@interface IGKDocRecordManagedObject ()

Expand Down Expand Up @@ -445,11 +444,14 @@ - (NSImage *)selectedIcon
}

- (CHSymbolButtonImageMask)iconMask
{
NSString *entityName = [[self entity] name];
return [[self class] iconMaskForEntity:entityName isInstanceMethod:[[self valueForSoftKey:@"isInstanceMethod"] boolValue]];
}
+ (CHSymbolButtonImageMask)iconMaskForEntity:(NSString *)entityName isInstanceMethod:(BOOL)instanceMethod
{
//FIXME: Maybe it would be better to use an NSDictionary -> NSNumber here instead

NSString *entityName = [[self entity] name];

if([entityName isEqual:@"ObjCClass"])
return CHSymbolButtonObjcClass;

Expand All @@ -461,7 +463,7 @@ - (CHSymbolButtonImageMask)iconMask

else if([entityName isEqual:@"ObjCMethod"])
{
if ([[self valueForKey:@"isInstanceMethod"] boolValue])
if (instanceMethod)
return CHSymbolButtonObjcMethod;
else
return CHSymbolButtonObjcMethod | CHSymbolButtonStaticScope;
Expand Down
2 changes: 2 additions & 0 deletions IGKHTMLGenerator.h
Expand Up @@ -63,6 +63,8 @@ BOOL IGKHTMLDisplayTypeMaskIsSingle(IGKHTMLDisplayTypeMask mask);
- (NSString *)html;

+ (BOOL)containsInDocument:(IGKDocRecordManagedObject *)mo transientObject:(NSManagedObject *)_transientObject displayTypeMask:(IGKHTMLDisplayTypeMask)_displayTypeMask containerName:(NSString *)containerName itemName:(NSString *)itemName ingrcode:(NSString *)ingrcode;
+ (NSString *)extractApplecodeFromHref:(NSString *)href itemName:(NSString **)itemName;
+ (NSString *)applecodeToIngrcode:(NSString *)applecode itemName:(NSString *)itemName;

- (id)transientObject;

Expand Down
65 changes: 48 additions & 17 deletions IGKHTMLGenerator.m
Expand Up @@ -259,39 +259,34 @@ + (BOOL)containsInDocument:(IGKDocRecordManagedObject *)mo transientObject:(NSMa

return containsInDocument;
}
+ (NSString *)hrefToActualFragment:(IGKDocRecordManagedObject *)mo transientObject:(NSManagedObject *)_transientObject displayTypeMask:(IGKHTMLDisplayTypeMask)_displayTypeMask
+ (NSString *)extractApplecodeFromHref:(NSString *)href itemName:(NSString **)itemName
{
NSString *href = [mo valueForKey:@"href"];

// NSString.html#//apple_ref/occ/instm/NSString/stringByAppendingPathComponent:
// We need to grab
// the type (cl, instm, etc)
// the container (NSString)
// the item (stringByAppendingPathComponent:)

NSString *regex = @"//apple_ref/(occ|c)/([^/]+)/([^/]+)(/([^/]+))?";
NSArray *captures = [href captureComponentsMatchedByRegex:regex];
if ([captures count] < 4)
return nil;

NSString *applecode = [captures objectAtIndex:2];
NSString *n = [captures objectAtIndex:3];

NSString *containerName = nil;
NSString *itemName = nil;


NSString *capturedName = nil;
if ([captures count] >= 6)
{
containerName = n;
itemName = [captures objectAtIndex:5];
capturedName = [captures objectAtIndex:5];
}
else
{
itemName = n;
capturedName = [captures objectAtIndex:3];
}

if (itemName)
*itemName = capturedName;

return applecode;
}
+ (NSString *)applecodeToIngrcode:(NSString *)applecode itemName:(NSString *)itemName
{
NSString *ingrcode = nil;

if ([applecode isEqual:@"cl"])
ingrcode = @"class";
else if ([applecode isEqual:@"cat"])
Expand Down Expand Up @@ -320,6 +315,42 @@ + (NSString *)hrefToActualFragment:(IGKDocRecordManagedObject *)mo transientObje
ingrcode = @"global";
}

return ingrcode;
}
+ (NSString *)hrefToActualFragment:(IGKDocRecordManagedObject *)mo transientObject:(NSManagedObject *)_transientObject displayTypeMask:(IGKHTMLDisplayTypeMask)_displayTypeMask
{
NSString *href = [mo valueForKey:@"href"];

// NSString.html#//apple_ref/occ/instm/NSString/stringByAppendingPathComponent:
// We need to grab
// the type (cl, instm, etc)
// the container (NSString)
// the item (stringByAppendingPathComponent:)

NSString *regex = @"//apple_ref/(occ|c)/([^/]+)/([^/]+)(/([^/]+))?";
NSArray *captures = [href captureComponentsMatchedByRegex:regex];
if ([captures count] < 4)
return nil;

NSString *applecode = [captures objectAtIndex:2];
NSString *n = [captures objectAtIndex:3];

NSString *containerName = nil;
NSString *itemName = nil;


if ([captures count] >= 6)
{
containerName = n;
itemName = [captures objectAtIndex:5];
}
else
{
itemName = n;
}

NSString *ingrcode = [[self class] applecodeToIngrcode:applecode itemName:itemName];

if ([self containsInDocument:mo transientObject:_transientObject displayTypeMask:_displayTypeMask containerName:containerName itemName:itemName ingrcode:ingrcode])
return [NSString stringWithFormat:@"#%@.%@", itemName, ingrcode];

Expand Down
61 changes: 58 additions & 3 deletions IGKWindowController.m
Expand Up @@ -988,10 +988,20 @@ - (void)reloadRightFilterBarTable:(IGKDocRecordManagedObject *)mo transient:(IGK
for (NSManagedObject *taskitem in taskitems)
{
NSMutableDictionary *taskitemDict = [[NSMutableDictionary alloc] init];
[taskitemDict setValue:[taskitem valueForKey:@"name"] forKey:@"name"];
[taskitemDict setValue:[IGKHTMLGenerator hrefToActualFragment:taskitem transientObject:transientObject displayTypeMask:acceptableDisplayTypes]
forKey:@"href"];


NSString *taskitemHref = [taskitem valueForKey:@"href"];

NSString *taskitemName = nil;
NSString *applecode = [IGKHTMLGenerator extractApplecodeFromHref:taskitemHref itemName:&taskitemName];
NSString *ingrcode = [IGKHTMLGenerator applecodeToIngrcode:applecode itemName:taskitemName];
NSString *entityName = [IGKDocRecordManagedObject entityNameFromURLComponentExtension:ingrcode];
CHSymbolButtonImageMask iconmask = [IGKDocRecordManagedObject iconMaskForEntity:entityName isInstanceMethod:[ingrcode isEqual:@"instance-method"]];

[taskitemDict setValue:[NSNumber numberWithUnsignedLongLong:iconmask] forKey:@"iconMask"];
[taskitemDict setValue:taskitemName forKey:@"name"];

[rightFilterBarTaskGroupedItems addObject:taskitemDict];
}
}
Expand Down Expand Up @@ -1239,6 +1249,44 @@ - (void)tableViewSelectionDidChange:(NSNotification *)aNotification
[self rightFilterTableChangedSelection];
}
}
- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
if (tableView == rightFilterBarTable)
{
id currentRow = [rightFilterBarItems objectAtIndex:row];

if ([currentRow respondsToSelector:@selector(characterAtIndex:)])
{
//[cell setAlignment:NSCenterTextAlignment];
[cell setFont:[NSFont boldSystemFontOfSize:13]];//[NSFont fontWithName:@"Menlo-Bold" size:12]];
//[(NSCell *)cell setTag:10];
}
else
{
//[cell setAlignment:NSNaturalTextAlignment];
[cell setFont:[NSFont fontWithName:@"Menlo" size:12]];
//[(NSCell *)cell setTag:-2];
//[cell setTag:-2];
}
}
}
/*
- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row
{
if (tableView == rightFilterBarTable)
{
id currentRow = [rightFilterBarItems objectAtIndex:row];
if ([currentRow respondsToSelector:@selector(characterAtIndex:)])
{
return 28;
}
}
return [tableView rowHeight];
}
*/

- (void)rightFilterTableChangedSelection
{
NSInteger selind = [rightFilterBarTable selectedRow];
Expand All @@ -1260,7 +1308,14 @@ - (void)rightFilterTableChangedSelection
NSString *href = [kvobject valueForKey:@"href"];
NSLog(@"[kvobject valueForKey:@\"href\"] = %@", href);

[browserWebView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.location.hash = '%@';", href]];
if ([href isLike:@"#*"])
{
[browserWebView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.location.hash = '%@';", href]];
}
else
{
[browserWebView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.location = '%@';", href]];
}
}
}

Expand Down

0 comments on commit 3c5d3b9

Please sign in to comment.