mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
+fix: try to fix printing scaling issue
This commit is contained in:
parent
15e5747a1e
commit
e38c8f283d
@ -1846,8 +1846,10 @@ Sci::Position Editor::FormatRange(Scintilla::Message iMessage, Scintilla::uptr_t
|
||||
if (iMessage == Message::FormatRange) {
|
||||
RangeToFormat *pfr = static_cast<RangeToFormat *>(ptr);
|
||||
CharacterRangeFull chrg{ pfr->chrg.cpMin,pfr->chrg.cpMax };
|
||||
AutoSurface surface(pfr->hdc, this, Technology::Default);
|
||||
AutoSurface surfaceMeasure(pfr->hdcTarget, this, Technology::Default);
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
AutoSurface surface(pfr->hdc, this, Technology::Default, true);
|
||||
AutoSurface surfaceMeasure(pfr->hdcTarget, this, Technology::Default, true);
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
if (!surface || !surfaceMeasure) {
|
||||
return 0;
|
||||
}
|
||||
@ -5767,15 +5769,17 @@ std::unique_ptr<Surface> Editor::CreateMeasurementSurface() const {
|
||||
return surf;
|
||||
}
|
||||
|
||||
std::unique_ptr<Surface> Editor::CreateDrawingSurface(SurfaceID sid, std::optional<Scintilla::Technology> technologyOpt) const {
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
std::unique_ptr<Surface> Editor::CreateDrawingSurface(SurfaceID sid, std::optional<Scintilla::Technology> technologyOpt, bool printing) const {
|
||||
if (!wMain.GetID()) {
|
||||
return {};
|
||||
}
|
||||
std::unique_ptr<Surface> surf = Surface::Allocate(technologyOpt ? *technologyOpt : technology);
|
||||
surf->Init(sid, wMain.GetID());
|
||||
surf->Init(sid, wMain.GetID(), printing);
|
||||
surf->SetMode(CurrentSurfaceMode());
|
||||
return surf;
|
||||
}
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
|
||||
Sci::Line Editor::WrapCount(Sci::Line line) {
|
||||
AutoSurface surface(this);
|
||||
@ -5903,7 +5907,7 @@ sptr_t Editor::StyleGetMessage(Message iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
// Added strike style, 2020-05-31
|
||||
case Message::StyleGetStrike:
|
||||
return vs.styles[wParam].strike ? 1 : 0;
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
case Message::StyleGetCase:
|
||||
return static_cast<int>(vs.styles[wParam].caseForce);
|
||||
case Message::StyleGetCharacterSet:
|
||||
@ -7087,13 +7091,13 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
case Message::GetIMEInteraction:
|
||||
return static_cast<sptr_t>(imeInteraction);
|
||||
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
case Message::IsIMEOpen:
|
||||
return static_cast<sptr_t>(imeIsOpen);
|
||||
|
||||
case Message::IsIMEModeCJK:
|
||||
return static_cast<sptr_t>(imeIsInModeCJK);
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
|
||||
case Message::SetBidirectional:
|
||||
// Message::SetBidirectional is implemented on platform subclasses if they support bidirectional text.
|
||||
|
||||
@ -599,7 +599,9 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
virtual std::string UTF8FromEncoded(std::string_view encoded) const = 0;
|
||||
virtual std::string EncodedFromUTF8(std::string_view utf8) const = 0;
|
||||
virtual std::unique_ptr<Surface> CreateMeasurementSurface() const;
|
||||
virtual std::unique_ptr<Surface> CreateDrawingSurface(SurfaceID sid, std::optional<Scintilla::Technology> technologyOpt = {}) const;
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
virtual std::unique_ptr<Surface> CreateDrawingSurface(SurfaceID sid, std::optional<Scintilla::Technology> technologyOpt = {}, bool printing = false) const;
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
|
||||
Sci::Line WrapCount(Sci::Line line);
|
||||
void AddStyledText(const char *buffer, Sci::Position appendLength);
|
||||
@ -695,9 +697,11 @@ public:
|
||||
AutoSurface(const Editor *ed) :
|
||||
surf(ed->CreateMeasurementSurface()) {
|
||||
}
|
||||
AutoSurface(SurfaceID sid, Editor *ed, std::optional<Scintilla::Technology> technology = {}) :
|
||||
surf(ed->CreateDrawingSurface(sid, technology)) {
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
AutoSurface(SurfaceID sid, Editor *ed, std::optional<Scintilla::Technology> technology = {}, bool printing = false) :
|
||||
surf(ed->CreateDrawingSurface(sid, technology, printing)) {
|
||||
}
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
// Deleted so AutoSurface objects can not be copied.
|
||||
AutoSurface(const AutoSurface &) = delete;
|
||||
AutoSurface(AutoSurface &&) = delete;
|
||||
|
||||
@ -199,7 +199,9 @@ public:
|
||||
static std::unique_ptr<Surface> Allocate(Scintilla::Technology technology);
|
||||
|
||||
virtual void Init(WindowID wid)=0;
|
||||
virtual void Init(SurfaceID sid, WindowID wid)=0;
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
virtual void Init(SurfaceID sid, WindowID wid, bool printing = false)=0;
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
virtual std::unique_ptr<Surface> AllocatePixMap(int width, int height)=0;
|
||||
|
||||
virtual void SetMode(SurfaceMode mode)=0;
|
||||
|
||||
@ -125,11 +125,11 @@ void LoadD2DOnce() noexcept {
|
||||
__uuidof(IDWriteFactory),
|
||||
reinterpret_cast<IUnknown**>(&pIDWriteFactory));
|
||||
}
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
if (SUCCEEDED(hr)) {
|
||||
pIDWriteFactory->GetGdiInterop(&gdiInterop);
|
||||
}
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
}
|
||||
}
|
||||
|
||||
@ -686,7 +686,9 @@ public:
|
||||
~SurfaceGDI() noexcept override;
|
||||
|
||||
void Init(WindowID wid) override;
|
||||
void Init(SurfaceID sid, WindowID wid) override;
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
void Init(SurfaceID sid, WindowID wid, bool printing = false) override;
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
std::unique_ptr<Surface> AllocatePixMap(int width, int height) override;
|
||||
|
||||
void SetMode(SurfaceMode mode_) override;
|
||||
@ -813,14 +815,16 @@ void SurfaceGDI::Init(WindowID wid) {
|
||||
logPixelsY = DpiForWindow(wid);
|
||||
}
|
||||
|
||||
void SurfaceGDI::Init(SurfaceID sid, WindowID wid) {
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
void SurfaceGDI::Init(SurfaceID sid, WindowID wid, bool printing) {
|
||||
Release();
|
||||
hdc = static_cast<HDC>(sid);
|
||||
::SetTextAlign(hdc, TA_BASELINE);
|
||||
// Windows on screen are scaled but printers are not.
|
||||
const bool printing = ::GetDeviceCaps(hdc, TECHNOLOGY) != DT_RASDISPLAY;
|
||||
//const bool printing = ::GetDeviceCaps(hdc, TECHNOLOGY) != DT_RASDISPLAY;
|
||||
logPixelsY = printing ? ::GetDeviceCaps(hdc, LOGPIXELSY) : DpiForWindow(wid);
|
||||
::SetTextAlign(hdc, TA_BASELINE);
|
||||
}
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
|
||||
std::unique_ptr<Surface> SurfaceGDI::AllocatePixMap(int width, int height) {
|
||||
return std::make_unique<SurfaceGDI>(hdc, width, height, mode, logPixelsY);
|
||||
@ -1517,7 +1521,9 @@ public:
|
||||
|
||||
void SetScale(WindowID wid) noexcept;
|
||||
void Init(WindowID wid) override;
|
||||
void Init(SurfaceID sid, WindowID wid) override;
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
void Init(SurfaceID sid, WindowID wid, bool printing = false) override;
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
std::unique_ptr<Surface> AllocatePixMap(int width, int height) override;
|
||||
|
||||
void SetMode(SurfaceMode mode_) override;
|
||||
@ -1647,11 +1653,14 @@ void SurfaceD2D::Init(WindowID wid) {
|
||||
SetScale(wid);
|
||||
}
|
||||
|
||||
void SurfaceD2D::Init(SurfaceID sid, WindowID wid) {
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
void SurfaceD2D::Init(SurfaceID sid, WindowID wid, bool /*printing*/) {
|
||||
Release();
|
||||
// printing always using GDI
|
||||
pRenderTarget = static_cast<ID2D1RenderTarget*>(sid);
|
||||
SetScale(wid);
|
||||
pRenderTarget = static_cast<ID2D1RenderTarget *>(sid);
|
||||
}
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
|
||||
std::unique_ptr<Surface> SurfaceD2D::AllocatePixMap(int width, int height) {
|
||||
std::unique_ptr<SurfaceD2D> surf = std::make_unique<SurfaceD2D>(pRenderTarget, width, height, mode, logPixelsY);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user