Tk Source Code

Check-in [09eec5d4]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:merge trunk. Make "font actual" return integers, for compatibility.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-434d294df
Files: files | file ages | folders
SHA1: 09eec5d40f7d53e3b7bda83758d940cc69c390c2
User & Date: jan.nijtmans 2017-05-18 12:19:10
Context
2017-05-19
12:45
Slightly use of more "int" in stead of double, for 100% compatibility at script level. Closed-Leaf check-in: 36c5cf94 user: jan.nijtmans tags: bug-434d294df
2017-05-18
12:19
merge trunk. Make "font actual" return integers, for compatibility. check-in: 09eec5d4 user: jan.nijtmans tags: bug-434d294df
11:11
minor gcc warning (const usage) check-in: e9d0658e user: jan.nijtmans tags: core-8-6-branch
2017-05-15
14:56
Another attempt to fix [434d294df8], this time (hopefully) suitable for 8.6. (less changes than the original attempt) check-in: 0a5c866c user: jan.nijtmans tags: bug-434d294df
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkFont.c.

3497
3498
3499
3500
3501
3502
3503

3504



3505
3506
3507
3508
3509
3510
3511
	switch (i) {
	case FONT_FAMILY:
	    str = faPtr->family;
	    valuePtr = Tcl_NewStringObj(str, ((str == NULL) ? 0 : -1));
	    break;

	case FONT_SIZE:

	    valuePtr = Tcl_NewDoubleObj(faPtr->size);



	    break;

	case FONT_WEIGHT:
	    str = TkFindStateString(weightMap, faPtr->weight);
	    valuePtr = Tcl_NewStringObj(str, -1);
	    break;








>
|
>
>
>







3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
	switch (i) {
	case FONT_FAMILY:
	    str = faPtr->family;
	    valuePtr = Tcl_NewStringObj(str, ((str == NULL) ? 0 : -1));
	    break;

	case FONT_SIZE:
	    if (faPtr->size >= 0.0) {
		valuePtr = Tcl_NewIntObj((int)(faPtr->size + 0.5));
	    } else {
		valuePtr = Tcl_NewIntObj(-(int)(-faPtr->size + 0.5));
	    }
	    break;

	case FONT_WEIGHT:
	    str = TkFindStateString(weightMap, faPtr->weight);
	    valuePtr = Tcl_NewStringObj(str, -1);
	    break;

Changes to macosx/tkMacOSXDialog.c.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*
 * tkMacOSXDialog.c --
 *
 *	Contains the Mac implementation of the common dialog boxes.
 *
 * Copyright (c) 1996-1997 Sun Microsystems, Inc.
 * Copyright 2001-2009, Apple Inc.
 * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]>
 * Copyright (c) 2017 Christian Gollwitzer. 
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

#include "tkMacOSXPrivate.h"
#include "tkFileFilter.h"








|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*
 * tkMacOSXDialog.c --
 *
 *	Contains the Mac implementation of the common dialog boxes.
 *
 * Copyright (c) 1996-1997 Sun Microsystems, Inc.
 * Copyright 2001-2009, Apple Inc.
 * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]>
 * Copyright (c) 2017 Christian Gollwitzer.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

#include "tkMacOSXPrivate.h"
#include "tkFileFilter.h"
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
    bool doFileTypes; // show the accessory view which displays the filter menu
    bool preselectFilter; // a filter was selected by the typevariable
    bool userHasSelectedFilter; // The user has changed the filter in the accessory view
    NSMutableArray *fileTypeNames; // array of names, e.g. "Text document"
    NSMutableArray *fileTypeExtensions; // array of allowed extensions per name, e.g. "txt", "doc"
    NSMutableArray *fileTypeLabels; // displayed string, e.g. "Text document (.txt, .doc)"
    NSMutableArray *allAllowedExtensions; // set of all allowed extensions
    NSInteger fileTypeIndex; // index of currently selected filter 
} filepanelFilterInfo;

filepanelFilterInfo filterInfo;

NSOpenPanel *openpanel;
NSSavePanel *savepanel;








|







30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
    bool doFileTypes; // show the accessory view which displays the filter menu
    bool preselectFilter; // a filter was selected by the typevariable
    bool userHasSelectedFilter; // The user has changed the filter in the accessory view
    NSMutableArray *fileTypeNames; // array of names, e.g. "Text document"
    NSMutableArray *fileTypeExtensions; // array of allowed extensions per name, e.g. "txt", "doc"
    NSMutableArray *fileTypeLabels; // displayed string, e.g. "Text document (.txt, .doc)"
    NSMutableArray *allAllowedExtensions; // set of all allowed extensions
    NSInteger fileTypeIndex; // index of currently selected filter
} filepanelFilterInfo;

