Skip to content

[Feature Request]: RTL support for **all** Krypton.Toolkit controls #2379

@PWagner1

Description

@PWagner1

Following work done in #2103

Krypton.Toolkit Controls RTL Compatibility Evaluation

Executive Summary

This comprehensive evaluation examines all controls in the Krypton.Toolkit namespace for Right-to-Left (RTL) compatibility. The analysis reveals a mixed implementation status across the 50+ controls, with some having excellent RTL support while others lack basic RTL functionality.

Overall RTL Implementation Status: 35% Complete

Detailed Control Evaluation

Excellent RTL Support (80-95%)

1. KryptonForm - 95% RTL Support

  • Location: KryptonForm.cs
  • Key Features:
    • Comprehensive RTL-aware title bar layout
    • Custom RTLPaletteRedirect and RTLTitleBarLayout classes
    • Proper handling of RightToLeft and RightToLeftLayout properties
    • RTL-aware button positioning and edge alignment
    • Icon/text padding for RTL mode (RTL_ICON_TEXT_PADDING = 8)
    • Dynamic RTL property application to button manager

2. KryptonDateTimePicker - 85% RTL Support

  • Location: KryptonDateTimePicker.cs
  • Key Features:
    • RTL-aware layout adjustments (UpdateForRightToLeft())
    • Proper docking changes for RTL mode
    • RTL-aware text fragment navigation
    • RightToLeftLayout property with change events
    • Proper RTL text direction handling
private void UpdateForRightToLeft()
{
    if (_drawText.RightToLeftLayout && (RightToLeft == RightToLeft.Yes))
    {
        _drawDockerInner.SetDock(_dropStretch, ViewDockStyle.Left);
        _drawDockerInner.SetDock(_upDownFit, ViewDockStyle.Left);
        _drawDockerInner.SetDock(_layoutCheckBox, ViewDockStyle.Right);
    }
    else
    {
        _drawDockerInner.SetDock(_dropStretch, ViewDockStyle.Right);
        _drawDockerInner.SetDock(_upDownFit, ViewDockStyle.Right);
        _drawDockerInner.SetDock(_layoutCheckBox, ViewDockStyle.Left);
    }
}

3. KryptonDataGridView - 80% RTL Support

  • Location: KryptonDataGridView.cs
  • Key Features:
    • RTL-aware cell alignment and text formatting
    • RightToLeftInternal property for internal RTL state
    • RTL-aware border handling
    • Comprehensive RTL text format flags
    • RTL-aware editing controls
internal bool RightToLeftInternal 
{
    get
    {
        if (_piRTL == null)
        {
            _piRTL = typeof(DataGridView).GetProperty(nameof(RightToLeftInternal), 
                BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField)!;
        }
        return (bool)_piRTL.GetValue(this, null)!;
    }
}

Good RTL Support (60-79%)

4. KryptonComboBox - 75% RTL Support

  • Location: KryptonComboBox.cs
  • Key Features:
    • RTL-aware text drawing with TextFormatFlags.RightToLeft
    • RTL-aware drop-down button positioning
    • Proper text alignment for RTL mode
    • RTL-aware layout adjustments
if (_kryptonComboBox.RightToLeft == RightToLeft.Yes)
{
    dropRect = new Rectangle(rect.left + borderSize.Width + 1, rect.top + 1, 
        dropDownWidth - 2, rect.bottom - rect.top - 2);
    rect.left += borderSize.Width + dropDownWidth;
    rect.right -= borderSize.Width;
}
else
{
    rect.left += borderSize.Width;
    rect.right -= borderSize.Width + dropDownWidth;
    dropRect = new Rectangle(rect.right + 1, rect.top + 1, 
        dropDownWidth - 2, rect.bottom - rect.top - 2);
}

5. KryptonSplitContainer - 70% RTL Support

  • Location: KryptonSplitContainer.cs
  • Key Features:
    • RTL-aware splitter positioning
    • RTL-aware panel sizing calculations
    • Proper RTL layout adjustments
