org.eclipse.swt.win32.win32.x86_3.7.2.v3740f

iew == null)
          {
            treeView = new NMTREEVIEW();
            OS.MoveMemory(treeView, lParam, NMTREEVIEW.sizeof);
          }
          TVITEM tvItem = itemOld;
          mask = 8;
          stateMask = 2;
          state = 2;
          OS.SendMessage(handle, OS.TVM_SETITEM, 0, tvItem);
        }
        if ((!newSelected) && (ignoreSelect))
        {
          if (treeView == null)
          {
            treeView = new NMTREEVIEW();
            OS.MoveMemory(treeView, lParam, NMTREEVIEW.sizeof);
          }
          TVITEM tvItem = itemNew;
          mask = 8;
          stateMask = 2;
          state = 0;
          OS.SendMessage(handle, OS.TVM_SETITEM, 0, tvItem);
        }
      }
      if (!ignoreSelect)
      {
        if (treeView == null)
        {
          treeView = new NMTREEVIEW();
          OS.MoveMemory(treeView, lParam, NMTREEVIEW.sizeof);
        }
        TVITEM tvItem = itemNew;
        hAnchor = hItem;
        Event event = new Event();
        item = _getItem(hItem, lParam);
        sendSelectionEvent(13, event, false);
      }
      updateScrollBar();
      break;
    case -454: 
    case -405: 
      if (itemToolTipHandle != 0) {
        OS.ShowWindow(itemToolTipHandle, 0);
      }
      boolean runExpanded = false;
      if ((style & 0x10000000) != 0) {
        style &= 0xDFFFFFFF;
      }
      if ((hooks(40)) || (hooks(42))) {
        style &= 0xDFFFFFFF;
      }
      if ((findImageControl() != null) && (getDrawing()) && (OS.IsWindowVisible(handle))) {
        OS.DefWindowProc(handle, 11, 0, 0);
      }
      if (hInsert != 0) {
        OS.SendMessage(handle, 4378, 0, 0);
      }
      if (!ignoreExpand)
      {
        NMTREEVIEW treeView = new NMTREEVIEW();
        OS.MoveMemory(treeView, lParam, NMTREEVIEW.sizeof);
        TVITEM tvItem = itemNew;
        if (items != null)
        {
          TreeItem item = _getItem(hItem, lParam);
          if (item != null)
          {
            Event event = new Event();
            item = item;
            switch (action)
            {
            case 2: 
              if ((state & 0x20) == 0)
              {
                sendEvent(17, event);
                if (isDisposed()) {
                  return LRESULT.ZERO;
                }
              }
              break;
            case 1: 
              sendEvent(18, event);
              if (isDisposed()) {
                return LRESULT.ZERO;
              }
              break;
            }
            int hFirstItem = OS.SendMessage(handle, 4362, 4, hItem);
            runExpanded = hFirstItem == 0;
          }
        }
      }
      else
      {
        if (!runExpanded) {
          break;
        }
      }
      break;
    case -455: 
    case -406: 
      if ((style & 0x10000000) != 0) {
        style |= 0x20000000;
      }
      if ((hooks(40)) || (hooks(42))) {
        style |= 0x20000000;
      }
      if ((findImageControl() != null) && (getDrawing()))
      {
        OS.DefWindowProc(handle, 11, 1, 0);
        OS.InvalidateRect(handle, null, true);
      }
      if (hInsert != 0) {
        OS.SendMessage(handle, 4378, insertAfter ? 1 : 0, hInsert);
      }
      if ((!OS.IsWinCE) && (OS.COMCTL32_MAJOR >= 6) && 
        (imageList != null))
      {
        NMTREEVIEW treeView = new NMTREEVIEW();
        OS.MoveMemory(treeView, lParam, NMTREEVIEW.sizeof);
        TVITEM tvItem = itemNew;
        if (hItem != 0)
        {
          int bits = OS.GetWindowLong(handle, -16);
          if ((bits & 0x1000) == 0)
          {
            RECT rect = new RECT();
            if (OS.TreeView_GetItemRect(handle, hItem, rect, false)) {
              OS.InvalidateRect(handle, rect, true);
            }
          }
        }
      }
      updateScrollBar();
      break;
    case -456: 
    case -407: 
      if (OS.GetKeyState(1) >= 0) {
        break;
      }
    case -457: 
    case -408: 
      dragStarted = true;
      NMTREEVIEW treeView = new NMTREEVIEW();
      OS.MoveMemory(treeView, lParam, NMTREEVIEW.sizeof);
      TVITEM tvItem = itemNew;
      if ((hItem != 0) && ((state & 0x2) == 0))
      {
        hSelect = hItem;
        ignoreSelect = (ignoreDeselect = 1);
        OS.SendMessage(handle, 4363, 9, hItem);
        ignoreSelect = (ignoreDeselect = 0);
        hSelect = 0;
      }
      break;
    case -16: 
      if (OS.IsPPC)
      {
        boolean hasMenu = (menu != null) && (!menu.isDisposed());
        if ((!hasMenu) && (!hooks(35))) {
          return LRESULT.ONE;
        }
      }
      break;
    case 1000: 
      if (OS.IsPPC)
      {
        boolean hasMenu = (menu != null) && (!menu.isDisposed());
        if ((hasMenu) || (hooks(35)))
        {
          NMRGINFO nmrg = new NMRGINFO();
          OS.MoveMemory(nmrg, lParam, NMRGINFO.sizeof);
          showMenu(x, y);
          gestureCompleted = true;
          return LRESULT.ONE;
        }
      }
      break;
    }
    return super.wmNotifyChild(hdr, wParam, lParam);
  }
  
  LRESULT wmNotifyHeader(NMHDR hdr, int wParam, int lParam)
  {
    switch (code)
    {
    case -326: 
    case -325: 
    case -306: 
    case -305: 
      NMHEADER phdn = new NMHEADER();
      OS.MoveMemory(phdn, lParam, NMHEADER.sizeof);
      TreeColumn column = columns[iItem];
      if ((column != null) && (!column.getResizable())) {
        return LRESULT.ONE;
      }
      ignoreColumnMove = true;
      switch (code)
      {
      case -325: 
      case -305: 
        if (column != null) {
          column.pack();
        }
        break;
      }
      break;
    case -16: 
      if (!ignoreColumnMove)
      {
        for (int i = 0; i < columnCount; i++)
        {
          TreeColumn column = columns[i];
          column.updateToolTip(i);
        }
        updateImageList();
      }
      ignoreColumnMove = false;
      break;
    case -310: 
      if (ignoreColumnMove) {
        return LRESULT.ONE;
      }
      NMHEADER phdn = new NMHEADER();
      OS.MoveMemory(phdn, lParam, NMHEADER.sizeof);
      if (iItem != -1)
      {
        TreeColumn column = columns[iItem];
        if ((column != null) && (!column.getMoveable()))
        {
          ignoreColumnMove = true;
          return LRESULT.ONE;
        }
      }
      break;
    case -311: 
      NMHEADER phdn = new NMHEADER();
      OS.MoveMemory(phdn, lParam, NMHEADER.sizeof);
      if ((iItem != -1) && (pitem != 0))
      {
        HDITEM pitem = new HDITEM();
        OS.MoveMemory(pitem, pitem, HDITEM.sizeof);
        if (((mask & 0x80) != 0) && (iOrder != -1))
        {
          int[] order = new int[columnCount];
          OS.SendMessage(hwndHeader, 4625, columnCount, order);
          int index = 0;
          while (index < order.length)
          {
            if (order[index] == iItem) {
              break;
            }
            index++;
          }
          if (index == order.length) {
            index = 0;
          }
          if (index != iOrder)
          {
            int start = Math.min(index, iOrder);
            int end = Math.max(index, iOrder);
            RECT rect = new RECT();RECT headerRect = new RECT();
            OS.GetClientRect(handle, rect);
            OS.SendMessage(hwndHeader, 4615, order[start], headerRect);
            left = Math.max(left, left);
            OS.SendMessage(hwndHeader, 4615, order[end], headerRect);
            right = Math.min(right, right);
            OS.InvalidateRect(handle, rect, true);
            ignoreColumnMove = false;
            for (int i = start; i <= end; i++)
            {
              TreeColumn column = columns[order[i]];
              if (!column.isDisposed()) {
                column.postEvent(10);
              }
            }
          }
        }
      }
      break;
    case -320: 
    case -300: 
      NMHEADER phdn = new NMHEADER();
      OS.MoveMemory(phdn, lParam, NMHEADER.sizeof);
      if (pitem != 0)
      {
        HDITEM newItem = new HDITEM();
        OS.MoveMemory(newItem, pitem, HDITEM.sizeof);
        if ((mask & 0x1) != 0)
        {
          RECT rect = new RECT();
          OS.GetClientRect(handle, rect);
          HDITEM oldItem = new HDITEM();
          mask = 1;
          OS.SendMessage(hwndHeader, OS.HDM_GETITEM, iItem, oldItem);
          int deltaX = cxy - cxy;
          RECT headerRect = new RECT();
          OS.SendMessage(hwndHeader, 4615, iItem, headerRect);
          int gridWidth = linesVisible ? 1 : 0;
          left = (right - gridWidth);
          int newX = left + deltaX;
          right = Math.max(right, left + Math.abs(deltaX));
          if ((explorerTheme) || (findImageControl() != null) || (hooks(41)) || (hooks(40)) || (hooks(42)))
          {
            left -= OS.GetSystemMetrics(83);
            OS.InvalidateRect(handle, rect, true);
            OS.OffsetRect(rect, deltaX, 0);
            OS.InvalidateRect(handle, rect, true);
          }
          else
          {
            int flags = 6;
            OS.ScrollWindowEx(handle, deltaX, 0, rect, null, 0, null, flags);
          }
          if (OS.SendMessage(hwndHeader, 4623, iItem, 0) != 0)
          {
            left = left;
            right = newX;
            OS.InvalidateRect(handle, rect, true);
          }
          setScrollWidth();
        }
      }
      break;
    case -321: 
    case -301: 
      NMHEADER phdn = new NMHEADER();
      OS.MoveMemory(phdn, lParam, NMHEADER.sizeof);
      if (pitem != 0)
      {
        HDITEM pitem = new HDITEM();
        OS.MoveMemory(pitem, pitem, HDITEM.sizeof);
        if ((mask & 0x1) != 0)
        {
          if (ignoreColumnMove) {
            if ((!OS.IsWinCE) && (OS.WIN32_VERSION >= OS.VERSION(6, 0)))
            {
              int flags = 384;
              OS.RedrawWindow(handle, null, 0, flags);
            }
            else if ((style & 0x20000000) == 0)
            {
              int oldStyle = style;
              style |= 0x20000000;
              OS.UpdateWindow(handle);
              style = oldStyle;
            }
          }
          TreeColumn column = columns[iItem];
          if (column != null)
          {
            column.updateToolTip(iItem);
            column.sendEvent(11);
            if (isDisposed()) {
              return LRESULT.ZERO;
            }
            TreeColumn[] newColumns = new TreeColumn[columnCount];
            System.arraycopy(columns, 0, newColumns, 0, columnCount);
            int[] order = new int[columnCount];
            OS.SendMessage(hwndHeader, 4625, columnCount, order);
            boolean moved = false;
            for (int i = 0; i < columnCount; i++)
            {
              TreeColumn nextColumn = newColumns[order[i]];
              if ((moved) && (!nextColumn.isDisposed()))
              {
                nextColumn.updateToolTip(order[i]);
                nextColumn.sendEvent(10);
              }
              if (nextColumn == column) {
                moved = true;
              }
            }
          }
        }
        setScrollWidth();
      }
      break;
    case -322: 
    case -302: 
      NMHEADER phdn = new NMHEADER();
      OS.MoveMemory(phdn, lParam, NMHEADER.sizeof);
      TreeColumn column = columns[iItem];
      if (column != null) {
        column.sendSelectionEvent(13);
      }
      break;
    case -323: 
    case -303: 
      NMHEADER phdn = new NMHEADER();
      OS.MoveMemory(phdn, lParam, NMHEADER.sizeof);
      TreeColumn column = columns[iItem];
      if (column != null) {
        column.sendSelectionEvent(14);
      }
      break;
    }
    return null;
  }
  
  LRESULT wmNotifyToolTip(NMHDR hdr, int wParam, int lParam)
  {
    if (OS.IsWinCE) {
      return null;
    }
    switch (code)
    {
    case -12: 
      NMTTCUSTOMDRAW nmcd = new NMTTCUSTOMDRAW();
      OS.MoveMemory(nmcd, lParam, NMTTCUSTOMDRAW.sizeof);
      return wmNotifyToolTip(nmcd, lParam);
    case -521: 
      LRESULT result = super.wmNotify(hdr, wParam, lParam);
      if (result != null) {
        return result;
      }
      int pos = OS.GetMessagePos();
      POINT pt = new POINT();
      OS.POINTSTOPOINT(pt, pos);
      OS.ScreenToClient(handle, pt);
      int[] index = new int[1];
      TreeItem[] item = new TreeItem[1];
      RECT[] cellRect = new RECT[1];RECT[] itemRect = new RECT[1];
      if (findCell(x, y, item, index, cellRect, itemRect))
      {
        RECT toolRect = toolTipRect(itemRect[0]);
        OS.MapWindowPoints(handle, 0, toolRect, 2);
        int width = right - left;
        int height = bottom - top;
        int flags = 21;
        if (isCustomToolTip()) {
          flags &= 0xFFFFFFFE;
        }
        SetWindowPos(itemToolTipHandle, 0, left, top, width, height, flags);
        return LRESULT.ONE;
      }
      return result;
    }
    return null;
  }
  
  LRESULT wmNotifyToolTip(NMTTCUSTOMDRAW nmcd, int lParam)
  {
    if (OS.IsWinCE) {
      return null;
    }
    switch (dwDrawStage)
    {
    case 1: 
      if (isCustomToolTip())
      {
        if ((!OS.IsWinCE) && (OS.WIN32_VERSION < OS.VERSION(6, 0))) {
          OS.SetTextColor(hdc, OS.GetSysColor(OS.COLOR_INFOBK));
        }
        return new LRESULT(18);
      }
      break;
    case 2: 
      if ((!OS.IsWinCE) && (OS.WIN32_VERSION < OS.VERSION(6, 0))) {
        OS.SetTextColor(hdc, OS.GetSysColor(OS.COLOR_INFOTEXT));
      }
      if (OS.SendMessage(itemToolTipHandle, OS.TTM_GETCURRENTTOOL, 0, 0) != 0)
      {
        TOOLINFO lpti = new TOOLINFO();
        cbSize = TOOLINFO.sizeof;
        if (OS.SendMessage(itemToolTipHandle, OS.TTM_GETCURRENTTOOL, 0, lpti) != 0)
        {
          int[] index = new int[1];
          TreeItem[] item = new TreeItem[1];
          RECT[] cellRect = new RECT[1];RECT[] itemRect = new RECT[1];
          int pos = OS.GetMessagePos();
          POINT pt = new POINT();
          OS.POINTSTOPOINT(pt, pos);
          OS.ScreenToClient(handle, pt);
          if (findCell(x, y, item, index, cellRect, itemRect))
          {
            int hDC = OS.GetDC(handle);
            int hFont = item[0].fontHandle(index[0]);
            if (hFont == -1) {
              hFont = OS.SendMessage(handle, 49, 0, 0);
            }
            int oldFont = OS.SelectObject(hDC, hFont);
            boolean drawForeground = true;
            cellRect[0] = item[0].getBounds(index[0], true, true, false, false, false, hDC);
            if (hooks(40))
            {
              Event event = sendEraseItemEvent(item[0], nmcd, index[0], cellRect[0]);
              if ((isDisposed()) || (item[0].isDisposed())) {
                break;
              }
              if (doit) {
                drawForeground = (detail & 0x10) != 0;
              } else {
                drawForeground = false;
              }
            }
            if (drawForeground)
            {
              int nSavedDC = OS.SaveDC(hdc);
              int gridWidth = getLinesVisible() ? 1 : 0;
              RECT insetRect = toolTipInset(cellRect[0]);
              OS.SetWindowOrgEx(hdc, left, top, null);
              GCData data = new GCData();
              device = display;
              foreground = OS.GetTextColor(hdc);
              background = OS.GetBkColor(hdc);
              font = Font.win32_new(display, hFont);
              GC gc = GC.win32_new(hdc, data);
              int x = 0left + 3;
              if (index[0] != 0) {
                x -= gridWidth;
              }
              Image image = item[0].getImage(index[0]);
              if ((image != null) || (index[0] == 0))
              {
                Point size = getImageSize();
                RECT imageRect = item[0].getBounds(index[0], false, true, false, false, false, hDC);
                if (imageList == null) {
                  x = (right - left);
                }
                if (image != null)
                {
                  Rectangle rect = image.getBounds();
                  gc.drawImage(image, x, y, width, height, x, top, x, y);
                  x += 3 + (index[0] == 0 ? 1 : 0);
                }
                x += x;
              }
              else
              {
                x += 3;
              }
              String string = item[0].getText(index[0]);
              if (string != null)
              {
                int flags = 2084;
                TreeColumn column = columns != null ? columns[index[0]] : null;
                if (column != null)
                {
                  if ((style & 0x1000000) != 0) {
                    flags |= 0x1;
                  }
                  if ((style & 0x20000) != 0) {
                    flags |= 0x2;
                  }
                }
                TCHAR buffer = new TCHAR(getCodePage(), string, false);
                RECT textRect = new RECT();
                OS.SetRect(textRect, x, 0top, 0right, 0bottom);
                OS.DrawText(hdc, buffer, buffer.length(), textRect, flags);
              }
              gc.dispose();
              OS.RestoreDC(hdc, nSavedDC);
            }
            if (hooks(42))
            {
              itemRect[0] = item[0].getBounds(index[0], true, true, false, false, false, hDC);
              sendPaintItemEvent(item[0], nmcd, index[0], itemRect[0]);
            }
            OS.SelectObject(hDC, oldFont);
            OS.ReleaseDC(handle, hDC);
          }
        }
      }
      break;
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.swt.widgets.Tree
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.swt.widgets;

import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.win32.HDITEM;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.internal.win32.RECT;
import org.eclipse.swt.internal.win32.TCHAR;
import org.eclipse.swt.internal.win32.TOOLINFO;
import org.eclipse.swt.internal.win32.TVITEM;

public class TreeColumn
  extends Item
{
  Tree parent;
  boolean resizable;
  boolean moveable;
  String toolTipText;
  int id;
  
  public TreeColumn(Tree parent, int style)
  {
    super(parent, checkStyle(style));
    resizable = true;
    this.parent = parent;
    parent.createItem(this, parent.getColumnCount());
  }
  
  public TreeColumn(Tree parent, int style, int index)
  {
    super(parent, checkStyle(style));
    resizable = true;
    this.parent = parent;
    parent.createItem(this, index);
  }
  
  public void addControlListener(ControlListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(11, typedListener);
    addListener(10, typedListener);
  }
  
  public void addSelectionListener(SelectionListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(13, typedListener);
    addListener(14, typedListener);
  }
  
  static int checkStyle(int style)
  {
    return checkBits(style, 16384, 16777216, 131072, 0, 0, 0);
  }
  
  protected void checkSubclass()
  {
    if (!isValidSubclass()) {
      error(43);
    }
  }
  
  void destroyWidget()
  {
    parent.destroyItem(this);
    releaseHandle();
  }
  
  public int getAlignment()
  {
    checkWidget();
    if ((style & 0x4000) != 0) {
      return 16384;
    }
    if ((style & 0x1000000) != 0) {
      return 16777216;
    }
    if ((style & 0x20000) != 0) {
      return 131072;
    }
    return 16384;
  }
  
  public boolean getMoveable()
  {
    checkWidget();
    return moveable;
  }
  
  String getNameText()
  {
    return getText();
  }
  
  public Tree getParent()
  {
    checkWidget();
    return parent;
  }
  
  public boolean getResizable()
  {
    checkWidget();
    return resizable;
  }
  
  public String getToolTipText()
  {
    checkWidget();
    return toolTipText;
  }
  
  public int getWidth()
  {
    checkWidget();
    int index = parent.indexOf(this);
    if (index == -1) {
      return 0;
    }
    int hwndHeader = parent.hwndHeader;
    if (hwndHeader == 0) {
      return 0;
    }
    HDITEM hdItem = new HDITEM();
    mask = 1;
    OS.SendMessage(hwndHeader, OS.HDM_GETITEM, index, hdItem);
    return cxy;
  }
  
  public void pack()
  {
    checkWidget();
    int index = parent.indexOf(this);
    if (index == -1) {
      return;
    }
    int columnWidth = 0;
    int hwnd = parent.handle;int hwndHeader = parent.hwndHeader;
    RECT headerRect = new RECT();
    OS.SendMessage(hwndHeader, 4615, index, headerRect);
    int hDC = OS.GetDC(hwnd);
    int oldFont = 0;int newFont = OS.SendMessage(hwnd, 49, 0, 0);
    if (newFont != 0) {
      oldFont = OS.SelectObject(hDC, newFont);
    }
    TVITEM tvItem = new TVITEM();
    mask = 28;
    hItem = OS.SendMessage(hwnd, 4362, 0, 0);
    while (hItem != 0)
    {
      OS.SendMessage(hwnd, OS.TVM_GETITEM, 0, tvItem);
      TreeItem item = lParam != -1 ? parent.items[lParam] : null;
      if (item != null)
      {
        int itemRight = 0;
        if (parent.hooks(41))
        {
          int detail = (state & 0x2) != 0 ? 2 : 0;
          Event event = parent.sendMeasureItemEvent(item, index, hDC, detail);
          if ((isDisposed()) || (parent.isDisposed())) {
            break;
          }
          itemRight = x + width;
        }
        else
        {
          int hFont = item.fontHandle(index);
          if (hFont != -1) {
            hFont = OS.SelectObject(hDC, hFont);
          }
          RECT itemRect = item.getBounds(index, true, true, false, false, false, hDC);
          if (hFont != -1) {
            OS.SelectObject(hDC, hFont);
          }
          itemRight = right;
        }
        columnWidth = Math.max(columnWidth, itemRight - left);
      }
      hItem = OS.SendMessage(hwnd, 4362, 6, hItem);
    }
    RECT rect = new RECT();
    int flags = 3072;
    TCHAR buffer = new TCHAR(parent.getCodePage(), text, false);
    OS.DrawText(hDC, buffer, buffer.length(), rect, flags);
    int headerWidth = right - left + 12;
    if ((OS.COMCTL32_MAJOR >= 6) && (OS.IsAppThemed())) {
      headerWidth += 3;
    }
    if ((image != null) || (parent.sortColumn == this))
    {
      Image headerImage = null;
      if ((parent.sortColumn == this) && (parent.sortDirection != 0))
      {
        if (OS.COMCTL32_MAJOR < 6) {
          headerImage = display.getSortImage(parent.sortDirection);
        } else {
          headerWidth += 10;
        }
      }
      else {
        headerImage = image;
      }
      if (headerImage != null)
      {
        Rectangle bounds = headerImage.getBounds();
        headerWidth += width;
      }
      int margin = 0;
      if ((hwndHeader != 0) && (OS.COMCTL32_VERSION >= OS.VERSION(5, 80))) {
        margin = OS.SendMessage(hwndHeader, 4629, 0, 0);
      } else {
        margin = OS.GetSystemMetrics(45) * 3;
      }
      headerWidth += margin * 2;
    }
    if (newFont != 0) {
      OS.SelectObject(hDC, oldFont);
    }
    OS.ReleaseDC(hwnd, hDC);
    int gridWidth = parent.linesVisible ? 1 : 0;
    setWidth(Math.max(headerWidth, columnWidth + gridWidth));
  }
  
  void releaseHandle()
  {
    super.releaseHandle();
    parent = null;
  }
  
  void releaseParent()
  {
    super.releaseParent();
    if (parent.sortColumn == this) {
      parent.sortColumn = null;
    }
  }
  
  public void removeControlListener(ControlListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    if (eventTable == null) {
      return;
    }
    eventTable.unhook(10, listener);
    eventTable.unhook(11, listener);
  }
  
  public void removeSelectionListener(SelectionListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    if (eventTable == null) {
      return;
    }
    eventTable.unhook(13, listener);
    eventTable.unhook(14, listener);
  }
  
  public void setAlignment(int alignment)
  {
    checkWidget();
    if ((alignment & 0x1024000) == 0) {
      return;
    }
    int index = parent.indexOf(this);
    if ((index == -1) || (index == 0)) {
      return;
    }
    style &= 0xFEFDBFFF;
    style |= alignment & 0x1024000;
    int hwndHeader = parent.hwndHeader;
    if (hwndHeader == 0) {
      return;
    }
    HDITEM hdItem = new HDITEM();
    mask = 4;
    OS.SendMessage(hwndHeader, OS.HDM_GETITEM, index, hdItem);
    fmt &= 0xFFFFFFFC;
    if ((style & 0x4000) == 16384) {
      fmt |= 0x0;
    }
    if ((style & 0x1000000) == 16777216) {
      fmt |= 0x2;
    }
    if ((style & 0x20000) == 131072) {
      fmt |= 0x1;
    }
    OS.SendMessage(hwndHeader, OS.HDM_SETITEM, index, hdItem);
    if (index != 0)
    {
      int hwnd = parent.handle;
      parent.forceResize();
      RECT rect = new RECT();RECT headerRect = new RECT();
      OS.GetClientRect(hwnd, rect);
      OS.SendMessage(hwndHeader, 4615, index, headerRect);
      left = left;
      right = right;
      OS.InvalidateRect(hwnd, rect, true);
    }
  }
  
  public void setImage(Image image)
  {
    checkWidget();
    if ((image != null) && (image.isDisposed())) {
      error(5);
    }
    super.setImage(image);
    if ((parent.sortColumn != this) || (parent.sortDirection != 0)) {
      setImage(image, false, false);
    }
  }
  
  void setImage(Image image, boolean sort, boolean right)
  {
    int index = parent.indexOf(this);
    if (index == -1) {
      return;
    }
    int hwndHeader = parent.hwndHeader;
    if (hwndHeader == 0) {
      return;
    }
    HDITEM hdItem = new HDITEM();
    mask = 52;
    OS.SendMessage(hwndHeader, OS.HDM_GETITEM, index, hdItem);
    fmt &= 0xEFFF;
    if (image != null)
    {
      if (sort)
      {
        mask &= 0xFFFFFFDF;
        fmt &= 0xF7FF;
        fmt |= 0x2000;
        hbm = handle;
      }
      else
      {
        mask &= 0xFFFFFFEF;
        fmt &= 0xDFFF;
        fmt |= 0x800;
        iImage = parent.imageIndexHeader(image);
      }
      if (right) {
        fmt |= 0x1000;
      }
    }
    else
    {
      mask &= 0xFFFFFFCF;
      fmt &= 0xD7FF;
    }
    OS.SendMessage(hwndHeader, OS.HDM_SETITEM, index, hdItem);
  }
  
  public void setMoveable(boolean moveable)
  {
    checkWidget();
    this.moveable = moveable;
  }
  
  public void setResizable(boolean resizable)
  {
    checkWidget();
    this.resizable = resizable;
  }
  
  void setSortDirection(int direction)
  {
    if (OS.COMCTL32_MAJOR >= 6)
    {
      int hwndHeader = parent.hwndHeader;
      if (hwndHeader != 0)
      {
        int index = parent.indexOf(this);
        if (index == -1) {
          return;
        }
        HDITEM hdItem = new HDITEM();
        mask = 36;
        OS.SendMessage(hwndHeader, OS.HDM_GETITEM, index, hdItem);
        switch (direction)
        {
        case 128: 
          fmt &= 0xF5FF;
          fmt |= 0x400;
          if (image == null) {
            mask &= 0xFFFFFFDF;
          }
          break;
        case 1024: 
          fmt &= 0xF3FF;
          fmt |= 0x200;
          if (image == null) {
            mask &= 0xFFFFFFDF;
          }
          break;
        case 0: 
          fmt &= 0xF9FF;
          if (image != null)
          {
            fmt |= 0x800;
            iImage = parent.imageIndexHeader(image);
          }
          else
          {
            fmt &= 0xF7FF;
            mask &= 0xFFFFFFDF;
          }
          break;
        }
        OS.SendMessage(hwndHeader, OS.HDM_SETITEM, index, hdItem);
        if ((OS.COMCTL32_MAJOR >= 6) && (OS.IsAppThemed()))
        {
          int hwnd = parent.handle;
          parent.forceResize();
          RECT rect = new RECT();RECT headerRect = new RECT();
          OS.GetClientRect(hwnd, rect);
          OS.SendMessage(hwndHeader, 4615, index, headerRect);
          left = left;
          right = right;
          OS.InvalidateRect(hwnd, rect, true);
        }
      }
    }
    else
    {
      switch (direction)
      {
      case 128: 
      case 1024: 
        setImage(display.getSortImage(direction), true, true);
        break;
      case 0: 
        setImage(image, false, false);
      }
    }
  }
  
  public void setText(String string)
  {
    checkWidget();
    if (string == null) {
      error(4);
    }
    if (string.equals(text)) {
      return;
    }
    int index = parent.indexOf(this);
    if (index == -1) {
      return;
    }
    super.setText(string);
    
    boolean replace = (!OS.IsWinCE) && (OS.WIN32_VERSION <= OS.VERSION(4, 10));
    int hHeap = OS.GetProcessHeap();
    TCHAR buffer = new TCHAR(parent.getCodePage(), fixMnemonic(string, replace), true);
    int byteCount = buffer.length() * TCHAR.sizeof;
    int pszText = OS.HeapAlloc(hHeap, 8, byteCount);
    OS.MoveMemory(pszText, buffer, byteCount);
    int hwndHeader = parent.hwndHeader;
    if (hwndHeader == 0) {
      return;
    }
    HDITEM hdItem = new HDITEM();
    mask = 2;
    pszText = pszText;
    int result = OS.SendMessage(hwndHeader, OS.HDM_SETITEM, index, hdItem);
    if (pszText != 0) {
      OS.HeapFree(hHeap, 0, pszText);
    }
    if (result == 0) {
      error(13);
    }
  }
  
  public void setToolTipText(String string)
  {
    checkWidget();
    toolTipText = string;
    int hwndHeaderToolTip = parent.headerToolTipHandle;
    if (hwndHeaderToolTip == 0)
    {
      parent.createHeaderToolTips();
      parent.updateHeaderToolTips();
    }
  }
  
  public void setWidth(int width)
  {
    checkWidget();
    if (width < 0) {
      return;
    }
    int index = parent.indexOf(this);
    if (index == -1) {
      return;
    }
    int hwndHeader = parent.hwndHeader;
    if (hwndHeader == 0) {
      return;
    }
    HDITEM hdItem = new HDITEM();
    mask = 1;
    cxy = width;
    OS.SendMessage(hwndHeader, OS.HDM_SETITEM, index, hdItem);
    RECT headerRect = new RECT();
    OS.SendMessage(hwndHeader, 4615, index, headerRect);
    parent.forceResize();
    int hwnd = parent.handle;
    RECT rect = new RECT();
    OS.GetClientRect(hwnd, rect);
    left = left;
    OS.InvalidateRect(hwnd, rect, true);
    parent.setScrollWidth();
  }
  
  void updateToolTip(int index)
  {
    int hwndHeaderToolTip = parent.headerToolTipHandle;
    if (hwndHeaderToolTip != 0)
    {
      int hwndHeader = parent.hwndHeader;
      RECT rect = new RECT();
      if (OS.SendMessage(hwndHeader, 4615, index, rect) != 0)
      {
        TOOLINFO lpti = new TOOLINFO();
        cbSize = TOOLINFO.sizeof;
        hwnd = hwndHeader;
        uId = id;
        left = left;
        top = top;
        right = right;
        bottom = bottom;
        OS.SendMessage(hwndHeaderToolTip, OS.TTM_NEWTOOLRECT, 0, lpti);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.swt.widgets.TreeColumn
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.swt.widgets;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.internal.win32.RECT;
import org.eclipse.swt.internal.win32.SCROLLINFO;
import org.eclipse.swt.internal.win32.TCHAR;
import org.eclipse.swt.internal.win32.TVITEM;

public class TreeItem
  extends Item
{
  int[] cellForeground;
  int[] cellBackground;
  int foreground = -1;
  int background = -1;
  boolean cached;
  Font[] cellFont;
  Font font;
  Image[] images;
  String[] strings;
  Tree parent;
  public int handle;
  
  public TreeItem(Tree parent, int style)
  {
    this(parent, style, 0, -65534, 0);
  }
  
  public TreeItem(Tree parent, int style, int index)
  {
    this(parent, style, 0, findPrevious(parent, index), 0);
  }
  
  public TreeItem(TreeItem parentItem, int style)
  {
    this(checkNullparent, style, handle, -65534, 0);
  }
  
  public TreeItem(TreeItem parentItem, int style, int index)
  {
    this(checkNullparent, style, handle, findPrevious(parentItem, index), 0);
  }
  
  TreeItem(Tree parent, int style, int hParent, int hInsertAfter, int hItem)
  {
    super(parent, style);
    this.parent = parent;
    parent.createItem(this, hParent, hInsertAfter, hItem);
  }
  
  static TreeItem checkNull(TreeItem item)
  {
    if (item == null) {
      SWT.error(4);
    }
    return item;
  }
  
  static int findPrevious(Tree parent, int index)
  {
    if (parent == null) {
      return 0;
    }
    if (index < 0) {
      SWT.error(6);
    }
    if (index == 0) {
      return -65535;
    }
    int hwnd = handle;
    int hFirstItem = OS.SendMessage(hwnd, 4362, 0, 0);
    int hItem = parent.findItem(hFirstItem, index - 1);
    if (hItem == 0) {
      SWT.error(6);
    }
    return hItem;
  }
  
  static int findPrevious(TreeItem parentItem, int index)
  {
    if (parentItem == null) {
      return 0;
    }
    if (index < 0) {
      SWT.error(6);
    }
    if (index == 0) {
      return -65535;
    }
    Tree parent = parentItem.parent;
    int hwnd = handle;int hParent = handle;
    int hFirstItem = OS.SendMessage(hwnd, 4362, 4, hParent);
    int hItem = parent.findItem(hFirstItem, index - 1);
    if (hItem == 0) {
      SWT.error(6);
    }
    return hItem;
  }
  
  protected void checkSubclass()
  {
    if (!isValidSubclass()) {
      error(43);
    }
  }
  
  void clear()
  {
    text = "";
    image = null;
    strings = null;
    images = null;
    if ((parent.style & 0x20) != 0)
    {
      int hwnd = parent.handle;
      TVITEM tvItem = new TVITEM();
      mask = 24;
      stateMask = 61440;
      state = 4096;
      hItem = handle;
      OS.SendMessage(hwnd, OS.TVM_SETITEM, 0, tvItem);
    }
    background = (foreground = -1);
    font = null;
    cellBackground = (cellForeground = null);
    cellFont = null;
    if ((parent.style & 0x10000000) != 0) {
      cached = false;
    }
  }
  
  public void clear(int index, boolean all)
  {
    checkWidget();
    int hwnd = parent.handle;
    int hItem = OS.SendMessage(hwnd, 4362, 4, handle);
    if (hItem == 0) {
      error(6);
    }
    hItem = parent.findItem(hItem, index);
    if (hItem == 0) {
      error(6);
    }
    TVITEM tvItem = new TVITEM();
    mask = 20;
    parent.clear(hItem, tvItem);
    if (all)
    {
      hItem = OS.SendMessage(hwnd, 4362, 4, hItem);
      parent.clearAll(hItem, tvItem, all);
    }
  }
  
  public void clearAll(boolean all)
  {
    checkWidget();
    int hwnd = parent.handle;
    int hItem = OS.SendMessage(hwnd, 4362, 4, handle);
    if (hItem == 0) {
      return;
    }
    TVITEM tvItem = new TVITEM();
    mask = 20;
    parent.clearAll(hItem, tvItem, all);
  }
  
  void destroyWidget()
  {
    TVITEM tvItem = new TVITEM();
    mask = 20;
    parent.releaseItem(handle, tvItem, false);
    parent.destroyItem(this, handle);
    releaseHandle();
  }
  
  int fontHandle(int index)
  {
    if ((cellFont != null) && (cellFont[index] != null)) {
      return cellFont[index].handle;
    }
    if (font != null) {
      return font.handle;
    }
    return -1;
  }
  
  public Color getBackground()
  {
    checkWidget();
    if (!parent.checkData(this, true)) {
      error(24);
    }
    if (background == -1) {
      return parent.getBackground();
    }
    return Color.win32_new(display, background);
  }
  
  public Color getBackground(int index)
  {
    checkWidget();
    if (!parent.checkData(this, true)) {
      error(24);
    }
    int count = Math.max(1, parent.getColumnCount());
    if ((index < 0) || (index > count - 1)) {
      return getBackground();
    }
    int pixel = cellBackground != null ? cellBackground[index] : -1;
    return pixel == -1 ? getBackground() : Color.win32_new(display, pixel);
  }
  
  public Rectangle getBounds()
  {
    checkWidget();
    if (!parent.checkData(this, true)) {
      error(24);
    }
    RECT rect = getBounds(0, true, false, false);
    int width = right - left;int height = bottom - top;
    return new Rectangle(left, top, width, height);
  }
  
  public Rectangle getBounds(int index)
  {
    checkWidget();
    if (!parent.checkData(this, true)) {
      error(24);
    }
    RECT rect = getBounds(index, true, true, true);
    int width = right - left;int height = bottom - top;
    return new Rectangle(left, top, width, height);
  }
  
  RECT getBounds(int index, boolean getText, boolean getImage, boolean fullText)
  {
    return getBounds(index, getText, getImage, fullText, false, true, 0);
  }
  
  RECT getBounds(int index, boolean getText, boolean getImage, boolean fullText, boolean fullImage, boolean clip, int hDC)
  {
    if ((!getText) && (!getImage)) {
      return new RECT();
    }
    int hwnd = parent.handle;
    if (((parent.style & 0x10000000) == 0) && (!cached) && (!parent.painted))
    {
      TVITEM tvItem = new TVITEM();
      mask = 17;
      hItem = handle;
      pszText = -1;
      parent.ignoreCustomDraw = true;
      OS.SendMessage(hwnd, OS.TVM_SETITEM, 0, tvItem);
      parent.ignoreCustomDraw = false;
    }
    boolean firstColumn = index == 0;
    int columnCount = 0;
    int hwndHeader = parent.hwndHeader;
    if (hwndHeader != 0)
    {
      columnCount = parent.columnCount;
      firstColumn = index == OS.SendMessage(hwndHeader, 4623, 0, 0);
    }
    RECT rect = new RECT();
    if (firstColumn)
    {
      boolean full = (columnCount == 0) && (getText) && (getImage) && (fullText) && (fullImage);
      if (!OS.TreeView_GetItemRect(hwnd, handle, rect, !full)) {
        return new RECT();
      }
      if ((getImage) && (!fullImage)) {
        if (OS.SendMessage(hwnd, 4360, 0, 0) != 0)
        {
          Point size = parent.getImageSize();
          left -= x + 3;
          if (!getText) {
            right = (left + x);
          }
        }
        else if (!getText)
        {
          right = left;
        }
      }
      if (((fullText) || (fullImage) || (clip)) && 
        (hwndHeader != 0))
      {
        RECT headerRect = new RECT();
        if (columnCount != 0)
        {
          if (OS.SendMessage(hwndHeader, 4615, index, headerRect) == 0) {
            return new RECT();
          }
        }
        else
        {
          right = parent.scrollWidth;
          if (right == 0) {
            headerRect = rect;
          }
        }
        if ((fullText) && (clip)) {
          right = right;
        }
        if (fullImage) {
          left = left;
        }
        if ((clip) && (right < right)) {
          right = right;
        }
      }
    }
    else
    {
      if ((index < 0) || (index >= columnCount)) {
        return new RECT();
      }
      RECT headerRect = new RECT();
      if (OS.SendMessage(hwndHeader, 4615, index, headerRect) == 0) {
        return new RECT();
      }
      if (!OS.TreeView_GetItemRect(hwnd, handle, rect, false)) {
        return new RECT();
      }
      left = left;
      if ((fullText) && (getImage) && (clip))
      {
        right = right;
      }
      else
      {
        right = left;
        Image image = null;
        if (index == 0) {
          image = this.image;
        } else if (images != null) {
          image = images[index];
        }
        if (image != null)
        {
          Point size = parent.getImageSize();
          right += x;
        }
        if (getText) {
          if ((fullText) && (clip))
          {
            left = (right + 3);
            right = right;
          }
          else
          {
            String string = strings != null ? strings[index] : index == 0 ? text : null;
            if (string != null)
            {
              RECT textRect = new RECT();
              TCHAR buffer = new TCHAR(parent.getCodePage(), string, false);
              int flags = 3104;
              int hNewDC = hDC;int hFont = 0;
              if (hDC == 0)
              {
                hNewDC = OS.GetDC(hwnd);
                hFont = fontHandle(index);
                if (hFont == -1) {
                  hFont = OS.SendMessage(hwnd, 49, 0, 0);
    
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd