diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:22:36 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:22:36 +0200 |
commit | ecb1524f8da7901338b263384fed3c612f117b4c (patch) | |
tree | e7e06423fe27ea5ab45f27fc4b39ae597ba72490 /wx+/rtl.h | |
parent | 5.10 (diff) | |
download | FreeFileSync-ecb1524f8da7901338b263384fed3c612f117b4c.tar.gz FreeFileSync-ecb1524f8da7901338b263384fed3c612f117b4c.tar.bz2 FreeFileSync-ecb1524f8da7901338b263384fed3c612f117b4c.zip |
5.11
Diffstat (limited to 'wx+/rtl.h')
-rw-r--r-- | wx+/rtl.h | 57 |
1 files changed, 55 insertions, 2 deletions
@@ -13,6 +13,7 @@ #include <wx/image.h> #include <wx/icon.h> #include <wx/app.h> +#include <wx/dcbuffer.h> //for macro: wxALWAYS_NATIVE_DOUBLE_BUFFER namespace zen { @@ -30,15 +31,25 @@ void drawBitmapRtlNoMirror(wxDC& dc, //wxDC::DrawLabel does already NOT mirror int alignment, std::unique_ptr<wxBitmap>& buffer); -void drawIconRtlNoMirror(wxDC& dc, - const wxIcon& icon, //wxDC::DrawIcon DOES mirror by default +void drawIconRtlNoMirror(wxDC& dc, //wxDC::DrawIcon DOES mirror by default + const wxIcon& icon, const wxPoint& pt, std::unique_ptr<wxBitmap>& buffer); wxBitmap mirrorIfRtl(const wxBitmap& bmp); +/* +class BufferedPaintDC +{ +public: + BufferedPaintDC(wxWindow& wnd, std::unique_ptr<wxBitmap>& buffer); +}; +*/ +//a fix for a poor wxWidgets implementation (wxAutoBufferedPaintDC skips one pixel on left side when RTL layout is active) + +//manual text flow correction: http://www.w3.org/International/articles/inline-bidi-markup/ @@ -116,6 +127,48 @@ wxBitmap mirrorIfRtl(const wxBitmap& bmp) else return bmp; } + + +#ifndef wxALWAYS_NATIVE_DOUBLE_BUFFER +#error we need this one! +#endif + +#if wxALWAYS_NATIVE_DOUBLE_BUFFER +struct BufferedPaintDC : public wxPaintDC { BufferedPaintDC(wxWindow& wnd, std::unique_ptr<wxBitmap>& buffer) : wxPaintDC(&wnd) {} }; + +#else +class BufferedPaintDC : public wxMemoryDC +{ +public: + BufferedPaintDC(wxWindow& wnd, std::unique_ptr<wxBitmap>& buffer) : buffer_(buffer), paintDc(&wnd) + { + const wxSize clientSize = wnd.GetClientSize(); + if (!buffer_ || clientSize != wxSize(buffer->GetWidth(), buffer->GetHeight())) + buffer.reset(new wxBitmap(clientSize.GetWidth(), clientSize.GetHeight())); + + SelectObject(*buffer); + + if (paintDc.IsOk() && paintDc.GetLayoutDirection() == wxLayout_RightToLeft) + SetLayoutDirection(wxLayout_RightToLeft); + } + + ~BufferedPaintDC() + { + if (GetLayoutDirection() == wxLayout_RightToLeft) + { + paintDc.SetLayoutDirection(wxLayout_LeftToRight); //workaround bug in wxDC::Blit() + SetLayoutDirection(wxLayout_LeftToRight); // + } + + const wxPoint origin = GetDeviceOrigin(); + paintDc.Blit(0, 0, buffer_->GetWidth(), buffer_->GetHeight(), this, -origin.x, -origin.y); + } + +private: + std::unique_ptr<wxBitmap>& buffer_; + wxPaintDC paintDc; +}; +#endif } #endif //RTL_H_0183487180058718273432148 |