comparison os2/dw.c @ 1428:7826031d48ce

Added support for pseudo transparent widget background colors on OS/2.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 04 Dec 2011 19:13:10 +0000
parents 1628bf383893
children fbaec6e5df63
comparison
equal deleted inserted replaced
1427:7b735226ab94 1428:7826031d48ce
4857 if(str && WinQueryPresParam(group ? group : handle, PP_FONTNAMESIZE, 0, NULL, 50, str, QPF_NOINHERIT)) 4857 if(str && WinQueryPresParam(group ? group : handle, PP_FONTNAMESIZE, 0, NULL, 50, str, QPF_NOINHERIT))
4858 return strdup(str); 4858 return strdup(str);
4859 return NULL; 4859 return NULL;
4860 } 4860 }
4861 4861
4862 /* Internal function to handle transparent children */
4863 void _handle_transparent(HWND handle)
4864 {
4865 ULONG pcolor, which = PP_BACKGROUNDCOLOR;;
4866
4867
4868 if(!WinQueryPresParam(handle, which, 0, NULL, sizeof(pcolor), &pcolor, QPF_NOINHERIT))
4869 which = PP_BACKGROUNDCOLORINDEX;
4870
4871 if(which == PP_BACKGROUNDCOLOR ||
4872 WinQueryPresParam(handle, which, 0, NULL, sizeof(pcolor), &pcolor, QPF_NOINHERIT))
4873 {
4874 HWND child;
4875 HENUM henum = WinBeginEnumWindows(handle);
4876
4877 while((child = WinGetNextWindow(henum)) != NULLHANDLE)
4878 {
4879 if(dw_window_get_data(child, "_dw_transparent"))
4880 {
4881 WinSetPresParam(child, which, sizeof(pcolor), &pcolor);
4882 }
4883 }
4884 WinEndEnumWindows(henum);
4885 }
4886 }
4887
4862 /* Internal version */ 4888 /* Internal version */
4863 int _dw_window_set_color(HWND handle, ULONG fore, ULONG back) 4889 int _dw_window_set_color(HWND handle, ULONG fore, ULONG back)
4864 { 4890 {
4891 /* Handle foreground */
4865 if((fore & DW_RGB_COLOR) == DW_RGB_COLOR) 4892 if((fore & DW_RGB_COLOR) == DW_RGB_COLOR)
4866 { 4893 {
4867 RGB2 rgb2; 4894 RGB2 rgb2;
4868 4895
4869 rgb2.bBlue = DW_BLUE_VALUE(fore); 4896 rgb2.bBlue = DW_BLUE_VALUE(fore);
4878 { 4905 {
4879 fore = _internal_color(fore); 4906 fore = _internal_color(fore);
4880 4907
4881 WinSetPresParam(handle, PP_FOREGROUNDCOLORINDEX, sizeof(ULONG), &fore); 4908 WinSetPresParam(handle, PP_FOREGROUNDCOLORINDEX, sizeof(ULONG), &fore);
4882 } 4909 }
4883 if((back & DW_RGB_COLOR) == DW_RGB_COLOR) 4910 /* Handle background */
4911 if(back == DW_RGB_TRANSPARENT)
4912 {
4913 /* Special case for setting transparent */
4914 ULONG pcolor;
4915 HWND parent = WinQueryWindow(handle, QW_PARENT);
4916
4917 dw_window_set_data(handle, "_dw_transparent", DW_INT_TO_POINTER(1));
4918
4919 if(WinQueryPresParam(parent, PP_BACKGROUNDCOLOR, 0, NULL,
4920 sizeof(pcolor), &pcolor, QPF_NOINHERIT | QPF_PURERGBCOLOR))
4921 WinSetPresParam(handle, PP_BACKGROUNDCOLOR, sizeof(pcolor), &pcolor);
4922 else if(WinQueryPresParam(parent, PP_BACKGROUNDCOLORINDEX, 0, NULL,
4923 sizeof(pcolor), &pcolor, QPF_NOINHERIT))
4924 WinSetPresParam(handle, PP_BACKGROUNDCOLORINDEX, sizeof(pcolor), &pcolor);
4925 }
4926 else if((back & DW_RGB_COLOR) == DW_RGB_COLOR)
4884 { 4927 {
4885 RGB2 rgb2; 4928 RGB2 rgb2;
4886 4929
4887 rgb2.bBlue = DW_BLUE_VALUE(back); 4930 rgb2.bBlue = DW_BLUE_VALUE(back);
4888 rgb2.bGreen = DW_GREEN_VALUE(back); 4931 rgb2.bGreen = DW_GREEN_VALUE(back);
4889 rgb2.bRed = DW_RED_VALUE(back); 4932 rgb2.bRed = DW_RED_VALUE(back);
4890 rgb2.fcOptions = 0; 4933 rgb2.fcOptions = 0;
4891 4934
4892 WinSetPresParam(handle, PP_BACKGROUNDCOLOR, sizeof(RGB2), &rgb2); 4935 WinSetPresParam(handle, PP_BACKGROUNDCOLOR, sizeof(RGB2), &rgb2);
4893 return 0;
4894 } 4936 }
4895 else if(back != DW_CLR_DEFAULT) 4937 else if(back != DW_CLR_DEFAULT)
4896 { 4938 {
4897 back = _internal_color(back); 4939 back = _internal_color(back);
4898 4940
4899 WinSetPresParam(handle, PP_BACKGROUNDCOLORINDEX, sizeof(ULONG), &back); 4941 WinSetPresParam(handle, PP_BACKGROUNDCOLORINDEX, sizeof(ULONG), &back);
4900 } 4942 }
4901 return 0; 4943 /* If this is a box... check if any of the children are transparent */
4944 _handle_transparent(handle);
4945 return DW_ERROR_NONE;
4902 } 4946 }
4903 /* 4947 /*
4904 * Sets the colors used by a specified window (widget) handle. 4948 * Sets the colors used by a specified window (widget) handle.
4905 * Parameters: 4949 * Parameters:
4906 * handle: The window (widget) handle. 4950 * handle: The window (widget) handle.
5672 NULL, 5716 NULL,
5673 NULL); 5717 NULL);
5674 blah->oldproc = WinSubclassWindow(tmp, _textproc); 5718 blah->oldproc = WinSubclassWindow(tmp, _textproc);
5675 WinSetWindowPtr(tmp, QWP_USER, blah); 5719 WinSetWindowPtr(tmp, QWP_USER, blah);
5676 dw_window_set_font(tmp, DefaultFont); 5720 dw_window_set_font(tmp, DefaultFont);
5677 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); 5721 dw_window_set_color(tmp, DW_CLR_BLACK, DW_RGB_TRANSPARENT);
5678 return tmp; 5722 return tmp;
5679 } 5723 }
5680 5724
5681 /* 5725 /*
5682 * Create a new status text window (widget) to be packed. 5726 * Create a new status text window (widget) to be packed.
6194 NULL, 6238 NULL,
6195 NULL); 6239 NULL);
6196 blah->oldproc = WinSubclassWindow(tmp, _entryproc); 6240 blah->oldproc = WinSubclassWindow(tmp, _entryproc);
6197 WinSetWindowPtr(tmp, QWP_USER, blah); 6241 WinSetWindowPtr(tmp, QWP_USER, blah);
6198 dw_window_set_font(tmp, DefaultFont); 6242 dw_window_set_font(tmp, DefaultFont);
6199 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); 6243 dw_window_set_color(tmp, DW_CLR_BLACK, DW_RGB_TRANSPARENT);
6200 return tmp; 6244 return tmp;
6201 } 6245 }
6202 6246
6203 6247
6204 /* 6248 /*
6301 NULL, 6345 NULL,
6302 NULL); 6346 NULL);
6303 blah->oldproc = WinSubclassWindow(tmp, _BtProc); 6347 blah->oldproc = WinSubclassWindow(tmp, _BtProc);
6304 WinSetWindowPtr(tmp, QWP_USER, blah); 6348 WinSetWindowPtr(tmp, QWP_USER, blah);
6305 dw_window_set_font(tmp, DefaultFont); 6349 dw_window_set_font(tmp, DefaultFont);
6306 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); 6350 dw_window_set_color(tmp, DW_CLR_BLACK, DW_RGB_TRANSPARENT);
6307 return tmp; 6351 return tmp;
6308 } 6352 }
6309 6353
6310 /* 6354 /*
6311 * Create a new listbox window (widget) to be packed. 6355 * Create a new listbox window (widget) to be packed.
6886 WinQueryClassName(item, 99, (PCH)tmpbuf); 6930 WinQueryClassName(item, 99, (PCH)tmpbuf);
6887 /* Don't set the ownership if it's an entryfield or spinbutton */ 6931 /* Don't set the ownership if it's an entryfield or spinbutton */
6888 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0 && strncmp(tmpbuf, "#2", 3)!=0) 6932 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0 && strncmp(tmpbuf, "#2", 3)!=0)
6889 WinSetOwner(item, box); 6933 WinSetOwner(item, box);
6890 WinSetParent(frame ? frame : item, box, FALSE); 6934 WinSetParent(frame ? frame : item, box, FALSE);
6935 _handle_transparent(box);
6891 /* Queue a redraw on the top-level window */ 6936 /* Queue a redraw on the top-level window */
6892 _dw_redraw(_toplevel_window(item), TRUE); 6937 _dw_redraw(_toplevel_window(item), TRUE);
6893 } 6938 }
6894 } 6939 }
6895 6940