Changeset 234 for trunk/src/plugins


Ignore:
Timestamp:
Nov 27, 2009, 1:11:27 PM (16 years ago)
Author:
lpino
Message:
  • Cleaning and fixing
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets/Text.java

    r231 r234  
    327327        if (hHint != SWT.DEFAULT) height = hHint;
    328328
    329         if ((style & SWT.V_SCROLL) != 0) {
     329        if ((style & SWT.V_SCROLL) != 0) {
    330330                width += OS.WinQuerySysValue (OS.HWND_DESKTOP, OS.SV_CXVSCROLL);
    331331        }
    332         if ((style & SWT.H_SCROLL) != 0) {
     332        if ((style & SWT.H_SCROLL) != 0) {
    333333                height += OS.WinQuerySysValue (OS.HWND_DESKTOP, OS.SV_CYHSCROLL);
    334334                if ((style & SWT.BORDER) == 0) width++;
     
    336336        if ((style & SWT.BORDER) != 0) {
    337337                int border = getBorderWidth ();
    338                 width += (border * 2) + 3;
    339                 height += (border * 2) + 1;
    340         }
    341         return new Point (width, height);
     338                width += (border * 2) + 1;
     339                height += (border * 2) + 2;
     340        }
     341        return new Point(width, height);
    342342}
    343343
     
    496496public int getCharCount () {
    497497        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        }
    499504         //@@TODO(lpino): Implement the DB support
    500505//      if (OS.IsDBLocale) length = mbcsToWcsPos (length);
    501506        return length;
    502507}
    503 //
     508
    504509String getClipboardText () {
    505510        String string = "";
    506511        int hab = parent.getDisplay ().hab;
    507512        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);
    521521        }
    522522        return string;
     
    847847 * </ul>
    848848 */
    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 //}
     849public int getTopPixel () {
     850        checkWidget ();
     851        if((style & SWT.SINGLE) != 0) return 0;
     852        return getTopIndex () * getLineHeight ();
     853}
    861854
    862855/*
     
    12721265        if ((style & SWT.MULTI) != 0){
    12731266            OS.WinSendMsg (handle, OS.MLM_SETSEL, start, start);
    1274 //            OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);
    12751267        }
    12761268        else{
    12771269            OS.WinSendMsg (handle, OS.EM_SETSEL, OS.MPFROM2SHORT((short)start,(short)start),0);
    1278 //            OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);
    12791270        }
    12801271}
     
    15161507public void showSelection () {
    15171508        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        }
    15201516}
    15211517
     
    16051601            if ((style & SWT.H_SCROLL) != 0) bits |= OS.MLS_HSCROLL;
    16061602            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;
    16081604        }
    16091605        else{
     
    16291625}
    16301626
    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 */
    16421658MRESULT WM_CHAR (int mp1, int mp2) {
    16431659        if (ignoreCharacter) return null;
     
    16461662        return result;
    16471663}
    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
    16881665//LRESULT WM_IME_CHAR (int wParam, int lParam) {
    16891666//
     
    17491726//      return null;
    17501727//}
    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 //
    17731728//LRESULT WM_SIZE (int wParam, int lParam) {
    17741729//      LRESULT result = super.WM_SIZE (wParam, lParam);
     
    18071762//      return result;
    18081763//}
    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 //}
    18431764
    18441765MRESULT wmControlChild (int mp1, int mp2) {
Note: See TracChangeset for help on using the changeset viewer.