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

;
    int oldWidth = maxRect.width;
    int oldHeight = maxRect.height;
    maxRect.x = (maxRect.y = maxRect.width = maxRect.height = 0);
    if (showMax)
    {
      Point maxSize = renderer.computeSize(-5, 0, gc, -1, -1);
      maxRect.x = (x - borderRight - x - 3);
      if (borderRight > 0) {
        maxRect.x += 1;
      }
      maxRect.y = (onBottom ? y - borderBottom - tabHeight + (tabHeight - y) / 2 : borderTop + (tabHeight - y) / 2);
      maxRect.width = x;
      maxRect.height = y;
    }
    if ((oldX != maxRect.x) || (oldWidth != maxRect.width) || 
      (oldY != maxRect.y) || (oldHeight != maxRect.height))
    {
      int left = Math.min(oldX, maxRect.x);
      int right = Math.max(oldX + oldWidth, maxRect.x + maxRect.width);
      int top = onBottom ? y - borderBottom - tabHeight : borderTop + 1;
      redraw(left, top, right - left, tabHeight, false);
    }
    oldX = minRect.x;
    oldY = minRect.y;
    oldWidth = minRect.width;
    oldHeight = minRect.height;
    minRect.x = (minRect.y = minRect.width = minRect.height = 0);
    if (showMin)
    {
      Point minSize = renderer.computeSize(-6, 0, gc, -1, -1);
      minRect.x = (x - borderRight - maxRect.width - x - 3);
      if (borderRight > 0) {
        minRect.x += 1;
      }
      minRect.y = (onBottom ? y - borderBottom - tabHeight + (tabHeight - y) / 2 : borderTop + (tabHeight - y) / 2);
      minRect.width = x;
      minRect.height = y;
    }
    if ((oldX != minRect.x) || (oldWidth != minRect.width) || 
      (oldY != minRect.y) || (oldHeight != minRect.height))
    {
      int left = Math.min(oldX, minRect.x);
      int right = Math.max(oldX + oldWidth, minRect.x + minRect.width);
      int top = onBottom ? y - borderBottom - tabHeight : borderTop + 1;
      redraw(left, top, right - left, tabHeight, false);
    }
    oldX = topRightRect.x;
    oldY = topRightRect.y;
    oldWidth = topRightRect.width;
    oldHeight = topRightRect.height;
    topRightRect.x = (topRightRect.y = topRightRect.width = topRightRect.height = 0);
    if (topRight != null)
    {
      switch (topRightAlignment)
      {
      case 4: 
        int rightEdge = x - borderRight - 3 - maxRect.width - minRect.width;
        if ((!simple) && (borderRight > 0) && (!showMax) && (!showMin)) {
          rightEdge -= 2;
        }
        if (single)
        {
          if ((items.length == 0) || (selectedIndex == -1))
          {
            topRightRect.x = (borderLeft + 3);
            topRightRect.width = (rightEdge - topRightRect.x);
          }
          else
          {
            CTabItem item = items[selectedIndex];
            int chevronWidth = renderer.computeSize(-7, 0, gc, -1, -1).x;
            if (x + width + 7 + chevronWidth >= rightEdge) {
              break;
            }
            topRightRect.x = (x + width + 7 + chevronWidth);
            topRightRect.width = (rightEdge - topRightRect.x);
          }
        }
        else
        {
          if (showChevron) {
            break;
          }
          if (items.length == 0)
          {
            topRightRect.x = (borderLeft + 3);
          }
          else
          {
            int lastIndex = items.length - 1;
            CTabItem lastItem = items[lastIndex];
            topRightRect.x = (x + width);
          }
          topRightRect.width = Math.max(0, rightEdge - topRightRect.x);
        }
        topRightRect.y = (onBottom ? y - borderBottom - tabHeight : borderTop + 1);
        topRightRect.height = (tabHeight - 1);
        break;
      case 131072: 
        Point topRightSize = topRight.computeSize(-1, tabHeight, false);
        int rightEdge = x - borderRight - 3 - maxRect.width - minRect.width;
        if ((!simple) && (borderRight > 0) && (!showMax) && (!showMin)) {
          rightEdge -= 2;
        }
        topRightRect.x = (rightEdge - x);
        topRightRect.width = x;
        topRightRect.y = (onBottom ? y - borderBottom - tabHeight : borderTop + 1);
        topRightRect.height = (tabHeight - 1);
      }
      topRight.setBounds(topRightRect);
    }
    if ((oldX != topRightRect.x) || (oldWidth != topRightRect.width) || 
      (oldY != topRightRect.y) || (oldHeight != topRightRect.height))
    {
      int left = Math.min(oldX, topRightRect.x);
      int right = Math.max(oldX + oldWidth, topRightRect.x + topRightRect.width);
      int top = onBottom ? y - borderBottom - tabHeight : borderTop + 1;
      redraw(left, top, right - left, tabHeight, false);
    }
    oldX = chevronRect.x;
    oldY = chevronRect.y;
    oldWidth = chevronRect.width;
    oldHeight = chevronRect.height;
    chevronRect.x = (chevronRect.y = chevronRect.height = chevronRect.width = 0);
    Point chevronSize = renderer.computeSize(-7, 0, gc, -1, -1);
    if (single)
    {
      if ((selectedIndex == -1) || (items.length > 1))
      {
        chevronRect.width = x;
        chevronRect.height = y;
        chevronRect.y = (onBottom ? y - borderBottom - tabHeight + (tabHeight - chevronRect.height) / 2 : borderTop + (tabHeight - chevronRect.height) / 2);
        if (selectedIndex == -1)
        {
          chevronRect.x = (x - borderRight - 3 - minRect.width - maxRect.width - topRightRect.width - chevronRect.width);
        }
        else
        {
          CTabItem item = items[selectedIndex];
          int w = x - borderRight - 3 - minRect.width - maxRect.width - chevronRect.width;
          if (topRightRect.width > 0) {
            w -= topRightRect.width + 3;
          }
          chevronRect.x = Math.min(x + width + 3, w);
        }
        if (borderRight > 0) {
          chevronRect.x += 1;
        }
      }
    }
    else if (showChevron)
    {
      chevronRect.width = x;
      chevronRect.height = y;
      int i = 0;int lastIndex = -1;
      while ((i < priority.length) && (items[priority[i]].showing)) {
        lastIndex = Math.max(lastIndex, priority[(i++)]);
      }
      if (lastIndex == -1) {
        lastIndex = firstIndex;
      }
      CTabItem lastItem = items[lastIndex];
      int w = x + width + 3;
      if ((!simple) && (lastIndex == selectedIndex)) {
        w -= renderer.curveIndent;
      }
      chevronRect.x = Math.min(w, getRightItemEdge(gc));
      chevronRect.y = (onBottom ? y - borderBottom - tabHeight + (tabHeight - chevronRect.height) / 2 : borderTop + (tabHeight - chevronRect.height) / 2);
    }
    if ((oldX != chevronRect.x) || (oldWidth != chevronRect.width) || 
      (oldY != chevronRect.y) || (oldHeight != chevronRect.height))
    {
      int left = Math.min(oldX, chevronRect.x);
      int right = Math.max(oldX + oldWidth, chevronRect.x + chevronRect.width);
      int top = onBottom ? y - borderBottom - tabHeight : borderTop + 1;
      redraw(left, top, right - left, tabHeight, false);
    }
  }
  
  public void setFont(Font font)
  {
    checkWidget();
    if ((font != null) && (font.equals(getFont()))) {
      return;
    }
    super.setFont(font);
    oldFont = getFont();
    if (!updateTabHeight(false))
    {
      updateItems();
      redraw();
    }
  }
  
  public void setForeground(Color color)
  {
    super.setForeground(color);
    redraw();
  }
  
  public void setInsertMark(CTabItem item, boolean after)
  {
    checkWidget();
  }
  
  public void setInsertMark(int index, boolean after)
  {
    checkWidget();
    if ((index < -1) || (index >= getItemCount())) {
      SWT.error(5);
    }
  }
  
  boolean setItemLocation(GC gc)
  {
    boolean changed = false;
    if (items.length == 0) {
      return false;
    }
    Rectangle trim = renderer.computeTrim(-3, 0, 0, 0, 0, 0);
    int borderLeft = -x;
    int borderBottom = height + y;
    int borderTop = -y;
    Point size = getSize();
    int y = onBottom ? Math.max(borderBottom, y - borderBottom - tabHeight) : borderTop;
    Point closeButtonSize = renderer.computeSize(-8, 0, gc, -1, -1);
    if (single)
    {
      int defaultX = getDisplaygetBoundswidth + 10;
      for (int i = 0; i < items.length; i++)
      {
        CTabItem item = items[i];
        if (i == selectedIndex)
        {
          firstIndex = selectedIndex;
          int oldX = x;int oldY = y;
          x = borderLeft;
          y = y;
          showing = true;
          if ((showClose) || (showClose))
          {
            closeRect.x = (borderLeft - renderer.computeTrim(i, 0, 0, 0, 0, 0).x);
            closeRect.y = (onBottom ? y - borderBottom - tabHeight + (tabHeight - y) / 2 : borderTop + (tabHeight - y) / 2);
          }
          if ((x != oldX) || (y != oldY)) {
            changed = true;
          }
        }
        else
        {
          x = defaultX;
          showing = false;
        }
      }
    }
    else
    {
      int rightItemEdge = getRightItemEdge(gc);
      int maxWidth = rightItemEdge - borderLeft;
      int width = 0;
      for (int i = 0; i < priority.length; i++)
      {
        CTabItem item = items[priority[i]];
        width += width;
        showing = (i == 0);
      }
      int x = -renderer.computeTrim(-2, 0, 0, 0, 0, 0).x;
      int defaultX = getDisplaygetBoundswidth + 10;
      firstIndex = (items.length - 1);
      for (int i = 0; i < items.length; i++)
      {
        CTabItem item = items[i];
        if (!showing)
        {
          if (x != defaultX) {
            changed = true;
          }
          x = defaultX;
        }
        else
        {
          firstIndex = Math.min(firstIndex, i);
          if ((x != x) || (y != y)) {
            changed = true;
          }
          x = x;
          y = y;
          int state = 0;
          if (i == selectedIndex) {
            state |= 0x2;
          }
          Rectangle edgeTrim = renderer.computeTrim(i, state, 0, 0, 0, 0);
          closeRect.x = (x + width - (width + x) - x);
          closeRect.y = (onBottom ? y - borderBottom - tabHeight + (tabHeight - y) / 2 : borderTop + (tabHeight - y) / 2);
          x += width;
          if ((!simple) && (i == selectedIndex)) {
            x -= renderer.curveIndent;
          }
        }
      }
    }
    return changed;
  }
  
  boolean setItemSize(GC gc)
  {
    boolean changed = false;
    if (isDisposed()) {
      return changed;
    }
    Point size = getSize();
    if ((x <= 0) || (y <= 0)) {
      return changed;
    }
    Rectangle trim = renderer.computeTrim(-3, 0, 0, 0, 0, 0);
    int borderRight = width + x;
    int borderLeft = -x;
    
    showChevron = false;
    if (single)
    {
      showChevron = true;
      if (selectedIndex != -1)
      {
        CTabItem tab = items[selectedIndex];
        int width = renderer.computeSize(selectedIndex, 2, gc, -1, -1).x;
        width = Math.min(width, getRightItemEdge(gc) - borderLeft);
        if ((height != tabHeight) || (width != width))
        {
          changed = true;
          shortenedText = null;
          shortenedTextWidth = 0;
          height = tabHeight;
          width = width;
          closeRect.width = (closeRect.height = 0);
          if ((showClose) || (showClose))
          {
            Point closeSize = renderer.computeSize(-8, 2, gc, -1, -1);
            closeRect.width = x;
            closeRect.height = y;
          }
        }
      }
      return changed;
    }
    if (items.length == 0) {
      return changed;
    }
    int tabAreaWidth = x - borderLeft - borderRight - 3;
    if (showMin) {
      tabAreaWidth -= renderer.computeSize(-6, 0, gc, -1, -1).x;
    }
    if (showMax) {
      tabAreaWidth -= renderer.computeSize(-5, 0, gc, -1, -1).x;
    }
    if ((topRightAlignment == 131072) && (topRight != null))
    {
      Point rightSize = topRight.computeSize(-1, -1, false);
      tabAreaWidth -= x + 3;
    }
    tabAreaWidth = Math.max(0, tabAreaWidth);
    
    int minWidth = 0;
    int[] minWidths = new int[items.length];
    for (int i = 0; i < priority.length; i++)
    {
      int index = priority[i];
      int state = 16777216;
      if (index == selectedIndex) {
        state |= 0x2;
      }
      minWidths[index] = renderer.computeSize(index, state, gc, -1, -1).x;
      minWidth += minWidths[index];
      if (minWidth > tabAreaWidth) {
        break;
      }
    }
    int[] widths;
    if (minWidth > tabAreaWidth)
    {
      showChevron = (items.length > 1);
      if (showChevron) {
        tabAreaWidth -= renderer.computeSize(-7, 0, gc, -1, -1).x;
      }
      int[] widths = minWidths;
      int index = selectedIndex != -1 ? selectedIndex : 0;
      if (tabAreaWidth < widths[index]) {
        widths[index] = Math.max(0, tabAreaWidth);
      }
    }
    else
    {
      int maxWidth = 0;
      int[] maxWidths = new int[items.length];
      for (int i = 0; i < items.length; i++)
      {
        int state = 0;
        if (i == selectedIndex) {
          state |= 0x2;
        }
        maxWidths[i] = renderer.computeSize(i, state, gc, -1, -1).x;
        maxWidth += maxWidths[i];
      }
      int[] widths;
      if (maxWidth <= tabAreaWidth)
      {
        widths = maxWidths;
      }
      else
      {
        int extra = (tabAreaWidth - minWidth) / items.length;
        for (;;)
        {
          int large = 0;int totalWidth = 0;
          for (int i = 0; i < items.length; i++) {
            if (maxWidths[i] > minWidths[i] + extra)
            {
              totalWidth += minWidths[i] + extra;
              large++;
            }
            else
            {
              totalWidth += maxWidths[i];
            }
          }
          if (totalWidth >= tabAreaWidth)
          {
            extra--;
            break;
          }
          if ((large == 0) || (tabAreaWidth - totalWidth < large)) {
            break;
          }
          extra++;
        }
        widths = new int[items.length];
        for (int i = 0; i < items.length; i++) {
          widths[i] = Math.min(maxWidths[i], minWidths[i] + extra);
        }
      }
    }
    for (int i = 0; i < items.length; i++)
    {
      CTabItem tab = items[i];
      int width = widths[i];
      if ((height != tabHeight) || (width != width))
      {
        changed = true;
        shortenedText = null;
        shortenedTextWidth = 0;
        height = tabHeight;
        width = width;
        closeRect.width = (closeRect.height = 0);
        if (((showClose) || (showClose)) && (
          (i == selectedIndex) || (showUnselectedClose)))
        {
          Point closeSize = renderer.computeSize(-8, 0, gc, -1, -1);
          closeRect.width = x;
          closeRect.height = y;
        }
      }
    }
    return changed;
  }
  
  public void setMaximizeVisible(boolean visible)
  {
    checkWidget();
    if (showMax == visible) {
      return;
    }
    showMax = visible;
    updateItems();
    redraw();
  }
  
  public void setLayout(Layout layout)
  {
    checkWidget();
  }
  
  public void setMaximized(boolean maximize)
  {
    checkWidget();
    if (maximized == maximize) {
      return;
    }
    if ((maximize) && (minimized)) {
      setMinimized(false);
    }
    maximized = maximize;
    redraw(maxRect.x, maxRect.y, maxRect.width, maxRect.height, false);
  }
  
  public void setMinimizeVisible(boolean visible)
  {
    checkWidget();
    if (showMin == visible) {
      return;
    }
    showMin = visible;
    updateItems();
    redraw();
  }
  
  public void setMinimized(boolean minimize)
  {
    checkWidget();
    if (minimized == minimize) {
      return;
    }
    if ((minimize) && (maximized)) {
      setMaximized(false);
    }
    minimized = minimize;
    redraw(minRect.x, minRect.y, minRect.width, minRect.height, false);
  }
  
  public void setMinimumCharacters(int count)
  {
    checkWidget();
    if (count < 0) {
      SWT.error(6);
    }
    if (minChars == count) {
      return;
    }
    minChars = count;
    if (updateItems()) {
      redrawTabs();
    }
  }
  
  public void setMRUVisible(boolean show)
  {
    checkWidget();
    if (mru == show) {
      return;
    }
    mru = show;
    if (!mru)
    {
      int idx = firstIndex;
      int next = 0;
      for (int i = firstIndex; i < items.length; i++) {
        priority[(next++)] = i;
      }
      for (int i = 0; i < idx; i++) {
        priority[(next++)] = i;
      }
      if (updateItems()) {
        redrawTabs();
      }
    }
  }
  
  public void setRenderer(CTabFolderRenderer renderer)
  {
    checkWidget();
    if (this.renderer == renderer) {
      return;
    }
    if (this.renderer != null) {
      this.renderer.dispose();
    }
    if (renderer == null) {
      renderer = new CTabFolderRenderer(this);
    }
    this.renderer = renderer;
    updateTabHeight(false);
    Rectangle rectBefore = getClientArea();
    updateItems();
    Rectangle rectAfter = getClientArea();
    if (!rectBefore.equals(rectAfter)) {
      notifyListeners(11, new Event());
    }
    redraw();
  }
  
  public void setSelection(CTabItem item)
  {
    checkWidget();
    if (item == null) {
      SWT.error(4);
    }
    int index = indexOf(item);
    setSelection(index);
  }
  
  public void setSelection(int index)
  {
    checkWidget();
    if ((index < 0) || (index >= items.length)) {
      return;
    }
    CTabItem selection = items[index];
    if (selectedIndex == index)
    {
      showItem(selection);
      return;
    }
    int oldIndex = selectedIndex;
    selectedIndex = index;
    if (oldIndex != -1)
    {
      items[oldIndex].closeImageState = 8;
      items[oldIndex].state &= 0xFFFFFFFD;
    }
    closeImageState = 0;
    showing = false;
    state |= 0x2;
    
    Control newControl = control;
    Control oldControl = null;
    if (oldIndex != -1) {
      oldControl = items[oldIndex].control;
    }
    if (newControl != oldControl)
    {
      if ((newControl != null) && (!newControl.isDisposed()))
      {
        newControl.setBounds(getClientArea());
        newControl.setVisible(true);
      }
      if ((oldControl != null) && (!oldControl.isDisposed())) {
        oldControl.setVisible(false);
      }
    }
    showItem(selection);
    redraw();
  }
  
  void setSelection(int index, boolean notify)
  {
    int oldSelectedIndex = selectedIndex;
    setSelection(index);
    if ((notify) && (selectedIndex != oldSelectedIndex) && (selectedIndex != -1))
    {
      Event event = new Event();
      item = getItem(selectedIndex);
      notifyListeners(13, event);
    }
  }
  
  public void setSelectionBackground(Color color)
  {
    checkWidget();
    if (selectionBackground.equals(color)) {
      return;
    }
    setSelectionHighlightGradientColor(null);
    if (color == null) {
      color = getDisplay().getSystemColor(25);
    }
    selectionBackground = color;
    renderer.createAntialiasColors();
    if (selectedIndex > -1) {
      redraw();
    }
  }
  
  public void setSelectionBackground(Color[] colors, int[] percents)
  {
    setSelectionBackground(colors, percents, false);
  }
  
  public void setSelectionBackground(Color[] colors, int[] percents, boolean vertical)
  {
    checkWidget();
    
    Color highlightBeginColor = null;
    int colorsLength;
    if (colors != null)
    {
      if ((percents == null) || (
        (percents.length != colors.length - 1) && (percents.length != colors.length - 2))) {
        SWT.error(5);
      }
      for (int i = 0; i < percents.length; i++)
      {
        if ((percents[i] < 0) || (percents[i] > 100)) {
          SWT.error(5);
        }
        if ((i > 0) && (percents[i] < percents[(i - 1)])) {
          SWT.error(5);
        }
      }
      int colorsLength;
      int colorsLength;
      if (percents.length == colors.length - 2)
      {
        highlightBeginColor = colors[(colors.length - 1)];
        colorsLength = colors.length - 1;
      }
      else
      {
        colorsLength = colors.length;
      }
      if (getDisplay().getDepth() < 15)
      {
        colors = new Color[] { colors[(colorsLength - 1)] };
        colorsLength = colors.length;
        percents = new int[0];
      }
    }
    else
    {
      colorsLength = 0;
    }
    if (selectionBgImage == null)
    {
      if ((selectionGradientColors != null) && (colors != null) && 
        (selectionGradientColors.length == colorsLength))
      {
        boolean same = false;
        for (int i = 0; i < selectionGradientColors.length; i++)
        {
          if (selectionGradientColors[i] == null) {
            same = colors[i] == null;
          } else {
            same = selectionGradientColors[i].equals(colors[i]);
          }
          if (!same) {
            break;
          }
        }
        if (same) {
          for (int i = 0; i < selectionGradientPercents.length; i++)
          {
            same = selectionGradientPercents[i] == percents[i];
            if (!same) {
              break;
            }
          }
        }
        if ((!same) || (selectionGradientVertical != vertical)) {}
      }
    }
    else {
      selectionBgImage = null;
    }
    if (colors == null)
    {
      selectionGradientColors = null;
      selectionGradientPercents = null;
      selectionGradientVertical = false;
      setSelectionBackground(null);
      setSelectionHighlightGradientColor(null);
    }
    else
    {
      selectionGradientColors = new Color[colorsLength];
      for (int i = 0; i < colorsLength; i++) {
        selectionGradientColors[i] = colors[i];
      }
      selectionGradientPercents = new int[percents.length];
      for (int i = 0; i < percents.length; i++) {
        selectionGradientPercents[i] = percents[i];
      }
      selectionGradientVertical = vertical;
      setSelectionBackground(selectionGradientColors[(selectionGradientColors.length - 1)]);
      setSelectionHighlightGradientColor(highlightBeginColor);
    }
    if (selectedIndex > -1) {
      redraw();
    }
  }
  
  void setSelectionHighlightGradientColor(Color start)
  {
    renderer.setSelectionHighlightGradientColor(start);
  }
  
  public void setSelectionBackground(Image image)
  {
    checkWidget();
    if (image == selectionBgImage) {
      return;
    }
    setSelectionHighlightGradientColor(null);
    if (image != null)
    {
      selectionGradientColors = null;
      selectionGradientPercents = null;
      renderer.disposeSelectionHighlightGradientColors();
    }
    selectionBgImage = image;
    renderer.createAntialiasColors();
    if (selectedIndex > -1) {
      redraw();
    }
  }
  
  public void setSelectionForeground(Color color)
  {
    checkWidget();
    if (selectionForeground.equals(color)) {
      return;
    }
    if (color == null) {
      color = getDisplay().getSystemColor(24);
    }
    selectionForeground = color;
    if (selectedIndex > -1) {
      redraw();
    }
  }
  
  public void setSimple(boolean simple)
  {
    checkWidget();
    if (this.simple != simple)
    {
      this.simple = simple;
      Rectangle rectBefore = getClientArea();
      updateItems();
      Rectangle rectAfter = getClientArea();
      if (!rectBefore.equals(rectAfter)) {
        notifyListeners(11, new Event());
      }
      redraw();
    }
  }
  
  public void setSingle(boolean single)
  {
    checkWidget();
    if (this.single != single)
    {
      this.single = single;
      if (!single) {
        for (int i = 0; i < items.length; i++) {
          if ((i != selectedIndex) && (items[i].closeImageState == 0)) {
            items[i].closeImageState = 8;
          }
        }
      }
      Rectangle rectBefore = getClientArea();
      updateItems();
      Rectangle rectAfter = getClientArea();
      if (!rectBefore.equals(rectAfter)) {
        notifyListeners(11, new Event());
      }
      redraw();
    }
  }
  
  public void setTabHeight(int height)
  {
    checkWidget();
    if (height < -1) {
      SWT.error(5);
    }
    fixedTabHeight = height;
    updateTabHeight(false);
  }
  
  public void setTabPosition(int position)
  {
    checkWidget();
    if ((position != 128) && (position != 1024)) {
      SWT.error(5);
    }
    if (onBottom != (position == 1024))
    {
      onBottom = (position == 1024);
      updateTabHeight(true);
      Rectangle rectBefore = getClientArea();
      updateItems();
      Rectangle rectAfter = getClientArea();
      if (!rectBefore.equals(rectAfter)) {
        notifyListeners(11, new Event());
      }
      redraw();
    }
  }
  
  public void setTopRight(Control control)
  {
    setTopRight(control, 131072);
  }
  
  public void setTopRight(Control control, int alignment)
  {
    checkWidget();
    if ((alignment != 131072) && (alignment != 4)) {
      SWT.error(5);
    }
    if ((control != null) && (control.getParent() != this)) {
      SWT.error(5);
    }
    topRight = control;
    topRightAlignment = alignment;
    if (updateItems()) {
      redraw();
    }
  }
  
  public void setUnselectedCloseVisible(boolean visible)
  {
    checkWidget();
    if (showUnselectedClose == visible) {
      return;
    }
    showUnselectedClose = visible;
    updateItems();
    redraw();
  }
  
  public void setUnselectedImageVisible(boolean visible)
  {
    checkWidget();
    if (showUnselectedImage == visible) {
      return;
    }
    showUnselectedImage = visible;
    updateItems();
    redraw();
  }
  
  public void showItem(CTabItem item)
  {
    checkWidget();
    if (item == null) {
      SWT.error(4);
    }
    if (item.isDisposed()) {
      SWT.error(5);
    }
    int index = indexOf(item);
    if (index == -1) {
      SWT.error(5);
    }
    int idx = -1;
    for (int i = 0; i < priority.length; i++) {
      if (priority[i] == index)
      {
        idx = i;
        break;
      }
    }
    if (mru)
    {
      int[] newPriority = new int[priority.length];
      System.arraycopy(priority, 0, newPriority, 1, idx);
      System.arraycopy(priority, idx + 1, newPriority, idx + 1, priority.length - idx - 1);
      newPriority[0] = index;
      priority = newPriority;
    }
    if (item.isShowing()) {
      return;
    }
    updateItems(index);
    redrawTabs();
  }
  
  void showList(Rectangle rect)
  {
    if ((this.items.length == 0) || (!showChevron)) {
      return;
    }
    if ((showMenu == null) || (showMenu.isDisposed()))
    {
      showMenu = new Menu(getShell(), getStyle() & 0x6000000);
    }
    else
    {
      MenuItem[] items = showMenu.getItems();
      for (int i = 0; i < items.length; i++) {
        items[i].dispose();
      }
    }
    for (int i = 0; i < this.items.length; i++)
    {
      CTabItem tab = this.items[i];
      if (!showing)
      {
        MenuItem item = new MenuItem(showMenu, 0);
        item.setText(tab.getText());
        item.setImage(tab.getImage());
        item.setData("CTabFolder_showList_Index", tab);
        item.addSelectionListener(new SelectionAdapter()
        {
          public void widgetSelected(SelectionEvent e)
          {
            MenuItem menuItem = (MenuItem)widget;
            int index = indexOf((CTabItem)menuItem.getData("CTabFolder_showList_Index"));
            setSelection(index, true);
          }
        });
      }
    }
    int x = x;
    int y = y + height;
    Point location = getDisplay().map(this, null, x, y);
    showMenu.setLocation(x, y);
    showMenu.setVisible(true);
  }
  
  public void showSelection()
  {
    checkWidget();
    if (selectedIndex != -1) {
      showItem(getSelection());
    }
  }
  
  void _setToolTipText(int x, int y)
  {
    String oldTip = getToolTipText();
    String newTip = _getToolTip(x, y);
    if ((newTip == null) || (!newTip.equals(oldTip))) {
      setToolTipText(newTip);
    }
  }
  
  boolean updateItems()
  {
    return updateItems(selectedIndex);
  }
  
  boolean updateItems(int showIndex)
  {
    GC gc = new GC(this);
    if ((!single) && (!mru) && (showIndex != -1))
    {
      int firstIndex = showIndex;
      if (priority[0] < showIndex)
      {
        Rectangle trim = renderer.computeTrim(-3, 0, 0, 0, 0, 0);
        int borderLeft = -x;
        int maxWidth = getRightItemEdge(gc) - borderLeft;
        int width = 0;
        int[] widths = new int[items.length];
        for (int i = priority[0]; i <= showIndex; i++)
        {
          int state = 16777216;
          if (i == selectedIndex) {
            state |= 0x2;
          }
          widths[i] = renderer.computeSize(i, state, gc, -1, -1).x;
          width += widths[i];
          if (width > maxWidth) {
            break;
          }
        }
        if (width > maxWidth)
        {
          width = 0;
          for (int i = showIndex; i >= 0; i--)
          {
            int state = 16777216;
            if (i == selectedIndex) {
              state |= 0x2;
            }
            if (widths[i] == 0) {
              widths[i] = renderer.computeSize(i, state, gc, -1, -1).x;
            }
            width += widths[i];
            if (width > maxWidth) {
              break;
            }
            firstIndex = i;
          }
        }
        else
        {
          firstIndex = priority[0];
          for (int i = showIndex + 1; i < items.length; i++)
          {
            int state = 16777216;
            if (i == selectedIndex) {
              state |= 0x2;
            }
            widths[i] = renderer.computeSize(i, state, gc, -1, -1).x;
            width += widths[i];
            if (width >= maxWidth) {
              break;
            }
          }
          if (width < maxWidth) {
            for (int i = priority[0] - 1; i >= 0; i--)
            {
              int state = 16777216;
              if (i == selectedIndex) {
                state |= 0x2;
              }
              if (widths[i] == 0) {
                widths[i] = renderer.computeSize(i, state, gc, -1, -1).x;
              }
              width += widths[i];
              if (width > maxWidth) {
                break;
              }
              firstIndex = i;
            }
          }
        }
      }
      if (firstIndex != priority[0])
      {
        int index = 0;
        for (int i = firstIndex; i < items.length; i++) {
          priority[(index++)] = i;
        }
        for (int i = 0; i < firstIndex; i++) {
          priority[(index++)] = i;
        }
      }
    }
    boolean oldShowChevron = showChevron;
    boolean changed = setItemSize(gc);
    changed |= setItemLocation(gc);
    setButtonBounds(gc);
    changed |= showChevron ^ oldShowChevron;
    if ((changed) && (getToolTipText() != null))
    {
      Point pt = getDisplay().getCursorLocation();
      pt = toControl(pt);
      _setToolTipText(x, y);
    }
    gc.dispose();
    return changed;
  }
  
  boolean updateTabHeight(boolean force)
  {
    int oldHeight = tabHeight;
    GC gc = new GC(this);
    tabHeight = renderer.computeSize(-2, 0, gc, -1, -1).y;
    gc.dispose();
    if ((!force) && (tabHeight == oldHeight)) {
      return false;
    }
    oldSize = null;
    notifyListeners(11, new Event());
    return true;
  }
  
  String _getToolTip(int x, int y)
  {
    if ((showMin) && (minRect.contains(x, y))) {
      return minimized ? SWT.getMessage("SWT_Restore") : SWT.getMessage("SWT_Minimize");
    }
    if ((showMax) && (maxRect.contains(x, y))) {
      return maximized ? SWT.getMessage("SWT_Restore") : SWT.getMessage("SWT_Maximize");
    }
    if ((showChevron) && (chevronRect.contains(x, y))) {
      return SWT.getMessage("SWT_ShowList");
    }
    CTabItem item = getItem(new Point(x, y));
    if (item == null) {
      return null;
    }
    if (!showing) {
      return null;
    }
    if (((showClose) || (showClose)) && (closeRect.contains(x, y))) {
      return SWT.getMessage("SWT_Close");
    }
    return item.getToolTipText();
  }
}

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

