source: trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEMenuOutlineView.m@ 428

Last change on this file since 428 was 428, checked in by Nicholas Riley, 16 years ago

Compiler fixes; first pass at menu-style highlighting

File size: 1.4 KB
Line 
1//
2// ICeCoffEEMenuOutlineView.m
3// ICeCoffEE
4//
5// Created by Nicholas Riley on 3/2/08.
6// Copyright 2008 Nicholas Riley. All rights reserved.
7//
8
9#import "ICeCoffEEMenuOutlineView.h"
10#import <Carbon/Carbon.h>
11
12@implementation ICeCoffEEMenuOutlineView
13
14- (void)highlightSelectionInClipRect:(NSRect)clipRect;
15{
16 NSRange rows = [self rowsInRect: clipRect];
17 unsigned maxRow = NSMaxRange(rows);
18
19 HIThemeMenuItemDrawInfo drawInfo = {0, kThemeMenuItemHierBackground | kThemeMenuItemPopUpBackground, kThemeMenuSelected};
20 if ([[self window] firstResponder] != self || [NSApp keyWindow] != [self window]) {
21 NSLog(@"firstResponder %@ key %@ main %@ this %@", [[self window] firstResponder], [NSApp keyWindow], [NSApp mainWindow], [self window]);
22 [super highlightSelectionInClipRect: clipRect];
23 return;
24 }
25
26 for (unsigned row = rows.location ; row < maxRow ; ++row) {
27 if (![self isRowSelected: row])
28 continue;
29
30 NSRect rowRect = [self rectOfRow: row];
31 rowRect.size.height += 2;
32 if (NSIntersectsRect(rowRect, clipRect)) {
33 OSStatus err = HIThemeDrawMenuItem((HIRect *)&clipRect,
34 (HIRect *)&rowRect,
35 &drawInfo,
36 (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort],
37 kHIThemeOrientationInverted,
38 (HIRect *)&rowRect);
39 if (err != noErr) {
40 [super highlightSelectionInClipRect: clipRect];
41 return;
42 }
43 }
44 }
45}
46
47@end
Note: See TracBrowser for help on using the repository browser.