|(new canvas-list%|| |
| || [||[items items]|| |
| || ||[item-height item-height]|| |
| || ||[item-color item-color]|| |
| || ||[alt-color alt-color]|| |
| || ||[selection-color selection-color]|| |
| || ||[hover-color hover-color]|| |
| || ||[force-selection force-selection]|| |
| || ||[paint-item-callback paint-item-callback]|| |
| || ||[selection-callback selection-callback]|| |
| || ||[action-callback action-callback]|| |
| || ||[context-action-callback context-action-callback]])|| |
| → (is-a?/c canvas-list%)|
| items : sequence? = #()|
| item-height : exact-nonnegative-integer? = 20|
| item-color : (or/c (is-a?/c color%) #f) = #f|
| alt-color : (or/c (is-a?/c color%) #f) = #f|
| selection-color : (or/c (is-a?/c color%) #f) = #f|
| hover-color : (or/c (is-a?/c color%) #f) = #f|
| force-selection : boolean? = #f|
| ||paint-item-callback|| ||:|| |
| || || ||=|| ||#f|
| ||selection-callback|| ||:|| |
| || || ||=|| ||#f|
| ||context-action-callback|| ||:|| |
| || || ||=|| ||#f|
The items are the initial sequence of items that should be displayed.
The item-height is the height - in pixels - afforded for each item to be drawn. This must be the same for every item and (currently) items can not have different heights.
There are 4 different, basic, background colors that are used to draw items by default. item-color is the basic background color used to draw each item and defaults to white. The alt-color - if provided - is the background color used for every-other item and defaults to a very light gray. The selection-color and hover-color are both used to highlight the currently selected item and the item the mouse is currently hovering over.
The force-selection parameter - when #t - makes it so that once an item in the list has been selected it cannot be unselected (typically by pressing ESC).
The paint-item-callback is called to render each item in the list. Before being called, the dc<%> clipping rect is set and translated to the correct location on screen; drawing at <0,0> will be the upper-left corner of the item’s cell. The arguments passed are the canvas-list% control, then item to render, the state of the item (whether it’s selected, being hovered, or an alternate index), the dc<%>, and the width and height of the cell.
The selection-callback is called every time the currently selected item changes to a different item in the list. It is passed the canvas-list%, the item selected, and - if selected with the mouse - the mouse-event%. If selection happens using the keyboard (e.g. arrow keys), then #f is passed for the event.
The action-callback is called whenever the user double-clicks an item or presses RETURN/ENTER while an item is selected. It is passed the same arguments as the selection-callback.
The context-action-callback is called when the user right-clicks an item. Typically this is used to bring up a popup-menu%. It is passed the same arguments as the selection-callback.
Returns the number of items in the primary key. This may be less than the number of items in the list if there is a filter applied.
Sorts the items in the list.
Applies a filter to the items in the list, hiding any that do not match the predicate.
Removes any applied sorting or filters to the list.
Returns the item at the given index or #f if the index is out of range.
Clears the current set of items being displayed and replaces it with a new set.
Inserts items into the list at the given index. If no index is provided it is inserted before the currently selected index. If there is no selection it is inserted at the beginning.
Appends items onto the list at the given index. If no index is provided it is added after the currently selected index. If there is no selection it is inserted at the beginning.
Returns the index of the currently selected item or #f if there is no selection.
Returns the currently selected item or #f if there is no selection.
Returns the index of the currently hovered item or #f if there is no item being hovered over.
Returns the currently hovered item or #f if there is no item being hovered over.
Ensures that the currently selected item is visible.
If an action-callback was set and there is a selected item, apply the callback.
Changes the current selection to the index. If not provided, the index of the currently hovered over item is used. If #f, then the current selection is cleared.
Clears the current selection.
Selects the first item in the list.
Selects the last item in the list.
Moves to the next item in the list after the current selection. The advance parameter is useful when wanting to skip items (e.g. when using page-up/page-down).
Moves to the previous item in the list before the current selection. The advance parameter is useful when wanting to skip items (e.g. when using page-up/page-down).
If there is a selected item, call proc with the selected item.