Annotation of chimera/nsAlertController.mm, revision 1.1

1.1     ! hyatt       1: #import "nsAlertController.h"
        !             2: #import "nsCocoaBrowserService.h"
        !             3: 
        !             4: @implementation nsAlertController
        !             5: 
        !             6: - (IBAction)hitButton1:(id)sender
        !             7: {
        !             8:   [NSApp stopModalWithCode:1];
        !             9: }
        !            10: 
        !            11: - (IBAction)hitButton2:(id)sender
        !            12: {
        !            13:   [NSApp stopModalWithCode:2];
        !            14: }
        !            15: 
        !            16: - (IBAction)hitButton3:(id)sender
        !            17: {
        !            18:   [NSApp stopModalWithCode:3];
        !            19: }
        !            20: 
        !            21: 
        !            22: - (void)awakeFromNib
        !            23: {
        !            24:   nsCocoaBrowserService::SetAlertController(self);
        !            25: }
        !            26: 
        !            27: - (void)alert:(NSWindow*)parent title:(NSString*)title text:(NSString*)text
        !            28: {
        !            29:   [alertPanelText setStringValue:text];
        !            30:   [alertPanel setTitle:title];
        !            31: 
        !            32:   [NSApp runModalForWindow:alertPanel relativeToWindow:parent];
        !            33:   
        !            34:   [alertPanel close];
        !            35: }
        !            36: 
        !            37: - (void)alertCheck:(NSWindow*)parent title:(NSString*)title text:(NSString*)text checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue
        !            38: {
        !            39:   [alertCheckPanelText setStringValue:text];
        !            40:   [alertCheckPanel setTitle:title];
        !            41:   int state = (*checkValue ? NSOnState : NSOffState);
        !            42:   [alertCheckPanelCheck setState:state];
        !            43:   [alertCheckPanelCheck setTitle:checkMsg];
        !            44: 
        !            45:   [NSApp runModalForWindow:alertCheckPanel relativeToWindow:parent];
        !            46: 
        !            47:   *checkValue = ([alertCheckPanelCheck state] == NSOnState);
        !            48:   [alertCheckPanel close];
        !            49: }
        !            50: 
        !            51: - (BOOL)confirm:(NSWindow*)parent title:(NSString*)title text:(NSString*)text
        !            52: {
        !            53:   [confirmPanelText setStringValue:text];
        !            54:   [confirmPanel setTitle:title];
        !            55: 
        !            56:   int result = [NSApp runModalForWindow:confirmPanel relativeToWindow:parent];
        !            57:   
        !            58:   [confirmPanel close];
        !            59: 
        !            60:   return (result == 1);
        !            61: }
        !            62: 
        !            63: - (BOOL)confirmCheck:(NSWindow*)parent title:(NSString*)title text:(NSString*)text checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue
        !            64: {
        !            65:   [confirmCheckPanelText setStringValue:text];
        !            66:   [confirmCheckPanel setTitle:title];
        !            67:   int state = (*checkValue ? NSOnState : NSOffState);
        !            68:   [confirmCheckPanelCheck setState:state];
        !            69:   [confirmCheckPanelCheck setTitle:checkMsg];
        !            70: 
        !            71:   int result = [NSApp runModalForWindow:confirmCheckPanel relativeToWindow:parent];
        !            72: 
        !            73:   *checkValue = ([confirmCheckPanelCheck state] == NSOnState);
        !            74:   [confirmCheckPanel close];
        !            75: 
        !            76:   return (result == 1);
        !            77: }
        !            78: 
        !            79: - (BOOL)prompt:(NSWindow*)parent title:(NSString*)title text:(NSString*)text promptText:(NSMutableString*)promptText checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue doCheck:(BOOL)doCheck
        !            80: {
        !            81:   [promptPanelText setStringValue:text];
        !            82:   [promptPanel setTitle:title];
        !            83:   if (doCheck) {
        !            84:     int state = (*checkValue ? NSOnState : NSOffState);
        !            85:     [promptPanelCheck setState:state];
        !            86:     [promptPanelCheck setEnabled:YES];
        !            87:   }
        !            88:   else {
        !            89:     [promptPanelCheck setEnabled:NO];
        !            90:   }  
        !            91:   [promptPanelCheck setTitle:checkMsg];
        !            92:   [promptPanelInput setStringValue:promptText];
        !            93: 
        !            94:   int result = [NSApp runModalForWindow:promptPanel relativeToWindow:parent];
        !            95: 
        !            96:   *checkValue = ([promptPanelCheck state] == NSOnState);
        !            97: 
        !            98:   NSString* value = [promptPanelInput stringValue];
        !            99:   PRUint32 length = [promptText length];
        !           100:   if (length) {
        !           101:     NSRange all;
        !           102:     all.location = 0;
        !           103:     all.length = [promptText length];
        !           104:     [promptText deleteCharactersInRange:all];
        !           105:   }
        !           106:   [promptText appendString:value];
        !           107: 
        !           108:   [promptPanel close];
        !           109: 
        !           110:   return (result == 1);        
        !           111: }
        !           112: 
        !           113: - (BOOL)promptUserNameAndPassword:(NSWindow*)parent title:(NSString*)title text:(NSString*)text userNameText:(NSMutableString*)userNameText passwordText:(NSMutableString*)passwordText checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue doCheck:(BOOL)doCheck
        !           114: {
        !           115:   [usernamePanelText setStringValue:text];
        !           116:   [usernamePanel setTitle:title];
        !           117:   if (doCheck) {
        !           118:     int state = (*checkValue ? NSOnState : NSOffState);
        !           119:     [usernamePanelCheck setState:state];
        !           120:     [usernamePanelCheck setEnabled:YES];
        !           121:   }
        !           122:   else {
        !           123:     [usernamePanelCheck setEnabled:NO];
        !           124:   }  
        !           125:   [usernamePanelCheck setTitle:checkMsg];
        !           126:   [usernamePanelPassword setStringValue:passwordText];
        !           127:   [usernamePanelUserName setStringValue:userNameText];
        !           128: 
        !           129:   int result = [NSApp runModalForWindow:usernamePanel relativeToWindow:parent];
        !           130: 
        !           131:   *checkValue = ([usernamePanelCheck state] == NSOnState);
        !           132: 
        !           133:   NSString* value = [usernamePanelUserName stringValue];
        !           134:   PRUint32 length = [userNameText length];
        !           135:   if (length) {
        !           136:     NSRange all;
        !           137:     all.location = 0;
        !           138:     all.length = [userNameText length];
        !           139:     [userNameText deleteCharactersInRange:all];
        !           140:   }
        !           141:   [userNameText appendString:value];
        !           142: 
        !           143:   value = [usernamePanelPassword stringValue];
        !           144:   length = [passwordText length];
        !           145:   if (length) {
        !           146:     NSRange all;
        !           147:     all.location = 0;
        !           148:     all.length = [passwordText length];
        !           149:     [passwordText deleteCharactersInRange:all];
        !           150:   }
        !           151:   [passwordText appendString:value];
        !           152: 
        !           153:   [usernamePanel close];
        !           154: 
        !           155:   return (result == 1);        
        !           156: }
        !           157: 
        !           158: - (BOOL)promptPassword:(NSWindow*)parent title:(NSString*)title text:(NSString*)text passwordText:(NSMutableString*)passwordText checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue doCheck:(BOOL)doCheck
        !           159: {
        !           160:   [passwordPanelText setStringValue:text];
        !           161:   [passwordPanel setTitle:title];
        !           162:   if (doCheck) {
        !           163:     int state = (*checkValue ? NSOnState : NSOffState);
        !           164:     [passwordPanelCheck setState:state];
        !           165:     [passwordPanelCheck setEnabled:YES];
        !           166:   }
        !           167:   else {
        !           168:     [passwordPanelCheck setEnabled:NO];
        !           169:   }  
        !           170:   [passwordPanelCheck setTitle:checkMsg];
        !           171:   [passwordPanelInput setStringValue:passwordText];
        !           172: 
        !           173:   int result = [NSApp runModalForWindow:passwordPanel relativeToWindow:parent];
        !           174: 
        !           175:   *checkValue = ([passwordPanelCheck state] == NSOnState);
        !           176: 
        !           177:   NSString* value = [passwordPanelInput stringValue];
        !           178:   PRUint32 length = [passwordText length];
        !           179:   if (length) {
        !           180:     NSRange all;
        !           181:     all.location = 0;
        !           182:     all.length = [passwordText length];
        !           183:     [passwordText deleteCharactersInRange:all];
        !           184:   }
        !           185:   [passwordText appendString:value];
        !           186: 
        !           187:   [passwordPanel close];
        !           188: 
        !           189:   return (result == 1);        
        !           190: }
        !           191: @end

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>