- Timestamp:
- Aug 15, 1999, 9:11:02 PM (26 years ago)
- Location:
- trunk/src/user32/new
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/new/button.cpp
r402 r500 1 /* $Id: button.cpp,v 1.1 0 1999-07-27 16:14:22cbratschi Exp $ */1 /* $Id: button.cpp,v 1.11 1999-08-15 19:11:00 cbratschi Exp $ */ 2 2 /* File: button.cpp -- Button type widgets 3 3 * … … 31 31 static void OB_Paint(HWND hwnd,HDC hDC,WORD action); 32 32 static void BUTTON_CheckAutoRadioButton(HWND hwnd); 33 static void BUTTON_DrawPushButton(HWND hwnd,HDC hDC,WORD action,BOOL pushedState); 33 34 static LRESULT BUTTON_LButtonDown(HWND hwnd,WPARAM wParam,LPARAM lParam); 34 35 … … 181 182 { 182 183 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 183 184 switch(dwStyle & 0x0f) 185 { 186 case BS_RADIOBUTTON: 187 case BS_AUTORADIOBUTTON: 188 case BS_OWNERDRAW: 189 SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),BN_DOUBLECLICKED),hwnd); 190 break; 191 192 default: 193 BUTTON_LButtonDown(hwnd,wParam,lParam); 194 break; 195 } 184 DWORD style = dwStyle & 0x0f; 185 186 if(dwStyle & BS_NOTIFY || style == BS_RADIOBUTTON || 187 style == BS_USERBUTTON || style == BS_OWNERDRAW) 188 SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),BN_DOUBLECLICKED),hwnd); 189 else BUTTON_LButtonDown(hwnd,wParam,lParam); 196 190 197 191 return 0; … … 200 194 static LRESULT BUTTON_LButtonDown(HWND hwnd,WPARAM wParam,LPARAM lParam) 201 195 { 196 SetCapture(hwnd); 197 SetFocus(hwnd); 202 198 SendMessageA(hwnd,BM_SETSTATE,TRUE,0); 203 SetFocus(hwnd);204 SetCapture(hwnd);205 199 206 200 return 0; … … 355 349 DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & 0x0f; 356 350 357 infoPtr->state |= BUTTON_HASFOCUS; 358 if (style == BS_AUTORADIOBUTTON) 359 { 360 SendMessageA(hwnd,BM_SETCHECK,1,0); 361 SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),BN_CLICKED),hwnd); 362 } else if (style == BS_RADIOBUTTON) 363 { 351 if ((style == BS_AUTORADIOBUTTON || style == BS_RADIOBUTTON) && 352 (GetCapture() != hwnd) && !(SendMessageA(hwnd,BM_GETCHECK,0,0) & BST_CHECKED)) 353 { 354 /* The notification is sent when the button (BS_AUTORADIOBUTTON) 355 is unckecked and the focus was not given by a mouse click. */ 356 if (style == BS_AUTORADIOBUTTON) SendMessageA(hwnd,BM_SETCHECK,TRUE,0); 364 357 SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),BN_CLICKED),hwnd); 365 358 } 366 359 360 infoPtr->state |= BUTTON_HASFOCUS; 367 361 PAINT_BUTTON(hwnd,style,ODA_FOCUS); 368 362 … … 424 418 HANDLE oldHbitmap = infoPtr->hImage; 425 419 426 if (dwStyle & BS_BITMAP ) infoPtr->hImage = (HANDLE)lParam;420 if (dwStyle & BS_BITMAP || dwStyle & BS_ICON) infoPtr->hImage = (HANDLE)lParam; 427 421 428 422 return oldHbitmap; … … 433 427 BUTTONINFO* infoPtr = (BUTTONINFO*)GetInfoPtr(hwnd); 434 428 435 return infoPtr->hImage; 429 switch(wParam) 430 { 431 case IMAGE_BITMAP: 432 return (HBITMAP)infoPtr->hImage; 433 case IMAGE_ICON: 434 return (HICON)infoPtr->hImage; 435 default: 436 return NULL; 437 } 436 438 } 437 439 … … 600 602 * Push Button Functions 601 603 */ 602 603 static void PB_Paint(HWND hwnd,HDC hDC,WORD action) 604 { 605 BUTTONINFO* infoPtr = (BUTTONINFO*)GetInfoPtr(hwnd); 606 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 607 RECT rc; 604 static void PB_Paint( HWND hwnd, HDC hDC, WORD action ) 605 { 606 BUTTONINFO *infoPtr = (BUTTONINFO *)GetInfoPtr(hwnd); 607 BOOL bHighLighted = (infoPtr->state & BUTTON_HIGHLIGHTED); 608 609 /* 610 * Delegate this to the more generic pushbutton painting 611 * method. 612 */ 613 BUTTON_DrawPushButton(hwnd, 614 hDC, 615 action, 616 bHighLighted); 617 } 618 619 /********************************************************************** 620 * This method will actually do the drawing of the pushbutton 621 * depending on it's state and the pushedState parameter. 622 */ 623 static void BUTTON_DrawPushButton( 624 HWND hwnd, 625 HDC hDC, 626 WORD action, 627 BOOL pushedState ) 628 { 629 RECT rc, focus_rect; 608 630 HPEN hOldPen; 609 631 HBRUSH hOldBrush; 632 BUTTONINFO *infoPtr = (BUTTONINFO *)GetInfoPtr(hwnd); 633 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 610 634 int xBorderOffset, yBorderOffset; 611 635 xBorderOffset = yBorderOffset = 0; … … 613 637 char* text; 614 638 615 GetClientRect( hwnd,&rc );639 GetClientRect( hwnd, &rc ); 616 640 617 641 /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */ 618 642 if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont ); 619 SendMessageA(GetParent(hwnd),WM_CTLCOLORBTN,hDC,hwnd); 620 643 BUTTON_SEND_CTLCOLOR( hwnd, hDC ); 621 644 hOldPen = (HPEN)SelectObject(hDC, GetSysColorPen(COLOR_WINDOWFRAME)); 622 645 hOldBrush =(HBRUSH)SelectObject(hDC,GetSysColorBrush(COLOR_BTNFACE)); 623 646 SetBkMode(hDC, TRANSPARENT); 624 Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);625 /* if (action == ODA_DRAWENTIRE)*/626 {627 SetPixel( hDC, rc.left, rc.top, GetSysColor(COLOR_WINDOW) );628 SetPixel( hDC, rc.left, rc.bottom-1, GetSysColor(COLOR_WINDOW) );629 SetPixel( hDC, rc.right-1, rc.top, GetSysColor(COLOR_WINDOW) );630 SetPixel( hDC, rc.right-1, rc.bottom-1, GetSysColor(COLOR_WINDOW));631 }632 InflateRect( &rc, -1, -1 );633 647 634 648 if ((dwStyle & 0x000f) == BS_DEFPUSHBUTTON) 635 649 { 636 650 Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom); 637 InflateRect( &rc, -1, -1 ); 638 } 639 640 if (infoPtr->state & BUTTON_HIGHLIGHTED) 641 { 642 /* draw button shadow: */ 643 SelectObject(hDC, GetSysColorBrush(COLOR_BTNSHADOW)); 644 PatBlt(hDC, rc.left, rc.top, 1, rc.bottom-rc.top, PATCOPY ); 645 PatBlt(hDC, rc.left, rc.top, rc.right-rc.left, 1, PATCOPY ); 646 rc.left += 2; /* To position the text down and right */ 647 rc.top += 2; 648 } else { 649 rc.right++, rc.bottom++; 650 DrawEdge( hDC, &rc, EDGE_RAISED, BF_RECT ); 651 652 /* To place de bitmap correctly */ 653 xBorderOffset += GetSystemMetrics(SM_CXEDGE); 654 yBorderOffset += GetSystemMetrics(SM_CYEDGE); 655 656 rc.right--, rc.bottom--; 657 } 658 659 /* draw button label, if any: */ 651 InflateRect( &rc, -1, -1 ); 652 } 653 654 UINT uState = DFCS_BUTTONPUSH; 655 656 if (pushedState) 657 { 658 if ( (dwStyle & 0x000f) == BS_DEFPUSHBUTTON ) 659 uState |= DFCS_FLAT; 660 else 661 uState |= DFCS_PUSHED; 662 } 663 664 DrawFrameControl( hDC, &rc, DFC_BUTTON, uState ); 665 InflateRect( &rc, -2, -2 ); 666 667 focus_rect = rc; 668 669 if (pushedState) 670 { 671 rc.left += 2; /* To position the text down and right */ 672 rc.top += 2; 673 } 674 675 676 /* draw button label, if any: 677 * 678 * In win9x we don't show text if there is a bitmap or icon. 679 * I don't know about win31 so I leave it as it was for win31. 680 * Dennis Björklund 12 Jul, 99 681 */ 660 682 textLen = GetWindowTextLengthA(hwnd); 661 if (textLen > 0 )683 if (textLen > 0 && (!(dwStyle & (BS_ICON|BS_BITMAP)))) 662 684 { 663 685 LOGBRUSH lb; … … 668 690 GetObjectA( GetSysColorBrush(COLOR_BTNFACE), sizeof(lb), &lb ); 669 691 if (dwStyle & WS_DISABLED && 670 GetSysColor(COLOR_GRAYTEXT) ==lb.lbColor)692 GetSysColor(COLOR_GRAYTEXT)==lb.lbColor) 671 693 /* don't write gray text on gray background */ 672 694 PaintGrayOnGray( hDC,infoPtr->hFont,&rc,text, 673 695 DT_CENTER | DT_VCENTER ); 674 696 else 675 697 { … … 679 701 DrawTextA( hDC, text, -1, &rc, 680 702 DT_SINGLELINE | DT_CENTER | DT_VCENTER ); 681 /* do we have the focus? */ 682 if (infoPtr->state & BUTTON_HASFOCUS) 683 { 684 RECT r = { 0, 0, 0, 0 }; 685 INT xdelta, ydelta; 686 687 DrawTextA( hDC, text, -1, &r, 688 DT_SINGLELINE | DT_CALCRECT ); 689 xdelta = ((rc.right - rc.left) - (r.right - r.left) - 1) / 2; 690 ydelta = ((rc.bottom - rc.top) - (r.bottom - r.top) - 1) / 2; 691 if (xdelta < 0) xdelta = 0; 692 if (ydelta < 0) ydelta = 0; 693 InflateRect( &rc, -xdelta, -ydelta ); 694 DrawFocusRect( hDC, &rc ); 695 } 703 /* do we have the focus? 704 * Win9x draws focus last with a size prop. to the button 705 */ 696 706 } 697 707 free(text); 698 708 } 699 700 if((dwStyle & BS_BITMAP) && (infoPtr->hImage != NULL)) 701 { 702 BITMAP bm; 703 HDC hdcMem; 704 int yOffset, xOffset, imageWidth, imageHeight; 705 706 GetObjectA (infoPtr->hImage, sizeof(BITMAP), &bm); 707 708 /* Center the bitmap */ 709 xOffset = (((rc.right - rc.left) - 2*xBorderOffset) - bm.bmWidth ) / 2; 710 yOffset = (((rc.bottom - rc.top) - 2*yBorderOffset) - bm.bmHeight ) / 2; 711 712 imageWidth = bm.bmWidth; 713 imageHeight = bm.bmHeight; 714 715 /* If the image is to big for the button */ 716 if (xOffset < 0) 709 if ( ((dwStyle & BS_ICON) || (dwStyle & BS_BITMAP) ) && 710 (infoPtr->hImage != NULL) ) 711 { 712 int yOffset, xOffset; 713 int imageWidth, imageHeight; 714 715 /* 716 * We extract the size of the image from the handle. 717 */ 718 if (dwStyle & BS_ICON) 719 { 720 ICONINFO iconInfo; 721 BITMAP bm; 722 723 GetIconInfo((HICON)infoPtr->hImage, &iconInfo); 724 GetObjectA (iconInfo.hbmColor, sizeof(BITMAP), &bm); 725 726 imageWidth = bm.bmWidth; 727 imageHeight = bm.bmHeight; 728 729 DeleteObject(iconInfo.hbmColor); 730 DeleteObject(iconInfo.hbmMask); 731 732 } 733 else 734 { 735 BITMAP bm; 736 737 GetObjectA (infoPtr->hImage, sizeof(BITMAP), &bm); 738 739 imageWidth = bm.bmWidth; 740 imageHeight = bm.bmHeight; 741 } 742 743 /* Center the bitmap */ 744 xOffset = (((rc.right - rc.left) - 2*xBorderOffset) - imageWidth ) / 2; 745 yOffset = (((rc.bottom - rc.top) - 2*yBorderOffset) - imageHeight) / 2; 746 747 /* If the image is too big for the button then create a region*/ 748 if(xOffset < 0 || yOffset < 0) 749 { 750 HRGN hBitmapRgn = NULL; 751 hBitmapRgn = CreateRectRgn( 752 rc.left + xBorderOffset, rc.top +yBorderOffset, 753 rc.right - xBorderOffset, rc.bottom - yBorderOffset); 754 SelectClipRgn(hDC, hBitmapRgn); 755 DeleteObject(hBitmapRgn); 756 } 757 758 /* Let minimum 1 space from border */ 759 xOffset++, yOffset++; 760 761 /* 762 * Draw the image now. 763 */ 764 if (dwStyle & BS_ICON) 765 { 766 DrawIcon(hDC, 767 rc.left + xOffset, rc.top + yOffset, 768 (HICON)infoPtr->hImage); 769 } 770 else 717 771 { 718 imageWidth = rc.right - rc.left - 2*xBorderOffset -1; 719 xOffset = xBorderOffset; 772 HDC hdcMem; 773 774 hdcMem = CreateCompatibleDC (hDC); 775 SelectObject (hdcMem, (HBITMAP)infoPtr->hImage); 776 BitBlt(hDC, 777 rc.left + xOffset, 778 rc.top + yOffset, 779 imageWidth, imageHeight, 780 hdcMem, 0, 0, SRCCOPY); 781 782 DeleteDC (hdcMem); 783 } 784 785 if(xOffset < 0 || yOffset < 0) 786 { 787 SelectClipRgn(hDC, NULL); 720 788 } 721 722 if (yOffset < 0) 723 { 724 imageHeight = rc.bottom - rc.top - 2*yBorderOffset -1; 725 yOffset = yBorderOffset; 726 } 727 728 /* Let minimum 1 space from border */ 729 xOffset++, yOffset++; 730 731 hdcMem = CreateCompatibleDC (hDC); 732 SelectObject (hdcMem, (HBITMAP)infoPtr->hImage); 733 BitBlt(hDC, rc.left + xOffset, 734 rc.top + yOffset, 735 imageWidth, imageHeight, 736 hdcMem, 0, 0, SRCCOPY); 737 738 DeleteDC (hdcMem); 739 } 789 } 790 791 if (infoPtr->state & BUTTON_HASFOCUS) 792 { 793 InflateRect( &focus_rect, -1, -1 ); 794 DrawFocusRect( hDC, &focus_rect ); 795 } 796 740 797 741 798 SelectObject( hDC, hOldPen ); 742 799 SelectObject( hDC, hOldBrush ); 743 800 } 744 745 801 746 802 /********************************************************************** … … 812 868 char* text = NULL; 813 869 870 /* 871 * if the button has a bitmap/icon, draw a normal pushbutton 872 * instead of a radion button. 873 */ 874 if (infoPtr->hImage!=NULL) 875 { 876 BOOL bHighLighted = ((infoPtr->state & BUTTON_HIGHLIGHTED) || 877 (infoPtr->state & BUTTON_CHECKED)); 878 879 BUTTON_DrawPushButton(hwnd, 880 hDC, 881 action, 882 bHighLighted); 883 return; 884 } 885 814 886 textLen = 0; 815 887 GetClientRect(hwnd, &client); … … 1019 1091 dis.itemData = 0; 1020 1092 GetClientRect( hwnd, &dis.rcItem ); 1093 1094 SetBkColor( hDC, GetSysColor( COLOR_BTNFACE ) ); 1095 FillRect( hDC, &dis.rcItem, GetSysColorBrush( COLOR_BTNFACE ) ); 1096 1021 1097 SendMessageA( GetParent(hwnd), WM_DRAWITEM, 1022 1098 GetWindowLongA(hwnd,GWL_ID), (LPARAM)&dis ); -
trunk/src/user32/new/combo.cpp
r387 r500 1 /* $Id: combo.cpp,v 1. 2 1999-07-24 17:10:24cbratschi Exp $ */1 /* $Id: combo.cpp,v 1.3 1999-08-15 19:11:00 cbratschi Exp $ */ 2 2 /* 3 3 * Combo controls … … 39 39 * Look and feel dependant "constants" 40 40 */ 41 #define COMBO_YBORDERGAP 5 41 42 #define COMBO_XBORDERSIZE() ( 2 ) 42 43 #define COMBO_YBORDERSIZE() ( 2 ) … … 484 485 if( lphc->owner || !(lpcs->style & WS_VISIBLE) ) 485 486 { 486 UINT lbeStyle; 487 UINT lbeStyle = 0; 488 UINT lbeExStyle = 0; 487 489 488 490 /* … … 530 532 lbeStyle |= LBS_DISABLENOSCROLL; 531 533 532 if( CB_GETTYPE(lphc) == CBS_SIMPLE ) /* child listbox */ 533 lbeStyle |= WS_CHILD | WS_VISIBLE; 534 else /* popup listbox */ 535 lbeStyle |= WS_POPUP; 534 if( CB_GETTYPE(lphc) == CBS_SIMPLE ) /* child listbox */ 535 { 536 lbeStyle |= WS_CHILD | WS_VISIBLE; 537 538 /* 539 * In win 95 look n feel, the listbox in the simple combobox has 540 * the WS_EXCLIENTEDGE style instead of the WS_BORDER style. 541 */ 542 lbeStyle &= ~WS_BORDER; 543 lbeExStyle |= WS_EX_CLIENTEDGE; 544 } 545 else /* popup listbox */ 546 lbeStyle |= WS_POPUP; 536 547 537 548 /* Dropdown ComboLBox is not a child window and we cannot pass 538 549 * ID_CB_LISTBOX directly because it will be treated as a menu handle. 539 550 */ 540 lphc->hWndLBox = CreateWindowExA( 0,551 lphc->hWndLBox = CreateWindowExA(lbeExStyle, 541 552 clbName, 542 553 NULL, … … 1063 1074 { 1064 1075 RECT rect; 1076 int nItems = 0; 1077 int i; 1078 int nHeight; 1079 int nDroppedHeight; 1065 1080 1066 1081 //TRACE("[%04x]: drop down\n", CB_HWND(lphc)); … … 1091 1106 /* now set popup position */ 1092 1107 GetWindowRect( lphc->hwndself, &rect ); 1093 1094 1108 1095 1109 /* … … 1099 1113 rect.left += COMBO_EDITBUTTONSPACE(); 1100 1114 1115 /* if the dropped height is greater than the total height of the dropped 1116 items list, then force the drop down list height to be the total height 1117 of the items in the dropped list */ 1118 1119 nDroppedHeight = lphc->droppedRect.bottom - lphc->droppedRect.top; 1120 nItems = (int)SendMessageA (lphc->hWndLBox, LB_GETCOUNT, 0, 0); 1121 nHeight = COMBO_YBORDERGAP; 1122 for (i = 0; i < nItems; i++) 1123 { 1124 nHeight += (int)SendMessageA (lphc->hWndLBox, LB_GETITEMHEIGHT, i, 0); 1125 1126 if (nHeight >= nDroppedHeight) 1127 break; 1128 } 1129 1130 if (nHeight < nDroppedHeight) 1131 nDroppedHeight = nHeight; 1132 1101 1133 SetWindowPos( lphc->hWndLBox, HWND_TOP, rect.left, rect.bottom, 1102 lphc->droppedRect.right - lphc->droppedRect.left, 1103 lphc->droppedRect.bottom - lphc->droppedRect.top, 1104 SWP_NOACTIVATE | SWP_NOREDRAW); 1134 lphc->droppedRect.right - lphc->droppedRect.left, 1135 nDroppedHeight, 1136 SWP_NOACTIVATE | SWP_NOREDRAW); 1137 1105 1138 1106 1139 if( !(lphc->wState & CBF_NOREDRAW) ) … … 1127 1160 //TRACE("[%04x]: roll up [%i]\n", CB_HWND(lphc), (INT)ok ); 1128 1161 1129 /*1130 * It seems useful to send the WM_LBUTTONUP with (-1,-1) when cancelling1131 * and with (0,0) (anywhere in the listbox) when Oking.1132 */1133 SendMessageA( lphc->hWndLBox, WM_LBUTTONUP, 0, ok ? (LPARAM)0 : (LPARAM)(-1) );1134 1135 1162 if( lphc->wState & CBF_DROPPED ) 1136 1163 { 1137 1164 RECT rect; 1165 1166 /* 1167 * It seems useful to send the WM_LBUTTONUP with (-1,-1) when cancelling 1168 * and with (0,0) (anywhere in the listbox) when Oking. 1169 */ 1170 SendMessageA( lphc->hWndLBox, WM_LBUTTONUP, 0, ok ? (LPARAM)0 : (LPARAM)(-1) ); 1138 1171 1139 1172 lphc->wState &= ~CBF_DROPPED; -
trunk/src/user32/new/edit.cpp
r394 r500 1 /* $Id: edit.cpp,v 1. 2 1999-07-25 16:31:44cbratschi Exp $ */1 /* $Id: edit.cpp,v 1.3 1999-08-15 19:11:00 cbratschi Exp $ */ 2 2 /* 3 3 * Edit control … … 17 17 */ 18 18 19 //#include "config.h"20 19 #include "winuser.h" 21 20 #include "winbase.h" 22 21 #include <string.h> 23 //#include "winnt.h"24 //#include "win.h"25 //#include "wine/winbase16.h"26 22 #include "controls.h" 27 23 #include "combo.h" 28 //#include "local.h"29 //#include "resource.h"30 //#include "debugtools.h"31 //#include "callback.h"32 //#include "tweak.h"33 24 34 25 #define BUFLIMIT_MULTI 65534 /* maximum buffer size (not including '\0') … … 98 89 INT line_count; /* number of lines */ 99 90 INT y_offset; /* scroll offset in number of lines */ 91 BOOL bCaptureState; /* flag indicating whether mouse was captured */ 100 92 /* 101 93 * only for multi line controls … … 3156 3148 return 0; 3157 3149 3150 es->bCaptureState = TRUE; 3158 3151 SetCapture(hwnd); 3159 3152 EDIT_ConfinePoint(hwnd, es, &x, &y); … … 3174 3167 static LRESULT EDIT_WM_LButtonUp(HWND hwnd, EDITSTATE *es, DWORD keys, INT x, INT y) 3175 3168 { 3176 if (GetCapture() == hwnd) { 3177 KillTimer(hwnd, 0); 3178 ReleaseCapture(); 3179 } 3180 return 0; 3169 if (es->bCaptureState && GetCapture() == hwnd) { 3170 KillTimer(hwnd, 0); 3171 ReleaseCapture(); 3172 } 3173 es->bCaptureState = FALSE; 3174 3175 return 0; 3181 3176 } 3182 3177 … … 3233 3228 es->style = cs->style; 3234 3229 3235 if ((es->style & WS_BORDER) && !(es->style & WS_DLGFRAME)) 3236 SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE) & ~WS_BORDER); 3237 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 */ 3236 if (es->style & WS_BORDER) 3237 { 3238 es->style &= ~WS_BORDER; 3239 SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE) & ~WS_BORDER); 3240 SetWindowLongA(hwnd,GWL_EXSTYLE,GetWindowLongA(hwnd,GWL_EXSTYLE) | WS_EX_CLIENTEDGE); 3241 } 3242 3238 3243 if (es->style & ES_MULTILINE) { 3239 3244 es->buffer_size = BUFSTART_MULTI; … … 3316 3321 if(es->style & WS_VSCROLL) rc.right++; 3317 3322 } 3318 DrawEdge(dc, &rc, EDGE_SUNKEN, BF_RECT);3323 Rectangle(dc, rc.left, rc.top, rc.right, rc.bottom); 3319 3324 } 3320 3325 IntersectClipRect(dc, es->format_rect.left, -
trunk/src/user32/new/listbox.cpp
r387 r500 1 /* $Id: listbox.cpp,v 1. 2 1999-07-24 17:10:25cbratschi Exp $ */1 /* $Id: listbox.cpp,v 1.3 1999-08-15 19:11:01 cbratschi Exp $ */ 2 2 /* 3 3 * Listbox controls … … 90 90 (!IS_OWNERDRAW(descr) || ((descr)->style & LBS_HASSTRINGS)) 91 91 92 #define IS_MULTISELECT(descr) \ 93 ((descr)->style & LBS_MULTIPLESEL || ((descr)->style & LBS_EXTENDEDSEL)) 94 92 95 #define SEND_NOTIFICATION(hwnd,descr,code) \ 93 96 (SendMessageA( (descr)->owner, WM_COMMAND, \ … … 1226 1229 if (oldsel != -1) LISTBOX_RepaintItem( hwnd, descr, oldsel, ODA_SELECT); 1227 1230 if (index != -1) LISTBOX_RepaintItem( hwnd, descr, index, ODA_SELECT ); 1228 if (send_notify ) SEND_NOTIFICATION( hwnd, descr,1231 if (send_notify && descr->nb_items) SEND_NOTIFICATION( hwnd, descr, 1229 1232 (index != -1) ? LBN_SELCHANGE : LBN_SELCANCEL ); 1230 1233 else … … 1273 1276 LB_ITEMDATA *item; 1274 1277 INT max_items; 1278 INT oldfocus = descr->focus_item; 1275 1279 1276 1280 if (index == -1) index = descr->nb_items; … … 1327 1331 1328 1332 /* Move selection and focused item */ 1329 1330 if (index <= descr->selected_item) descr->selected_item++;1331 if (index <= descr->focus_item)1332 {1333 descr->focus_item++;1334 LISTBOX_MoveCaret( hwnd, descr, descr->focus_item, FALSE );1335 }1336 1337 1333 /* If listbox was empty, set focus to the first item */ 1338 1339 if (descr->nb_items == 1) LISTBOX_SetCaretIndex( hwnd, descr, 0, FALSE ); 1334 if (descr->nb_items == 1) 1335 LISTBOX_SetCaretIndex( hwnd, descr, 0, FALSE ); 1336 /* single select don't change selection index in win31 */ 1337 else 1338 { 1339 if (index <= descr->selected_item) 1340 { 1341 descr->selected_item++; 1342 descr->focus_item = oldfocus; /* focus not changed */ 1343 } 1344 } 1340 1345 return LB_OKAY; 1341 1346 } … … 1364 1369 if (HAS_STRINGS(descr)) 1365 1370 { 1371 if (!str) str=""; 1366 1372 if (!(new_str = HEAP_strdupA( descr->heap, 0, str ))) 1367 1373 { … … 1451 1457 1452 1458 LISTBOX_UpdateScroll( hwnd, descr ); 1459 /* if we removed the scrollbar, reset the top of the list 1460 (correct for owner-drawn ???) */ 1461 if (descr->nb_items == descr->page_size) 1462 LISTBOX_SetTopItem( hwnd, descr, 0, TRUE ); 1463 1464 /* Move selection and focused item */ 1465 if (!IS_MULTISELECT(descr)) 1466 { 1467 if (index == descr->selected_item) 1468 descr->selected_item = -1; 1469 else if (index < descr->selected_item) 1470 { 1471 descr->selected_item--; 1472 } 1473 } 1453 1474 LISTBOX_InvalidateItems( hwnd, descr, index ); 1454 1455 /* Move selection and focused item */ 1456 1457 if (index <= descr->selected_item) descr->selected_item--; 1458 if (index <= descr->focus_item) 1459 { 1460 descr->focus_item--; 1461 LISTBOX_MoveCaret( hwnd, descr, descr->focus_item, FALSE ); 1475 if (descr->focus_item >= descr->nb_items) 1476 { 1477 descr->focus_item = descr->nb_items - 1; 1478 if (descr->focus_item < 0) descr->focus_item = 0; 1462 1479 } 1463 1480 return LB_OKAY; … … 1781 1798 descr->captured = FALSE; 1782 1799 if (GetCapture() == hwnd) ReleaseCapture(); 1783 if ( descr->style & LBS_NOTIFY)1800 if ((descr->style & LBS_NOTIFY) && descr->nb_items) 1784 1801 SEND_NOTIFICATION( hwnd, descr, LBN_SELCHANGE ); 1785 1802 } … … 1904 1921 { 1905 1922 INT caret = -1; 1923 BOOL bForceSelection = TRUE; /* select item pointed to by focus_item */ 1924 1925 if ((IS_MULTISELECT(descr)) || (descr->selected_item == descr->focus_item)) 1926 bForceSelection = FALSE; /* only for single select list */ 1927 1906 1928 if (descr->style & LBS_WANTKEYBOARDINPUT) 1907 1929 { … … 1916 1938 if (descr->style & LBS_MULTICOLUMN) 1917 1939 { 1940 bForceSelection = FALSE; 1918 1941 if (descr->focus_item >= descr->page_size) 1919 1942 caret = descr->focus_item - descr->page_size; … … 1928 1951 if (descr->style & LBS_MULTICOLUMN) 1929 1952 { 1953 bForceSelection = FALSE; 1930 1954 if (descr->focus_item + descr->page_size < descr->nb_items) 1931 1955 caret = descr->focus_item + descr->page_size; … … 1971 1995 (descr->style & LBS_NOTIFY) != 0 ); 1972 1996 } 1973 else if (descr->selected_item == -1)1974 {1975 LISTBOX_SetSelection( hwnd, descr, descr->focus_item, TRUE,1976 (descr->style & LBS_NOTIFY) != 0 );1977 }1978 1997 break; 1979 } 1998 default: 1999 bForceSelection = FALSE; 2000 } 2001 if (bForceSelection) /* focused item is used instead of key */ 2002 caret = descr->focus_item; 1980 2003 if (caret >= 0) 1981 2004 { … … 1984 2007 descr->anchor_item = caret; 1985 2008 LISTBOX_MoveCaret( hwnd, descr, caret, TRUE ); 2009 LISTBOX_SetSelection( hwnd, descr, caret, TRUE, FALSE); 1986 2010 if (descr->style & LBS_NOTIFY) 1987 2011 { … … 1991 2015 descr->lphc->wState |= CBF_NOROLLUP; 1992 2016 } 1993 SEND_NOTIFICATION( hwnd, descr, LBN_SELCHANGE );2017 if (descr->nb_items) SEND_NOTIFICATION( hwnd, descr, LBN_SELCHANGE ); 1994 2018 } 1995 2019 } … … 2021 2045 if (caret != -1) 2022 2046 { 2047 if ((!IS_MULTISELECT(descr)) && descr->selected_item == -1) 2048 LISTBOX_SetSelection( hwnd, descr, caret, TRUE, FALSE); 2023 2049 LISTBOX_MoveCaret( hwnd, descr, caret, TRUE ); 2024 if ( descr->style & LBS_NOTIFY)2050 if ((descr->style & LBS_NOTIFY) && descr->nb_items) 2025 2051 SEND_NOTIFICATION( hwnd, descr, LBN_SELCHANGE ); 2026 2052 } … … 2135 2161 if (!(descr = (LB_DESCR*)GetInfoPtr(hwnd))) 2136 2162 { 2137 if (msg == WM_CREATE) 2138 { 2139 if (!LISTBOX_Create( hwnd, NULL )) 2140 return -1; 2141 //TRACE("creating wnd=%04x descr=%p\n", 2142 // hwnd, *(LB_DESCR **)wnd->wExtra ); 2143 return 0; 2144 } 2163 switch (msg) 2164 { 2165 case WM_CREATE: 2166 { 2167 if (!LISTBOX_Create( hwnd, NULL )) 2168 return -1; 2169 //TRACE("creating wnd=%04x descr=%p\n", 2170 // hwnd, *(LB_DESCR **)wnd->wExtra ); 2171 return 0; 2172 } 2173 case WM_NCCREATE: 2174 { 2175 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 2176 2177 /* 2178 * When a listbox is not in a combobox and the look 2179 * is win95, the WS_BORDER style is replaced with 2180 * the WS_EX_CLIENTEDGE style. 2181 */ 2182 if (dwStyle & WS_BORDER) 2183 { 2184 SetWindowLongA(hwnd,GWL_EXSTYLE,GetWindowLongA(hwnd,GWL_EXSTYLE) | WS_EX_CLIENTEDGE); 2185 SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE) & ~ WS_BORDER); 2186 } 2187 } 2188 } 2145 2189 /* Ignore all other messages before we get a WM_CREATE */ 2146 2190 return DefWindowProcA( hwnd, msg, wParam, lParam ); … … 2167 2211 2168 2212 case LB_DELETESTRING: 2169 return LISTBOX_RemoveItem( hwnd, descr, wParam ); 2213 if (LISTBOX_RemoveItem( hwnd, descr, wParam) != LB_ERR) 2214 return descr->nb_items; 2215 else 2216 return LB_ERR; 2170 2217 2171 2218 case LB_GETITEMDATA: … … 2195 2242 if (descr->nb_items==0) 2196 2243 return LB_ERR; 2244 if (!IS_MULTISELECT(descr)) 2245 return descr->selected_item; 2197 2246 /* else */ 2198 2247 if (descr->selected_item!=-1) … … 2228 2277 2229 2278 case LB_SETCARETINDEX: 2230 return LISTBOX_SetCaretIndex( hwnd, descr, wParam, !lParam ); 2279 if ((!IS_MULTISELECT(descr)) && (descr->selected_item != -1)) return LB_ERR; 2280 if (LISTBOX_SetCaretIndex( hwnd, descr, wParam, !lParam ) == LB_ERR) 2281 return LB_ERR; 2282 else 2283 return LB_OKAY; 2231 2284 2232 2285 case LB_GETCARETINDEX: … … 2267 2320 2268 2321 case LB_SETCURSEL: 2322 if (IS_MULTISELECT(descr)) return LB_ERR; 2269 2323 LISTBOX_SetCaretIndex( hwnd, descr, wParam, TRUE ); 2270 2324 return LISTBOX_SetSelection( hwnd, descr, wParam, TRUE, FALSE ); … … 2436 2490 break; 2437 2491 2438 case WM_NCCREATE:2439 SetWindowLongA(hwnd,GWL_EXSTYLE,GetWindowLongA(hwnd,GWL_EXSTYLE) | WS_EX_CLIENTEDGE);2440 return DefWindowProcA( hwnd, msg, wParam, lParam );2441 2492 default: 2442 2493 //if ((msg >= WM_USER) && (msg < 0xc000)) -
trunk/src/user32/new/scroll.cpp
r387 r500 1 /* $Id: scroll.cpp,v 1. 4 1999-07-24 17:10:25cbratschi Exp $ */1 /* $Id: scroll.cpp,v 1.5 1999-08-15 19:11:01 cbratschi Exp $ */ 2 2 /* 3 3 * Scrollbar control … … 52 52 53 53 /* Overlap between arrows and thumb */ 54 #define SCROLL_ARROW_THUMB_OVERLAP 154 #define SCROLL_ARROW_THUMB_OVERLAP 0 55 55 56 56 /* Delay (in ms) before first repetition when holding the button down */ … … 97 97 static INT SCROLL_SetScrollInfo( HWND hwnd, INT nBar, 98 98 const SCROLLINFO *info, INT *action ); 99 static void SCROLL_DrawInterior_9x( HWND hwnd, HDC hdc, INT nBar, 100 RECT *rect, INT arrowSize, 101 INT thumbSize, INT thumbPos, 102 UINT flags, BOOL vertical, 103 BOOL top_selected, BOOL bottom_selected ); 99 104 100 105 /*********************************************************************** … … 379 384 } 380 385 381 382 386 /*********************************************************************** 383 387 * SCROLL_DrawArrows … … 385 389 * Draw the scroll bar arrows. 386 390 */ 391 static void SCROLL_DrawArrows_9x( HDC hdc, SCROLLBAR_INFO *infoPtr, 392 RECT *rect, INT arrowSize, BOOL vertical, 393 BOOL top_pressed, BOOL bottom_pressed ) 394 { 395 RECT r; 396 397 r = *rect; 398 if( vertical ) 399 r.bottom = r.top + arrowSize; 400 else 401 r.right = r.left + arrowSize; 402 403 DrawFrameControl( hdc, &r, DFC_SCROLL, 404 (vertical ? DFCS_SCROLLUP : DFCS_SCROLLLEFT) 405 | (top_pressed ? (DFCS_PUSHED | DFCS_FLAT) : 0 ) 406 | (infoPtr->flags&ESB_DISABLE_LTUP ? DFCS_INACTIVE : 0 ) ); 407 408 r = *rect; 409 if( vertical ) 410 r.top = r.bottom-arrowSize; 411 else 412 r.left = r.right-arrowSize; 413 414 DrawFrameControl( hdc, &r, DFC_SCROLL, 415 (vertical ? DFCS_SCROLLDOWN : DFCS_SCROLLRIGHT) 416 | (bottom_pressed ? (DFCS_PUSHED | DFCS_FLAT) : 0 ) 417 | (infoPtr->flags&ESB_DISABLE_RTDN ? DFCS_INACTIVE : 0) ); 418 } 419 387 420 static void SCROLL_DrawArrows( HDC hdc, SCROLLBAR_INFO *infoPtr, 388 RECT *rect, INT arrowSize, BOOL vertical, 389 BOOL top_pressed, BOOL bottom_pressed ) 390 { 391 HDC hdcMem = CreateCompatibleDC( hdc ); 392 HBITMAP hbmpPrev = SelectObject( hdcMem, vertical ? 393 TOP_ARROW(infoPtr->flags, top_pressed) 394 : LEFT_ARROW(infoPtr->flags, top_pressed)); 395 INT offset = 1; 396 397 if (offset) arrowSize--; 398 SetStretchBltMode( hdc, STRETCH_DELETESCANS ); 399 StretchBlt( hdc, rect->left+offset, rect->top+offset, 400 vertical ? rect->right-(rect->left+offset) : arrowSize, 401 vertical ? arrowSize : rect->bottom-(rect->top+offset), 402 hdcMem, 0, 0, 403 GetSystemMetrics(SM_CXVSCROLL),GetSystemMetrics(SM_CYHSCROLL), 404 SRCCOPY ); 405 406 SelectObject( hdcMem, vertical ? 407 BOTTOM_ARROW( infoPtr->flags, bottom_pressed ) 408 : RIGHT_ARROW( infoPtr->flags, bottom_pressed ) ); 409 if (vertical) 410 StretchBlt( hdc, (rect->left+offset), rect->bottom - arrowSize, 411 rect->right - (rect->left+offset), arrowSize, 412 hdcMem, 0, 0, 413 GetSystemMetrics(SM_CXVSCROLL),GetSystemMetrics(SM_CYHSCROLL), 414 SRCCOPY ); 415 else 416 StretchBlt( hdc, rect->right - arrowSize, rect->top+offset, 417 arrowSize, rect->bottom - (rect->top+offset), 418 hdcMem, 0, 0, 419 GetSystemMetrics(SM_CXVSCROLL), GetSystemMetrics(SM_CYHSCROLL), 420 SRCCOPY ); 421 SelectObject( hdcMem, hbmpPrev ); 422 DeleteDC( hdcMem ); 421 RECT *rect, INT arrowSize, BOOL vertical, 422 BOOL top_pressed, BOOL bottom_pressed ) 423 { 424 SCROLL_DrawArrows_9x( hdc, infoPtr, rect, arrowSize, 425 vertical, top_pressed,bottom_pressed ); 423 426 } 424 427 … … 429 432 * Draw the moving thumb rectangle. 430 433 */ 434 static void SCROLL_DrawMovingThumb_9x( HDC hdc, RECT *rect, BOOL vertical, 435 INT arrowSize, INT thumbSize ) 436 { 437 INT pos = SCROLL_TrackingPos; 438 INT max_size; 439 440 if( vertical ) 441 max_size = rect->bottom - rect->top; 442 else 443 max_size = rect->right - rect->left; 444 445 max_size -= (arrowSize-SCROLL_ARROW_THUMB_OVERLAP) + thumbSize; 446 447 if( pos < (arrowSize-SCROLL_ARROW_THUMB_OVERLAP) ) 448 pos = (arrowSize-SCROLL_ARROW_THUMB_OVERLAP); 449 else if( pos > max_size ) 450 pos = max_size; 451 452 SCROLL_DrawInterior_9x( SCROLL_TrackingWin, hdc, SCROLL_TrackingBar, 453 rect, arrowSize, thumbSize, pos, 454 0, vertical, FALSE, FALSE ); 455 456 SCROLL_MovingThumb = !SCROLL_MovingThumb; 457 } 458 431 459 static void SCROLL_DrawMovingThumb( HDC hdc, RECT *rect, BOOL vertical, 432 INT arrowSize, INT thumbSize ) 433 { 434 RECT r = *rect; 435 if (vertical) 436 { 437 r.top += SCROLL_TrackingPos; 438 if (r.top < rect->top + arrowSize - SCROLL_ARROW_THUMB_OVERLAP) 439 r.top = rect->top + arrowSize - SCROLL_ARROW_THUMB_OVERLAP; 440 if (r.top + thumbSize > 441 rect->bottom - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP)) 442 r.top = rect->bottom - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP) 443 - thumbSize; 444 r.bottom = r.top + thumbSize; 445 } 446 else 447 { 448 r.left += SCROLL_TrackingPos; 449 if (r.left < rect->left + arrowSize - SCROLL_ARROW_THUMB_OVERLAP) 450 r.left = rect->left + arrowSize - SCROLL_ARROW_THUMB_OVERLAP; 451 if (r.left + thumbSize > 452 rect->right - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP)) 453 r.left = rect->right - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP) 454 - thumbSize; 455 r.right = r.left + thumbSize; 456 } 457 DrawFocusRect( hdc, &r ); 458 SCROLL_MovingThumb = !SCROLL_MovingThumb; 459 } 460 460 INT arrowSize, INT thumbSize ) 461 { 462 SCROLL_DrawMovingThumb_9x( hdc, rect, vertical, arrowSize, thumbSize ); 463 } 461 464 462 465 /*********************************************************************** … … 465 468 * Draw the scroll bar interior (everything except the arrows). 466 469 */ 470 static void SCROLL_DrawInterior_9x( HWND hwnd, HDC hdc, INT nBar, 471 RECT *rect, INT arrowSize, 472 INT thumbSize, INT thumbPos, 473 UINT flags, BOOL vertical, 474 BOOL top_selected, BOOL bottom_selected ) 475 { 476 RECT r; 477 HPEN hSavePen; 478 HBRUSH hSaveBrush,hBrush; 479 480 /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR. 481 * The window-owned scrollbars need to call DEFWND_ControlColor 482 * to correctly setup default scrollbar colors 483 */ 484 if (nBar == SB_CTL) 485 { 486 hBrush = (HBRUSH)SendMessageA( GetParent(hwnd), WM_CTLCOLORSCROLLBAR, 487 (WPARAM)hdc,(LPARAM)hwnd); 488 } 489 else 490 { 491 //CB: implement! 492 //hBrush = DEFWND_ControlColor( hdc, CTLCOLOR_SCROLLBAR ); 493 } 494 495 hSavePen = SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) ); 496 hSaveBrush = SelectObject( hdc, hBrush ); 497 498 /* Calculate the scroll rectangle */ 499 r = *rect; 500 if (vertical) 501 { 502 r.top += arrowSize - SCROLL_ARROW_THUMB_OVERLAP; 503 r.bottom -= (arrowSize - SCROLL_ARROW_THUMB_OVERLAP); 504 } 505 else 506 { 507 r.left += arrowSize - SCROLL_ARROW_THUMB_OVERLAP; 508 r.right -= (arrowSize - SCROLL_ARROW_THUMB_OVERLAP); 509 } 510 511 /* Draw the scroll rectangles and thumb */ 512 if (!thumbPos) /* No thumb to draw */ 513 { 514 PatBlt( hdc, r.left, r.top, 515 r.right - r.left, r.bottom - r.top, 516 PATCOPY ); 517 518 /* cleanup and return */ 519 SelectObject( hdc, hSavePen ); 520 SelectObject( hdc, hSaveBrush ); 521 return; 522 } 523 524 if (vertical) 525 { 526 PatBlt( hdc, r.left, r.top, 527 r.right - r.left, 528 thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP), 529 top_selected ? 0x0f0000 : PATCOPY ); 530 r.top += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP); 531 PatBlt( hdc, r.left, r.top + thumbSize, 532 r.right - r.left, 533 r.bottom - r.top - thumbSize, 534 bottom_selected ? 0x0f0000 : PATCOPY ); 535 r.bottom = r.top + thumbSize; 536 } 537 else /* horizontal */ 538 { 539 PatBlt( hdc, r.left, r.top, 540 thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP), 541 r.bottom - r.top, 542 top_selected ? 0x0f0000 : PATCOPY ); 543 r.left += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP); 544 PatBlt( hdc, r.left + thumbSize, r.top, 545 r.right - r.left - thumbSize, 546 r.bottom - r.top, 547 bottom_selected ? 0x0f0000 : PATCOPY ); 548 r.right = r.left + thumbSize; 549 } 550 551 /* Draw the thumb */ 552 DrawEdge( hdc, &r, EDGE_RAISED, BF_RECT | BF_MIDDLE ); 553 554 /* cleanup */ 555 SelectObject( hdc, hSavePen ); 556 SelectObject( hdc, hSaveBrush ); 557 } 558 559 467 560 static void SCROLL_DrawInterior( HWND hwnd, HDC hdc, INT nBar, 468 561 RECT *rect, INT arrowSize, … … 483 576 /* Select the correct brush and pen */ 484 577 485 if ((flags & ESB_DISABLE_BOTH) == ESB_DISABLE_BOTH) 486 { 487 /* This ought to be the color of the parent window */ 488 //hBrush = GetSysColorBrush(COLOR_WINDOW); 489 /* Under Win9x look & feel, scrollbars don't have a solid border. 490 * To make scrollbar's background different from the window 491 * background, we need to apply a gray 0x55aa pattern brush. 492 * Otherwise it won't look good. 493 */ 494 //hBrush = CACHE_GetPattern55AABrush(); 495 hBrush = GetSysColorBrush(COLOR_3DFACE); //CB: improve! 496 } 497 else 498 { 499 /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR. 500 * The window-owned scrollbars need to call DEFWND_ControlColor 501 * to correctly setup default scrollbar colors 502 */ 503 if (nBar == SB_CTL) { 504 hBrush = (HBRUSH)SendMessageA( GetParent(hwnd), WM_CTLCOLORSCROLLBAR, 505 (WPARAM)hdc,(LPARAM)hwnd); 506 } else { 507 /* CB: implement later! 508 hBrush = DEFWND_ControlColor( hdc, CTLCOLOR_SCROLLBAR ); 509 */ 510 } 511 } 578 /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR. 579 * The window-owned scrollbars need to call DEFWND_ControlColor 580 * to correctly setup default scrollbar colors 581 */ 582 if (nBar == SB_CTL) { 583 hBrush = (HBRUSH)SendMessageA( GetParent(hwnd), WM_CTLCOLORSCROLLBAR, 584 (WPARAM)hdc,(LPARAM)hwnd); 585 } else { 586 //CB: implement! 587 //hBrush = DEFWND_ControlColor( hdc, CTLCOLOR_SCROLLBAR ); 588 } 589 512 590 hSavePen = SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) ); 513 591 hSaveBrush = SelectObject( hdc, hBrush ); … … 527 605 } 528 606 607 /* Draw the scroll bar frame */ 608 609 /* Only draw outline if Win 3.1. Mar 24, 1999 - Ronald B. Cemer */ 610 529 611 /* Draw the scroll rectangles and thumb */ 530 612 531 613 if (!thumbPos) /* No thumb to draw */ 532 614 { 533 PatBlt( hdc, r.left+1, r.top+1, r.right - r.left - 2, 534 r.bottom - r.top - 2, PATCOPY ); 615 INT offset = 0; 616 617 PatBlt( hdc, r.left+offset, r.top+offset, 618 r.right - r.left - 2*offset, r.bottom - r.top - 2*offset, 619 PATCOPY ); 535 620 536 621 /* cleanup and return */ … … 542 627 if (vertical) 543 628 { 544 PatBlt( hdc, r.left + 1, r.top + 1, 545 r.right - r.left - 2, 546 thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP) - 1, 629 INT offset = 0; 630 631 PatBlt( hdc, r.left + offset, r.top + offset, 632 r.right - r.left - offset*2, 633 thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP) - offset, 547 634 top_selected ? 0x0f0000 : PATCOPY ); 548 635 r.top += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP); 549 PatBlt( hdc, r.left + 1, r.top + thumbSize,550 r.right - r.left - 2,551 r.bottom - r.top - thumbSize - 1,636 PatBlt( hdc, r.left + offset, r.top + thumbSize, 637 r.right - r.left - offset*2, 638 r.bottom - r.top - thumbSize - offset, 552 639 bottom_selected ? 0x0f0000 : PATCOPY ); 553 640 r.bottom = r.top + thumbSize; … … 555 642 else /* horizontal */ 556 643 { 557 PatBlt( hdc, r.left + 1, r.top + 1, 558 thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP) - 1, 559 r.bottom - r.top - 2, 644 INT offset = 0; 645 646 PatBlt( hdc, r.left + offset, r.top + offset, 647 thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP), 648 r.bottom - r.top - offset*2, 560 649 top_selected ? 0x0f0000 : PATCOPY ); 561 650 r.left += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP); 562 PatBlt( hdc, r.left + thumbSize, r.top + 1,563 r.right - r.left - thumbSize - 1,564 r.bottom - r.top - 2,651 PatBlt( hdc, r.left + thumbSize, r.top + offset, 652 r.right - r.left - thumbSize - offset, 653 r.bottom - r.top - offset*2, 565 654 bottom_selected ? 0x0f0000 : PATCOPY ); 566 655 r.right = r.left + thumbSize; … … 571 660 SelectObject( hdc, GetSysColorBrush(COLOR_BTNFACE) ); 572 661 573 r.top++, r.left++; 574 r.bottom--; r.right--; 575 Rectangle( hdc, r.left, r.top, r.right-1, r.bottom-1 ); 662 Rectangle( hdc, r.left+1, r.top+1, r.right-1, r.bottom-1 ); 576 663 577 664 DrawEdge( hdc, &r, EDGE_RAISED, BF_RECT ); … … 586 673 SelectObject( hdc, hSaveBrush ); 587 674 } 588 589 675 590 676 /*********************************************************************** … … 770 856 SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, 771 857 SB_LINEUP, hwndCtl ); 772 //CB: SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?773 // SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,774 // (TIMERPROC)0 );775 858 } 859 //CB: SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ? 860 // SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY, 861 // (TIMERPROC)0 ); 776 862 } 777 863 //CB: else KillSystemTimer( hwnd, SCROLL_TIMER ); … … 871 957 SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, 872 958 SB_LINEDOWN, hwndCtl ); 873 //CB: SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?874 // SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,875 // (TIMERPROC)0 );876 959 } 960 //CB: SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ? 961 // SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY, 962 // (TIMERPROC)0 ); 877 963 } 878 964 //CB: else KillSystemTimer( hwnd, SCROLL_TIMER ); -
trunk/src/user32/new/static.cpp
r387 r500 1 /* $Id: static.cpp,v 1. 4 1999-07-24 17:10:26cbratschi Exp $ */1 /* $Id: static.cpp,v 1.5 1999-08-15 19:11:01 cbratschi Exp $ */ 2 2 /* 3 3 * Static control … … 83 83 * Set the bitmap for an SS_BITMAP control. 84 84 */ 85 static HBITMAP STATIC_SetBitmap( HWND hwnd, HBITMAP h bitmap )86 { 87 HBITMAP prevIcon;85 static HBITMAP STATIC_SetBitmap( HWND hwnd, HBITMAP hBitmap ) 86 { 87 HBITMAP hOldBitmap; 88 88 STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd); 89 89 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); … … 91 91 if ((dwStyle & SS_TYPEMASK) != SS_BITMAP) return 0; 92 92 93 if (infoPtr->hIcon) DeleteObject(infoPtr->hIcon); 94 prevIcon = infoPtr->hIcon; 95 infoPtr->hIcon = hbitmap; 96 97 if (hbitmap) 93 if (hBitmap && GetObjectType(hBitmap) != OBJ_BITMAP) { 94 //ERR("huh? hBitmap!=0, but not bitmap\n"); 95 return 0; 96 } 97 hOldBitmap = infoPtr->hIcon; 98 infoPtr->hIcon = hBitmap; 99 if (hBitmap) 98 100 { 101 BITMAP bm; 102 GetObjectA(hBitmap, sizeof(bm), &bm); 103 SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight, 104 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER ); 105 /* CB: alternative code, if necessary 99 106 HDC hdc = GetDC(hwnd); 100 107 BITMAPINFO info; … … 106 113 } 107 114 ReleaseDC(hwnd,hdc); 108 } 109 110 return prevIcon;111 } 112 115 */ 116 117 } 118 return hOldBitmap; 119 } 113 120 114 121 /*********************************************************************** … … 535 542 hdc, hwnd ); 536 543 FillRect( hdc, &rc, hbrush ); 537 if (infoPtr->hIcon) 538 DrawIcon(hdc,0,0,infoPtr->hIcon); 544 545 if (infoPtr->hIcon) { 546 BITMAP bm; 547 SIZE sz; 548 549 if(GetObjectType(infoPtr->hIcon) != OBJ_BITMAP) 550 return; 551 if (!(hMemDC = CreateCompatibleDC( hdc ))) return; 552 GetObjectA(infoPtr->hIcon, sizeof(bm), &bm); 553 GetBitmapDimensionEx(infoPtr->hIcon, &sz); 554 oldbitmap = SelectObject(hMemDC, infoPtr->hIcon); 555 BitBlt(hdc, sz.cx, sz.cy, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, 556 SRCCOPY); 557 SelectObject(hMemDC, oldbitmap); 558 DeleteDC(hMemDC); 559 } 539 560 } 540 561 -
trunk/src/user32/new/uitools.cpp
r407 r500 1 /* $Id: uitools.cpp,v 1. 2 1999-08-03 21:22:34 sandervlExp $ */1 /* $Id: uitools.cpp,v 1.3 1999-08-15 19:11:02 cbratschi Exp $ */ 2 2 /* 3 3 * User Interface Functions … … 462 462 LTInnerI = RBInnerI = LTRBInnerFlat[uType & (BDR_INNER|BDR_OUTER)]; 463 463 LTOuterI = RBOuterI = LTRBOuterFlat[uType & (BDR_INNER|BDR_OUTER)]; 464 465 /* Bertho Stultiens states above that this function exactly matches win95 466 * In win98 BF_FLAT rectangels have an inner border same color as the 467 * middle (COLOR_BTNFACE). I believe it's the same for win95 but since 468 * I don't know I go with Bertho and just sets it for win98 until proven 469 * otherwise. 470 * Dennis Björklund, 10 June, 99 471 */ 472 if(LTInnerI != -1 ) 473 LTInnerI = RBInnerI = COLOR_BTNFACE; 464 474 } 465 475 else if(uFlags & BF_SOFT) … … 488 498 if(RBOuterI != -1) RBOuterPen = GetSysColorPen(RBOuterI); 489 499 490 if((uFlags & BF_MIDDLE) && retval)491 {492 FillRect(hdc, &InnerRect, GetSysColorBrush(uFlags & BF_MONO ?493 COLOR_WINDOW : COLOR_BTNFACE));494 }495 496 500 MoveToEx(hdc, 0, 0, &SavePoint); 497 501 … … 545 549 } 546 550 547 /* Adjust rectangle if asked */ 548 if(uFlags & BF_ADJUST) 551 if( ((uFlags & BF_MIDDLE) && retval) || (uFlags & BF_ADJUST) ) 549 552 { 550 553 int add = (LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0) 551 554 + (LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0); 552 if(uFlags & BF_LEFT) rc->left += add; 553 if(uFlags & BF_RIGHT) rc->right -= add; 554 if(uFlags & BF_TOP) rc->top += add; 555 if(uFlags & BF_BOTTOM) rc->bottom -= add; 555 556 if(uFlags & BF_LEFT) InnerRect.left += add; 557 if(uFlags & BF_RIGHT) InnerRect.right -= add; 558 if(uFlags & BF_TOP) InnerRect.top += add; 559 if(uFlags & BF_BOTTOM) InnerRect.bottom -= add; 560 561 if((uFlags & BF_MIDDLE) && retval) 562 { 563 FillRect(hdc, &InnerRect, GetSysColorBrush(uFlags & BF_MONO ? 564 COLOR_WINDOW : COLOR_BTNFACE)); 565 } 566 567 if(uFlags & BF_ADJUST) 568 *rc = InnerRect; 556 569 } 557 570 … … 1124 1137 HBRUSH hbsave, hb, hb2; 1125 1138 HPEN hpsave, hp, hp2; 1126 int tri = 310*SmallDiam/1000;1139 int tri = 290*SmallDiam/1000 -1; 1127 1140 int d46, d93; 1128 1141 … … 1140 1153 case DFCS_SCROLLUP: 1141 1154 Line[2].x = myr.left + 470*SmallDiam/1000 + 2; 1142 Line[2].y = myr. top + 313*SmallDiam/1000 + 1;1155 Line[2].y = myr.bottom - 687*SmallDiam/1000 + 1; 1143 1156 Line[0].x = Line[2].x - tri; 1144 1157 Line[1].x = Line[2].x + tri; … … 1147 1160 1148 1161 case DFCS_SCROLLLEFT: 1149 Line[2].x = myr. left + 313*SmallDiam/1000 + 1;1162 Line[2].x = myr.right - 687*SmallDiam/1000 + 1; 1150 1163 Line[2].y = myr.top + 470*SmallDiam/1000 + 2; 1151 1164 Line[0].y = Line[2].y - tri; … … 1242 1255 1243 1256 /* Here do the real scroll-bar controls end up */ 1244 UITOOLS95_DFC_ButtonPush(dc, r, uFlags & 0xff00); 1257 if( ! (uFlags & (0xff00 & ~DFCS_ADJUSTRECT)) ) 1258 /* UITOOLS95_DFC_ButtonPush always uses BF_SOFT which we don't */ 1259 /* want for the normal scroll-arrow button. */ 1260 UITOOLS95_DrawRectEdge( dc, r, EDGE_RAISED, (uFlags&DFCS_ADJUSTRECT) | BF_MIDDLE | BF_RECT); 1261 else 1262 UITOOLS95_DFC_ButtonPush(dc, r, (uFlags & 0xff00) ); 1245 1263 1246 1264 if(uFlags & DFCS_INACTIVE) … … 1253 1271 } 1254 1272 1255 for(i = 0; i < 3; i++) 1256 { 1273 if( (uFlags & DFCS_INACTIVE) || !(uFlags & DFCS_PUSHED) ) 1274 for(i = 0; i < 3; i++) 1275 { 1257 1276 Line[i].x--; 1258 1277 Line[i].y--; 1259 }1278 } 1260 1279 1261 1280 i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT;
Note:
See TracChangeset
for help on using the changeset viewer.