Changeset 226 for trunk/src


Ignore:
Timestamp:
Nov 16, 2009, 1:25:40 PM (16 years ago)
Author:
lpino
Message:
  • Work in progress. Fixed border style for MLE
File:
1 edited

Legend:

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

    r198 r226  
    297297        checkWidget ();
    298298        Point size = new Point (0, 0);
     299        int count = ((style & SWT.MULTI) != 0)?OS.WinSendMsg (handle, OS.MLM_QUERYLINECOUNT, 0, 0):1;
    299300        int hps = this.hps;
    300301        if (hps == 0) hps = OS.WinGetPS (handle);
    301 //      int newFont, oldFont = 0;
    302 //      int hDC = OS.GetDC (handle);
    303 //      newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
    304 //      if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
    305 //      TEXTMETRIC tm = new TEXTMETRIC ();
    306 //      OS.GetTextMetrics (hDC, tm);
    307302        FONTMETRICS fm = new FONTMETRICS();
    308303        OS.GpiQueryFontMetrics (hps, FONTMETRICS.sizeof, fm);
    309         int count = ((style & SWT.MULTI) != 0)?OS.WinSendMsg (handle, OS.MLM_QUERYLINECOUNT, 0, 0):1;
    310304        int height = count * fm.lEmHeight, width = 0;
    311 //      RECT rect = new RECT ();
    312 //      int flags = OS.DT_CALCRECT | OS.DT_EDITCONTROL | OS.DT_NOPREFIX;
    313 //      boolean wrap = (style & SWT.MULTI) != 0 && (style & SWT.WRAP) != 0;
    314 //      if (wrap && wHint != SWT.DEFAULT) {
    315 //              flags |= OS.DT_WORDBREAK;
    316 //              rect.right = wHint;
    317 //      }
    318 //      String text = getText ();
    319 //        PSZ buffer = new PSZ (text);
    320 //      TCHAR buffer = new TCHAR (getCodePage (), text, false);
    321 //      OS.DrawText (hDC, buffer, buffer.length (), rect, flags);
    322 //      width = rect.right - rect.left;
    323         int length = OS.WinQueryWindowTextLength (handle);
     305
     306        boolean wrap = (style & SWT.MULTI) != 0 && (style & SWT.WRAP) != 0;
     307
     308/*      int[] pts = new int[8];
     309        OS.WinSendMsg (handle, OS.MLM_QUERYFORMATRECT, pts, OS.MLFFMTRECT_MATCHWINDOW);
     310 */       
     311        int length = OS.WinQueryWindowTextLength (handle);
     312        System.out.println("Text::computeSize -> text = " + getText());
     313        System.out.println("Text::computeSize -> lineas = " + count);
     314        System.out.println("Text::computeSize -> handle = " + Integer.toHex);
    324315        byte[] text = null;
    325316        if (length != 0) {
     
    353344        }
    354345        width += size.x;
     346        System.out.println("Text::computeSize -> ancho = " + width);
    355347        if (this.hps == 0) OS.WinReleasePS (hps);
    356348//      if (wrap && hHint == SWT.DEFAULT) {
     
    474466            return OS.WinSendMsg(handle, OS.MLM_CHARFROMLINE, -1, 0);
    475467        else
    476             //@@TODO(lpino): Check if this it's OK for SINGLE style
    477468            return 1;
    478469}
     
    491482 * </ul>
    492483 */
    493 //public Point getCaretLocation () {
    494 //      checkWidget ();
    495 //      /*
    496 //      * Bug in Windows.  For some reason, Windows is unable
    497 //      * to return the pixel coordinates of the last character
    498 //      * in the widget.  The fix is to temporarily insert a
    499 //      * space, query the coordinates and delete the space.
    500 //      * The selection is always an i-beam in this case because
    501 //      * this is the only time the start of the selection can
    502 //      * be equal to the last character position in the widget.
    503 //      * If EM_POSFROMCHAR fails for any other reason, return
    504 //      * pixel coordinates (0,0).
    505 //      */
    506 //      int start = 0;
    507 //      OS.SendMessage (handle, OS.EM_GETSEL, start, (int []) null);
    508 //      int pos = OS.SendMessage (handle, OS.EM_POSFROMCHAR, start [0], 0);
    509 //      if (pos == -1) {
    510 //              pos = 0;
    511 //              if (start [0] >= OS.GetWindowTextLength (handle)) {
    512 //                      int cp = getCodePage ();
    513 //                      OS.SendMessage (handle, OS.EM_REPLACESEL, 0, new TCHAR (cp, " ", true));
    514 //                      pos = OS.SendMessage (handle, OS.EM_POSFROMCHAR, start [0], 0);
    515 //                      OS.SendMessage (handle, OS.EM_SETSEL, start [0], start [0] + 1);
    516 //                      OS.SendMessage (handle, OS.EM_REPLACESEL, 0, new TCHAR (cp, "", true));
    517 //              }
    518 //      }
    519 //      return new Point ((short) (pos & 0xFFFF), (short) (pos >> 16));
    520 //}
     484public Point getCaretLocation () {
     485        checkWidget ();
     486/*      int pos = 0;
     487        if ((style & SWT.MULTI) != 0){
     488                pos = OS.WinSendMsg (handle, OS.MLM_QUERYSEL, OS.MLFQS_MINSEL, 0);
     489        } else {
     490                pos = OS.WinSendMsg (handle, OS.EM_QUERYSEL, 0, 0);
     491        }
     492        return new Point ((short) (pos & 0xFFFF), (short) (pos >> 16));
     493        */
     494        return null;
     495}
    521496
    522497/**
     
    551526            return OS.SHORT1FROMMP(pos);
    552527        }
    553 //      int [] start = new int [1], end = new int [1];
    554 //      OS.SendMessage (handle, OS.EM_GETSEL, start, end);
    555 //      int startLine = OS.SendMessage (handle, OS.EM_LINEFROMCHAR, start [0], 0);
    556 //      int caretPos = OS.SendMessage (handle, OS.EM_LINEINDEX, -1, 0);
    557 //      int caretLine = OS.SendMessage (handle, OS.EM_LINEFROMCHAR, caretPos, 0);
    558 //      int caret = end [0];
    559 //      if (caretLine == startLine) caret = start [0]; 
    560 //      return caret;
    561528}
    562529
     
    743710public Point getSelection () {
    744711        checkWidget ();
    745         int pos = 0;
    746         pos = OS.WinSendMsg (handle, OS.EM_QUERYSEL, 0, 0);
     712        int pos = 0;
     713        if ((style & SWT.MULTI) != 0){
     714                pos = OS.WinSendMsg (handle, OS.MLM_QUERYSEL, (short)OS.MLFQS_MINMAXSEL , 0);
     715        }else{
     716                pos = OS.WinSendMsg (handle, OS.EM_QUERYSEL, 0, 0);
     717        }
    747718        //@@TODO(lpino): Do we need to consider DB?
    748719//      if (OS.IsDBLocale) {
     
    12981269 * </ul>
    12991270 */
    1300 //public void setEchoChar (char echo) {
    1301 //      checkWidget ();
     1271public void setEchoChar (char echo) {
     1272        checkWidget ();
    13021273//      if (echo != 0) {
    13031274//              if ((echo = (char) wcsToMbcs (echo, getCodePage ())) == 0) echo = '*';
     
    13101281//      */
    13111282//      OS.InvalidateRect (handle, null, true);
    1312 //}
     1283}
    13131284
    13141285/**
     
    14101381}
    14111382
    1412 //public void setRedraw (boolean redraw) {
    1413 //      checkWidget ();
    1414 //      super.setRedraw (redraw);
     1383public void setRedraw (boolean redraw) {
     1384        checkWidget ();
     1385        super.setRedraw (redraw);
    14151386//      /*
    14161387//      * Feature in Windows.  When WM_SETREDRAW is used to turn
     
    14291400//      if (oldStart == start [0] && oldEnd == end [0]) return;
    14301401//      OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);               
    1431 //}
     1402}
    14321403
    14331404/**
     
    15661537 * </ul>
    15671538 */
    1568 //public void setTopIndex (int index) {
    1569 //      checkWidget ();
    1570 //      int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
    1571 //      if ((bits & OS.ES_MULTILINE) == 0) return;
    1572 //      int count = OS.SendMessage (handle, OS.EM_GETLINECOUNT, 0, 0);
    1573 //      index = Math.min (Math.max (index, 0), count - 1);
    1574 //      int topIndex = OS.SendMessage (handle, OS.EM_GETFIRSTVISIBLELINE, 0, 0);
    1575 //      OS.SendMessage (handle, OS.EM_LINESCROLL, 0, index - topIndex);
    1576 //}
     1539public void setTopIndex (int index) {
     1540        checkWidget ();
     1541        if ((style & SWT.MULTI) == 0) return;
     1542/*      int bits = OS.WinQueryWindowULong (handle, OS.QWL_STYLE);
     1543        if ((bits & OS.ES_MULTILINE) == 0) return; */
     1544        int count = OS.WinSendMsg (handle, OS.MLM_QUERYLINECOUNT, 0, 0);
     1545        index = Math.min (Math.max (index, 0), count - 1);
     1546        /* In PM this is the actual char position */
     1547        int topIndex = OS.WinSendMsg (handle, OS.MLM_QUERYFIRSTCHAR, 0, 0);
     1548        /* This will cause a scroll to the selected position */
     1549        OS.WinSendMsg (handle, OS.MLM_SETSEL, topIndex, topIndex);
     1550}
    15771551
    15781552/*
     
    16861660        int bits = super.widgetStyle ();
    16871661        if ((style & SWT.MULTI) != 0){
    1688             if ((style & SWT.READ_ONLY) != 0) bits |= OS.MLS_READONLY;
    1689     //  if ((style & SWT.SINGLE) != 0) return bits | OS.MLS_HSCROLL;
    1690     //  bits |= OS.MLS_HSCROLL;
     1662            if ((style & SWT.READ_ONLY) != 0) bits |= OS.MLS_READONLY; 
    16911663            if ((style & SWT.WRAP) != 0) bits |= OS.MLS_WORDWRAP;
    16921664            if ((style & SWT.V_SCROLL) != 0) bits |= OS.MLS_VSCROLL;
    16931665            if ((style & SWT.H_SCROLL) != 0) bits |= OS.MLS_HSCROLL;
    1694             return bits | OS.MLS_BORDER;
     1666            if ((style & SWT.BORDER) != 0) bits |= OS.MLS_BORDER;
     1667            return bits | OS.WS_VISIBLE;
    16951668        }
    16961669        else{
Note: See TracChangeset for help on using the changeset viewer.