if (CommonHelper.GetRightToLeftLayout(this) && (RightToLeft == RightToLeft.Yes))
{
    before = Panel2MinSize;
    after = Panel1MinSize;
}
else
{
    before = Panel1MinSize;
    after = Panel2MinSize;
}

6. KryptonTreeView - 65% RTL Support

  • Location: KryptonTreeView.cs
  • Key Features:
    • RightToLeftLayout property with change events
    • RTL-aware tree node positioning
    • Proper RTL event handling

7. KryptonListView - 60% RTL Support

  • Location: KryptonListView.cs
  • Key Features:
    • RightToLeftLayout property implementation
    • Basic RTL layout support

⚠️ Basic RTL Support (30-59%)

8. KryptonTextBox - 55% RTL Support

  • Location: KryptonTextBox.cs
  • Key Features:
    • RTL-aware text alignment
    • Basic RTL text direction support
    • Missing: RTL-aware content positioning
stringFormat.Alignment = _kryptonTextBox.TextAlign switch
{
    HorizontalAlignment.Left => RightToLeft == RightToLeft.Yes
        ? StringAlignment.Far
        : StringAlignment.Near,
    HorizontalAlignment.Right => RightToLeft == RightToLeft.Yes
        ? StringAlignment.Near
        : StringAlignment.Far,
    HorizontalAlignment.Center => StringAlignment.Center,
    _ => stringFormat.Alignment
};

9. KryptonMaskedTextBox - 50% RTL Support

  • Location: KryptonMaskedTextBox.cs
  • Key Features:
    • Similar RTL support to KryptonTextBox
    • RTL-aware text alignment
    • Missing: RTL-aware mask handling

10. KryptonProgressBar - 45% RTL Support

  • Location: KryptonProgressBar.cs
  • Key Features:
    • RTL-aware progress bar positioning
    • RTL-aware orientation handling
    • Missing: RTL-aware text positioning
if (RightToLeft == RightToLeft.Yes)
{
    innerRect.X = ClientRectangle.Right - innerRect.Width;
}

11. KryptonRadioButton - 40% RTL Support

  • Location: KryptonRadioButton.cs
  • Key Features:
    • RTL-aware button positioning
    • RTL-aware orientation handling
    • Missing: RTL-aware content alignment
VisualOrientation.Bottom => RightToLeft == RightToLeft.Yes ? ViewDockStyle.Right : ViewDockStyle.Left,
_ => RightToLeft == RightToLeft.Yes ? ViewDockStyle.Left : ViewDockStyle.Right

12. KryptonCheckBox - 40% RTL Support

  • Location: KryptonCheckBox.cs
  • Key Features:
    • Similar RTL support to KryptonRadioButton
    • RTL-aware button positioning
    • Missing: RTL-aware content alignment

13. KryptonTrackBar - 35% RTL Support

  • Location: KryptonTrackBar.cs
  • Key Features:
    • Basic RTL property handling
    • RTL-aware track bar positioning
    • Missing: RTL-aware slider behavior
protected override void OnRightToLeftChanged(EventArgs e)
{
    _drawTrackBar.RightToLeft = RightToLeft;
    base.OnRightToLeftChanged(e);
}

Limited RTL Support (10-29%)

14. KryptonButton/KryptonDropButton - 25% RTL Support

  • Location: KryptonButton.cs, KryptonDropButton.cs
  • Current Status:
    • Inherits basic RTL support from VisualControlBase
    • No specific RTL-aware layout or positioning
    • Missing: RTL-aware button content alignment
    • Missing: RTL-aware button styling

15. KryptonPanel - 20% RTL Support

  • Location: KryptonPanel.cs
  • Current Status:
    • Inherits basic RTL support from VisualPanel
    • No specific RTL-aware layout adjustments
    • Missing: RTL-aware panel content positioning

