C# Class BrightIdeasSoftware.BaseRenderer

Inheritance: AbstractRenderer
Mostrar archivo Open project: soywiz/cspspemu

Private Properties

Property Type Description
ClearState void

Public Methods

Method Description
ApplyCellPadding ( Rectangle r ) : Rectangle

Change the bounds of the given rectangle to take any cell padding into account

DrawText ( Graphics g, Rectangle r, String txt ) : void

Draw the given text and optional image in the "normal" fashion

GetBackgroundColor ( ) : Color

Return the Color that is the background color for this item's cell

GetEditRectangle ( Graphics g, Rectangle cellBounds, BrightIdeasSoftware.OLVListItem item, int subItemIndex, Size preferredSize ) : Rectangle

Calculate the edit rectangle

GetForegroundColor ( ) : Color

Return the color to be used for text in this cell

HitTest ( BrightIdeasSoftware.OlvListViewHitTestInfo hti, int x, int y ) : void

Calculate which part of this cell was hit

OptionalRender ( Graphics g, Rectangle r ) : bool

Draw our data into the given rectangle using the given graphics context.

Subclasses should override this method.

Render ( Graphics g, Rectangle r ) : void

Draw our data into the given rectangle using the given graphics context.

Subclasses should override this method if they never want to fall back on the default processing

RenderItem ( DrawListViewItemEventArgs e, Graphics g, Rectangle itemBounds, object rowObject ) : bool

Render the whole item in a non-details view.

RenderSubItem ( DrawListViewSubItemEventArgs e, Graphics g, Rectangle cellBounds, object rowObject ) : bool

Render one cell

Protected Methods

Method Description
AlignHorizontally ( Rectangle outer, Rectangle inner ) : int

Calculate the left edge of the rectangle that aligns the outer rectangle with the inner one according to this renderer's horizontal alignement

AlignRectangle ( Rectangle outer, Rectangle inner ) : Rectangle

Align the second rectangle with the first rectangle, according to the alignment of the column

AlignVertically ( Rectangle outer, Rectangle inner ) : int

Calculate the top of the rectangle that aligns the outer rectangle with the inner rectangle according to this renders vertical alignment

AlignVertically ( Rectangle outer, int innerHeight ) : int

Calculate the top of the rectangle that aligns the outer rectangle with a rectangle of the given height according to this renderer's vertical alignment

CalculateAlignedRectangle ( Graphics g, Rectangle r ) : Rectangle

Calculate the space that our rendering will occupy and then align that space with the given rectangle, according to the Column alignment

CalculateCheckBoxBounds ( Graphics g, Rectangle cellBounds ) : Rectangle
CalculateCheckBoxWidth ( Graphics g ) : int

How much space will the check box for this cell occupy?

Only column 0 can have check boxes. Sub item checkboxes are treated as images

CalculateImageWidth ( Graphics g, object imageSelector ) : int

How much horizontal space will the image of this cell occupy?

CalculatePaddedAlignedBounds ( Graphics g, Rectangle bounds, Size preferredSize ) : Rectangle
CalculateTextWidth ( Graphics g, string txt ) : int

How much horizontal space will the text of this cell occupy?

DrawAlignedImage ( Graphics g, Rectangle r, Image image ) : void

Draw the given image aligned horizontally within the column.

Over tall images are scaled to fit. Over-wide images are truncated. This is by design!

DrawAlignedImageAndText ( Graphics g, Rectangle r ) : void

Draw our subitems image and text

DrawBackground ( Graphics g, Rectangle r ) : void

Fill in the background of this cell

DrawCheckBox ( Graphics g, Rectangle r ) : int

Draw the check box of this row

DrawImage ( Graphics g, Rectangle r, Object imageSelector ) : int

Draw the given text and optional image in the "normal" fashion

DrawImageAndText ( Graphics g, Rectangle r ) : void

Draw our subitems image and text

DrawImages ( Graphics g, Rectangle r, ICollection imageSelectors ) : int

Draw the given collection of image selectors

DrawTextGdi ( Graphics g, Rectangle r, String txt ) : void

Print the given text in the given rectangle using only GDI routines

The native list control uses GDI routines to do its drawing, so using them here makes the owner drawn mode looks more natural.

This method doesn't honour the CanWrap setting on the renderer. All text is single line

DrawTextGdiPlus ( Graphics g, Rectangle r, String txt ) : void

Print the given text in the given rectangle using normal GDI+ .NET methods

