Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.jface.text
Class MarginPainter  view MarginPainter download MarginPainter.java

java.lang.Object
  extended byorg.eclipse.jface.text.MarginPainter
All Implemented Interfaces:
java.util.EventListener, IPainter, org.eclipse.swt.events.PaintListener, org.eclipse.swt.internal.SWTEventListener

public class MarginPainter
extends java.lang.Object
implements IPainter, org.eclipse.swt.events.PaintListener

Paints a vertical line (margin line) after a given column respecting the text viewer's font.

Clients usually instantiate and configure objects of this class.

This class is not intended to be subclassed.

Since:
2.1

Field Summary
private  int fCachedWidgetX
          The cached x-offset of the fMarginWidth for the current font
private  org.eclipse.swt.graphics.Color fColor
          The color in which to paint the line
private  boolean fIsActive
          The active state of this painter
private  int fLineStyle
          The line style of the line to be painted, default value SWT.LINE_SOLID
private  int fLineWidth
          The line width of the line to be painted, default value 1
private  int fMarginWidth
          The column after which to paint the line, default value 80
private  org.eclipse.swt.custom.StyledText fTextWidget
          The widget of the text viewer
 
Fields inherited from interface org.eclipse.jface.text.IPainter
CONFIGURATION, INTERNAL, KEY_STROKE, MOUSE_BUTTON, SELECTION, TEXT_CHANGE
 
Constructor Summary
MarginPainter(ITextViewer textViewer)
          Creates a new painter for the given text viewer.
 
Method Summary
private  void computeWidgetX()
          Computes and remembers the x-offset of the margin column for the current widget font.
 void deactivate(boolean redraw)
          Deactivates this painter.
 void dispose()
          Disposes this painter.
 void initialize()
          Initializes this painter, by flushing and recomputing all caches and causing the widget to be redrawn.
 void paint(int reason)
          Requests this painter to repaint because of the given reason.
 void paintControl(org.eclipse.swt.events.PaintEvent e)
          Sent when a paint event occurs for the control.
 void setMarginRulerColor(org.eclipse.swt.graphics.Color color)
          Sets the color of the margin line.
 void setMarginRulerColumn(int width)
          Sets the column after which to draw the margin line.
 void setMarginRulerStyle(int lineStyle)
          Sets the line style of the margin line.
 void setMarginRulerWidth(int lineWidth)
          Sets the line width of the margin line.
 void setPositionManager(IPaintPositionManager manager)
          Sets the paint position manager that can be used by this painter or removes any previously set paint position manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fTextWidget

private org.eclipse.swt.custom.StyledText fTextWidget
The widget of the text viewer


fMarginWidth

private int fMarginWidth
The column after which to paint the line, default value 80


fColor

private org.eclipse.swt.graphics.Color fColor
The color in which to paint the line


fLineStyle

private int fLineStyle
The line style of the line to be painted, default value SWT.LINE_SOLID


fLineWidth

private int fLineWidth
The line width of the line to be painted, default value 1


fCachedWidgetX

private int fCachedWidgetX
The cached x-offset of the fMarginWidth for the current font


fIsActive

private boolean fIsActive
The active state of this painter

Constructor Detail

MarginPainter

public MarginPainter(ITextViewer textViewer)
Creates a new painter for the given text viewer.

Method Detail

setMarginRulerColumn

public void setMarginRulerColumn(int width)
Sets the column after which to draw the margin line.


setMarginRulerStyle

public void setMarginRulerStyle(int lineStyle)
Sets the line style of the margin line.


setMarginRulerWidth

public void setMarginRulerWidth(int lineWidth)
Sets the line width of the margin line.


setMarginRulerColor

public void setMarginRulerColor(org.eclipse.swt.graphics.Color color)
Sets the color of the margin line. Must be called before paint is called the first time.


initialize

public void initialize()
Initializes this painter, by flushing and recomputing all caches and causing the widget to be redrawn. Must be called explicitly when font of text widget changes.


computeWidgetX

private void computeWidgetX()
Computes and remembers the x-offset of the margin column for the current widget font.


deactivate

public void deactivate(boolean redraw)
Description copied from interface: IPainter
Deactivates this painter. If the painter is inactive, this call does not have any effect. redraw indicates whether the painter should remove any decoration it previously applied. A deactivated painter can be reactivated by calling paint.

Specified by:
deactivate in interface IPainter

dispose

public void dispose()
Description copied from interface: IPainter
Disposes this painter. Prior to disposing, a painter should be deactivated. A disposed painter can not be reactivated.

Specified by:
dispose in interface IPainter

paint

public void paint(int reason)
Description copied from interface: IPainter
Requests this painter to repaint because of the given reason. Based on the given reason the painter can decide whether it will repaint or not. If it repaints and is inactive, it will activate itself.

Specified by:
paint in interface IPainter

paintControl

public void paintControl(org.eclipse.swt.events.PaintEvent e)
Description copied from interface: org.eclipse.swt.events.PaintListener
Sent when a paint event occurs for the control.

Specified by:
paintControl in interface org.eclipse.swt.events.PaintListener

setPositionManager

public void setPositionManager(IPaintPositionManager manager)
Description copied from interface: IPainter
Sets the paint position manager that can be used by this painter or removes any previously set paint position manager.

Specified by:
setPositionManager in interface IPainter