import { NamedContainer } from "./named-container.js"; import type { TextStyle } from "./paintable.js"; export type ChoiceType = any; export type ChoiceItem = { text: string; value: ChoiceType; fieldName?: string; }; export interface ChoiceStyle extends TextStyle { fillColor?: string; rootColor?: string; rootTextColor?: string; arrowColor?: string; spacing?: number; } export type ChooserConst = new (items: ChoiceItem[], item_w: number, item_h: number, style?: ChoiceStyle) => Chooser; /** abstract base class for other Chooser implementations */ export declare abstract class Chooser extends NamedContainer { items: ChoiceItem[]; constructor(items: ChoiceItem[], item_w: number, item_h: number, style?: ChoiceStyle); _itemChanged: (item: ChoiceItem) => void; /** application sets a callback, to react when ChoiceItem is selected. */ onItemChanged(f: (item: ChoiceItem) => void): void; /** selected item has changed: invoke onChange(item) */ changed(item: ChoiceItem): void; /** call when Chooser is ready for use; after setting onItemChange() etc. */ enable(): void; /** choose the given Item. */ select(item: ChoiceItem): ChoiceItem; /** * Set value in target in the prototype where it is defined. * * Used when target extends a library class compiled to use the base class. * * For example: TP-local extends TP-lib when using hexlib * * @param value the new value to be set * @param item included for those that need item.fieldName or such * @param target the associated object to which fieldName applies * @return false if value has not been set; call select(item) instead. */ setValue(value: any, item: ChoiceItem, target?: object): boolean; }