Krypton.Toolkit right-to-left layout
Overview
Issue #2379 extends the Form/Ribbon two-flag RTL contract to Toolkit visual bases and the remaining control chrome (spin buttons, lists, split/group). Ribbon RTL is #2382. Workspace RTL is a separate branch (#2383).
Contract
| Flag | Meaning |
|---|---|
Control.RightToLeft = Yes |
Reading order; renderer Near/Far content (AccurateText, RenderStandard.RightToLeftIndex). ComboBox drop glyph follows this for WinForms parity. |
RightToLeftLayout = true |
Layout mirroring when also RightToLeft.Yes. |
Gate: CommonHelper.IsRightToLeftLayout(control) (both flags).
Named to match WinForms Form.RightToLeftLayout (bool). Distinct from the Toolkit RightToLeftLayout enum used by dialog routing.
Where the layout flag lives
VisualControlBase— ComboBox, TextBox, NUD, ListBox, SplitContainer (VisualControlContainment), GroupBox, HeaderGroup, DateTimePicker, TreeView, ListView, MonthCalendar (VisualSimpleBase), Ribbon override.VisualPanel—KryptonPanel(does not inheritVisualControlBase).VisualContainerControlBase— container visuals that do not inheritVisualControlBase.VisualPopup,KryptonForm— existing bool flags.
CommonHelper.GetRightToLeftLayout fast-paths those types, then reflects for WinForms Form / ListView / TreeView.
Docker double-flip rule
ViewLayoutDocker.CalculateDock and ViewDrawDocker.CalculateDock swap Left/Right when IsRightToLeftLayout is true, unless IgnoreRightToLeftLayout is set.
- Rely on docker for ButtonSpecs (Near→Left, then docker flips) and GroupBox/HeaderGroup Left/Right captions.
- Or set
IgnoreRightToLeftLayoutand assign docks yourself (KryptonDateTimePicker, CheckBox/RadioButtonUpdateForOrientation).
Never both.
Helpers
ToolkitRtlLayout (Krypton.Toolkit/General/ToolkitRtlLayout.cs): IsRtl, MirrorDock, ApplyTo (copy both flags onto a hosted control), FlipHorizontal, MapNearFar.
Per-control notes
- NumericUpDown / DomainUpDown:
UpDownAlignLeft when both flags, Right otherwise. - ListBox / CheckedListBox: inner native
RightToLeftonly (WinFormsListBoxhas no layout bool). Scrollbar moves with native RTL. - RichTextBox: inner
RightToLeft. ParagraphSelectionAlignmentis unchanged (Left remains Left). - ComboBox drop: still keys off
RightToLeftalone (WinForms combo parity). ButtonSpecs use docker + layout flag. - CheckBox / RadioButton: glyph side from
RightToLeft; docker Ignore so both flags do not invert twice. - KryptonHScrollBar / KryptonVScrollBar: no thumb reversal; list RTL is native VScroll-on-the-left.
- Context menu:
Showcopies both flags from the caller ontoVisualContextMenu. Item docks rely on docker flip (do not also MirrorDock). Submenus useShowHorz = Before; Left/Right keys swap; split hit-test uses the separator side; chevron is flipped. HorizontalViewLayoutStackreverses column order. - TaskDialog: owner flags copy onto the dialog form; element
TableLayoutPanels setRightToLeftonly when both flags are on (so icon/text/footer columns reverse). Heading Near/Far maps throughMapNearFar. - PropertyGrid: host
RightToLeftis forwarded toInternalPropertyGridand its children. Native category UI is not rewritten. - CommandLink: docker packs the arrow to the start edge;
CommandLinkArrowHelper.GetDefaultArrowImage(..., rightToLeft: true)supplies a mirrored arrow when both flags are set. - MonthCalendar: both flags pack the day-name row and date grid from the start edge (first weekday on the right). Do not also reverse the day index. Prev/Next ButtonSpecs stay Near/Far Left/Right and rely on docker flip.