Java Code Examples for org.eclipse.nebula.widgets.grid.GridColumnGroup#getStyle()

The following examples show how to use org.eclipse.nebula.widgets.grid.GridColumnGroup#getStyle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultColumnGroupHeaderRenderer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean notify(int event, Point point, Object value)
{
    GridColumnGroup group = (GridColumnGroup)value;

    if ((group.getStyle() & SWT.TOGGLE) != 0)
    {
        if (event == IInternalWidget.LeftMouseButtonDown)
        {
            if (getToggleBounds().contains(point))
            {
                group.setExpanded(!group.getExpanded());

                if (group.getExpanded())
                {
                    group.notifyListeners(SWT.Expand,new Event());
                }
                else
                {
                    group.notifyListeners(SWT.Collapse,new Event());
                }
                return true;
            }
        }
        else
        {
            if (getToggleBounds().contains(point))
            {
                setHoverDetail("toggle");
                return true;
            }
        }
    }

    return false;
}
 
Example 2
Source File: DefaultColumnGroupHeaderRenderer.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean notify(int event, Point point, Object value)
{
    GridColumnGroup group = (GridColumnGroup)value;

    if ((group.getStyle() & SWT.TOGGLE) != 0)
    {
        if (event == IInternalWidget.LeftMouseButtonDown)
        {
            if (getToggleBounds().contains(point))
            {
                group.setExpanded(!group.getExpanded());

                if (group.getExpanded())
                {
                    group.notifyListeners(SWT.Expand,new Event());
                }
                else
                {
                    group.notifyListeners(SWT.Collapse,new Event());
                }
                return true;
            }
        }
        else
        {
            if (getToggleBounds().contains(point))
            {
                setHoverDetail("toggle");
                return true;
            }
        }
    }

    return false;
}
 
Example 3
Source File: DefaultColumnGroupHeaderRenderer.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean notify(int event, Point point, Object value)
{
    GridColumnGroup group = (GridColumnGroup)value;

    if ((group.getStyle() & SWT.TOGGLE) != 0)
    {
        if (event == IInternalWidget.LeftMouseButtonDown)
        {
            if (getToggleBounds().contains(point))
            {
                group.setExpanded(!group.getExpanded());

                if (group.getExpanded())
                {
                    group.notifyListeners(SWT.Expand,new Event());
                }
                else
                {
                    group.notifyListeners(SWT.Collapse,new Event());
                }
                return true;
            }
        }
        else
        {
            if (getToggleBounds().contains(point))
            {
                setHoverDetail("toggle");
                return true;
            }
        }
    }

    return false;
}
 
Example 4
Source File: DefaultColumnGroupHeaderRenderer.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Point computeSize(GC gc, int wHint, int hHint, Object value)
{
    GridColumnGroup group = (GridColumnGroup)value;

    gc.setFont(group.getHeaderFont());

    int x = leftMargin;
    int y = topMargin + gc.getFontMetrics().getHeight() + bottomMargin;


    if (group.getImage() != null)
    {
        x += group.getImage().getBounds().width + imageSpacing;

        y = Math.max(y, topMargin + group.getImage().getBounds().height + bottomMargin);
    }

    if (!isWordWrap())
    {
      x += gc.stringExtent(group.getText()).x + rightMargin;
    }
    else
    {
      int toggleWidth = 0;
        if ((group.getStyle() & SWT.TOGGLE) != 0)
          toggleWidth = toggleRenderer.getSize().x;

      int plainTextWidth;
      if (wHint == SWT.DEFAULT)
        plainTextWidth = getBounds().width - x - rightMargin - toggleWidth;
      else
        plainTextWidth = wHint - x - rightMargin - toggleWidth;

      getTextLayout(gc, group);
        textLayout.setText(group.getText());
        textLayout.setWidth(plainTextWidth < 1 ? 1 : plainTextWidth);

        x += plainTextWidth + rightMargin;

        int textHeight = topMargin;
        textHeight += textLayout.getBounds().height;
        textHeight += bottomMargin;

        y = Math.max(y, textHeight);
    }
    return new Point(x, y);
}
 
Example 5
Source File: DefaultColumnGroupHeaderRenderer.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Point computeSize(GC gc, int wHint, int hHint, Object value)
{
    GridColumnGroup group = (GridColumnGroup)value;

    gc.setFont(group.getHeaderFont());

    int x = leftMargin;
    int y = topMargin + gc.getFontMetrics().getHeight() + bottomMargin;


    if (group.getImage() != null)
    {
        x += group.getImage().getBounds().width + imageSpacing;

        y = Math.max(y, topMargin + group.getImage().getBounds().height + bottomMargin);
    }

    if (!isWordWrap())
    {
      x += gc.stringExtent(group.getText()).x + rightMargin;
    }
    else
    {
      int toggleWidth = 0;
        if ((group.getStyle() & SWT.TOGGLE) != 0)
          toggleWidth = toggleRenderer.getSize().x;

      int plainTextWidth;
      if (wHint == SWT.DEFAULT)
        plainTextWidth = getBounds().width - x - rightMargin - toggleWidth;
      else
        plainTextWidth = wHint - x - rightMargin - toggleWidth;

      getTextLayout(gc, group);
        textLayout.setText(group.getText());
        textLayout.setWidth(plainTextWidth < 1 ? 1 : plainTextWidth);

        x += plainTextWidth + rightMargin;

        int textHeight = topMargin;
        textHeight += textLayout.getBounds().height;
        textHeight += bottomMargin;

        y = Math.max(y, textHeight);
    }
    return new Point(x, y);
}
 
Example 6
Source File: DefaultColumnGroupHeaderRenderer.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Point computeSize(GC gc, int wHint, int hHint, Object value)
{
    GridColumnGroup group = (GridColumnGroup)value;

    gc.setFont(group.getHeaderFont());

    int x = leftMargin;
    int y = topMargin + gc.getFontMetrics().getHeight() + bottomMargin;


    if (group.getImage() != null)
    {
        x += group.getImage().getBounds().width + imageSpacing;

        y = Math.max(y, topMargin + group.getImage().getBounds().height + bottomMargin);
    }

    if (!isWordWrap())
    {
      x += gc.stringExtent(group.getText()).x + rightMargin;
    }
    else
    {
      int toggleWidth = 0;
        if ((group.getStyle() & SWT.TOGGLE) != 0)
          toggleWidth = toggleRenderer.getSize().x;

      int plainTextWidth;
      if (wHint == SWT.DEFAULT)
        plainTextWidth = getBounds().width - x - rightMargin - toggleWidth;
      else
        plainTextWidth = wHint - x - rightMargin - toggleWidth;

      getTextLayout(gc, group);
        textLayout.setText(group.getText());
        textLayout.setWidth(plainTextWidth < 1 ? 1 : plainTextWidth);

        x += plainTextWidth + rightMargin;

        int textHeight = topMargin;
        textHeight += textLayout.getBounds().height;
        textHeight += bottomMargin;

        y = Math.max(y, textHeight);
    }
    return new Point(x, y);
}