diff --git a/uppsrc/CtrlLib/Static.cpp b/uppsrc/CtrlLib/Static.cpp index 00d3cb37a..40029e200 100644 --- a/uppsrc/CtrlLib/Static.cpp +++ b/uppsrc/CtrlLib/Static.cpp @@ -245,9 +245,18 @@ Size ImageCtrl::GetMinSize() const return img.GetSize(); } + +Picture& Picture::Background(Color color) +{ + background = color; + Transparent(IsNull(color)); + Refresh(); + return *this; +} + void Picture::Paint(Draw& w) { Size sz = GetSize(); - w.DrawRect(0, 0, sz.cx, sz.cy, background); +_DBG_ // w.DrawRect(0, 0, sz.cx, sz.cy, background); if(!picture) return; int dx = 0; int dy = 0; diff --git a/uppsrc/CtrlLib/StaticCtrl.h b/uppsrc/CtrlLib/StaticCtrl.h index a9db4bf64..f3cb11322 100644 --- a/uppsrc/CtrlLib/StaticCtrl.h +++ b/uppsrc/CtrlLib/StaticCtrl.h @@ -127,12 +127,13 @@ protected: public: Drawing Get() const { return picture; } - Picture& Background(Color color) { background = color; Refresh(); return *this; } + Picture& Background(Color color); Picture& KeepRatio(bool keep = true) { ratio = keep; Refresh(); return *this; } Picture& NoKeepRatio() { return KeepRatio(false); } Picture& Set(const Drawing& _picture) { picture = _picture; Refresh(); return *this; } Picture& operator=(const Drawing& _picture) { return Set(_picture); } + Picture& operator=(const Painting& _picture) { return Set(AsDrawing(_picture)); } Picture(); }; diff --git a/uppsrc/CtrlLib/src.tpp/Static$en-us.tpp b/uppsrc/CtrlLib/src.tpp/Static$en-us.tpp index 7d6101938..7bab831a5 100644 --- a/uppsrc/CtrlLib/src.tpp/Static$en-us.tpp +++ b/uppsrc/CtrlLib/src.tpp/Static$en-us.tpp @@ -155,6 +155,10 @@ olor]_[*@3 color])&] [s2; Sets background [%-*@3 color]. Default is white.&] [s3; &] [s4;%- &] +[s5;:Picture`:`:Get`(`)const:%- [_^Drawing^ Drawing]_[* Get]()_[@(0.0.255) const]&] +[s2; Returns Drawing assigned to Picture.&] +[s3;%- &] +[s4;%- &] [s5;:Picture`:`:KeepRatio`(bool`):%- [_^Picture^ Picture][@(0.0.255) `&]_[* KeepRatio]([@(0.0.255) b ool]_[*@3 keep]_`=_[@(0.0.255) true])&] [s2; If active, Picture keeps the aspect ratio of Drawing. Default @@ -171,6 +175,10 @@ onst]_[_^Drawing^ Drawing][@(0.0.255) `&]_[*@3 `_picture])&] rator`=]([@(0.0.255) const]_[_^Drawing^ Drawing][@(0.0.255) `&]_[*@3 `_picture])&] [s2; Assigns the Drawing.&] [s3; &] +[s4;%- &] +[s5;:Picture`:`:operator`=`(const Painting`&`):%- [_^Picture^ Picture][@(0.0.255) `&]_[* op +erator`=]([@(0.0.255) const]_[_^Painting^ Painting][@(0.0.255) `&]_[*@3 `_picture])&] +[s2; Assigns [%-*@3 `_picture], converted to Drawing.&] [s0; &] [s0; &] [s0;%- &] @@ -210,4 +218,4 @@ is a simple structure with two fields:&] [s7; [*@5 l1]-|the first margin&] [s7;%- [*@5 l2]-|the second margin&] [s3; &] -[s0; ] \ No newline at end of file +[s0; ]] \ No newline at end of file diff --git a/uppsrc/Draw/Draw.cpp b/uppsrc/Draw/Draw.cpp index 4f036a9e0..94a628d36 100644 --- a/uppsrc/Draw/Draw.cpp +++ b/uppsrc/Draw/Draw.cpp @@ -401,7 +401,7 @@ void Draw::DrawPaintingOp(const Rect& target, const Painting& pw) while(yy < sz.cy) { int ccy = min(sz.cy - yy, 100); ImageBuffer ib(sz.cx, ccy); - Fill(~ib, White(), ib.GetLength()); + Fill(~ib, IsPrinter() ? White() : Null, ib.GetLength()); PaintImageBuffer(ib, pw, sz, Point(0, yy), true); DrawImageBandRLE(*this, target.left, target.top + yy, ib, 16); yy += ccy; @@ -409,7 +409,7 @@ void Draw::DrawPaintingOp(const Rect& target, const Painting& pw) } else { ImageBuffer ib(sz); - Fill(~ib, IsPrinter() ? White() : SColorPaper(), ib.GetLength()); + Fill(~ib, IsPrinter() ? White() : Null, ib.GetLength()); PaintImageBuffer(ib, pw, sz, Point(0, 0), IsPrinter()); DrawImage(target.left, target.top, ib); } diff --git a/uppsrc/Draw/Draw.h b/uppsrc/Draw/Draw.h index 87a52b01f..47f3556b1 100644 --- a/uppsrc/Draw/Draw.h +++ b/uppsrc/Draw/Draw.h @@ -373,6 +373,8 @@ void SColorDkShadow_Write(Color c); inline Color InvertColor() { return Color(255, 0); } inline Color DefaultInk() { return Black(); } //TODO! +Drawing AsDrawing(const Painting& pw); + class Painting : public ValueType > { String cmd; ValueArray data; diff --git a/uppsrc/Painter/Painting.cpp b/uppsrc/Painter/Painting.cpp index ac6acb6a7..c00f60277 100644 --- a/uppsrc/Painter/Painting.cpp +++ b/uppsrc/Painter/Painting.cpp @@ -290,4 +290,12 @@ void PaintingPainter::Create(Sizef sz) Create(sz.cx, sz.cy); } +Drawing AsDrawing(const Painting& pw) +{ + Size sz = pw.GetSize(); + DrawingDraw dw(sz); + dw.DrawPainting(sz, pw); + return dw.GetResult(); +} + END_UPP_NAMESPACE diff --git a/uppsrc/RichText/Object.cpp b/uppsrc/RichText/Object.cpp index 91a19419e..81d262669 100644 --- a/uppsrc/RichText/Object.cpp +++ b/uppsrc/RichText/Object.cpp @@ -376,14 +376,6 @@ void RichObjectTypeDrawingCls::Paint(const Value& data, Draw& w, Size sz) const w.DrawDrawing(Rect(sz), ValueTo(data).drawing); } -Drawing AsDrawing(const Painting& pw) -{ - Size sz = pw.GetSize(); - DrawingDraw dw(sz); - dw.DrawPainting(sz, pw); - return dw.GetResult(); -} - RichObject CreatePaintingObject(const Painting& pw, Size dot_size, Size out_size) { return CreateDrawingObject(AsDrawing(pw), dot_size, out_size);