Skip to content

Commit

Permalink
Revert "Use GraphicsContext with wxDC API (#746)"
Browse files Browse the repository at this point in the history
This reverts commit 8653e07.
  • Loading branch information
tobiolo committed Nov 4, 2024
1 parent 867bc77 commit 866ecfd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
20 changes: 5 additions & 15 deletions src/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -610,20 +610,9 @@ struct Document {
curdrawroot->ColWidth(), 0);
}

void Draw(
#ifdef __WXMSW__
wxBufferedPaintDC
#else
wxPaintDC
#endif
&pdc) {
wxGraphicsContext *context = wxGraphicsContext::Create(pdc);
context->SetAntialiasMode(wxANTIALIAS_DEFAULT);
void Draw(wxDC &dc) {
redrawpending = false;
pdc.SetBackground(wxBrush(wxColor(Background())));
pdc.SetGraphicsContext(context);
wxDC &dc = static_cast<wxDC&>(pdc);
sw->DoPrepareDC(dc);
dc.SetBackground(wxBrush(wxColor(Background())));
dc.Clear();
if (!rootgrid) return;
sw->GetClientSize(&maxx, &maxy);
Expand Down Expand Up @@ -661,6 +650,7 @@ struct Document {
centery = sys->centered && !originy && maxy > layoutys
? (maxy - layoutys) / 2 * currentviewscale
: 0;
sw->DoPrepareDC(dc);
ShiftToCenter(dc);
Render(dc);
DrawSelect(dc, selected);
Expand Down Expand Up @@ -720,8 +710,8 @@ struct Document {
hover.g = nullptr;
redrawpending = true;
sys->UpdateStatus(selected);
#ifndef __WXMSW__
// wxWidgets on wxMAC and wxGTK does not always automatically update the scrollbar
#ifdef __WXGTK__
// wxWidgets (wxGTK) does not always automatically update the scrollbar
// to new canvas size and current position within after zoom so force it manually
int curx, cury;
sw->GetViewStart(&curx, &cury);
Expand Down
6 changes: 3 additions & 3 deletions src/mycanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ struct TSCanvas : public wxScrolledCanvas {
}

void OnPaint(wxPaintEvent &event) {
#ifdef __WXMSW__
#if defined(__WXMAC__) || defined(__WXGTK__)
wxPaintDC dc(this);
#else
auto sz = GetClientSize();
if (sz.GetX() <= 0 || sz.GetY() <= 0) return;
wxBitmap buffer(sz.GetX(), sz.GetY(), 24);
wxBufferedPaintDC dc(this, buffer);
#else
wxPaintDC dc(this);
#endif
// DoPrepareDC(dc);
doc->Draw(dc);
Expand Down
1 change: 0 additions & 1 deletion src/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include <wx/filename.h>
#include <wx/fontdlg.h>
#include <wx/fswatcher.h>
#include <wx/graphics.h>
#include <wx/ipc.h>
#include <wx/mstream.h>
#include <wx/notebook.h>
Expand Down

0 comments on commit 866ecfd

Please sign in to comment.