changeset 1427:7b735226ab94

Simplified the widget color handling code on Windows. Added support for pseudo transparent widget background colors on Windows. Updated the readme with recent features.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 03 Dec 2011 19:33:42 +0000
parents dfd9f177c34c
children 7826031d48ce
files readme win/dw.c
diffstat 2 files changed, 41 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/readme	Sat Dec 03 09:11:44 2011 +0000
+++ b/readme	Sat Dec 03 19:33:42 2011 +0000
@@ -39,6 +39,12 @@
 Added dw_window_set_tooltip() for adding tooltips to most widgets.
 Added support for -1 size parameter to the dw_box_pack*() functions to 
     automatically figure out a suggested size for many controls.
+Added automatic window redraw support for OS/2, Windows and Mac.
+Added Open Watcom compiler support for OS/2.
+Added pseudo transparent background widget support on Windows.
+   If you set the background color of a widget to DW_RGB_TRANSPARENT...
+   it will attempt to use the background color of the parent.
+   Several types of widgets have this set by default now.
 Fixed bubble help not being displayed on Windows.
 Fixed menu bar items remaining highlighted on Mac.
 
--- a/win/dw.c	Sat Dec 03 09:11:44 2011 +0000
+++ b/win/dw.c	Sat Dec 03 19:33:42 2011 +0000
@@ -2695,6 +2695,7 @@
       SetFocus(handle);
 }
 
+/* Subclass function that will handle setting colors on controls */
 BOOL CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
 {
    ColorInfo *cinfo;
@@ -2847,64 +2848,50 @@
             ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr((HWND)mp2, GWLP_USERDATA);
             if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1)
             {
+               int thisback = thiscinfo->back;
+               
                /* Handle foreground */
-               if(thiscinfo->fore > -1 && thiscinfo->fore < 18)
+               if(thiscinfo->fore != DW_CLR_DEFAULT)
                {
-                  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)));
+                  int fore = _internal_color(thiscinfo->fore);
+               
+                  SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(fore),
+                                       DW_GREEN_VALUE(fore),
+                                       DW_BLUE_VALUE(fore)));
                }
                /* Handle background */
-               if(thiscinfo->back > -1 && thiscinfo->back < 18)
+               if(thiscinfo->back == DW_RGB_TRANSPARENT)
+               {
+                  ColorInfo *parentcinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
+                  
+                  if(parentcinfo && parentcinfo->back != -1)
+                     thisback = parentcinfo->back;
+               }
+               if(thisback == DW_CLR_DEFAULT)
                {
-                  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;
+                  HBRUSH hbr = GetSysColorBrush(COLOR_3DFACE);
+
+                  SetBkColor((HDC)mp1, GetSysColor(COLOR_3DFACE));
+
+                  SelectObject((HDC)mp1, hbr);
+                  return (LONG)hbr;
                }
-               else if((thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR)
+               else if(thisback != -1 && thisback != DW_RGB_TRANSPARENT)
                {
-                  SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back),
-                                     DW_GREEN_VALUE(thiscinfo->back),
-                                     DW_BLUE_VALUE(thiscinfo->back)));
+                  int back = _internal_color(thisback);
+                  
+                  SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(back),
+                                     DW_GREEN_VALUE(back),
+                                     DW_BLUE_VALUE(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)));
+                  thiscinfo->hbrush = CreateSolidBrush(RGB(DW_RED_VALUE(back),
+                                                 DW_GREEN_VALUE(back),
+                                                 DW_BLUE_VALUE(back)));
                   SelectObject((HDC)mp1, thiscinfo->hbrush);
                   return (LONG)thiscinfo->hbrush;
                }
             }
-
          }
          break;
       }
@@ -5610,6 +5597,7 @@
                      DWInstance,
                      NULL);
    dw_window_set_font(tmp, DefaultFont);
+   dw_window_set_color(tmp, DW_CLR_DEFAULT, DW_RGB_TRANSPARENT);
    return tmp;
 }
 
@@ -6073,6 +6061,7 @@
    cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc);
    SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
    dw_window_set_font(tmp, DefaultFont);
+   dw_window_set_color(tmp, DW_CLR_DEFAULT, DW_RGB_TRANSPARENT);
    return tmp;
 }
 
@@ -6173,6 +6162,7 @@
    SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
    dw_window_set_data(tmp, "_dw_checkbox", DW_INT_TO_POINTER(1));
    dw_window_set_font(tmp, DefaultFont);
+   dw_window_set_color(tmp, DW_CLR_DEFAULT, DW_RGB_TRANSPARENT);
    return tmp;
 }