Mercurial > dwindows
comparison win/dw.c @ 155:840c54766306
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.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 07 Nov 2002 22:31:02 +0000 |
parents | a371875d5486 |
children | a07dd2e819f3 |
comparison
equal
deleted
inserted
replaced
154:7f8fcce45bdd | 155:840c54766306 |
---|---|
1508 case WM_CTLCOLORDLG: | 1508 case WM_CTLCOLORDLG: |
1509 { | 1509 { |
1510 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong((HWND)mp2, GWL_USERDATA); | 1510 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong((HWND)mp2, GWL_USERDATA); |
1511 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1) | 1511 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1) |
1512 { | 1512 { |
1513 if(thiscinfo->fore > -1 && thiscinfo->back > -1 && | 1513 /* Handle foreground */ |
1514 thiscinfo->fore < 18 && thiscinfo->back < 18) | 1514 if(thiscinfo->fore > -1 && thiscinfo->fore < 18) |
1515 { | 1515 { |
1516 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore], | 1516 if(thiscinfo->fore != DW_CLR_DEFAULT) |
1517 _green[thiscinfo->fore], | 1517 { |
1518 _blue[thiscinfo->fore])); | 1518 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore], |
1519 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back], | 1519 _green[thiscinfo->fore], |
1520 _green[thiscinfo->back], | 1520 _blue[thiscinfo->fore])); |
1521 _blue[thiscinfo->back])); | 1521 } |
1522 if(thiscinfo->hbrush) | |
1523 DeleteObject(thiscinfo->hbrush); | |
1524 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back], | |
1525 _green[thiscinfo->back], | |
1526 _blue[thiscinfo->back])); | |
1527 SelectObject((HDC)mp1, thiscinfo->hbrush); | |
1528 return (LONG)thiscinfo->hbrush; | |
1529 } | 1522 } |
1530 if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR && (thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR) | 1523 else if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR) |
1531 { | 1524 { |
1532 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore), | 1525 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore), |
1533 DW_GREEN_VALUE(thiscinfo->fore), | 1526 DW_GREEN_VALUE(thiscinfo->fore), |
1534 DW_BLUE_VALUE(thiscinfo->fore))); | 1527 DW_BLUE_VALUE(thiscinfo->fore))); |
1528 } | |
1529 /* Handle background */ | |
1530 if(thiscinfo->back > -1 && thiscinfo->back < 18) | |
1531 { | |
1532 if(thiscinfo->back == DW_CLR_DEFAULT) | |
1533 { | |
1534 HBRUSH hbr = GetSysColorBrush(COLOR_3DFACE); | |
1535 | |
1536 SelectObject((HDC)mp1, hbr); | |
1537 return (LONG)hbr; | |
1538 } | |
1539 else | |
1540 { | |
1541 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back], | |
1542 _green[thiscinfo->back], | |
1543 _blue[thiscinfo->back])); | |
1544 if(thiscinfo->hbrush) | |
1545 DeleteObject(thiscinfo->hbrush); | |
1546 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back], | |
1547 _green[thiscinfo->back], | |
1548 _blue[thiscinfo->back])); | |
1549 SelectObject((HDC)mp1, thiscinfo->hbrush); | |
1550 } | |
1551 return (LONG)thiscinfo->hbrush; | |
1552 } | |
1553 else if((thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR) | |
1554 { | |
1535 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back), | 1555 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back), |
1536 DW_GREEN_VALUE(thiscinfo->back), | 1556 DW_GREEN_VALUE(thiscinfo->back), |
1537 DW_BLUE_VALUE(thiscinfo->back))); | 1557 DW_BLUE_VALUE(thiscinfo->back))); |
1538 if(thiscinfo->hbrush) | 1558 if(thiscinfo->hbrush) |
1539 DeleteObject(thiscinfo->hbrush); | 1559 DeleteObject(thiscinfo->hbrush); |
1586 { | 1606 { |
1587 PAINTSTRUCT ps; | 1607 PAINTSTRUCT ps; |
1588 HDC hdcPaint = BeginPaint(hWnd, &ps); | 1608 HDC hdcPaint = BeginPaint(hWnd, &ps); |
1589 int success = FALSE; | 1609 int success = FALSE; |
1590 | 1610 |
1591 if(thiscinfo->fore > -1 && thiscinfo->back > -1 && | 1611 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1) |
1592 thiscinfo->fore < 18 && thiscinfo->back < 18) | |
1593 { | 1612 { |
1594 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore], | 1613 /* Handle foreground */ |
1595 _green[thiscinfo->fore], | 1614 if(thiscinfo->fore > -1 && thiscinfo->fore < 18) |
1596 _blue[thiscinfo->fore])); | 1615 { |
1597 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back], | 1616 if(thiscinfo->fore != DW_CLR_DEFAULT) |
1598 _green[thiscinfo->back], | 1617 { |
1599 _blue[thiscinfo->back])); | 1618 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore], |
1600 DeleteObject(thiscinfo->hbrush); | 1619 _green[thiscinfo->fore], |
1601 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back], | 1620 _blue[thiscinfo->fore])); |
1602 _green[thiscinfo->back], | 1621 } |
1603 _blue[thiscinfo->back])); | 1622 } |
1604 SelectObject(hdcPaint, thiscinfo->hbrush); | 1623 else if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR) |
1605 Rectangle(hdcPaint, ps.rcPaint.left - 1, ps.rcPaint.top - 1, ps.rcPaint.right + 1, ps.rcPaint.bottom + 1); | 1624 { |
1606 success = TRUE; | 1625 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore), |
1607 } | 1626 DW_GREEN_VALUE(thiscinfo->fore), |
1608 if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR && (thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR) | 1627 DW_BLUE_VALUE(thiscinfo->fore))); |
1609 { | 1628 } |
1610 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore), | 1629 /* Handle background */ |
1611 DW_GREEN_VALUE(thiscinfo->fore), | 1630 if(thiscinfo->back > -1 && thiscinfo->back < 18) |
1612 DW_BLUE_VALUE(thiscinfo->fore))); | 1631 { |
1613 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back), | 1632 if(thiscinfo->back != DW_CLR_DEFAULT) |
1614 DW_GREEN_VALUE(thiscinfo->back), | 1633 { |
1615 DW_BLUE_VALUE(thiscinfo->back))); | 1634 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back], |
1616 DeleteObject(thiscinfo->hbrush); | 1635 _green[thiscinfo->back], |
1617 thiscinfo->hbrush = CreateSolidBrush(RGB(DW_RED_VALUE(thiscinfo->back), | 1636 _blue[thiscinfo->back])); |
1618 DW_GREEN_VALUE(thiscinfo->back), | 1637 if(thiscinfo->hbrush) |
1619 DW_BLUE_VALUE(thiscinfo->back))); | 1638 DeleteObject(thiscinfo->hbrush); |
1620 SelectObject(hdcPaint, thiscinfo->hbrush); | 1639 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back], |
1621 Rectangle(hdcPaint, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom); | 1640 _green[thiscinfo->back], |
1622 success = TRUE; | 1641 _blue[thiscinfo->back])); |
1642 SelectObject(hdcPaint, thiscinfo->hbrush); | |
1643 Rectangle(hdcPaint, ps.rcPaint.left - 1, ps.rcPaint.top - 1, ps.rcPaint.right + 1, ps.rcPaint.bottom + 1); | |
1644 success = TRUE; | |
1645 } | |
1646 } | |
1647 else if((thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR) | |
1648 { | |
1649 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back), | |
1650 DW_GREEN_VALUE(thiscinfo->back), | |
1651 DW_BLUE_VALUE(thiscinfo->back))); | |
1652 if(thiscinfo->hbrush) | |
1653 DeleteObject(thiscinfo->hbrush); | |
1654 thiscinfo->hbrush = CreateSolidBrush(RGB(DW_RED_VALUE(thiscinfo->back), | |
1655 DW_GREEN_VALUE(thiscinfo->back), | |
1656 DW_BLUE_VALUE(thiscinfo->back))); | |
1657 SelectObject(hdcPaint, thiscinfo->hbrush); | |
1658 Rectangle(hdcPaint, ps.rcPaint.left - 1, ps.rcPaint.top - 1, ps.rcPaint.right + 1, ps.rcPaint.bottom + 1); | |
1659 success = TRUE; | |
1660 } | |
1623 } | 1661 } |
1624 | 1662 |
1625 EndPaint(hWnd, &ps); | 1663 EndPaint(hWnd, &ps); |
1626 if(success) | 1664 if(success) |
1627 return FALSE; | 1665 return FALSE; |
1935 case WM_CTLCOLORDLG: | 1973 case WM_CTLCOLORDLG: |
1936 { | 1974 { |
1937 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong((HWND)mp2, GWL_USERDATA); | 1975 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong((HWND)mp2, GWL_USERDATA); |
1938 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1) | 1976 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1) |
1939 { | 1977 { |
1940 if(thiscinfo->fore > -1 && thiscinfo->back > -1 && | 1978 /* Handle foreground */ |
1941 thiscinfo->fore < 18 && thiscinfo->back < 18) | 1979 if(thiscinfo->fore > -1 && thiscinfo->fore < 18) |
1942 { | 1980 { |
1943 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore], | 1981 if(thiscinfo->fore != DW_CLR_DEFAULT) |
1944 _green[thiscinfo->fore], | 1982 { |
1945 _blue[thiscinfo->fore])); | 1983 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore], |
1946 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back], | 1984 _green[thiscinfo->fore], |
1947 _green[thiscinfo->back], | 1985 _blue[thiscinfo->fore])); |
1948 _blue[thiscinfo->back])); | 1986 } |
1949 if(thiscinfo->hbrush) | |
1950 DeleteObject(thiscinfo->hbrush); | |
1951 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back], | |
1952 _green[thiscinfo->back], | |
1953 _blue[thiscinfo->back])); | |
1954 SelectObject((HDC)mp1, thiscinfo->hbrush); | |
1955 return (LONG)thiscinfo->hbrush; | |
1956 } | 1987 } |
1957 if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR && (thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR) | 1988 else if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR) |
1958 { | 1989 { |
1959 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore), | 1990 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore), |
1960 DW_GREEN_VALUE(thiscinfo->fore), | 1991 DW_GREEN_VALUE(thiscinfo->fore), |
1961 DW_BLUE_VALUE(thiscinfo->fore))); | 1992 DW_BLUE_VALUE(thiscinfo->fore))); |
1993 } | |
1994 /* Handle background */ | |
1995 if(thiscinfo->back > -1 && thiscinfo->back < 18) | |
1996 { | |
1997 if(thiscinfo->back == DW_CLR_DEFAULT) | |
1998 { | |
1999 HBRUSH hbr = GetSysColorBrush(COLOR_3DFACE); | |
2000 | |
2001 SetBkColor((HDC)mp1, GetSysColor(COLOR_3DFACE)); | |
2002 | |
2003 | |
2004 SelectObject((HDC)mp1, hbr); | |
2005 return (LONG)hbr; | |
2006 } | |
2007 else | |
2008 { | |
2009 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back], | |
2010 _green[thiscinfo->back], | |
2011 _blue[thiscinfo->back])); | |
2012 if(thiscinfo->hbrush) | |
2013 DeleteObject(thiscinfo->hbrush); | |
2014 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back], | |
2015 _green[thiscinfo->back], | |
2016 _blue[thiscinfo->back])); | |
2017 SelectObject((HDC)mp1, thiscinfo->hbrush); | |
2018 } | |
2019 return (LONG)thiscinfo->hbrush; | |
2020 } | |
2021 else if((thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR) | |
2022 { | |
1962 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back), | 2023 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back), |
1963 DW_GREEN_VALUE(thiscinfo->back), | 2024 DW_GREEN_VALUE(thiscinfo->back), |
1964 DW_BLUE_VALUE(thiscinfo->back))); | 2025 DW_BLUE_VALUE(thiscinfo->back))); |
1965 if(thiscinfo->hbrush) | 2026 if(thiscinfo->hbrush) |
1966 DeleteObject(thiscinfo->hbrush); | 2027 DeleteObject(thiscinfo->hbrush); |
4021 * id: An ID to be used with WinWindowFromID() or 0L. | 4082 * id: An ID to be used with WinWindowFromID() or 0L. |
4022 * multi: Multiple select TRUE or FALSE. | 4083 * multi: Multiple select TRUE or FALSE. |
4023 */ | 4084 */ |
4024 HWND dw_listbox_new(ULONG id, int multi) | 4085 HWND dw_listbox_new(ULONG id, int multi) |
4025 { | 4086 { |
4026 HWND tmp = CreateWindow(LISTBOXCLASSNAME, | 4087 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE, |
4027 "", | 4088 LISTBOXCLASSNAME, |
4028 WS_VISIBLE | LBS_NOINTEGRALHEIGHT | | 4089 "", |
4029 WS_CHILD | LBS_HASSTRINGS | | 4090 WS_VISIBLE | LBS_NOINTEGRALHEIGHT | |
4030 LBS_NOTIFY | WS_BORDER | WS_CLIPCHILDREN | | 4091 WS_CHILD | LBS_HASSTRINGS | |
4031 WS_VSCROLL | (multi ? LBS_MULTIPLESEL : 0) , | 4092 LBS_NOTIFY | WS_BORDER | WS_CLIPCHILDREN | |
4032 0,0,2000,1000, | 4093 WS_VSCROLL | (multi ? LBS_MULTIPLESEL : 0) , |
4033 DW_HWND_OBJECT, | 4094 0,0,2000,1000, |
4034 (HMENU)id, | 4095 DW_HWND_OBJECT, |
4035 DWInstance, | 4096 (HMENU)id, |
4036 NULL); | 4097 DWInstance, |
4098 NULL); | |
4037 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo)); | 4099 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo)); |
4038 | 4100 |
4039 if(!cinfo) | 4101 if(!cinfo) |
4040 { | 4102 { |
4041 DestroyWindow(tmp); | 4103 DestroyWindow(tmp); |