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

New implementation of overlayed images.

This commit is contained in:
Mikhail Khodjaiants 2003-05-05 19:53:03 +00:00
parent 8db10675f9
commit 4a88230536
13 changed files with 248 additions and 241 deletions

View file

@ -1,3 +1,18 @@
2003-05-05 Mikhail Khodjaiants
New implementation of overlayed images.
* OverlayImageDescriptor.java: new
* CImageDescriptor.java: removed
* CDebugImages.java: new overlay images
* CDTDebugModelPresentation.java: presentation of breakpoints and debug elements.
* icons/full/ovr16/address_ovr.gif: new
* icons/full/ovr16/address_ovr_disabled.gif: new
* icons/full/ovr16/function_ovr.gif: new
* icons/full/ovr16/function_ovr_disabled.gif: new
* icons/full/ovr16/conditional_ovr.gif: new
* icons/full/ovr16/conditional_ovr_disabled.gif: new
* icons/full/ovr16/error_ovr.gif: new
* icons/full/ovr16/warning_ovr.gif: new
2003-04-29 Alain Magloire
* src/org/eclipse/cdt/debug/internal/ui/editor/CDebugDocumentProvider.java (doSetInput):

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointTrigger;
import org.eclipse.cdt.debug.core.cdi.model.ICDISignal;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICDebugElementErrorStatus;
import org.eclipse.cdt.debug.core.model.ICDebugTargetType;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
@ -66,6 +67,7 @@ import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.IValueDetailListener;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorDescriptor;
@ -201,6 +203,30 @@ public class CDTDebugModelPresentation extends LabelProvider
* @see org.eclipse.debug.ui.ILabelProvider#getImage(Object)
*/
public Image getImage( Object element )
{
Image baseImage = getBaseImage( element );
if ( baseImage != null )
{
ImageDescriptor[] overlays = new ImageDescriptor[] { null, null, null, null };
if ( element instanceof ICDebugElementErrorStatus && !((ICDebugElementErrorStatus)element).isOK() )
{
switch( ((ICDebugElementErrorStatus)element).getSeverity() )
{
case ICDebugElementErrorStatus.WARNING:
overlays[OverlayImageDescriptor.BOTTOM_LEFT] = CDebugImages.DESC_OVRS_WARNING;
break;
case ICDebugElementErrorStatus.ERROR:
overlays[OverlayImageDescriptor.BOTTOM_LEFT] = CDebugImages.DESC_OVRS_ERROR;
break;
}
}
OverlayImageDescriptor overlayImage = new OverlayImageDescriptor( baseImage, overlays );
return overlayImage.createImage();
}
return null;
}
private Image getBaseImage( Object element )
{
if ( element instanceof IDebugTarget )
{
@ -208,7 +234,7 @@ public class CDTDebugModelPresentation extends LabelProvider
int type = ( targetType != null ) ? targetType.getTargetType() : ICDebugTargetType.TARGET_TYPE_UNKNOWN;
if ( type == ICDebugTargetType.TARGET_TYPE_LOCAL_CORE_DUMP )
{
return fDebugImageRegistry.get( new CImageDescriptor( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_DEBUG_TARGET_TERMINATED ), 0 ) );
return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_DEBUG_TARGET_TERMINATED ) );
}
}
if ( element instanceof IThread )
@ -217,7 +243,20 @@ public class CDTDebugModelPresentation extends LabelProvider
int type = ( targetType != null ) ? targetType.getTargetType() : ICDebugTargetType.TARGET_TYPE_UNKNOWN;
if ( type == ICDebugTargetType.TARGET_TYPE_LOCAL_CORE_DUMP )
{
return fDebugImageRegistry.get( new CImageDescriptor( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_THREAD_TERMINATED ), 0 ) );
return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_THREAD_TERMINATED ) );
}
IThread thread = (IThread)element;
if ( thread.isSuspended() )
{
return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED ) );
}
else if (thread.isTerminated())
{
return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_THREAD_TERMINATED ) );
}
else
{
return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_THREAD_RUNNING ) );
}
}
@ -266,6 +305,16 @@ public class CDTDebugModelPresentation extends LabelProvider
* @see org.eclipse.debug.ui.ILabelProvider#getText(Object)
*/
public String getText( Object element )
{
StringBuffer baseText = new StringBuffer( getBaseText( element ) );
if ( element instanceof ICDebugElementErrorStatus && !((ICDebugElementErrorStatus)element).isOK() )
{
baseText.append( getFormattedString( " <{0}>", ((ICDebugElementErrorStatus)element).getMessage() ) );
}
return baseText.toString();
}
private String getBaseText( Object element )
{
boolean showQualified= isShowQualifiedNames();
StringBuffer label = new StringBuffer();
@ -377,7 +426,7 @@ public class CDTDebugModelPresentation extends LabelProvider
if ( info != null && info instanceof ICDISignalExitInfo)
{
ICDISignalExitInfo sigInfo = (ICDISignalExitInfo)info;
label += MessageFormat.format( " (Signal ''{0}'' received. Description: {1})",
label += MessageFormat.format( ": Signal ''{0}'' received. Description: {1}.",
new String[] { sigInfo.getName(), sigInfo.getDescription() } );
}
else if ( info != null && info instanceof ICDIExitInfo )
@ -541,14 +590,6 @@ public class CDTDebugModelPresentation extends LabelProvider
protected Image getBreakpointImage( ICBreakpoint breakpoint ) throws CoreException
{
if ( breakpoint instanceof ICAddressBreakpoint )
{
return getAddressBreakpointImage( (ICAddressBreakpoint)breakpoint );
}
if ( breakpoint instanceof ICFunctionBreakpoint )
{
return getFunctionBreakpointImage( (ICFunctionBreakpoint)breakpoint );
}
if ( breakpoint instanceof ICLineBreakpoint )
{
return getLineBreakpointImage( (ICLineBreakpoint)breakpoint );
@ -562,72 +603,43 @@ public class CDTDebugModelPresentation extends LabelProvider
protected Image getLineBreakpointImage( ICLineBreakpoint breakpoint ) throws CoreException
{
int flags = computeBreakpointAdornmentFlags( breakpoint );
CImageDescriptor descriptor = null;
ImageDescriptor descriptor = null;
if ( breakpoint.isEnabled() )
{
descriptor = new CImageDescriptor( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_BREAKPOINT ), flags );
descriptor = DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_BREAKPOINT );
}
else
{
descriptor = new CImageDescriptor( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_BREAKPOINT_DISABLED ), flags );
descriptor = DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_BREAKPOINT_DISABLED );
}
return fDebugImageRegistry.get( descriptor );
}
protected Image getAddressBreakpointImage( ICAddressBreakpoint breakpoint ) throws CoreException
{
int flags = computeBreakpointAdornmentFlags( breakpoint );
CImageDescriptor descriptor = null;
if ( breakpoint.isEnabled() )
{
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_ADDRESS_BREAKPOINT_ENABLED, flags );
}
else
{
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_ADDRESS_BREAKPOINT_DISABLED, flags );
}
return fDebugImageRegistry.get( descriptor );
}
protected Image getFunctionBreakpointImage( ICFunctionBreakpoint breakpoint ) throws CoreException
{
int flags = computeBreakpointAdornmentFlags( breakpoint );
CImageDescriptor descriptor = null;
if ( breakpoint.isEnabled() )
{
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_FUNCTION_BREAKPOINT_ENABLED, flags );
}
else
{
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_FUNCTION_BREAKPOINT_DISABLED, flags );
}
return fDebugImageRegistry.get( descriptor );
;
OverlayImageDescriptor overlayImage = new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeBreakpointOverlays( breakpoint ) );
return overlayImage.createImage();
}
protected Image getWatchpointImage( ICWatchpoint watchpoint ) throws CoreException
{
int flags = computeBreakpointAdornmentFlags( watchpoint );
CImageDescriptor descriptor = null;
ImageDescriptor descriptor = null;
if ( watchpoint.isEnabled() )
{
if ( watchpoint.isReadType() && !watchpoint.isWriteType() )
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_READ_WATCHPOINT_ENABLED, flags );
descriptor = CDebugImages.DESC_OBJS_READ_WATCHPOINT_ENABLED;
else if ( !watchpoint.isReadType() && watchpoint.isWriteType() )
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_WRITE_WATCHPOINT_ENABLED, flags );
descriptor = CDebugImages.DESC_OBJS_WRITE_WATCHPOINT_ENABLED;
else
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_WATCHPOINT_ENABLED, flags );
descriptor = CDebugImages.DESC_OBJS_WATCHPOINT_ENABLED;
}
else
{
if ( watchpoint.isReadType() && !watchpoint.isWriteType() )
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_READ_WATCHPOINT_DISABLED, flags );
descriptor = CDebugImages.DESC_OBJS_READ_WATCHPOINT_DISABLED;
else if ( !watchpoint.isReadType() && watchpoint.isWriteType() )
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_WRITE_WATCHPOINT_DISABLED, flags );
descriptor = CDebugImages.DESC_OBJS_WRITE_WATCHPOINT_DISABLED;
else
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_WATCHPOINT_DISABLED, flags );
descriptor = CDebugImages.DESC_OBJS_WATCHPOINT_DISABLED;
}
return fDebugImageRegistry.get( descriptor );
OverlayImageDescriptor overlayImage = new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeBreakpointOverlays( watchpoint ) );
return overlayImage.createImage();
}
protected IBreakpoint getBreakpoint( IMarker marker )
@ -782,30 +794,37 @@ public class CDTDebugModelPresentation extends LabelProvider
}
}
/**
* Returns the adornment flags for the given breakpoint.
* These flags are used to render appropriate overlay
* icons for the breakpoint.
*/
private int computeBreakpointAdornmentFlags( ICBreakpoint breakpoint )
private ImageDescriptor[] computeBreakpointOverlays( ICBreakpoint breakpoint )
{
int flags = 0;
ImageDescriptor[] overlays = new ImageDescriptor[] { null, null, null, null };
try
{
if ( breakpoint.isEnabled() )
if ( breakpoint.isConditional() )
{
flags |= CImageDescriptor.ENABLED;
overlays[OverlayImageDescriptor.TOP_LEFT] = ( breakpoint.isEnabled() ) ?
CDebugImages.DESC_OVRS_BREAKPOINT_CONDITIONAL : CDebugImages.DESC_OVRS_BREAKPOINT_CONDITIONAL_DISABLED;
}
if ( breakpoint.isInstalled() )
{
flags |= CImageDescriptor.INSTALLED;
overlays[OverlayImageDescriptor.BOTTOM_LEFT] = ( breakpoint.isEnabled() ) ?
CDebugImages.DESC_OVRS_BREAKPOINT_INSTALLED : CDebugImages.DESC_OVRS_BREAKPOINT_INSTALLED_DISABLED;
}
if ( breakpoint instanceof ICAddressBreakpoint )
{
overlays[OverlayImageDescriptor.TOP_RIGHT] = ( breakpoint.isEnabled() ) ?
CDebugImages.DESC_OVRS_ADDRESS_BREAKPOINT : CDebugImages.DESC_OVRS_ADDRESS_BREAKPOINT_DISABLED;
}
if ( breakpoint instanceof ICFunctionBreakpoint )
{
overlays[OverlayImageDescriptor.TOP_RIGHT] = ( breakpoint.isEnabled() ) ?
CDebugImages.DESC_OVRS_FUNCTION_BREAKPOINT : CDebugImages.DESC_OVRS_FUNCTION_BREAKPOINT_DISABLED;
}
}
catch( CoreException e )
{
CDebugUIPlugin.log( e );
}
return flags;
return overlays;
}
protected Image getVariableImage( IVariable element ) throws DebugException
@ -813,39 +832,39 @@ public class CDTDebugModelPresentation extends LabelProvider
if ( element instanceof ICVariable )
{
if ( !((ICVariable)element).isEditable() )
return fDebugImageRegistry.get( new CImageDescriptor( CDebugImages.DESC_OBJS_VARIABLE_AGGREGATE, 0 ) );
return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_VARIABLE_AGGREGATE );
else if ( ((ICVariable)element).hasChildren() )
return fDebugImageRegistry.get( new CImageDescriptor( CDebugImages.DESC_OBJS_VARIABLE_POINTER, 0 ) );
return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_VARIABLE_POINTER );
else
return fDebugImageRegistry.get( new CImageDescriptor( CDebugImages.DESC_OBJS_VARIABLE_SIMPLE, 0 ) );
return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_VARIABLE_SIMPLE );
}
return null;
}
protected Image getRegisterGroupImage( IRegisterGroup element ) throws DebugException
{
return fDebugImageRegistry.get( new CImageDescriptor( CDebugImages.DESC_OBJS_REGISTER_GROUP, 0 ) );
return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_REGISTER_GROUP );
}
protected Image getRegisterImage( IRegister element ) throws DebugException
{
return fDebugImageRegistry.get( new CImageDescriptor( CDebugImages.DESC_OBJS_REGISTER, 0 ) );
return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_REGISTER );
}
protected Image getExpressionImage( IExpression element ) throws DebugException
{
return fDebugImageRegistry.get( new CImageDescriptor( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_EXPRESSION ), 0 ) );
return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_EXPRESSION ) );
}
protected Image getSharedLibraryImage( ICSharedLibrary element ) throws DebugException
{
if ( element.areSymbolsLoaded() )
{
return CDebugUIPlugin.getImageDescriptorRegistry().get( new CImageDescriptor( CDebugImages.DESC_OBJS_LOADED_SHARED_LIBRARY, 0 ) );
return CDebugUIPlugin.getImageDescriptorRegistry().get( CDebugImages.DESC_OBJS_LOADED_SHARED_LIBRARY );
}
else
{
return CDebugUIPlugin.getImageDescriptorRegistry().get( new CImageDescriptor( CDebugImages.DESC_OBJS_SHARED_LIBRARY, 0 ) );
return CDebugUIPlugin.getImageDescriptorRegistry().get( CDebugImages.DESC_OBJS_SHARED_LIBRARY );
}
}

