mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
bazaar: CtrlProp, CtrlFinder, CtrlMover, CtrlPos: cleanup and get rid of Visiting interface
git-svn-id: svn://ultimatepp.org/upp/trunk@3752 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
34e87c8269
commit
1814c7ac74
18 changed files with 149 additions and 210 deletions
|
|
@ -78,46 +78,32 @@ Ctrl* CtrlFinder::GetCtrl(Ctrl& c, Point& p, int& f, const CtrlFilterType& fil)
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CtrlFinder::Reload()
|
void CtrlFinder::UpdatedSource()
|
||||||
{
|
{
|
||||||
if(IsEmpty()) return;
|
|
||||||
V::Reload();
|
|
||||||
|
|
||||||
Remove();
|
Remove();
|
||||||
Get().GetParent()->AddChild(&SetPos(Get().GetPos()), &Get());
|
if(!pctrl) { ctrl = NULL; return; }
|
||||||
}
|
ASSERT(pctrl->GetParent());
|
||||||
|
//add the finder on top of any child in the search ctrl's parent
|
||||||
void CtrlFinder::Visit(Ctrl& c)
|
pctrl->GetParent()->AddChild(&SetPos(pctrl->GetPos()), pctrl);
|
||||||
{
|
|
||||||
ASSERT(c.GetParent());
|
|
||||||
V::Visit(c);
|
|
||||||
Enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CtrlFinder::Clear()
|
|
||||||
{
|
|
||||||
ctrl = NULL;
|
|
||||||
Remove();
|
|
||||||
V::Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CtrlFinder::LeftDown(Point p, dword keyflags)
|
void CtrlFinder::LeftDown(Point p, dword keyflags)
|
||||||
{
|
{
|
||||||
ctrl = NULL;
|
if(!pctrl) return;
|
||||||
if(IsEmpty()) return;
|
|
||||||
Point pt(p);
|
Point pt(p);
|
||||||
ctrl = GetCtrl(Get(), pt, flags, filter);
|
ctrl = GetCtrl(*pctrl, pt, flags, filter);
|
||||||
if(!ctrl) ctrl = &Get();
|
if(!ctrl) ctrl = pctrl;
|
||||||
|
if(!ctrl) return;
|
||||||
WhenLeftDown(*ctrl, p, keyflags);
|
WhenLeftDown(*ctrl, p, keyflags);
|
||||||
Action();
|
Action();
|
||||||
}
|
}
|
||||||
void CtrlFinder::RightDown(Point p, dword keyflags)
|
void CtrlFinder::RightDown(Point p, dword keyflags)
|
||||||
{
|
{
|
||||||
ctrl = NULL;
|
if(!pctrl) return;
|
||||||
if(IsEmpty()) return;
|
|
||||||
Point pt(p);
|
Point pt(p);
|
||||||
ctrl = GetCtrl(Get(), pt, flags, filter);
|
ctrl = GetCtrl(*pctrl, pt, flags, filter);
|
||||||
if(!ctrl) ctrl = &Get();
|
if(!ctrl) ctrl = pctrl;
|
||||||
|
if(!ctrl) return;
|
||||||
WhenRightDown(*ctrl, p, keyflags);
|
WhenRightDown(*ctrl, p, keyflags);
|
||||||
Action();
|
Action();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,38 +5,10 @@
|
||||||
|
|
||||||
using namespace Upp;
|
using namespace Upp;
|
||||||
|
|
||||||
#include <Gen/Gen.h>
|
class CtrlFinder : public ParentCtrl
|
||||||
|
|
||||||
class MouseHookCtrl : public ParentCtrl
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef MouseHookCtrl CLASSNAME;
|
|
||||||
|
|
||||||
virtual void LeftDown(Point p, dword keyflags) { WhenLeftDown(p,keyflags); }
|
|
||||||
virtual void RightDown(Point p, dword keyflags) { WhenRightDown(p,keyflags); }
|
|
||||||
virtual void LeftUp(Point p, dword keyflags) { WhenLeftUp(p,keyflags); }
|
|
||||||
virtual void RightUp(Point p, dword keyflags) { WhenRightUp(p,keyflags); }
|
|
||||||
virtual void MouseMove(Point p, dword keyflags) { WhenMouseMove(p,keyflags); }
|
|
||||||
virtual void LeftRepeat(Point p, dword keyflags) { WhenLeftRepeat(p,keyflags); }
|
|
||||||
virtual void RightRepeat(Point p, dword keyflags) { WhenRightRepeat(p,keyflags); }
|
|
||||||
|
|
||||||
Callback2<Point, dword> WhenLeftDown;
|
|
||||||
Callback2<Point, dword> WhenRightDown;
|
|
||||||
Callback2<Point, dword> WhenLeftUp;
|
|
||||||
Callback2<Point, dword> WhenRightUp;
|
|
||||||
Callback2<Point, dword> WhenMouseMove;
|
|
||||||
Callback2<Point, dword> WhenLeftRepeat;
|
|
||||||
Callback2<Point, dword> WhenRightRepeat;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class CtrlFinder : public ParentCtrl, public Visiting<Ctrl>
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef CtrlFinder CLASSNAME;
|
typedef CtrlFinder CLASSNAME;
|
||||||
typedef MouseHookCtrl R;
|
|
||||||
typedef Visiting<Ctrl> V;
|
|
||||||
|
|
||||||
typedef Callback3<Ctrl*&, Point&, int&> CtrlFilterType;
|
typedef Callback3<Ctrl*&, Point&, int&> CtrlFilterType;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
|
@ -55,32 +27,37 @@ public:
|
||||||
DEF = VISIBLE | INVISIBLE | ENABLED | DISABLED | VIEW | FRAME | DEEP,
|
DEF = VISIBLE | INVISIBLE | ENABLED | DISABLED | VIEW | FRAME | DEEP,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void StdCtrlFilter(Ctrl*& q, Point& pt, int& f);
|
|
||||||
static Ctrl* ChildAtPoint(Ctrl& par, Point& pt, int& f, const CtrlFilterType& fil);
|
|
||||||
static Ctrl* GetCtrl(Ctrl& c, Point& p, int& f, const CtrlFilterType& fil);
|
|
||||||
|
|
||||||
CtrlFinder() : flags(DEF), filter(STDBACK(StdCtrlFilter)) {}
|
CtrlFinder() : flags(DEF), filter(STDBACK(StdCtrlFilter)) {}
|
||||||
|
|
||||||
virtual void Visit(Ctrl& c);
|
virtual void UpdatedSource();
|
||||||
virtual void Reload();
|
|
||||||
virtual void Clear();
|
|
||||||
|
|
||||||
virtual void LeftDown(Point p, dword keyflags);
|
virtual void LeftDown(Point p, dword keyflags);
|
||||||
virtual void RightDown(Point p, dword keyflags);
|
virtual void RightDown(Point p, dword keyflags);
|
||||||
|
|
||||||
Callback3<Ctrl&, Point, dword> WhenLeftDown;
|
void SetSource(Ctrl* c) { if(c) ASSERT(c->GetParent()); pctrl = c; ctrl = NULL; UpdatedSource(); Enable(); }
|
||||||
Callback3<Ctrl&, Point, dword> WhenRightDown;
|
Ctrl* GetSource() const { return pctrl; }
|
||||||
|
void ClearSource() { SetSource(NULL); }
|
||||||
|
|
||||||
|
void SetCtrl(Ctrl* c) { if(c && pctrl) ASSERT(c->GetParent() == ~pctrl); ctrl = c; UpdateRefresh(); }
|
||||||
|
Ctrl* GetCtrl() const { return ctrl; }
|
||||||
|
void ClearCtrl() { SetCtrl(NULL); }
|
||||||
|
|
||||||
virtual Value GetData() const { return RawToValue(~ctrl); }
|
virtual Value GetData() const { return RawToValue(~ctrl); }
|
||||||
Ctrl* GetCtrl() const { return ctrl; }
|
virtual void SetData(const Value& v) { SetCtrl(RawValue<Ctrl*>::Extract(v)); }
|
||||||
void ClearCtrl() { ctrl = NULL; }
|
|
||||||
void SetCtrl(Ctrl& c) { /*ASSERT(c.GetParent());*/ ctrl = &c; }
|
static void StdCtrlFilter(Ctrl*& q, Point& pt, int& f);
|
||||||
|
static Ctrl* ChildAtPoint(Ctrl& par, Point& pt, int& f, const CtrlFilterType& fil);
|
||||||
|
static Ctrl* GetCtrl(Ctrl& c, Point& p, int& f, const CtrlFilterType& fil);
|
||||||
|
|
||||||
|
Callback3<Ctrl&, Point, dword> WhenLeftDown;
|
||||||
|
Callback3<Ctrl&, Point, dword> WhenRightDown;
|
||||||
|
|
||||||
CtrlFilterType filter; //set to NULL if should not be handled, change flags if desired
|
CtrlFilterType filter; //set to NULL if should not be handled, change flags if desired
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Ptr<Ctrl> ctrl;
|
Ptr<Ctrl> pctrl; //the parent we search in
|
||||||
|
Ptr<Ctrl> ctrl; //the current found child
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
description "Find a Ctrl using a transparent Hook Ctrl, see CtrlPropTest\377";
|
description "Find a Ctrl using a transparent Hook Ctrl, see CtrlPropTest\377";
|
||||||
|
|
||||||
uses
|
uses
|
||||||
CtrlLib,
|
CtrlLib;
|
||||||
Gen;
|
|
||||||
|
|
||||||
file
|
file
|
||||||
CtrlFinder.h,
|
CtrlFinder.h,
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ void CtrlFinderTest::OnSelect(Ctrl& c, Point p, dword keyflags)
|
||||||
|
|
||||||
void CtrlFinderTest::VisitCB()
|
void CtrlFinderTest::VisitCB()
|
||||||
{
|
{
|
||||||
hk.Visit(vis);
|
hk.SetSource(&vis);
|
||||||
}
|
}
|
||||||
void CtrlFinderTest::ClearCB()
|
void CtrlFinderTest::ClearCB()
|
||||||
{
|
{
|
||||||
hk.Clear();
|
hk.ClearSource();
|
||||||
}
|
}
|
||||||
void CtrlFinderTest::EnableCB()
|
void CtrlFinderTest::EnableCB()
|
||||||
{
|
{
|
||||||
|
|
@ -87,7 +87,7 @@ CtrlFinderTest::CtrlFinderTest()
|
||||||
ViewCB();
|
ViewCB();
|
||||||
|
|
||||||
hk.WhenLeftDown = THISBACK(OnSelect);
|
hk.WhenLeftDown = THISBACK(OnSelect);
|
||||||
hk.Visit(vis);
|
hk.SetSource(&vis);
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI_APP_MAIN
|
GUI_APP_MAIN
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,10 @@ Point CtrlMover::GetOffset(const Ctrl& c, const Ctrl& q)
|
||||||
|
|
||||||
void CtrlMover::OnCtrlLeft(Ctrl& c, Point p, dword keyflags)
|
void CtrlMover::OnCtrlLeft(Ctrl& c, Point p, dword keyflags)
|
||||||
{
|
{
|
||||||
if(&c == &rc) { rc.Remove(); return; }
|
|
||||||
if(&c == &Get()) { rc.Remove(); return; } //mat not move base
|
|
||||||
if(c.InFrame()) return; //may not move frames
|
if(c.InFrame()) return; //may not move frames
|
||||||
rc.Remove();
|
rc.Remove();
|
||||||
|
if(&c == &rc) return;
|
||||||
|
if(&c == ~pctrl) return; //mat not move base
|
||||||
Add(rc.SizePos());
|
Add(rc.SizePos());
|
||||||
|
|
||||||
//if c is frame: rect in parents window,
|
//if c is frame: rect in parents window,
|
||||||
|
|
@ -39,7 +39,7 @@ void CtrlMover::OnCtrlLeft(Ctrl& c, Point p, dword keyflags)
|
||||||
Rect r = c.GetRect();
|
Rect r = c.GetRect();
|
||||||
if(c.InView())
|
if(c.InView())
|
||||||
r.Offset(c.GetParent()->GetView().TopLeft());
|
r.Offset(c.GetParent()->GetView().TopLeft());
|
||||||
r.Offset(GetOffset(*c.GetParent(), Get()));
|
r.Offset(GetOffset(*c.GetParent(), *pctrl));
|
||||||
|
|
||||||
rc.SetData(r);
|
rc.SetData(r);
|
||||||
Action();
|
Action();
|
||||||
|
|
@ -47,16 +47,14 @@ void CtrlMover::OnCtrlLeft(Ctrl& c, Point p, dword keyflags)
|
||||||
|
|
||||||
void CtrlMover::OnRectChange()
|
void CtrlMover::OnRectChange()
|
||||||
{
|
{
|
||||||
if(IsEmpty()) { rc.Remove(); return; }
|
if(!pctrl || !ctrl) { rc.Remove(); return; }
|
||||||
if(!GetCtrl()) return;
|
|
||||||
Ctrl& c = *GetCtrl();
|
|
||||||
|
|
||||||
Rect r = rc.GetData();
|
Rect r = rc.GetData();
|
||||||
r.Offset(-GetOffset(*c.GetParent(), Get()));
|
r.Offset(-GetOffset(*ctrl->GetParent(), *pctrl));
|
||||||
if(c.InView())
|
if(ctrl->InView())
|
||||||
r.Offset(-c.GetParent()->GetView().TopLeft());
|
r.Offset(-ctrl->GetParent()->GetView().TopLeft());
|
||||||
|
|
||||||
c.SetRect(r);
|
ctrl->SetRect(r);
|
||||||
Action();
|
Action();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,9 +65,8 @@ void CtrlMover::OnMissed(Point p, dword keyflags)
|
||||||
|
|
||||||
void CtrlMover::Updated()
|
void CtrlMover::Updated()
|
||||||
{
|
{
|
||||||
Ctrl* c = GetCtrl();
|
if(!pctrl || !ctrl) { rc.Remove(); return; }
|
||||||
if(!c) return;
|
rc.SetData(ctrl->GetRect());
|
||||||
rc.SetData(c->GetRect());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CtrlMover::State(int reason)
|
void CtrlMover::State(int reason)
|
||||||
|
|
@ -78,24 +75,6 @@ void CtrlMover::State(int reason)
|
||||||
if(!IsEnabled()) rc.Remove();
|
if(!IsEnabled()) rc.Remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CtrlMover::Visit(Ctrl& c)
|
|
||||||
{
|
|
||||||
rc.Remove();
|
|
||||||
V::Visit(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CtrlMover::Clear()
|
|
||||||
{
|
|
||||||
V::Clear();
|
|
||||||
rc.Remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CtrlMover::Reload()
|
|
||||||
{
|
|
||||||
if(IsEmpty()) return;
|
|
||||||
V::Reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
CtrlMover::CtrlMover()
|
CtrlMover::CtrlMover()
|
||||||
{
|
{
|
||||||
WhenLeftDown = THISBACK(OnCtrlLeft);
|
WhenLeftDown = THISBACK(OnCtrlLeft);
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,8 @@ class CtrlMover : public CtrlFinder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef CtrlMover CLASSNAME;
|
typedef CtrlMover CLASSNAME;
|
||||||
typedef CtrlFinder V;
|
|
||||||
CtrlMover();
|
|
||||||
|
|
||||||
virtual void Visit(Ctrl& c);
|
CtrlMover();
|
||||||
virtual void Clear();
|
|
||||||
virtual void Reload();
|
|
||||||
|
|
||||||
virtual void State(int reason);
|
virtual void State(int reason);
|
||||||
virtual void Updated();
|
virtual void Updated();
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,11 @@ void CtrlMoverTest::OnSelect(Ctrl& c, Point p, dword keyflags)
|
||||||
|
|
||||||
void CtrlMoverTest::VisitCB()
|
void CtrlMoverTest::VisitCB()
|
||||||
{
|
{
|
||||||
hk.Visit(vis);
|
hk.SetSource(&vis);
|
||||||
}
|
}
|
||||||
void CtrlMoverTest::ClearCB()
|
void CtrlMoverTest::ClearCB()
|
||||||
{
|
{
|
||||||
hk.Clear();
|
hk.ClearSource();
|
||||||
}
|
}
|
||||||
void CtrlMoverTest::EnableCB()
|
void CtrlMoverTest::EnableCB()
|
||||||
{
|
{
|
||||||
|
|
@ -87,7 +87,7 @@ CtrlMoverTest::CtrlMoverTest()
|
||||||
ViewCB();
|
ViewCB();
|
||||||
|
|
||||||
hk.WhenLeftDown = THISBACK(OnSelect);
|
hk.WhenLeftDown = THISBACK(OnSelect);
|
||||||
hk.Visit(vis);
|
hk.SetSource(&vis);
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI_APP_MAIN
|
GUI_APP_MAIN
|
||||||
|
|
|
||||||
|
|
@ -90,12 +90,12 @@ void CtrlPos::Paint(Draw& w)
|
||||||
if(!IsTransparent())
|
if(!IsTransparent())
|
||||||
w.DrawRect(0,0,sz.cx,sz.cy, SColorFace());
|
w.DrawRect(0,0,sz.cx,sz.cy, SColorFace());
|
||||||
|
|
||||||
if(IsEnabled() && !IsEmpty())
|
if(IsEnabled() && pctrl)
|
||||||
DrawHintFrame(w, Get(), Get(), LtGray());
|
DrawHintFrame(w, *pctrl, *pctrl, LtGray());
|
||||||
|
|
||||||
if(!GetCtrl()) return;
|
if(!ctrl) return;
|
||||||
Ctrl& c = *GetCtrl();
|
Ctrl& c = *ctrl;
|
||||||
if(&c == &Get()) return;
|
if(&c == pctrl) return;
|
||||||
|
|
||||||
Rect r = c.GetRect();
|
Rect r = c.GetRect();
|
||||||
Rect _r = c.GetParent()->GetView();
|
Rect _r = c.GetParent()->GetView();
|
||||||
|
|
@ -103,7 +103,7 @@ void CtrlPos::Paint(Draw& w)
|
||||||
|
|
||||||
if(c.InView())
|
if(c.InView())
|
||||||
r.Offset(_r.TopLeft());
|
r.Offset(_r.TopLeft());
|
||||||
Point op = CtrlMover::GetOffset(*(c.GetParent()), Get());
|
Point op = CtrlMover::GetOffset(*c.GetParent(), *pctrl);
|
||||||
r.Offset(op);
|
r.Offset(op);
|
||||||
_r.Offset(op);
|
_r.Offset(op);
|
||||||
|
|
||||||
|
|
@ -125,10 +125,10 @@ void CtrlPos::LeftDown(Point p, dword keyflags)
|
||||||
moving = false;
|
moving = false;
|
||||||
pressed = (keyflags & K_MOUSELEFT);
|
pressed = (keyflags & K_MOUSELEFT);
|
||||||
|
|
||||||
if(GetCtrl())
|
if(ctrl)
|
||||||
{
|
{
|
||||||
|
Ctrl& c = *ctrl;
|
||||||
//if already found prepare moving
|
//if already found prepare moving
|
||||||
Ctrl& c = *GetCtrl();
|
|
||||||
ASSERT(!c.InFrame());
|
ASSERT(!c.InFrame());
|
||||||
xpos = c.GetPos();
|
xpos = c.GetPos();
|
||||||
xp = p;
|
xp = p;
|
||||||
|
|
@ -138,7 +138,7 @@ void CtrlPos::LeftDown(Point p, dword keyflags)
|
||||||
|
|
||||||
if(c.InView())
|
if(c.InView())
|
||||||
r.Offset(_r.TopLeft());
|
r.Offset(_r.TopLeft());
|
||||||
Point op = CtrlMover::GetOffset(*(c.GetParent()), Get());
|
Point op = CtrlMover::GetOffset(*c.GetParent(), *pctrl);
|
||||||
r.Offset(op);
|
r.Offset(op);
|
||||||
_r.Offset(op);
|
_r.Offset(op);
|
||||||
|
|
||||||
|
|
@ -161,12 +161,12 @@ void CtrlPos::LeftDown(Point p, dword keyflags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CtrlFinder::LeftDown(p, keyflags);
|
CtrlFinder::LeftDown(p, keyflags);
|
||||||
if(GetCtrl() == &Get()) //may not move base
|
if(ctrl == pctrl) //may not move base
|
||||||
{
|
{
|
||||||
ClearCtrl();
|
ClearCtrl();
|
||||||
Action();
|
Action();
|
||||||
}
|
}
|
||||||
if(GetCtrl() && GetCtrl()->InFrame())
|
if(ctrl && ctrl->InFrame())
|
||||||
{
|
{
|
||||||
ClearCtrl(); //may not move frames
|
ClearCtrl(); //may not move frames
|
||||||
Action();
|
Action();
|
||||||
|
|
@ -182,8 +182,8 @@ void CtrlPos::MouseMove(Point p, dword keyflags)
|
||||||
pressed = (keyflags & K_MOUSELEFT);
|
pressed = (keyflags & K_MOUSELEFT);
|
||||||
//int m = RectCtrl::GetMode(r, p, keyflags, style->handsize);
|
//int m = RectCtrl::GetMode(r, p, keyflags, style->handsize);
|
||||||
//ci = RectCtrl::SetCursor(m, keyflags);
|
//ci = RectCtrl::SetCursor(m, keyflags);
|
||||||
if(!GetCtrl()) return;
|
if(!ctrl) return;
|
||||||
Ctrl& c = *GetCtrl();
|
Ctrl& c = *ctrl;
|
||||||
|
|
||||||
if(pressed && mode != RectCtrl::NONE)
|
if(pressed && mode != RectCtrl::NONE)
|
||||||
{
|
{
|
||||||
|
|
@ -197,19 +197,19 @@ void CtrlPos::MouseMove(Point p, dword keyflags)
|
||||||
Rect r = LogPosPopUp::CtrlRect(xpos, q->GetSize());
|
Rect r = LogPosPopUp::CtrlRect(xpos, q->GetSize());
|
||||||
if(c.InView())
|
if(c.InView())
|
||||||
r.Offset(c.GetParent()->GetView().TopLeft());
|
r.Offset(c.GetParent()->GetView().TopLeft());
|
||||||
Point ops = CtrlMover::GetOffset(*(c.GetParent()), Get());
|
Point ops = CtrlMover::GetOffset(*(c.GetParent()), *pctrl);
|
||||||
r.Offset(ops);
|
r.Offset(ops);
|
||||||
|
|
||||||
c.Remove(); //prevent moving control from finding when searching new parent
|
c.Remove(); //prevent moving control from finding when searching new parent
|
||||||
Point pt(p);
|
Point pt(p);
|
||||||
int ft(flags); flags |= (DEEP | NEST);
|
int ft(flags); flags |= (DEEP | NEST);
|
||||||
Ctrl* pc = GetCtrl(Get(), pt, flags, filter);
|
Ctrl* pc = GetCtrl(*pctrl, pt, flags, filter);
|
||||||
flags &= ~(DEEP | NEST); flags |= (ft & DEEP); //restore DEEP flag from save, NEST is ours
|
flags &= ~(DEEP | NEST); flags |= (ft & DEEP); //restore DEEP flag from save, NEST is ours
|
||||||
if(!pc) pc = &Get();
|
if(!pc) pc = pctrl;
|
||||||
if(pc != q)
|
if(pc != q)
|
||||||
{
|
{
|
||||||
r.Offset(-pc->GetView().TopLeft());
|
r.Offset(-pc->GetView().TopLeft());
|
||||||
Point opd = CtrlMover::GetOffset(*pc, Get());
|
Point opd = CtrlMover::GetOffset(*pc, *pctrl);
|
||||||
r.Offset(-opd);
|
r.Offset(-opd);
|
||||||
|
|
||||||
xpos = LogPosPopUp::MakeLogPos(xpos, r, pc->GetSize());
|
xpos = LogPosPopUp::MakeLogPos(xpos, r, pc->GetSize());
|
||||||
|
|
@ -278,7 +278,7 @@ void CtrlPos::RightDown(Point p, dword keyflags)
|
||||||
|
|
||||||
Ctrl* pc = GetCtrl()->GetParent();
|
Ctrl* pc = GetCtrl()->GetParent();
|
||||||
r.Offset(-pc->GetView().TopLeft());
|
r.Offset(-pc->GetView().TopLeft());
|
||||||
Point opd = CtrlMover::GetOffset(*pc, Get());
|
Point opd = CtrlMover::GetOffset(*pc, *pctrl);
|
||||||
r.Offset(-opd);
|
r.Offset(-opd);
|
||||||
|
|
||||||
Ctrl::LogPos pos = LogPosPopUp::MakeLogPos(xpos, r, psz);
|
Ctrl::LogPos pos = LogPosPopUp::MakeLogPos(xpos, r, psz);
|
||||||
|
|
@ -315,6 +315,7 @@ void CtrlPos::MouseWheel(Point p, int zdelta, dword keyflags)
|
||||||
void CtrlPos::Updated()
|
void CtrlPos::Updated()
|
||||||
{
|
{
|
||||||
//refresh the view of the currently selected ctrl
|
//refresh the view of the currently selected ctrl
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CtrlPos::State(int reason)
|
void CtrlPos::State(int reason)
|
||||||
|
|
@ -323,12 +324,6 @@ void CtrlPos::State(int reason)
|
||||||
if(!IsEnabled()) { ClearCtrl(); Refresh(); }
|
if(!IsEnabled()) { ClearCtrl(); Refresh(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void CtrlPos::Clear()
|
|
||||||
{
|
|
||||||
V::Clear();
|
|
||||||
Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
CtrlPos::CtrlPos()
|
CtrlPos::CtrlPos()
|
||||||
: pressed(false), moving(false), mode(RectCtrl::NONE), g(4,4)
|
: pressed(false), moving(false), mode(RectCtrl::NONE), g(4,4)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ using namespace Upp;
|
||||||
#include <RectCtrl/RectCtrl.h>
|
#include <RectCtrl/RectCtrl.h>
|
||||||
#include <LogPosCtrl/LogPosCtrl.h>
|
#include <LogPosCtrl/LogPosCtrl.h>
|
||||||
#include <CtrlFinder/CtrlFinder.h>
|
#include <CtrlFinder/CtrlFinder.h>
|
||||||
#include <Gen/Gen.h>
|
|
||||||
|
|
||||||
//for some helpers
|
//for some helpers
|
||||||
#include <CtrlMover/CtrlMover.h>
|
#include <CtrlMover/CtrlMover.h>
|
||||||
|
|
@ -25,8 +24,6 @@ public:
|
||||||
|
|
||||||
CtrlPos();
|
CtrlPos();
|
||||||
|
|
||||||
virtual void Clear();
|
|
||||||
|
|
||||||
virtual void Paint(Draw& w);
|
virtual void Paint(Draw& w);
|
||||||
virtual void LeftDown(Point p, dword keyflags);
|
virtual void LeftDown(Point p, dword keyflags);
|
||||||
virtual void MouseMove(Point p, dword keyflags);
|
virtual void MouseMove(Point p, dword keyflags);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ description "change Ctrl LogPos in a live environment\377";
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Core,
|
Core,
|
||||||
Gen,
|
|
||||||
RectCtrl,
|
RectCtrl,
|
||||||
LogPosCtrl,
|
LogPosCtrl,
|
||||||
CtrlFinder,
|
CtrlFinder,
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ void CtrlPosTest::OnSelect(Ctrl& c, Point p, dword keyflags)
|
||||||
|
|
||||||
void CtrlPosTest::VisitCB()
|
void CtrlPosTest::VisitCB()
|
||||||
{
|
{
|
||||||
hk.Visit(vis);
|
hk.SetSource(&vis);
|
||||||
}
|
}
|
||||||
void CtrlPosTest::ClearCB()
|
void CtrlPosTest::ClearCB()
|
||||||
{
|
{
|
||||||
hk.Clear();
|
hk.ClearSource();
|
||||||
}
|
}
|
||||||
void CtrlPosTest::EnableCB()
|
void CtrlPosTest::EnableCB()
|
||||||
{
|
{
|
||||||
|
|
@ -89,7 +89,7 @@ CtrlPosTest::CtrlPosTest()
|
||||||
ViewCB();
|
ViewCB();
|
||||||
|
|
||||||
hk.WhenLeftDown = THISBACK(OnSelect);
|
hk.WhenLeftDown = THISBACK(OnSelect);
|
||||||
hk.Visit(vis);
|
hk.SetSource(&vis);
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI_APP_MAIN
|
GUI_APP_MAIN
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ CtrlPosTest2::CtrlPosTest2()
|
||||||
|
|
||||||
Sizeable().Zoomable();
|
Sizeable().Zoomable();
|
||||||
|
|
||||||
hk.Visit(vis); //will add itself to vis->GetParent --> to this TopWindow with same vis.GetPos to cover it perfectly.
|
hk.SetSource(&vis); //will add itself to vis->GetParent --> to this TopWindow with same vis.GetPos to cover it perfectly.
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI_APP_MAIN
|
GUI_APP_MAIN
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ uses
|
||||||
CtrlLib,
|
CtrlLib,
|
||||||
LogPosCtrl,
|
LogPosCtrl,
|
||||||
ValueCtrl,
|
ValueCtrl,
|
||||||
Gen,
|
|
||||||
Property;
|
Property;
|
||||||
|
|
||||||
file
|
file
|
||||||
|
|
|
||||||
|
|
@ -8,22 +8,39 @@ PropEditCtrl::PropEditCtrl()
|
||||||
//ac.WhenUpdateRow = THISBACK(OnUpdateRow);
|
//ac.WhenUpdateRow = THISBACK(OnUpdateRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropEditCtrl::Visit(Ctrl& e)
|
void PropEditCtrl::Updated()
|
||||||
{
|
{
|
||||||
V::Visit(e);
|
if(!ctrl)
|
||||||
|
{
|
||||||
|
sctrl = NULL;
|
||||||
ac.Clear();
|
ac.Clear();
|
||||||
vsav.Clear();
|
vsav.Clear();
|
||||||
am.Clear();
|
am.Clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(sctrl == ctrl)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < ac.GetCount(); i++)
|
||||||
|
{
|
||||||
|
Value v;
|
||||||
|
int ii = am.Find(ac.Get(i, 0));
|
||||||
|
if(ii<0) continue;
|
||||||
|
if(!am[ii].get(v)) continue;
|
||||||
|
ac.Set(i, 1, v);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sctrl = ctrl;
|
||||||
|
|
||||||
|
Ctrl& e = *ctrl;
|
||||||
|
|
||||||
//init local accessor map
|
//init local accessor map
|
||||||
//prefer the dynamic access
|
//prefer the dynamic access
|
||||||
//fall back to the static accessors from Props<>
|
//fall back to the static accessors from Props<>
|
||||||
GetAccessorMapI* ami = dynamic_cast<GetAccessorMapI*>(&e);
|
GetAccessorMapI* ami = dynamic_cast<GetAccessorMapI*>(&e);
|
||||||
if(ami)
|
if(ami) am <<= ami->GetAccessorMap();
|
||||||
am <<= ami->GetAccessorMap();
|
else if(!Props<Ctrl>::SetupAccessorMap(e, am)) return;
|
||||||
else
|
|
||||||
if(!Props<Ctrl>::SetupAccessorMap(e, am)) return;
|
|
||||||
|
|
||||||
for(int i = 0, k = 0; i < am.GetCount(); i++)
|
for(int i = 0, k = 0; i < am.GetCount(); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -88,42 +105,21 @@ void PropEditCtrl::Visit(Ctrl& e)
|
||||||
//ac.UpdateRefresh();
|
//ac.UpdateRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropEditCtrl::Clear()
|
|
||||||
{
|
|
||||||
V::Clear();
|
|
||||||
ac.Clear();
|
|
||||||
vsav.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropEditCtrl::Reload()
|
|
||||||
{
|
|
||||||
V::Reload();
|
|
||||||
for(int i = 0; i < ac.GetCount(); i++)
|
|
||||||
{
|
|
||||||
Value v;
|
|
||||||
int ii = am.Find(ac.Get(i, 0));
|
|
||||||
if(ii<0) continue;
|
|
||||||
if(!am[ii].get(v)) continue;
|
|
||||||
ac.Set(i, 1, v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropEditCtrl::OnUpdateRow()
|
void PropEditCtrl::OnUpdateRow()
|
||||||
{
|
{
|
||||||
if(IsEmpty()) return;
|
if(!ctrl) return;
|
||||||
if(!ac.IsCursor()) return; //FIXME Option Focus issue
|
if(!ac.IsCursor()) return; //FIXME Option Focus issue
|
||||||
int ii = am.Find(ac.Get(0));
|
int ii = am.Find(ac.Get(0));
|
||||||
if(ii<0) return;
|
if(ii<0) return;
|
||||||
am[ii].set(ac.Get(1));
|
am[ii].set(ac.Get(1));
|
||||||
vsav.GetAdd(ac.Get(0)).a = true; //dirty
|
vsav.GetAdd(ac.Get(0)).a = true; //dirty
|
||||||
Action();
|
Action();
|
||||||
Get().UpdateActionRefresh(); //propagate user action
|
ctrl->UpdateActionRefresh(); //propagate user action
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropEditCtrl::Restore()
|
void PropEditCtrl::Undo()
|
||||||
{
|
{
|
||||||
if(!IsEmpty())
|
if(!ctrl) return;
|
||||||
{
|
|
||||||
for(int i = 0; i < vsav.GetCount(); i++)
|
for(int i = 0; i < vsav.GetCount(); i++)
|
||||||
if(vsav[i].a)
|
if(vsav[i].a)
|
||||||
{
|
{
|
||||||
|
|
@ -131,7 +127,6 @@ void PropEditCtrl::Restore()
|
||||||
if(ii<0) continue;
|
if(ii<0) continue;
|
||||||
am[ii].set(vsav[i].b);
|
am[ii].set(vsav[i].b);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PropEdit::PropEdit()
|
PropEdit::PropEdit()
|
||||||
|
|
|
||||||
|
|
@ -6,26 +6,30 @@
|
||||||
#include <LogPosCtrl/LogPosCtrl.h>
|
#include <LogPosCtrl/LogPosCtrl.h>
|
||||||
#include <ValueCtrl/ValueCtrl.h>
|
#include <ValueCtrl/ValueCtrl.h>
|
||||||
|
|
||||||
#include <Gen/Gen.h>
|
|
||||||
|
|
||||||
#define LAYOUTFILE <CtrlProp/PropEdit.lay>
|
#define LAYOUTFILE <CtrlProp/PropEdit.lay>
|
||||||
#include <CtrlCore/lay.h>
|
#include <CtrlCore/lay.h>
|
||||||
|
|
||||||
class PropEditCtrl : public WithPropEditLay<ParentCtrl>, public Visiting<Ctrl>
|
class PropEditCtrl : public WithPropEditLay<ParentCtrl>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef PropEditCtrl CLASSNAME;
|
typedef PropEditCtrl CLASSNAME;
|
||||||
typedef Visiting<Ctrl> V;
|
|
||||||
PropEditCtrl();
|
PropEditCtrl();
|
||||||
|
|
||||||
virtual void Visit(Ctrl& e);
|
virtual void Updated();
|
||||||
virtual void Reload();
|
virtual void Undo();
|
||||||
virtual void Clear();
|
|
||||||
virtual void Restore();
|
|
||||||
|
|
||||||
void OnUpdateRow();
|
void OnUpdateRow();
|
||||||
|
|
||||||
|
void SetCtrl(Ctrl* c) { ctrl = c; UpdateRefresh(); }
|
||||||
|
Ctrl* GetCtrl() const { return ctrl; }
|
||||||
|
void ClearCtrl() { SetCtrl(NULL); }
|
||||||
|
|
||||||
|
virtual Value GetData() const { return RawToValue(~ctrl); }
|
||||||
|
virtual void SetData(const Value& v) { SetCtrl(RawValue<Ctrl*>::Extract(v)); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Ptr<Ctrl> ctrl, sctrl; //the current child, and a cache
|
||||||
ArrayMap<String, Tuple2<bool, Value> > vsav;
|
ArrayMap<String, Tuple2<bool, Value> > vsav;
|
||||||
AccessorMap am;
|
AccessorMap am;
|
||||||
};
|
};
|
||||||
|
|
@ -38,10 +42,10 @@ public:
|
||||||
|
|
||||||
virtual void Deactivate() {} //let other popups open
|
virtual void Deactivate() {} //let other popups open
|
||||||
|
|
||||||
void PopUp(Ctrl* owner, Ctrl& e) { pec.Visit(e); PopUpC::PopUp(owner); }
|
void PopUp(Ctrl* owner, Ctrl& e) { pec.SetCtrl(&e); PopUpC::PopUp(owner); }
|
||||||
|
|
||||||
virtual void Rejector() { pec.Restore(); pec.Clear(); PopUpC::Rejector(); }
|
virtual void Rejector() { pec.Undo(); pec.ClearCtrl(); PopUpC::Rejector(); }
|
||||||
virtual void Acceptor() { pec.Clear(); PopUpC::Acceptor(); }
|
virtual void Acceptor() { pec.ClearCtrl(); PopUpC::Acceptor(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PropEditCtrl pec;
|
PropEditCtrl pec;
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,16 @@ PropListCtrl::PropListCtrl()
|
||||||
CtrlLayout(*this);
|
CtrlLayout(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropListCtrl::Reload()
|
void PropListCtrl::Updated()
|
||||||
{
|
{
|
||||||
V::Reload();
|
if(!ctrl)
|
||||||
Ctrl& e = Get();
|
{
|
||||||
|
gl.SetData(Null);
|
||||||
|
sl.SetData(Null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ctrl& e = *ctrl;
|
||||||
|
|
||||||
Value v;
|
Value v;
|
||||||
bool b;
|
bool b;
|
||||||
|
|
|
||||||
|
|
@ -6,19 +6,26 @@
|
||||||
#include <LogPosCtrl/LogPosCtrl.h>
|
#include <LogPosCtrl/LogPosCtrl.h>
|
||||||
#include <ValueCtrl/ValueCtrl.h>
|
#include <ValueCtrl/ValueCtrl.h>
|
||||||
|
|
||||||
#include <Gen/Gen.h>
|
|
||||||
|
|
||||||
#define LAYOUTFILE <CtrlProp/PropList.lay>
|
#define LAYOUTFILE <CtrlProp/PropList.lay>
|
||||||
#include <CtrlCore/lay.h>
|
#include <CtrlCore/lay.h>
|
||||||
|
|
||||||
class PropListCtrl : public WithPropListLay<ParentCtrl>, public Visiting<Ctrl>
|
class PropListCtrl : public WithPropListLay<ParentCtrl>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef PropListCtrl CLASSNAME;
|
typedef PropListCtrl CLASSNAME;
|
||||||
typedef Visiting<Ctrl> V;
|
|
||||||
PropListCtrl();
|
PropListCtrl();
|
||||||
|
|
||||||
virtual void Reload();
|
virtual void Updated();
|
||||||
|
|
||||||
|
void SetCtrl(Ctrl* c) { ctrl = c; UpdateRefresh(); }
|
||||||
|
Ctrl* GetCtrl() const { return ctrl; }
|
||||||
|
void ClearCtrl() { SetCtrl(NULL); }
|
||||||
|
|
||||||
|
virtual Value GetData() const { return RawToValue(~ctrl); }
|
||||||
|
virtual void SetData(const Value& v) { SetCtrl(RawValue<Ctrl*>::Extract(v)); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Ptr<Ctrl> ctrl; //the current found child
|
||||||
};
|
};
|
||||||
|
|
||||||
class PropList : public PopUpC
|
class PropList : public PopUpC
|
||||||
|
|
@ -27,8 +34,8 @@ public:
|
||||||
typedef PropList CLASSNAME;
|
typedef PropList CLASSNAME;
|
||||||
PropList();
|
PropList();
|
||||||
|
|
||||||
void PopUp(Ctrl* owner, Ctrl& e) { plc.Visit(e); PopUpC::PopUp(owner); }
|
void PopUp(Ctrl* owner, Ctrl& e) { plc.SetCtrl(&e); PopUpC::PopUp(owner); }
|
||||||
virtual void Acceptor() { plc.Clear(); PopUpC::Acceptor(); }
|
virtual void Acceptor() { plc.ClearCtrl(); PopUpC::Acceptor(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PropListCtrl plc;
|
PropListCtrl plc;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ CtrlPropTest::CtrlPropTest()
|
||||||
AddFrame(mb);
|
AddFrame(mb);
|
||||||
|
|
||||||
hk.WhenRightDown = THISBACK(OnCtrlRight);
|
hk.WhenRightDown = THISBACK(OnCtrlRight);
|
||||||
hk.Visit(vis);
|
hk.SetSource(&vis);
|
||||||
hk.Disable();
|
hk.Disable();
|
||||||
|
|
||||||
InitDummies();
|
InitDummies();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue