comparison os2/dw.c @ 192:d946e329670c

Added test application for OS/2, and allow dw_color_xxx_set() to use OS/2 style colors not just RGB.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 17 Jan 2003 23:28:28 +0000
parents f4c9fa77136a
children b023d363fc09
comparison
equal deleted inserted replaced
191:634625c3239d 192:d946e329670c
901 } 901 }
902 page = (ULONG)WinSendMsg(hwnd, BKM_QUERYPAGEID, (MPARAM)page, MPFROM2SHORT(BKA_NEXT, BKA_MAJOR)); 902 page = (ULONG)WinSendMsg(hwnd, BKM_QUERYPAGEID, (MPARAM)page, MPFROM2SHORT(BKA_NEXT, BKA_MAJOR));
903 } 903 }
904 904
905 } 905 }
906 }
907
908 /* Return the OS/2 color from the DW color */
909 unsigned long _internal_color(unsigned long color)
910 {
911 if(color == DW_CLR_BLACK)
912 return CLR_BLACK;
913 if(color == DW_CLR_WHITE)
914 return CLR_WHITE;
915 return color;
906 } 916 }
907 917
908 /* This function calculates how much space the widgets and boxes require 918 /* This function calculates how much space the widgets and boxes require
909 * and does expansion as necessary. 919 * and does expansion as necessary.
910 */ 920 */
3374 WinSetPresParam(handle, PP_FOREGROUNDCOLOR, sizeof(RGB2), &rgb2); 3384 WinSetPresParam(handle, PP_FOREGROUNDCOLOR, sizeof(RGB2), &rgb2);
3375 3385
3376 } 3386 }
3377 else if(fore != DW_CLR_DEFAULT) 3387 else if(fore != DW_CLR_DEFAULT)
3378 { 3388 {
3379 if(fore == DW_CLR_BLACK) 3389 fore = _internal_color(fore);
3380 fore = CLR_BLACK;
3381 if(fore == DW_CLR_WHITE)
3382 fore = CLR_WHITE;
3383 3390
3384 WinSetPresParam(handle, PP_FOREGROUNDCOLORINDEX, sizeof(ULONG), &fore); 3391 WinSetPresParam(handle, PP_FOREGROUNDCOLORINDEX, sizeof(ULONG), &fore);
3385 } 3392 }
3386 if((back & DW_RGB_COLOR) == DW_RGB_COLOR) 3393 if((back & DW_RGB_COLOR) == DW_RGB_COLOR)
3387 { 3394 {
3395 WinSetPresParam(handle, PP_BACKGROUNDCOLOR, sizeof(RGB2), &rgb2); 3402 WinSetPresParam(handle, PP_BACKGROUNDCOLOR, sizeof(RGB2), &rgb2);
3396 return 0; 3403 return 0;
3397 } 3404 }
3398 else if(back != DW_CLR_DEFAULT) 3405 else if(back != DW_CLR_DEFAULT)
3399 { 3406 {
3400 if(back == DW_CLR_BLACK) 3407 back = _internal_color(back);
3401 back = CLR_BLACK;
3402 if(back == DW_CLR_WHITE)
3403 back = CLR_WHITE;
3404 3408
3405 WinSetPresParam(handle, PP_BACKGROUNDCOLORINDEX, sizeof(ULONG), &back); 3409 WinSetPresParam(handle, PP_BACKGROUNDCOLORINDEX, sizeof(ULONG), &back);
3406 } 3410 }
3407 return 0; 3411 return 0;
3408 } 3412 }
6182 * green: green value. 6186 * green: green value.
6183 * blue: blue value. 6187 * blue: blue value.
6184 */ 6188 */
6185 void API dw_color_foreground_set(unsigned long value) 6189 void API dw_color_foreground_set(unsigned long value)
6186 { 6190 {
6187 _foreground = DW_RED_VALUE(value) << 16 | DW_GREEN_VALUE(value) << 8 | DW_BLUE_VALUE(value); 6191 _foreground = value;
6188 } 6192 }
6189 6193
6190 /* Sets the current background drawing color. 6194 /* Sets the current background drawing color.
6191 * Parameters: 6195 * Parameters:
6192 * red: red value. 6196 * red: red value.
6193 * green: green value. 6197 * green: green value.
6194 * blue: blue value. 6198 * blue: blue value.
6195 */ 6199 */
6196 void API dw_color_background_set(unsigned long value) 6200 void API dw_color_background_set(unsigned long value)
6197 { 6201 {
6198 _background = DW_RED_VALUE(value) << 16 | DW_GREEN_VALUE(value) << 8 | DW_BLUE_VALUE(value); 6202 _background = value;
6199 } 6203 }
6200 6204
6201 HPS _set_hps(HPS hps) 6205 HPS _set_hps(HPS hps)
6202 { 6206 {
6203 LONG alTable[18]; 6207 LONG alTable[18];
6204 6208
6205 GpiQueryLogColorTable(hps, 0L, 0L, 18L, alTable); 6209 GpiQueryLogColorTable(hps, 0L, 0L, 18L, alTable);
6206 6210
6207 alTable[16] = _foreground; 6211 alTable[16] = DW_RED_VALUE(_foreground) << 16 | DW_GREEN_VALUE(_foreground) << 8 | DW_BLUE_VALUE(_foreground);
6208 alTable[17] = _background; 6212 alTable[17] = DW_RED_VALUE(_background) << 16 | DW_GREEN_VALUE(_background) << 8 | DW_BLUE_VALUE(_background);
6209 6213
6210 GpiCreateLogColorTable(hps, 6214 GpiCreateLogColorTable(hps,
6211 0L, 6215 0L,
6212 LCOLF_CONSECRGB, 6216 LCOLF_CONSECRGB,
6213 0L, 6217 0L,
6214 18, 6218 18,
6215 alTable); 6219 alTable);
6216 GpiSetColor(hps, 16); 6220 if(_foreground & DW_RGB_COLOR)
6217 GpiSetBackColor(hps, 17); 6221 GpiSetColor(hps, 16);
6222 else
6223 GpiSetColor(hps, _internal_color(_foreground));
6224 if(_background & DW_RGB_COLOR)
6225 GpiSetBackColor(hps, 17);
6226 else
6227 GpiSetBackColor(hps, _internal_color(_background));
6218 return hps; 6228 return hps;
6219 } 6229 }
6220 6230
6221 HPS _set_colors(HWND handle) 6231 HPS _set_colors(HWND handle)
6222 { 6232 {