Printing to a printer dc has to be done using this method.

GetCheckBoxState ( CheckState checkState ) : CheckBoxState

Calculate the renderer checkboxstate we need to correctly draw the given state

GetImage ( ) : Image

Return the image that should be drawn against this subitem

GetImage ( Object imageSelector ) : Image

Return the actual image that should be drawn when keyed by the given image selector. An image selector can be: an int, giving the index into the image list a string, giving the image key into the image list an Image, being the image itself

GetImageSelector ( ) : Object

GetText ( ) : string

Return the string that should be drawn within this

GetTextBackgroundColor ( ) : Color

Return the Color that is the background color for this item's text

HandleGetEditRectangle ( Graphics g, Rectangle cellBounds, BrightIdeasSoftware.OLVListItem item, int subItemIndex, Size preferredSize ) : Rectangle

Handle a HitTest request after all state information has been initialized

HandleHitTest ( Graphics g, BrightIdeasSoftware.OlvListViewHitTestInfo hti, int x, int y ) : void

Do the actual work of hit testing. Subclasses should override this rather than HitTest()

StandardGetEditRectangle ( Graphics g, Rectangle cellBounds, Size preferredSize ) : Rectangle

This method calculates the bounds of the text within a standard layout (i.e. optional checkbox, optional image, text)

This method only works correctly if the state of the renderer has been fully initialized (see BaseRenderer.GetEditRectangle)

StandardHitTest ( Graphics g, BrightIdeasSoftware.OlvListViewHitTestInfo hti, Rectangle bounds, int x, int y ) : void

Perform normal hit testing relative to the given bounds

StandardRender ( Graphics g, Rectangle r ) : void

Draw the standard "[checkbox] [image] [text]" cell after the state properties have been initialized.

Private Methods

Method Description
ClearState ( ) : void

Method Details

AlignHorizontally() protected method

Calculate the left edge of the rectangle that aligns the outer rectangle with the inner one according to this renderer's horizontal alignement
protected AlignHorizontally ( Rectangle outer, Rectangle inner ) : int
outer System.Drawing.Rectangle
inner System.Drawing.Rectangle
return int

AlignRectangle() protected method

Align the second rectangle with the first rectangle, according to the alignment of the column
protected AlignRectangle ( Rectangle outer, Rectangle inner ) : Rectangle
outer System.Drawing.Rectangle The cell's bounds
inner System.Drawing.Rectangle The rectangle to be aligned within the bounds
return System.Drawing.Rectangle

AlignVertically() protected method

Calculate the top of the rectangle that aligns the outer rectangle with the inner rectangle according to this renders vertical alignment
protected AlignVertically ( Rectangle outer, Rectangle inner ) : int
outer System.Drawing.Rectangle
inner System.Drawing.Rectangle
return int

AlignVertically() protected method

Calculate the top of the rectangle that aligns the outer rectangle with a rectangle of the given height according to this renderer's vertical alignment
protected AlignVertically ( Rectangle outer, int innerHeight ) : int
outer System.Drawing.Rectangle
innerHeight int
return int

ApplyCellPadding() public method

Change the bounds of the given rectangle to take any cell padding into account
public ApplyCellPadding ( Rectangle r ) : Rectangle
r System.Drawing.Rectangle
return System.Drawing.Rectangle

CalculateAlignedRectangle() protected method

Calculate the space that our rendering will occupy and then align that space with the given rectangle, according to the Column alignment
protected CalculateAlignedRectangle ( Graphics g, Rectangle r ) : Rectangle
g System.Drawing.Graphics
r System.Drawing.Rectangle
return System.Drawing.Rectangle

CalculateCheckBoxBounds() protected method

protected CalculateCheckBoxBounds ( Graphics g, Rectangle cellBounds ) : Rectangle
g System.Drawing.Graphics
cellBounds System.Drawing.Rectangle
return System.Drawing.Rectangle

CalculateCheckBoxWidth() protected method

How much space will the check box for this cell occupy?
Only column 0 can have check boxes. Sub item checkboxes are treated as images
protected CalculateCheckBoxWidth ( Graphics g ) : int
g System.Drawing.Graphics
return int

CalculateImageWidth() protected method

How much horizontal space will the image of this cell occupy?
protected CalculateImageWidth ( Graphics g, object imageSelector ) : int
g System.Drawing.Graphics
imageSelector object
return int

CalculatePaddedAlignedBounds() protected method

