< prev index next >

src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m

Print this page




 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];
 197     }
 198 }


 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     trackingArea = nil;
 174         
 175     [self addTrackingArea];
 176         
 177     return self;
 178 }
 179 
 180 - (void)addTrackingArea {
 181     NSTrackingAreaOptions options = NSTrackingMouseMoved | 
 182                                     NSTrackingInVisibleRect | 
 183                                     NSTrackingActiveAlways;
 184     trackingArea = [[NSTrackingArea alloc] initWithRect: CGRectZero
 185                                                 options: options
 186                                                 owner: self
 187                                                 userInfo: nil];
 188     [self addTrackingArea:trackingArea];
 189 }
 190 
 191 -(void) dealloc {
 192     [image release];
 193     [trackingArea release];
 194     [super dealloc];
 195 }
 196 
 197 - (void)setHighlighted:(BOOL)aFlag
 198 {
 199     if (isHighlighted != aFlag) {
 200         isHighlighted = aFlag;
 201         [self setNeedsDisplay:YES];
 202     }
 203 }
 204 
 205 - (void)setImage:(NSImage*)anImage {
 206     [anImage retain];
 207     [image release];
 208     image = anImage;
 209 
 210     if (image != nil) {
 211         [self setNeedsDisplay:YES];
 212     }
 213 }


 266         jlong res = JNFCallLongMethod(env, trayIcon.peer, jm_getPopupMenuModel);
 267 
 268         if (res != 0) {
 269             CPopupMenu *cmenu = jlong_to_ptr(res);
 270             NSMenu* menu = [cmenu menu];
 271             [menu setDelegate:self];
 272             [trayIcon.theItem popUpStatusItemMenu:menu];
 273             [self setNeedsDisplay:YES];
 274         }
 275     }
 276 }
 277 
 278 - (void) mouseUp:(NSEvent *)event {
 279     [trayIcon deliverJavaMouseEvent: event];
 280 }
 281 
 282 - (void) mouseDragged:(NSEvent *)event {
 283     [trayIcon deliverJavaMouseEvent: event];
 284 }
 285 
 286 - (void) mouseMoved: (NSEvent *)event {
 287     [trayIcon deliverJavaMouseEvent: event];
 288 }
 289 
 290 - (void) rightMouseDown:(NSEvent *)event {
 291     [trayIcon deliverJavaMouseEvent: event];
 292 }
 293 
 294 - (void) rightMouseUp:(NSEvent *)event {
 295     [trayIcon deliverJavaMouseEvent: event];
 296 }
 297 
 298 - (void) rightMouseDragged:(NSEvent *)event {
 299     [trayIcon deliverJavaMouseEvent: event];
 300 }
 301 
 302 - (void) otherMouseDown:(NSEvent *)event {
 303     [trayIcon deliverJavaMouseEvent: event];
 304 }
 305 
 306 - (void) otherMouseUp:(NSEvent *)event {
 307     [trayIcon deliverJavaMouseEvent: event];
 308 }
 309 


< prev index next >