예제 #1
0
 @Override
 LRESULT WM_INPUTLANGCHANGE(long /*int*/ wParam, long /*int*/ lParam) {
   LRESULT result = super.WM_INPUTLANGCHANGE(wParam, lParam);
   if (caret != null && caret.isFocusCaret()) {
     caret.setIMEFont();
     caret.resizeIME();
   }
   return result;
 }
예제 #2
0
 @Override
 LRESULT WM_KILLFOCUS(long /*int*/ wParam, long /*int*/ lParam) {
   if (ime != null) {
     LRESULT result = ime.WM_KILLFOCUS(wParam, lParam);
     if (result != null) return result;
   }
   Caret caret = this.caret;
   LRESULT result = super.WM_KILLFOCUS(wParam, lParam);
   if (caret != null) caret.killFocus();
   return result;
 }
예제 #3
0
 @Override
 long /*int*/ windowProc(long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
   if (msg == Display.SWT_RESTORECARET) {
     if ((state & CANVAS) != 0) {
       if (caret != null) {
         caret.killFocus();
         caret.setFocus();
         return 1;
       }
     }
   }
   return super.windowProc(hwnd, msg, wParam, lParam);
 }
예제 #4
0
 /**
  * Sets the receiver's caret.
  *
  * <p>The caret for the control is automatically hidden and shown when the control is painted or
  * resized, when focus is gained or lost and when an the control is scrolled. To avoid drawing on
  * top of the caret, the programmer must hide and show the caret when drawing in the window any
  * other time.
  *
  * @param caret the new caret for the receiver, may be null
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_INVALID_ARGUMENT - if the caret has been disposed
  *     </ul>
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void setCaret(Caret caret) {
   checkWidget();
   Caret newCaret = caret;
   Caret oldCaret = this.caret;
   this.caret = newCaret;
   if (hasFocus()) {
     if (oldCaret != null) oldCaret.killFocus();
     if (newCaret != null) {
       if (newCaret.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
       newCaret.setFocus();
     }
   }
 }
예제 #5
0
 @Override
 LRESULT WM_WINDOWPOSCHANGING(long /*int*/ wParam, long /*int*/ lParam) {
   LRESULT result = super.WM_WINDOWPOSCHANGING(wParam, lParam);
   if (result != null) return result;
   /*
    * Bug in Windows.  When a window with style WS_EX_LAYOUTRTL
    * that contains a caret is resized, Windows does not move the
    * caret in relation to the mirrored origin in the top right.
    * The fix is to hide the caret in WM_WINDOWPOSCHANGING and
    * show the caret in WM_WINDOWPOSCHANGED.
    */
   boolean isFocus = (style & SWT.RIGHT_TO_LEFT) != 0 && caret != null && caret.isFocusCaret();
   if (isFocus) caret.killFocus();
   return result;
 }
예제 #6
0
 @Override
 void releaseChildren(boolean destroy) {
   if (caret != null) {
     caret.release(false);
     caret = null;
   }
   if (ime != null) {
     ime.release(false);
     ime = null;
   }
   super.releaseChildren(destroy);
 }
예제 #7
0
  @Override
  LRESULT WM_IME_COMPOSITION(long /*int*/ wParam, long /*int*/ lParam) {
    if (ime != null) {
      LRESULT result = ime.WM_IME_COMPOSITION(wParam, lParam);
      if (result != null) return result;
    }

    /*
     * Bug in Windows.  On Korean Windows XP, the IME window
     * for the Korean Input System (MS-IME 2002) always opens
     * in the top left corner of the screen, despite the fact
     * that ImmSetCompositionWindow() was called to position
     * the IME when focus is gained.  The fix is to position
     * the IME on every WM_IME_COMPOSITION message.
     */
    if (!OS.IsWinCE && OS.WIN32_VERSION == OS.VERSION(5, 1)) {
      if (OS.IsDBLocale) {
        short langID = OS.GetSystemDefaultUILanguage();
        short primaryLang = OS.PRIMARYLANGID(langID);
        if (primaryLang == OS.LANG_KOREAN) {
          if (caret != null && caret.isFocusCaret()) {
            POINT ptCurrentPos = new POINT();
            if (OS.GetCaretPos(ptCurrentPos)) {
              COMPOSITIONFORM lpCompForm = new COMPOSITIONFORM();
              lpCompForm.dwStyle = OS.CFS_POINT;
              lpCompForm.x = ptCurrentPos.x;
              lpCompForm.y = ptCurrentPos.y;
              long /*int*/ hIMC = OS.ImmGetContext(handle);
              OS.ImmSetCompositionWindow(hIMC, lpCompForm);
              OS.ImmReleaseContext(handle, hIMC);
            }
          }
        }
      }
    }
    return super.WM_IME_COMPOSITION(wParam, lParam);
  }
