-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathApplicationHandler.m
170 lines (140 loc) · 3.26 KB
/
ApplicationHandler.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
//
// ApplicationHandler.m
// SimpleCap
//
// Created by - on 08/07/02.
// Copyright 2008 Hiroshi Hashiguchi. All rights reserved.
//
#import "ApplicationHandler.h"
#import "CaptureController.h"
#import "TimerController.h"
#import "Window.h"
@implementation ApplicationHandler
// for protocol
- (void)reset
{
}
- (void)setup
{
// setup array
_app_windows = [[NSMutableArray alloc] init];
}
- (BOOL)startWithObject:(id)object
{
_application = [object retain];
[_capture_controller disableMouseEventInWindow];
_animation_counter = 0;
[_capture_controller startTimerOnClient:self
title:[_application objectForKey:@"name"]
image:[_application objectForKey:@"image"]];
return YES;
}
- (void) dealloc
{
[_app_windows release];
[super dealloc];
}
- (void)tearDown
{
[_application release];
[_capture_controller enableMouseEventInWindow];
[_app_windows removeAllObjects];
}
- (void)drawRect:(NSRect)rect
{
}
- (void)mouseMoved:(NSEvent *)theEvent
{
}
- (void)mouseDown:(NSEvent *)theEvent
{
}
- (void)keyDown:(NSEvent *)theEvent
{
[super keyDown:theEvent];
}
- (NSInteger)windowLevel
{
return [super defaultWindowLevel]+1;
}
- (CGImageRef)capture
{
return [self cgimageWithWindowList:_app_windows
cgrect:CGRectNull];
}
- (void)setAppWindows
{
int pid = [[_application objectForKey:@"pid"] intValue];
for(Window* window in [self getWindowAllList]) {
if (pid == [window ownerPID]) {
[_app_windows addObject:window];
}
}
}
//
// <TimerClient>
//
- (void)timerStarted:(TimerController*)controller
{
}
- (void)timerCounted:(TimerController*)controller
{
_animation_counter++;
CaptureView* view = [_capture_controller view];
[view setNeedsDisplay:YES];
}
- (void)timerFinished:(TimerController*)controller
{
[self setAppWindows];
/*
[_capture_controller saveImage:[self capture]
withMouseCursorInWindowList:_app_windows
imageFrame:[Window unionNSRectWithWindowList:_app_windows]];
[_capture_controller exit];
*/
if ([controller isCopy]) {
[_capture_controller copyImage:[self capture]
withMouseCursorInWindowList:_app_windows
imageFrame:[Window unionNSRectWithWindowList:_app_windows]];
[_capture_controller exit];
} else if ([controller isContinous]) {
[_capture_controller setContinouslyFlag:YES];
[_capture_controller saveImage:[self capture]
withMouseCursorInWindowList:_app_windows
imageFrame:[Window unionNSRectWithWindowList:_app_windows]];
[controller start];
} else {
// NORMAL
[_capture_controller saveImage:[self capture]
withMouseCursorInWindowList:_app_windows
imageFrame:[Window unionNSRectWithWindowList:_app_windows]];
[_capture_controller openViewerWithLastfile];
[_capture_controller exit];
}
}
- (void)timerCanceled:(TimerController*)controller
{
[_capture_controller cancel];
}
- (void)timerPaused:(TimerController*)controller
{
}
- (void)timerRestarted:(TimerController*)controller
{
}
- (void)openConfigMenuWithView:(NSView*)view event:(NSEvent*)event
{
[_capture_controller openWindowConfigMenuWithView:view event:event];
}
- (NSMenu *)menuForEvent:(NSEvent *)theEvent
{
return [super menuForEvent:theEvent];
}
- (void)setupQuickConfigMenu:(NSMenu*)menu
{
[super setupQuickConfigMenu:menu];
}
- (void)changedImageFormatTo:(int)image_format
{
}
@end