mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
.reference
git-svn-id: svn://ultimatepp.org/upp/trunk@14457 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
53e285b6a5
commit
6bc20ed5c9
6 changed files with 144 additions and 25 deletions
|
|
@ -5,9 +5,12 @@ using namespace Upp;
|
|||
struct MyApp : TopWindow {
|
||||
Rect rect;
|
||||
int hline, vline;
|
||||
Point line1, line2;
|
||||
|
||||
typedef MyApp CLASSNAME;
|
||||
|
||||
DropList op;
|
||||
|
||||
void Round(Rect& r)
|
||||
{
|
||||
int cx = r.GetWidth();
|
||||
|
|
@ -19,42 +22,49 @@ struct MyApp : TopWindow {
|
|||
{
|
||||
Size sz = GetSize();
|
||||
w.DrawRect(sz, SColorPaper());
|
||||
DrawFrame(w, rect, Black());
|
||||
w.DrawRect(0, hline, sz.cx, 1, SRed);
|
||||
w.DrawRect(vline, 0, 1, sz.cy, SBlue);
|
||||
DrawFrame(w, rect, SBlack());
|
||||
w.DrawRect(0, hline, sz.cx, 1, SRed());
|
||||
w.DrawRect(vline, 0, 1, sz.cy, SBlue());
|
||||
if(line1 != line2)
|
||||
w.DrawLine(line1, line2, DPI(2), SMagenta());
|
||||
}
|
||||
|
||||
virtual void LeftDown(Point p, dword keyflags) {
|
||||
RectTracker tr(*this);
|
||||
Size sz = GetSize();
|
||||
if((keyflags & K_CTRL) && (keyflags & K_ALT)) {
|
||||
switch((int)~op) {
|
||||
case 0:
|
||||
rect = tr.Track(rect, ALIGN_RIGHT, ALIGN_BOTTOM);
|
||||
break;
|
||||
case 1:
|
||||
rect = tr.Track(rect, ALIGN_LEFT, ALIGN_TOP);
|
||||
break;
|
||||
case 2:
|
||||
tr.Dashed().Animation();
|
||||
rect = tr.Track(rect, ALIGN_CENTER, ALIGN_CENTER);
|
||||
break;
|
||||
case 3:
|
||||
tr.Solid();
|
||||
vline = tr.TrackVertLine(0, 0, sz.cy, vline);
|
||||
break;
|
||||
case 4:
|
||||
tr.Solid();
|
||||
hline = tr.TrackHorzLine(0, 0, sz.cx, hline);
|
||||
break;
|
||||
case 5:
|
||||
line1 = p;
|
||||
line2 = tr.TrackLine(p.x, p.y);
|
||||
break;
|
||||
case 6:
|
||||
tr.Dashed();
|
||||
tr.MinSize(Size(-10000, -10000)); // allow negative size
|
||||
tr.Width(DPI(4));
|
||||
tr.SetColor(Yellow());
|
||||
tr.round = THISBACK(Round);
|
||||
rect = tr.Track(rect, ALIGN_RIGHT, ALIGN_BOTTOM);
|
||||
rect.Normalize();
|
||||
}
|
||||
else
|
||||
if(keyflags & K_ALT) {
|
||||
tr.Dashed().Animation();
|
||||
tr.round = THISBACK(Round);
|
||||
rect = tr.Track(rect, ALIGN_CENTER, ALIGN_CENTER);
|
||||
}
|
||||
else
|
||||
if(keyflags & K_SHIFT) {
|
||||
tr.Solid();
|
||||
hline = tr.TrackHorzLine(0, 0, sz.cx, hline);
|
||||
}
|
||||
else
|
||||
if(keyflags & K_CTRL) {
|
||||
tr.Solid();
|
||||
vline = tr.TrackVertLine(0, 0, sz.cy, vline);
|
||||
}
|
||||
else {
|
||||
tr.Normal();
|
||||
rect = tr.Track(rect, ALIGN_RIGHT, ALIGN_BOTTOM);
|
||||
}
|
||||
break;
|
||||
};
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
|
@ -63,6 +73,19 @@ struct MyApp : TopWindow {
|
|||
hline = 150;
|
||||
vline = 150;
|
||||
Sizeable().Zoomable();
|
||||
|
||||
line1 = line2 = Point(10, 10);
|
||||
|
||||
Add(op.LeftPosZ(10, 200).TopPosZ(10));
|
||||
op.Add(0, "Bottom right corner of rectangle");
|
||||
op.Add(1, "Top left corner of rectangle");
|
||||
op.Add(2, "Move rectangle");
|
||||
op.Add(3, "Vertical line");
|
||||
op.Add(4, "Horizontal line");
|
||||
op.Add(5, "Free line");
|
||||
op.Add(6, "Resize rectangle, special features");
|
||||
|
||||
op <<= 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue