-
Notifications
You must be signed in to change notification settings - Fork 0
/
VNCMouseTracks.m
144 lines (124 loc) · 3.12 KB
/
VNCMouseTracks.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//
// VNCMouseTracks.m
// vnsea
//
// Created by Glenn Kreisel on 10/28/07.
// Copyright 2007 __MyCompanyName__. All rights reserved.
//
#import "VNCMouseTracks.h"
@implementation VNCMouseTracks
- (id)initWithFrame:(CGRect)frame style:(mouseTracksStyles)wStyle scroller: (VNCScrollerView *)scroller;
{
if ([super initWithFrame:frame])
{
_styleWindow = wStyle;
_szBubbleText = nil;
_ptVNC = frame.origin;
_scroller = scroller;
// NSLog(@"Before Setting to %f,%f", [self frame].origin.x, [self frame].origin.y);
[self zoomOrientationChange];
// NSLog(@"Setting to %f,%f", [self frame].origin.x, [self frame].origin.y);
// NSLog(@"");
[scroller addSubview: self];
}
return self;
}
- (void)animateHide:(NSTimer *)timer
{
if (_cyclesLeft)
{
float fAlpha = [self alpha] * ((float)_cyclesLeft / 10.0);
[self setAlpha: fAlpha];
[self setNeedsDisplay];
_cyclesLeft--;
}
else
{
[timer invalidate];
_popupTimer = nil;
[self removeFromSuperview];
[timer release];
}
}
- (void)hideAnimate:(float)fTime
{
_fAnimateTime = fTime;
}
- (void)hide
{
if (_popupTimer != nil)
{
[_popupTimer invalidate];
[_popupTimer release];
_popupTimer = nil;
}
[self removeFromSuperview];
[self release];
}
- (BOOL)isOpaque
{
// NSLog(@"Checking for Opaque");
return NO;
}
- (void)dealloc
{
// NSLog(@"Dealloc MouseTracks");
[self removeFromSuperview];
if (_szBubbleText != nil)
free(_szBubbleText);
[super dealloc];
}
- (void)zoomOrientationChange
{
CGRect frame = [self frame];
CGRect r, rcBounds = CGRectMake(0,0,0,0);
r.origin = _ptVNC;
frame.origin = [_scroller getIPodScreenPoint: r bounds: rcBounds];
frame.origin.x -= [self bounds].size.width / 2;
frame.origin.y -= [self bounds].size.height / 2;
[self setFrame: frame];
}
- (void)setCenterLocation:(CGPoint)ptCenter
{
_ptVNC = ptCenter;
[self zoomOrientationChange];
return;
}
- (void)handlePopupTimer:(NSTimer *)timer
{
// NSLog(@"Timer going Away");
// VNCPopupWindow **pw = (VNCPopupWindow **)[timer userInfo];
_popupTimer = [[NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(animateHide:) userInfo:nil repeats:YES] retain];
[timer release];
}
- (void)setTimer:(float)fSeconds info:(id)info
{
//NSLog(@"In Setting Timer on Popup");
_cyclesLeft = 10;
_popupTimer = [[NSTimer scheduledTimerWithTimeInterval:fSeconds target:self selector:@selector(handlePopupTimer:) userInfo:nil repeats:NO] retain];
// NSLog(@"Set Timer on Popup");
}
- (void)setStyleWindow:(mouseTracksStyles)wStyle
{
_styleWindow = wStyle;
}
- (void)drawRect:(CGRect)destRect
{
CGContextRef context = UICurrentContext();
CGRect rcElipse = [self bounds];
CGContextClearRect(context, rcElipse);
rcElipse = CGRectInset(rcElipse, 1, 1);
// CGContextSetRGBStrokeColor(context, 0, 0, 1, 1);
// CGContextSetLineWidth (context, 2);
// CGContextStrokeEllipseInRect(context, rcElipse);
if (_styleWindow == kPopupStyleMouseDown)
{
CGContextSetRGBFillColor(context, 1, 0, 0, .7);
}
else if (_styleWindow == kPopupStyleMouseUp)
{
CGContextSetRGBFillColor(context, 0, 1, 0, .7);
}
CGContextFillEllipseInRect(context, rcElipse);
}
@end