diff --git a/uppsrc/RichEdit/DiagramEditor.cpp b/uppsrc/RichEdit/DiagramEditor.cpp index a6a3b14d3..2eccfc284 100644 --- a/uppsrc/RichEdit/DiagramEditor.cpp +++ b/uppsrc/RichEdit/DiagramEditor.cpp @@ -23,13 +23,13 @@ DiagramEditor::DiagramEditor() .NullImage(DiagramImg::InkNull()) .StaticImage(DiagramImg::InkA()); ink.Tip(t_("Line color")); - ink << [=] { SetAttrs(); }; + ink << [=] { SetAttrs(ATTR_INK); }; paper.ColorImage(DiagramImg::Paper()) .NullImage(DiagramImg::PaperNull()) .StaticImage(DiagramImg::PaperA()); paper.Tip(t_("Background color")); - paper << [=] { SetAttrs(); }; + paper << [=] { SetAttrs(ATTR_PAPER); }; int cy = GetStdFontCy(); @@ -53,7 +53,7 @@ DiagramEditor::DiagramEditor() m.shape = i; shape.Add(i, MakeImage(m)); } - shape << [=] { SetAttrs(); }; + shape << [=] { SetAttrs(ATTR_SHAPE); }; struct Dialine : DiagramItem { Dialine() { @@ -76,7 +76,7 @@ DiagramEditor::DiagramEditor() dl.Add(i, MakeImage(m)); } - dl << [=] { SetAttrs(); }; + dl << [=] { SetAttrs(ATTR_CAP0 + !left); }; }; LDL(line_start, true); @@ -87,11 +87,11 @@ DiagramEditor::DiagramEditor() m.dash = i; line_dash.Add(i, MakeImage(m)); } - line_dash << [=] { SetAttrs(); }; + line_dash << [=] { SetAttrs(ATTR_DASH); }; for(int i = 0; i < 10; i++) line_width.Add(i); - line_width << [=] { SetAttrs(); }; + line_width << [=] { SetAttrs(ATTR_WIDTH); }; ResetUndo(); Sync(); diff --git a/uppsrc/RichEdit/DiagramEditor.h b/uppsrc/RichEdit/DiagramEditor.h index c8010e102..a3e1676d4 100644 --- a/uppsrc/RichEdit/DiagramEditor.h +++ b/uppsrc/RichEdit/DiagramEditor.h @@ -105,7 +105,17 @@ private: void FixPositions(); - void SetAttrs(); + enum { + ATTR_SHAPE = 0x0001, + ATTR_CAP0 = 0x0002, + ATTR_CAP1 = 0x0004, + ATTR_WIDTH = 0x0008, + ATTR_DASH = 0x0010, + ATTR_INK = 0x0020, + ATTR_PAPER = 0x0040, + ATTR_ALL = 0xffffffff + }; + void SetAttrs(dword attr); void GetAttrs(); void Copy(); diff --git a/uppsrc/RichEdit/DiagramMouse.cpp b/uppsrc/RichEdit/DiagramMouse.cpp index 2744bc491..96660c17d 100644 --- a/uppsrc/RichEdit/DiagramMouse.cpp +++ b/uppsrc/RichEdit/DiagramMouse.cpp @@ -161,7 +161,7 @@ void DiagramEditor::MouseMove(Point p, dword keyflags) if(HasCapture() && IsCursor()) { DiagramItem& m = CursorItem(); if(grid) - p = m.IsLine() ? p / 16 * 16 : p / 8 * 8; + p = m.IsLine() ? p / 8 * 8 : p / 16 * 16; if(IsNull(draghandle)) { // move selection Point offset = p - dragstart; Rect to = dragfrom.Offseted(offset); @@ -267,7 +267,7 @@ void DiagramEditor::RightDown(Point p, dword keyflags) m.pt[0] = Pointf(p) - Pointf(64, 32); m.pt[1] = Pointf(p) + Pointf(64, 32); m.shape = si; - SetAttrs(); + SetAttrs(ATTR_ALL); SetCursor(data.item.GetCount() - 1); Sync(); } diff --git a/uppsrc/RichEdit/Ops.cpp b/uppsrc/RichEdit/Ops.cpp index dde356400..7bc6ad542 100644 --- a/uppsrc/RichEdit/Ops.cpp +++ b/uppsrc/RichEdit/Ops.cpp @@ -2,17 +2,24 @@ namespace Upp { -void DiagramEditor::SetAttrs() +void DiagramEditor::SetAttrs(dword attrs) { for(int i = 0; i < sel.GetCount(); i++) { DiagramItem& m = data.item[sel[i]]; - m.shape = ~shape; - m.cap[0] = ~line_start; - m.cap[1] = ~line_end; - m.width = ~line_width; - m.dash = ~line_dash; - m.ink = ~ink; - m.paper = ~paper; + if(attrs & ATTR_SHAPE) + m.shape = ~shape; + if(attrs & ATTR_CAP0) + m.cap[0] = ~line_start; + if(attrs & ATTR_CAP1) + m.cap[1] = ~line_end; + if(attrs & ATTR_WIDTH) + m.width = ~line_width; + if(attrs & ATTR_DASH) + m.dash = ~line_dash; + if(attrs & ATTR_INK) + m.ink = ~ink; + if(attrs & ATTR_PAPER) + m.paper = ~paper; } Sync(); Commit(); diff --git a/uppsrc/RichText/Diagram.cpp b/uppsrc/RichText/Diagram.cpp index b15456d49..23b51d8e3 100644 --- a/uppsrc/RichText/Diagram.cpp +++ b/uppsrc/RichText/Diagram.cpp @@ -260,7 +260,7 @@ void DiagramItem::Paint(Painter& w, dword style) const break; } DoDash(); - w.Stroke(width, ink).Fill(paper); + w.Fill(paper).Stroke(width, ink); txt.Paint(zoom, w, r.left, r.top + (r.GetHeight() - txt_cy) / 2, r.GetWidth()); } } diff --git a/upptst/Diagram/main.cpp b/upptst/Diagram/main.cpp index 3fd0dab13..27b163914 100644 --- a/upptst/Diagram/main.cpp +++ b/upptst/Diagram/main.cpp @@ -8,7 +8,7 @@ GUI_APP_MAIN app.Sizeable().Zoomable(); DiagramEditor de; app.Add(de.SizePos()); - String fn = "c:/xxx/test.qdf"; + String fn = GetHomeDirFile("test.qdf"); de.Load(LoadFile(fn)); app.Run(); SaveFile(fn, de.Save());