diff --git a/bazaar/AutoScroller/AutoScroller.h b/bazaar/AutoScroller/AutoScroller.h index e5851a9ab..7eaefedd8 100644 --- a/bazaar/AutoScroller/AutoScroller.h +++ b/bazaar/AutoScroller/AutoScroller.h @@ -27,9 +27,9 @@ public: void OnScroll(); Callback WhenScrolled; + ScrollBars scroll; protected: - ScrollBars scroll; Ptr pane; }; diff --git a/bazaar/AutoScroller/AutoScroller.hpp b/bazaar/AutoScroller/AutoScroller.hpp index 7bd667e94..bce3079c1 100644 --- a/bazaar/AutoScroller/AutoScroller.hpp +++ b/bazaar/AutoScroller/AutoScroller.hpp @@ -6,7 +6,7 @@ template AutoScroller::AutoScroller() { - EnableScroll(); + C::AddFrame(scroll); scroll.AutoHide(); scroll.WhenScroll = THISBACK(OnScroll); } @@ -40,9 +40,6 @@ void AutoScroller::Layout() template void AutoScroller::EnableScroll(bool b) { - if(scroll.x.InFrame() || scroll.y.InFrame()) return; - if(b) C::AddFrame(scroll); - else C::RemoveFrame(scroll); scroll.x.Enable(b); scroll.y.Enable(b); } diff --git a/bazaar/CtrlFinder/CtrlFinder.cpp b/bazaar/CtrlFinder/CtrlFinder.cpp index 40dcfc91c..64e298cb4 100644 --- a/bazaar/CtrlFinder/CtrlFinder.cpp +++ b/bazaar/CtrlFinder/CtrlFinder.cpp @@ -103,7 +103,8 @@ void CtrlFinder::LeftDown(Point p, dword keyflags) { if(!pctrl) return; Point pt(p); - ctrl = GetCtrl(*pctrl, pt, flags, filter); + int f(flags); + ctrl = GetCtrl(*pctrl, pt, f, filter); if(!ctrl) ctrl = pctrl; if(!ctrl) return; WhenLeftDown(*ctrl, p, keyflags); @@ -113,7 +114,8 @@ void CtrlFinder::RightDown(Point p, dword keyflags) { if(!pctrl) return; Point pt(p); - ctrl = GetCtrl(*pctrl, pt, flags, filter); + int f(flags); + ctrl = GetCtrl(*pctrl, pt, f, filter); if(!ctrl) ctrl = pctrl; if(!ctrl) return; WhenRightDown(*ctrl, p, keyflags); @@ -121,3 +123,4 @@ void CtrlFinder::RightDown(Point p, dword keyflags) if(WhenBar) MenuBar::Execute(WhenBar); } + diff --git a/bazaar/CtrlFinder/CtrlFinder.h b/bazaar/CtrlFinder/CtrlFinder.h index ad3774160..fc31e1c53 100644 --- a/bazaar/CtrlFinder/CtrlFinder.h +++ b/bazaar/CtrlFinder/CtrlFinder.h @@ -27,7 +27,7 @@ public: DEF = VISIBLE | INVISIBLE | ENABLED | DISABLED | VIEW | FRAME | DEEP, }; - CtrlFinder() : flags(DEF), filter(STDBACK(StdCtrlFilter)) {} + CtrlFinder() : flags(DEF), filter(STDBACK(StdCtrlFilter)) { WantFocus(); } virtual void LeftDown(Point p, dword keyflags); virtual void RightDown(Point p, dword keyflags); diff --git a/bazaar/CtrlPos/CtrlPos.cpp b/bazaar/CtrlPos/CtrlPos.cpp index 65e602854..c0a8b712c 100644 --- a/bazaar/CtrlPos/CtrlPos.cpp +++ b/bazaar/CtrlPos/CtrlPos.cpp @@ -68,7 +68,11 @@ void CtrlPos::DrawHintFrame(Draw& w, const Ctrl& g, const Ctrl& q, const Color& Ctrl* c = q.GetFirstChild(); while(c) { - if(c->InView()) + Ctrl* e(c); + Point p; p.Clear(); + int f(flags); + filter(e, p, f); + if(e && c->InView()) { Rect r = c->GetRect(); if(c->InView()) @@ -78,7 +82,8 @@ void CtrlPos::DrawHintFrame(Draw& w, const Ctrl& g, const Ctrl& q, const Color& r.Inflate(1); RectCtrl::DrawHandleFrame(w, r, hintcol, 1); } - DrawHintFrame(w, g, *c, hintcol); + if(f & CtrlFinder::DEEP) + DrawHintFrame(w, g, *c, hintcol); c = c->GetNext(); } } @@ -166,7 +171,8 @@ void CtrlPos::LeftDown(Point p, dword keyflags) if(pctrl) { Point pt(p); - ctrl = CtrlFinder::GetCtrl(*pctrl, pt, flags, filter); + int f(flags); + ctrl = CtrlFinder::GetCtrl(*pctrl, pt, f, filter); if(ctrl) { if(ctrl->InFrame()) //may not move base nor frames @@ -328,6 +334,18 @@ void CtrlPos::LeftDouble(Point p, dword flags) WhenLeftDouble(); } +bool CtrlPos::Key(dword key, int count) +{ + if(key == K_SPACE) + { + ClearCtrl(); + Action(); + Refresh(); + return true; + } + return false; +} + void CtrlPos::Updated() { //refresh the view of the currently selected ctrl @@ -338,6 +356,7 @@ CtrlPos::CtrlPos() : pressed(false), moving(false), mode(RectCtrl::NONE), g(4,4) { BackPaint(); + NoIgnoreMouse(); style = &RectCtrl::StyleDefault(); //xpos.SetNull(); xp.SetNull(); diff --git a/bazaar/CtrlPos/CtrlPos.h b/bazaar/CtrlPos/CtrlPos.h index 971d45852..ef3c9ae17 100644 --- a/bazaar/CtrlPos/CtrlPos.h +++ b/bazaar/CtrlPos/CtrlPos.h @@ -31,6 +31,7 @@ public: virtual void RightDown(Point p, dword keyflags); virtual void MouseWheel(Point p, int zdelta, dword keyflags); virtual void LeftDouble(Point p, dword flags); + virtual bool Key(dword key, int count); virtual void Updated(); virtual Rect GetVoidRect() const { return Ctrl::GetVoidRect(); } @@ -38,7 +39,7 @@ public: static void DrawAlignHandle(Draw& w, const Rect& _r, const Rect& r, const Ctrl::LogPos& pos, const Color& col); static bool GetAlignMode(const Rect& _r, const Rect& r, const Point& pp, Ctrl::LogPos& pos, int handsize); - static void DrawHintFrame(Draw& w, const Ctrl& g, const Ctrl& q, const Color& hintcol); + void DrawHintFrame(Draw& w, const Ctrl& g, const Ctrl& q, const Color& hintcol); Callback WhenLeftDouble; diff --git a/bazaar/CtrlPosTest/CtrlPosTest.h b/bazaar/CtrlPosTest/CtrlPosTest.h index 1e0e84d71..659b0af2a 100644 --- a/bazaar/CtrlPosTest/CtrlPosTest.h +++ b/bazaar/CtrlPosTest/CtrlPosTest.h @@ -15,6 +15,8 @@ public: typedef CtrlPosTest CLASSNAME; CtrlPosTest(); + virtual void Activate(); + void VisitCB(); void ClearCB(); void EnableCB(); diff --git a/bazaar/CtrlPosTest/main.cpp b/bazaar/CtrlPosTest/main.cpp index 100e490e5..663cbe126 100644 --- a/bazaar/CtrlPosTest/main.cpp +++ b/bazaar/CtrlPosTest/main.cpp @@ -24,6 +24,7 @@ void CtrlPosTest::ClearCB() void CtrlPosTest::EnableCB() { hk.Enable(); + hk.SetFocus(); } void CtrlPosTest::DisableCB() { @@ -90,6 +91,12 @@ CtrlPosTest::CtrlPosTest() hk.WhenLeftDown = THISBACK(OnSelect); hk.SetSource(&vis); + hk.SetFocus(); +} + +void CtrlPosTest::Activate() +{ + hk.SetFocus(); } GUI_APP_MAIN diff --git a/bazaar/CtrlPosTest2/CtrlPosTest2.h b/bazaar/CtrlPosTest2/CtrlPosTest2.h index c04df012d..3ed0dfb33 100644 --- a/bazaar/CtrlPosTest2/CtrlPosTest2.h +++ b/bazaar/CtrlPosTest2/CtrlPosTest2.h @@ -16,6 +16,7 @@ public: typedef CtrlPosTest2 CLASSNAME; CtrlPosTest2(); + virtual void Activate(); //keep the visiting control separated from the CtrlFinder (aka CtrlPos) //so simply visiting this TopWindow is not possible (cause of Ctrl Tree search from bottom) diff --git a/bazaar/CtrlPosTest2/main.cpp b/bazaar/CtrlPosTest2/main.cpp index 43056d971..8136ec81f 100644 --- a/bazaar/CtrlPosTest2/main.cpp +++ b/bazaar/CtrlPosTest2/main.cpp @@ -12,6 +12,12 @@ CtrlPosTest2::CtrlPosTest2() sc.AddPane(vis); sc.WhenScrolled = callback(&hk, &CtrlPos::UpdateRefresh); hk.SetSource(&vis); //will add itself to vis->GetParent --> to this TopWindow with same vis.GetPos to cover it perfectly. + hk.SetFocus(); +} + +void CtrlPosTest2::Activate() +{ + hk.SetFocus(); } GUI_APP_MAIN