Interface ICustomColumn
Base interface implemented by custom columns that can appear to the left and right of an edit control.
Namespace: Sdl.DesktopEditor.EditorApi
Assembly: Sdl.DesktopEditor.EditorApi.dll
Syntax
public interface ICustomColumn
Remarks
This interface defines what is needed to support a read-only column.
Columns that need to interact with the user, e.g. to respond to mouse events should implement IInteractiveCustomColumn, which derives from this interface.
The edit control uses this interface to interact with the custom columns.
Custom columns can be added to an edit control by creating object instances that implement this interface and passing them to AddColumn(ICustomColumn, CustomColumnLocation).
During initialization the GetOptimalWidth(Graphics) method will be called to determine and used to set the Width property.
CalculateCellContentHeight(Graphics, IRowInfo) will be called for each row in the column when rows are sized.
DrawCell(Graphics, IRowInfo, Rectangle, Pen, Pen, Pen, Pen) is called when a cell needs to be displayed.
Properties
EditControl
The edit control hosting this column.
Declaration
IEditControl EditControl { get; set; }
Property Value
Type | Description |
---|---|
IEditControl |
Remarks
This is set during initialization.
IsComplex
Determines whether the column is complex or not. A normal column can draw each row independently of other rows. However, a complex column cannot draw each row independently of other rows. So complex columns need to be entirely redrawn when rows are changed or resized.
Declaration
bool IsComplex { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Width
The width of the column, in pixels. The editor will set this property before the first call to CalculateCellContentHeight(Graphics, IRowInfo).
Declaration
int Width { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
If the column width changes, all the cell heights will need to be re-calculated. The edit control will call CalculateCellContentHeight(Graphics, IRowInfo) to calculate the height of each row.
Methods
BeginDraw()
Called by the control when a repaint is needed. This is called once before a range of DrawCell calls.
Declaration
void BeginDraw()
CalculateCellContentHeight(Graphics, IRowInfo)
Called by the control to determine the minimum height of the content of this column for a specific row, given the current value of the Width property.
Declaration
int CalculateCellContentHeight(Graphics g, IRowInfo row)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | The graphics context to use for drawing column content for this cell. |
IRowInfo | row | The row for the cell. |
Returns
Type | Description |
---|---|
System.Int32 | The height in pixels required to display the full content of the cell. |
DrawCell(Graphics, IRowInfo, Rectangle, Pen, Pen, Pen, Pen)
Called to render a row (cell) of the column.
Declaration
void DrawCell(Graphics g, IRowInfo row, Rectangle cellBounds, Pen leftBorderPen, Pen rightBorderPen, Pen topBorderPen, Pen bottomBorderPen)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | The graphics context to use for drawing column content for this cell. |
IRowInfo | row | The row for the cell. |
System.Drawing.Rectangle | cellBounds | The rectangle in which to draw the cell content. |
System.Drawing.Pen | leftBorderPen | The pen to use if a border on the left should be drawn. May be |
System.Drawing.Pen | rightBorderPen | The pen to use if a border on the right should be drawn. May be |
System.Drawing.Pen | topBorderPen | The pen to use if a border on the top should be drawn. May be |
System.Drawing.Pen | bottomBorderPen | The pen to use if a border on the bottom should be drawn. May be |
Remarks
The implementation should draw the background, cell borders and cell content within the specified rectangle.
It is up to the implementation which cell boundaries to draw. For consistency with surrounding content it is highly recommended to draw any borders using the respective specified pens.
GetOptimalWidth(Graphics)
Called by the edit control to request the optimal width of the column as part of setting the initial Width for the column.
Declaration
int GetOptimalWidth(Graphics g)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g |
Returns
Type | Description |
---|---|
System.Int32 | The most suitable width of the column. |
Remarks
There is no guarantee this width will be used, but it will likely be used if sufficient space is available.
PrepareRegisterRows()
Called from the Editor before RegisterRows are called. Unfortunately RegisterRow is called for all rows when a change occurs in structure, even the row was already 'registered'.
Declaration
void PrepareRegisterRows()
RegisterRow(IRowInfo)
Called from the Editor when a row has been created. Allows a column to keep track of the rows available in the Editor and collect any information it needs about it.
Declaration
void RegisterRow(IRowInfo row)
Parameters
Type | Name | Description |
---|---|---|
IRowInfo | row | The row that has been created in the Editor. |
SetRowSizeAccessor(RowSizeAccessor)
Allows the Editor to pass in a row size delegate which can be used to get the current System.Drawing.Rectangle of any row in the Editor.
Declaration
void SetRowSizeAccessor(RowSizeAccessor rowSizeAccessor)
Parameters
Type | Name | Description |
---|---|---|
RowSizeAccessor | rowSizeAccessor | Delegate that will be passed into the row when registered with the Editor. |