Check-in [67e475ea97]
Not logged in

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

Overview
Comment:improved handling of differences in xdpi/ydpi i.e. non-quadratic pixels
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 67e475ea97b19d5700766cca3703b29a197727c2
User & Date: chw 2015-11-06 17:07:36
Original Comment: improved handling of differences in xdpy/ypdi i.e. non-quadratic pixels
Context
2015-11-07
18:02
tkpath pimage item review fixing potential crashes check-in: e1b484dd2d user: chw tags: trunk
2015-11-06
17:07
improved handling of differences in xdpi/ydpi i.e. non-quadratic pixels check-in: 67e475ea97 user: chw tags: trunk
2015-11-03
19:20
tkpath out-of-memory handling for Agg2D backend improved check-in: 7715a5d700 user: chw tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to jni/sdl2tk/generic/tkCmds.c.
823
824
825
826
827
828
829

830
831
832

833
834
835






836
837
838
839
840
841
842
    skip = TkGetDisplayOf(interp, objc - 1, objv + 1, &tkwin);
    if (skip < 0) {
	return TCL_ERROR;
    }
    screenPtr = Tk_Screen(tkwin);
    if (objc - skip == 1) {
#ifdef PLATFORM_SDL

	int widthM, widthS;

	ScreenGetMMWidth(Tk_Display(tkwin), screenPtr, &widthM, &widthS);

	d = 25.4 / 72;
	d *= widthS;
	d /= widthM;






#else
	d = 25.4 / 72;
	d *= WidthOfScreen(screenPtr);
	d /= WidthMMOfScreen(screenPtr);
#endif
	Tcl_SetObjResult(interp, Tcl_NewDoubleObj(d));
    } else if (objc - skip == 2) {







>
|

|
>



>
>
>
>
>
>







823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
    skip = TkGetDisplayOf(interp, objc - 1, objv + 1, &tkwin);
    if (skip < 0) {
	return TCL_ERROR;
    }
    screenPtr = Tk_Screen(tkwin);
    if (objc - skip == 1) {
#ifdef PLATFORM_SDL
	double d2;
	int widthM, widthS, heightM, heightS;

	ScreenGetMMWidthHeight(Tk_Display(tkwin), screenPtr, &widthM, &widthS,
	       &heightM, &heightS);
	d = 25.4 / 72;
	d *= widthS;
	d /= widthM;
	d2 = 25.4 / 72;
	d2 *= heightS;
	d2 /= heightM;
	if (d2 > d) {
	    d = d2;
	}
#else
	d = 25.4 / 72;
	d *= WidthOfScreen(screenPtr);
	d /= WidthMMOfScreen(screenPtr);
#endif
	Tcl_SetObjResult(interp, Tcl_NewDoubleObj(d));
    } else if (objc - skip == 2) {
1715
1716
1717
1718
1719
1720
1721

1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739




1740
1741
1742
1743
1744
1745
1746
	}
	Tcl_SetObjResult(interp, Tcl_NewBooleanObj(alive));
	break;
    }
    case WIN_FPIXELS: {
	double mm, pixels;
#ifdef PLATFORM_SDL

	int widthM, widthS;
#endif

	if (objc != 4) {
	    Tcl_WrongNumArgs(interp, 2, objv, "window number");
	    return TCL_ERROR;
	}
	if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin) != TCL_OK) {
	    return TCL_ERROR;
	}
	string = Tcl_GetString(objv[3]);
	if (Tk_GetScreenMM(interp, tkwin, string, &mm) != TCL_OK) {
	    return TCL_ERROR;
	}
#ifdef PLATFORM_SDL
	ScreenGetMMWidth(Tk_Display(tkwin), Tk_Screen(tkwin),
	    &widthM, &widthS);
	pixels = mm * widthS / widthM;




#else
	pixels = mm * WidthOfScreen(Tk_Screen(tkwin))
		/ WidthMMOfScreen(Tk_Screen(tkwin));
#endif
	Tcl_SetObjResult(interp, Tcl_NewDoubleObj(pixels));
	break;
    }







>
|














|
|

>
>
>
>







1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
	}
	Tcl_SetObjResult(interp, Tcl_NewBooleanObj(alive));
	break;
    }
    case WIN_FPIXELS: {
	double mm, pixels;
#ifdef PLATFORM_SDL
	double pixels2;
	int widthM, widthS, heightM, heightS;
#endif

	if (objc != 4) {
	    Tcl_WrongNumArgs(interp, 2, objv, "window number");
	    return TCL_ERROR;
	}
	if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin) != TCL_OK) {
	    return TCL_ERROR;
	}
	string = Tcl_GetString(objv[3]);
	if (Tk_GetScreenMM(interp, tkwin, string, &mm) != TCL_OK) {
	    return TCL_ERROR;
	}
#ifdef PLATFORM_SDL
	ScreenGetMMWidthHeight(Tk_Display(tkwin), Tk_Screen(tkwin),
		&widthM, &widthS, &heightM, &heightS);
	pixels = mm * widthS / widthM;
	pixels2 = mm * heightS / heightM;
	if (pixels2 > pixels) {
	    pixels = pixels2;
	}
