# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1042846108 0 # Node ID d946e329670c2b293552b4ae355621f6a4a67dc8 # Parent 634625c3239dea9f1d58a9bf8534dc63e5bfaefe Added test application for OS/2, and allow dw_color_xxx_set() to use OS/2 style colors not just RGB. diff -r 634625c3239d -r d946e329670c dwtest.c --- a/dwtest.c Fri Jan 17 20:31:06 2003 +0000 +++ b/dwtest.c Fri Jan 17 23:28:28 2003 +0000 @@ -24,20 +24,21 @@ textbox1, textbox2, buttonbox; -int exit_callback(HWND window, void *data) +int DWSIGNAL exit_callback(HWND window, void *data) { dw_window_destroy((HWND)data); exit(0); return -1; } -int test_callback(HWND window, void *data) +int DWSIGNAL test_callback(HWND window, void *data) { dw_window_destroy((HWND)data); exit(0); return -1; } -int browse_callback(HWND window, void *data) + +int DWSIGNAL browse_callback(HWND window, void *data) { dw_file_browse("test string", NULL, "c", DW_FILE_OPEN ); return 0; @@ -137,11 +138,13 @@ int rows=100,width1=6,width2=50; /* This gets called when a part of the graph needs to be repainted. */ -int text_expose(HWND hwnd, DWExpose *exp, void *data) +int DWSIGNAL text_expose(HWND hwnd, DWExpose *exp, void *data) { HPIXMAP hpm = (HPIXMAP)data; dw_pixmap_bitblt(hwnd, NULL, 0, 0, font_width*width1, font_height*rows, NULL, hpm, 0, 0 ); + dw_flush(); + return TRUE; } void text_add(void) @@ -168,7 +171,6 @@ dw_draw_rect(0, text1pm, TRUE, 0, 0, font_width*width1, font_height*rows); dw_draw_rect(0, text2pm, TRUE, 0, 0, font_width*width2, font_height*rows); - dw_window_set_font(textbox1, "9.WarpSans"); dw_font_text_extents( NULL, text1pm, "O", &font_width, &font_height ); dw_messagebox("DWTest", "Width: %d Height: %d\n", font_width, font_height); @@ -184,7 +186,6 @@ } dw_signal_connect(textbox1, "expose_event", DW_SIGNAL_FUNC(text_expose), text1pm); dw_signal_connect(textbox2, "expose_event", DW_SIGNAL_FUNC(text_expose), text2pm); - dw_flush(); } /* diff -r 634625c3239d -r d946e329670c dwtest.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwtest.def Fri Jan 17 23:28:28 2003 +0000 @@ -0,0 +1,5 @@ +NAME DWTEST WINDOWAPI + +DESCRIPTION 'Sample DW appliaction' + +STACKSIZE 128000 diff -r 634625c3239d -r d946e329670c makefile.vac --- a/makefile.vac Fri Jan 17 20:31:06 2003 +0000 +++ b/makefile.vac Fri Jan 17 23:28:28 2003 +0000 @@ -37,6 +37,16 @@ copy dwcompat.lib lib\dwcompat.lib copy dwcompat.dll dll\dwcompat.dll +dwtest.obj: + icc /Ti /DOS2 /DTCPV40HDRS /Sp1 /I. /I..\ipformat /I..\include /Sm /Ss /Q /Gm /Gt /C dwtest.c +dwtest.exe: dwtest.obj + icc @<< + /B" /DE /optfunc" + /Fedwtest.exe + lib\dw.lib lib\dwcompat.lib + dwtest.obj + dwtest.def +<< clean : @if exist *.obj del *.obj @if exist *.map del *.map diff -r 634625c3239d -r d946e329670c os2/dw.c --- a/os2/dw.c Fri Jan 17 20:31:06 2003 +0000 +++ b/os2/dw.c Fri Jan 17 23:28:28 2003 +0000 @@ -905,6 +905,16 @@ } } +/* Return the OS/2 color from the DW color */ +unsigned long _internal_color(unsigned long color) +{ + if(color == DW_CLR_BLACK) + return CLR_BLACK; + if(color == DW_CLR_WHITE) + return CLR_WHITE; + return color; +} + /* This function calculates how much space the widgets and boxes require * and does expansion as necessary. */ @@ -3376,10 +3386,7 @@ } else if(fore != DW_CLR_DEFAULT) { - if(fore == DW_CLR_BLACK) - fore = CLR_BLACK; - if(fore == DW_CLR_WHITE) - fore = CLR_WHITE; + fore = _internal_color(fore); WinSetPresParam(handle, PP_FOREGROUNDCOLORINDEX, sizeof(ULONG), &fore); } @@ -3397,10 +3404,7 @@ } else if(back != DW_CLR_DEFAULT) { - if(back == DW_CLR_BLACK) - back = CLR_BLACK; - if(back == DW_CLR_WHITE) - back = CLR_WHITE; + back = _internal_color(back); WinSetPresParam(handle, PP_BACKGROUNDCOLORINDEX, sizeof(ULONG), &back); } @@ -6184,7 +6188,7 @@ */ void API dw_color_foreground_set(unsigned long value) { - _foreground = DW_RED_VALUE(value) << 16 | DW_GREEN_VALUE(value) << 8 | DW_BLUE_VALUE(value); + _foreground = value; } /* Sets the current background drawing color. @@ -6195,7 +6199,7 @@ */ void API dw_color_background_set(unsigned long value) { - _background = DW_RED_VALUE(value) << 16 | DW_GREEN_VALUE(value) << 8 | DW_BLUE_VALUE(value); + _background = value; } HPS _set_hps(HPS hps) @@ -6204,8 +6208,8 @@ GpiQueryLogColorTable(hps, 0L, 0L, 18L, alTable); - alTable[16] = _foreground; - alTable[17] = _background; + alTable[16] = DW_RED_VALUE(_foreground) << 16 | DW_GREEN_VALUE(_foreground) << 8 | DW_BLUE_VALUE(_foreground); + alTable[17] = DW_RED_VALUE(_background) << 16 | DW_GREEN_VALUE(_background) << 8 | DW_BLUE_VALUE(_background); GpiCreateLogColorTable(hps, 0L, @@ -6213,8 +6217,14 @@ 0L, 18, alTable); - GpiSetColor(hps, 16); - GpiSetBackColor(hps, 17); + if(_foreground & DW_RGB_COLOR) + GpiSetColor(hps, 16); + else + GpiSetColor(hps, _internal_color(_foreground)); + if(_background & DW_RGB_COLOR) + GpiSetBackColor(hps, 17); + else + GpiSetBackColor(hps, _internal_color(_background)); return hps; }