From a14a7a0ccc9de76aeab0b2e4bbf58f1a79deedc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 3 Jul 2024 10:19:30 +0200 Subject: New upstream version 5.3.0GA --- app/wlib/mswlib/mswcolor.c | 124 +++++++++++++++++++++++++-------------------- 1 file changed, 69 insertions(+), 55 deletions(-) (limited to 'app/wlib/mswlib/mswcolor.c') diff --git a/app/wlib/mswlib/mswcolor.c b/app/wlib/mswlib/mswcolor.c index fb9b0ba..f28e298 100644 --- a/app/wlib/mswlib/mswcolor.c +++ b/app/wlib/mswlib/mswcolor.c @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -34,16 +33,17 @@ static void mswGetCustomColors( void ); static struct { - WORD palVersion; - WORD palNumEntries; - PALETTEENTRY palPalEntry[NUM_COLORS]; - } colorPalette = { - 0x300, - 2, - { + WORD palVersion; + WORD palNumEntries; + PALETTEENTRY palPalEntry[NUM_COLORS]; +} colorPalette = { + 0x300, + 2, + { { 255, 255, 255 }, /* White */ { 0, 0, 0 } /* Black */ - } }; + } +}; static long flipRGB( long rgb ) @@ -68,8 +68,10 @@ static void getpalette( void ) cnt = GetDeviceCaps(hdc, SIZEPALETTE); GetSystemPaletteEntries( hdc, 0, cnt, pe ); f = fopen( "palette.txt", "w" ); - for (inx=0;inx NUM_GRAYS ) + } else if ( n > NUM_GRAYS ) { return wDrawColorWhite; - else { + } else { n = (n*256)/NUM_GRAYS; return wDrawFindColor( wRGB(n,n,n) ); } } wDrawColor wDrawFindColor( - long rgb0 ) + long rgb0 ) { static long saved_rgb = wRGB(255,255,255); static wDrawColor saved_color = 0; int r0, g0, b0; - if (rgb0 == saved_rgb) + if (rgb0 == saved_rgb) { return saved_color; + } r0 = (int)(rgb0>>16)&0xFF; g0 = (int)(rgb0>>8)&0xFF; b0 = (int)(rgb0)&0xFF; @@ -210,7 +219,7 @@ wDrawColor wDrawFindColor( long wDrawGetRGB( - wDrawColor color ) + wDrawColor color ) { long rgb; int r, g, b; @@ -259,8 +268,8 @@ void mswPutCustomColors( void ) wBool_t wColorSelect( - const char * title, - wDrawColor * color ) + const char * title, + wDrawColor * color ) { long rgb; @@ -285,18 +294,18 @@ wBool_t wColorSelect( typedef struct { - wDrawColor * valueP; - wColorSelectButtonCallBack_p action; - const char * labelStr; - void * data; - wDrawColor color; - wButton_p button; - wIcon_p bm; - } colorData_t; + wDrawColor * valueP; + wColorSelectButtonCallBack_p action; + const char * labelStr; + void * data; + wDrawColor color; + wButton_p button; + wIcon_p bm; +} colorData_t; static void doColorButton( - void * data ) + void * data ) { colorData_t * cd = (colorData_t*)data; wDrawColor newColor; @@ -305,30 +314,33 @@ static void doColorButton( if (wColorSelect( cd->labelStr, &newColor )) { cd->color = newColor; wColorSelectButtonSetColor( cd->button, newColor ); - if (cd->valueP) + if (cd->valueP) { *cd->valueP = newColor; - if (cd->action) + } + if (cd->action) { cd->action( cd->data, newColor ); + } } } wButton_p wColorSelectButtonCreate( - wWin_p win, - wWinPix_t x, - wWinPix_t y, - const char * helpStr, - const char * labelStr, - long option, - wWinPix_t width, - wDrawColor * color, - wColorSelectButtonCallBack_p action, - void * data ) + wWin_p win, + wWinPix_t x, + wWinPix_t y, + const char * helpStr, + const char * labelStr, + long option, + wWinPix_t width, + wDrawColor * color, + wColorSelectButtonCallBack_p action, + void * data ) { wButton_p bb; wIcon_p bm; colorData_t * cd; - bm = wIconCreateBitMap( square10_width, square10_height, square10_bits, (color?*color:0) ); + bm = wIconCreateBitMap( square10_width, square10_height, square10_bits, + (color?*color:0) ); cd = malloc( sizeof *cd ); cd->valueP = color; cd->action = action; @@ -336,17 +348,19 @@ wButton_p wColorSelectButtonCreate( cd->labelStr = labelStr; cd->color = (color?*color:0); cd->bm = bm; - bb = wButtonCreate( win, x, y, helpStr, (char*)bm, option|BO_ICON, width, doColorButton, cd ); + bb = wButtonCreate( win, x, y, helpStr, (char*)bm, option|BO_ICON, width, + doColorButton, cd ); cd->button = bb; - if ( labelStr ) - wControlSetLabel( (wControl_p)bb, labelStr ); + if ( labelStr ) { + wControlSetLabel( (wControl_p)bb, labelStr ); + } return bb; } void wColorSelectButtonSetColor( - wButton_p bb, - wDrawColor color ) + wButton_p bb, + wDrawColor color ) { ((colorData_t*)((wControl_p)bb)->data)->color = color; wIconSetColor( ((colorData_t*)((wControl_p)bb)->data)->bm, color ); @@ -355,7 +369,7 @@ void wColorSelectButtonSetColor( wDrawColor wColorSelectButtonGetColor( - wButton_p bb ) + wButton_p bb ) { return ((colorData_t*)((wControl_p)bb)->data)->color; } -- cgit v1.2.3