153 [event deltaX]); 154 CHECK_NULL(jEvent); 155 156 static JNF_CLASS_CACHE(jc_TrayIcon, "sun/lwawt/macosx/CTrayIcon"); 157 static JNF_MEMBER_CACHE(jm_handleMouseEvent, jc_TrayIcon, "handleMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V"); 158 JNFCallVoidMethod(env, peer, jm_handleMouseEvent, jEvent); 159 (*env)->DeleteLocalRef(env, jEvent); 160 } 161 162 @end //AWTTrayIcon 163 //================================================ 164 165 @implementation AWTTrayIconView 166 167 -(id)initWithTrayIcon:(AWTTrayIcon *)theTrayIcon { 168 self = [super initWithFrame:NSMakeRect(0, 0, 1, 1)]; 169 170 [self setTrayIcon: theTrayIcon]; 171 isHighlighted = NO; 172 image = nil; 173 174 return self; 175 } 176 177 -(void) dealloc { 178 [image release]; 179 [super dealloc]; 180 } 181 182 - (void)setHighlighted:(BOOL)aFlag 183 { 184 if (isHighlighted != aFlag) { 185 isHighlighted = aFlag; 186 [self setNeedsDisplay:YES]; 187 } 188 } 189 190 - (void)setImage:(NSImage*)anImage { 191 [anImage retain]; 192 [image release]; 193 image = anImage; 194 195 if (image != nil) { 196 [self setNeedsDisplay:YES]; 251 jlong res = JNFCallLongMethod(env, trayIcon.peer, jm_getPopupMenuModel); 252 253 if (res != 0) { 254 CPopupMenu *cmenu = jlong_to_ptr(res); 255 NSMenu* menu = [cmenu menu]; 256 [menu setDelegate:self]; 257 [trayIcon.theItem popUpStatusItemMenu:menu]; 258 [self setNeedsDisplay:YES]; 259 } 260 } 261 } 262 263 - (void) mouseUp:(NSEvent *)event { 264 [trayIcon deliverJavaMouseEvent: event]; 265 } 266 267 - (void) mouseDragged:(NSEvent *)event { 268 [trayIcon deliverJavaMouseEvent: event]; 269 } 270 271 - (void) rightMouseDown:(NSEvent *)event { 272 [trayIcon deliverJavaMouseEvent: event]; 273 } 274 275 - (void) rightMouseUp:(NSEvent *)event { 276 [trayIcon deliverJavaMouseEvent: event]; 277 } 278 279 - (void) rightMouseDragged:(NSEvent *)event { 280 [trayIcon deliverJavaMouseEvent: event]; 281 } 282 283 - (void) otherMouseDown:(NSEvent *)event { 284 [trayIcon deliverJavaMouseEvent: event]; 285 } 286 287 - (void) otherMouseUp:(NSEvent *)event { 288 [trayIcon deliverJavaMouseEvent: event]; 289 } 290 | 153 [event deltaX]); 154 CHECK_NULL(jEvent); 155 156 static JNF_CLASS_CACHE(jc_TrayIcon, "sun/lwawt/macosx/CTrayIcon"); 157 static JNF_MEMBER_CACHE(jm_handleMouseEvent, jc_TrayIcon, "handleMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V"); 158 JNFCallVoidMethod(env, peer, jm_handleMouseEvent, jEvent); 159 (*env)->DeleteLocalRef(env, jEvent); 160 } 161 162 @end //AWTTrayIcon 163 //================================================ 164 165 @implementation AWTTrayIconView 166 167 -(id)initWithTrayIcon:(AWTTrayIcon *)theTrayIcon { 168 self = [super initWithFrame:NSMakeRect(0, 0, 1, 1)]; 169 170 [self setTrayIcon: theTrayIcon]; 171 isHighlighted = NO; 172 image = nil; 173 [self addTrackingArea]; 174 175 return self; 176 } 177 178 - (void)addTrackingArea { 179 if (trackingArea) { 180 [self removeTrackingArea:trackingArea]; 181 } 182 183 NSTrackingAreaOptions options = NSTrackingMouseMoved | 184 NSTrackingInVisibleRect | 185 NSTrackingActiveAlways; 186 trackingArea = [[NSTrackingArea alloc] initWithRect: CGRectZero 187 options: options 188 owner: self 189 userInfo: nil]; 190 [self addTrackingArea:trackingArea]; 191 } 192 193 -(void) dealloc { 194 [image release]; 195 [super dealloc]; 196 } 197 198 - (void)setHighlighted:(BOOL)aFlag 199 { 200 if (isHighlighted != aFlag) { 201 isHighlighted = aFlag; 202 [self setNeedsDisplay:YES]; 203 } 204 } 205 206 - (void)setImage:(NSImage*)anImage { 207 [anImage retain]; 208 [image release]; 209 image = anImage; 210 211 if (image != nil) { 212 [self setNeedsDisplay:YES]; 267 jlong res = JNFCallLongMethod(env, trayIcon.peer, jm_getPopupMenuModel); 268 269 if (res != 0) { 270 CPopupMenu *cmenu = jlong_to_ptr(res); 271 NSMenu* menu = [cmenu menu]; 272 [menu setDelegate:self]; 273 [trayIcon.theItem popUpStatusItemMenu:menu]; 274 [self setNeedsDisplay:YES]; 275 } 276 } 277 } 278 279 - (void) mouseUp:(NSEvent *)event { 280 [trayIcon deliverJavaMouseEvent: event]; 281 } 282 283 - (void) mouseDragged:(NSEvent *)event { 284 [trayIcon deliverJavaMouseEvent: event]; 285 } 286 287 - (void) mouseMoved: (NSEvent *)event { 288 [trayIcon deliverJavaMouseEvent: event]; 289 } 290 291 - (void) rightMouseDown:(NSEvent *)event { 292 [trayIcon deliverJavaMouseEvent: event]; 293 } 294 295 - (void) rightMouseUp:(NSEvent *)event { 296 [trayIcon deliverJavaMouseEvent: event]; 297 } 298 299 - (void) rightMouseDragged:(NSEvent *)event { 300 [trayIcon deliverJavaMouseEvent: event]; 301 } 302 303 - (void) otherMouseDown:(NSEvent *)event { 304 [trayIcon deliverJavaMouseEvent: event]; 305 } 306 307 - (void) otherMouseUp:(NSEvent *)event { 308 [trayIcon deliverJavaMouseEvent: event]; 309 } 310 |