filepanelFilterInfo filterInfo;

NSOpenPanel *openpanel;
NSSavePanel *savepanel;

409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
    TkInitFileFilters(&fl);
    if (TkGetFileFilters(interp, &fl, fileTypesPtr, 0) != TCL_OK) {
	TkFreeFileFilters(&fl);
	return TCL_ERROR;
    }

    filterInfo.doFileTypes = (fl.filters != NULL);
    
    filterInfo.fileTypeIndex = 0;
    filterInfo.fileTypeExtensions = [NSMutableArray array];
    filterInfo.fileTypeNames = [NSMutableArray array];
    filterInfo.fileTypeLabels = [NSMutableArray array];
    filterInfo.allAllowedExtensions = [NSMutableArray array];

    if (filterInfo.doFileTypes) {







|







409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
    TkInitFileFilters(&fl);
    if (TkGetFileFilters(interp, &fl, fileTypesPtr, 0) != TCL_OK) {
	TkFreeFileFilters(&fl);
	return TCL_ERROR;
    }

    filterInfo.doFileTypes = (fl.filters != NULL);

    filterInfo.fileTypeIndex = 0;
    filterInfo.fileTypeExtensions = [NSMutableArray array];
    filterInfo.fileTypeNames = [NSMutableArray array];
    filterInfo.fileTypeLabels = [NSMutableArray array];
    filterInfo.allAllowedExtensions = [NSMutableArray array];

    if (filterInfo.doFileTypes) {
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
		    	str++;
		     }
		    if (*str) {
			NSString *extension = [[NSString alloc] initWithUTF8String:str];
			if (![filterInfo.allAllowedExtensions containsObject:extension]) {
			    [filterInfo.allAllowedExtensions addObject:extension];
			}
			
			[clauseextensions addObject:extension];
			[displayextensions addObject:[@"." stringByAppendingString:extension]];

			[extension release];
		    }
		}
	    }
	    [filterInfo.fileTypeExtensions addObject:clauseextensions];

	    NSMutableString * label = [[NSMutableString alloc] initWithString:name];
	    [label appendString:@" ("];
	    [label appendString:[displayextensions componentsJoinedByString:@", "]];
	    [label appendString:@")"];
	    [filterInfo.fileTypeLabels addObject:label];
	    [label release];
	    
	}

	/* Check if the typevariable exists and matches one of the names */
	filterInfo.preselectFilter = false;
	filterInfo.userHasSelectedFilter = false;
	if (typeVariablePtr) {
	    /* extract the variable content as a NSString */
	    Tcl_Obj *selectedFileTypeObj = Tcl_ObjGetVar2(interp, typeVariablePtr, NULL, TCL_GLOBAL_ONLY);
	    
	    /* check that the typevariable exists */
	    if (selectedFileTypeObj != NULL) {	
		const char *selectedFileType = Tcl_GetString(selectedFileTypeObj);
		NSString *selectedFileTypeStr = [[NSString alloc] initWithUTF8String:selectedFileType];
		NSUInteger index = [filterInfo.fileTypeNames indexOfObject:selectedFileTypeStr];
		
		if (index != NSNotFound) {
		    filterInfo.fileTypeIndex = index;
		    filterInfo.preselectFilter = true;
		}
	    }
	}	

    } 

    TkFreeFileFilters(&fl);
    return TCL_OK;
}


