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.
This commit is contained in:
Thomas Goyne 2014-05-12 08:02:56 -07:00
parent 0909d137b0
commit 164ad33753

View file

@ -59,6 +59,39 @@
#include <wx/scrolbar.h> #include <wx/scrolbar.h>
#include <wx/sizer.h> #include <wx/sizer.h>
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 { enum {
GRID_SCROLLBAR = 1730, GRID_SCROLLBAR = 1730,
MENU_SHOW_COL = 1250 // Needs 15 IDs after this MENU_SHOW_COL = 1250 // Needs 15 IDs after this
@ -279,7 +312,7 @@ void BaseGrid::OnPaint(wxPaintEvent &) {
GetClientSize(&w,&h); GetClientSize(&w,&h);
w -= scrollBar->GetSize().GetWidth(); w -= scrollBar->GetSize().GetWidth();
wxAutoBufferedPaintDC dc(this); PaintDC dc(this);
dc.SetFont(font); dc.SetFont(font);
dc.SetBackground(row_colors.Default); dc.SetBackground(row_colors.Default);