ultimatepp/bazaar/AutoScroller/AutoScroller.hpp
kohait 43b6edb721 bazaar: Gen: SerializeStore, Link<> helpers, Dispatcher uses Gen version of GetLinkCount
git-svn-id: svn://ultimatepp.org/upp/trunk@3309 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2011-03-25 07:12:28 +00:00

52 lines
1,013 B
C++

#ifndef _AutoScroller_AutoScroller_hpp_
#define _AutoScroller_AutoScroller_hpp_
#include "AutoScroller.h"
template<class C>
AutoScroller<C>::AutoScroller()
{
EnableScroll();
scroll.WhenScroll = THISBACK(OnScroll);
Add(pane.TopPos(0).LeftPos(0));
SetPaneSize(GetSize());
}
template<class C>
void AutoScroller<C>::OnScroll()
{
Rect r(-scroll.Get(), pane.GetRect().GetSize());
pane.SetRect(r);
}
template<class C>
void AutoScroller<C>::Layout()
{
Size sz = GetSize();
if(sz != scroll.GetPage())
scroll.SetPage(sz);
}
template<class C>
void AutoScroller<C>::SetPaneSize(const Size & sz)
{
Ctrl::LogPos logp;
logp.x = ParentCtrl::PosLeft(0, sz.cx);
logp.y = ParentCtrl::PosTop(0, sz.cy);
pane.SetPos(logp);
scroll.SetTotal(sz);
}
template<class C>
void AutoScroller<C>::EnableScroll(bool b)
{
if(b) AddFrame(scroll.AutoHide());
else RemoveFrame(scroll);
scroll.x.Enable(b);
scroll.y.Enable(b);
return;
scroll.Show(b);
Layout();
}
#endif