/*







|















|








|

|



|





|

|







438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
		    	str++;
		     }
		    if (*str) {
			NSString *extension = [[NSString alloc] initWithUTF8String:str];
			if (![filterInfo.allAllowedExtensions containsObject:extension]) {
			    [filterInfo.allAllowedExtensions addObject:extension];
			}

			[clauseextensions addObject:extension];
			[displayextensions addObject:[@"." stringByAppendingString:extension]];

			[extension release];
		    }
		}
	    }
	    [filterInfo.fileTypeExtensions addObject:clauseextensions];

	    NSMutableString * label = [[NSMutableString alloc] initWithString:name];
	    [label appendString:@" ("];
	    [label appendString:[displayextensions componentsJoinedByString:@", "]];
	    [label appendString:@")"];
	    [filterInfo.fileTypeLabels addObject:label];
	    [label release];

	}

	/* Check if the typevariable exists and matches one of the names */
	filterInfo.preselectFilter = false;
	filterInfo.userHasSelectedFilter = false;
	if (typeVariablePtr) {
	    /* extract the variable content as a NSString */
	    Tcl_Obj *selectedFileTypeObj = Tcl_ObjGetVar2(interp, typeVariablePtr, NULL, TCL_GLOBAL_ONLY);

	    /* check that the typevariable exists */
	    if (selectedFileTypeObj != NULL) {
		const char *selectedFileType = Tcl_GetString(selectedFileTypeObj);
		NSString *selectedFileTypeStr = [[NSString alloc] initWithUTF8String:selectedFileType];
		NSUInteger index = [filterInfo.fileTypeNames indexOfObject:selectedFileTypeStr];

		if (index != NSNotFound) {
		    filterInfo.fileTypeIndex = index;
		    filterInfo.preselectFilter = true;
		}
	    }
	}

    }

    TkFreeFileFilters(&fl);
    return TCL_OK;
}


