comparison mac/dw.m @ 1517:6506f29dfefc

Implement automatic checking and unchecking of menu items on Mac. This was overlooked because I typically set the state in the app.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 29 Dec 2011 15:40:42 +0000
parents def1ca619ba2
children c98b2ce2d5b2
comparison
equal deleted inserted replaced
1516:03c0eca3aaba 1517:6506f29dfefc
509 -(void)menuHandler:(id)param; 509 -(void)menuHandler:(id)param;
510 -(void)doBitBlt:(id)param; 510 -(void)doBitBlt:(id)param;
511 -(void)doFlush:(id)param; 511 -(void)doFlush:(id)param;
512 @end 512 @end
513 513
514 @interface DWMenuItem : NSMenuItem
515 {
516 int check;
517 }
518 -(void)setCheck:(int)input;
519 -(int)check;
520 -(void)dealloc;
521 @end
522
514 @implementation DWObject 523 @implementation DWObject
515 -(void)uselessThread:(id)sender { /* Thread only to initialize threading */ } 524 -(void)uselessThread:(id)sender { /* Thread only to initialize threading */ }
516 -(void)synchronizeThread:(id)param 525 -(void)synchronizeThread:(id)param
517 { 526 {
518 pthread_mutex_unlock(DWRunMutex); 527 pthread_mutex_unlock(DWRunMutex);
520 pthread_mutex_unlock(DWThreadMutex2); 529 pthread_mutex_unlock(DWThreadMutex2);
521 pthread_mutex_lock(DWRunMutex); 530 pthread_mutex_lock(DWRunMutex);
522 } 531 }
523 -(void)menuHandler:(id)param 532 -(void)menuHandler:(id)param
524 { 533 {
534 DWMenuItem *item = param;
535 if([item check])
536 {
537 if([item state] == NSOnState)
538 [item setState:NSOffState];
539 else
540 [item setState:NSOnState];
541 }
525 _event_handler(param, nil, 8); 542 _event_handler(param, nil, 8);
526 } 543 }
527 -(void)doBitBlt:(id)param 544 -(void)doBitBlt:(id)param
528 { 545 {
529 NSValue *bi = (NSValue *)param; 546 NSValue *bi = (NSValue *)param;
977 -(void)setUserdata:(void *)input { userdata = input; } 994 -(void)setUserdata:(void *)input { userdata = input; }
978 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } 995 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
979 @end 996 @end
980 997
981 /* Subclass for a menu item type */ 998 /* Subclass for a menu item type */
982 @interface DWMenuItem : NSMenuItem { }
983 -(void)dealloc;
984 @end
985
986 @implementation DWMenuItem 999 @implementation DWMenuItem
1000 -(void)setCheck:(int)input { check = input; }
1001 -(int)check { return check; }
987 -(void)dealloc { dw_signal_disconnect_by_window(self); [super dealloc]; } 1002 -(void)dealloc { dw_signal_disconnect_by_window(self); [super dealloc]; }
988 @end 1003 @end
989 1004
990 /* Subclass for a scrollbox type */ 1005 /* Subclass for a scrollbox type */
991 @interface DWScrollBox : NSScrollView 1006 @interface DWScrollBox : NSScrollView
7216 action:@selector(menuHandler:) 7231 action:@selector(menuHandler:)
7217 keyEquivalent:[ NSString stringWithUTF8String:accel ]] autorelease]; 7232 keyEquivalent:[ NSString stringWithUTF8String:accel ]] autorelease];
7218 [menu addItem:item]; 7233 [menu addItem:item];
7219 7234
7220 [item setTag:itemid]; 7235 [item setTag:itemid];
7221 if(flags & DW_MIS_CHECKED) 7236 if(check)
7222 { 7237 {
7223 [item setState:NSOnState]; 7238 [item setCheck:YES];
7239 if(flags & DW_MIS_CHECKED)
7240 {
7241 [item setState:NSOnState];
7242 }
7224 } 7243 }
7225 if(flags & DW_MIS_DISABLED) 7244 if(flags & DW_MIS_DISABLED)
7226 { 7245 {
7227 [item setEnabled:NO]; 7246 [item setEnabled:NO];
7228 } 7247 }