- Timestamp:
- Nov 27, 2009, 1:11:27 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets/Text.java
r231 r234 327 327 if (hHint != SWT.DEFAULT) height = hHint; 328 328 329 if ((style & SWT.V_SCROLL) != 0) {329 if ((style & SWT.V_SCROLL) != 0) { 330 330 width += OS.WinQuerySysValue (OS.HWND_DESKTOP, OS.SV_CXVSCROLL); 331 331 } 332 if ((style & SWT.H_SCROLL) != 0) {332 if ((style & SWT.H_SCROLL) != 0) { 333 333 height += OS.WinQuerySysValue (OS.HWND_DESKTOP, OS.SV_CYHSCROLL); 334 334 if ((style & SWT.BORDER) == 0) width++; … … 336 336 if ((style & SWT.BORDER) != 0) { 337 337 int border = getBorderWidth (); 338 width += (border * 2) + 3;339 height += (border * 2) + 1;340 } 341 return new Point 338 width += (border * 2) + 1; 339 height += (border * 2) + 2; 340 } 341 return new Point(width, height); 342 342 } 343 343 … … 496 496 public int getCharCount () { 497 497 checkWidget (); 498 int length = OS.WinQueryWindowTextLength (handle); 498 int length = 0; 499 if ((style & SWT.MULTI) != 0){ 500 length = OS.WinSendMsg (handle, OS.MLM_QUERYTEXTLENGTH, 0, 0); 501 }else{ 502 length = OS.WinQueryWindowTextLength (handle); 503 } 499 504 //@@TODO(lpino): Implement the DB support 500 505 // if (OS.IsDBLocale) length = mbcsToWcsPos (length); 501 506 return length; 502 507 } 503 // 508 504 509 String getClipboardText () { 505 510 String string = ""; 506 511 int hab = parent.getDisplay ().hab; 507 512 if (OS.WinOpenClipbrd (hab)) { 508 // int hMem = OS.GetClipboardData (OS.IsUnicode ? OS.CF_UNICODETEXT : OS.CF_TEXT); 509 // if (hMem != 0) { 510 // int byteCount = OS.GlobalSize (hMem); 511 // int ptr = OS.GlobalLock (hMem); 512 // if (ptr != 0) { 513 // /* Use the character encoding for the default locale */ 514 // TCHAR buffer = new TCHAR (0, byteCount / TCHAR.sizeof); 515 // OS.MoveMemory (buffer, ptr, byteCount); 516 // string = buffer.toString (0, buffer.strlen ()); 517 // OS.GlobalUnlock (hMem); 518 // } 519 // } 520 OS.WinCloseClipbr (hab); 513 int pText = OS.WinQueryClipbrdData(hab, OS.CF_TEXT); 514 if(pText != 0){ 515 byte[] buffer = new byte[OS.strlen(pText)]; 516 OS.objcpy(buffer, pText); 517 PSZ text = new PSZ(buffer); 518 string = text.toString(); 519 } 520 OS.WinCloseClipbrd (hab); 521 521 } 522 522 return string; … … 847 847 * </ul> 848 848 */ 849 //public int getTopPixel () { 850 // checkWidget (); 851 // /* 852 // * Note, EM_GETSCROLLPOS is implemented in Rich Edit 3.0 853 // * and greater. The plain text widget and previous versions 854 // * of Rich Edit return zero. 855 // */ 856 // int [] buffer = new int [2]; 857 // int code = OS.SendMessage (handle, OS.EM_GETSCROLLPOS, 0, buffer); 858 // if (code == 1) return buffer [1]; 859 // return getTopIndex () * getLineHeight (); 860 //} 849 public int getTopPixel () { 850 checkWidget (); 851 if((style & SWT.SINGLE) != 0) return 0; 852 return getTopIndex () * getLineHeight (); 853 } 861 854 862 855 /* … … 1272 1265 if ((style & SWT.MULTI) != 0){ 1273 1266 OS.WinSendMsg (handle, OS.MLM_SETSEL, start, start); 1274 // OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);1275 1267 } 1276 1268 else{ 1277 1269 OS.WinSendMsg (handle, OS.EM_SETSEL, OS.MPFROM2SHORT((short)start,(short)start),0); 1278 // OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);1279 1270 } 1280 1271 } … … 1516 1507 public void showSelection () { 1517 1508 checkWidget (); 1518 int pos = OS.WinSendMsg (handle, OS.MLM_QUERYSEL, OS.MLFQS_ANCHORSEL , 0); 1519 OS.WinSendMsg (handle, OS.MLM_SETSEL, pos, pos); 1509 if ((style & SWT.MULTI) != 0){ 1510 int pos = OS.WinSendMsg (handle, OS.MLM_QUERYSEL, OS.MLFQS_ANCHORSEL , 0); 1511 OS.WinSendMsg (handle, OS.MLM_SETSEL, pos, pos); 1512 } else { 1513 int pos = OS.WinSendMsg (handle, OS.EM_QUERYSEL, 0 , 0); 1514 OS.WinSendMsg (handle, OS.MLM_SETFIRSTCHAR, OS.SHORT1FROMMP(pos), 0); 1515 } 1520 1516 } 1521 1517 … … 1605 1601 if ((style & SWT.H_SCROLL) != 0) bits |= OS.MLS_HSCROLL; 1606 1602 if ((style & SWT.BORDER) != 0) bits |= OS.MLS_BORDER; 1607 return bits | OS.WS_VISIBLE | OS.WS_GROUP | OS.WS_TABSTOP ;1603 return bits | OS.WS_VISIBLE | OS.WS_GROUP | OS.WS_TABSTOP | OS.MLS_LIMITVSCROLL; 1608 1604 } 1609 1605 else{ … … 1629 1625 } 1630 1626 1631 //int windowProc (int msg, int mp1, int mp2) { 1632 // int result = super.windowProc (msg, mp1, mp2); 1633 // switch(msg){ 1634 // case OS.MLM_CUT:{ 1635 // OS.WinSendMsg(handle, OS.MLM_CUT,0,0); 1636 // break; 1637 // } 1638 // } 1639 // return result; 1640 //} 1641 1627 /* int windowProc (int msg, int mp1, int mp2) { 1628 int result = super.windowProc (msg, mp1, mp2); 1629 switch(msg){ 1630 case OS.MLM_PASTE:{ 1631 System.out.println("Text::windowProc -> MLM_PASTE"); 1632 break; 1633 } 1634 case OS.EM_PASTE:{ 1635 System.out.println("Text::windowProc -> EM_PASTE"); 1636 if (!hooks (SWT.Verify)) return result; 1637 int bits = OS.WinQueryWindowULong(handle, OS.QWL_STYLE); 1638 if ((bits & OS.ES_READONLY) != 0) return result; 1639 String oldText = getClipboardText (); 1640 if (oldText == null) return result; 1641 int pos = OS.WinSendMsg (handle, OS.EM_QUERYSEL, 0, 0); 1642 int start = OS.SHORT1FROMMP(pos); 1643 int end = OS.SHORT2FROMMP(pos); 1644 String newText = verifyText (oldText, start, end); 1645 if (newText == null) return OS.FALSE; 1646 if (newText != oldText) { 1647 newText = Display.withCrLf (newText); 1648 PSZ buffer = new PSZ(newText); 1649 // OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer); 1650 // return LRESULT.ZERO; 1651 } 1652 break; 1653 } 1654 } 1655 return result; 1656 } 1657 */ 1642 1658 MRESULT WM_CHAR (int mp1, int mp2) { 1643 1659 if (ignoreCharacter) return null; … … 1646 1662 return result; 1647 1663 } 1648 // 1649 //LRESULT WM_CLEAR (int wParam, int lParam) { 1650 // LRESULT result = super.WM_CLEAR (wParam, lParam); 1651 // if (result != null) return result; 1652 // if (!hooks (SWT.Verify)) return result; 1653 // int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); 1654 // if ((bits & OS.ES_READONLY) != 0) return result; 1655 // int [] start = new int [1], end = new int [1]; 1656 // OS.SendMessage (handle, OS.EM_GETSEL, start, end); 1657 // if (start [0] == end [0]) return result; 1658 // String newText = verifyText ("", start [0], end [0]); 1659 // if (newText == null) return LRESULT.ZERO; 1660 // if (newText.length () != 0) { 1661 // result = new LRESULT (callWindowProc (OS.WM_CLEAR, 0, 0)); 1662 // newText = Display.withCrLf (newText); 1663 // TCHAR buffer = new TCHAR (getCodePage (), newText, true); 1664 // OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer); 1665 // } 1666 // return result; 1667 //} 1668 // 1669 //LRESULT WM_CUT (int wParam, int lParam) { 1670 // LRESULT result = super.WM_CUT (wParam, lParam); 1671 // if (result != null) return result; 1672 // if (!hooks (SWT.Verify)) return result; 1673 // int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); 1674 // if ((bits & OS.ES_READONLY) != 0) return result; 1675 // int [] start = new int [1], end = new int [1]; 1676 // OS.SendMessage (handle, OS.EM_GETSEL, start, end); 1677 // if (start [0] == end [0]) return result; 1678 // String newText = verifyText ("", start [0], end [0]); 1679 // if (newText == null) return LRESULT.ZERO; 1680 // if (newText.length () != 0) { 1681 // result = new LRESULT (callWindowProc (OS.WM_CUT, 0, 0)); 1682 // newText = Display.withCrLf (newText); 1683 // TCHAR buffer = new TCHAR (getCodePage (), newText, true); 1684 // OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer); 1685 // } 1686 // return result; 1687 //} 1664 1688 1665 //LRESULT WM_IME_CHAR (int wParam, int lParam) { 1689 1666 // … … 1749 1726 // return null; 1750 1727 //} 1751 //1752 //LRESULT WM_PASTE (int wParam, int lParam) {1753 // LRESULT result = super.WM_PASTE (wParam, lParam);1754 // if (result != null) return result;1755 // if (!hooks (SWT.Verify)) return result;1756 // int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);1757 // if ((bits & OS.ES_READONLY) != 0) return result;1758 // String oldText = getClipboardText ();1759 // if (oldText == null) return result;1760 // int [] start = new int [1], end = new int [1];1761 // OS.SendMessage (handle, OS.EM_GETSEL, start, end);1762 // String newText = verifyText (oldText, start [0], end [0]);1763 // if (newText == null) return LRESULT.ZERO;1764 // if (newText != oldText) {1765 // newText = Display.withCrLf (newText);1766 // TCHAR buffer = new TCHAR (getCodePage (), newText, true);1767 // OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);1768 // return LRESULT.ZERO;1769 // }1770 // return result;1771 //}1772 //1773 1728 //LRESULT WM_SIZE (int wParam, int lParam) { 1774 1729 // LRESULT result = super.WM_SIZE (wParam, lParam); … … 1807 1762 // return result; 1808 1763 //} 1809 //1810 //LRESULT WM_UNDO (int wParam, int lParam) {1811 // LRESULT result = super.WM_UNDO (wParam, lParam);1812 // if (result != null) return result;1813 // if (!hooks (SWT.Verify)) return result;1814 //1815 // /* Undo and then Redo to get the Undo text */1816 // if (OS.SendMessage (handle, OS.EM_CANUNDO, 0, 0) == 0) {1817 // return result;1818 // }1819 // ignoreVerify = true;1820 // callWindowProc (OS.WM_UNDO, wParam, lParam);1821 // String oldText = getSelectionText ();1822 // callWindowProc (OS.WM_UNDO, wParam, lParam);1823 // ignoreVerify = false;1824 //1825 // /* Verify the Undo operation */1826 // int [] start = new int [1], end = new int [1];1827 // OS.SendMessage (handle, OS.EM_GETSEL, start, end);1828 // String newText = verifyText (oldText, start [0], end [0]);1829 // if (newText == null) return LRESULT.ZERO;1830 // if (newText != oldText) {1831 // newText = Display.withCrLf (newText);1832 // TCHAR buffer = new TCHAR (getCodePage (), newText, true);1833 // OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);1834 // return LRESULT.ZERO;1835 // }1836 //1837 // /* Do the original Undo */1838 // ignoreVerify = true;1839 // callWindowProc (OS.WM_UNDO, wParam, lParam);1840 // ignoreVerify = false;1841 // return LRESULT.ONE;1842 //}1843 1764 1844 1765 MRESULT wmControlChild (int mp1, int mp2) {
Note:
See TracChangeset
for help on using the changeset viewer.