From d609960eb621fafc2ef9c3a525399e967e5d8323 Mon Sep 17 00:00:00 2001 From: Mirek Fidler Date: Thu, 20 Nov 2025 11:18:47 +0100 Subject: [PATCH] Draw: ChPaintImage -> Draw9Slice --- uppsrc/Draw/Cham.cpp | 11 ----------- uppsrc/Draw/Cham.h | 3 --- uppsrc/Draw/Draw.h | 3 +++ uppsrc/Draw/DrawUtil.cpp | 12 ++++++++++++ upptst/ChPaintImage/main.cpp | 2 +- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/uppsrc/Draw/Cham.cpp b/uppsrc/Draw/Cham.cpp index 8bd87cc31..465cb8e4a 100644 --- a/uppsrc/Draw/Cham.cpp +++ b/uppsrc/Draw/Cham.cpp @@ -300,17 +300,6 @@ Value ChLookFnImage(Draw& w, const Rect& r, const Image& img, int op, Color ink) return ChLookFnImage(w, r, img, op, ink, img.GetHotSpot(), img.Get2ndSpot()); } -void ChPaintImage(Draw& w, const Rect& r, const Image& img, Point p1, Point p2) -{ - ChLookFnImage(w, r, img, LOOK_PAINT, Null, p1, p2); -} - -void ChPaintImage(Draw& w, const Rect& r, const Image& img, int margin) -{ - Size sz = img.GetSize(); - ChPaintImage(w, r, img, Point(margin, margin), Point(sz.cx - margin - 1, sz.cy - margin - 1)); -} - Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op, Color ink) { if(IsType(v)) { diff --git a/uppsrc/Draw/Cham.h b/uppsrc/Draw/Cham.h index b7fcb2848..0a62eddaf 100644 --- a/uppsrc/Draw/Cham.h +++ b/uppsrc/Draw/Cham.h @@ -21,9 +21,6 @@ void ColoredOverride(Iml& target, Iml& source); void ChReset(); void ChFinish(); -void ChPaintImage(Draw& w, const Rect& r, const Image& img, Point p1, Point p2); -void ChPaintImage(Draw& w, const Rect& r, const Image& img, int margin); - void ChPaint(Draw& w, const Rect& r, const Value& look, Color ink = Null); void ChPaint(Draw& w, int x, int y, int cx, int cy, const Value& look, Color ink = Null); void ChPaintNoCache(Draw& w, int x, int y, int cx, int cy, const Value& look, Color ink = Null); diff --git a/uppsrc/Draw/Draw.h b/uppsrc/Draw/Draw.h index 7e3350289..745235a25 100644 --- a/uppsrc/Draw/Draw.h +++ b/uppsrc/Draw/Draw.h @@ -947,6 +947,9 @@ void DrawRectMinusRect(Draw& w, const Rect& rect, const Rect& inner, Color color void DrawHighlightImage(Draw& w, int x, int y, const Image& img, bool highlight = true, bool enabled = true, Color maskcolor = SColorPaper); +void Draw9Slice(Draw& w, const Rect& r, const Image& img, Point p1, Point p2); +void Draw9Slice(Draw& w, const Rect& r, const Image& img, int margin); + Color GradientColor(Color fc, Color tc, int i, int n); void DrawTextEllipsis(Draw& w, int x, int y, int cx, const char *text, const char *ellipsis, diff --git a/uppsrc/Draw/DrawUtil.cpp b/uppsrc/Draw/DrawUtil.cpp index 0d2353d7f..6a08a74d2 100644 --- a/uppsrc/Draw/DrawUtil.cpp +++ b/uppsrc/Draw/DrawUtil.cpp @@ -580,6 +580,18 @@ void DrawXPButton(Draw& w, Rect r, int type) } } +void Draw9Slice(Draw& w, const Rect& r, const Image& img, Point p1, Point p2) +{ + Value ChLookFnImage(Draw& w, const Rect& r, const Image& img, int op, Color ink, Point p, Point p2); + ChLookFnImage(w, r, img, LOOK_PAINT, Null, p1, p2); +} + +void Draw9Slice(Draw& w, const Rect& r, const Image& img, int margin) +{ + Size sz = img.GetSize(); + Draw9Slice(w, r, img, Point(margin, margin), Point(sz.cx - margin - 1, sz.cy - margin - 1)); +} + static DrawingToPdfFnType sPdf; static PdfDrawJPEGFnType sJpeg; diff --git a/upptst/ChPaintImage/main.cpp b/upptst/ChPaintImage/main.cpp index 2ced11b92..b3a5e8c16 100644 --- a/upptst/ChPaintImage/main.cpp +++ b/upptst/ChPaintImage/main.cpp @@ -5,7 +5,7 @@ using namespace Upp; struct MyApp : TopWindow { void Paint(Upp::Draw& w) override { w.DrawRect(GetSize(), White()); - ChPaintImage(w, RectC(100, 100, 100, 100), CtrlsImg::OkBh(), DPI(5)); + Draw9Slice(w, RectC(100, 100, 100, 100), CtrlsImg::OkBh(), DPI(5)); } };