Index:
ChangeLog =================================================================== RCS
file: /home/tools/org.eclipse.cdt.debug.ui/ChangeLog,v retrieving revision
1.60 diff -u -r1.60 ChangeLog --- ChangeLog 19 Dec 2002 02:13:39
-0000 1.60 +++ ChangeLog 19 Dec 2002 18:30:23 -0000 @@ -1,3 +1,8
@@ +2002-12-19 Mikhail Khodjaiants + Added new utility class -
PixelConverter + * PixelCoverter.java + *
AttachSourceLocationBlock.java + 2002-12-18 Mikhail
Khodjaiants Implementing the "Source Lookup" property
page. * SourceLookupBlock.java: common control block. Index:
PixelConverter.java =================================================================== RCS
file: PixelConverter.java diff -N PixelConverter.java --- /dev/null 1
Jan 1970 00:00:00 -0000 +++ PixelConverter.java 19 Dec 2002 18:31:00
-0000 @@ -0,0 +1,63 @@ +package
org.eclipse.cdt.debug.internal.ui; + +/********************************************************************** +Copyright
(c) 2000, 2002 IBM Corp. and others. +All rights reserved. This program and
the accompanying materials +are made available under the terms of the Common
Public License v0.5 +which accompanies this distribution, and is available
at +http://www.eclipse.org/legal/cpl-v05.html + +Contributors: +
IBM Corporation - Initial
implementation +**********************************************************************/ + +import
org.eclipse.swt.graphics.FontMetrics; +import
org.eclipse.swt.graphics.GC; +import
org.eclipse.swt.widgets.Control; + +import
org.eclipse.jface.dialogs.Dialog; + +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 ); + } +} Index:
AttachSourceLocationBlock.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/AttachSourceLocationBlock.java,v retrieving
revision 1.2 diff -u -r1.2 AttachSourceLocationBlock.java ---
AttachSourceLocationBlock.java 17 Dec 2002 23:09:27 -0000 1.2 +++
AttachSourceLocationBlock.java 19 Dec 2002 18:31:14 -0000 @@ -5,15 +5,14
@@ */ package
org.eclipse.cdt.debug.ui.sourcelookup; +import
org.eclipse.cdt.debug.internal.ui.PixelConverter; import
org.eclipse.core.runtime.IPath; -import
org.eclipse.jface.dialogs.Dialog; import
org.eclipse.jface.dialogs.IDialogConstants; import
org.eclipse.jface.resource.JFaceResources; import
org.eclipse.swt.SWT; import
org.eclipse.swt.events.SelectionAdapter; import
org.eclipse.swt.events.SelectionEvent; import
org.eclipse.swt.graphics.FontMetrics; -import
org.eclipse.swt.graphics.GC; import
org.eclipse.swt.layout.GridData; import
org.eclipse.swt.layout.GridLayout; import
org.eclipse.swt.widgets.Button; @@ -52,7 +51,6
@@ fControl.setLayout( new GridLayout()
); fControl.setLayoutData( new GridData( GridData.FILL_BOTH
) ); fControl.setFont( JFaceResources.getDialogFont()
); - initializeDialogUnits( fControl
); createLocationControls( fControl
); createAssociationControls( fControl ); @@ -84,17
+82,18 @@ protected void createLocationControls(
Composite parent ) { + PixelConverter converter =
new PixelConverter( parent ); Label label = new Label(
parent, SWT.NONE ); label.setText( "Select location
directory:" ); label.setLayoutData( new GridData(
GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL )
); Composite composite = new Composite( parent, SWT.NONE
); composite.setLayout( new GridLayout( 2, false )
); GridData data = "" GridData( GridData.FILL_BOTH
); - data.widthHint = Dialog.convertWidthInCharsToPixels(
fFontMetrics, 70 ); + data.widthHint =
converter.convertWidthInCharsToPixels( 70
); composite.setLayoutData( data
); fLocationText = new Text( composite, SWT.SINGLE |
SWT.BORDER ); fLocationText.setLayoutData( new GridData(
GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL ) ); - Button
button = createButton( composite, "&Browse..." ); + Button
button = createButton( composite, "&Browse...", converter
); button.addSelectionListener( new SelectionAdapter()
{ /*
(non-Javadoc) @@ -149,41 +148,18
@@ fAssociationText.setText( ""
); } - protected Button createButton( Composite
parent, String label ) + protected Button createButton( Composite
parent, String label, PixelConverter pc
) { Button button = new Button( parent,
SWT.PUSH ); button.setText( label
); GridData data = "" GridData( GridData.END
); - data.heightHint = convertVerticalDLUsToPixels(
IDialogConstants.BUTTON_HEIGHT ); - int widthHint =
convertHorizontalDLUsToPixels( IDialogConstants.BUTTON_WIDTH
); + data.heightHint = pc.convertVerticalDLUsToPixels(
IDialogConstants.BUTTON_HEIGHT ); + int widthHint =
pc.convertHorizontalDLUsToPixels( IDialogConstants.BUTTON_WIDTH
); data.widthHint = Math.max( widthHint,
button.computeSize( SWT.DEFAULT, SWT.DEFAULT, true ).x
); button.setLayoutData( data
); button.setFont( parent.getFont()
); return
button; - } - - protected int convertVerticalDLUsToPixels(
int dlus ) - { - if ( fFontMetrics == null
) - return 0; - return
Dialog.convertVerticalDLUsToPixels( fFontMetrics, dlus
); - } - - protected int convertHorizontalDLUsToPixels( int
dlus ) - { - if ( fFontMetrics == null
) - return 0; - return
Dialog.convertHorizontalDLUsToPixels( fFontMetrics, dlus
); - } - - protected void initializeDialogUnits( Control
control ) - { - // Compute and store a font
metric - GC gc = new GC( control ); - gc.setFont(
control.getFont() ); - fFontMetrics =
gc.getFontMetrics(); - gc.dispose(); } public
String getLocationPath()
|