#else
	pixels = mm * WidthOfScreen(Tk_Screen(tkwin))
		/ WidthMMOfScreen(Tk_Screen(tkwin));
#endif
	Tcl_SetObjResult(interp, Tcl_NewDoubleObj(pixels));
	break;
    }
Changes to jni/sdl2tk/generic/tkFont.c.
4076
4077
4078
4079
4080
4081
4082




4083
4084
4085
4086
4087
4088
4089




4090
4091
4092
4093
4094
4095
4096
4097





4098
4099
4100
4101
4102
4103
4104
int
TkFontGetPixels(
    Tk_Window tkwin,		/* For point->pixel conversion factor. */
    int size)			/* Font size. */
{
    double d;
    int widthM, widthS;





    if (size < 0) {
	return -size;
    }

#ifdef PLATFORM_SDL
    ScreenGetMMWidth(Tk_Display(tkwin), Tk_Screen(tkwin), &widthM, &widthS);




#else
    widthS = WidthOfScreen(Tk_Screen(tkwin));
    widthM = WidthMMOfScreen(Tk_Screen(tkwin));
#endif

    d = size * 25.4 / 72.0;
    d *= widthS;
    d /= widthM;





    return (int) (d + 0.5);
}

/*
 *---------------------------------------------------------------------------
 *
 * TkFontGetPoints --







>
>
>
>






|
>
>
>
>








>
>
>
>
>







4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
int
TkFontGetPixels(
    Tk_Window tkwin,		/* For point->pixel conversion factor. */
    int size)			/* Font size. */
{
    double d;
    int widthM, widthS;
#ifdef PLATFORM_SDL
    double d2;
    int heightM, heightS;
#endif

    if (size < 0) {
	return -size;
    }

#ifdef PLATFORM_SDL
    ScreenGetMMWidthHeight(Tk_Display(tkwin), Tk_Screen(tkwin),
	    &widthM, &widthS, &heightM, &heightS);
    d2 = size * 25.4 / 72.0;
    d2 *= heightS;
    d2 /= heightM;
#else
    widthS = WidthOfScreen(Tk_Screen(tkwin));
    widthM = WidthMMOfScreen(Tk_Screen(tkwin));
#endif

    d = size * 25.4 / 72.0;
    d *= widthS;
    d /= widthM;
#ifdef PLATFORM_SDL
    if (d2 > d) {
	d = d2;
    }
#endif
    return (int) (d + 0.5);
}

/*
 *---------------------------------------------------------------------------
 *
 * TkFontGetPoints --
4118
4119
4120
4121
4122
4123
4124




4125
4126
4127
4128
4129
4130
4131




4132
4133
4134
4135
4136
4137
4138
4139





4140
4141
4142
4143
4144
4145
4146
int
TkFontGetPoints(
    Tk_Window tkwin,		/* For pixel->point conversion factor. */
    int size)			/* Font size. */
{
    double d;
    int widthM, widthS;





    if (size >= 0) {
	return size;
    }

#ifdef PLATFORM_SDL
    ScreenGetMMWidth(Tk_Display(tkwin), Tk_Screen(tkwin), &widthM, &widthS);




#else
    widthS = WidthOfScreen(Tk_Screen(tkwin));
    widthM = WidthMMOfScreen(Tk_Screen(tkwin));
#endif

    d = -size * 72.0 / 25.4;
    d *= widthM;
    d /= widthS;





    return (int) (d + 0.5);
}

/*
 *-------------------------------------------------------------------------
 *
 * TkFontGetAliasList --







>
>
>
>






|
>
>
>
>








>
>
>
>
>







4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
int
TkFontGetPoints(
    Tk_Window tkwin,		/* For pixel->point conversion factor. */
    int size)			/* Font size. */
{
    double d;
    int widthM, widthS;
#ifdef PLATFORM_SDL
    double d2;
    int heightM, heightS;
#endif

    if (size >= 0) {
	return size;
    }

#ifdef PLATFORM_SDL
    ScreenGetMMWidthHeight(Tk_Display(tkwin), Tk_Screen(tkwin),
	    &widthM, &widthS, &heightM, &heightS);
    d2 = -size * 72.0 / 25.4;
    d2 *= heightM;
    d2 /= heightS;
#else
    widthS = WidthOfScreen(Tk_Screen(tkwin));
    widthM = WidthMMOfScreen(Tk_Screen(tkwin));
#endif

    d = -size * 72.0 / 25.4;
    d *= widthM;
    d /= widthS;
#ifdef PLATFORM_SDL
    if (d2 < d) {
	d = d2;
    }
#endif
    return (int) (d + 0.5);
}

