1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

fix for bug 234921

This commit is contained in:
Vivian Kong 2008-05-30 20:47:08 +00:00
parent f67f60bafb
commit ace09273d7
2 changed files with 64 additions and 7 deletions

View file

@ -0,0 +1,56 @@
/*******************************************************************************
* Copyright (c) 2000, 2008 IBM Corporation 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.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.xlc.ui;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Control;
public class PixelConverter {
private FontMetrics fFontMetrics;
public PixelConverter( Control control ) {
GC gc = new GC( control );
gc.setFont( control.getFont() );
fFontMetrics = gc.getFontMetrics();
gc.dispose();
}
/**
* @see org.eclipse.jface.dialogs.DialogPage#convertHeightInCharsToPixels(int)
*/
public int convertHeightInCharsToPixels( int chars ) {
return Dialog.convertHeightInCharsToPixels( fFontMetrics, chars );
}
/**
* @see org.eclipse.jface.dialogs.DialogPage#convertHorizontalDLUsToPixels(int)
*/
public int convertHorizontalDLUsToPixels( int dlus ) {
return Dialog.convertHorizontalDLUsToPixels( fFontMetrics, dlus );
}
/**
* @see org.eclipse.jface.dialogs.DialogPage#convertVerticalDLUsToPixels(int)
*/
public int convertVerticalDLUsToPixels( int dlus ) {
return Dialog.convertVerticalDLUsToPixels( fFontMetrics, dlus );
}
/**
* @see org.eclipse.jface.dialogs.DialogPage#convertWidthInCharsToPixels(int)
*/
public int convertWidthInCharsToPixels( int chars ) {
return Dialog.convertWidthInCharsToPixels( fFontMetrics, chars );
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 IBM Corporation and others.
* Copyright (c) 2007, 2008 IBM Corporation 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
@ -13,11 +13,16 @@ package org.eclipse.cdt.managedbuilder.xlc.ui.wizards;
import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPage;
import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager;
import org.eclipse.cdt.managedbuilder.xlc.ui.Messages;
import org.eclipse.cdt.managedbuilder.xlc.ui.PixelConverter;
import org.eclipse.cdt.managedbuilder.xlc.ui.XLCUIPlugin;
import org.eclipse.cdt.managedbuilder.xlc.ui.preferences.PreferenceConstants;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@ -28,10 +33,6 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
/**
* @author crecoskie
@ -116,12 +117,12 @@ public class XLCSettingsWizardPage extends MBSCustomPage {
// set the layout data for the first column, which contains labels
GridData labelGridData = new GridData();
PixelConverter pixelConverter= new PixelConverter(parent);
// create the first label
Label label1 = new Label(fComposite, SWT.NONE);
label1.setText(Messages.XLCSettingsWizardPage_1);
labelGridData.widthHint = 120;
labelGridData.widthHint = pixelConverter.convertWidthInCharsToPixels(label1.getText().length() + 2);
label1.setLayoutData(labelGridData);
label1.setVisible(true);