Stroke Kind Guide
The stroke kind components let users choose a line style (TTMSFNCGraphicsStrokeKind) for use with graphics strokes, pens, or drawing tools. Two controls serve this purpose:
| Component | Presentation |
|---|---|
TTMSFNCStrokeKindSelector |
An always-visible grid showing all stroke pattern samples |
TTMSFNCStrokeKindPicker |
A compact control that opens the selector in a dropdown |
Available stroke kinds include: gskSolid, gskDash, gskDot, gskDashDot, gskDashDotDot, and gskNone.
Using the selector
The selector displays all items in a grid. Read SelectedStrokeKind to get the current choice, or handle OnStrokeKindSelected to react immediately.
// TTMSFNCStrokeKindSelector shows all available stroke patterns in a grid.
// Read or set the selected kind via SelectedStrokeKind.
TMSFNCStrokeKindSelector1.SelectedStrokeKind := gskSolid;
procedure TForm1.TMSFNCStrokeKindSelector1StrokeKindSelected(Sender: TObject;
AStrokeKind: TTMSFNCGraphicsStrokeKind);
begin
// Apply the chosen stroke kind to a drawing stroke
ShapeStroke.Kind := AStrokeKind;
Panel1.Invalidate;
end;
Using the picker
The picker is suited to toolbars where space is limited. Setting CloseOnSelection := True collapses the dropdown automatically after a choice is made.
// TTMSFNCStrokeKindPicker opens the selector in a dropdown.
// Connect it to a graphics stroke via OnStrokeKindSelected.
TMSFNCStrokeKindPicker1.SelectedStrokeKind := gskDash;
TMSFNCStrokeKindPicker1.CloseOnSelection := True;
procedure TForm1.TMSFNCStrokeKindPicker1StrokeKindSelected(Sender: TObject;
AStrokeKind: TTMSFNCGraphicsStrokeKind);
begin
TMSFNCRichEditor1.Pen.Kind := AStrokeKind;
end;
Combining selector and picker
When the application shows both a settings panel (selector) and a toolbar (picker), keeping their SelectedStrokeKind in sync provides a consistent UI.
// Use selector and picker together: selector previews all choices in-place,
// picker saves space in a toolbar. Both share the same selected kind.
procedure TForm1.FormCreate(Sender: TObject);
begin
TMSFNCStrokeKindSelector1.SelectedStrokeKind := gskSolid;
TMSFNCStrokeKindPicker1.SelectedStrokeKind := gskSolid;
// Keep them in sync when the selector changes
TMSFNCStrokeKindSelector1.OnStrokeKindSelected := SelectorKindChanged;
end;
procedure TForm1.SelectorKindChanged(Sender: TObject;
AStrokeKind: TTMSFNCGraphicsStrokeKind);
begin
TMSFNCStrokeKindPicker1.SelectedStrokeKind := AStrokeKind;
ApplyStrokeKindToCanvas(AStrokeKind);
end;