public class CTabFolder2Adapter
  implements CTabFolder2Listener
{
  public void close(CTabFolderEvent event) {}
  
  public void minimize(CTabFolderEvent event) {}
  
  public void maximize(CTabFolderEvent event) {}
  
  public void restore(CTabFolderEvent event) {}
  
  public void showList(CTabFolderEvent event) {}
}

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

import org.eclipse.swt.internal.SWTEventListener;

public abstract interface CTabFolder2Listener
  extends SWTEventListener
{
  public abstract void close(CTabFolderEvent paramCTabFolderEvent);
  
  public abstract void minimize(CTabFolderEvent paramCTabFolderEvent);
  
  public abstract void maximize(CTabFolderEvent paramCTabFolderEvent);
  
  public abstract void restore(CTabFolderEvent paramCTabFolderEvent);
  
  public abstract void showList(CTabFolderEvent paramCTabFolderEvent);
}

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

public class CTabFolderAdapter
  implements CTabFolderListener
{
  public void itemClosed(CTabFolderEvent event) {}
}

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

import org.eclipse.swt.events.TypedEvent;
import org.eclipse.swt.widgets.Widget;

public class CTabFolderEvent
  extends TypedEvent
{
  public Widget item;
  public boolean doit;
  public int x;
  public int y;
  public int width;
  public int height;
  static final long serialVersionUID = 3760566386225066807L;
  
  CTabFolderEvent(Widget w)
  {
    super(w);
  }
  
  public String toString()
  {
    String string = super.toString();
    return string.substring(0, string.length() - 1) + 
      " item=" + item + 
      " doit=" + doit + 
      " x=" + x + 
      " y=" + y + 
      " width=" + width + 
      " height=" + height + 
      "}";
  }
}

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

