mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Bazaar: AutoScruoller now in Upp namespace.
git-svn-id: svn://ultimatepp.org/upp/trunk@15025 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
e2a1fb5fe5
commit
bf5cedfca7
3 changed files with 73 additions and 66 deletions
|
|
@ -1,3 +1,6 @@
|
|||
#include "AutoScroller.hpp"
|
||||
|
||||
template class AutoScroller<ParentCtrl>;
|
||||
namespace Upp
|
||||
{
|
||||
template class AutoScroller<ParentCtrl>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,36 +2,37 @@
|
|||
#define _AutoScroller_AutoScroller_h_
|
||||
|
||||
#include <CtrlLib/CtrlLib.h>
|
||||
using namespace Upp;
|
||||
|
||||
template<class C = ParentCtrl>
|
||||
class AutoScroller : public C
|
||||
namespace Upp
|
||||
{
|
||||
public:
|
||||
typedef AutoScroller<C> CLASSNAME;
|
||||
AutoScroller();
|
||||
template<class C = ParentCtrl>
|
||||
class AutoScroller : public C
|
||||
{
|
||||
public:
|
||||
using CLASSNAME = AutoScroller<C>;
|
||||
AutoScroller();
|
||||
|
||||
public:
|
||||
virtual void Layout();
|
||||
|
||||
void EnableScroll(bool b = true);
|
||||
void DisableScroll() { EnableScroll(false); }
|
||||
bool IsEnabledScroll() const { return scroll.x.IsEnabled() || scroll.y.IsEnabled(); }
|
||||
|
||||
public:
|
||||
virtual void Layout();
|
||||
void AddPane(Ctrl& c) { ClearPane(); pane = &c; C::Add(c); }
|
||||
Ctrl* GetPane() const { return pane; }
|
||||
inline bool HasPane() const { return (~pane != NULL); }
|
||||
void ClearPane() { if(! ~pane) return; pane->Remove(); pane = NULL; }
|
||||
|
||||
void EnableScroll(bool b = true);
|
||||
void DisableScroll() { EnableScroll(false); }
|
||||
bool IsEnabledScroll() const { return scroll.x.IsEnabled() || scroll.y.IsEnabled(); }
|
||||
|
||||
void AddPane(Ctrl& c) { ClearPane(); pane = &c; C::Add(c); }
|
||||
Ctrl* GetPane() const { return pane; }
|
||||
inline bool HasPane() const { return (~pane != NULL); }
|
||||
void ClearPane() { if(! ~pane) return; pane->Remove(); pane = NULL; }
|
||||
|
||||
void Scroll(const Point& p);
|
||||
void OnScroll();
|
||||
|
||||
Callback WhenScrolled;
|
||||
ScrollBars scroll;
|
||||
|
||||
protected:
|
||||
Ptr<Ctrl> pane;
|
||||
};
|
||||
|
||||
void Scroll(const Point& p);
|
||||
void OnScroll();
|
||||
|
||||
Callback WhenScrolled;
|
||||
ScrollBars scroll;
|
||||
|
||||
protected:
|
||||
Ptr<Ctrl> pane;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,45 +3,48 @@
|
|||
|
||||
#include "AutoScroller.h"
|
||||
|
||||
template<class C>
|
||||
AutoScroller<C>::AutoScroller()
|
||||
namespace Upp
|
||||
{
|
||||
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);
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue