/** Sets up column header styling. Added by {@link DefaultColumnHeaderLayerConfiguration} */
public class DefaultColumnHeaderStyleConfiguration extends AbstractRegistryConfiguration {

  public Font font = GUIHelper.getFont(new FontData("Verdana", 10, SWT.NORMAL));
  public Color bgColor = GUIHelper.COLOR_WIDGET_BACKGROUND;
  public Color fgColor = GUIHelper.COLOR_WIDGET_FOREGROUND;
  public HorizontalAlignmentEnum hAlign = HorizontalAlignmentEnum.CENTER;
  public VerticalAlignmentEnum vAlign = VerticalAlignmentEnum.MIDDLE;
  public BorderStyle borderStyle = null;

  public ICellPainter cellPainter = new BeveledBorderDecorator(new TextPainter());

  public void configureRegistry(IConfigRegistry configRegistry) {
    configRegistry.registerConfigAttribute(
        CellConfigAttributes.CELL_PAINTER,
        cellPainter,
        DisplayMode.NORMAL,
        GridRegion.COLUMN_HEADER);
    configRegistry.registerConfigAttribute(
        CellConfigAttributes.CELL_PAINTER, cellPainter, DisplayMode.NORMAL, GridRegion.CORNER);

    // Normal
    Style cellStyle = new Style();
    cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, bgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, fgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, hAlign);
    cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, vAlign);
    cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, borderStyle);
    cellStyle.setAttributeValue(CellStyleAttributes.FONT, font);

    configRegistry.registerConfigAttribute(
        CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, GridRegion.COLUMN_HEADER);
    configRegistry.registerConfigAttribute(
        CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, GridRegion.CORNER);
  }
}
Exemplo n.º 2
0
 private void update(FontData data) {
   this.fontData[0] = data;
   this.selectedFont = GUIHelper.getFont(data);
   setText(data.getName() + ", " + data.getHeight() + "pt");
   setFont(createDisplayFont(data));
   setAlignment(SWT.CENTER);
   setToolTipText("Click to select font");
 }
Exemplo n.º 3
0
 private Font createDisplayFont(FontData data) {
   FontData resizedData = new FontData(data.getName(), 8, data.getStyle());
   displayFont = GUIHelper.getFont(resizedData);
   return displayFont;
 }