import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Layout;

class CTabFolderLayout
  extends Layout
{
  protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache)
  {
    CTabFolder folder = (CTabFolder)composite;
    CTabItem[] items = items;
    CTabFolderRenderer renderer = renderer;
    
    int tabW = 0;
    int selectedIndex = selectedIndex;
    if (selectedIndex == -1) {
      selectedIndex = 0;
    }
    GC gc = new GC(folder);
    for (int i = 0; i < items.length; i++) {
      if (single)
      {
        tabW = Math.max(tabW, computeSize2-1-1x);
      }
      else
      {
        int state = 0;
        if (i == selectedIndex) {
          state |= 0x2;
        }
        tabW += computeSize-1-1x;
      }
    }
    tabW += 3;
    if (showMax) {
      tabW += computeSize-50-1-1x;
    }
    if (showMin) {
      tabW += computeSize-60-1-1x;
    }
    if (single) {
      tabW += computeSize-70-1-1x;
    }
    if (topRight != null)
    {
      Point pt = topRight.computeSize(-1, tabHeight, flushCache);
      tabW += 3 + x;
    }
    gc.dispose();
    
    int controlW = 0;
    int controlH = 0;
    for (int i = 0; i < items.length; i++)
    {
      Control control = items[i].getControl();
      if ((control != null) && (!control.isDisposed()))
      {
        Point size = control.computeSize(wHint, hHint, flushCache);
        controlW = Math.max(controlW, x);
        controlH = Math.max(controlH, y);
      }
    }
    int minWidth = Math.max(tabW, controlW);
    int minHeight = minimized ? 0 : controlH;
    if (minWidth == 0) {
      minWidth = 64;
    }
    if (minHeight == 0) {
      minHeight = 64;
    }
    if (wHint != -1) {
      minWidth = wHint;
    }
    if (hHint != -1) {
      minHeight = hHint;
    }
    return new Point(minWidth, minHeight);
  }
  
  protected boolean flushCache(Control control)
  {
    return true;
  }
  
  protected void layout(Composite composite, boolean flushCache)
  {
    CTabFolder folder = (CTabFolder)composite;
    if (selectedIndex != -1)
    {
      Control control = items[selectedIndex].getControl();
      if ((control != null) && (!control.isDisposed())) {
        control.setBounds(folder.getClientArea());
      }
    }
  }
}

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

