# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1036708262 0 # Node ID 840c5476630641b67a4ad7f027de67430f7de81f # Parent 7f8fcce45bdd7d2af1710b71fa3c82c56b870e4c Another sync of sources, enhancements to dw_window_set_color() ... works completely on Windows now and added DW_CLR_DEFAULT. Also color pairs don't need to be of the same type anymore. diff -r 7f8fcce45bdd -r 840c54766306 dw.h --- a/dw.h Thu Nov 07 06:21:29 2002 +0000 +++ b/dw.h Thu Nov 07 22:31:02 2002 +0000 @@ -54,6 +54,7 @@ #define DW_CLR_WHITE 16 #define DW_CLR_BLACK 17 +#define DW_CLR_DEFAULT 18 #define DW_CLR_BLUE CLR_BLUE #define DW_CLR_RED CLR_RED #define DW_CLR_PINK CLR_PINK @@ -203,6 +204,7 @@ #define DW_CLR_PINK 13 #define DW_CLR_CYAN 14 #define DW_CLR_WHITE 15 +#define DW_CLR_DEFAULT 16 #define DW_FCF_TITLEBAR WS_CAPTION #define DW_FCF_SYSMENU WS_SYSMENU @@ -414,6 +416,7 @@ #define DW_CLR_PINK 13 #define DW_CLR_CYAN 14 #define DW_CLR_WHITE 15 +#define DW_CLR_DEFAULT 16 #define DW_FCF_TITLEBAR 1 #define DW_FCF_SYSMENU (1 << 1) diff -r 7f8fcce45bdd -r 840c54766306 gtk/dw.c --- a/gtk/dw.c Thu Nov 07 06:21:29 2002 +0000 +++ b/gtk/dw.c Thu Nov 07 22:31:02 2002 +0000 @@ -1324,89 +1324,101 @@ int _set_color(HWND handle, unsigned long fore, unsigned long back) { + /* Remember that each color component in X11 use 16 bit no matter + * what the destination display supports. (and thus GDK) + */ + GdkColor forecolor, backcolor; #if GTK_MAJOR_VERSION < 2 - GtkStyle *style; + GtkStyle *style = gtk_style_copy(gtk_widget_get_style(handle)); #endif - if(fore & DW_RGB_COLOR || back & DW_RGB_COLOR) - { - /* Remember that each color component in X11 use 16 bit no matter - * what the destination display supports. (and thus GDK) - */ - GdkColor forecolor = { 0, DW_RED_VALUE(fore) << 8, DW_GREEN_VALUE(fore) << 8, DW_BLUE_VALUE(fore) << 8 }; - GdkColor backcolor = { 0, DW_RED_VALUE(back) << 8, DW_GREEN_VALUE(back) << 8, DW_BLUE_VALUE(back) << 8 }; + if(fore & DW_RGB_COLOR) + { + forecolor.pixel = 0; + forecolor.red = DW_RED_VALUE(fore) << 8; + forecolor.green = DW_GREEN_VALUE(fore) << 8; + forecolor.blue = DW_BLUE_VALUE(fore) << 8; gdk_color_alloc(_dw_cmap, &forecolor); - gdk_color_alloc(_dw_cmap, &backcolor); #if GTK_MAJOR_VERSION > 1 gtk_widget_modify_text(handle, 0, &forecolor); gtk_widget_modify_text(handle, 1, &forecolor); gtk_widget_modify_fg(handle, 0, &forecolor); gtk_widget_modify_fg(handle, 1, &forecolor); +#else + if(style) + style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = forecolor; +#endif + } + else if(fore != DW_CLR_DEFAULT) + { + forecolor = _colors[fore]; + +#if GTK_MAJOR_VERSION > 1 + gtk_widget_modify_text(handle, 0, &_colors[fore]); + gtk_widget_modify_text(handle, 1, &_colors[fore]); + gtk_widget_modify_fg(handle, 0, &_colors[fore]); + gtk_widget_modify_fg(handle, 1, &_colors[fore]); +#else + if(style) + style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = _colors[fore]; +#endif + } + if(back & DW_RGB_COLOR) + { + backcolor.pixel = 0; + backcolor.red = DW_RED_VALUE(back) << 8; + backcolor.green = DW_GREEN_VALUE(back) << 8; + backcolor.blue = DW_BLUE_VALUE(back) << 8; + + gdk_color_alloc(_dw_cmap, &backcolor); + +#if GTK_MAJOR_VERSION > 1 gtk_widget_modify_base(handle, 0, &backcolor); gtk_widget_modify_base(handle, 1, &backcolor); gtk_widget_modify_bg(handle, 0, &backcolor); gtk_widget_modify_bg(handle, 1, &backcolor); #else - style = gtk_style_copy(gtk_widget_get_style(handle)); if(style) - { - style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = forecolor; style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = backcolor; - gtk_widget_set_style(handle, style); - gtk_style_unref(style); - } #endif - - _save_gdk_colors(handle, forecolor, backcolor); - - if(GTK_IS_CLIST(handle)) - { - int z, rowcount = (int)gtk_object_get_data(GTK_OBJECT(handle), "rowcount"); - - for(z=0;z 1 - gtk_widget_modify_text(handle, 0, &_colors[fore]); - gtk_widget_modify_text(handle, 1, &_colors[fore]); - gtk_widget_modify_fg(handle, 0, &_colors[fore]); - gtk_widget_modify_fg(handle, 1, &_colors[fore]); gtk_widget_modify_base(handle, 0, &_colors[back]); gtk_widget_modify_base(handle, 1, &_colors[back]); gtk_widget_modify_bg(handle, 0, &_colors[back]); gtk_widget_modify_bg(handle, 1, &_colors[back]); #else - style = gtk_style_copy(gtk_widget_get_style(handle)); if(style) - { - style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = _colors[fore]; style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = _colors[back]; - gtk_widget_set_style(handle, style); - } #endif - - _save_gdk_colors(handle, _colors[fore], _colors[back]); - - if(GTK_IS_CLIST(handle)) + } + + _save_gdk_colors(handle, forecolor, backcolor); + + if(GTK_IS_CLIST(handle)) + { + int z, rowcount = (int)gtk_object_get_data(GTK_OBJECT(handle), "rowcount"); + + for(z=0;zfore != -1 && thiscinfo->back != -1) { - if(thiscinfo->fore > -1 && thiscinfo->back > -1 && - thiscinfo->fore < 18 && thiscinfo->back < 18) + /* Handle foreground */ + if(thiscinfo->fore > -1 && thiscinfo->fore < 18) { - SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore], - _green[thiscinfo->fore], - _blue[thiscinfo->fore])); - SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back], - _green[thiscinfo->back], - _blue[thiscinfo->back])); - if(thiscinfo->hbrush) - DeleteObject(thiscinfo->hbrush); - thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back], - _green[thiscinfo->back], - _blue[thiscinfo->back])); - SelectObject((HDC)mp1, thiscinfo->hbrush); - return (LONG)thiscinfo->hbrush; + if(thiscinfo->fore != DW_CLR_DEFAULT) + { + SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore], + _green[thiscinfo->fore], + _blue[thiscinfo->fore])); + } } - if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR && (thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR) + else if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR) { SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore), DW_GREEN_VALUE(thiscinfo->fore), DW_BLUE_VALUE(thiscinfo->fore))); + } + /* Handle background */ + if(thiscinfo->back > -1 && thiscinfo->back < 18) + { + if(thiscinfo->back == DW_CLR_DEFAULT) + { + HBRUSH hbr = GetSysColorBrush(COLOR_3DFACE); + + SelectObject((HDC)mp1, hbr); + return (LONG)hbr; + } + else + { + SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back], + _green[thiscinfo->back], + _blue[thiscinfo->back])); + if(thiscinfo->hbrush) + DeleteObject(thiscinfo->hbrush); + thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back], + _green[thiscinfo->back], + _blue[thiscinfo->back])); + SelectObject((HDC)mp1, thiscinfo->hbrush); + } + return (LONG)thiscinfo->hbrush; + } + else if((thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR) + { SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back), DW_GREEN_VALUE(thiscinfo->back), DW_BLUE_VALUE(thiscinfo->back))); @@ -1588,38 +1608,56 @@ HDC hdcPaint = BeginPaint(hWnd, &ps); int success = FALSE; - if(thiscinfo->fore > -1 && thiscinfo->back > -1 && - thiscinfo->fore < 18 && thiscinfo->back < 18) + if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1) { - SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore], - _green[thiscinfo->fore], - _blue[thiscinfo->fore])); - SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back], - _green[thiscinfo->back], - _blue[thiscinfo->back])); - DeleteObject(thiscinfo->hbrush); - thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back], - _green[thiscinfo->back], - _blue[thiscinfo->back])); - SelectObject(hdcPaint, thiscinfo->hbrush); - Rectangle(hdcPaint, ps.rcPaint.left - 1, ps.rcPaint.top - 1, ps.rcPaint.right + 1, ps.rcPaint.bottom + 1); - success = TRUE; - } - if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR && (thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR) - { - SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore), - DW_GREEN_VALUE(thiscinfo->fore), - DW_BLUE_VALUE(thiscinfo->fore))); - SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back), - DW_GREEN_VALUE(thiscinfo->back), - DW_BLUE_VALUE(thiscinfo->back))); - DeleteObject(thiscinfo->hbrush); - thiscinfo->hbrush = CreateSolidBrush(RGB(DW_RED_VALUE(thiscinfo->back), - DW_GREEN_VALUE(thiscinfo->back), - DW_BLUE_VALUE(thiscinfo->back))); - SelectObject(hdcPaint, thiscinfo->hbrush); - Rectangle(hdcPaint, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom); - success = TRUE; + /* Handle foreground */ + if(thiscinfo->fore > -1 && thiscinfo->fore < 18) + { + if(thiscinfo->fore != DW_CLR_DEFAULT) + { + SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore], + _green[thiscinfo->fore], + _blue[thiscinfo->fore])); + } + } + else if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR) + { + SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore), + DW_GREEN_VALUE(thiscinfo->fore), + DW_BLUE_VALUE(thiscinfo->fore))); + } + /* Handle background */ + if(thiscinfo->back > -1 && thiscinfo->back < 18) + { + if(thiscinfo->back != DW_CLR_DEFAULT) + { + SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back], + _green[thiscinfo->back], + _blue[thiscinfo->back])); + if(thiscinfo->hbrush) + DeleteObject(thiscinfo->hbrush); + thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back], + _green[thiscinfo->back], + _blue[thiscinfo->back])); + SelectObject(hdcPaint, thiscinfo->hbrush); + Rectangle(hdcPaint, ps.rcPaint.left - 1, ps.rcPaint.top - 1, ps.rcPaint.right + 1, ps.rcPaint.bottom + 1); + success = TRUE; + } + } + else if((thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR) + { + SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back), + DW_GREEN_VALUE(thiscinfo->back), + DW_BLUE_VALUE(thiscinfo->back))); + if(thiscinfo->hbrush) + DeleteObject(thiscinfo->hbrush); + thiscinfo->hbrush = CreateSolidBrush(RGB(DW_RED_VALUE(thiscinfo->back), + DW_GREEN_VALUE(thiscinfo->back), + DW_BLUE_VALUE(thiscinfo->back))); + SelectObject(hdcPaint, thiscinfo->hbrush); + Rectangle(hdcPaint, ps.rcPaint.left - 1, ps.rcPaint.top - 1, ps.rcPaint.right + 1, ps.rcPaint.bottom + 1); + success = TRUE; + } } EndPaint(hWnd, &ps); @@ -1937,28 +1975,51 @@ ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong((HWND)mp2, GWL_USERDATA); if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1) { - if(thiscinfo->fore > -1 && thiscinfo->back > -1 && - thiscinfo->fore < 18 && thiscinfo->back < 18) + /* Handle foreground */ + if(thiscinfo->fore > -1 && thiscinfo->fore < 18) { - SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore], - _green[thiscinfo->fore], - _blue[thiscinfo->fore])); - SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back], - _green[thiscinfo->back], - _blue[thiscinfo->back])); - if(thiscinfo->hbrush) - DeleteObject(thiscinfo->hbrush); - thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back], - _green[thiscinfo->back], - _blue[thiscinfo->back])); - SelectObject((HDC)mp1, thiscinfo->hbrush); - return (LONG)thiscinfo->hbrush; + if(thiscinfo->fore != DW_CLR_DEFAULT) + { + SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore], + _green[thiscinfo->fore], + _blue[thiscinfo->fore])); + } } - if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR && (thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR) + else if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR) { SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore), DW_GREEN_VALUE(thiscinfo->fore), DW_BLUE_VALUE(thiscinfo->fore))); + } + /* Handle background */ + if(thiscinfo->back > -1 && thiscinfo->back < 18) + { + if(thiscinfo->back == DW_CLR_DEFAULT) + { + HBRUSH hbr = GetSysColorBrush(COLOR_3DFACE); + + SetBkColor((HDC)mp1, GetSysColor(COLOR_3DFACE)); + + + SelectObject((HDC)mp1, hbr); + return (LONG)hbr; + } + else + { + SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back], + _green[thiscinfo->back], + _blue[thiscinfo->back])); + if(thiscinfo->hbrush) + DeleteObject(thiscinfo->hbrush); + thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back], + _green[thiscinfo->back], + _blue[thiscinfo->back])); + SelectObject((HDC)mp1, thiscinfo->hbrush); + } + return (LONG)thiscinfo->hbrush; + } + else if((thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR) + { SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back), DW_GREEN_VALUE(thiscinfo->back), DW_BLUE_VALUE(thiscinfo->back))); @@ -4023,17 +4084,18 @@ */ HWND dw_listbox_new(ULONG id, int multi) { - HWND tmp = CreateWindow(LISTBOXCLASSNAME, - "", - WS_VISIBLE | LBS_NOINTEGRALHEIGHT | - WS_CHILD | LBS_HASSTRINGS | - LBS_NOTIFY | WS_BORDER | WS_CLIPCHILDREN | - WS_VSCROLL | (multi ? LBS_MULTIPLESEL : 0) , - 0,0,2000,1000, - DW_HWND_OBJECT, - (HMENU)id, - DWInstance, - NULL); + HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE, + LISTBOXCLASSNAME, + "", + WS_VISIBLE | LBS_NOINTEGRALHEIGHT | + WS_CHILD | LBS_HASSTRINGS | + LBS_NOTIFY | WS_BORDER | WS_CLIPCHILDREN | + WS_VSCROLL | (multi ? LBS_MULTIPLESEL : 0) , + 0,0,2000,1000, + DW_HWND_OBJECT, + (HMENU)id, + DWInstance, + NULL); ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo)); if(!cinfo)