From 164ad3375379f261fe3abed23846b39c3e798a9b Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Mon, 12 May 2014 08:02:56 -0700 Subject: [PATCH] Fix RTL painting of the subtitles grid wx comes very close to just making it work automatically, but it doesn't translate the origin to the top-right corner and wxBufferedPaintDC doesn't handle RTL at all, so reimplement it with some hacks. Closes #1354. --- src/base_grid.cpp | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/base_grid.cpp b/src/base_grid.cpp index 89ddb004a..a36902ffa 100644 --- a/src/base_grid.cpp +++ b/src/base_grid.cpp @@ -59,6 +59,39 @@ #include #include +namespace { +#ifdef __WXMSW__ +class PaintDC : public wxBufferedDC { + wxPaintDC dc; + +public: + PaintDC(wxWindow *window) : dc(window) { + dc.SetLayoutDirection(wxLayout_LeftToRight); + Init(&dc, window->GetClientSize(), 0); + if (window->GetLayoutDirection() == wxLayout_RightToLeft) { + SetLayoutDirection(wxLayout_RightToLeft); + SetLogicalOrigin(GetSize().GetWidth(), 0); + } + } + + ~PaintDC() { + SetLayoutDirection(wxLayout_LeftToRight); + SetLogicalOrigin(0, 0); + UnMask(); + } + + void Clear() { + auto origin = GetLogicalOrigin(); + SetLogicalOrigin(0, 0); + wxBufferedDC::Clear(); + SetLogicalOrigin(origin.x, origin.y); + } +}; +#else +typedef wxAutoBufferedPaintDC PaintDC; +#endif +} + enum { GRID_SCROLLBAR = 1730, MENU_SHOW_COL = 1250 // Needs 15 IDs after this @@ -279,7 +312,7 @@ void BaseGrid::OnPaint(wxPaintEvent &) { GetClientSize(&w,&h); w -= scrollBar->GetSize().GetWidth(); - wxAutoBufferedPaintDC dc(this); + PaintDC dc(this); dc.SetFont(font); dc.SetBackground(row_colors.Default);