/*
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
	    typeVariablePtr = objv[i + 1];
	    break;
	case OPEN_COMMAND:
	    cmdObj = objv[i+1];
	    break;
	}
    }
    
    /* From OSX 10.11, the title string is silently ignored. 
     * Prepend the title to the message 
     * NOTE should be conditional on OSX version, but
     * -mmacosx-version-min does not revert this behaviour*/
    if (title) {
	[openpanel setTitle:title];
	if (message) {
	    NSString *fullmessage = [[NSString alloc] initWithFormat:@"%@\n%@",title,message];
	    [message release];
	    [title release];
	    message = fullmessage;
	} else {
	    message = title;
	}
    }

    if (message) {
	[openpanel setMessage:message];
	[message release];
    }

    [openpanel setAllowsMultipleSelection:multiple];
    
    if (parseFileFilters(interp, fileTypesPtr, typeVariablePtr) != TCL_OK) {
	goto end;
    }

    if (filterInfo.doFileTypes) {
	NSView  *accessoryView = [[NSView alloc] initWithFrame:NSMakeRect(0.0, 0.0, 200, 32.0)];
	NSTextField *label = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 60, 22)];
	[label setEditable:NO];
	[label setStringValue:@"Enable:"];
	[label setBordered:NO];
	[label setBezeled:NO];
	[label setDrawsBackground:NO];

	NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(50.0, 2, 140, 22.0) pullsDown:NO];
	[popupButton addItemsWithTitles:filterInfo.fileTypeLabels];
	[popupButton setAction:@selector(selectFormat:)];

	[accessoryView addSubview:label];
	[accessoryView addSubview:popupButton];
	
	if (filterInfo.preselectFilter) {
	    /* A specific filter was selected from the typevariable. Select it and 
	     * open the accessory view */
	    [popupButton selectItemAtIndex:filterInfo.fileTypeIndex];
	    /* on OSX > 10.11, the optons are not visible by default. Ergo allow all file types 
	    [openpanel setAllowedFileTypes:filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex]];
	    */
	    [openpanel setAllowedFileTypes:filterInfo.allAllowedExtensions];
	} else {
	    [openpanel setAllowedFileTypes:filterInfo.allAllowedExtensions];
	}
	
	[openpanel setAllowsOtherFileTypes:NO];

	[openpanel setAccessoryView:accessoryView];
    } else {
	/* No filters are given. Allow picking all files */
	[openpanel setAllowsOtherFileTypes:YES];
    }

    if (cmdObj) {
	callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo));
	if (Tcl_IsShared(cmdObj)) {
	    cmdObj = Tcl_DuplicateObj(cmdObj);
	}
	Tcl_IncrRefCount(cmdObj);
    }
    
    callbackInfo->cmdObj = cmdObj;
    callbackInfo->interp = interp;
    callbackInfo->multiple = multiple;
    parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
    if (haveParentOption && parent && ![parent attachedSheet]) {
	    parentIsKey = [parent isKeyWindow];
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060







|
|
|




















|



















|

|


|






|















|







583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
	    typeVariablePtr = objv[i + 1];
	    break;
	case OPEN_COMMAND:
	    cmdObj = objv[i+1];
	    break;
	}
    }

    /* From OSX 10.11, the title string is silently ignored.
     * Prepend the title to the message
     * NOTE should be conditional on OSX version, but
     * -mmacosx-version-min does not revert this behaviour*/
    if (title) {
	[openpanel setTitle:title];
	if (message) {
	    NSString *fullmessage = [[NSString alloc] initWithFormat:@"%@\n%@",title,message];
	    [message release];
	    [title release];
	    message = fullmessage;
	} else {
	    message = title;
	}
    }

    if (message) {
	[openpanel setMessage:message];
	[message release];
    }

    [openpanel setAllowsMultipleSelection:multiple];

    if (parseFileFilters(interp, fileTypesPtr, typeVariablePtr) != TCL_OK) {
	goto end;
    }

    if (filterInfo.doFileTypes) {
	NSView  *accessoryView = [[NSView alloc] initWithFrame:NSMakeRect(0.0, 0.0, 200, 32.0)];
	NSTextField *label = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 60, 22)];
	[label setEditable:NO];
	[label setStringValue:@"Enable:"];
	[label setBordered:NO];
	[label setBezeled:NO];
	[label setDrawsBackground:NO];

	NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(50.0, 2, 140, 22.0) pullsDown:NO];
	[popupButton addItemsWithTitles:filterInfo.fileTypeLabels];
	[popupButton setAction:@selector(selectFormat:)];

	[accessoryView addSubview:label];
	[accessoryView addSubview:popupButton];

	if (filterInfo.preselectFilter) {
	    /* A specific filter was selected from the typevariable. Select it and
	     * open the accessory view */
	    [popupButton selectItemAtIndex:filterInfo.fileTypeIndex];
	    /* on OSX > 10.11, the optons are not visible by default. Ergo allow all file types
	    [openpanel setAllowedFileTypes:filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex]];
	    */
	    [openpanel setAllowedFileTypes:filterInfo.allAllowedExtensions];
	} else {
	    [openpanel setAllowedFileTypes:filterInfo.allAllowedExtensions];
	}

	[openpanel setAllowsOtherFileTypes:NO];

	[openpanel setAccessoryView:accessoryView];
    } else {
	/* No filters are given. Allow picking all files */
	[openpanel setAllowsOtherFileTypes:YES];
    }

    if (cmdObj) {
	callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo));
	if (Tcl_IsShared(cmdObj)) {
	    cmdObj = Tcl_DuplicateObj(cmdObj);
	}
	Tcl_IncrRefCount(cmdObj);
    }

    callbackInfo->cmdObj = cmdObj;
    callbackInfo->interp = interp;
    callbackInfo->multiple = multiple;
    parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
    if (haveParentOption && parent && ![parent attachedSheet]) {
	    parentIsKey = [parent isKeyWindow];
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
	[NSApp tkFilePanelDidEnd:openpanel returnCode:modalReturnCode
		contextInfo:callbackInfo];
    }
    result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR;
    if (parentIsKey) {
	[parent makeKeyWindow];
    }
    
    if ((typeVariablePtr && (modalReturnCode == NSOKButton)) && 
	filterInfo.doFileTypes && filterInfo.userHasSelectedFilter) {
	/*
	 * The -typevariable must be set to the selected file type, if the dialog was not cancelled
	 */
	#if 0
	NSLog(@"result: %i modal: %li", result, (long)modalReturnCode);
	#endif
	NSString * selectedFilter = filterInfo.fileTypeNames[filterInfo.fileTypeIndex];
	Tcl_ObjSetVar2(interp, typeVariablePtr, NULL,
		Tcl_NewStringObj([selectedFilter UTF8String], -1), TCL_GLOBAL_ONLY);
    }

 
  end:
    return result;
}


/*
 *----------------------------------------------------------------------







|
|












|







694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
	[NSApp tkFilePanelDidEnd:openpanel returnCode:modalReturnCode
		contextInfo:callbackInfo];
    }
    result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR;
    if (parentIsKey) {
	[parent makeKeyWindow];
    }

    if ((typeVariablePtr && (modalReturnCode == NSOKButton)) &&
	filterInfo.doFileTypes && filterInfo.userHasSelectedFilter) {
	/*
	 * The -typevariable must be set to the selected file type, if the dialog was not cancelled
	 */
	#if 0
	NSLog(@"result: %i modal: %li", result, (long)modalReturnCode);
	#endif
	NSString * selectedFilter = filterInfo.fileTypeNames[filterInfo.fileTypeIndex];
	Tcl_ObjSetVar2(interp, typeVariablePtr, NULL,
		Tcl_NewStringObj([selectedFilter UTF8String], -1), TCL_GLOBAL_ONLY);
    }


  end:
    return result;
}


