- Timestamp:
- Oct 8, 1999, 11:26:08 PM (26 years ago)
- Location:
- trunk/src/user32
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/button.cpp
r1184 r1203 1 /* $Id: button.cpp,v 1. 4 1999-10-08 12:10:26cbratschi Exp $ */1 /* $Id: button.cpp,v 1.5 1999-10-08 21:23:07 cbratschi Exp $ */ 2 2 /* File: button.cpp -- Button type widgets 3 3 * … … 6 6 * Copyright (C) 1994 Alexandre Julliard 7 7 * Copyright (c) 1999 Christoph Bratschi 8 * 9 * WINE version: 990923 8 10 */ 9 11 … … 467 469 dwStyle &= ~WS_TABSTOP; 468 470 469 if (oldStyle != dwStyle) SetWindowLongA(hwnd,GWL_STYLE,dwStyle);471 //if (oldStyle != dwStyle) SetWindowLongA(hwnd,GWL_STYLE,dwStyle); 470 472 } 471 473 infoPtr->state = (infoPtr->state & ~3) | wParam; … … 930 932 if (action == ODA_DRAWENTIRE || action == ODA_SELECT) 931 933 { 932 HDC hMemDC = CreateCompatibleDC( hDC ); 933 int x = 0, y = 0; 934 delta = (rbox.bottom - rbox.top - checkBoxHeight) >> 1; 935 936 if (action == ODA_SELECT) FillRect( hDC, &rbox, hBrush ); 937 else FillRect( hDC, &client, hBrush ); 938 939 if (infoPtr->state & BUTTON_HIGHLIGHTED) x += 2 * checkBoxWidth; 940 if (infoPtr->state & (BUTTON_CHECKED | BUTTON_3STATE)) x += checkBoxWidth; 934 UINT state; 935 941 936 if (((dwStyle & 0x0f) == BS_RADIOBUTTON) || 942 ((dwStyle & 0x0f) == BS_AUTORADIOBUTTON)) y += checkBoxHeight; 943 else if (infoPtr->state & BUTTON_3STATE) y += 2 * checkBoxHeight; 944 945 SelectObject( hMemDC, hbitmapCheckBoxes ); 946 BitBlt( hDC, rbox.left, rbox.top + delta, checkBoxWidth, 947 checkBoxHeight, hMemDC, x, y, SRCCOPY ); 948 DeleteDC( hMemDC ); 937 ((dwStyle & 0x0f) == BS_AUTORADIOBUTTON)) state = DFCS_BUTTONRADIO; 938 else if (infoPtr->state & BUTTON_3STATE) state = DFCS_BUTTON3STATE; 939 else state = DFCS_BUTTONCHECK; 940 941 if (infoPtr->state & (BUTTON_CHECKED | BUTTON_3STATE)) state |= DFCS_CHECKED; 942 943 if (infoPtr->state & BUTTON_HIGHLIGHTED) state |= DFCS_PUSHED; 944 945 if (dwStyle & WS_DISABLED) state |= DFCS_INACTIVE; 946 947 DrawFrameControl( hDC, &rbox, DFC_BUTTON, state ); 949 948 950 949 if( text && action != ODA_SELECT ) … … 960 959 DrawTextA( hDC, text, -1, &rtext, 961 960 DT_SINGLELINE | DT_VCENTER ); 962 textLen = 0; /* skip DrawText() below */963 961 } 964 962 } -
trunk/src/user32/combo.cpp
r1184 r1203 1 /* $Id: combo.cpp,v 1. 3 1999-10-08 12:10:26cbratschi Exp $ */1 /* $Id: combo.cpp,v 1.4 1999-10-08 21:23:37 cbratschi Exp $ */ 2 2 /* 3 3 * Combo controls … … 7 7 * 8 8 * FIXME: roll up in Netscape 3.01. 9 * 10 * WINE version: 990923 9 11 */ 10 12 … … 655 657 RECT rectButton) 656 658 { 657 UINT x, y;658 BOOL bBool;659 HDC hMemDC;660 HBRUSH hPrevBrush;661 COLORREF oldTextColor, oldBkColor;662 663 659 if( lphc->wState & CBF_NOREDRAW ) 664 660 return; 665 661 666 hPrevBrush = SelectObject(hdc, GetSysColorBrush(COLOR_BTNFACE)); 667 668 /* 669 * Draw the button background 670 */ 671 PatBlt( hdc, 672 rectButton.left, 673 rectButton.top, 674 rectButton.right-rectButton.left, 675 rectButton.bottom-rectButton.top, 676 PATCOPY ); 677 678 bBool = lphc->wState & CBF_BUTTONDOWN; 679 if (bBool) 662 663 UINT buttonState = DFCS_SCROLLCOMBOBOX; 664 665 if (lphc->wState & CBF_BUTTONDOWN) 680 666 { 681 DrawEdge( hdc, &rectButton, EDGE_SUNKEN, BF_RECT );667 buttonState |= DFCS_PUSHED; 682 668 } 683 else 669 670 if (CB_DISABLED(lphc)) 684 671 { 685 DrawEdge( hdc, &rectButton, EDGE_RAISED, BF_RECT );672 buttonState |= DFCS_INACTIVE; 686 673 } 687 674 688 /* 689 * Remove the edge of the button from the rectangle 690 * and calculate the position of the bitmap. 691 */ 692 InflateRect( &rectButton, -2, -2); 693 694 x = (rectButton.left + rectButton.right - CBitWidth) >> 1; 695 y = (rectButton.top + rectButton.bottom - CBitHeight) >> 1; 696 697 698 hMemDC = CreateCompatibleDC( hdc ); 699 SelectObject( hMemDC, hComboBmp ); 700 oldTextColor = SetTextColor( hdc, GetSysColor(COLOR_BTNFACE) ); 701 oldBkColor = SetBkColor( hdc, CB_DISABLED(lphc) ? RGB(128,128,128) : 702 RGB(0,0,0) ); 703 BitBlt( hdc, x, y, CBitWidth, CBitHeight, hMemDC, 0, 0, SRCCOPY ); 704 SetBkColor( hdc, oldBkColor ); 705 SetTextColor( hdc, oldTextColor ); 706 DeleteDC( hMemDC ); 707 SelectObject( hdc, hPrevBrush ); 675 DrawFrameControl(hdc,&rectButton,DFC_SCROLL,buttonState); 708 676 } 709 677 … … 718 686 RECT rectEdit) 719 687 { 720 INT 721 LPSTR 688 INT id, size = 0; 689 LPSTR pText = NULL; 722 690 723 691 if( lphc->wState & CBF_NOREDRAW ) return; … … 729 697 { 730 698 size = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, id, 0); 731 pText = (LPSTR)HeapAlloc( GetProcessHeap(), 0, size + 1); 732 if(pText) 733 { 734 SendMessageA( lphc->hWndLBox, LB_GETTEXT, (WPARAM)id, (LPARAM)pText ); 735 pText[size] = '\0'; /* just in case */ 736 } else return; 699 if( (pText = (char*)HeapAlloc( GetProcessHeap(), 0, size + 1)) != NULL ) 700 { 701 SendMessageA( lphc->hWndLBox, LB_GETTEXT, (WPARAM)id, (LPARAM)pText ); 702 pText[size] = '\0'; /* just in case */ 703 } else return; 737 704 } 738 705 739 706 if( lphc->wState & CBF_EDIT ) 740 707 { 741 742 743 708 if( CB_HASSTRINGS(lphc) ) SetWindowTextA( lphc->hWndEdit, pText ? pText : "" ); 709 if( lphc->wState & CBF_FOCUSED ) 710 SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1)); 744 711 } 745 712 else /* paint text field ourselves */ 746 713 { 747 HBRUSH hPrevBrush = 0; 748 HDC hDC = hdc; 749 750 if( !hDC ) 751 { 752 hDC = GetDC(lphc->hwndself); 753 if (hDC) 754 { 755 HBRUSH hBrush = SendMessageA( lphc->owner, 756 WM_CTLCOLORLISTBOX, 757 hDC, lphc->hwndself ); 758 hPrevBrush = SelectObject( hDC, 759 (hBrush) ? hBrush : GetStockObject(WHITE_BRUSH) ); 760 } 761 } 762 if( hDC ) 763 { 764 UINT itemState; 765 HFONT hPrevFont = (lphc->hFont) ? SelectObject(hDC, lphc->hFont) : 0; 766 767 /* 768 * Give ourselves some space. 769 */ 770 InflateRect( &rectEdit, -1, -1 ); 771 772 if ( (lphc->wState & CBF_FOCUSED) && 773 !(lphc->wState & CBF_DROPPED) ) 774 { 775 /* highlight */ 776 777 FillRect( hDC, &rectEdit, GetSysColorBrush(COLOR_HIGHLIGHT) ); 778 SetBkColor( hDC, GetSysColor( COLOR_HIGHLIGHT ) ); 779 SetTextColor( hDC, GetSysColor( COLOR_HIGHLIGHTTEXT ) ); 780 itemState = ODS_SELECTED | ODS_FOCUS; 781 } 782 else 783 itemState = 0; 784 785 if( CB_OWNERDRAWN(lphc) ) 786 { 787 DRAWITEMSTRUCT dis; 788 HRGN clipRegion; 789 790 /* 791 * Save the current clip region. 792 * To retrieve the clip region, we need to create one "dummy" 793 * clip region. 794 */ 795 clipRegion = CreateRectRgnIndirect(&rectEdit); 796 797 if (GetClipRgn(hDC, clipRegion)!=1) 798 { 799 DeleteObject(clipRegion); 800 clipRegion=(HRGN)NULL; 801 } 802 803 if ( GetWindowLongA(lphc->hwndself,GWL_STYLE) & WS_DISABLED ) 804 itemState |= ODS_DISABLED; 805 806 dis.CtlType = ODT_COMBOBOX; 807 dis.CtlID = GetWindowLongA(lphc->hwndself,GWL_ID); 808 dis.hwndItem = lphc->hwndself; 809 dis.itemAction = ODA_DRAWENTIRE; 810 dis.itemID = id; 811 dis.itemState = itemState; 812 dis.hDC = hDC; 813 dis.rcItem = rectEdit; 814 dis.itemData = SendMessageA( lphc->hWndLBox, LB_GETITEMDATA, 815 (WPARAM)id, 0 ); 816 817 /* 818 * Clip the DC and have the parent draw the item. 819 */ 820 IntersectClipRect(hDC, 821 rectEdit.left, rectEdit.top, 822 rectEdit.right, rectEdit.bottom); 823 824 SendMessageA(lphc->owner, WM_DRAWITEM, 825 GetWindowLongA(lphc->hwndself,GWL_ID), (LPARAM)&dis ); 826 827 /* 828 * Reset the clipping region. 829 */ 830 SelectClipRgn(hDC, clipRegion); 831 } 832 else 833 { 834 ExtTextOutA( hDC, 835 rectEdit.left + 1, 836 rectEdit.top + 1, 837 ETO_OPAQUE | ETO_CLIPPED, 838 &rectEdit, 839 pText ? pText : "" , size, NULL ); 840 841 if(lphc->wState & CBF_FOCUSED && !(lphc->wState & CBF_DROPPED)) 842 DrawFocusRect( hDC, &rectEdit ); 843 } 844 845 if( hPrevFont ) 846 SelectObject(hDC, hPrevFont ); 847 848 if( !hdc ) 849 { 850 if( hPrevBrush ) 851 SelectObject( hDC, hPrevBrush ); 852 853 ReleaseDC( lphc->hwndself, hDC ); 854 } 855 } 714 UINT itemState; 715 HFONT hPrevFont = (lphc->hFont) ? SelectObject(hdc, lphc->hFont) : 0; 716 717 /* 718 * Give ourselves some space. 719 */ 720 InflateRect( &rectEdit, -1, -1 ); 721 722 if ( (lphc->wState & CBF_FOCUSED) && 723 !(lphc->wState & CBF_DROPPED) ) 724 { 725 /* highlight */ 726 727 FillRect( hdc, &rectEdit, GetSysColorBrush(COLOR_HIGHLIGHT) ); 728 SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) ); 729 SetTextColor( hdc, GetSysColor( COLOR_HIGHLIGHTTEXT ) ); 730 itemState = ODS_SELECTED | ODS_FOCUS; 731 } 732 else 733 itemState = 0; 734 735 if( CB_OWNERDRAWN(lphc) ) 736 { 737 DRAWITEMSTRUCT dis; 738 HRGN clipRegion; 739 DWORD dwStyle = GetWindowLongA(lphc->hwndself,GWL_STYLE); 740 741 /* 742 * Save the current clip region. 743 * To retrieve the clip region, we need to create one "dummy" 744 * clip region. 745 */ 746 clipRegion = CreateRectRgnIndirect(&rectEdit); 747 748 if (GetClipRgn(hdc, clipRegion)!=1) 749 { 750 DeleteObject(clipRegion); 751 clipRegion=(HRGN)NULL; 752 } 753 754 if ( dwStyle & WS_DISABLED ) 755 itemState |= ODS_DISABLED; 756 757 dis.CtlType = ODT_COMBOBOX; 758 dis.CtlID = GetWindowLongA(lphc->hwndself,GWL_ID); 759 dis.hwndItem = lphc->hwndself; 760 dis.itemAction = ODA_DRAWENTIRE; 761 dis.itemID = id; 762 dis.itemState = itemState; 763 dis.hDC = hdc; 764 dis.rcItem = rectEdit; 765 dis.itemData = SendMessageA( lphc->hWndLBox, LB_GETITEMDATA, 766 (WPARAM)id, 0 ); 767 768 /* 769 * Clip the DC and have the parent draw the item. 770 */ 771 IntersectClipRect(hdc, 772 rectEdit.left, rectEdit.top, 773 rectEdit.right, rectEdit.bottom); 774 775 SendMessageA(lphc->owner, WM_DRAWITEM, 776 GetWindowLongA(lphc->hwndself,GWL_ID), (LPARAM)&dis ); 777 778 /* 779 * Reset the clipping region. 780 */ 781 SelectClipRgn(hdc, clipRegion); 782 } 783 else 784 { 785 ExtTextOutA( hdc, 786 rectEdit.left + 1, 787 rectEdit.top + 1, 788 ETO_OPAQUE | ETO_CLIPPED, 789 &rectEdit, 790 pText ? pText : "" , size, NULL ); 791 792 if(lphc->wState & CBF_FOCUSED && !(lphc->wState & CBF_DROPPED)) 793 DrawFocusRect( hdc, &rectEdit ); 794 } 795 796 if( hPrevFont ) 797 SelectObject(hdc, hPrevFont ); 856 798 } 857 799 if (pText) 858 800 HeapFree( GetProcessHeap(), 0, pText ); 859 801 } 860 802 … … 885 827 886 828 /*********************************************************************** 829 * COMBO_PrepareColors 830 * 831 * This method will sent the appropriate WM_CTLCOLOR message to 832 * prepare and setup the colors for the combo's DC. 833 * 834 * It also returns the brush to use for the background. 835 */ 836 static HBRUSH COMBO_PrepareColors( 837 HWND hwnd, 838 LPHEADCOMBO lphc, 839 HDC hDC) 840 { 841 HBRUSH hBkgBrush; 842 843 /* 844 * Get the background brush for this control. 845 */ 846 if (CB_DISABLED(lphc)) 847 { 848 hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORSTATIC, 849 hDC, lphc->hwndself ); 850 851 /* 852 * We have to change the text color since WM_CTLCOLORSTATIC will 853 * set it to the "enabled" color. This is the same behavior as the 854 * edit control 855 */ 856 SetTextColor(hDC, GetSysColor(COLOR_GRAYTEXT)); 857 } 858 else 859 { 860 if (lphc->wState & CBF_EDIT) 861 { 862 hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLOREDIT, 863 hDC, lphc->hwndself ); 864 } 865 else 866 { 867 hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORLISTBOX, 868 hDC, lphc->hwndself ); 869 } 870 } 871 872 /* 873 * Catch errors. 874 */ 875 if( !hBkgBrush ) 876 hBkgBrush = GetSysColorBrush(COLOR_WINDOW); 877 878 return hBkgBrush; 879 } 880 881 /*********************************************************************** 887 882 * COMBO_EraseBackground 888 883 */ … … 913 908 } 914 909 915 hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORLISTBOX, 916 hDC, hwnd); 917 918 if( !hBkgBrush ) 919 hBkgBrush = GetStockObject(WHITE_BRUSH); 910 /* 911 * Retrieve the background brush 912 */ 913 hBkgBrush = COMBO_PrepareColors(hwnd, lphc, hDC); 920 914 921 915 FillRect(hDC, &clientRect, hBkgBrush); … … 943 937 HBRUSH hPrevBrush, hBkgBrush; 944 938 945 hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORLISTBOX,946 hDC, lphc->hwndself );947 948 if( !hBkgBrush )949 hBkgBrush = GetStockObject(WHITE_BRUSH);939 /* 940 * Retrieve the background brush and select it in the 941 * DC. 942 */ 943 hBkgBrush = COMBO_PrepareColors(lphc->hwndself, lphc, hDC); 950 944 951 945 hPrevBrush = SelectObject( hDC, hBkgBrush ); … … 1082 1076 int i; 1083 1077 int nHeight; 1084 int nDroppedHeight ;1078 int nDroppedHeight,nTempDroppedHeight; 1085 1079 1086 1080 //TRACE("[%04x]: drop down\n", CB_HWND(lphc)); … … 1122 1116 of the items in the dropped list */ 1123 1117 1118 /* And Remove any extra space (Best Fit) */ 1124 1119 nDroppedHeight = lphc->droppedRect.bottom - lphc->droppedRect.top; 1125 1120 nItems = (int)SendMessageA (lphc->hWndLBox, LB_GETCOUNT, 0, 0); 1126 nHeight = COMBO_YBORDERGAP; 1121 nHeight = COMBO_YBORDERSIZE(); 1122 nTempDroppedHeight = 0; 1127 1123 for (i = 0; i < nItems; i++) 1128 1124 { 1129 1125 nHeight += (int)SendMessageA (lphc->hWndLBox, LB_GETITEMHEIGHT, i, 0); 1130 1126 1131 if (nHeight >= nDroppedHeight) 1127 /* Did we pass the limit of what can be displayed */ 1128 if (nHeight > nDroppedHeight) 1129 { 1132 1130 break; 1133 1131 } 1134 1135 if (nHeight < nDroppedHeight) 1136 nDroppedHeight = nHeight; 1132 nTempDroppedHeight = nHeight; 1133 } 1134 1135 nDroppedHeight = nTempDroppedHeight; 1137 1136 1138 1137 SetWindowPos( lphc->hWndLBox, HWND_TOP, rect.left, rect.bottom, … … 1177 1176 lphc->wState &= ~CBF_DROPPED; 1178 1177 ShowWindow( lphc->hWndLBox, SW_HIDE ); 1178 if(GetCapture() == lphc->hWndLBox) 1179 { 1180 ReleaseCapture(); 1181 } 1182 1179 1183 1180 1184 if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) … … 1708 1712 } 1709 1713 ReleaseCapture(); 1714 SetCapture(lphc->hWndLBox); 1710 1715 } 1711 1716 … … 1852 1857 EnableWindow( lphc->hWndEdit, (BOOL)wParam ); 1853 1858 EnableWindow( lphc->hWndLBox, (BOOL)wParam ); 1859 1860 /* Force the control to repaint when the enabled state changes. */ 1861 InvalidateRect(CB_HWND(lphc), NULL, TRUE); 1854 1862 return TRUE; 1855 1863 case WM_SETREDRAW: -
trunk/src/user32/edit.cpp
r949 r1203 1 /* $Id: edit.cpp,v 1. 1 1999-09-15 23:18:50 sandervlExp $ */1 /* $Id: edit.cpp,v 1.2 1999-10-08 21:24:07 cbratschi Exp $ */ 2 2 /* 3 3 * Edit control … … 9 9 * Copyright 1999 Christoph Bratschi (ported from WINE) 10 10 * 11 * WINE version: 990923 11 12 */ 12 13 … … 90 91 INT y_offset; /* scroll offset in number of lines */ 91 92 BOOL bCaptureState; /* flag indicating whether mouse was captured */ 93 BOOL bEnableState; /* flag keeping the enable state */ 92 94 /* 93 95 * only for multi line controls … … 214 216 static LRESULT EDIT_WM_MouseMove(HWND hwnd, EDITSTATE *es, DWORD keys, INT x, INT y); 215 217 static LRESULT EDIT_WM_NCCreate(HWND hwnd, LPCREATESTRUCTA cs); 216 static void EDIT_WM_Paint(HWND hwnd, EDITSTATE *es );218 static void EDIT_WM_Paint(HWND hwnd, EDITSTATE *es,WPARAM wParam); 217 219 static void EDIT_WM_Paste(HWND hwnd, EDITSTATE *es); 218 220 static void EDIT_WM_SetFocus(HWND hwnd, EDITSTATE *es, HWND window_losing_focus); … … 320 322 //DPRINTF_EDIT_MSG32("EM_SETSEL"); 321 323 EDIT_EM_SetSel(hwnd, es, wParam, lParam, FALSE); 324 EDIT_EM_ScrollCaret(hwnd,es); 322 325 result = 1; 323 326 break; … … 598 601 case WM_ENABLE: 599 602 //DPRINTF_EDIT_MSG32("WM_ENABLE"); 603 es->bEnableState = (BOOL)wParam; 600 604 InvalidateRect(hwnd, NULL, TRUE); 601 605 break; … … 672 676 case WM_PAINT: 673 677 //DPRINTF_EDIT_MSG32("WM_PAINT"); 674 EDIT_WM_Paint(hwnd, es );678 EDIT_WM_Paint(hwnd, es,wParam); 675 679 break; 676 680 … … 1297 1301 INT e; 1298 1302 1299 if (es->style & ES_MULTILINE) 1300 e = EDIT_CharFromPos(hwnd, es, 0x7fffffff, 1301 HIWORD(EDIT_EM_PosFromChar(hwnd, es, es->selection_end, es->flags & EF_AFTER_WRAP)), &after_wrap); 1303 /* Pass a high value in x to make sure of receiving the en of the line */ 1304 if (es->style & ES_MULTILINE) 1305 e = EDIT_CharFromPos(hwnd, es, 0x3fffffff, 1306 HIWORD(EDIT_EM_PosFromChar(hwnd, es, es->selection_end, es->flags & EF_AFTER_WRAP)), &after_wrap); 1302 1307 else 1303 1308 e = lstrlenA(es->text); … … 1341 1346 INT e; 1342 1347 1343 if (es->style & ES_MULTILINE) 1344 e = EDIT_CharFromPos(hwnd, es, 0x80000000, 1345 HIWORD(EDIT_EM_PosFromChar(hwnd, es, es->selection_end, es->flags & EF_AFTER_WRAP)), NULL); 1346 else 1347 e = 0; 1348 EDIT_EM_SetSel(hwnd, es, e, extend ? es->selection_start : e, FALSE); 1348 /* Pass the x_offset in x to make sure of receiving the first position of the line */ 1349 if (es->style & ES_MULTILINE) 1350 e = EDIT_CharFromPos(hwnd, es, -es->x_offset, 1351 HIWORD(EDIT_EM_PosFromChar(hwnd, es, es->selection_end, es->flags & EF_AFTER_WRAP)), NULL); 1352 else 1353 e = 0; 1354 EDIT_EM_SetSel(hwnd, es, extend ? es->selection_start : e, e, FALSE); 1349 1355 EDIT_EM_ScrollCaret(hwnd, es); 1350 1356 } … … 2563 2569 static void EDIT_WM_Char(HWND hwnd, EDITSTATE *es, CHAR c, DWORD key_data) 2564 2570 { 2571 BOOL control = GetKeyState(VK_CONTROL) & 0x8000; 2565 2572 switch (c) { 2566 2573 case '\r': 2574 /* If the edit doesn't want the return, do nothing */ 2575 if(!(es->style & ES_WANTRETURN)) 2576 break; 2567 2577 case '\n': 2568 2578 if (es->style & ES_MULTILINE) { … … 2578 2588 EDIT_EM_ReplaceSel(hwnd, es, TRUE, "\t"); 2579 2589 break; 2590 case VK_BACK: 2591 if (!(es->style & ES_READONLY) && !control) { 2592 if (es->selection_start != es->selection_end) 2593 EDIT_WM_Clear(hwnd, es); 2594 else { 2595 /* delete character left of caret */ 2596 EDIT_EM_SetSel(hwnd, es, -1, 0, FALSE); 2597 EDIT_MoveBackward(hwnd, es, TRUE); 2598 EDIT_WM_Clear(hwnd, es); 2599 } 2600 } 2601 break; 2580 2602 default: 2581 2603 if (!(es->style & ES_READONLY) && ((BYTE)c >= ' ') && (c != 127)) { … … 2699 2721 /********************************************************************* 2700 2722 * 2701 * 2723 * WM_CREATE 2702 2724 * 2703 2725 */ 2704 2726 static LRESULT EDIT_WM_Create(HWND hwnd, EDITSTATE *es, LPCREATESTRUCTA cs) 2705 2727 { 2706 2707 *To initialize some final structure members, we call some helper2708 *functions. However, since the EDITSTATE is not consistent (i.e.2709 *not fully initialized), we should be very careful which2710 *functions can be called, and in what order.2711 2728 /* 2729 * To initialize some final structure members, we call some helper 2730 * functions. However, since the EDITSTATE is not consistent (i.e. 2731 * not fully initialized), we should be very careful which 2732 * functions can be called, and in what order. 2733 */ 2712 2734 EDIT_WM_SetFont(hwnd, es, 0, FALSE); 2713 EDIT_EM_EmptyUndoBuffer(hwnd, es); 2714 2715 if (cs->lpszName && *(cs->lpszName) != '\0') { 2716 EDIT_EM_ReplaceSel(hwnd, es, FALSE, cs->lpszName); 2717 /* if we insert text to the editline, the text scrolls out of the window, as the caret is placed after the insert pos normally; thus we reset es->selection... to 0 and update caret */ 2718 es->selection_start = es->selection_end = 0; 2719 EDIT_EM_ScrollCaret(hwnd, es); 2720 } 2721 return 0; 2735 EDIT_EM_EmptyUndoBuffer(hwnd, es); 2736 if (cs->lpszName && *(cs->lpszName) != '\0') { 2737 EDIT_EM_ReplaceSel(hwnd, es, FALSE, cs->lpszName); 2738 /* if we insert text to the editline, the text scrolls out 2739 * of the window, as the caret is placed after the insert 2740 * pos normally; thus we reset es->selection... to 0 and 2741 * update caret 2742 */ 2743 es->selection_start = es->selection_end = 0; 2744 EDIT_EM_ScrollCaret(hwnd, es); 2745 } 2746 return 0; 2722 2747 } 2723 2748 … … 2751 2776 RECT rc; 2752 2777 2753 if (! IsWindowEnabled(hwnd)|| (es->style & ES_READONLY))2778 if (!es->bEnableState || (es->style & ES_READONLY)) 2754 2779 brush = (HBRUSH)EDIT_SEND_CTLCOLORSTATIC(hwnd, dc); 2755 2780 else … … 3039 3064 EDIT_MovePageDown_ML(hwnd, es, shift); 3040 3065 break; 3041 case VK_BACK:3042 if (!(es->style & ES_READONLY) && !control) {3043 if (es->selection_start != es->selection_end)3044 EDIT_WM_Clear(hwnd, es);3045 else {3046 /* delete character left of caret */3047 EDIT_EM_SetSel(hwnd, es, -1, 0, FALSE);3048 EDIT_MoveBackward(hwnd, es, TRUE);3049 EDIT_WM_Clear(hwnd, es);3050 }3051 }3052 break;3053 3066 case VK_DELETE: 3054 3067 if (!(es->style & ES_READONLY) && !(shift && control)) { … … 3085 3098 EDIT_WM_Copy(hwnd, es); 3086 3099 break; 3100 case VK_RETURN: 3101 /* If the edit doesn't want the return send a message to the default object */ 3102 if(!(es->style & ES_WANTRETURN)) 3103 { 3104 HWND hwndParent = GetParent(hwnd); 3105 DWORD dw = SendMessageA( hwndParent, DM_GETDEFID, 0, 0 ); 3106 if (HIWORD(dw) == DC_HASDEFID) 3107 { 3108 SendMessageA( hwndParent, WM_COMMAND, 3109 MAKEWPARAM( LOWORD(dw), BN_CLICKED ), 3110 (LPARAM)GetDlgItem( hwndParent, LOWORD(dw) ) ); 3111 } 3112 } 3113 break; 3087 3114 } 3088 3115 return 0; … … 3167 3194 static LRESULT EDIT_WM_LButtonUp(HWND hwnd, EDITSTATE *es, DWORD keys, INT x, INT y) 3168 3195 { 3169 3170 3171 3172 3173 3174 3175 3196 if (es->bCaptureState && GetCapture() == hwnd) { 3197 KillTimer(hwnd, 0); 3198 ReleaseCapture(); 3199 } 3200 es->bCaptureState = FALSE; 3201 3202 return 0; 3176 3203 } 3177 3204 … … 3228 3255 es->style = cs->style; 3229 3256 3230 3231 /* 3232 * In Win95 look and feel, the WS_BORDER style is replaced by the 3233 * WS_EX_CLIENTEDGE style for the edit control. This gives the edit 3234 * control a non client area. 3235 */ 3257 es->bEnableState = !(cs->style & WS_DISABLED); 3258 3259 /* 3260 * In Win95 look and feel, the WS_BORDER style is replaced by the 3261 * WS_EX_CLIENTEDGE style for the edit control. This gives the edit 3262 * control a non client area. 3263 */ 3236 3264 if (es->style & WS_BORDER) 3237 3238 3239 3240 3241 3242 3265 { 3266 es->style &= ~WS_BORDER; 3267 SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE) & ~WS_BORDER); 3268 SetWindowLongA(hwnd,GWL_EXSTYLE,GetWindowLongA(hwnd,GWL_EXSTYLE) | WS_EX_CLIENTEDGE); 3269 } 3270 3243 3271 if (es->style & ES_MULTILINE) { 3244 3272 es->buffer_size = BUFSTART_MULTI; … … 3298 3326 * 3299 3327 */ 3300 static void EDIT_WM_Paint(HWND hwnd, EDITSTATE *es )3328 static void EDIT_WM_Paint(HWND hwnd, EDITSTATE *es,WPARAM wParam) 3301 3329 { 3302 3330 PAINTSTRUCT ps; … … 3307 3335 RECT rcLine; 3308 3336 RECT rcRgn; 3309 BOOL rev = IsWindowEnabled(hwnd)&&3337 BOOL rev = es->bEnableState && 3310 3338 ((es->flags & EF_FOCUSED) || 3311 3339 (es->style & ES_NOHIDESEL)); … … 3314 3342 EDIT_NOTIFY_PARENT(hwnd, EN_UPDATE, "EN_UPDATE"); 3315 3343 3316 dc = BeginPaint(hwnd, &ps); 3344 if (!wParam) 3345 dc = BeginPaint(hwnd, &ps); 3346 else 3347 dc = (HDC) wParam; 3348 3317 3349 if(es->style & WS_BORDER) { 3318 3350 GetClientRect(hwnd, &rc); … … 3333 3365 if (es->font) 3334 3366 old_font = SelectObject(dc, es->font); 3335 if (! IsWindowEnabled(hwnd)|| (es->style & ES_READONLY))3367 if (!es->bEnableState || (es->style & ES_READONLY)) 3336 3368 EDIT_SEND_CTLCOLORSTATIC(hwnd, dc); 3337 3369 else 3338 3370 EDIT_SEND_CTLCOLOR(hwnd, dc); 3339 if (! IsWindowEnabled(hwnd))3371 if (!es->bEnableState) 3340 3372 SetTextColor(dc, GetSysColor(COLOR_GRAYTEXT)); 3341 3373 GetClipBox(dc, &rcRgn); … … 3357 3389 EDIT_SetCaretPos(hwnd, es, es->selection_end, 3358 3390 es->flags & EF_AFTER_WRAP); 3359 EndPaint(hwnd, &ps);3391 if (!wParam) EndPaint(hwnd, &ps); 3360 3392 if ((es->style & WS_VSCROLL) && !(es->flags & EF_VSCROLL_TRACK)) { 3361 3393 INT vlc = (es->format_rect.bottom - es->format_rect.top) / es->line_height; … … 3441 3473 HDC dc; 3442 3474 HFONT old_font = 0; 3475 RECT r; 3443 3476 3444 3477 es->font = font; … … 3455 3488 EDIT_EM_SetMargins(hwnd, es, EC_LEFTMARGIN | EC_RIGHTMARGIN, 3456 3489 EC_USEFONTINFO, EC_USEFONTINFO); 3490 /* Force the recalculation of the format rect for each font change */ 3491 GetClientRect(hwnd, &r); 3492 EDIT_SetRectNP(hwnd, es, &r); 3457 3493 if (es->style & ES_MULTILINE) 3458 3494 EDIT_BuildLineDefs_ML(hwnd, es); 3459 else { 3460 RECT r; 3461 GetClientRect(hwnd, &r); 3462 EDIT_SetRectNP(hwnd, es, &r); 3463 } 3495 3464 3496 if (redraw) 3465 3497 InvalidateRect(hwnd, NULL, TRUE); -
trunk/src/user32/listbox.cpp
r949 r1203 1 /* $Id: listbox.cpp,v 1. 1 1999-09-15 23:18:51 sandervlExp $ */1 /* $Id: listbox.cpp,v 1.2 1999-10-08 21:24:40 cbratschi Exp $ */ 2 2 /* 3 3 * Listbox controls … … 5 5 * Copyright 1996 Alexandre Julliard 6 6 * Copyright 1999 Christoph Bratschi (ported from WINE) 7 * 8 * WINE version: 990923 7 9 */ 8 10 … … 624 626 INT i; 625 627 LPINT16 p = (LPINT16)tabs; 626 //dbg_decl_str(listbox, 256);627 628 628 629 for (i = 0; i < descr->nb_tabs; i++) { … … 764 765 if (HAS_STRINGS(descr)) 765 766 { 766 if (!str ) return LB_ERR;767 if (!str || !str[0]) return LB_ERR; 767 768 if (exact) 768 769 { … … 1784 1785 1785 1786 1787 /************************************************************************* 1788 * LISTBOX_HandleLButtonDownCombo [Internal] 1789 * 1790 * Process LButtonDown message for the ComboListBox 1791 * 1792 * PARAMS 1793 * pWnd [I] The windows internal structure 1794 * pDescr [I] The ListBox internal structure 1795 * wParam [I] Key Flag (WM_LBUTTONDOWN doc for more info) 1796 * x [I] X Mouse Coordinate 1797 * y [I] Y Mouse Coordinate 1798 * 1799 * RETURNS 1800 * 0 since we are processing the WM_LBUTTONDOWN Message 1801 * 1802 * NOTES 1803 * This function is only to be used when a ListBox is a ComboListBox 1804 */ 1805 1806 static LRESULT LISTBOX_HandleLButtonDownCombo( HWND hwnd, LB_DESCR *pDescr, 1807 WPARAM wParam, INT x, INT y) 1808 { 1809 RECT clientRect, screenRect; 1810 POINT mousePos; 1811 1812 mousePos.x = x; 1813 mousePos.y = y; 1814 1815 GetClientRect(hwnd, &clientRect); 1816 1817 if(PtInRect(&clientRect, mousePos)) 1818 { 1819 /* MousePos is in client, resume normal processing */ 1820 return LISTBOX_HandleLButtonDown( hwnd, pDescr, wParam, x, y); 1821 } 1822 else 1823 { 1824 POINT screenMousePos; 1825 HWND hWndOldCapture; 1826 1827 /* Check the Non-Client Area */ 1828 screenMousePos = mousePos; 1829 hWndOldCapture = GetCapture(); 1830 ReleaseCapture(); 1831 GetWindowRect(hwnd, &screenRect); 1832 ClientToScreen(hwnd, &screenMousePos); 1833 1834 if(!PtInRect(&screenRect, screenMousePos)) 1835 { 1836 /* Close The Drop Down */ 1837 SEND_NOTIFICATION( hwnd, pDescr, LBN_SELCANCEL ); 1838 return 0; 1839 } 1840 else 1841 { 1842 /* Check to see the NC is a scrollbar */ 1843 INT nHitTestType=0; 1844 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 1845 /* Check Vertical scroll bar */ 1846 if (dwStyle & WS_VSCROLL) 1847 { 1848 clientRect.right += GetSystemMetrics(SM_CXVSCROLL); 1849 if (PtInRect( &clientRect, mousePos )) 1850 { 1851 nHitTestType = HTVSCROLL; 1852 } 1853 } 1854 /* Check horizontal scroll bar */ 1855 if (dwStyle & WS_HSCROLL) 1856 { 1857 clientRect.bottom += GetSystemMetrics(SM_CYHSCROLL); 1858 if (PtInRect( &clientRect, mousePos )) 1859 { 1860 nHitTestType = HTHSCROLL; 1861 } 1862 } 1863 /* Windows sends this message when a scrollbar is clicked 1864 */ 1865 1866 if(nHitTestType != 0) 1867 { 1868 SendMessageA(hwnd, WM_NCLBUTTONDOWN, nHitTestType, 1869 MAKELONG(screenMousePos.x, screenMousePos.y)); 1870 } 1871 /* Resume the Capture after scrolling is complete 1872 */ 1873 if(hWndOldCapture != 0) 1874 { 1875 SetCapture(hWndOldCapture); 1876 } 1877 } 1878 } 1879 return 0; 1880 } 1881 1882 1786 1883 /*********************************************************************** 1787 1884 * LISTBOX_HandleLButtonUp … … 2162 2259 { 2163 2260 switch (msg) 2164 2165 2166 2261 { 2262 case WM_CREATE: 2263 { 2167 2264 if (!LISTBOX_Create( hwnd, NULL )) 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2265 return -1; 2266 //TRACE("creating wnd=%04x descr=%p\n", 2267 // hwnd, *(LB_DESCR **)wnd->wExtra ); 2268 return 0; 2269 } 2270 case WM_NCCREATE: 2271 { 2272 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 2273 2274 /* 2275 * When a listbox is not in a combobox and the look 2276 * is win95, the WS_BORDER style is replaced with 2277 * the WS_EX_CLIENTEDGE style. 2278 */ 2279 if (dwStyle & WS_BORDER) 2280 { 2281 SetWindowLongA(hwnd,GWL_EXSTYLE,GetWindowLongA(hwnd,GWL_EXSTYLE) | WS_EX_CLIENTEDGE); 2282 SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE) & ~ WS_BORDER); 2283 } 2284 } 2285 } 2189 2286 /* Ignore all other messages before we get a WM_CREATE */ 2190 2287 return DefWindowProcA( hwnd, msg, wParam, lParam ); … … 2214 2311 return descr->nb_items; 2215 2312 else 2216 return LB_ERR; 2313 return LB_ERR; 2217 2314 2218 2315 case LB_GETITEMDATA: … … 2561 2658 * the mouse is captured to show the tracking of the item. 2562 2659 */ 2563 captured = descr->captured; 2564 descr->captured = TRUE; 2565 2566 LISTBOX_HandleMouseMove( hwnd, 2567 descr, 2568 mousePos.x, mousePos.y); 2569 2570 descr->captured = captured; 2571 2572 /* 2573 * However, when tracking, it is important that we do not 2574 * perform a selection if the cursor is outside the list. 2575 */ 2660 2576 2661 GetClientRect(hwnd, &clientRect); 2577 2578 if (!PtInRect( &clientRect, mousePos )) 2662 if (PtInRect( &clientRect, mousePos )) 2663 { 2664 captured = descr->captured; 2665 descr->captured = TRUE; 2666 2667 LISTBOX_HandleMouseMove( hwnd, descr, 2668 mousePos.x, mousePos.y); 2669 descr->captured = captured; 2670 } 2671 else 2579 2672 { 2580 LISTBOX_MoveCaret( hwnd, descr, -1, FALSE ); 2673 LISTBOX_HandleMouseMove( hwnd, descr, 2674 mousePos.x, mousePos.y); 2581 2675 } 2676 2582 2677 2583 2678 return 0; … … 2620 2715 return LISTBOX_HandleLButtonUp( hwnd, descr ); 2621 2716 case WM_LBUTTONDOWN: 2622 return LISTBOX_HandleLButtonDown ( hwnd, descr, wParam,2717 return LISTBOX_HandleLButtonDownCombo( hwnd, descr, wParam, 2623 2718 (INT16)LOWORD(lParam), (INT16)HIWORD(lParam)); 2624 /* avoid activation at all costs */ 2625 case WM_MOUSEACTIVATE: 2719 case WM_MOUSEACTIVATE: 2626 2720 return MA_NOACTIVATE; 2627 2721 case WM_NCACTIVATE: -
trunk/src/user32/scroll.cpp
r1184 r1203 1 /* $Id: scroll.cpp,v 1. 6 1999-10-08 12:10:27 cbratschi Exp $ */1 /* $Id: scroll.cpp,v 1.7 1999-10-08 21:25:47 cbratschi Exp $ */ 2 2 /* 3 3 * Scrollbar control … … 7 7 * Copyright 1993 Martin Ayotte 8 8 * Copyright 1994, 1996 Alexandre Julliard 9 * 10 * WINE version: 990923 9 11 */ 10 12 … … 1182 1184 UINT new_flags; 1183 1185 1184 //dbg_decl_str(scroll, 256);1185 1186 1186 *action = 0; 1187 1187 … … 1194 1194 if (info->fMask & SIF_PAGE) 1195 1195 { 1196 //dsprintf(scroll, " page=%d", info->nPage );1197 1196 if( infoPtr->Page != info->nPage ) 1198 1197 { … … 1216 1215 if (info->fMask & SIF_RANGE) 1217 1216 { 1218 //dsprintf(scroll, " min=%d max=%d", info->nMin, info->nMax );1219 1220 1217 /* Invalid range -> range is set to (0,0) */ 1221 1218 if ((info->nMin > info->nMax) || … … 1236 1233 } 1237 1234 } 1238 1239 //TRACE("hwnd=%04x bar=%d %s\n",1240 // hwnd, nBar, dbg_str(scroll));1241 1235 1242 1236 /* Make sure the page size is valid */ -
trunk/src/user32/static.cpp
r992 r1203 1 /* $Id: static.cpp,v 1. 3 1999-09-20 19:17:58 sandervlExp $ */1 /* $Id: static.cpp,v 1.4 1999-10-08 21:26:08 cbratschi Exp $ */ 2 2 /* 3 3 * Static control … … 7 7 * Copyright David W. Metcalfe, 1993 8 8 * 9 * WINE version: 990923 9 10 */ 10 11 … … 92 93 93 94 if (hBitmap && GetObjectType(hBitmap) != OBJ_BITMAP) { 94 95 95 //ERR("huh? hBitmap!=0, but not bitmap\n"); 96 return 0; 96 97 } 97 98 hOldBitmap = infoPtr->hIcon; … … 102 103 GetObjectA(hBitmap, sizeof(bm), &bm); 103 104 SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight, 104 105 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER ); 105 106 /* CB: alternative code, if necessary 106 107 HDC hdc = GetDC(hwnd); … … 113 114 } 114 115 ReleaseDC(hwnd,hdc); 115 */ 116 116 */ 117 117 118 } 118 119 return hOldBitmap; … … 463 464 FillRect( hdc, &rc, hBrush ); 464 465 466 if (!IsWindowEnabled(hwnd)) SetTextColor(hdc,GetSysColor(COLOR_GRAYTEXT)); 467 465 468 textLen = GetWindowTextLengthA(hwnd); 466 469 if (textLen > 0) … … 545 548 if (infoPtr->hIcon) { 546 549 BITMAP bm; 547 550 SIZE sz; 548 551 549 552 if(GetObjectType(infoPtr->hIcon) != OBJ_BITMAP) 550 553 return; 551 554 if (!(hMemDC = CreateCompatibleDC( hdc ))) return; 552 553 554 555 556 557 558 555 GetObjectA(infoPtr->hIcon, sizeof(bm), &bm); 556 GetBitmapDimensionEx(infoPtr->hIcon, &sz); 557 oldbitmap = SelectObject(hMemDC, infoPtr->hIcon); 558 BitBlt(hdc, sz.cx, sz.cy, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, 559 SRCCOPY); 560 SelectObject(hMemDC, oldbitmap); 561 DeleteDC(hMemDC); 559 562 } 560 563 }
Note:
See TracChangeset
for help on using the changeset viewer.