/*******************************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * 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.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.designer.internal.ui.views.attributes.page;

import org.eclipse.birt.report.designer.internal.ui.views.attributes.widget.PropertyDescriptorFactory;
import org.eclipse.birt.report.designer.ui.views.attributes.IPropertyDescriptor;
import org.eclipse.birt.report.model.api.StyleHandle;
import org.eclipse.birt.report.model.api.elements.ReportDesignConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;

/**
 * The Font attribute page of DE element.
 *  
 */
public class FontPage extends AttributePage
{

	/**
	 * @param parent
	 *            A widget which will be the parent of the new instance (cannot
	 *            be null)
	 * @param style
	 *            The style of widget to construct
	 */
	public FontPage( Composite parent, int style )
	{
		super( parent, style );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.designer.ui.attributes.page.AttributePage#buildUI()
	 */
	protected void buildUI( )
	{
		setLayout( WidgetUtil.createGridLayout( 6 ) );

		WidgetUtil.buildGridControl( this,
				propertiesMap,
				ReportDesignConstants.STYLE_ELEMENT,
				StyleHandle.FONT_FAMILY_PROP,
				1,
				false );
		WidgetUtil.buildGridControl( this,
				propertiesMap,
				ReportDesignConstants.STYLE_ELEMENT,
				StyleHandle.FONT_SIZE_PROP,
				1,
				false );
		
		WidgetUtil.createGridPlaceholder( this, 2, true );
		
		WidgetUtil.buildGridControl( this,
				propertiesMap,
				ReportDesignConstants.STYLE_ELEMENT,
				StyleHandle.COLOR_PROP,
				1,
				false );
		

		WidgetUtil.createGridPlaceholder( this, 4, false );

		Composite container = new Composite( this, SWT.NONE );
		GridData data = new GridData( );
		data.horizontalSpan = 7;
		container.setLayoutData( data );
		container.setLayout( new FillLayout( ) );

		String[] textStyles = {
				StyleHandle.FONT_WEIGHT_PROP,
				StyleHandle.FONT_STYLE_PROP,
				StyleHandle.TEXT_UNDERLINE_PROP,
				StyleHandle.TEXT_LINE_THROUGH_PROP,
		};
		for ( int i = 0; i < textStyles.length; i++ )
		{
			IPropertyDescriptor descriptor = PropertyDescriptorFactory.getPropertyDescriptor( ReportDesignConstants.STYLE_ELEMENT,
					textStyles[i] );
			propertiesMap.put( textStyles[i], descriptor );
			descriptor.createControl( container );
		}
	}

}