protected CalculatePaddedAlignedBounds ( Graphics g, Rectangle bounds, Size preferredSize ) : Rectangle
g System.Drawing.Graphics
bounds System.Drawing.Rectangle
preferredSize System.Drawing.Size
return System.Drawing.Rectangle

CalculateTextWidth() protected method

How much horizontal space will the text of this cell occupy?
protected CalculateTextWidth ( Graphics g, string txt ) : int
g System.Drawing.Graphics
txt string
return int

DrawAlignedImage() protected method

Draw the given image aligned horizontally within the column.
Over tall images are scaled to fit. Over-wide images are truncated. This is by design!
protected DrawAlignedImage ( Graphics g, Rectangle r, Image image ) : void
g System.Drawing.Graphics Graphics context to use for drawing
r System.Drawing.Rectangle Bounds of the cell
image Image The image to be drawn
return void

DrawAlignedImageAndText() protected method

Draw our subitems image and text
protected DrawAlignedImageAndText ( Graphics g, Rectangle r ) : void
g System.Drawing.Graphics Graphics context to use for drawing
r System.Drawing.Rectangle Bounds of the cell
return void

DrawBackground() protected method

Fill in the background of this cell
protected DrawBackground ( Graphics g, Rectangle r ) : void
g System.Drawing.Graphics Graphics context to use for drawing
r System.Drawing.Rectangle Bounds of the cell
return void

DrawCheckBox() protected method

Draw the check box of this row
protected DrawCheckBox ( Graphics g, Rectangle r ) : int
g System.Drawing.Graphics Graphics context to use for drawing
r System.Drawing.Rectangle Bounds of the cell
return int

DrawImage() protected method

Draw the given text and optional image in the "normal" fashion
protected DrawImage ( Graphics g, Rectangle r, Object imageSelector ) : int
g System.Drawing.Graphics Graphics context to use for drawing
r System.Drawing.Rectangle Bounds of the cell
imageSelector Object The optional image to be drawn
return int

DrawImageAndText() protected method

Draw our subitems image and text
protected DrawImageAndText ( Graphics g, Rectangle r ) : void
g System.Drawing.Graphics Graphics context to use for drawing
r System.Drawing.Rectangle Bounds of the cell
return void

DrawImages() protected method

Draw the given collection of image selectors
protected DrawImages ( Graphics g, Rectangle r, ICollection imageSelectors ) : int
g System.Drawing.Graphics
r System.Drawing.Rectangle
imageSelectors ICollection
return int

DrawText() public method

Draw the given text and optional image in the "normal" fashion
public DrawText ( Graphics g, Rectangle r, String txt ) : void
g System.Drawing.Graphics Graphics context to use for drawing
r System.Drawing.Rectangle Bounds of the cell
txt String The string to be drawn
return void

DrawTextGdi() protected method

Print the given text in the given rectangle using only GDI routines
The native list control uses GDI routines to do its drawing, so using them here makes the owner drawn mode looks more natural.

This method doesn't honour the CanWrap setting on the renderer. All text is single line

protected DrawTextGdi ( Graphics g, Rectangle r, String txt ) : void
g System.Drawing.Graphics
r System.Drawing.Rectangle
txt String
return void

DrawTextGdiPlus() protected method

Print the given text in the given rectangle using normal GDI+ .NET methods
Printing to a printer dc has to be done using this method.
protected DrawTextGdiPlus ( Graphics g, Rectangle r, String txt ) : void
g System.Drawing.Graphics
r System.Drawing.Rectangle
txt String
return void

GetBackgroundColor() public method

Return the Color that is the background color for this item's cell
public GetBackgroundColor ( ) : Color
return Color

GetCheckBoxState() protected method

Calculate the renderer checkboxstate we need to correctly draw the given state
protected GetCheckBoxState ( CheckState checkState ) : CheckBoxState
checkState CheckState
return CheckBoxState

GetEditRectangle() public method

Calculate the edit rectangle
public GetEditRectangle ( Graphics g, Rectangle cellBounds, BrightIdeasSoftware.OLVListItem item, int subItemIndex, Size preferredSize ) : Rectangle
g System.Drawing.Graphics
cellBounds System.Drawing.Rectangle
item BrightIdeasSoftware.OLVListItem
subItemIndex int
preferredSize System.Drawing.Size
return System.Drawing.Rectangle

GetForegroundColor() public method