View file

@ -49,8 +49,16 @@ public class CDebugImages
/*
* Available cached Images in the C/C++ debug plug-in image registry.
*/
public static final String IMG_OBJS_BREAKPOINT_INSTALLED = NAME_PREFIX + "installed_ovr.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_BREAKPOINT_INSTALLED_DISABLED = NAME_PREFIX + "installed_ovr_disabled.gif"; //$NON-NLS-1$
public static final String IMG_OVRS_BREAKPOINT_INSTALLED = NAME_PREFIX + "installed_ovr.gif"; //$NON-NLS-1$
public static final String IMG_OVRS_BREAKPOINT_INSTALLED_DISABLED = NAME_PREFIX + "installed_ovr_disabled.gif"; //$NON-NLS-1$
public static final String IMG_OVRS_BREAKPOINT_CONDITIONAL = NAME_PREFIX + "conditional_ovr.gif"; //$NON-NLS-1$
public static final String IMG_OVRS_BREAKPOINT_CONDITIONAL_DISABLED = NAME_PREFIX + "conditional_ovr_disabled.gif"; //$NON-NLS-1$
public static final String IMG_OVRS_ADDRESS_BREAKPOINT = NAME_PREFIX + "address_ovr.gif"; //$NON-NLS-1$
public static final String IMG_OVRS_ADDRESS_BREAKPOINT_DISABLED = NAME_PREFIX + "address_ovr_disabled.gif"; //$NON-NLS-1$
public static final String IMG_OVRS_FUNCTION_BREAKPOINT = NAME_PREFIX + "function_ovr.gif"; //$NON-NLS-1$
public static final String IMG_OVRS_FUNCTION_BREAKPOINT_DISABLED = NAME_PREFIX + "function_ovr_disabled.gif"; //$NON-NLS-1$
public static final String IMG_OVRS_ERROR = NAME_PREFIX + "error_ovr.gif"; //$NON-NLS-1$
public static final String IMG_OVRS_WARNING = NAME_PREFIX + "warning_ovr.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_ADDRESS_BREAKPOINT_ENABLED = NAME_PREFIX + "addrbrkp_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_ADDRESS_BREAKPOINT_DISABLED = NAME_PREFIX + "addrbrkpd_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_FUNCTION_BREAKPOINT_ENABLED = NAME_PREFIX + "funbrkp_obj.gif"; //$NON-NLS-1$
@ -102,12 +110,16 @@ public class CDebugImages
// private static final String T_DTOOL = "dtool16"; //$NON-NLS-1$
// private static final String T_ETOOL = "etool16"; //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_BREAKPOINT_INSTALLED = createManaged( T_OVR, IMG_OBJS_BREAKPOINT_INSTALLED );
public static final ImageDescriptor DESC_OBJS_BREAKPOINT_INSTALLED_DISABLED = createManaged( T_OVR, IMG_OBJS_BREAKPOINT_INSTALLED_DISABLED );
public static final ImageDescriptor DESC_OBJS_ADDRESS_BREAKPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_ADDRESS_BREAKPOINT_ENABLED );
public static final ImageDescriptor DESC_OBJS_ADDRESS_BREAKPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_ADDRESS_BREAKPOINT_DISABLED );
public static final ImageDescriptor DESC_OBJS_FUNCTION_BREAKPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_FUNCTION_BREAKPOINT_ENABLED );
public static final ImageDescriptor DESC_OBJS_FUNCTION_BREAKPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_FUNCTION_BREAKPOINT_DISABLED );
public static final ImageDescriptor DESC_OVRS_ERROR = createManaged( T_OVR, IMG_OVRS_ERROR );
public static final ImageDescriptor DESC_OVRS_WARNING = createManaged( T_OVR, IMG_OVRS_WARNING );
public static final ImageDescriptor DESC_OVRS_BREAKPOINT_INSTALLED = createManaged( T_OVR, IMG_OVRS_BREAKPOINT_INSTALLED );
public static final ImageDescriptor DESC_OVRS_BREAKPOINT_INSTALLED_DISABLED = createManaged( T_OVR, IMG_OVRS_BREAKPOINT_INSTALLED_DISABLED );
public static final ImageDescriptor DESC_OVRS_BREAKPOINT_CONDITIONAL = createManaged( T_OVR, IMG_OVRS_BREAKPOINT_CONDITIONAL );
public static final ImageDescriptor DESC_OVRS_BREAKPOINT_CONDITIONAL_DISABLED = createManaged( T_OVR, IMG_OVRS_BREAKPOINT_CONDITIONAL_DISABLED );
public static final ImageDescriptor DESC_OVRS_ADDRESS_BREAKPOINT = createManaged( T_OVR, IMG_OVRS_ADDRESS_BREAKPOINT );
public static final ImageDescriptor DESC_OVRS_ADDRESS_BREAKPOINT_DISABLED = createManaged( T_OVR, IMG_OVRS_ADDRESS_BREAKPOINT_DISABLED );
public static final ImageDescriptor DESC_OVRS_FUNCTION_BREAKPOINT = createManaged( T_OVR, IMG_OVRS_FUNCTION_BREAKPOINT );
public static final ImageDescriptor DESC_OVRS_FUNCTION_BREAKPOINT_DISABLED = createManaged( T_OVR, IMG_OVRS_FUNCTION_BREAKPOINT_DISABLED );
public static final ImageDescriptor DESC_OBJS_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_WATCHPOINT_ENABLED );
public static final ImageDescriptor DESC_OBJS_WATCHPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_WATCHPOINT_DISABLED );
public static final ImageDescriptor DESC_OBJS_READ_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_READ_WATCHPOINT_ENABLED );

