From fc35dfd2773dfa7b909f45cf5f1a24dc720c17a6 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Tue, 28 Oct 2014 18:31:10 -0500 Subject: [PATCH] WINGs: Fix decimal/hexadecimal conversion bug in color panel. In particular, the values were only being converted when the RGB slider was used to pick the color. If another tool was used, e.g., the magnifying glass, th e value was assumed to be decimal, even if hexadecimal was selected. --- WINGs/wcolorpanel.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/WINGs/wcolorpanel.c b/WINGs/wcolorpanel.c index b2c3e77a..0b3fc159 100644 --- a/WINGs/wcolorpanel.c +++ b/WINGs/wcolorpanel.c @@ -3391,6 +3391,7 @@ static void grayInit(W_ColorPanel * panel) static void rgbInit(W_ColorPanel * panel) { char tmp[4]; + const char *format; if (panel->color.set != cpRGB) convertCPColor(&panel->color); @@ -3399,11 +3400,20 @@ static void rgbInit(W_ColorPanel * panel) WMSetSliderValue(panel->rgbGreenS, panel->color.rgb.green); WMSetSliderValue(panel->rgbBlueS, panel->color.rgb.blue); - sprintf(tmp, "%d", panel->color.rgb.red); + switch (panel->rgbState) { + case RGBdec: + format = "%d"; + break; + case RGBhex: + format = "%0X"; + break; + } + + sprintf(tmp, format, panel->color.rgb.red); WMSetTextFieldText(panel->rgbRedT, tmp); - sprintf(tmp, "%d", panel->color.rgb.green); + sprintf(tmp, format, panel->color.rgb.green); WMSetTextFieldText(panel->rgbGreenT, tmp); - sprintf(tmp, "%d", panel->color.rgb.blue); + sprintf(tmp, format, panel->color.rgb.blue); WMSetTextFieldText(panel->rgbBlueT, tmp); }