public void show(int effect, int x, int y) {
   effect = checkEffect(effect);
   int handle = table.handle;
   Point coordinates = new Point(x, y);
   coordinates = table.toControl(coordinates);
   LVHITTESTINFO pinfo = new LVHITTESTINFO();
   pinfo.x = coordinates.x;
   pinfo.y = coordinates.y;
   OS.SendMessage(handle, OS.LVM_HITTEST, 0, pinfo);
   if ((effect & DND.FEEDBACK_SCROLL) == 0) {
     scrollBeginTime = 0;
     scrollIndex = -1;
   } else {
     if (pinfo.iItem != -1 && scrollIndex == pinfo.iItem && scrollBeginTime != 0) {
       if (System.currentTimeMillis() >= scrollBeginTime) {
         int top = Math.max(0, OS.SendMessage(handle, OS.LVM_GETTOPINDEX, 0, 0));
         int count = OS.SendMessage(handle, OS.LVM_GETITEMCOUNT, 0, 0);
         int index =
             (scrollIndex - 1 < top)
                 ? Math.max(0, scrollIndex - 1)
                 : Math.min(count - 1, scrollIndex + 1);
         OS.SendMessage(handle, OS.LVM_ENSUREVISIBLE, index, 0);
         scrollBeginTime = 0;
         scrollIndex = -1;
       }
     } else {
       scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
       scrollIndex = pinfo.iItem;
     }
   }
   LVITEM lvItem = new LVITEM();
   lvItem.stateMask = OS.LVIS_DROPHILITED;
   OS.SendMessage(handle, OS.LVM_SETITEMSTATE, -1, lvItem);
   if (pinfo.iItem != -1 && (effect & DND.FEEDBACK_SELECT) != 0) {
     lvItem.state = OS.LVIS_DROPHILITED;
     OS.SendMessage(handle, OS.LVM_SETITEMSTATE, pinfo.iItem, lvItem);
   }
   // Insert mark only supported on Windows XP with manifest
   //	if (OS.COMCTL32_MAJOR >= 6) {
   //		if ((effect & DND.FEEDBACK_INSERT_BEFORE) != 0 || (effect & DND.FEEDBACK_INSERT_AFTER) != 0)
   // {
   //			LVINSERTMARK lvinsertmark = new LVINSERTMARK();
   //			lvinsertmark.cbSize = LVINSERTMARK.sizeof;
   //			lvinsertmark.dwFlags = (effect & DND.FEEDBACK_INSERT_BEFORE) != 0 ? 0 : OS.LVIM_AFTER;
   //			lvinsertmark.iItem = pinfo.iItem == -1 ? 0 : pinfo.iItem;
   //			int hItem = pinfo.iItem;
   //			OS.SendMessage (handle, OS.LVM_SETINSERTMARK, 0, lvinsertmark);
   //		} else {
   //			OS.SendMessage (handle, OS.LVM_SETINSERTMARK, 0, 0);
   //		}
   //	}
   return;
 }
Exemplo n.º 2
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();
 }