import org.eclipse.swt.internal.SWTEventListener;

public abstract interface CTabFolderListener
  extends SWTEventListener
{
  public abstract void itemClosed(CTabFolderEvent paramCTabFolderEvent);
}

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

import java.util.Hashtable;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.graphics.TextLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;

public class CTabFolderRenderer
{
  protected CTabFolder parent;
  int[] curve;
  int[] topCurveHighlightStart;
  int[] topCurveHighlightEnd;
  int curveWidth = 0;
  int curveIndent = 0;
  int lastTabHeight = -1;
  Color fillColor;
  Color selectionHighlightGradientBegin = null;
  Color[] selectionHighlightGradientColorsCache = null;
  Color selectedOuterColor = null;
  Color selectedInnerColor = null;
  Color tabAreaColor = null;
  Color lastBorderColor = null;
  static final String COLOR_CACHE = "org.eclipse.swt.custom.CTabFolderRenderer.ColorCache";
  static final int[] TOP_LEFT_CORNER_HILITE = { 5, 2, 4, 2, 3, 3, 2, 4, 2, 5, 1, 6 };
  static final int[] TOP_LEFT_CORNER = { 0, 6, 1, 5, 1, 4, 4, 1, 5, 1, 6 };
  static final int[] TOP_RIGHT_CORNER = { -6, 0, -5, 1, -4, 1, -1, 4, -1, 5, 06 };
  static final int[] BOTTOM_LEFT_CORNER = { 0, -6, 1, -5, 1, -4, 4, -1, 5, -1, 6 };
  static final int[] BOTTOM_RIGHT_CORNER = { -6, 0, -5, -1, -4, -1, -1, -4, -1, -5, 0-6 };
  static final int[] SIMPLE_TOP_LEFT_CORNER = { 0, 2, 1, 1, 2 };
  static final int[] SIMPLE_TOP_RIGHT_CORNER = { -2, 0, -1, 1, 02 };
  static final int[] SIMPLE_BOTTOM_LEFT_CORNER = { 0, -2, 1, -1, 2 };
  static final int[] SIMPLE_BOTTOM_RIGHT_CORNER = { -2, 0, -1, -1, 0-2 };
  static final int[] SIMPLE_UNSELECTED_INNER_CORNER = new int[2];
  static final int[] TOP_LEFT_CORNER_BORDERLESS = { 0, 6, 1, 5, 1, 4, 4, 1, 5, 1, 6 };
  static final int[] TOP_RIGHT_CORNER_BORDERLESS = { -7, 0, -6, 1, -5, 1, -2, 4, -2, 5, -1, 6 };
  static final int[] BOTTOM_LEFT_CORNER_BORDERLESS = { 0, -6, 1, -6, 1, -5, 2, -4, 4, -2, 5, -1, 6, -1, 6 };
  static final int[] BOTTOM_RIGHT_CORNER_BORDERLESS = { -7, 0, -7, -1, -6, -1, -5, -2, -3, -4, -2, -5, -2, -6, -1, -6 };
  static final int[] SIMPLE_TOP_LEFT_CORNER_BORDERLESS = { 0, 2, 1, 1, 2 };
  static final int[] SIMPLE_TOP_RIGHT_CORNER_BORDERLESS = { -3, 0, -2, 1, -1, 2 };
  static final int[] SIMPLE_BOTTOM_LEFT_CORNER_BORDERLESS = { 0, -3, 1, -2, 2, -1, 3 };
  static final int[] SIMPLE_BOTTOM_RIGHT_CORNER_BORDERLESS = { -4, 0, -3, -1, -2, -2, -1, -3 };
  static final RGB CLOSE_FILL = new RGB(252, 160, 160);
  static final int BUTTON_SIZE = 18;
  static final int BUTTON_BORDER = 17;
  static final int BUTTON_FILL = 25;
  static final int BORDER1_COLOR = 18;
  static final int ITEM_TOP_MARGIN = 2;
  static final int ITEM_BOTTOM_MARGIN = 2;
  static final int ITEM_LEFT_MARGIN = 4;
  static final int ITEM_RIGHT_MARGIN = 4;
  static final int INTERNAL_SPACING = 4;
  static final int FLAGS = 9;
  static final String ELLIPSIS = "...";
  public static final int PART_BODY = -1;
  public static final 
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