/*
 *-------------------------------------------------------------------------
 *
 * TkFontGetAliasList --
Changes to jni/sdl2tk/generic/tkGet.c.
581
582
583
584
585
586
587
588

589
590

591
592





593
594
595
596
597
598
599
    while ((*end != '\0') && isspace(UCHAR(*end))) {
	end++;
    }
    switch (*end) {
    case 0:
#ifdef PLATFORM_SDL
    {
	int wM, wS;


	ScreenGetMMWidth(Tk_Display(tkwin), Tk_Screen(tkwin), &wM, &wS);

	d /= wS;
	d *= wM;





    }
#else
	d /= WidthOfScreen(Tk_Screen(tkwin));
	d *= WidthMMOfScreen(Tk_Screen(tkwin));
#endif
	break;
    case 'c':







|
>

|
>


>
>
>
>
>







581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
    while ((*end != '\0') && isspace(UCHAR(*end))) {
	end++;
    }
    switch (*end) {
    case 0:
#ifdef PLATFORM_SDL
    {
	int wM, wS, hM, hS;
	double d2 = d;

	ScreenGetMMWidthHeight(Tk_Display(tkwin), Tk_Screen(tkwin),
		&wM, &wS, &hM, &hS);
	d /= wS;
	d *= wM;
	d2 /= hS;
	d2 *= hM;
	if (d2 < d) {
	    d = d2;
	}
    }
#else
	d /= WidthOfScreen(Tk_Screen(tkwin));
	d *= WidthMMOfScreen(Tk_Screen(tkwin));
#endif
	break;
    case 'c':
700
701
702
703
704
705
706




707
708
709
710
711
712
713
714
715
716









717
718
719
720
721
722
723
				 * units. */
    const char *string,		/* String describing a number of pixels. */
    double *doublePtr)		/* Place to store converted result. */
{
    char *end;
    double d;
    int widthM, widthS;





    d = strtod((char *) string, &end);
    if (end == string) {
	goto error;
    }
    while ((*end != '\0') && isspace(UCHAR(*end))) {
	end++;
    }
#ifdef PLATFORM_SDL
    ScreenGetMMWidth(Tk_Display(tkwin), Tk_Screen(tkwin), &widthM, &widthS);









#else
    widthS = WidthOfScreen(Tk_Screen(tkwin));
    widthM = WidthMMOfScreen(Tk_Screen(tkwin));
#endif
    switch (*end) {
    case 0:
	break;







>
>
>
>









|
>
>
>
>
>
>
>
>
>







707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
				 * units. */
    const char *string,		/* String describing a number of pixels. */
    double *doublePtr)		/* Place to store converted result. */
{
    char *end;
    double d;
    int widthM, widthS;
#ifdef PLATFORM_SDL
    int heightM, heightS;
    double d2, d3;
#endif

    d = strtod((char *) string, &end);
    if (end == string) {
	goto error;
    }
    while ((*end != '\0') && isspace(UCHAR(*end))) {
	end++;
    }
#ifdef PLATFORM_SDL
    ScreenGetMMWidthHeight(Tk_Display(tkwin), Tk_Screen(tkwin),
	    &widthM, &widthS, &heightM, &heightS);
    d2 = widthS;
    d2 /= widthM;
    d3 = heightS;
    d3 /= heightM;
    if (d3 > d2) {
	widthS = heightS;
	widthM = heightM;
    }
#else
    widthS = WidthOfScreen(Tk_Screen(tkwin));
    widthM = WidthMMOfScreen(Tk_Screen(tkwin));
#endif
    switch (*end) {
    case 0:
	break;
Changes to jni/sdl2tk/generic/tkObj.c.
248
249
250
251
252
253
254



255
256








257
258
259
260
261
262
263
	    goto retry;
	}
	if ((pixelPtr->tkwin != tkwin) || dblPtr) {
	    d = pixelPtr->value;
	    if (pixelPtr->units >= 0) {
		int widthM, widthS;
#ifdef PLATFORM_SDL



		ScreenGetMMWidth(Tk_Display(tkwin), Tk_Screen(tkwin),
		    &widthM, &widthS);








#else
		widthS = WidthOfScreen(Tk_Screen(tkwin));
		widthM = WidthMMOfScreen(Tk_Screen(tkwin));
#endif
		d *= bias[pixelPtr->units] * widthS;
		d /= widthM;
	    }







>
>
>
|
|
>
>
>
>
>
>
>
>







248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
	    goto retry;
	}
	if ((pixelPtr->tkwin != tkwin) || dblPtr) {
	    d = pixelPtr->value;
	    if (pixelPtr->units >= 0) {
		int widthM, widthS;
#ifdef PLATFORM_SDL
		int heightM, heightS;
		double d2, d3;

		ScreenGetMMWidthHeight(Tk_Display(tkwin), Tk_Screen(tkwin),
			&widthM, &widthS, &heightM, &heightS);
		d2 = widthS;
		d2 /= widthM;
		d3 = heightS;
		d3 /= heightM;
		if (d3 > d2) {
		    widthS = heightS;
		    widthM = heightM;
		}
#else
		widthS = WidthOfScreen(Tk_Screen(tkwin));
		widthM = WidthMMOfScreen(Tk_Screen(tkwin));
#endif
		d *= bias[pixelPtr->units] * widthS;
		d /= widthM;
	    }
562
563
564
565
566
567
568
569

570
571

572
573





574
575
576
577
578
579
580
    }

    mmPtr = objPtr->internalRep.twoPtrValue.ptr1;
    if (mmPtr->tkwin != tkwin) {
	d = mmPtr->value;
	if (mmPtr->units == -1) {
#ifdef PLATFORM_SDL
	    int wM, wS;


	    ScreenGetMMWidth(Tk_Display(tkwin), Tk_Screen(tkwin), &wM, &wS);

	    d /= wS;
	    d *= wM;





#else
	    d /= WidthOfScreen(Tk_Screen(tkwin));
	    d *= WidthMMOfScreen(Tk_Screen(tkwin));
#endif
	} else {
	    d *= bias[mmPtr->units];
	}







|
>

|
>


>
>
>
>
>







573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
    }

    mmPtr = objPtr->internalRep.twoPtrValue.ptr1;
    if (mmPtr->tkwin != tkwin) {
	d = mmPtr->value;
	if (mmPtr->units == -1) {
#ifdef PLATFORM_SDL
	    int wM, wS, hM, hS;
	    double d2 = d;

	    ScreenGetMMWidthHeight(Tk_Display(tkwin), Tk_Screen(tkwin),
		    &wM, &wS, &hM, &hS);
	    d /= wS;
	    d *= wM;
	    d2 /= hS;
	    d2 *= hM;
	    if (d2 < d) {
		d = d2;
	    }
#else
	    d /= WidthOfScreen(Tk_Screen(tkwin));
	    d *= WidthMMOfScreen(Tk_Screen(tkwin));
#endif
	} else {
	    d *= bias[mmPtr->units];
	}
Changes to jni/sdl2tk/generic/ttk/ttkDefaultTheme.c.
561
562
563
564
565
566
567
568
569
570





571
572
573
574
575
576
577
578
579
580
581
582
583
584
{
    IndicatorSpec *spec = clientData;
    IndicatorElement *indicator = elementRecord;
    Ttk_Padding margins;
    Display *display = Tk_Display(tkwin);
    int dim;
#ifdef PLATFORM_SDL
    int wM, wS;

    ScreenGetMMWidth(display, DefaultScreenOfDisplay(display), &wM, &wS);





    dim = 2 * wS;
    dim /= wM;
#else
    dim = 2 * WidthOfScreen(DefaultScreenOfDisplay(display));
    dim /= WidthMMOfScreen(DefaultScreenOfDisplay(display));
#endif
    if (dim >= 11) {
	/* more than 140 DPI */
	if (spec == &checkbutton_spec_small) {
	    spec = &checkbutton_spec_large;
	} else if (spec == &radiobutton_spec_small) {
	    spec = &radiobutton_spec_large;
	}
    }







|

|
>
>
>
>
>






|







561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
{
    IndicatorSpec *spec = clientData;
    IndicatorElement *indicator = elementRecord;
    Ttk_Padding margins;
    Display *display = Tk_Display(tkwin);
    int dim;
#ifdef PLATFORM_SDL
    int wM, wS, hM, hS;

    ScreenGetMMWidthHeight(display, DefaultScreenOfDisplay(display),
	    &wM, &wS, &hM, &hS);
    if ((hS/hM) > (wS/wM)) {
	wM = hM;
	wS = hS;
    }
    dim = 2 * wS;
    dim /= wM;
#else
    dim = 2 * WidthOfScreen(DefaultScreenOfDisplay(display));
    dim /= WidthMMOfScreen(DefaultScreenOfDisplay(display));
#endif
    if (((dim >= 11) && (dim < 22)) || (dim >= 33)) {
	/* more than 140 DPI */
	if (spec == &checkbutton_spec_small) {
	    spec = &checkbutton_spec_large;
	} else if (spec == &radiobutton_spec_small) {
	    spec = &radiobutton_spec_large;
	}
    }
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
    XColor *fgColor, *frameColor, *shadeColor, *indicatorColor, *borderColor;
    int index, ix, iy, w, h, dim;
    XGCValues gcValues;
    GC copyGC;
    unsigned long imgColors[8];
    XImage *img;
#ifdef PLATFORM_SDL
    int wM, wS;
#endif

    Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding);
    b = Ttk_PadBox(b, padding);

#ifdef PLATFORM_SDL
    ScreenGetMMWidth(display, DefaultScreenOfDisplay(display), &wM, &wS);





    dim = 2 * wS;
    dim /= wM;
#else
    dim = 2 * WidthOfScreen(DefaultScreenOfDisplay(display));
    dim /= WidthMMOfScreen(DefaultScreenOfDisplay(display));
#endif
    if (dim >= 11) {
	/* more than 140 DPI */
	if (spec == &checkbutton_spec_small) {
	    spec = &checkbutton_spec_large;
	} else if (spec == &radiobutton_spec_small) {
	    spec = &radiobutton_spec_large;
	}
    }







|






|
>
>
>
>
>






|







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
    XColor *fgColor, *frameColor, *shadeColor, *indicatorColor, *borderColor;
    int index, ix, iy, w, h, dim;
    XGCValues gcValues;
    GC copyGC;
    unsigned long imgColors[8];
    XImage *img;
#ifdef PLATFORM_SDL
    int wM, wS, hM, hS;
#endif

    Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding);
    b = Ttk_PadBox(b, padding);

#ifdef PLATFORM_SDL
    ScreenGetMMWidthHeight(display, DefaultScreenOfDisplay(display),
	    &wM, &wS, &hM, &hS);
    if ((hS/hM) > (wS/wM)) {
	wM = hM;
	wS = hS;
    }
    dim = 2 * wS;
    dim /= wM;
#else
    dim = 2 * WidthOfScreen(DefaultScreenOfDisplay(display));
    dim /= WidthMMOfScreen(DefaultScreenOfDisplay(display));
#endif
    if (((dim >= 11) && (dim < 22)) || (dim >= 33)) {
	/* more than 140 DPI */
	if (spec == &checkbutton_spec_small) {
	    spec = &checkbutton_spec_large;
	} else if (spec == &radiobutton_spec_small) {
	    spec = &radiobutton_spec_large;
	}
    }
686
687
688
689
690
691
692
693
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
723
    dim = w;
    w = spec->width;
    h = spec->height;
    for (iy=0 ; iy<h ; iy++) {
	if (dim > w) {
	    for (ix=0 ; ix<w ; ix++) {
		XPutPixel(img, ix*2, iy*2,
		    imgColors[spec->pixels[iy][index*dim+ix] - 'A'] );
		XPutPixel(img, ix*2+1, iy*2,
		    imgColors[spec->pixels[iy][index*dim+ix] - 'A'] );
		XPutPixel(img, ix*2, iy*2+1,
		    imgColors[spec->pixels[iy][index*dim+ix] - 'A'] );
		XPutPixel(img, ix*2+1, iy*2+1,
		    imgColors[spec->pixels[iy][index*dim+ix] - 'A'] );
	    }
	} else {
	    for (ix=0 ; ix<w ; ix++) {
		XPutPixel(img, ix, iy,
		    imgColors[spec->pixels[iy][index*dim+ix] - 'A'] );
	    }
	}
    }





    /*
     * Copy onto our target drawable surface.
     */
    memset(&gcValues, 0, sizeof(gcValues));
    copyGC = Tk_GetGC(tkwin, 0, &gcValues);

    TkPutImage(NULL, 0, display, d, copyGC, img, 0, 0, b.x, b.y,
               spec->width, spec->height);

    /*
     * Tidy up.
     */
    Tk_FreeGC(display, copyGC);
    XDestroyImage(img);
}







|

|

|

|




|



>
>
>
>







|
<







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
723
724
725
726
727
728
729

730
731
732
733
734
735
736
    dim = w;
    w = spec->width;
    h = spec->height;
    for (iy=0 ; iy<h ; iy++) {
	if (dim > w) {
	    for (ix=0 ; ix<w ; ix++) {
		XPutPixel(img, ix*2, iy*2,
		    imgColors[spec->pixels[iy][index*w+ix] - 'A'] );
		XPutPixel(img, ix*2+1, iy*2,
		    imgColors[spec->pixels[iy][index*w+ix] - 'A'] );
		XPutPixel(img, ix*2, iy*2+1,
		    imgColors[spec->pixels[iy][index*w+ix] - 'A'] );
		XPutPixel(img, ix*2+1, iy*2+1,
		    imgColors[spec->pixels[iy][index*w+ix] - 'A'] );
	    }
	} else {
	    for (ix=0 ; ix<w ; ix++) {
		XPutPixel(img, ix, iy,
		    imgColors[spec->pixels[iy][index*w+ix] - 'A'] );
	    }
	}
    }
    if (dim > w) {
	w += spec->width;
	h += spec->height;
    }

    /*
     * Copy onto our target drawable surface.
     */
    memset(&gcValues, 0, sizeof(gcValues));
    copyGC = Tk_GetGC(tkwin, 0, &gcValues);

    TkPutImage(NULL, 0, display, d, copyGC, img, 0, 0, b.x, b.y, w, h);


    /*
     * Tidy up.
     */
    Tk_FreeGC(display, copyGC);
    XDestroyImage(img);
}
Changes to jni/sdl2tk/library/iconlist.tcl.
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
    #	operations.
    #
    method Create {} {
	variable hull
	set sbar [ttk::scrollbar $hull.sbar -orient horizontal -takefocus 0]
	catch {$sbar configure -highlightthickness 0}
	set canvas [canvas $hull.canvas -highlightthick 0 -takefocus 1 \
			-width 400 -height 120 -background white]
	pack $sbar -side bottom -fill x -padx 2 -pady {0 2}
	pack $canvas -expand yes -fill both -padx 2 -pady {2 0}

	$sbar configure -command [list $canvas xview]
	$canvas configure -xscrollcommand [list $sbar set]

	# Initializes the max icon/text width and height and other variables







|







401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
    #	operations.
    #
    method Create {} {
	variable hull
	set sbar [ttk::scrollbar $hull.sbar -orient horizontal -takefocus 0]
	catch {$sbar configure -highlightthickness 0}
	set canvas [canvas $hull.canvas -highlightthick 0 -takefocus 1 \
			-width 400 -height 166 -background white]
	pack $sbar -side bottom -fill x -padx 2 -pady {0 2}
	pack $canvas -expand yes -fill both -padx 2 -pady {2 0}

	$sbar configure -command [list $canvas xview]
	$canvas configure -xscrollcommand [list $sbar set]

	# Initializes the max icon/text width and height and other variables
Changes to jni/sdl2tk/sdl/tkSDLButton.c.
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
    XColor *selectColor,	/* color when selected */
    XColor *disableColor,	/* color when disabled */
    int on,			/* are we on? */
    int disabled,		/* are we disabled? */
    int mode)			/* kind of indicator to draw */
{
    int ix, iy;
    int dim, dimI;
    int imgsel, imgstart;
    TkBorder *bg_brdr = (TkBorder*)bgBorder;
    XGCValues gcValues;
    GC copyGC;
    unsigned long imgColors[8];
    XImage *img;
    Pixmap pixmap;







|







253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
    XColor *selectColor,	/* color when selected */
    XColor *disableColor,	/* color when disabled */
    int on,			/* are we on? */
    int disabled,		/* are we disabled? */
    int mode)			/* kind of indicator to draw */
{
    int ix, iy;
    int dimW, dimWI, dimH, dimHI;
    int imgsel, imgstart;
    TkBorder *bg_brdr = (TkBorder*)bgBorder;
    XGCValues gcValues;
    GC copyGC;
    unsigned long imgColors[8];
    XImage *img;
    Pixmap pixmap;
284
285
286
287
288
289
290
291





292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
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

    if (selectColor == NULL) {
	selectColor = bg_brdr->bgColorPtr;
    }

    depth = Tk_Depth(tkwin);

    ScreenGetMMWidth(display, DefaultScreenOfDisplay(display), &dim, &dimI);





    dimI *= 2;
    dimI /= dim;
    if (dimI < 11) {
	/* < 140 DPI */
	button_images = button_images_small;
	img_dim = &img_dim_small;
    } else {
	button_images = button_images_large;
	img_dim = &img_dim_large;
    }

    /*
     * Compute starting point and dimensions of image inside button_images to
     * be used.
     */

    switch (mode) {
    default:
    case CHECK_BUTTON:
	imgsel = on == 2 ? CHECK_DISON_OFFSET :
		on == 1 ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
	imgsel += disabled && on != 2 ? CHECK_DISOFF_OFFSET : 0;
	imgstart = CHECK_START;
	dim = CHECK_BUTTON_DIM;
	break;

    case CHECK_MENU:
	imgsel = on == 2 ? CHECK_DISOFF_OFFSET :
		on == 1 ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
	imgsel += disabled && on != 2 ? CHECK_DISOFF_OFFSET : 0;
	imgstart = CHECK_START + CHECK_START_YOFFSET;
	imgsel += CHECK_START_XOFFSET;
	dim = CHECK_MENU_DIM;
	break;

    case RADIO_BUTTON:
	imgsel = on == 2 ? RADIO_DISON_OFFSET :
		on==1 ? RADIO_ON_OFFSET : RADIO_OFF_OFFSET;
	imgsel += disabled && on != 2 ? RADIO_DISOFF_OFFSET : 0;
	imgstart = RADIO_START;
	dim = RADIO_BUTTON_DIM;
	break;

    case RADIO_MENU:
	imgsel = on == 2 ? RADIO_DISOFF_OFFSET :
		on==1 ? RADIO_ON_OFFSET : RADIO_OFF_OFFSET;
	imgsel += disabled && on != 2 ? RADIO_DISOFF_OFFSET : 0;
	imgstart = RADIO_START + RADIO_START_YOFFSET;
	imgsel += RADIO_START_XOFFSET;
	dim = RADIO_MENU_DIM;
	break;
    }

    /*
     * Allocate the drawing areas to use. Note that we use double-buffering
     * here because not all code paths leading to this function do so.
     */

    /*
     * Double image when density above 280 DPI.
     */

    if (dimI < 22) {
	dimI = dim;
    } else {
	dimI = dim * 2;
    }

    pixmap = Tk_GetPixmap(display, d, dimI, dimI, depth);
    if (pixmap == None) {
	return;
    }

    x -= dimI/2;
    y -= dimI/2;

    img = XGetImage(display, pixmap, 0, 0,
	    (unsigned int)dimI, (unsigned int)dimI, AllPlanes, ZPixmap);
    if (img == NULL) {
	return;
    }

    /*
     * Set up the color mapping table.
     */







|
>
>
>
>
>
|
|
|




















|








|







|








|












|
|

|


|




|
|


|







284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
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

    if (selectColor == NULL) {
	selectColor = bg_brdr->bgColorPtr;
    }

    depth = Tk_Depth(tkwin);

    ScreenGetMMWidthHeight(display, DefaultScreenOfDisplay(display),
	    &dimW, &dimWI, &dimH, &dimHI);
    if ((dimHI/dimH) > (dimWI/dimW)) {
	dimW = dimH;
	dimWI = dimHI;
    }
    dimWI *= 2;
    dimWI /= dimW;
    if (dimWI < 11) {
	/* < 140 DPI */
	button_images = button_images_small;
	img_dim = &img_dim_small;
    } else {
	button_images = button_images_large;
	img_dim = &img_dim_large;
    }

    /*
     * Compute starting point and dimensions of image inside button_images to
     * be used.
     */

    switch (mode) {
    default:
    case CHECK_BUTTON:
	imgsel = on == 2 ? CHECK_DISON_OFFSET :
		on == 1 ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
	imgsel += disabled && on != 2 ? CHECK_DISOFF_OFFSET : 0;
	imgstart = CHECK_START;
	dimW = CHECK_BUTTON_DIM;
	break;

    case CHECK_MENU:
	imgsel = on == 2 ? CHECK_DISOFF_OFFSET :
		on == 1 ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
	imgsel += disabled && on != 2 ? CHECK_DISOFF_OFFSET : 0;
	imgstart = CHECK_START + CHECK_START_YOFFSET;
	imgsel += CHECK_START_XOFFSET;
	dimW = CHECK_MENU_DIM;
	break;

    case RADIO_BUTTON:
	imgsel = on == 2 ? RADIO_DISON_OFFSET :
		on==1 ? RADIO_ON_OFFSET : RADIO_OFF_OFFSET;
	imgsel += disabled && on != 2 ? RADIO_DISOFF_OFFSET : 0;
	imgstart = RADIO_START;
	dimW = RADIO_BUTTON_DIM;
	break;

    case RADIO_MENU:
	imgsel = on == 2 ? RADIO_DISOFF_OFFSET :
		on==1 ? RADIO_ON_OFFSET : RADIO_OFF_OFFSET;
	imgsel += disabled && on != 2 ? RADIO_DISOFF_OFFSET : 0;
	imgstart = RADIO_START + RADIO_START_YOFFSET;
	imgsel += RADIO_START_XOFFSET;
	dimW = RADIO_MENU_DIM;
	break;
    }

    /*
     * Allocate the drawing areas to use. Note that we use double-buffering
     * here because not all code paths leading to this function do so.
     */

    /*
     * Double image when density above 280 DPI.
     */

    if (dimWI < 22) {
	dimWI = dimW;
    } else {
	dimWI = dimW * 2;
    }

    pixmap = Tk_GetPixmap(display, d, dimWI, dimWI, depth);
    if (pixmap == None) {
	return;
    }

    x -= dimWI/2;
    y -= dimWI/2;

    img = XGetImage(display, pixmap, 0, 0,
	    (unsigned int)dimWI, (unsigned int)dimWI, AllPlanes, ZPixmap);
    if (img == NULL) {
	return;
    }

    /*
     * Set up the color mapping table.
     */
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
    imgColors[7 /*H*/] =
	    Tk_GetColorByValue(tkwin, disableColor)->pixel;

    /*
     * Create the image, painting it into an XImage one pixel at a time.
     */

    for (iy=0 ; iy<dim ; iy++) {
	if (dimI > dim) {
	    for (ix=0 ; ix<dim ; ix++) {
		XPutPixel(img, ix * 2, iy * 2,
		    imgColors[button_images[imgstart+iy][imgsel+ix] - 'A']);
		XPutPixel(img, ix * 2 + 1, iy * 2,
		    imgColors[button_images[imgstart+iy][imgsel+ix] - 'A']);
		XPutPixel(img, ix * 2, iy * 2 + 1,
		    imgColors[button_images[imgstart+iy][imgsel+ix] - 'A']);
		XPutPixel(img, ix * 2 + 1, iy * 2 + 1,
		    imgColors[button_images[imgstart+iy][imgsel+ix] - 'A']);
	    }
	} else {
	    for (ix=0 ; ix<dim ; ix++) {
		XPutPixel(img, ix, iy,
		    imgColors[button_images[imgstart+iy][imgsel+ix] - 'A']);
	    }
	}
    }

    /*
     * Copy onto our target drawable surface.
     */

    memset(&gcValues, 0, sizeof(gcValues));
    gcValues.background = bg_brdr->bgColorPtr->pixel;
    gcValues.graphics_exposures = False;
    copyGC = Tk_GetGC(tkwin, 0, &gcValues);

    XPutImage(display, pixmap, copyGC, img, 0, 0, 0, 0,
	    (unsigned)dimI, (unsigned)dimI);
    XCopyArea(display, pixmap, d, copyGC, 0, 0,
	    (unsigned)dimI, (unsigned)dimI, x, y);

    /*
     * Tidy up.
     */

    Tk_FreeGC(display, copyGC);
    XDestroyImage(img);







|
|
|










|
















|

|







401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
    imgColors[7 /*H*/] =
	    Tk_GetColorByValue(tkwin, disableColor)->pixel;

    /*
     * Create the image, painting it into an XImage one pixel at a time.
     */

    for (iy=0 ; iy<dimW ; iy++) {
	if (dimWI > dimW) {
	    for (ix=0 ; ix<dimW ; ix++) {
		XPutPixel(img, ix * 2, iy * 2,
		    imgColors[button_images[imgstart+iy][imgsel+ix] - 'A']);
		XPutPixel(img, ix * 2 + 1, iy * 2,
		    imgColors[button_images[imgstart+iy][imgsel+ix] - 'A']);
		XPutPixel(img, ix * 2, iy * 2 + 1,
		    imgColors[button_images[imgstart+iy][imgsel+ix] - 'A']);
		XPutPixel(img, ix * 2 + 1, iy * 2 + 1,
		    imgColors[button_images[imgstart+iy][imgsel+ix] - 'A']);
	    }
	} else {
	    for (ix=0 ; ix<dimW ; ix++) {
		XPutPixel(img, ix, iy,
		    imgColors[button_images[imgstart+iy][imgsel+ix] - 'A']);
	    }
	}
    }

    /*
     * Copy onto our target drawable surface.
     */

    memset(&gcValues, 0, sizeof(gcValues));
    gcValues.background = bg_brdr->bgColorPtr->pixel;
    gcValues.graphics_exposures = False;
    copyGC = Tk_GetGC(tkwin, 0, &gcValues);

    XPutImage(display, pixmap, copyGC, img, 0, 0, 0, 0,
	    (unsigned)dimWI, (unsigned)dimWI);
    XCopyArea(display, pixmap, d, copyGC, 0, 0,
	    (unsigned)dimWI, (unsigned)dimWI, x, y);

    /*
     * Tidy up.
     */

    Tk_FreeGC(display, copyGC);
    XDestroyImage(img);
Changes to jni/sdl2tk/sdl/tkSDLMenubu.c.
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
 *----------------------------------------------------------------------
 */

void
TkpComputeMenuButtonGeometry(
    TkMenuButton *mbPtr)	/* Widget record for menu button. */
{
    int width, height, mm, pixels;
    int	avgWidth, txtWidth, txtHeight;
    int haveImage = 0, haveText = 0;
    Tk_FontMetrics fm;

    mbPtr->inset = mbPtr->highlightWidth + mbPtr->borderWidth;

    width = 0;







|







341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
 *----------------------------------------------------------------------
 */

void
TkpComputeMenuButtonGeometry(
    TkMenuButton *mbPtr)	/* Widget record for menu button. */
{
    int width, height;
    int	avgWidth, txtWidth, txtHeight;
    int haveImage = 0, haveText = 0;
    Tk_FontMetrics fm;

    mbPtr->inset = mbPtr->highlightWidth + mbPtr->borderWidth;

    width = 0;
447
448
449
450
451
452
453


454





455
456
457
458
459
460
461
462
463

    if (! haveImage) {
	width += 2*mbPtr->padX;
	height += 2*mbPtr->padY;
    }

    if (mbPtr->indicatorOn) {


	ScreenGetMMWidth(mbPtr->display, Tk_Screen(mbPtr->tkwin), &mm, &pixels);





	mbPtr->indicatorHeight= (INDICATOR_HEIGHT * pixels)/(10*mm);
	mbPtr->indicatorWidth = (INDICATOR_WIDTH * pixels)/(10*mm)
		+ 2*mbPtr->indicatorHeight;
	width += mbPtr->indicatorWidth;
    } else {
	mbPtr->indicatorHeight = 0;
	mbPtr->indicatorWidth = 0;
    }








>
>
|
>
>
>
>
>
|
|







447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470

    if (! haveImage) {
	width += 2*mbPtr->padX;
	height += 2*mbPtr->padY;
    }

    if (mbPtr->indicatorOn) {
	int mmW, mmH, pixW, pixH;

	ScreenGetMMWidthHeight(mbPtr->display, Tk_Screen(mbPtr->tkwin),
		&mmW, &pixW, &mmH, &pixH);
	if ((pixH/mmH) > (pixW/mmW)) {
	    mmW = mmH;
	    pixW = pixH;
	}
	mbPtr->indicatorHeight= (INDICATOR_HEIGHT * pixW)/(10*mmW);
	mbPtr->indicatorWidth = (INDICATOR_WIDTH * pixW)/(10*mmW)
		+ 2*mbPtr->indicatorHeight;
	width += mbPtr->indicatorWidth;
    } else {
	mbPtr->indicatorHeight = 0;
	mbPtr->indicatorWidth = 0;
    }

jni/tcl/generic/tclStrToD.c became a regular file.
jni/tcl/library/clock.tcl became executable.
jni/tcl/unix/configure.in became a regular file.
jni/tcl/win/tclWinFile.c became executable.
Changes to src/org/libsdl/app/SDLActivity.java.
726
727
728
729
730
731
732


733



734

735
736
737
738
739
740
741
            break;
        }

        mWidth = width;
        mHeight = height;
        DisplayMetrics dm = new DisplayMetrics();
        mDisplay.getMetrics(dm);


        SDLActivity.onNativeResize(width, height, sdlFormat,



                                   (int) dm.xdpi, (int) dm.ydpi);

        Log.v(TAG, "Window size: " + width + "x" + height);
        dm = null;

        // Set mIsSurfaceReady to 'true' *before* making a call to handleResume
        SDLActivity.mIsSurfaceReady = true;
        SDLActivity.onNativeSurfaceChanged();








>
>
|
>
>
>
|
>







726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
            break;
        }

        mWidth = width;
        mHeight = height;
        DisplayMetrics dm = new DisplayMetrics();
        mDisplay.getMetrics(dm);
        int rot = mDisplay.getRotation();
        if (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270) {
            SDLActivity.onNativeResize(width, height, sdlFormat,
                                       (int) dm.ydpi, (int) dm.xdpi);
        } else {
            SDLActivity.onNativeResize(width, height, sdlFormat,
                                       (int) dm.xdpi, (int) dm.ydpi);
        }
        Log.v(TAG, "Window size: " + width + "x" + height);
        dm = null;

        // Set mIsSurfaceReady to 'true' *before* making a call to handleResume
        SDLActivity.mIsSurfaceReady = true;
        SDLActivity.onNativeSurfaceChanged();