Return the color to be used for text in this cell
public GetForegroundColor ( ) : Color
return Color

GetImage() protected method

Return the image that should be drawn against this subitem
protected GetImage ( ) : Image
return Image

GetImage() protected method

Return the actual image that should be drawn when keyed by the given image selector. An image selector can be: an int, giving the index into the image list a string, giving the image key into the image list an Image, being the image itself
protected GetImage ( Object imageSelector ) : Image
imageSelector Object The value that indicates the image to be used
return Image

GetImageSelector() protected method

protected GetImageSelector ( ) : Object
return Object

GetText() protected method

Return the string that should be drawn within this
protected GetText ( ) : string
return string

GetTextBackgroundColor() protected method

Return the Color that is the background color for this item's text
protected GetTextBackgroundColor ( ) : Color
return Color

HandleGetEditRectangle() protected method

Handle a HitTest request after all state information has been initialized
protected HandleGetEditRectangle ( Graphics g, Rectangle cellBounds, BrightIdeasSoftware.OLVListItem item, int subItemIndex, Size preferredSize ) : Rectangle
g System.Drawing.Graphics
cellBounds System.Drawing.Rectangle
item BrightIdeasSoftware.OLVListItem
subItemIndex int
preferredSize System.Drawing.Size
return System.Drawing.Rectangle

HandleHitTest() protected method

Do the actual work of hit testing. Subclasses should override this rather than HitTest()
protected HandleHitTest ( Graphics g, BrightIdeasSoftware.OlvListViewHitTestInfo hti, int x, int y ) : void
g System.Drawing.Graphics
hti BrightIdeasSoftware.OlvListViewHitTestInfo
x int
y int
return void

HitTest() public method

Calculate which part of this cell was hit
public HitTest ( BrightIdeasSoftware.OlvListViewHitTestInfo hti, int x, int y ) : void
hti BrightIdeasSoftware.OlvListViewHitTestInfo
x int
y int
return void

OptionalRender() public method

Draw our data into the given rectangle using the given graphics context.

Subclasses should override this method.

public OptionalRender ( Graphics g, Rectangle r ) : bool
g System.Drawing.Graphics The graphics context that should be used for drawing
r System.Drawing.Rectangle The bounds of the subitem cell
return bool

Render() public method

Draw our data into the given rectangle using the given graphics context.

Subclasses should override this method if they never want to fall back on the default processing

public Render ( Graphics g, Rectangle r ) : void
g System.Drawing.Graphics The graphics context that should be used for drawing
r System.Drawing.Rectangle The bounds of the subitem cell
return void

RenderItem() public method

Render the whole item in a non-details view.
public RenderItem ( DrawListViewItemEventArgs e, Graphics g, Rectangle itemBounds, object rowObject ) : bool
e System.Windows.Forms.DrawListViewItemEventArgs
g System.Drawing.Graphics
itemBounds System.Drawing.Rectangle
rowObject object
return bool

RenderSubItem() public method

Render one cell
public RenderSubItem ( DrawListViewSubItemEventArgs e, Graphics g, Rectangle cellBounds, object rowObject ) : bool
e System.Windows.Forms.DrawListViewSubItemEventArgs
g System.Drawing.Graphics
cellBounds System.Drawing.Rectangle
rowObject object
return bool

StandardGetEditRectangle() protected method

This method calculates the bounds of the text within a standard layout (i.e. optional checkbox, optional image, text)
This method only works correctly if the state of the renderer has been fully initialized (see BaseRenderer.GetEditRectangle)
protected StandardGetEditRectangle ( Graphics g, Rectangle cellBounds, Size preferredSize ) : Rectangle
g System.Drawing.Graphics
cellBounds System.Drawing.Rectangle
preferredSize System.Drawing.Size
return System.Drawing.Rectangle

StandardHitTest() protected method

Perform normal hit testing relative to the given bounds
protected StandardHitTest ( Graphics g, BrightIdeasSoftware.OlvListViewHitTestInfo hti, Rectangle bounds, int x, int y ) : void
g System.Drawing.Graphics
hti BrightIdeasSoftware.OlvListViewHitTestInfo
bounds System.Drawing.Rectangle
x int
y int
return void

StandardRender() protected method

Draw the standard "[checkbox] [image] [text]" cell after the state properties have been initialized.
protected StandardRender ( Graphics g, Rectangle r ) : void
g System.Drawing.Graphics
r System.Drawing.Rectangle
return void