16. KryptonLabel - 15% RTL Support

  • Location: KryptonLabel.cs
  • Current Status:
    • Inherits basic RTL support from VisualControlBase
    • Missing: RTL-aware text alignment
    • Missing: RTL-aware content positioning

17. KryptonGroupBox - 15% RTL Support

  • Location: KryptonGroupBox.cs
  • Current Status:
    • Inherits basic RTL support from VisualControlBase
    • Missing: RTL-aware group box layout
    • Missing: RTL-aware title positioning

18. KryptonPropertyGrid - 10% RTL Support

  • Location: KryptonPropertyGrid.cs
  • Current Status:
    • Only comment about RTL layout
    • Missing: RTL-aware property grid layout
    • Missing: RTL-aware property positioning

No RTL Support (0%)

19. KryptonMonthCalendar - 0% RTL Support

  • Location: KryptonMonthCalendar.cs
  • Missing Features:
    • RTL-aware calendar layout
    • RTL-aware date navigation
    • RTL-aware month/year positioning

20. KryptonRichTextBox - 0% RTL Support

  • Location: KryptonRichTextBox.cs
  • Missing Features:
    • RTL-aware rich text layout
    • RTL-aware text flow
    • RTL-aware content positioning

21. KryptonScrollBar - 0% RTL Support

  • Location: KryptonScrollBar.cs
  • Missing Features:
    • RTL-aware scroll bar positioning
    • RTL-aware scroll direction
    • RTL-aware scroll bar layout

22. KryptonNumericUpDown - 0% RTL Support

  • Location: KryptonNumericUpDown.cs
  • Missing Features:
    • RTL-aware up/down button positioning
    • RTL-aware number alignment
    • RTL-aware increment/decrement behavior

23. KryptonListBox - 0% RTL Support

  • Location: KryptonListBox.cs
  • Missing Features:
    • RTL-aware list item positioning
    • RTL-aware selection behavior
    • RTL-aware list layout

24. KryptonCheckedListBox - 0% RTL Support

  • Location: KryptonCheckedListBox.cs
  • Missing Features:
    • RTL-aware checkbox positioning
    • RTL-aware list item layout
    • RTL-aware selection behavior

25. KryptonDomainUpDown - 0% RTL Support

  • Location: KryptonDomainUpDown.cs
  • Missing Features:
    • RTL-aware domain item positioning
    • RTL-aware up/down button layout
    • RTL-aware text alignment

Control Categories Analysis

Text Input Controls

  • KryptonTextBox: 55% RTL support
  • KryptonMaskedTextBox: 50% RTL support
  • KryptonRichTextBox: 0% RTL support
  • KryptonComboBox: 75% RTL support
  • KryptonDomainUpDown: 0% RTL support
  • KryptonNumericUpDown: 0% RTL support

Selection Controls

  • KryptonListBox: 0% RTL support
  • KryptonCheckedListBox: 0% RTL support
  • KryptonTreeView: 65% RTL support
  • KryptonListView: 60% RTL support

Button Controls

  • KryptonButton: 25% RTL support
  • KryptonRadioButton: 40% RTL support
  • KryptonCheckBox: 40% RTL support

Container Controls

  • KryptonPanel: 20% RTL support
  • KryptonGroupBox: 15% RTL support
  • KryptonSplitContainer: 70% RTL support

Data Controls

  • KryptonDataGridView: 80% RTL support
  • KryptonPropertyGrid: 10% RTL support

Date/Time Controls

  • KryptonDateTimePicker: 85% RTL support
  • KryptonMonthCalendar: 0% RTL support

Progress Controls

  • KryptonProgressBar: 45% RTL support
  • KryptonTrackBar: 35% RTL support
  • KryptonScrollBar: 0% RTL support

Display Controls

  • KryptonLabel: 15% RTL support
  • KryptonForm: 95% RTL support

Key Findings

Strengths:

  1. Excellent RTL Infrastructure - Base classes provide solid RTL foundation
  2. Comprehensive RTL Support in Key Controls - Form, DataGridView, DateTimePicker have excellent RTL support
  3. Consistent RTL Patterns - Most controls follow established RTL implementation patterns
  4. Good RTL Testing - RTL test forms exist for verification

