Mercurial > dwindows
comparison win/dw.c @ 12:26e2130135b9
Many Win32 and GTK fixes.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 06 Jul 2001 13:32:57 +0000 |
parents | 005fa766e8c2 |
children | 176cee043f1b |
comparison
equal
deleted
inserted
replaced
11:cfab3266106f | 12:26e2130135b9 |
---|---|
14 #include <string.h> | 14 #include <string.h> |
15 #include <stdio.h> | 15 #include <stdio.h> |
16 #include <process.h> | 16 #include <process.h> |
17 #include "dw.h" | 17 #include "dw.h" |
18 | 18 |
19 /* Get around apparent bugs in the | |
20 * Microsoft runtime when in the debugger. | |
21 * You can set this value to 0 when releasing. | |
22 */ | |
23 #define DEBUG_MALLOC 100 | |
24 | |
19 /* this is the callback handle for the window procedure */ | 25 /* this is the callback handle for the window procedure */ |
20 /* make sure you always match the calling convention! */ | 26 /* make sure you always match the calling convention! */ |
21 int (*filterfunc)(HWND, UINT, WPARAM, LPARAM) = 0L; | 27 int (*filterfunc)(HWND, UINT, WPARAM, LPARAM) = 0L; |
22 | 28 |
23 HWND hwndBubble = (HWND)NULL, hwndBubbleLast, DW_HWND_OBJECT = (HWND)NULL; | 29 HWND hwndBubble = (HWND)NULL, hwndBubbleLast, DW_HWND_OBJECT = (HWND)NULL; |
37 | 43 |
38 #define ICON_INDEX_LIMIT 200 | 44 #define ICON_INDEX_LIMIT 200 |
39 HICON lookup[200]; | 45 HICON lookup[200]; |
40 HIMAGELIST hSmall, hLarge; | 46 HIMAGELIST hSmall, hLarge; |
41 | 47 |
42 COLORREF _foreground = RGB(127, 127, 127); | 48 #define THREAD_LIMIT 128 |
43 COLORREF _background = 0; | 49 COLORREF _foreground[THREAD_LIMIT]; |
44 HPEN _hPen; | 50 COLORREF _background[THREAD_LIMIT]; |
45 HBRUSH _hBrush; | 51 HPEN _hPen[THREAD_LIMIT]; |
52 HBRUSH _hBrush[THREAD_LIMIT]; | |
46 | 53 |
47 #ifdef DWDEBUG | 54 #ifdef DWDEBUG |
48 FILE *f; | 55 FILE *f; |
49 | 56 |
50 void reopen(void) | 57 void reopen(void) |
1750 /* This handles drawing the status text areas */ | 1757 /* This handles drawing the status text areas */ |
1751 BOOL CALLBACK _statuswndproc(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2) | 1758 BOOL CALLBACK _statuswndproc(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2) |
1752 { | 1759 { |
1753 switch (msg) | 1760 switch (msg) |
1754 { | 1761 { |
1762 case WM_SETTEXT: | |
1763 { | |
1764 /* Make sure the control redraws when there is a text change */ | |
1765 int ret = (int)DefWindowProc(hwnd, msg, mp1, mp2); | |
1766 | |
1767 InvalidateRgn(hwnd, NULL, TRUE); | |
1768 return ret; | |
1769 } | |
1755 case WM_PAINT: | 1770 case WM_PAINT: |
1756 { | 1771 { |
1757 HDC hdcPaint; | 1772 HDC hdcPaint; |
1758 PAINTSTRUCT ps; | 1773 PAINTSTRUCT ps; |
1759 RECT rcPaint; | 1774 RECT rc; |
1760 HBRUSH hBrush; | |
1761 HPEN hPen; | |
1762 HFONT hFont; | 1775 HFONT hFont; |
1776 HBRUSH oldBrush; | |
1777 HPEN oldPen; | |
1778 unsigned long cx, cy; | |
1779 int threadid = dw_thread_id(); | |
1763 char tempbuf[1024] = ""; | 1780 char tempbuf[1024] = ""; |
1764 | 1781 |
1782 if(threadid < 0 || threadid >= THREAD_LIMIT) | |
1783 threadid = 0; | |
1784 | |
1765 hdcPaint = BeginPaint(hwnd, &ps); | 1785 hdcPaint = BeginPaint(hwnd, &ps); |
1766 GetWindowRect(hwnd, &rcPaint); | 1786 EndPaint(hwnd, &ps); |
1767 | 1787 |
1768 dw_color_foreground_set(DW_RGB(_red[DW_CLR_PALEGRAY], | 1788 hdcPaint = GetDC(hwnd); |
1769 _green[DW_CLR_PALEGRAY], | 1789 |
1770 _blue[DW_CLR_PALEGRAY])); | 1790 oldBrush = _hBrush[threadid]; |
1771 | 1791 oldPen = _hPen[threadid]; |
1772 dw_draw_rect(hwnd, 0, TRUE, 1, 1, rcPaint.right - rcPaint.left - 2, rcPaint.bottom - rcPaint.top - 2); | 1792 |
1773 | 1793 dw_window_get_pos_size(hwnd, NULL, NULL, &cx, &cy); |
1774 dw_color_foreground_set(DW_RGB(_red[DW_CLR_DARKGRAY], | 1794 |
1775 _green[DW_CLR_DARKGRAY], | 1795 _hBrush[threadid] = GetStockObject(LTGRAY_BRUSH); |
1776 _blue[DW_CLR_DARKGRAY])); | 1796 |
1777 | 1797 dw_draw_rect(hwnd, 0, TRUE, 0, 0, cx, cy); |
1778 dw_draw_line(hwnd, 0, 0, 0, rcPaint.right - rcPaint.left, 0); | 1798 |
1779 dw_draw_line(hwnd, 0, 0, 0, 0, rcPaint.bottom - rcPaint.top); | 1799 _hPen[threadid] = CreatePen(PS_SOLID, 1, RGB(_red[DW_CLR_DARKGRAY], |
1780 | 1800 _green[DW_CLR_DARKGRAY], |
1781 dw_color_foreground_set(DW_RGB(_red[DW_CLR_WHITE], | 1801 _blue[DW_CLR_DARKGRAY])); |
1782 _green[DW_CLR_WHITE], | 1802 |
1783 _blue[DW_CLR_WHITE])); | 1803 dw_draw_line(hwnd, 0, 0, 0, cx, 0); |
1784 | 1804 dw_draw_line(hwnd, 0, 0, 0, 0, cy); |
1785 dw_draw_line(hwnd, 0, rcPaint.right - rcPaint.left - 1, rcPaint.bottom - rcPaint.top - 1, rcPaint.right - rcPaint.left - 1, 0); | 1805 |
1786 dw_draw_line(hwnd, 0, rcPaint.right - rcPaint.left - 1, rcPaint.bottom - rcPaint.top - 1, 0, rcPaint.bottom - rcPaint.top - 1); | 1806 DeleteObject(_hPen[threadid]); |
1787 | 1807 |
1788 rcPaint.left += 3; | 1808 _hPen[threadid] = GetStockObject(WHITE_PEN); |
1789 rcPaint.top++; | 1809 |
1790 rcPaint.bottom--; | 1810 dw_draw_line(hwnd, 0, cx - 1, cy - 1, cx - 1, 0); |
1791 rcPaint.right--; | 1811 dw_draw_line(hwnd, 0, cx - 1, cy - 1, 0, cy - 1); |
1812 | |
1813 rc.left = 3; | |
1814 rc.top = 1; | |
1815 rc.bottom = cy - 1; | |
1816 rc.right = cx - 1; | |
1792 | 1817 |
1793 GetWindowText(hwnd, tempbuf, 1024); | 1818 GetWindowText(hwnd, tempbuf, 1024); |
1794 | 1819 |
1795 dw_color_foreground_set(DW_RGB(_red[DW_CLR_BLACK], | |
1796 _green[DW_CLR_BLACK], | |
1797 _blue[DW_CLR_BLACK])); | |
1798 | |
1799 hBrush = (HBRUSH)SelectObject(hdcPaint, _hBrush); | |
1800 hPen = (HPEN)SelectObject(hdcPaint, _hPen); | |
1801 hFont = (HFONT)SelectObject(hdcPaint, GetStockObject(DEFAULT_GUI_FONT)); | 1820 hFont = (HFONT)SelectObject(hdcPaint, GetStockObject(DEFAULT_GUI_FONT)); |
1802 | 1821 |
1803 ExtTextOut(hdcPaint, rcPaint.left, rcPaint.top, ETO_CLIPPED, | 1822 SetTextColor(hdcPaint, RGB(0,0,0)); |
1804 &rcPaint, tempbuf, strlen(tempbuf), NULL); | 1823 SetBkMode(hdcPaint, TRANSPARENT); |
1805 | 1824 |
1806 SelectObject(hdcPaint, hBrush); | 1825 ExtTextOut(hdcPaint, 3, 1, ETO_CLIPPED, &rc, tempbuf, strlen(tempbuf), NULL); |
1807 SelectObject(hdcPaint, hPen); | 1826 |
1808 SelectObject(hdcPaint, hFont); | 1827 SelectObject(hdcPaint, hFont); |
1809 | 1828 |
1810 EndPaint(hwnd, &ps); | 1829 _hBrush[threadid] = oldBrush; |
1830 _hPen[threadid] = oldPen; | |
1831 ReleaseDC(hwnd, hdcPaint); | |
1811 } | 1832 } |
1812 return FALSE; | 1833 return FALSE; |
1813 } | 1834 } |
1814 return DefWindowProc(hwnd, msg, mp1, mp2); | 1835 return DefWindowProc(hwnd, msg, mp1, mp2); |
1815 } | 1836 } |
1968 ptlWork.y + (rect.bottom-rect.top) + 1, | 1989 ptlWork.y + (rect.bottom-rect.top) + 1, |
1969 size.cx + 2, | 1990 size.cx + 2, |
1970 size.cy + 2, | 1991 size.cy + 2, |
1971 SWP_NOACTIVATE | SWP_SHOWWINDOW); | 1992 SWP_NOACTIVATE | SWP_SHOWWINDOW); |
1972 | 1993 |
1994 ReleaseDC(hwndBubble, hdc); | |
1973 } | 1995 } |
1974 } | 1996 } |
1975 } | 1997 } |
1976 else{ | 1998 else{ |
1977 /* Calling ReleaseCapture in Win95 also causes WM_CAPTURECHANGED | 1999 /* Calling ReleaseCapture in Win95 also causes WM_CAPTURECHANGED |
2115 f = fopen("dw.log", "wt"); | 2137 f = fopen("dw.log", "wt"); |
2116 #endif | 2138 #endif |
2117 /* We need the version to check capability like up-down controls */ | 2139 /* We need the version to check capability like up-down controls */ |
2118 dwVersion = GetVersion(); | 2140 dwVersion = GetVersion(); |
2119 | 2141 |
2120 _hPen = CreatePen(PS_SOLID, 1, _foreground); | 2142 for(z=0;z<THREAD_LIMIT;z++) |
2121 _hBrush = CreateSolidBrush(_foreground); | 2143 { |
2144 _foreground[z] = RGB(128,128,128); | |
2145 _background[z] = 0; | |
2146 _hPen[z] = CreatePen(PS_SOLID, 1, _foreground[z]); | |
2147 _hBrush[z] = CreateSolidBrush(_foreground[z]); | |
2148 } | |
2122 | 2149 |
2123 return 0; | 2150 return 0; |
2124 } | 2151 } |
2125 | 2152 |
2126 /* | 2153 /* |
2459 */ | 2486 */ |
2460 HWND dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) | 2487 HWND dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) |
2461 { | 2488 { |
2462 HWND hwndframe; | 2489 HWND hwndframe; |
2463 Box *newbox = malloc(sizeof(Box)); | 2490 Box *newbox = malloc(sizeof(Box)); |
2491 ULONG flStyleEx = 0; | |
2464 | 2492 |
2465 newbox->pad = 0; | 2493 newbox->pad = 0; |
2466 newbox->type = BOXVERT; | 2494 newbox->type = BOXVERT; |
2467 newbox->count = 0; | 2495 newbox->count = 0; |
2468 | 2496 |
2497 if(hwndOwner) | |
2498 flStyleEx |= WS_EX_MDICHILD; | |
2499 | |
2469 if(!(flStyle & WS_CAPTION)) | 2500 if(!(flStyle & WS_CAPTION)) |
2470 flStyle |= WS_POPUPWINDOW; | 2501 flStyle |= WS_POPUPWINDOW; |
2502 | |
2471 if(flStyle & DW_FCF_TASKLIST) | 2503 if(flStyle & DW_FCF_TASKLIST) |
2472 { | 2504 { |
2473 ULONG newflags = (flStyle | WS_CLIPCHILDREN) & ~DW_FCF_TASKLIST; | 2505 ULONG newflags = (flStyle | WS_CLIPCHILDREN) & ~DW_FCF_TASKLIST; |
2474 hwndframe = CreateWindow(ClassName, title, newflags, CW_USEDEFAULT, CW_USEDEFAULT, | 2506 |
2475 CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, NULL, NULL, NULL); | 2507 hwndframe = CreateWindowEx(flStyleEx, ClassName, title, newflags, CW_USEDEFAULT, CW_USEDEFAULT, |
2508 CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, NULL, NULL, NULL); | |
2476 } | 2509 } |
2477 else | 2510 else |
2478 hwndframe = CreateWindowEx(WS_EX_TOOLWINDOW, ClassName, title, flStyle | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, | 2511 { |
2512 flStyleEx |= WS_EX_TOOLWINDOW; | |
2513 | |
2514 hwndframe = CreateWindowEx(flStyleEx, ClassName, title, flStyle | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, | |
2479 CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, NULL, NULL, NULL); | 2515 CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, NULL, NULL, NULL); |
2516 } | |
2480 SetWindowLong(hwndframe, GWL_USERDATA, (ULONG)newbox); | 2517 SetWindowLong(hwndframe, GWL_USERDATA, (ULONG)newbox); |
2518 | |
2519 if(hwndOwner) | |
2520 SetParent(hwndframe, hwndOwner); | |
2481 | 2521 |
2482 return hwndframe; | 2522 return hwndframe; |
2483 } | 2523 } |
2484 | 2524 |
2485 /* | 2525 /* |
2488 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). | 2528 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). |
2489 * pad: Number of pixels to pad around the box. | 2529 * pad: Number of pixels to pad around the box. |
2490 */ | 2530 */ |
2491 HWND dw_box_new(int type, int pad) | 2531 HWND dw_box_new(int type, int pad) |
2492 { | 2532 { |
2493 Box *newbox = malloc(sizeof(Box)); | 2533 Box *newbox = malloc(sizeof(Box)+DEBUG_MALLOC); |
2494 HWND hwndframe; | 2534 HWND hwndframe; |
2495 | 2535 |
2496 newbox->pad = pad; | 2536 newbox->pad = pad; |
2497 newbox->type = type; | 2537 newbox->type = type; |
2498 newbox->count = 0; | 2538 newbox->count = 0; |
2709 * Parameters: | 2749 * Parameters: |
2710 * menu: The handle the the existing menu. | 2750 * menu: The handle the the existing menu. |
2711 * id: Menuitem id. | 2751 * id: Menuitem id. |
2712 * check: TRUE for checked FALSE for not checked. | 2752 * check: TRUE for checked FALSE for not checked. |
2713 */ | 2753 */ |
2714 void dw_menu_item_set_check(HMENUI menux, int id, int check) | 2754 void dw_menu_item_set_check(HMENUI menux, unsigned long id, int check) |
2715 { | 2755 { |
2716 MENUITEMINFO mii; | 2756 MENUITEMINFO mii; |
2717 HMENU menu; | 2757 HMENU menu; |
2718 | 2758 |
2719 if(!menux) | 2759 if(!menux) |
3299 { | 3339 { |
3300 int z; | 3340 int z; |
3301 Item *tmpitem, *thisitem = thisbox->items; | 3341 Item *tmpitem, *thisitem = thisbox->items; |
3302 char tmpbuf[100]; | 3342 char tmpbuf[100]; |
3303 | 3343 |
3304 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); | 3344 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)+DEBUG_MALLOC); |
3305 | 3345 |
3306 for(z=0;z<thisbox->count;z++) | 3346 for(z=0;z<thisbox->count;z++) |
3307 { | 3347 { |
3308 tmpitem[z] = thisitem[z]; | 3348 tmpitem[z] = thisitem[z]; |
3309 } | 3349 } |
4382 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE | LVIF_TEXT; | 4422 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE | LVIF_TEXT; |
4383 lvi.pszText = filename; | 4423 lvi.pszText = filename; |
4384 lvi.cchTextMax = strlen(filename); | 4424 lvi.cchTextMax = strlen(filename); |
4385 lvi.iImage = _lookup_icon(handle, (HICON)icon); | 4425 lvi.iImage = _lookup_icon(handle, (HICON)icon); |
4386 | 4426 |
4387 ListView_InsertItem(handle, &lvi); | 4427 ListView_SetItem(handle, &lvi); |
4388 } | 4428 } |
4389 | 4429 |
4390 /* | 4430 /* |
4391 * Sets an item in specified row and column to the given data. | 4431 * Sets an item in specified row and column to the given data. |
4392 * Parameters: | 4432 * Parameters: |
4613 * green: green value. | 4653 * green: green value. |
4614 * blue: blue value. | 4654 * blue: blue value. |
4615 */ | 4655 */ |
4616 void dw_color_foreground_set(unsigned long value) | 4656 void dw_color_foreground_set(unsigned long value) |
4617 { | 4657 { |
4618 DeleteObject(_hPen); | 4658 int threadid = dw_thread_id(); |
4619 DeleteObject(_hBrush); | 4659 |
4620 _foreground = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); | 4660 if(threadid < 0 || threadid >= THREAD_LIMIT) |
4621 _hPen = CreatePen(PS_SOLID, 1, _foreground); | 4661 threadid = 0; |
4622 _hBrush = CreateSolidBrush(_foreground); | 4662 |
4663 DeleteObject(_hPen[threadid]); | |
4664 DeleteObject(_hBrush[threadid]); | |
4665 _foreground[threadid] = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); | |
4666 _hPen[threadid] = CreatePen(PS_SOLID, 1, _foreground[threadid]); | |
4667 _hBrush[threadid] = CreateSolidBrush(_foreground[threadid]); | |
4623 } | 4668 } |
4624 | 4669 |
4625 /* Sets the current background drawing color. | 4670 /* Sets the current background drawing color. |
4626 * Parameters: | 4671 * Parameters: |
4627 * red: red value. | 4672 * red: red value. |
4628 * green: green value. | 4673 * green: green value. |
4629 * blue: blue value. | 4674 * blue: blue value. |
4630 */ | 4675 */ |
4631 void dw_color_background_set(unsigned long value) | 4676 void dw_color_background_set(unsigned long value) |
4632 { | 4677 { |
4633 | 4678 int threadid = dw_thread_id(); |
4634 _background = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); | 4679 |
4680 if(threadid < 0 || threadid >= THREAD_LIMIT) | |
4681 threadid = 0; | |
4682 | |
4683 _background[threadid] = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); | |
4635 } | 4684 } |
4636 | 4685 |
4637 /* Draw a point on a window (preferably a render window). | 4686 /* Draw a point on a window (preferably a render window). |
4638 * Parameters: | 4687 * Parameters: |
4639 * handle: Handle to the window. | 4688 * handle: Handle to the window. |
4642 * y: Y coordinate. | 4691 * y: Y coordinate. |
4643 */ | 4692 */ |
4644 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) | 4693 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) |
4645 { | 4694 { |
4646 HDC hdcPaint; | 4695 HDC hdcPaint; |
4696 int threadid = dw_thread_id(); | |
4697 | |
4698 if(threadid < 0 || threadid >= THREAD_LIMIT) | |
4699 threadid = 0; | |
4647 | 4700 |
4648 if(handle) | 4701 if(handle) |
4649 hdcPaint = GetDC(handle); | 4702 hdcPaint = GetDC(handle); |
4650 else if(pixmap) | 4703 else if(pixmap) |
4651 hdcPaint = pixmap->hdc; | 4704 hdcPaint = pixmap->hdc; |
4652 else | 4705 else |
4653 return; | 4706 return; |
4654 | 4707 |
4655 SetPixel(hdcPaint, x, y, _foreground); | 4708 SetPixel(hdcPaint, x, y, _foreground[threadid]); |
4656 if(!pixmap) | 4709 if(!pixmap) |
4657 ReleaseDC(handle, hdcPaint); | 4710 ReleaseDC(handle, hdcPaint); |
4658 } | 4711 } |
4659 | 4712 |
4660 /* Draw a line on a window (preferably a render window). | 4713 /* Draw a line on a window (preferably a render window). |
4668 */ | 4721 */ |
4669 void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) | 4722 void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) |
4670 { | 4723 { |
4671 HDC hdcPaint; | 4724 HDC hdcPaint; |
4672 HPEN oldPen; | 4725 HPEN oldPen; |
4726 int threadid = dw_thread_id(); | |
4727 | |
4728 if(threadid < 0 || threadid >= THREAD_LIMIT) | |
4729 threadid = 0; | |
4673 | 4730 |
4674 if(handle) | 4731 if(handle) |
4675 hdcPaint = GetDC(handle); | 4732 hdcPaint = GetDC(handle); |
4676 else if(pixmap) | 4733 else if(pixmap) |
4677 hdcPaint = pixmap->hdc; | 4734 hdcPaint = pixmap->hdc; |
4678 else | 4735 else |
4679 return; | 4736 return; |
4680 | 4737 |
4681 oldPen = SelectObject(hdcPaint, _hPen); | 4738 oldPen = SelectObject(hdcPaint, _hPen[threadid]); |
4682 MoveToEx(hdcPaint, x1, y1, NULL); | 4739 MoveToEx(hdcPaint, x1, y1, NULL); |
4683 LineTo(hdcPaint, x2, y2); | 4740 LineTo(hdcPaint, x2, y2); |
4684 SelectObject(hdcPaint, oldPen); | 4741 SelectObject(hdcPaint, oldPen); |
4685 /* For some reason Win98 (at least) fails | 4742 /* For some reason Win98 (at least) fails |
4686 * to draw the last pixel. So I do it myself. | 4743 * to draw the last pixel. So I do it myself. |
4687 */ | 4744 */ |
4688 SetPixel(hdcPaint, x2, y2, _foreground); | 4745 SetPixel(hdcPaint, x2, y2, _foreground[threadid]); |
4689 if(!pixmap) | 4746 if(!pixmap) |
4690 ReleaseDC(handle, hdcPaint); | 4747 ReleaseDC(handle, hdcPaint); |
4691 } | 4748 } |
4692 | 4749 |
4693 /* Draw a rectangle on a window (preferably a render window). | 4750 /* Draw a rectangle on a window (preferably a render window). |
4702 void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) | 4759 void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) |
4703 { | 4760 { |
4704 HDC hdcPaint; | 4761 HDC hdcPaint; |
4705 HPEN oldPen; | 4762 HPEN oldPen; |
4706 HBRUSH oldBrush; | 4763 HBRUSH oldBrush; |
4764 int threadid = dw_thread_id(); | |
4765 | |
4766 if(threadid < 0 || threadid >= THREAD_LIMIT) | |
4767 threadid = 0; | |
4707 | 4768 |
4708 if(handle) | 4769 if(handle) |
4709 hdcPaint = GetDC(handle); | 4770 hdcPaint = GetDC(handle); |
4710 else if(pixmap) | 4771 else if(pixmap) |
4711 hdcPaint = pixmap->hdc; | 4772 hdcPaint = pixmap->hdc; |
4712 else | 4773 else |
4713 return; | 4774 return; |
4714 | 4775 |
4715 oldPen = SelectObject(hdcPaint, _hPen); | 4776 oldPen = SelectObject(hdcPaint, _hPen[threadid]); |
4716 oldBrush = SelectObject(hdcPaint, _hBrush); | 4777 oldBrush = SelectObject(hdcPaint, _hBrush[threadid]); |
4717 Rectangle(hdcPaint, x, y, x + width, y + height); | 4778 Rectangle(hdcPaint, x, y, x + width, y + height); |
4718 SelectObject(hdcPaint, oldPen); | 4779 SelectObject(hdcPaint, oldPen); |
4719 SelectObject(hdcPaint, oldBrush); | 4780 SelectObject(hdcPaint, oldBrush); |
4720 if(!pixmap) | 4781 if(!pixmap) |
4721 ReleaseDC(handle, hdcPaint); | 4782 ReleaseDC(handle, hdcPaint); |
4732 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) | 4793 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) |
4733 { | 4794 { |
4734 HDC hdc; | 4795 HDC hdc; |
4735 int size = 9, z, mustdelete = 0; | 4796 int size = 9, z, mustdelete = 0; |
4736 HFONT hFont, oldFont; | 4797 HFONT hFont, oldFont; |
4798 int threadid = dw_thread_id(); | |
4799 | |
4800 if(threadid < 0 || threadid >= THREAD_LIMIT) | |
4801 threadid = 0; | |
4737 | 4802 |
4738 if(handle) | 4803 if(handle) |
4739 { | 4804 { |
4740 hdc = GetDC(handle); | 4805 hdc = GetDC(handle); |
4741 hFont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); | 4806 hFont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); |
4762 hFont = _aquire_font(cinfo->fontname); | 4827 hFont = _aquire_font(cinfo->fontname); |
4763 mustdelete = 1; | 4828 mustdelete = 1; |
4764 } | 4829 } |
4765 } | 4830 } |
4766 oldFont = SelectObject(hdc, hFont); | 4831 oldFont = SelectObject(hdc, hFont); |
4767 SetTextColor(hdc, _foreground); | 4832 SetTextColor(hdc, _foreground[threadid]); |
4768 SetBkMode(hdc, TRANSPARENT); | 4833 SetBkMode(hdc, TRANSPARENT); |
4769 TextOut(hdc, x, y, text, strlen(text)); | 4834 TextOut(hdc, x, y, text, strlen(text)); |
4770 SelectObject(hdc, oldFont); | 4835 SelectObject(hdc, oldFont); |
4771 if(mustdelete) | 4836 if(mustdelete) |
4772 DeleteObject(hFont); | 4837 DeleteObject(hFont); |