ultimatepp/bazaar/AutoScroller/AutoScroller.h
klugier a6bda7eb9f Bazaar: AutoScroller now uses always single inclued.
git-svn-id: svn://ultimatepp.org/upp/trunk@15202 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2020-10-04 20:25:02 +00:00

50 lines
919 B
C++

#ifndef _AutoScroller_AutoScroller_hpp_
#define _AutoScroller_AutoScroller_hpp_
#include "AutoScrollerParentCtrl.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