import { ColorUtils } from '@deephaven/utils'; import { type GridColor, type GridColorWay, type NullableGridColor } from './GridTheme'; import { type Coordinate, type VisibleIndex } from './GridMetrics'; import { type BoundedAxisRange } from './GridAxisRange'; import { type GridRenderState } from './GridRendererTypes'; import { type CellRenderType } from './CellRenderer'; import type CellRenderer from './CellRenderer'; import DataBarCellRenderer from './DataBarCellRenderer'; import TextCellRenderer from './TextCellRenderer'; /** * A GridRenderer handles rendering the different parts of the grid * This default rendering just renders a basic grid. Extend this class and implement * your own methods to customize drawing of the grid (eg. Draw icons or special features) */ export declare class GridRenderer { static DEFAULT_EDGE_RADIUS: number; protected textCellRenderer: TextCellRenderer; protected dataBarCellRenderer: DataBarCellRenderer; /** * Truncate a string to the specified length and add ellipses if necessary * @param str The string to truncate * @param len The length to truncate the string to. If longer than the actual string, just returns the string * @returns The truncated string */ static truncate(str: string, len: number): string; /** * Uses binary search to truncate a string to fit in the provided width * @param context The drawing context to measure the text in * @param str The string to get the maximum length it can draw * @param width The width to truncate it to * @param start The low boundary to start the search * @param end The high boundary to start the search * @param truncationChar This char will be repeated as the display string if the string is truncated instead of just adding an ellipsis * @returns The truncated string */ static binaryTruncateToWidth(context: CanvasRenderingContext2D, str: string, width: number, start?: number, end?: number, truncationChar?: string): string; /** * Truncate a string (if necessary) to fit in the specified width. * First uses the estimated font width to calculate a lower/upper bound * Then uses binary search within those bounds to find the exact max length * @param context The drawing context * @param str The string to calculate max length for * @param width The width to truncate within * @param fontWidth The estimated width of each character * @param truncationChar This char will be repeated as the display string if the string is truncated instead of just adding an ellipsis * @returns The truncated string that fits within the width provided */ static truncateToWidth(context: CanvasRenderingContext2D, str: string, width: number, fontWidthLower?: number, fontWidthUpper?: number, truncationChar?: string): string; /** * Cache shared between all grids. Often grids will have the same theme/colors, so we should share the cache. */ static getCachedBackgroundColors: ((backgroundColors: GridColorWay, maxDepth: number) => GridColor[][]) & import("@types/memoizee").Memoized<(backgroundColors: GridColorWay, maxDepth: number) => GridColor[][]>; /** * A memoized version of the GridColorUtils.colorWithAlpha function. */ static getCachedColorWithAlpha: typeof import("./GridColorUtils").colorWithAlpha & import("@types/memoizee").Memoized; /** * A memoized version of the ColorUtils.isDark function. * ColorUtils.isDark is a very expensive function, and having a shared cache between all grids is a good idea. */ static getCachedColorIsDark: typeof ColorUtils.isDark & import("@types/memoizee").Memoized; /** * Draw the grid canvas with the state provided * @param state The state of the grid */ drawCanvas(state: GridRenderState): void; configureContext(context: CanvasRenderingContext2D, state: GridRenderState): void; drawBackground(context: CanvasRenderingContext2D, state: GridRenderState): void; drawGrid(context: CanvasRenderingContext2D, state: GridRenderState): void; drawFloatingRows(context: CanvasRenderingContext2D, state: GridRenderState): void; drawFloatingColumns(context: CanvasRenderingContext2D, state: GridRenderState): void; drawFloatingBorders(context: CanvasRenderingContext2D, state: GridRenderState): void; drawGridBackground(context: CanvasRenderingContext2D, state: GridRenderState, drawHover?: boolean): void; drawRowStripes(context: CanvasRenderingContext2D, state: GridRenderState): void; drawRowStripesForRows(context: CanvasRenderingContext2D, state: GridRenderState, rows: readonly VisibleIndex[], rowBackgroundColors: GridColorWay, minX?: number, maxX?: number): void; drawMouseColumnHover(context: CanvasRenderingContext2D, state: GridRenderState): void; drawMouseRowHover(context: CanvasRenderingContext2D, state: GridRenderState): void; drawFloatingMouseRowHover(context: CanvasRenderingContext2D, state: GridRenderState): void; drawMouseRowHoverForRow(context: CanvasRenderingContext2D, state: GridRenderState, row: VisibleIndex): void; drawGridLines(context: CanvasRenderingContext2D, state: GridRenderState): void; drawGridLinesForItems(context: CanvasRenderingContext2D, state: GridRenderState, columns: readonly VisibleIndex[], rows: readonly VisibleIndex[], columnColor: NullableGridColor, rowColor: NullableGridColor): void; drawGridLinesForColumns(context: CanvasRenderingContext2D, state: GridRenderState, columns: readonly VisibleIndex[]): void; drawGridLinesForRows(context: CanvasRenderingContext2D, state: GridRenderState, rows: readonly VisibleIndex[]): void; drawCellBackgrounds(context: CanvasRenderingContext2D, state: GridRenderState): void; drawCellBackgroundsForItems(context: CanvasRenderingContext2D, state: GridRenderState, columns: readonly VisibleIndex[], rows: readonly VisibleIndex[]): void; drawCellBackground(context: CanvasRenderingContext2D, state: GridRenderState, column: VisibleIndex, row: VisibleIndex, rowAfter?: VisibleIndex): void; drawCellContents(context: CanvasRenderingContext2D, state: GridRenderState): void; drawColumnCellContents(context: CanvasRenderingContext2D, state: GridRenderState, column: VisibleIndex): void; drawCellContent(context: CanvasRenderingContext2D, state: GridRenderState, column: VisibleIndex, row: VisibleIndex): void; getCellRenderer(renderType: CellRenderType): CellRenderer; drawCellRowTreeDepthLines(context: CanvasRenderingContext2D, state: GridRenderState, row: VisibleIndex, rowAfter?: VisibleIndex): void; drawHeaders(context: CanvasRenderingContext2D, state: GridRenderState): void; drawFooters(context: CanvasRenderingContext2D, state: GridRenderState): void; drawColumnHeaders(context: CanvasRenderingContext2D, state: GridRenderState): void; drawColumnHeadersForRange(context: CanvasRenderingContext2D, state: GridRenderState, range: BoundedAxisRange, bounds: { minX: number; maxX: number; }): void; drawColumnHeadersAtDepth(context: CanvasRenderingContext2D, state: GridRenderState, range: BoundedAxisRange, bounds: { minX: number; maxX: number; }, depth: number): void; /** * Draws the column header for the given visible index * @param context Canvas context * @param state Grid render state * @param index Visible index of the column header to draw * @param bounds The horizontal bounds the header can be drawn in */ drawColumnHeaderAtIndex(context: CanvasRenderingContext2D, state: GridRenderState, index: VisibleIndex, bounds: { minX: number; maxX: number; }): void; drawColumnHeader(context: CanvasRenderingContext2D, state: GridRenderState, columnText: string, columnX: Coordinate, columnWidth: number, style?: { backgroundColor?: string; textColor?: string; separatorColor?: string; }, bounds?: { minX?: number; maxX?: number; }): void; drawRowHeaders(context: CanvasRenderingContext2D, state: GridRenderState): void; drawRowHeader(context: CanvasRenderingContext2D, state: GridRenderState, row: VisibleIndex, rowY: Coordinate, rowHeight: number): void; drawRowFooters(context: CanvasRenderingContext2D, state: GridRenderState): void; drawSelectedRanges(context: CanvasRenderingContext2D, state: GridRenderState, viewport?: { left?: VisibleIndex; top?: VisibleIndex; right?: VisibleIndex; bottom?: VisibleIndex; minX?: Coordinate; minY?: Coordinate; maxX?: Coordinate; maxY?: Coordinate; }): void; drawActiveCell(context: CanvasRenderingContext2D, state: GridRenderState, column: VisibleIndex, row: VisibleIndex): void; /** * Draws a rounded rectangle using the current state of the canvas. * * @param context The canvas context * @param x coordinate of the left side * @param y coordinate of the top side * @param w width of the rectangle * @param h height of the rectangle * @param r corner radius of the rectangle */ drawRoundedRect(context: CanvasRenderingContext2D, x: Coordinate, y: Coordinate, w: number, h: number, r?: number): void; drawDraggingColumn(context: CanvasRenderingContext2D, state: GridRenderState): void; drawDraggingRow(context: CanvasRenderingContext2D, state: GridRenderState): void; drawScrollBars(context: CanvasRenderingContext2D, state: GridRenderState): void; getCachedHeaderWidth: ((context: CanvasRenderingContext2D, text: string) => number) & import("@types/memoizee").Memoized<(context: CanvasRenderingContext2D, text: string) => number>; } export default GridRenderer; //# sourceMappingURL=GridRenderer.d.ts.map