mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
RichEdit: Improving diagrams
This commit is contained in:
parent
e5cc85d4d6
commit
ef6c94e785
6 changed files with 36 additions and 19 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue