Changeset 12508
- Timestamp:
- Dec 1, 1999, 7:23:29 PM (25 years ago)
- Location:
- tags/trunk/src/user32
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified tags/trunk/src/user32/edit.cpp ¶
r12446 r12508 1 /* $Id: edit.cpp,v 1. 19 1999-11-27 14:16:34cbratschi Exp $ */1 /* $Id: edit.cpp,v 1.20 1999-12-01 18:23:27 cbratschi Exp $ */ 2 2 /* 3 3 * Edit control … … 11 11 * WINE version: 991031 12 12 * 13 * Status: in progress 14 * Version: ?.?? 15 */ 16 17 /* 18 * please read EDIT.TODO (and update it when you change things) 13 * Status: complete 14 * Version: 5.00 (without undocumented specs) 19 15 */ 20 16 21 17 /* CB: todo 22 - EN_UPDATE: send before update 23 - EN_CHANGE: send after update -> WM_PAINT isn't the right place 24 - EN_HSCROLL/EN_VSCROLL: send before update 25 - WS_BORDER -> bug in Win32BaseWindow::SetWindowLong 26 - many messages, styles, notifications 18 - EN_ALIGN_LTR_EC, EN_ALIGN_RTL_EC -> undocumented notifications 19 - EM_SETIMESTATUS, EM_GETITEMSTATUS -> undocumented messages 20 - text alignment for single and multi line (ES_LEFT, ES_RIGHT, ES_CENTER) 21 new in Win98, Win2k: for single line too 22 - WinNT/Win2k: higher size limits (single: 0x7FFFFFFE, multi: none) 23 - problems with OS/2 PM font kerning: 24 TabbedTextOutA 25 GetTextExtentPoint32A 26 WINE code uses relative positions -> rewrite to absolute! 27 27 */ 28 28 … … 39 39 FIXME: BTW, Win95 specs say 65535 (do you dare ???) */ 40 40 #define BUFLIMIT_SINGLE 32766 /* maximum buffer size (not including '\0') */ 41 42 //#define BUFLIMIT_MULTI 0xFFFFFFFE 43 //#define BUFLIMIT_SINGLE 0x7FFFFFFF 44 41 45 #define BUFSTART_MULTI 1024 /* starting size */ 42 46 #define BUFSTART_SINGLE 256 /* starting size */ … … 190 194 static LRESULT EDIT_EM_CharFromPos(HWND hwnd, EDITSTATE *es, INT x, INT y); 191 195 static BOOL EDIT_EM_FmtLines(HWND hwnd, EDITSTATE *es, BOOL add_eol); 196 static INT EDIT_EM_GetFirstVisibleLine(HWND hwnd,EDITSTATE *es); 192 197 static HLOCAL EDIT_EM_GetHandle(HWND hwnd, EDITSTATE *es); 198 static INT EDIT_EM_GetLimitText(HWND hwnd,EDITSTATE *es); 193 199 static INT EDIT_EM_GetLine(HWND hwnd, EDITSTATE *es, INT line, LPSTR lpch); 200 static INT EDIT_EM_GetLineCount(HWND hwnd,EDITSTATE *es); 201 static LONG EDIT_EM_GetMargins(HWND hwnd,EDITSTATE *es); 202 static BOOL EDIT_EM_GetModify(HWND hwnd,EDITSTATE *es); 203 static CHAR EDIT_EM_GetPasswordChar(HWND hwnd,EDITSTATE *es); 204 static VOID EDIT_EM_GetRect(HWND hwnd,EDITSTATE *es,LPRECT lprc); 194 205 static LRESULT EDIT_EM_GetSel(HWND hwnd, EDITSTATE *es, LPUINT start, LPUINT end); 195 206 static LRESULT EDIT_EM_GetThumb(HWND hwnd, EDITSTATE *es); 207 static PVOID EDIT_EM_GetWordbreakProc(HWND hwnd,EDITSTATE *es); 196 208 static INT EDIT_EM_LineFromChar(HWND hwnd, EDITSTATE *es, INT index); 197 209 static INT EDIT_EM_LineIndex(HWND hwnd, EDITSTATE *es, INT line); … … 205 217 static void EDIT_EM_SetLimitText(HWND hwnd, EDITSTATE *es, INT limit); 206 218 static void EDIT_EM_SetMargins(HWND hwnd, EDITSTATE *es, INT action, INT left, INT right); 219 static void EDIT_EM_SetModify(HWND hwnd,EDITSTATE *es,BOOL fModified); 207 220 static void EDIT_EM_SetPasswordChar(HWND hwnd, EDITSTATE *es, CHAR c); 221 static BOOL EDIT_EM_SetReadOnly(HWND hwnd,EDITSTATE *es,BOOL fReadOnly); 222 static void EDIT_EM_SetRect(HWND hwnd,EDITSTATE *es,LPRECT lprc); 223 static void EDIT_EM_SetRectNP(HWND hwnd,EDITSTATE *es,LPRECT lprc); 208 224 static void EDIT_EM_SetSel(HWND hwnd, EDITSTATE *es, UINT start, UINT end, BOOL after_wrap); 209 225 static BOOL EDIT_EM_SetTabStops(HWND hwnd, EDITSTATE *es, INT count, LPINT tabs); 210 226 static void EDIT_EM_SetWordBreakProc(HWND hwnd, EDITSTATE *es, EDITWORDBREAKPROCA wbp); 211 227 static BOOL EDIT_EM_Undo(HWND hwnd, EDITSTATE *es); 228 static LRESULT EDIT_EM_SetImeStatus(HWND hwnd,EDITSTATE *es,WPARAM wParam,LPARAM lParam); 229 static LRESULT EDIT_EM_GetImeStatus(HWND hwnd,EDITSTATE *es,WPARAM wParam,LPARAM lParam); 212 230 /* 213 231 * WM_XXX message handlers … … 345 363 case EM_GETRECT: 346 364 //DPRINTF_EDIT_MSG32("EM_GETRECT"); 347 if (lParam) 348 CopyRect((LPRECT)lParam, &es->format_rect); 365 EDIT_EM_GetRect(hwnd,es,(LPRECT)lParam); 349 366 break; 350 367 351 368 case EM_SETRECT: 352 369 //DPRINTF_EDIT_MSG32("EM_SETRECT"); 353 if ((es->style & ES_MULTILINE) && lParam) { 354 EDIT_SetRectNP(hwnd, es, (LPRECT)lParam); 355 EDIT_Refresh(hwnd,es); 356 } 370 EDIT_EM_SetRect(hwnd,es,(LPRECT)lParam); 357 371 break; 358 372 359 373 case EM_SETRECTNP: 360 374 //DPRINTF_EDIT_MSG32("EM_SETRECTNP"); 361 if ((es->style & ES_MULTILINE) && lParam) 362 EDIT_SetRectNP(hwnd, es, (LPRECT)lParam); 375 EDIT_EM_SetRectNP(hwnd,es,(LPRECT)lParam); 363 376 break; 364 377 … … 381 394 case EM_GETMODIFY: 382 395 //DPRINTF_EDIT_MSG32("EM_GETMODIFY"); 383 result = ( (es->flags & EF_MODIFIED) != 0);396 result = (LRESULT)EDIT_EM_GetModify(hwnd,es); 384 397 break; 385 398 386 399 case EM_SETMODIFY: 387 400 //DPRINTF_EDIT_MSG32("EM_SETMODIFY"); 388 if (wParam) 389 es->flags |= EF_MODIFIED; 390 else 391 es->flags &= ~(EF_MODIFIED | EF_UPDATE); /* reset pending updates */ 401 EDIT_EM_SetModify(hwnd,es,(BOOL)wParam); 392 402 break; 393 403 394 404 case EM_GETLINECOUNT: 395 405 //DPRINTF_EDIT_MSG32("EM_GETLINECOUNT"); 396 result = ( es->style & ES_MULTILINE) ? es->line_count : 1;406 result = (LRESULT)EDIT_EM_GetLineCount(hwnd,es); 397 407 break; 398 408 … … 515 525 case EM_GETFIRSTVISIBLELINE: 516 526 //DPRINTF_EDIT_MSG32("EM_GETFIRSTVISIBLELINE"); 517 result = ( es->style & ES_MULTILINE) ? es->y_offset : es->x_offset;527 result = (LRESULT)EDIT_EM_GetFirstVisibleLine(hwnd,es); 518 528 break; 519 529 520 530 case EM_SETREADONLY: 521 531 //DPRINTF_EDIT_MSG32("EM_SETREADONLY"); 522 if (wParam) 523 { 524 SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE) | ES_READONLY); 525 es->style |= ES_READONLY; 526 } else 527 { 528 SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE) & ~ES_READONLY); 529 es->style &= ~ES_READONLY; 530 } 531 result = 1; 532 result = (LRESULT)EDIT_EM_SetReadOnly(hwnd,es,(BOOL)wParam); 532 533 break; 533 534 … … 539 540 case EM_GETWORDBREAKPROC: 540 541 //DPRINTF_EDIT_MSG32("EM_GETWORDBREAKPROC"); 541 result = (LRESULT) es->word_break_procA;542 result = (LRESULT)EDIT_EM_GetWordbreakProc(hwnd,es); 542 543 break; 543 544 544 545 case EM_GETPASSWORDCHAR: 545 546 //DPRINTF_EDIT_MSG32("EM_GETPASSWORDCHAR"); 546 result = es->password_char;547 result = (LRESULT)EDIT_EM_GetPasswordChar(hwnd,es); 547 548 break; 548 549 … … 556 557 case EM_GETMARGINS: 557 558 //DPRINTF_EDIT_MSG32("EM_GETMARGINS"); 558 result = MAKELONG(es->left_margin, es->right_margin);559 result = EDIT_EM_GetMargins(hwnd,es); 559 560 break; 560 561 561 562 case EM_GETLIMITTEXT: 562 563 //DPRINTF_EDIT_MSG32("EM_GETLIMITTEXT"); 563 result = es->buffer_limit;564 result = (LRESULT)EDIT_EM_GetLimitText(hwnd,es); 564 565 break; 565 566 … … 572 573 //DPRINTF_EDIT_MSG32("EM_CHARFROMPOS"); 573 574 result = EDIT_EM_CharFromPos(hwnd, es, SLOWORD(lParam), SHIWORD(lParam)); 575 break; 576 577 case EM_SETIMESTATUS: 578 result = EDIT_EM_SetImeStatus(hwnd,es,wParam,lParam); 579 break; 580 581 case EM_GETIMESTATUS: 582 result = EDIT_EM_GetImeStatus(hwnd,es,wParam,lParam); 574 583 break; 575 584 … … 1785 1794 * NB : Q137805 is unclear about this. POINT * pointer in lParam apply 1786 1795 * to Richedit, not to the edit control. Original documentation is valid. 1787 * FIXME: do the specs mean to return -1 if outside client area or1788 * if outside formatting rectangle ???1789 1796 * 1790 1797 */ … … 1792 1799 { 1793 1800 POINT pt; 1794 RECT rc;1795 1801 INT index; 1796 1802 1797 1803 pt.x = x; 1798 1804 pt.y = y; 1799 GetClientRect(hwnd, &rc); 1800 if (!PtInRect(&rc, pt)) 1801 return -1; 1805 1806 if (!PtInRect(&es->format_rect,pt)) return -1; 1802 1807 1803 1808 index = EDIT_CharFromPos(hwnd, es, x, y, NULL); … … 1817 1822 if (add_eol) { 1818 1823 es->flags |= EF_USE_SOFTBRK; 1819 //FIXME_(edit)("soft break enabled, not implemented\n");1824 dprintf(("EDIT: EM_FMTLINES: soft break enabled, not implemented\n")); 1820 1825 } 1821 1826 return add_eol; 1822 1827 } 1823 1828 1829 static INT EDIT_EM_GetFirstVisibleLine(HWND hwnd,EDITSTATE *es) 1830 { 1831 return (es->style & ES_MULTILINE) ? es->y_offset : es->x_offset; 1832 } 1824 1833 1825 1834 /********************************************************************* … … 1874 1883 } 1875 1884 1885 static INT EDIT_EM_GetLimitText(HWND hwnd,EDITSTATE *es) 1886 { 1887 return es->buffer_limit; 1888 } 1889 1876 1890 /********************************************************************* 1877 1891 * … … 1884 1898 INT len; 1885 1899 INT i; 1900 1901 if (!lpch || *(WORD*)lpch == 0) return 0; 1886 1902 1887 1903 if (es->style & ES_MULTILINE) { … … 1892 1908 i = EDIT_EM_LineIndex(hwnd, es, line); 1893 1909 src = es->text + i; 1894 //SvL: Shouldn't this be *lpch-1? For terminating 01895 //len = MIN(*(WORD *)lpch-1, EDIT_EM_LineLength(hwnd, es, i));1896 1910 len = MIN(*(WORD *)lpch, EDIT_EM_LineLength(hwnd, es, i)); 1897 1911 for (i = 0 ; i < len ; i++) { … … 1901 1915 } 1902 1916 //SvL: Terminate string 1903 //*lpch = 0;1917 *lpch = 0; 1904 1918 return (LRESULT)len; 1905 1919 } 1906 1920 1921 static INT EDIT_EM_GetLineCount(HWND hwnd,EDITSTATE *es) 1922 { 1923 return (es->style & ES_MULTILINE) ? es->line_count : 1; 1924 } 1925 1926 static LONG EDIT_EM_GetMargins(HWND hwnd,EDITSTATE *es) 1927 { 1928 return MAKELONG(es->left_margin, es->right_margin); 1929 } 1930 1931 static BOOL EDIT_EM_GetModify(HWND hwnd,EDITSTATE *es) 1932 { 1933 return ((es->flags & EF_MODIFIED) != 0); 1934 } 1935 1936 static CHAR EDIT_EM_GetPasswordChar(HWND hwnd,EDITSTATE *es) 1937 { 1938 return es->password_char; 1939 } 1940 1941 static VOID EDIT_EM_GetRect(HWND hwnd,EDITSTATE *es,LPRECT lprc) 1942 { 1943 if (lprc) CopyRect(lprc,&es->format_rect); 1944 } 1907 1945 1908 1946 /********************************************************************* … … 1917 1955 1918 1956 ORDER_UINT(s, e); 1957 1919 1958 if (start) 1920 1959 *start = s; … … 1924 1963 } 1925 1964 1926 1927 1965 /********************************************************************* 1928 1966 * 1929 1967 * EM_GETTHUMB 1930 *1931 * FIXME: is this right ? (or should it be only VSCROLL)1932 * (and maybe only for edit controls that really have their1933 * own scrollbars) (and maybe only for multiline controls ?)1934 * All in all: very poorly documented1935 *1936 * FIXME: now it's also broken, because of the new WM_HSCROLL /1937 * WM_VSCROLL handlers1938 *1939 1968 */ 1940 1969 static LRESULT EDIT_EM_GetThumb(HWND hwnd, EDITSTATE *es) 1941 1970 { 1942 return MAKELONG(EDIT_WM_VScroll(hwnd, es, EM_GETTHUMB, 0, 0), 1943 EDIT_WM_HScroll(hwnd, es, EM_GETTHUMB, 0, 0)); 1944 } 1945 1971 SCROLLINFO si; 1972 1973 if (!(es->style & ES_MULTILINE)) return 0; 1974 1975 si.cbSize = sizeof(si); 1976 si.fMask = SIF_TRACKPOS; 1977 return GetScrollInfo(hwnd,SB_VERT,&si) ? si.nTrackPos:0; 1978 } 1979 1980 static PVOID EDIT_EM_GetWordbreakProc(HWND hwnd,EDITSTATE *es) 1981 { 1982 return es->word_break_procA; 1983 } 1946 1984 1947 1985 /********************************************************************* … … 1960 1998 return es->line_count - 1; 1961 1999 if (index == -1) 1962 index = MIN(es->selection_start, es->selection_end); 2000 index = MIN(es->selection_start, es->selection_end); //selection_end == caret pos 1963 2001 1964 2002 line = 0; … … 2021 2059 return lstrlenA(es->text); 2022 2060 2023 if (index == -1) {2024 /* FIXME: broken2025 INT32 sl = EDIT_EM_LineFromChar(wnd, es, es->selection_start);2026 INT32 el = EDIT_EM_LineFromChar(wnd, es, es->selection_end);2027 return es->selection_start - es->line_defs[sl].offset + 2028 es->line_defs[el].offset +2029 es->line_defs[el].length -es->selection_end;2030 */2031 return 0;2061 if (index == -1) 2062 { 2063 INT sl = EDIT_EM_LineFromChar(hwnd,es,MIN(es->selection_start,es->selection_end)); 2064 INT el = EDIT_EM_LineFromChar(hwnd,es,MAX(es->selection_start,es->selection_end)); 2065 2066 if (sl == el) 2067 return EDIT_EM_LineLength(hwnd,es,sl)+es->selection_start-es->selection_end; 2068 else 2069 return es->selection_start+EDIT_EM_LineLength(hwnd,es,el)-es->selection_end; 2032 2070 } 2033 2071 line_def = es->first_line_def; … … 2096 2134 nyoff = es->line_count - 1; 2097 2135 dy = (es->y_offset - nyoff) * es->line_height; 2098 if (dx || dy) { 2136 if (dx || dy) 2137 { 2099 2138 RECT rc1; 2100 2139 RECT rc; 2140 2141 if (dx && !(es->flags & EF_HSCROLL_TRACK)) 2142 EDIT_NOTIFY_PARENT(hwnd, EN_HSCROLL); 2143 if (dy && !(es->flags & EF_VSCROLL_TRACK)) 2144 EDIT_NOTIFY_PARENT(hwnd, EN_VSCROLL); 2145 2101 2146 GetClientRect(hwnd, &rc1); 2102 2147 IntersectRect(&rc, &rc1, &es->format_rect); … … 2108 2153 EDIT_UpdateScrollBars(hwnd,es,dx,dy); 2109 2154 } 2110 if (dx && !(es->flags & EF_HSCROLL_TRACK)) 2111 EDIT_NOTIFY_PARENT(hwnd, EN_HSCROLL); 2112 if (dy && !(es->flags & EF_VSCROLL_TRACK)) 2113 EDIT_NOTIFY_PARENT(hwnd, EN_VSCROLL); 2155 2114 2156 return TRUE; 2115 2157 } … … 2178 2220 } 2179 2221 2222 BOOL EDIT_CheckNumber(CHAR *text) 2223 { 2224 if (!text) return TRUE; 2225 2226 while (text[0] != 0) 2227 { 2228 if ((BYTE)text[0] < '0' || (BYTE)text[0] > '9') return FALSE; 2229 text++; 2230 } 2231 2232 return TRUE; 2233 } 2180 2234 2181 2235 /********************************************************************* 2182 2236 * 2183 2237 * EM_REPLACESEL 2184 *2185 * FIXME: handle ES_NUMBER and ES_OEMCONVERT here2186 2238 * 2187 2239 */ … … 2237 2289 lstrcpyA(es->text + s, es->text + e); 2238 2290 } 2239 if (strl) { 2240 /* there is an insertion */ 2241 if (can_undo) { 2242 if ((s == es->undo_position) || 2243 ((es->undo_insert_count) && 2244 (s == es->undo_position + es->undo_insert_count))) 2245 /* 2246 * insertion is new and at delete position or 2247 * an extension to either left or right 2248 */ 2249 es->undo_insert_count += strl; 2250 else { 2251 /* new insertion undo */ 2252 es->undo_position = s; 2253 es->undo_insert_count = strl; 2254 /* new insertion makes old delete-buffer invalid */ 2255 *es->undo_text = '\0'; 2256 } 2257 } else 2258 EDIT_EM_EmptyUndoBuffer(hwnd, es); 2259 2260 /* now insert */ 2261 tl = lstrlenA(es->text); 2262 for (p = es->text + tl ; p >= es->text + s ; p--) 2263 p[strl] = p[0]; 2264 for (i = 0 , p = es->text + s ; i < strl ; i++) 2265 p[i] = lpsz_replace[i]; 2266 if(es->style & ES_UPPERCASE) 2267 CharUpperBuffA(p, strl); 2268 else if(es->style & ES_LOWERCASE) 2269 CharLowerBuffA(p, strl); 2270 s += strl; 2291 if (strl) 2292 { 2293 if (es->style & ES_NUMBER && !EDIT_CheckNumber((CHAR*)lpsz_replace)) 2294 MessageBeep(MB_ICONEXCLAMATION); 2295 else 2296 { 2297 /* there is an insertion */ 2298 if (can_undo) { 2299 if ((s == es->undo_position) || 2300 ((es->undo_insert_count) && 2301 (s == es->undo_position + es->undo_insert_count))) 2302 /* 2303 * insertion is new and at delete position or 2304 * an extension to either left or right 2305 */ 2306 es->undo_insert_count += strl; 2307 else { 2308 /* new insertion undo */ 2309 es->undo_position = s; 2310 es->undo_insert_count = strl; 2311 /* new insertion makes old delete-buffer invalid */ 2312 *es->undo_text = '\0'; 2313 } 2314 } else 2315 EDIT_EM_EmptyUndoBuffer(hwnd, es); 2316 2317 2318 /* now insert */ 2319 tl = lstrlenA(es->text); 2320 for (p = es->text + tl ; p >= es->text + s ; p--) 2321 p[strl] = p[0]; 2322 for (i = 0 , p = es->text + s ; i < strl ; i++) 2323 p[i] = lpsz_replace[i]; 2324 2325 if (es->style & ES_OEMCONVERT) 2326 { 2327 CHAR *text = (LPSTR)HeapAlloc(es->heap,0,strl); 2328 2329 CharToOemBuffA(lpsz_replace,text,strl); 2330 OemToCharBuffA(text,p,strl); 2331 HeapFree(es->heap,0,text); 2332 } 2333 2334 if(es->style & ES_UPPERCASE) 2335 CharUpperBuffA(p, strl); 2336 else if(es->style & ES_LOWERCASE) 2337 CharLowerBuffA(p, strl); 2338 2339 s += strl; 2340 } 2271 2341 } 2272 2342 /* FIXME: really inefficient */ … … 2319 2389 } 2320 2390 if (dy) { 2391 EDIT_NOTIFY_PARENT(hwnd, EN_VSCROLL); 2321 2392 EDIT_EM_LineScroll(hwnd, es, 0, dy); 2322 EDIT_NOTIFY_PARENT(hwnd, EN_VSCROLL);2323 2393 } 2324 2394 return MAKELONG((INT16)dy, (BOOL16)TRUE); … … 2400 2470 * EM_SETHANDLE 2401 2471 * 2402 * FIXME: ES_LOWERCASE, ES_UPPERCASE, ES_OEMCONVERT, ES_NUMBER ???2403 *2404 2472 */ 2405 2473 static void EDIT_EM_SetHandle(HWND hwnd, EDITSTATE *es, HLOCAL hloc) … … 2426 2494 es->buffer_size = LocalSize(es->hloc) - 1; 2427 2495 EDIT_LockBuffer(hwnd, es); 2496 2497 if (es->text && es->text[0] != 0) 2498 { 2499 if (es->style & ES_NUMBER) 2500 { 2501 //CB: todo 2502 } 2503 2504 if (es->style & ES_OEMCONVERT) 2505 { 2506 INT len = lstrlenA(es->text); 2507 CHAR *text = (LPSTR)HeapAlloc(es->heap,0,len); 2508 2509 CharToOemBuffA(es->text,text,len); 2510 OemToCharBuffA(text,es->text,len); 2511 HeapFree(es->heap,0,text); 2512 } 2513 2514 if(es->style & ES_UPPERCASE) 2515 CharUpperA(es->text); 2516 else if(es->style & ES_LOWERCASE) 2517 CharLowerA(es->text); 2518 } 2428 2519 2429 2520 es->x_offset = es->y_offset = 0; … … 2474 2565 INT left, INT right) 2475 2566 { 2567 RECT r; 2568 INT oldLeft = es->left_margin,oldRight = es->right_margin; 2569 2476 2570 if (action & EC_LEFTMARGIN) { 2477 2571 if (left != EC_USEFONTINFO) … … 2488 2582 } 2489 2583 //TRACE_(edit)("left=%d, right=%d\n", es->left_margin, es->right_margin); 2490 } 2491 2584 2585 if (oldLeft != es->left_margin || oldRight != es->right_margin) 2586 { 2587 GetClientRect(hwnd, &r); 2588 EDIT_SetRectNP(hwnd, es, &r); 2589 if (es->style & ES_MULTILINE) 2590 EDIT_BuildLineDefs_ML(hwnd, es); 2591 2592 EDIT_Refresh(hwnd,es); 2593 if (es->flags & EF_FOCUSED) { 2594 DestroyCaret(); 2595 CreateCaret(hwnd, 0, 2, es->line_height); 2596 EDIT_SetCaretPos(hwnd, es, es->selection_end, 2597 es->flags & EF_AFTER_WRAP); 2598 ShowCaret(hwnd); 2599 } 2600 } 2601 } 2602 2603 static void EDIT_EM_SetModify(HWND hwnd,EDITSTATE *es,BOOL fModified) 2604 { 2605 if (fModified) 2606 es->flags |= EF_MODIFIED; 2607 else 2608 es->flags &= ~(EF_MODIFIED | EF_UPDATE); /* reset pending updates */ 2609 } 2492 2610 2493 2611 /********************************************************************* … … 2515 2633 } 2516 2634 2635 static BOOL EDIT_EM_SetReadOnly(HWND hwnd,EDITSTATE *es,BOOL fReadOnly) 2636 { 2637 if (fReadOnly) 2638 { 2639 SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE) | ES_READONLY); 2640 es->style |= ES_READONLY; 2641 } else 2642 { 2643 SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE) & ~ES_READONLY); 2644 es->style &= ~ES_READONLY; 2645 } 2646 2647 return TRUE; 2648 } 2649 2650 static void EDIT_EM_SetRect(HWND hwnd,EDITSTATE *es,LPRECT lprc) 2651 { 2652 if ((es->style & ES_MULTILINE) && lprc) 2653 { 2654 EDIT_SetRectNP(hwnd,es,lprc); 2655 EDIT_Refresh(hwnd,es); 2656 } 2657 } 2658 2659 static void EDIT_EM_SetRectNP(HWND hwnd,EDITSTATE *es,LPRECT lprc) 2660 { 2661 if ((es->style & ES_MULTILINE) && lprc) 2662 EDIT_SetRectNP(hwnd,es,lprc); 2663 } 2517 2664 2518 2665 /********************************************************************* … … 2642 2789 } 2643 2790 2791 static LRESULT EDIT_EM_SetImeStatus(HWND hwnd,EDITSTATE *es,WPARAM wParam,LPARAM lParam) 2792 { 2793 //CB: undocumented! 2794 2795 return 0; 2796 } 2797 2798 static LRESULT EDIT_EM_GetImeStatus(HWND hwnd,EDITSTATE *es,WPARAM wParam,LPARAM lParam) 2799 { 2800 //CB: undocumented! 2801 2802 return 0; 2803 } 2644 2804 2645 2805 /********************************************************************* … … 2655 2815 /* If the edit doesn't want the return and it's not a multiline edit, do nothing */ 2656 2816 if(!(es->style & ES_MULTILINE) && !(es->style & ES_WANTRETURN)) 2657 break; 2817 { 2818 MessageBeep(MB_ICONEXCLAMATION); 2819 break; 2820 } 2658 2821 case '\n': 2659 2822 if (es->style & ES_MULTILINE) { … … 2682 2845 break; 2683 2846 default: 2684 if (!(es->style & ES_READONLY) && ((BYTE)c >= ' ') && (c != 127)) { 2685 char str[2]; 2686 str[0] = c; 2687 str[1] = '\0'; 2688 EDIT_EM_ReplaceSel(hwnd, es, TRUE, str); 2689 } 2847 if (!(es->style & ES_READONLY) && ((BYTE)c >= ' ') && (c != 127)) 2848 { 2849 char str[2]; 2850 2851 if (es->style & ES_NUMBER) 2852 { 2853 if ((BYTE)c < '0' || (BYTE)c > '9') MessageBeep(MB_ICONEXCLAMATION); 2854 return; 2855 } 2856 str[0] = c; 2857 str[1] = '\0'; 2858 EDIT_EM_ReplaceSel(hwnd, es, TRUE, str); 2859 } else MessageBeep(MB_ICONEXCLAMATION); 2690 2860 break; 2691 2861 } … … 2758 2928 EnableMenuItem(popup, 0, MF_BYPOSITION | (EDIT_EM_CanUndo(hwnd, es) ? MF_ENABLED : MF_GRAYED)); 2759 2929 /* cut */ 2760 EnableMenuItem(popup, 2, MF_BYPOSITION | ((end - start) && !(es->style & ES_PASSWORD) ? MF_ENABLED : MF_GRAYED));2930 EnableMenuItem(popup, 2, MF_BYPOSITION | ((end - start) && !(es->style & (ES_PASSWORD | ES_READONLY)) ? MF_ENABLED : MF_GRAYED)); 2761 2931 /* copy */ 2762 2932 EnableMenuItem(popup, 3, MF_BYPOSITION | ((end - start) && !(es->style & ES_PASSWORD) ? MF_ENABLED : MF_GRAYED)); 2763 2933 /* paste */ 2764 EnableMenuItem(popup, 4, MF_BYPOSITION | (IsClipboardFormatAvailable(CF_TEXT) ? MF_ENABLED : MF_GRAYED));2934 EnableMenuItem(popup, 4, MF_BYPOSITION | (IsClipboardFormatAvailable(CF_TEXT) && !(es->style & ES_READONLY) ? MF_ENABLED : MF_GRAYED)); 2765 2935 /* delete */ 2766 EnableMenuItem(popup, 5, MF_BYPOSITION | ((end - start) ? MF_ENABLED : MF_GRAYED));2936 EnableMenuItem(popup, 5, MF_BYPOSITION | ((end - start) && !(es->style & ES_READONLY) ? MF_ENABLED : MF_GRAYED)); 2767 2937 /* select all */ 2768 2938 EnableMenuItem(popup, 7, MF_BYPOSITION | (start || (end != lstrlenA(es->text)) ? MF_ENABLED : MF_GRAYED)); … … 3500 3670 ShowCaret(hwnd); 3501 3671 3502 //CB: replace3503 3672 if (es->flags & EF_UPDATE) 3504 3673 { … … 3604 3773 RECT r; 3605 3774 3606 es->font = font;3607 3775 dc = GetDC(hwnd); 3608 3776 if (font) 3609 3777 old_font = SelectObject(dc, font); 3610 GetTextMetricsA(dc, &tm); 3778 if (!GetTextMetricsA(dc, &tm)) 3779 { 3780 SelectObject(dc,old_font); 3781 ReleaseDC(hwnd,dc); 3782 3783 return; 3784 } 3785 es->font = font; 3611 3786 es->line_height = tm.tmHeight; 3612 3613 //@@@PH 1999/11/08 prevent division by zero3614 if (es->line_height == 0)3615 es->line_height = 12; // reasonable default?3616 3787 3617 3788 es->char_width = tm.tmAveCharWidth; … … 3721 3892 EDIT_MoveForward(hwnd, es, TRUE); 3722 3893 } 3723 /* 3724 * FIXME: gotta do some vertical scrolling here, like 3725 * EDIT_EM_LineScroll(wnd, 0, 1); 3726 */ 3894 3895 if (!(es->style & ES_MULTILINE)) return; 3896 3897 if (es->region_posy < 0) 3898 { 3899 EDIT_MoveUp_ML(hwnd,es,TRUE); 3900 } else if (es->region_posy > 0) 3901 { 3902 EDIT_MoveDown_ML(hwnd,es,TRUE); 3903 } 3727 3904 } 3728 3905 -
TabularUnified tags/trunk/src/user32/pmframe.cpp ¶
r12291 r12508 1 /* $Id: pmframe.cpp,v 1.2 4 1999-11-11 17:13:45cbratschi Exp $ */1 /* $Id: pmframe.cpp,v 1.25 1999-12-01 18:23:28 cbratschi Exp $ */ 2 2 /* 3 3 * Win32 Frame Managment Code for OS/2 … … 312 312 goto RunDefFrameProc; //CB: must call def frame proc or frame control activation is broken 313 313 } 314 314 315 315 case WM_WINDOWPOSCHANGED: 316 316 { -
TabularUnified tags/trunk/src/user32/scroll.cpp ¶
r12414 r12508 1 /* $Id: scroll.cpp,v 1.2 5 1999-11-24 18:21:37cbratschi Exp $ */1 /* $Id: scroll.cpp,v 1.26 1999-12-01 18:23:28 cbratschi Exp $ */ 2 2 /* 3 3 * Scrollbar control … … 83 83 { 84 84 Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); 85 85 86 if (!win32wnd) return 0; 86 if (nBar == SB_HORZ) return Win32BaseWindow::OS2ToWin32Handle(win32wnd->getHorzScrollHandle()); 87 else return Win32BaseWindow::OS2ToWin32Handle(win32wnd->getVertScrollHandle()); 87 if (nBar == SB_HORZ) 88 return (win32wnd->getStyle() & WS_HSCROLL) ? Win32BaseWindow::OS2ToWin32Handle(win32wnd->getHorzScrollHandle()):0; 89 else 90 return (win32wnd->getStyle() & WS_VSCROLL) ? Win32BaseWindow::OS2ToWin32Handle(win32wnd->getVertScrollHandle()):0; 88 91 } 92 89 93 case SB_CTL: 90 94 return hwnd; … … 1422 1426 { 1423 1427 action = SA_SSI_HIDE; 1428 infoPtr->flags = 0; 1424 1429 goto done; 1425 1430 } … … 1630 1635 dprintf(("ShowScrollBar window not found!")); 1631 1636 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 1632 return 0;1637 return FALSE; 1633 1638 } 1634 1639 … … 1663 1668 { 1664 1669 Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(hwnd); 1670 1665 1671 if(!window) 1666 1672 { … … 1674 1680 BOOL rc = FALSE; 1675 1681 1676 if ( nBar == SB_VERT || nBar == SB_BOTH)1682 if ((nBar == SB_VERT || nBar == SB_BOTH) && window->getStyle() & WS_VSCROLL) 1677 1683 { 1678 1684 HWND hwndScroll = Win32BaseWindow::OS2ToWin32Handle(window->getVertScrollHandle()); … … 1690 1696 } 1691 1697 } 1692 if ( nBar == SB_HORZ || (rc && nBar == SB_BOTH))1698 if ((nBar == SB_HORZ || (rc && nBar == SB_BOTH)) && window->getStyle() & WS_HSCROLL) 1693 1699 { 1694 HWND hwndScroll = Win32BaseWindow::OS2ToWin32Handle(window->get VertScrollHandle());1700 HWND hwndScroll = Win32BaseWindow::OS2ToWin32Handle(window->getHorzScrollHandle()); 1695 1701 1696 1702 infoPtr = SCROLL_GetInfoPtr(hwndScroll,SB_VERT); -
TabularUnified tags/trunk/src/user32/win32wbase.cpp ¶
r12503 r12508 1 /* $Id: win32wbase.cpp,v 1. 99 1999-12-01 10:49:45 sandervlExp $ */1 /* $Id: win32wbase.cpp,v 1.100 1999-12-01 18:23:29 cbratschi Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 … … 1346 1346 { 1347 1347 DWORD newFlags; 1348 1348 1349 rc = FrameShowScrollBars(this,showHorz,showVert,fShow,FALSE,&newFlags); 1349 1350 flags |= newFlags;
Note:
See TracChangeset
for help on using the changeset viewer.