/*
 *----------------------------------------------------------------------
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
		if (Tcl_GetBooleanFromObj(interp, objv[i + 1],
			&confirmOverwrite) != TCL_OK) {
		    goto end;
		}
		break;
	}
    }
    
    if (title) {
	[savepanel setTitle:title];
	if (message) {
	    NSString *fullmessage = [[NSString alloc] initWithFormat:@"%@\n%@",title,message];
	    [message release];
	    [title release];
	    message = fullmessage;







|







822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
		if (Tcl_GetBooleanFromObj(interp, objv[i + 1],
			&confirmOverwrite) != TCL_OK) {
		    goto end;
		}
		break;
	}
    }

    if (title) {
	[savepanel setTitle:title];
	if (message) {
	    NSString *fullmessage = [[NSString alloc] initWithFormat:@"%@\n%@",title,message];
	    [message release];
	    [title release];
	    message = fullmessage;
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
	[popupButton selectItemAtIndex:filterInfo.fileTypeIndex];
	[popupButton setAction:@selector(saveFormat:)];

	[accessoryView addSubview:label];
	[accessoryView addSubview:popupButton];

	[savepanel setAccessoryView:accessoryView];
	
	[savepanel setAllowedFileTypes:filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex]];
	[savepanel setAllowsOtherFileTypes:NO];
    } else if (defaultType) {
	/* If no filetypes are given, defaultextension is an alternative way
	 * to specify the attached extension. Just propose this extension,
	 * but don't display an accessory view */
	NSMutableArray *AllowedFileTypes = [NSMutableArray array];







|







862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
	[popupButton selectItemAtIndex:filterInfo.fileTypeIndex];
	[popupButton setAction:@selector(saveFormat:)];

	[accessoryView addSubview:label];
	[accessoryView addSubview:popupButton];

	[savepanel setAccessoryView:accessoryView];

	[savepanel setAllowedFileTypes:filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex]];
	[savepanel setAllowsOtherFileTypes:NO];
    } else if (defaultType) {
	/* If no filetypes are given, defaultextension is an alternative way
	 * to specify the attached extension. Just propose this extension,
	 * but don't display an accessory view */
	NSMutableArray *AllowedFileTypes = [NSMutableArray array];
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
	[NSApp tkFilePanelDidEnd:savepanel returnCode:modalReturnCode
		contextInfo:callbackInfo];
    }
    result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR;
    if (parentIsKey) {
	[parent makeKeyWindow];
    }
    
    if ((typeVariablePtr && (modalReturnCode == NSOKButton)) && filterInfo.doFileTypes) {
	/*
	 * The -typevariable must be set to the selected file type, if the dialog was not cancelled
	 */
	#if 0
	NSLog(@"result: %i modal: %li", result, (long)modalReturnCode);
	#endif







|







926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
	[NSApp tkFilePanelDidEnd:savepanel returnCode:modalReturnCode
		contextInfo:callbackInfo];
    }
    result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR;
    if (parentIsKey) {
	[parent makeKeyWindow];
    }

    if ((typeVariablePtr && (modalReturnCode == NSOKButton)) && filterInfo.doFileTypes) {
	/*
	 * The -typevariable must be set to the selected file type, if the dialog was not cancelled
	 */
	#if 0
	NSLog(@"result: %i modal: %li", result, (long)modalReturnCode);
	#endif

Changes to unix/tcl.m4.

1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
	    LDFLAGS="$LDFLAGS -Wl,-Bexport"
	    CC_SEARCH_FLAGS=""
	    LD_SEARCH_FLAGS=""
	    ;;
	OpenBSD-*)
	    arch=`arch -s`
	    case "$arch" in
	    vax)
		# Equivalent using configure option --disable-load
		# Step 4 will set the necessary variables
		DL_OBJS=""
		SHLIB_LD_LIBS=""
		LDFLAGS=""
		;;
	    *)
		case "$arch" in
		alpha|sparc|sparc64)
		    SHLIB_CFLAGS="-fPIC"
		    ;;
		*)
		    SHLIB_CFLAGS="-fpic"
		    ;;
		esac
		SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}'
		SHLIB_SUFFIX=".so"
		DL_OBJS="tclLoadDl.o"
		DL_LIBS=""
		AS_IF([test $doRpath = yes], [
		    CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
		SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}'
		LDFLAGS="-Wl,-export-dynamic"
		;;
	    esac
	    case "$arch" in
	    vax)
		CFLAGS_OPTIMIZE="-O1"
		;;
	    sh)
		CFLAGS_OPTIMIZE="-O0"
		;;
	    *)
		CFLAGS_OPTIMIZE="-O2"
		;;
	    esac
	    AS_IF([test "${TCL_THREADS}" = "1"], [
		# On OpenBSD:	Compile with -pthread
		#		Don't link with -lpthread
		LIBS=`echo $LIBS | sed s/-lpthread//`
		CFLAGS="$CFLAGS -pthread"
	    ])
	    # OpenBSD doesn't do version numbers with dots.







