Mercurial > dwindows
comparison win/dw.c @ 7:005fa766e8c2
Updates to latest build.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 03 Jul 2001 13:54:29 +0000 |
parents | 67a643a734d9 |
children | 26e2130135b9 |
comparison
equal
deleted
inserted
replaced
6:160798fd63c4 | 7:005fa766e8c2 |
---|---|
1745 #endif | 1745 #endif |
1746 } | 1746 } |
1747 return DefWindowProc(hwnd, msg, mp1, mp2); | 1747 return DefWindowProc(hwnd, msg, mp1, mp2); |
1748 } | 1748 } |
1749 | 1749 |
1750 /* This handles drawing the status text areas */ | |
1751 BOOL CALLBACK _statuswndproc(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2) | |
1752 { | |
1753 switch (msg) | |
1754 { | |
1755 case WM_PAINT: | |
1756 { | |
1757 HDC hdcPaint; | |
1758 PAINTSTRUCT ps; | |
1759 RECT rcPaint; | |
1760 HBRUSH hBrush; | |
1761 HPEN hPen; | |
1762 HFONT hFont; | |
1763 char tempbuf[1024] = ""; | |
1764 | |
1765 hdcPaint = BeginPaint(hwnd, &ps); | |
1766 GetWindowRect(hwnd, &rcPaint); | |
1767 | |
1768 dw_color_foreground_set(DW_RGB(_red[DW_CLR_PALEGRAY], | |
1769 _green[DW_CLR_PALEGRAY], | |
1770 _blue[DW_CLR_PALEGRAY])); | |
1771 | |
1772 dw_draw_rect(hwnd, 0, TRUE, 1, 1, rcPaint.right - rcPaint.left - 2, rcPaint.bottom - rcPaint.top - 2); | |
1773 | |
1774 dw_color_foreground_set(DW_RGB(_red[DW_CLR_DARKGRAY], | |
1775 _green[DW_CLR_DARKGRAY], | |
1776 _blue[DW_CLR_DARKGRAY])); | |
1777 | |
1778 dw_draw_line(hwnd, 0, 0, 0, rcPaint.right - rcPaint.left, 0); | |
1779 dw_draw_line(hwnd, 0, 0, 0, 0, rcPaint.bottom - rcPaint.top); | |
1780 | |
1781 dw_color_foreground_set(DW_RGB(_red[DW_CLR_WHITE], | |
1782 _green[DW_CLR_WHITE], | |
1783 _blue[DW_CLR_WHITE])); | |
1784 | |
1785 dw_draw_line(hwnd, 0, rcPaint.right - rcPaint.left - 1, rcPaint.bottom - rcPaint.top - 1, rcPaint.right - rcPaint.left - 1, 0); | |
1786 dw_draw_line(hwnd, 0, rcPaint.right - rcPaint.left - 1, rcPaint.bottom - rcPaint.top - 1, 0, rcPaint.bottom - rcPaint.top - 1); | |
1787 | |
1788 rcPaint.left += 3; | |
1789 rcPaint.top++; | |
1790 rcPaint.bottom--; | |
1791 rcPaint.right--; | |
1792 | |
1793 GetWindowText(hwnd, tempbuf, 1024); | |
1794 | |
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)); | |
1802 | |
1803 ExtTextOut(hdcPaint, rcPaint.left, rcPaint.top, ETO_CLIPPED, | |
1804 &rcPaint, tempbuf, strlen(tempbuf), NULL); | |
1805 | |
1806 SelectObject(hdcPaint, hBrush); | |
1807 SelectObject(hdcPaint, hPen); | |
1808 SelectObject(hdcPaint, hFont); | |
1809 | |
1810 EndPaint(hwnd, &ps); | |
1811 } | |
1812 return FALSE; | |
1813 } | |
1814 return DefWindowProc(hwnd, msg, mp1, mp2); | |
1815 } | |
1816 | |
1750 /* Function: _BtProc | 1817 /* Function: _BtProc |
1751 * Abstract: Subclass procedure for buttons | 1818 * Abstract: Subclass procedure for buttons |
1752 */ | 1819 */ |
1753 | 1820 |
1754 BOOL CALLBACK _BtProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2) | 1821 BOOL CALLBACK _BtProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2) |
2317 GetClassName(handle, tmpbuf, 99); | 2384 GetClassName(handle, tmpbuf, 99); |
2318 | 2385 |
2319 if(strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME))==0) | 2386 if(strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME))==0) |
2320 return FALSE; | 2387 return FALSE; |
2321 | 2388 |
2389 if(strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW))==0) | |
2390 { | |
2391 ListView_SetTextColor(handle, RGB(DW_RED_VALUE(fore), | |
2392 DW_GREEN_VALUE(fore), | |
2393 DW_BLUE_VALUE(fore))); | |
2394 ListView_SetTextBkColor(handle, RGB(DW_RED_VALUE(back), | |
2395 DW_GREEN_VALUE(back), | |
2396 DW_BLUE_VALUE(back))); | |
2397 ListView_SetBkColor(handle, RGB(DW_RED_VALUE(back), | |
2398 DW_GREEN_VALUE(back), | |
2399 DW_BLUE_VALUE(back))); | |
2400 InvalidateRgn(handle, NULL, TRUE); | |
2401 return TRUE; | |
2402 } | |
2403 | |
2322 if(cinfo) | 2404 if(cinfo) |
2323 { | 2405 { |
2324 cinfo->fore = fore; | 2406 cinfo->fore = fore; |
2325 cinfo->back = back; | 2407 cinfo->back = back; |
2326 } | 2408 } |
2333 cinfo->buddy = 0; | 2415 cinfo->buddy = 0; |
2334 | 2416 |
2335 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); | 2417 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); |
2336 SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo); | 2418 SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo); |
2337 } | 2419 } |
2420 InvalidateRgn(handle, NULL, TRUE); | |
2338 return TRUE; | 2421 return TRUE; |
2339 } | 2422 } |
2340 | 2423 |
2341 /* | 2424 /* |
2342 * Sets the font used by a specified window (widget) handle. | 2425 * Sets the font used by a specified window (widget) handle. |
2735 * id: An ID to be used with WinWindowFromID() or 0L. | 2818 * id: An ID to be used with WinWindowFromID() or 0L. |
2736 */ | 2819 */ |
2737 HWND dw_text_new(char *text, ULONG id) | 2820 HWND dw_text_new(char *text, ULONG id) |
2738 { | 2821 { |
2739 HWND tmp = CreateWindow(STATICCLASSNAME, | 2822 HWND tmp = CreateWindow(STATICCLASSNAME, |
2740 text, | 2823 text, |
2741 BS_TEXT | WS_CHILD | WS_CLIPCHILDREN, | 2824 BS_TEXT | WS_CHILD | WS_CLIPCHILDREN, |
2742 0,0,2000,1000, | 2825 0,0,2000,1000, |
2743 DW_HWND_OBJECT, | 2826 DW_HWND_OBJECT, |
2744 (HMENU)id, | 2827 (HMENU)id, |
2745 NULL, | 2828 NULL, |
2746 NULL); | 2829 NULL); |
2747 dw_window_set_font(tmp, DefaultFont); | 2830 dw_window_set_font(tmp, DefaultFont); |
2831 return tmp; | |
2832 } | |
2833 | |
2834 /* | |
2835 * Create a new status text window (widget) to be packed. | |
2836 * Parameters: | |
2837 * text: The text to be display by the static text widget. | |
2838 * id: An ID to be used with WinWindowFromID() or 0L. | |
2839 */ | |
2840 HWND dw_status_text_new(char *text, ULONG id) | |
2841 { | |
2842 HWND tmp = CreateWindow(STATICCLASSNAME, | |
2843 text, | |
2844 BS_TEXT | WS_CHILD | WS_CLIPCHILDREN, | |
2845 0,0,2000,1000, | |
2846 DW_HWND_OBJECT, | |
2847 (HMENU)id, | |
2848 NULL, | |
2849 NULL); | |
2850 dw_window_set_font(tmp, DefaultFont); | |
2851 SubclassWindow(tmp, _statuswndproc); | |
2748 return tmp; | 2852 return tmp; |
2749 } | 2853 } |
2750 | 2854 |
2751 /* | 2855 /* |
2752 * Create a new Multiline Editbox window (widget) to be packed. | 2856 * Create a new Multiline Editbox window (widget) to be packed. |
3902 int point = (int)SendMessage(handle, EM_LINEINDEX, (WPARAM)line, 0); | 4006 int point = (int)SendMessage(handle, EM_LINEINDEX, (WPARAM)line, 0); |
3903 dw_mle_set(handle, point); | 4007 dw_mle_set(handle, point); |
3904 } | 4008 } |
3905 | 4009 |
3906 /* | 4010 /* |
4011 * Sets the editablity of an MLE box. | |
4012 * Parameters: | |
4013 * handle: Handle to the MLE. | |
4014 * state: TRUE if it can be edited, FALSE for readonly. | |
4015 */ | |
4016 void dw_mle_set_editable(HWND handle, int state) | |
4017 { | |
4018 SendMessage(handle, EM_SETREADONLY, (WPARAM)(state ? FALSE : TRUE), 0); | |
4019 } | |
4020 | |
4021 /* | |
4022 * Sets the word wrap state of an MLE box. | |
4023 * Parameters: | |
4024 * handle: Handle to the MLE. | |
4025 * state: TRUE if it wraps, FALSE if it doesn't. | |
4026 */ | |
4027 void dw_mle_set_word_wrap(HWND handle, int state) | |
4028 { | |
4029 } | |
4030 | |
4031 /* | |
3907 * Sets the current cursor position of an MLE box. | 4032 * Sets the current cursor position of an MLE box. |
3908 * Parameters: | 4033 * Parameters: |
3909 * handle: Handle to the MLE to be positioned. | 4034 * handle: Handle to the MLE to be positioned. |
3910 * point: Point to position cursor. | 4035 * point: Point to position cursor. |
3911 */ | 4036 */ |
4184 * handle: Handle to the container window (widget). | 4309 * handle: Handle to the container window (widget). |
4185 * rowcount: The number of items to be populated. | 4310 * rowcount: The number of items to be populated. |
4186 */ | 4311 */ |
4187 void *dw_container_alloc(HWND handle, int rowcount) | 4312 void *dw_container_alloc(HWND handle, int rowcount) |
4188 { | 4313 { |
4314 LV_ITEM lvi; | |
4315 int z; | |
4316 | |
4317 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT; | |
4318 lvi.iSubItem = 0; | |
4319 lvi.pszText = ""; | |
4320 lvi.cchTextMax = 1; | |
4321 | |
4322 for(z=0;z<rowcount;z++) | |
4323 ListView_InsertItem(handle, &lvi); | |
4189 return (void *)handle; | 4324 return (void *)handle; |
4190 } | 4325 } |
4191 | 4326 |
4192 /* Finds a icon in the table, otherwise it adds it to the table | 4327 /* Finds a icon in the table, otherwise it adds it to the table |
4193 * and returns the index in the table. | 4328 * and returns the index in the table. |
4335 sprintf(textbuffer, "%d:%s%dam", ftime.hours ? ftime.hours : 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); | 4470 sprintf(textbuffer, "%d:%s%dam", ftime.hours ? ftime.hours : 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); |
4336 lvi.pszText = textbuffer; | 4471 lvi.pszText = textbuffer; |
4337 lvi.cchTextMax = strlen(textbuffer); | 4472 lvi.cchTextMax = strlen(textbuffer); |
4338 } | 4473 } |
4339 | 4474 |
4340 if(column == 0) | 4475 ListView_SetItemText(handle, row, column, destptr); |
4341 ListView_InsertItem(handle, &lvi); | |
4342 else | |
4343 ListView_SetItemText(handle, row, column, destptr); | |
4344 } | 4476 } |
4345 | 4477 |
4346 /* | 4478 /* |
4347 * Sets the title of a row in the container. | 4479 * Sets the title of a row in the container. |
4348 * Parameters: | 4480 * Parameters: |
4359 lvi.iSubItem = 0; | 4491 lvi.iSubItem = 0; |
4360 lvi.mask = LVIF_PARAM; | 4492 lvi.mask = LVIF_PARAM; |
4361 lvi.lParam = (LPARAM)title; | 4493 lvi.lParam = (LPARAM)title; |
4362 | 4494 |
4363 if(!ListView_SetItem(container, &lvi) && lvi.lParam) | 4495 if(!ListView_SetItem(container, &lvi) && lvi.lParam) |
4364 { | |
4365 free((void *)lvi.lParam); | |
4366 lvi.lParam = 0; | 4496 lvi.lParam = 0; |
4367 } | |
4368 | 4497 |
4369 } | 4498 } |
4370 | 4499 |
4371 /* | 4500 /* |
4372 * Sets the title of a row in the container. | 4501 * Sets the title of a row in the container. |