ultimatepp/bazaar/AutoScroller/AutoScroller.hpp
klugier bf5cedfca7 Bazaar: AutoScruoller now in Upp namespace.
git-svn-id: svn://ultimatepp.org/upp/trunk@15025 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2020-09-12 21:29:10 +00:00

50 lines
909 B
C++

#ifndef _AutoScroller_AutoScroller_hpp_
#define _AutoScroller_AutoScroller_hpp_
#include "AutoScroller.h"
namespace Upp
{
template<class C>
AutoScroller<C>::AutoScroller()
{
C::AddFrame(scroll);
scroll.AutoHide();
scroll.WhenScroll = THISBACK(OnScroll);
}
template<class C>
void AutoScroller<C>::Scroll(const Point& p)
{
if(!HasPane()) return;
Rect _r = pane->GetRect();
Rect r(-p, _r.GetSize());
pane->SetRect(r);
WhenScrolled();
}
template<class C>
void AutoScroller<C>::OnScroll()
{
Scroll(scroll.Get());
}
template<class C>
void AutoScroller<C>::Layout()
{
Size psz = C::GetSize();
scroll.SetPage(psz);
if(!HasPane()) return;
Size tsz = pane->GetSize();
scroll.SetTotal(tsz);
}
template<class C>
void AutoScroller<C>::EnableScroll(bool b)
{
scroll.x.Enable(b);
scroll.y.Enable(b);
}
}
#endif