<
<
<
<
<
<
<
<
<
|
|
|
|
|
|
|
|
|
<
<
|
|
|
|
|
<
<
<
<
<
<
<
<
<
<
|
<
<







1463
1464
1465
1466
1467
1468
1469









1470
1471
1472
1473
1474
1475
1476
1477
1478


1479
1480
1481
1482
1483










1484


1485
1486
1487
1488
1489
1490
1491
	    LDFLAGS="$LDFLAGS -Wl,-Bexport"
	    CC_SEARCH_FLAGS=""
	    LD_SEARCH_FLAGS=""
	    ;;
	OpenBSD-*)
	    arch=`arch -s`
	    case "$arch" in









	    alpha|sparc64)
		SHLIB_CFLAGS="-fPIC"
		;;
	    *)
		SHLIB_CFLAGS="-fpic"
		;;
	    esac
	    SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}'
	    SHLIB_SUFFIX=".so"


	    AS_IF([test $doRpath = yes], [
		CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
	    LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
	    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so${SHLIB_VERSION}'
	    LDFLAGS="-Wl,-export-dynamic"










	    CFLAGS_OPTIMIZE="-O2"


	    AS_IF([test "${TCL_THREADS}" = "1"], [
		# On OpenBSD:	Compile with -pthread
		#		Don't link with -lpthread
		LIBS=`echo $LIBS | sed s/-lpthread//`
		CFLAGS="$CFLAGS -pthread"
	    ])
	    # OpenBSD doesn't do version numbers with dots.

Changes to unix/tkUnixButton.c.

346
347
348
349
350
351
352









































353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
 *
 * Side effects:
 *	Commands are output to X to display the button in its current mode.
 *	The REDRAW_PENDING flag is cleared.
 *
 *----------------------------------------------------------------------
 */










































void
TkpDisplayButton(
    ClientData clientData)	/* Information about widget. */
{
    register TkButton *butPtr = (TkButton *) clientData;
    GC gc;
    Tk_3DBorder border;
    Pixmap pixmap;
    int x = 0;			/* Initialization only needed to stop compiler
				 * warning. */
    int y, relief;
    Tk_Window tkwin = butPtr->tkwin;
    int width = 0, height = 0, fullWidth, fullHeight;
    int textXOffset, textYOffset;
    int haveImage = 0, haveText = 0;
    int offset;			/* 1 means this is a button widget, so we
				 * offset the text to make the button appear
				 * to move up and down as the relief
				 * changes. */
    int imageWidth, imageHeight;
    int imageXOffset = 0, imageYOffset = 0;
				/* image information that will be used to
				 * restrict disabled pixmap as well */

    butPtr->flags &= ~REDRAW_PENDING;
    if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
















<
<
<
<







346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409




410
411
412
413
414
415
416
 *
 * Side effects:
 *	Commands are output to X to display the button in its current mode.
 *	The REDRAW_PENDING flag is cleared.
 *
 *----------------------------------------------------------------------
 */

static void
ShiftByOffset(
    TkButton *butPtr,
    int relief,
    int *x,		/* shift this x coordinate */
    int *y,		/* shift this y coordinate */
    int width,		/* width of image/text */
    int height)		/* height of image/text */
{
    if (relief != TK_RELIEF_RAISED
	    && butPtr->type == TYPE_BUTTON
	    && !Tk_StrictMotif(butPtr->tkwin)) {
	int shiftX;
	int shiftY;

	/*
	 * This is an (unraised) button widget, so we offset the text to make
	 * the button appear to move up and down as the relief changes.
	 */

	shiftX = shiftY = (relief == TK_RELIEF_SUNKEN) ? 2 : 1;

	if (relief != TK_RELIEF_RIDGE) {
	    /*
	     * Take back one pixel if the padding is even, otherwise the
	     * content will be displayed too far right/down.
	     */

	    if ((Tk_Width(butPtr->tkwin) - width) % 2 == 0) {
		shiftX -= 1;
	    }
	    if ((Tk_Height(butPtr->tkwin) - height) % 2 == 0) {
		shiftY -= 1;
	    }
	}

	*x += shiftX;
	*y += shiftY;
    }
}

void
TkpDisplayButton(
    ClientData clientData)	/* Information about widget. */
{
    register TkButton *butPtr = (TkButton *) clientData;
    GC gc;
    Tk_3DBorder border;
    Pixmap pixmap;
    int x = 0;			/* Initialization only needed to stop compiler
				 * warning. */
    int y, relief;
    Tk_Window tkwin = butPtr->tkwin;
    int width = 0, height = 0, fullWidth, fullHeight;
    int textXOffset, textYOffset;
    int haveImage = 0, haveText = 0;




    int imageWidth, imageHeight;
    int imageXOffset = 0, imageYOffset = 0;
				/* image information that will be used to
				 * restrict disabled pixmap as well */

    butPtr->flags &= ~REDRAW_PENDING;
    if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
	if (butPtr->flags & SELECTED) {
	    relief = TK_RELIEF_SUNKEN;
	} else if (butPtr->overRelief != relief) {
	    relief = butPtr->offRelief;
	}
    }

    offset = (butPtr->type == TYPE_BUTTON) && !Tk_StrictMotif(butPtr->tkwin);

    /*
     * In order to avoid screen flashes, this function redraws the button in a
     * pixmap, then copies the pixmap to the screen in a single operation.
     * This means that there's no point in time where the on-screen image has
     * been cleared.
     */








<
<







465
466
467
468
469
470
471


472
473
474
475
476
477
478
	if (butPtr->flags & SELECTED) {
	    relief = TK_RELIEF_SUNKEN;
	} else if (butPtr->overRelief != relief) {
	    relief = butPtr->offRelief;
	}
    }



    /*
     * In order to avoid screen flashes, this function redraws the button in a
     * pixmap, then copies the pixmap to the screen in a single operation.
     * This means that there's no point in time where the on-screen image has
     * been cleared.
     */

521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
	    break;
	}

	TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
		butPtr->indicatorSpace + fullWidth, fullHeight, &x, &y);

	x += butPtr->indicatorSpace;

	x += offset;
	y += offset;
	if (relief == TK_RELIEF_RAISED) {
	    x -= offset;
	    y -= offset;
	} else if (relief == TK_RELIEF_SUNKEN) {
	    x += offset;
	    y += offset;
	}

	imageXOffset += x;
	imageYOffset += y;

	if (butPtr->image != NULL) {
	    /*
	     * Do boundary clipping, so that Tk_RedrawImage is passed valid
	     * coordinates. [Bug 979239]







|
<
<
<
<
<
<
<
<
<
<







556
557
558
559
560
561
562
563










564
565
566
567
568
569
570
	    break;
	}

	TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
		butPtr->indicatorSpace + fullWidth, fullHeight, &x, &y);

	x += butPtr->indicatorSpace;
	ShiftByOffset(butPtr, relief, &x, &y, width, height);










	imageXOffset += x;
	imageYOffset += y;

	if (butPtr->image != NULL) {
	    /*
	     * Do boundary clipping, so that Tk_RedrawImage is passed valid
	     * coordinates. [Bug 979239]
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
		butPtr->underline);
	y += fullHeight/2;
    } else {
	if (haveImage) {
	    TkComputeAnchor(butPtr->anchor, tkwin, 0, 0,
		    butPtr->indicatorSpace + width, height, &x, &y);
	    x += butPtr->indicatorSpace;

	    x += offset;
	    y += offset;
	    if (relief == TK_RELIEF_RAISED) {
		x -= offset;
		y -= offset;
	    } else if (relief == TK_RELIEF_SUNKEN) {
		x += offset;
		y += offset;
	    }
	    imageXOffset += x;
	    imageYOffset += y;
	    if (butPtr->image != NULL) {
		/*
		 * Do boundary clipping, so that Tk_RedrawImage is passed
		 * valid coordinates. [Bug 979239]
		 */







|
<
<
<
<
<
<
<
<
<







614
615
616
617
618
619
620
621









622
623
624
625
626
627
628
		butPtr->underline);
	y += fullHeight/2;
    } else {
	if (haveImage) {
	    TkComputeAnchor(butPtr->anchor, tkwin, 0, 0,
		    butPtr->indicatorSpace + width, height, &x, &y);
	    x += butPtr->indicatorSpace;
	    ShiftByOffset(butPtr, relief, &x, &y, width, height);









	    imageXOffset += x;
	    imageYOffset += y;
	    if (butPtr->image != NULL) {
		/*
		 * Do boundary clipping, so that Tk_RedrawImage is passed
		 * valid coordinates. [Bug 979239]
		 */
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
	    y += height/2;
	} else {
 	    TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
		    butPtr->indicatorSpace + butPtr->textWidth,
		    butPtr->textHeight, &x, &y);

	    x += butPtr->indicatorSpace;

	    x += offset;
	    y += offset;
	    if (relief == TK_RELIEF_RAISED) {
		x -= offset;
		y -= offset;
	    } else if (relief == TK_RELIEF_SUNKEN) {
		x += offset;
		y += offset;
	    }
	    Tk_DrawTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout,
		    x, y, 0, -1);
	    Tk_UnderlineTextLayout(butPtr->display, pixmap, gc,
		    butPtr->textLayout, x, y, butPtr->underline);
	    y += butPtr->textHeight/2;
	}
    }