View file

@ -1,159 +0,0 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.ui;
import org.eclipse.jface.resource.CompositeImageDescriptor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
/**
*
* A CImageDescriptor consists of a main icon and several adornments. The adornments
* are computed according to flags set on creation of the descriptor.
*
* @since Aug 30, 2002
*/
public class CImageDescriptor extends CompositeImageDescriptor
{
/** Flag to render the is out of synch adornment */
public final static int IS_OUT_OF_SYNCH = 0x001;
/** Flag to render the may be out of synch adornment */
public final static int MAY_BE_OUT_OF_SYNCH = 0x002;
/** Flag to render the installed breakpoint adornment */
public final static int INSTALLED = 0x004;
/** Flag to render the entry method breakpoint adornment */
public final static int ENTRY = 0x008;
/** Flag to render the exit method breakpoint adornment */
public final static int EXIT = 0x010;
/** Flag to render the enabled breakpoint adornment */
public final static int ENABLED = 0x020;
/** Flag to render the conditional breakpoint adornment */
public final static int CONDITIONAL = 0x040;
/** Flag to render the caught breakpoint adornment */
public final static int CAUGHT = 0x080;
/** Flag to render the uncaught breakpoint adornment */
public final static int UNCAUGHT = 0x100;
/** Flag to render the scoped breakpoint adornment */
public final static int SCOPED = 0x200;
private ImageDescriptor fBaseImage;
private int fFlags;
private Point fSize;
/**
* Create a new CImageDescriptor.
*
* @param baseImage an image descriptor used as the base image
* @param flags flags indicating which adornments are to be rendered
*
*/
public CImageDescriptor( ImageDescriptor baseImage, int flags )
{
setBaseImage( baseImage );
setFlags( flags );
}
/**
* @see CompositeImageDescriptor#getSize()
*/
protected Point getSize()
{
if ( fSize == null )
{
ImageData data = getBaseImage().getImageData();
setSize( new Point( data.width, data.height ) );
}
return fSize;
}
/**
* @see Object#equals(java.lang.Object)
*/
public boolean equals( Object object )
{
if ( !( object instanceof CImageDescriptor ) )
{
return false;
}
CImageDescriptor other = (CImageDescriptor)object;
return ( getBaseImage().equals( other.getBaseImage() ) && getFlags() == other.getFlags() );
}
/**
* @see Object#hashCode()
*/
public int hashCode()
{
return getBaseImage().hashCode() | getFlags();
}
/**
* @see CompositeImageDescriptor#drawCompositeImage(int, int)
*/
protected void drawCompositeImage( int width, int height )
{
ImageData bg = getBaseImage().getImageData();
if ( bg == null )
{
bg = DEFAULT_IMAGE_DATA;
}
drawImage( bg, 0, 0 );
drawOverlays();
}
/**
* Add any overlays to the image as specified in the flags.
*/
protected void drawOverlays()
{
int flags = getFlags();
int x = 0;
int y = 0;
ImageData data = null;
if ( ( flags & INSTALLED ) != 0 )
{
x = 0;
y = getSize().y;
if ( ( flags & ENABLED ) != 0 )
{
data = CDebugImages.DESC_OBJS_BREAKPOINT_INSTALLED.getImageData();
}
else
{
data = CDebugImages.DESC_OBJS_BREAKPOINT_INSTALLED_DISABLED.getImageData();
}
y -= data.height;
drawImage( data, x, y );
}
}
protected ImageDescriptor getBaseImage()
{
return fBaseImage;
}
protected void setBaseImage( ImageDescriptor baseImage )
{
fBaseImage = baseImage;
}
protected int getFlags()
{
return fFlags;
}
protected void setFlags( int flags )
{
fFlags = flags;
}
protected void setSize( Point size )
{
fSize = size;
}
}

