⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ngfilllayout.java

📁 Novocode的 SWT 控件框架 丰富了MDI功能
💻 JAVA
字号:
/*******************************************************************************
 * Copyright (c) 2004 Stefan Zeiger and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.novocode.com/legal/epl-v10.html
 * 
 * Contributors:
 *     Stefan Zeiger (szeiger@novocode.com) - initial API and implementation
 *******************************************************************************/

package com.novocode.naf.gui.layout;

import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;

import com.novocode.naf.app.NAFException;
import com.novocode.naf.data.Orientation;
import com.novocode.naf.data.SizeMeasure;
import com.novocode.naf.data.SizeMeasurePair;
import com.novocode.naf.data.XMLProperty;
import com.novocode.naf.gui.SWTUtil;
import com.novocode.naf.gui.ShellWindowInstance;


/**
 * Layout creator for SWT FillLayout.
 * 
 * @author Stefan Zeiger (szeiger@novocode.com)
 * @since Nov 29, 2003
 */

public final class NGFillLayout extends NGLayout
{
  private static final SizeMeasure DEFAULT_MARGIN  = new SizeMeasure(0);
  private static final SizeMeasure DEFAULT_SPACING = DEFAULT_MARGIN;


  private Orientation orientation = Orientation.VERTICAL;
  private SizeMeasurePair margin = new SizeMeasurePair(DEFAULT_MARGIN);
  private SizeMeasure spacing = DEFAULT_SPACING;


  @XMLProperty
  public void setMargin(SizeMeasurePair a) { this.margin = new SizeMeasurePair(a); }


  @XMLProperty("hmargin")
  public void setHorizontalMargin(SizeMeasure s) { this.margin.setHorizonal(s); }
  public SizeMeasure getHorizontalMargin() { return margin.getHorizonal(); }


  @XMLProperty("vmargin")
  public void setVerticalMargin(SizeMeasure s) { this.margin.setVertical(s); }
  public SizeMeasure getVerticalMargin() { return margin.getVertical(); }


  @XMLProperty
  public void setSpacing(SizeMeasure s) { this.spacing = s; }
  public SizeMeasure getSpacing() { return spacing; }


  @XMLProperty
  public void setOrientation(Orientation o) { this.orientation = o; }
  public Orientation getOrientation() { return orientation; }

  
  public void assignLayout(Composite comp, ShellWindowInstance wi) throws NAFException
  {
    int embase = SWTUtil.computeEMBase(comp);
    FillLayout l = new FillLayout(orientation.style);
    if(margin != null)
    {
      l.marginWidth  = margin.getHorizonal().compute(embase);
      l.marginHeight = margin.getVertical().compute(embase);
      l.spacing      = spacing.compute(embase);
    }
    comp.setLayout(l);
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -