< 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     [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     [trackingArea release];
 196     [super dealloc];
 197 }
 198 
 199 - (void)setHighlighted:(BOOL)aFlag
 200 {
 201     if (isHighlighted != aFlag) {
 202         isHighlighted = aFlag;
 203         [self setNeedsDisplay:YES];
 204     }
 205 }
 206 
 207 - (void)setImage:(NSImage*)anImage {
 208     [anImage retain];
 209     [image release];
 210     image = anImage;
 211 
 212     if (image != nil) {
 213         [self setNeedsDisplay:YES];
 214     }
 215 }


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


< prev index next >