예제 #8
0
 @Override
 LRESULT WM_SIZE(long /*int*/ wParam, long /*int*/ lParam) {
   LRESULT result = super.WM_SIZE(wParam, lParam);
   if (caret != null && caret.isFocusCaret()) caret.resizeIME();
   return result;
 }
예제 #9
0
 @Override
 LRESULT WM_SETFOCUS(long /*int*/ wParam, long /*int*/ lParam) {
   LRESULT result = super.WM_SETFOCUS(wParam, lParam);
   if (caret != null && caret.isFocusCaret()) caret.setFocus();
   return result;
 }
예제 #10
0
 @Override
 public void setFont(Font font) {
   checkWidget();
   if (caret != null) caret.setFont(font);
   super.setFont(font);
 }
예제 #11
0
 void scrollInPixels(int destX, int destY, int x, int y, int width, int height, boolean all) {
   forceResize();
   boolean isFocus = caret != null && caret.isFocusCaret();
   if (isFocus) caret.killFocus();
   RECT sourceRect = new RECT();
   OS.SetRect(sourceRect, x, y, x + width, y + height);
   RECT clientRect = new RECT();
   OS.GetClientRect(handle, clientRect);
   if (OS.IntersectRect(clientRect, sourceRect, clientRect)) {
     if (OS.IsWinCE) {
       OS.UpdateWindow(handle);
     } else {
       int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN;
       OS.RedrawWindow(handle, null, 0, flags);
     }
   }
   int deltaX = destX - x, deltaY = destY - y;
   if (findImageControl() != null) {
     if (OS.IsWinCE) {
       OS.InvalidateRect(handle, sourceRect, true);
     } else {
       int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE;
       if (all) flags |= OS.RDW_ALLCHILDREN;
       OS.RedrawWindow(handle, sourceRect, 0, flags);
     }
     OS.OffsetRect(sourceRect, deltaX, deltaY);
     if (OS.IsWinCE) {
       OS.InvalidateRect(handle, sourceRect, true);
     } else {
       int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE;
       if (all) flags |= OS.RDW_ALLCHILDREN;
       OS.RedrawWindow(handle, sourceRect, 0, flags);
     }
   } else {
     int flags = OS.SW_INVALIDATE | OS.SW_ERASE;
     /*
      * Feature in Windows.  If any child in the widget tree partially
      * intersects the scrolling rectangle, Windows moves the child
      * and copies the bits that intersect the scrolling rectangle but
      * does not redraw the child.
      *
      * Feature in Windows.  When any child in the widget tree does not
      * intersect the scrolling rectangle but the parent does intersect,
      * Windows does not move the child.  This is the documented (but
      * strange) Windows behavior.
      *
      * The fix is to not use SW_SCROLLCHILDREN and move the children
      * explicitly after scrolling.
      */
     //		if (all) flags |= OS.SW_SCROLLCHILDREN;
     OS.ScrollWindowEx(handle, deltaX, deltaY, sourceRect, null, 0, null, flags);
   }
   if (all) {
     Control[] children = _getChildren();
     for (int i = 0; i < children.length; i++) {
       Control child = children[i];
       Rectangle rect = child.getBoundsInPixels();
       if (Math.min(x + width, rect.x + rect.width) >= Math.max(x, rect.x)
           && Math.min(y + height, rect.y + rect.height) >= Math.max(y, rect.y)) {
         child.setLocationInPixels(rect.x + deltaX, rect.y + deltaY);
       }
     }
   }
   if (isFocus) caret.setFocus();
 }
예제 #12
0
 @Override
 void reskinChildren(int flags) {
   if (caret != null) caret.reskin(flags);
   if (ime != null) ime.reskin(flags);
   super.reskinChildren(flags);
 }