From ea87ffd7d0f9b56a16f7b3bdb4a3317d1dc75107 Mon Sep 17 00:00:00 2001 From: SinghRajenM Date: Wed, 26 Apr 2017 01:35:33 +0530 Subject: [PATCH] Support RTL for header & footer printing Closes #3208 --- PowerEditor/src/Notepad_plus.cpp | 2 +- PowerEditor/src/ScitillaComponent/Printer.cpp | 9 +++++---- PowerEditor/src/ScitillaComponent/Printer.h | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 41e0edfc9..d13b3bc92 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -1810,7 +1810,7 @@ void Notepad_plus::filePrint(bool showDialog) int startPos = int(_pEditView->execute(SCI_GETSELECTIONSTART)); int endPos = int(_pEditView->execute(SCI_GETSELECTIONEND)); - printer.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), _pEditView, showDialog, startPos, endPos); + printer.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), _pEditView, showDialog, startPos, endPos, _nativeLangSpeaker.isRTL()); printer.doPrint(); } diff --git a/PowerEditor/src/ScitillaComponent/Printer.cpp b/PowerEditor/src/ScitillaComponent/Printer.cpp index f823246f3..f663b2054 100644 --- a/PowerEditor/src/ScitillaComponent/Printer.cpp +++ b/PowerEditor/src/ScitillaComponent/Printer.cpp @@ -38,7 +38,7 @@ void replaceStr(generic_string & str, generic_string str2BeReplaced, generic_str str.replace(pos, str2BeReplaced.length(), replacement); } -void Printer::init(HINSTANCE hInst, HWND hwnd, ScintillaEditView *pSEView, bool showDialog, int startPos, int endPos) +void Printer::init(HINSTANCE hInst, HWND hwnd, ScintillaEditView *pSEView, bool showDialog, int startPos, int endPos, bool isRTL) { _pSEView = pSEView; _startPos = startPos; @@ -72,6 +72,7 @@ void Printer::init(HINSTANCE hInst, HWND hwnd, ScintillaEditView *pSEView, bool // Don't display dialog box, just use the default printer and options _pdlg.Flags |= PD_RETURNDEFAULT; } + _isRTL = isRTL; } @@ -342,6 +343,7 @@ size_t Printer::doPrint(bool justDoIt) size_t pageNum = 1; const TCHAR pageVar[] = TEXT("$(CURRENT_PRINTING_PAGE)"); + _pSEView->execute(SCI_SETPRINTCOLOURMODE, nppGUI._printSettings._printOption); // setting mode once is enough while (lengthPrinted < lengthDoc) { bool printPage = (!(_pdlg.Flags & PD_PAGENUMS) || @@ -364,7 +366,7 @@ size_t Printer::doPrint(bool justDoIt) ::SetTextColor(_pdlg.hDC, RGB(0, 0, 0)); ::SetBkColor(_pdlg.hDC, RGB(255, 255, 255)); - UINT oldTASettings = ::SetTextAlign(_pdlg.hDC, TA_BOTTOM); + UINT oldTASettings = ::SetTextAlign(_pdlg.hDC, _isRTL ? TA_RTLREADING | TA_BOTTOM : TA_BOTTOM); RECT rcw = {frPrint.rc.left, frPrint.rc.top - headerLineHeight - headerLineHeight / 2, frPrint.rc.right, frPrint.rc.top - headerLineHeight / 2}; rcw.bottom = rcw.top + headerLineHeight; @@ -422,7 +424,6 @@ size_t Printer::doPrint(bool justDoIt) frPrint.chrg.cpMin = lengthPrinted; frPrint.chrg.cpMax = lengthDoc; - _pSEView->execute(SCI_SETPRINTCOLOURMODE, nppGUI._printSettings._printOption); lengthPrinted = long(_pSEView->execute(SCI_FORMATRANGE, printPage, reinterpret_cast(&frPrint))); if (printPage) @@ -434,7 +435,7 @@ size_t Printer::doPrint(bool justDoIt) ::SetTextColor(_pdlg.hDC, RGB(0, 0, 0)); ::SetBkColor(_pdlg.hDC, RGB(255, 255, 255)); - UINT oldta = ::SetTextAlign(_pdlg.hDC, TA_TOP); + UINT oldta = ::SetTextAlign(_pdlg.hDC, _isRTL ? TA_RTLREADING | TA_TOP : TA_TOP); RECT rcw = {frPrint.rc.left, frPrint.rc.bottom + footerLineHeight / 2, frPrint.rc.right, frPrint.rc.bottom + footerLineHeight + footerLineHeight / 2}; diff --git a/PowerEditor/src/ScitillaComponent/Printer.h b/PowerEditor/src/ScitillaComponent/Printer.h index 6f0fbc1d2..6bae2834f 100644 --- a/PowerEditor/src/ScitillaComponent/Printer.h +++ b/PowerEditor/src/ScitillaComponent/Printer.h @@ -46,7 +46,7 @@ class Printer { public : Printer(){}; - void init(HINSTANCE hInst, HWND hwnd, ScintillaEditView *pSEView, bool showDialog, int startPos, int endPos); + void init(HINSTANCE hInst, HWND hwnd, ScintillaEditView *pSEView, bool showDialog, int startPos, int endPos, bool isRTL = false); size_t doPrint() { if (!::PrintDlg(&_pdlg)) return 0; @@ -61,6 +61,7 @@ private : size_t _startPos = 0; size_t _endPos = 0; size_t _nbPageTotal =0; + bool _isRTL = false; }; #endif //PRINTER_H