View file

@ -0,0 +1,120 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.ui;
import java.util.Arrays;
import org.eclipse.jface.resource.CompositeImageDescriptor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
public class OverlayImageDescriptor extends CompositeImageDescriptor
{
static final int DEFAULT_WIDTH = 16;
static final int DEFAULT_HEIGHT = 16;
public static final int TOP_LEFT = 0;
public static final int TOP_RIGHT = 1;
public static final int BOTTOM_LEFT = 2;
public static final int BOTTOM_RIGHT = 3;
// the base image
private Image fBase;
// the overlay images
private ImageDescriptor[] fOverlays;
// the size
private Point fSize;
public OverlayImageDescriptor( Image base, ImageDescriptor[] overlays )
{
fBase = base;
fOverlays = overlays;
fSize = new Point( DEFAULT_WIDTH, DEFAULT_HEIGHT );
}
public OverlayImageDescriptor( Image base, ImageDescriptor[] overlays, Point size )
{
fBase = base;
fOverlays = overlays;
fSize = size;
}
/**
* Draw the fOverlays for the reciever.
*/
protected void drawOverlays( ImageDescriptor[] overlays )
{
Point size = getSize();
for ( int i = 0; i < overlays.length; i++ )
{
ImageDescriptor overlay = overlays[i];
if ( overlay == null )
continue;
ImageData overlayData = overlay.getImageData();
//Use the missing descriptor if it is not there.
if ( overlayData == null )
overlayData = ImageDescriptor.getMissingImageDescriptor().getImageData();
switch( i )
{
case TOP_LEFT:
drawImage( overlayData, 0, 0 );
break;
case TOP_RIGHT:
drawImage( overlayData, size.x - overlayData.width, 0 );
break;
case BOTTOM_LEFT:
drawImage( overlayData, 0, size.y - overlayData.height );
break;
case BOTTOM_RIGHT:
drawImage( overlayData, size.x - overlayData.width, size.y - overlayData.height );
break;
}
}
}
public boolean equals( Object o )
{
if ( !( o instanceof OverlayImageDescriptor ) )
return false;
OverlayImageDescriptor other = (OverlayImageDescriptor)o;
return fBase.equals( other.fBase ) && Arrays.equals( fOverlays, other.fOverlays );
}
public int hashCode()
{
int code = fBase.hashCode();
for ( int i = 0; i < fOverlays.length; i++ )
{
if ( fOverlays[i] != null )
code ^= fOverlays[i].hashCode();
}
return code;
}
/* (non-Javadoc)
* @see org.eclipse.jface.resource.CompositeImageDescriptor#drawCompositeImage(int, int)
*/
protected void drawCompositeImage( int width, int height )
{
drawImage( fBase.getImageData(), 0, 0 );
drawOverlays( fOverlays );
}
/* (non-Javadoc)
* @see org.eclipse.jface.resource.CompositeImageDescriptor#getSize()
*/
protected Point getSize()
{
return fSize;
}
}