Critical Gaps:

  1. Missing RTL Support in Major Controls:

    • KryptonButton (25% support)
    • KryptonPanel (20% support)
    • KryptonLabel (15% support)
    • KryptonGroupBox (15% support)
  2. No RTL Support in Important Controls:

    • KryptonMonthCalendar (0% support)
    • KryptonRichTextBox (0% support)
    • KryptonScrollBar (0% support)
    • KryptonListBox (0% support)
  3. Inconsistent RTL Implementation:

    • Some controls have comprehensive RTL support
    • Others have minimal or no RTL support
    • No standardized approach across all controls

Recommendations

High Priority (Immediate Action Required):

  1. Implement RTL Support in KryptonButton:

    // Add RTL-aware button content layout
    private void ApplyRTLToButton()
    {
        if (RightToLeft == RightToLeft.Yes)
        {
            // Adjust text and image positioning
            AdjustButtonContentPositioning();
            // Reverse button content alignment
            ReverseButtonContentAlignment();
            // Mirror button layout
            MirrorButtonLayout();
        }
    }
  2. Implement RTL Support in KryptonPanel:

    // Add RTL-aware panel layout
    private void ApplyRTLToPanel()
    {
        if (RightToLeft == RightToLeft.Yes && RightToLeftLayout)
        {
            // Reverse panel content positioning
            ReversePanelContentPositioning();
            // Adjust panel layout direction
            AdjustPanelLayoutDirection();
        }
    }
  3. Implement RTL Support in KryptonLabel:

    // Add RTL-aware label text alignment
    private void ApplyRTLToLabel()
    {
        if (RightToLeft == RightToLeft.Yes)
        {
            // Adjust text alignment for RTL
            AdjustLabelTextAlignment();
            // Mirror label content
            MirrorLabelContent();
        }
    }

Medium Priority:

  1. Implement RTL Support in KryptonMonthCalendar:

    • RTL-aware calendar layout
    • RTL-aware date navigation
    • RTL-aware month/year positioning
  2. Implement RTL Support in KryptonRichTextBox:

    • RTL-aware rich text layout
    • RTL-aware text flow
    • RTL-aware content positioning
  3. Implement RTL Support in KryptonListBox:

    • RTL-aware list item positioning
    • RTL-aware selection behavior
    • RTL-aware list layout

Low Priority:

  1. Standardize RTL Implementation:

    • Create common RTL helper classes
    • Implement consistent RTL property handling
    • Add RTL-aware layout base classes
  2. Enhance RTL Testing:

    • Add comprehensive RTL test cases
    • Test all controls in RTL mode
    • Verify RTL behavior across different themes

Implementation Strategy

Phase 1: Critical Controls (Weeks 1-4)

  • Implement RTL support in KryptonButton
  • Implement RTL support in KryptonPanel
  • Implement RTL support in KryptonLabel
  • Implement RTL support in KryptonGroupBox

Phase 2: Important Controls (Weeks 5-8)

  • Implement RTL support in KryptonMonthCalendar
  • Implement RTL support in KryptonRichTextBox
  • Implement RTL support in KryptonListBox
  • Implement RTL support in KryptonScrollBar

Phase 3: Remaining Controls (Weeks 9-12)

  • Implement RTL support in remaining controls
  • Standardize RTL implementation across all controls
  • Comprehensive testing and documentation

Success Metrics

  • RTL Implementation Coverage: Target 90% (currently 35%)
  • RTL Test Coverage: Target 85% (currently 25%)
  • RTL Performance: No more than 10% performance impact
  • RTL Compatibility: 100% with major RTL languages

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:toolkitAll issues related to the toolkit components.enhancementNew feature or requestversion:110All things to do with V110.✨ new featureA new feature has been requested.💡 suggestionA suggestion has been requested.

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions