Changeset 1203 for trunk/src/user32/edit.cpp
- Timestamp:
- Oct 8, 1999, 11:26:08 PM (26 years ago)
- File:
-
- 1 edited
-
trunk/src/user32/edit.cpp (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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 * WM_CREATE2723 * 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 if (es->bCaptureState && GetCapture() == hwnd) {3170 KillTimer(hwnd, 0);3171 ReleaseCapture();3172 }3173 es->bCaptureState = FALSE;3174 3175 return 0;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 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 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);
Note:
See TracChangeset
for help on using the changeset viewer.
