-
Notifications
You must be signed in to change notification settings - Fork 9
/
BHSearchView.m
68 lines (48 loc) · 1.88 KB
/
BHSearchView.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// BHSearchView.m
// BezelHUD
//
// Created by Julius Eckert on 27.01.08.
// Copyright 2008 Julius Eckert. All rights reserved.
//
#import "BHSearchView.h"
@implementation BHSearchView
-(void) awakeFromNib {
[super awakeFromNib];
resultController = [[SFResults alloc] initWithFocus:self];
}
-(void) setEditorActivated:(bool)active {
editorActivated = active;
[self setNeedsDisplay:true];
}
- (void)drawRect:(NSRect)rect {
if (!editorActivated) [super drawRect:rect];
}
- (IBAction)showResultView:sender {
if ([[self window] firstResponder] != self) [[self window] makeFirstResponder:self];
if ([[resultController window] isVisible]) return;
[[resultController window] setLevel:[[self window] level] +1];
[[resultController window] setFrameUsingName:@"results" force:YES];
NSRect windowRect = [[resultController window] frame];
NSRect screenRect = [[[resultController window] screen] frame];
NSPoint resultPoint = [[self window] convertBaseToScreen:[self frame] .origin];
float extraHeight = windowRect.size.height-(resultPoint.y-screenRect.origin.y);
if (extraHeight>0) {
windowRect.origin.y = screenRect.origin.y;
windowRect.size.height -= extraHeight;
} else {
windowRect.origin.y = resultPoint.y-windowRect.size.height-30;//resultsPadding;
}
windowRect.origin.x = [[self window] frame].origin.x + ([[self window] frame].size.width/2 - windowRect.size.width/2);
//windowRect.origin.y += 1.5;
windowRect = NSIntersectionRect(windowRect, screenRect);
[[resultController window] setFrame:windowRect display:NO];
[self updateResultView:sender];
if ([[self controller] respondsToSelector:@selector(searchView:resultsVisible:)])
[(id)[self controller] searchView:self resultsVisible:YES];
if ([[self window] isVisible]) {
[[resultController window] orderFront:nil];
[[self window] addChildWindow:[resultController window] ordered:NSWindowAbove];
}
}
@end