[Overview][Types][Classes][Procedures and functions][Index] |
Draws an item on the extended combo-box control.
Source position: comboex.pas line 156
protected procedure TCustomComboBoxEx.DrawItem( |
Index: Integer; |
ARect: TRect; |
State: TOwnerDrawState |
); override; |
Index |
|
Ordinal position for the item drawn in the method. |
ARect |
|
Display rectangle for the item drawn in the method. |
State |
|
State used to draw the item in the control. |
DrawItem is an overridden procedure used to draw an item on the extended combo-box control.
Index contains the ordinal position for the TComboExItem instance in ItemsEx that is drawn in the method.
ARect is the TRect instance with the coordinates for the item. The values in ARect are set in the calling procedure (LMDrawListItem in TCustomComboBox). When the left coordinate is greater than zero (0), the item is a sub-item (or not a main item). Sub-items are drawn with the additional spacing in Indent applied to the drawing rectangle.
State contains the owner draw state used to render the item on the control. It is used along with the Focused, DroppedDown, and IsEnabled to determine the brush color and style used to render the item on the Canvas.
DrawItem calculates the vertical space needed for the text on the item. It also ensures that the Indent for the item is used to position output horizontally on the control.
If Images have been assigned for the control, the image index appropriate for the value in State is determined. The value odSelected causes the SelectedImageIndex for the item is be used. Otherwise, the ImageIndex for the item is used.
The image size is determined using the SizeForPPI method in Images with the value in its ImagesWidth and the display density for the control Font. DrawItem gets the location for the image and the indent spacing for the current BiDiMode setting for the control. Right-to-Left rendering aligns the image and indent to the right-hand edge of the drawing rectangle. The DrawForPPI method in Images is called to scale the selected image to the current PixelsPerInch setting in Font, and to render the image on the control Canvas.
An image is not drawn when Images is unassigned or contains zero (0) images, or when values have not been explicitly assigned to either ImageIndex or SelectedImageIndex for the extended item in Index.
DrawItem configures the Canvas to use the brush style and font color needed for the values in State, DroppedDown, and Focused. clHighlight is used as the Font color for an item where any one of these values is True. Otherwise, clWindowText is used. If the item is Focused and Enabled but not DroppedDown, the background color is set to clBtnFace and the focus rectangle is drawn.
Text drawing flags are derived for the item; text is on an single line and ellipsified when too long. Text is aligned for the Bidi mode on the control, and centered vertically in the output rectangle. The text is rendered on the Canvas by calling the DrawText method in the LCL interface.
Remark: | DrawItem does NOT call the inherited method in TCustomComboBox or trigger its OnDrawItem event handler. The extended combo-box item is rendered entirely in this method. |
|
Contains images which can be displayed for items defined in the ItemsEx property. |
|
|
Collection with the extended items defined for the control. |
|
|
Implements an extended item used in TComboEx. |
|
|
Provides access to the drawing surface for the control. |
|
|
Indicates whether the drop-down list has been displayed. |
|
|
Draws a list item, using the OnDrawItem handler (when assigned). |
|
|
Alias for the TOwnerDrawState type in lcltype.pp. |
|
|
Checks whether the control has focus. |
|
|
Returns True if both the control and all of its Parent controls are Enabled. |
Version 4.0 | Generated 2025-05-03 | Home |