diff --git a/uppsrc/CtrlCore/Ctrl.cpp b/uppsrc/CtrlCore/Ctrl.cpp index 4850dc426..cfa46034c 100644 --- a/uppsrc/CtrlCore/Ctrl.cpp +++ b/uppsrc/CtrlCore/Ctrl.cpp @@ -1081,4 +1081,16 @@ int Ctrl::GetExitCode() const return exitcode; } +#ifdef HAS_TopFrameDraw + +ViewDraw::ViewDraw(Ctrl *ctrl, const Rect& r) +: TopFrameDraw(ctrl, (ctrl->GetScreenView() & (r + ctrl->GetScreenView().TopLeft())) + - ctrl->GetTopCtrl()->GetScreenRect().TopLeft()) +{ + Point p = r.TopLeft(); + Offset(min(p.x, 0), min(p.y, 0)); +} + +#endif + } diff --git a/uppsrc/CtrlCore/CtrlCore.h b/uppsrc/CtrlCore/CtrlCore.h index 3b24b82b1..485269386 100644 --- a/uppsrc/CtrlCore/CtrlCore.h +++ b/uppsrc/CtrlCore/CtrlCore.h @@ -1665,6 +1665,16 @@ T *Ctrl::GetAscendant() const return NULL; } +#ifdef HAS_TopFrameDraw + +struct ViewDraw : public TopFrameDraw { + ViewDraw(Ctrl *ctrl, const Rect& r); + ViewDraw(Ctrl *ctrl) : ViewDraw(ctrl, ctrl->GetSize()) {} + ViewDraw(Ctrl *ctrl, int x, int y, int cx, int cy) : ViewDraw(ctrl, RectC(x, y, cx, cy)) {} +}; + +#endif + } #endif diff --git a/uppsrc/CtrlCore/Gtk.h b/uppsrc/CtrlCore/Gtk.h index 7ad2b125f..0c024ac1d 100644 --- a/uppsrc/CtrlCore/Gtk.h +++ b/uppsrc/CtrlCore/Gtk.h @@ -75,7 +75,7 @@ private: friend class ImageDraw; friend class BackDraw; - friend class ViewDraw; + friend class TopFrameDraw; Rect GetClip() const; void FlushText(); @@ -210,3 +210,5 @@ int rmsecs(); } #define GUIPLATFORM_INCLUDE_AFTER + +#define HAS_TopFrameDraw diff --git a/uppsrc/CtrlCore/GtkAfter.h b/uppsrc/CtrlCore/GtkAfter.h index d777a2815..6ead01d55 100644 --- a/uppsrc/CtrlCore/GtkAfter.h +++ b/uppsrc/CtrlCore/GtkAfter.h @@ -1,10 +1,10 @@ -class ViewDraw : public SystemDraw { +class TopFrameDraw : public SystemDraw { #if GTK_CHECK_VERSION(3, 22, 0) GdkDrawingContext *ctx; #endif public: - ViewDraw(Ctrl *ctrl); - ~ViewDraw(); + TopFrameDraw(Ctrl *ctrl, const Rect& r); + ~TopFrameDraw(); }; void DrawDragRect(Ctrl& q, const DrawDragRectInfo& f); diff --git a/uppsrc/CtrlCore/GtkWnd.cpp b/uppsrc/CtrlCore/GtkWnd.cpp index d07251a8c..83611627d 100644 --- a/uppsrc/CtrlCore/GtkWnd.cpp +++ b/uppsrc/CtrlCore/GtkWnd.cpp @@ -516,15 +516,17 @@ Rect Ctrl::GetDefaultWindowRect() return RectC(r.left + pos + 20, r.top + pos + 20, cx, cy); } -ViewDraw::ViewDraw(Ctrl *ctrl) +TopFrameDraw::TopFrameDraw(Ctrl *ctrl, const Rect& r) { EnterGuiMutex(); Ctrl *top = ctrl->GetTopCtrl(); #if GTK_CHECK_VERSION(3, 22, 0) - cairo_rectangle_int_t r; - r.x = r.y = 0; - r.width = r.height = 100000; - cairo_region_t *rg = cairo_region_create_rectangle(&r); + cairo_rectangle_int_t rr; + rr.x = Ctrl::LSC(r.left); + rr.y = Ctrl::LSC(r.top); + rr.width = Ctrl::LSC(r.GetWidth()); + rr.height = Ctrl::LSC(r.GetHeight()); + cairo_region_t *rg = cairo_region_create_rectangle(&rr); ctx = gdk_window_begin_draw_frame(top->gdk(), rg); cairo_region_destroy(rg); cr = gdk_drawing_context_get_cairo_context(ctx); @@ -532,10 +534,10 @@ ViewDraw::ViewDraw(Ctrl *ctrl) cr = gdk_cairo_create(top->gdk()); #endif cairo_scale(cr, Ctrl::LSC(1), Ctrl::LSC(1)); - Clipoff(ctrl->GetScreenView() - top->GetScreenRect().TopLeft()); + Clipoff(r); } -ViewDraw::~ViewDraw() +TopFrameDraw::~TopFrameDraw() { FlushText(); #if GTK_CHECK_VERSION(3, 22, 0) diff --git a/uppsrc/CtrlCore/X11Gui.h b/uppsrc/CtrlCore/X11Gui.h index e731b4aa5..bfebcc257 100644 --- a/uppsrc/CtrlCore/X11Gui.h +++ b/uppsrc/CtrlCore/X11Gui.h @@ -121,7 +121,7 @@ private: friend class ImageDraw; friend class FontInfo; friend class Font; - friend class ViewDraw; + friend class TopFrameDraw; friend void StaticExitDraw_(); friend Font StdFont(); @@ -259,4 +259,6 @@ Index& _NET_Supported(); #define GUIPLATFORM_INCLUDE_AFTER "X11GuiA.h" +#define HAS_TopFrameDraw + } diff --git a/uppsrc/CtrlCore/X11GuiA.h b/uppsrc/CtrlCore/X11GuiA.h index e99cfc923..c64c91105 100644 --- a/uppsrc/CtrlCore/X11GuiA.h +++ b/uppsrc/CtrlCore/X11GuiA.h @@ -1,7 +1,7 @@ -class ViewDraw : public SystemDraw { +class TopFrameDraw : public SystemDraw { public: - ViewDraw(Ctrl *ctrl); - ~ViewDraw(); + TopFrameDraw(Ctrl *ctrl, const Rect& r); + ~TopFrameDraw(); protected: bool caret; diff --git a/uppsrc/CtrlCore/X11Wnd.cpp b/uppsrc/CtrlCore/X11Wnd.cpp index 4eb0d4515..35f5a9fcd 100644 --- a/uppsrc/CtrlCore/X11Wnd.cpp +++ b/uppsrc/CtrlCore/X11Wnd.cpp @@ -1115,11 +1115,10 @@ void Ctrl::SyncNativeWindows(void) // 01/12/2007 - END -ViewDraw::ViewDraw(Ctrl *ctrl) +TopFrameDraw::TopFrameDraw(Ctrl *ctrl, const Rect& r) { EnterGuiMutex(); Ctrl *top = ctrl->GetTopCtrl(); - Rect r = ctrl->GetScreenView() - top->GetScreenRect().TopLeft(); Vector clip; clip.Add(r); dw = top->GetWindow(); @@ -1129,7 +1128,7 @@ ViewDraw::ViewDraw(Ctrl *ctrl) Init(clip, r.TopLeft()); } -ViewDraw::~ViewDraw() +TopFrameDraw::~TopFrameDraw() { XFreeGC(Xdisplay, gc); LeaveGuiMutex(); diff --git a/uppsrc/Painter/Painter.h b/uppsrc/Painter/Painter.h index 80aea1ed8..5ef926a09 100644 --- a/uppsrc/Painter/Painter.h +++ b/uppsrc/Painter/Painter.h @@ -382,6 +382,7 @@ class DrawPainter : public ImagePainter { public: DrawPainter(Draw& w, Size sz, int mode = MODE_ANTIALIASED); + DrawPainter(Draw& w, int cx, int cy, int mode = MODE_ANTIALIASED) : DrawPainter(w, Size(cx, cy), mode) {} ~DrawPainter(); };