From e5099d96090e2bd20f1cbeb5b53eed06149db28c Mon Sep 17 00:00:00 2001 From: csaba Date: Wed, 15 Mar 2023 12:25:33 +0000 Subject: Code simplification in tkUnixButton.c --- unix/tkUnixButton.c | 112 ++++++++++++++-------------------------------------- 1 file changed, 30 insertions(+), 82 deletions(-) diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c index 25f99d4..c67f1fa 100644 --- a/unix/tkUnixButton.c +++ b/unix/tkUnixButton.c @@ -66,90 +66,42 @@ const Tk_ClassProcs tkpButtonProcs = { static const char checkbtnOffData[] = "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" + " \n" + " \n" + " \n" ""; static const char checkbtnOnData[] = "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" + " \n" + " \n" + " \n" + " \n" ""; static const char radiobtnOffData[] = "\n" " \n" - " \n" + " \n" " \n" - " \n" + " \n" " \n" " \n" - " \n" - " \n" - " \n" - " \n" + " \n" + " \n" ""; static const char radiobtnOnData[] = "\n" " \n" - " \n" + " \n" " \n" - " \n" + " \n" " \n" " \n" - " \n" - " \n" - " \n" - " \n" - " \n" + " \n" + " \n" + " \n" ""; static const char menuOffData[] = @@ -157,12 +109,12 @@ static const char menuOffData[] = static const char checkmenuOnData[] = "\n" - " \n" + " \n" ""; static const char radiomenuOnData[] = "\n" - " \n" + " \n" ""; @@ -221,12 +173,12 @@ TkpDrawCheckIndicator( const char *svgDataPtr; int hasBorder, hasInterior, dim; TkBorder *bg_brdr = (TkBorder*)bgBorder; - char borderColorStr[7], lightColorStr[7], interiorColorStr[7], indicatorColorStr[7]; + char darkColorStr[7], lightColorStr[7], interiorColorStr[7], indicatorColorStr[7]; char imgName[60]; Tk_Image img; size_t svgDataLen; char *svgDataCopy; - char *borderColorPtr, *lightColorPtr, *interiorColorPtr, *indicatorColorPtr; + char *darkColorPtr, *lightColorPtr, *interiorColorPtr, *indicatorColorPtr; Tcl_Interp *interp = Tk_Interp(tkwin); const char *cmdFmt; size_t scriptSize; @@ -285,17 +237,17 @@ TkpDrawCheckIndicator( } /* - * Construct the color strings borderColorStr, + * Construct the color strings darkColorStr, lightColorStr, * interiorColorStr, and indicatorColorStr */ TkpGetShadows(bg_brdr, tkwin); if (bg_brdr->darkColorPtr == NULL) { - strcpy(borderColorStr, "000000"); + strcpy(darkColorStr, "000000"); } else { ColorToStr(Tk_GetColorByValue(tkwin, bg_brdr->darkColorPtr), - borderColorStr); + darkColorStr); } if (bg_brdr->lightColorPtr == NULL) { strcpy(lightColorStr, "ffffff"); @@ -322,7 +274,7 @@ TkpDrawCheckIndicator( snprintf(imgName, sizeof(imgName), "::tk::icons::indicator%d_%s_%s_%s_%s", mode, - hasBorder ? borderColorStr : "XXXXXX", + hasBorder ? darkColorStr : "XXXXXX", hasBorder ? lightColorStr : "XXXXXX", hasInterior ? interiorColorStr : "XXXXXX", on ? indicatorColorStr : "XXXXXX"); @@ -346,26 +298,22 @@ TkpDrawCheckIndicator( * Update the colors within svgDataCopy */ - borderColorPtr = strstr(svgDataPtr, "DARKKK"); + darkColorPtr = strstr(svgDataPtr, "DARKKK"); lightColorPtr = strstr(svgDataPtr, "LIGHTT"); interiorColorPtr = strstr(svgDataPtr, "INTROR"); indicatorColorPtr = strstr(svgDataPtr, "INDCTR"); - while (borderColorPtr != NULL) { - memcpy(borderColorPtr, borderColorStr, 6); - borderColorPtr = strstr(borderColorPtr, "DARKKK"); + if (darkColorPtr != NULL) { + memcpy(darkColorPtr, darkColorStr, 6); } - while (lightColorPtr != NULL) { + if (lightColorPtr != NULL) { memcpy(lightColorPtr, lightColorStr, 6); - lightColorPtr = strstr(lightColorPtr, "LIGHTT"); } - while (interiorColorPtr != NULL) { + if (interiorColorPtr != NULL) { memcpy(interiorColorPtr, interiorColorStr, 6); - interiorColorPtr = strstr(interiorColorPtr, "INTROR"); } - while (indicatorColorPtr != NULL) { + if (indicatorColorPtr != NULL) { memcpy(indicatorColorPtr, indicatorColorStr, 6); - indicatorColorPtr = strstr(indicatorColorPtr, "INDCTR"); } /* -- cgit v0.12