|
<
<
<
<
<
<
<
<
<







667
668
669
670
671
672
673
674









675
676
677
678
679
680
681
	    y += height/2;
	} else {
 	    TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
		    butPtr->indicatorSpace + butPtr->textWidth,
		    butPtr->textHeight, &x, &y);

	    x += butPtr->indicatorSpace;
	    ShiftByOffset(butPtr, relief, &x, &y, width, height);









	    Tk_DrawTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout,
		    x, y, 0, -1);
	    Tk_UnderlineTextLayout(butPtr->display, pixmap, gc,
		    butPtr->textLayout, x, y, butPtr->underline);
	    y += butPtr->textHeight/2;
	}
    }

Changes to unix/tkUnixFont.c.

2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
	}
	rest = str;
	for (i = XLFD_PIXEL_SIZE; i < XLFD_CHARSET; i++) {
	    rest = strchr(rest + 1, '-');
	}
	*str = '\0';
	sprintf(buf, "%.200s-%d-*-*-*-*-*%s", nameList[bestIdx[1]],
		(int)(-wantPtr->fa.size-0.5), rest);
	*str = '-';
	fontStructPtr = XLoadQueryFont(display, buf);
	bestScore[1] = INT_MAX;
    }
    if (fontStructPtr == NULL) {
	fontStructPtr = XLoadQueryFont(display, nameList[bestIdx[0]]);
	if (fontStructPtr == NULL) {







|







2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
	}
	rest = str;
	for (i = XLFD_PIXEL_SIZE; i < XLFD_CHARSET; i++) {
	    rest = strchr(rest + 1, '-');
	}
	*str = '\0';
	sprintf(buf, "%.200s-%d-*-*-*-*-*%s", nameList[bestIdx[1]],
		(int)(-wantPtr->fa.size+0.5), rest);
	*str = '-';
	fontStructPtr = XLoadQueryFont(display, buf);
	bestScore[1] = INT_MAX;
    }
    if (fontStructPtr == NULL) {
	fontStructPtr = XLoadQueryFont(display, nameList[bestIdx[0]]);
	if (fontStructPtr == NULL) {

Changes to win/tkWinDialog.c.

2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
    enum options {
	MSG_DEFAULT,	MSG_DETAIL,	MSG_ICON,	MSG_MESSAGE,
	MSG_PARENT,	MSG_TITLE,	MSG_TYPE
    };
    ThreadSpecificData *tsdPtr =
	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
    Tcl_DString titleBuf, tmpBuf;
    WCHAR *titlePtr, *tmpPtr;
    const char *src;

    defaultBtn = -1;
    detailObj = NULL;
    icon = MB_ICONINFORMATION;
    messageObj = NULL;
    parent = tkwin;







|







2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
    enum options {
	MSG_DEFAULT,	MSG_DETAIL,	MSG_ICON,	MSG_MESSAGE,
	MSG_PARENT,	MSG_TITLE,	MSG_TYPE
    };
    ThreadSpecificData *tsdPtr =
	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
    Tcl_DString titleBuf, tmpBuf;
    const WCHAR *titlePtr, *tmpPtr;
    const char *src;

    defaultBtn = -1;
    detailObj = NULL;
    icon = MB_ICONINFORMATION;
    messageObj = NULL;
    parent = tkwin;