#ifndef __XSROLL_H__
#define __XSROLL_H__ #include "CocoHead.h"
#include "XWindow.h" class ENGINE_API CXSroll : public CXWindow
{
public:
enum XSrollType
{
_SrollDirectionVertical = , //垂直
_SrollDirectionHorizontal = , //水平
_SrollVerticalTable = , //垂直选项(Table类型)
_SrollHorizontalTable = , //水平选项(Table类型)
_SrollDirectionBoth = ,
}; public:
CXSroll();
virtual ~CXSroll(); static CXSroll* create(int nId, CCPoint tPos, CCRect rect, const char* psPic = NULL, CXWindow* pParentWnd = NULL); virtual bool init( int nId, CCPoint tPos, CCRect rect, const char* psPic = NULL, CXWindow* pParentWnd = NULL ); virtual UI_TYPE getUIType(); void setSrollType(CXSroll::XSrollType eSrollType);
CXSroll::XSrollType getSrollType(); void addItem(CXWindow* pWnd);
void addItem(CXWindow* pWnd, int nZOrder); void setBounds(float fBounds);
float getBounds(); CXWindow* getItemChildById(int nItemId, int nChildId);
deque<CXWindow*>* getItemDequeById(int nItemId);
map<CXWindow*, deque<CXWindow*> >& getMapItem(); void setTouchDistribute(bool bDistribute); void setItemEnabled(unsigned int wIndex,unsigned int wCount); void setDisableDrag(bool bDisable); protected: virtual void visit(); virtual bool onMouseDown(CCTouch *pTouch, CCEvent *pEvent);
virtual void onMouseUp(CCTouch *pTouch, CCEvent *pEvent);
virtual void onMouseMove(CCTouch *pTouch, CCEvent *pEvent); void setItemPos(CXWindow* pWnd); void deaccelerateScrolling(float dt); void clippingToBounds(float dt); private:
CCNode* m_pContainer;
map<CXWindow*, deque<CXWindow*> > m_mapItem; //集装箱字典
deque<CXWindow*> m_dequeItem;
vector<CXWindow*> m_vecItem;//防止m_mapItem无序 XSrollType m_eSrollType;
float m_fItemPosLenght; //总长度 bool m_bSelected;
CCPoint m_tUnitMoveDist;
CCPoint m_tOriginalPos;
CCPoint m_tEndPos; CCPoint m_tContainerDownPos;
CCPoint m_tContainerUpPos;
CCPoint m_tContainerDragDist; unsigned int m_nTableFocusIndex;
float m_fBounds;
int m_nTableDragDistFold; //
CXWindow* m_pFocusWnd;
bool m_bFocusWndClick;
bool m_bDistributeTouch; bool m_bDisableDrag; }; #endif//__XSROLL_H__
05-11 16:16