DragBar.cpp
上传用户:garry_shen
上传日期:2015-04-15
资源大小:45647k
文件大小:4k
- // DragBar.cpp: implementation of the CDragBar class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "XMudClient.h"
- #include "DragBar.h"
- #include "FacePlate.h"
- #include "MainScreen.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- extern CMainScreen m_MainScreen;
- extern rmfullglobals myglobs;
- CDragBar::CDragBar(int nMaxShow, int left, int top, int right, int bottom)
- {
- SetRect(&rcUpBtnDownSour,14,600,27,617);
- SetRect(&rcDownBtnDownSour,28,600,41,617);
- SetRect(&rcDragBarSour,0,600,13,626);
- bUpBtnDown = FALSE;
- bDownBtnDown = FALSE;
- bPreDrag = FALSE;
- nMousey = 0;
- nDragBary = 0;
- rcThis.left = left;
- rcThis.top = top;
- rcThis.right = right;
- rcThis.bottom = bottom;
- nDragBarSpace = bottom - top - 62;
- nDragBarUpSpace = 0;
- rcDragBarBtn = rcThis;
- rcUpBtn = rcThis;
- rcDownBtn = rcThis;
- rcUpBtn.bottom = rcUpBtn.top + 17;
- rcDownBtn.top = rcDownBtn.bottom - 17;
- rcDragBarBtn.top = rcUpBtn.bottom + 1;
- rcDragBarBtn.bottom = rcDragBarBtn.top + 26;
- nMax = nMaxShow;
- nRecordCount = 0;
- nFirstPos = 0;
- }
- CDragBar::~CDragBar()
- {
- }
- BOOL CDragBar::LButtonDown(POINT Pos)
- {
- if(!PtInRect(&rcThis,Pos)) return FALSE;
- if(PtInRect(&rcUpBtn,Pos)){
- bUpBtnDown = TRUE;
- nFirstPos--;
- }else if(PtInRect(&rcDownBtn,Pos)){
- bDownBtnDown = TRUE;
- nFirstPos++;
- }else if(PtInRect(&rcDragBarBtn,Pos)){
- if(nRecordCount > nMax){
- bPreDrag = TRUE;
- nMousey = Pos.y;
- nDragBary = rcDragBarBtn.top;
- }
- }
- else if((Pos.y > rcUpBtn.bottom)&&(Pos.y < rcDragBarBtn.top)){
- nFirstPos -= nMax;
- }
- else if((Pos.y > rcDragBarBtn.bottom)&&(Pos.y < rcDownBtn.top)){
- nFirstPos += nMax;
- }
- else return FALSE;
- m_MainScreen.mFirstFD.bReDraw[0]=TRUE;
- m_MainScreen.mFirstFD.bReDraw[1]=TRUE;
- m_MainScreen.mSecondFD.bReDraw[0]=TRUE;
- m_MainScreen.mSecondFD.bReDraw[1]=TRUE;
- m_MainScreen.mTalkFD.bReDraw[0]=TRUE;
- m_MainScreen.mTalkFD.bReDraw[1]=TRUE;
- // ReDraw();
- return TRUE;
- }
- BOOL CDragBar::LButtonUp(POINT Pos)
- {
- if(bUpBtnDown) bUpBtnDown = FALSE;
- else if(bDownBtnDown) bDownBtnDown = FALSE;
- else if(bPreDrag) bPreDrag = FALSE;
- else return FALSE;
- m_MainScreen.mFirstFD.bReDraw[0]=TRUE;
- m_MainScreen.mFirstFD.bReDraw[1]=TRUE;
- m_MainScreen.mSecondFD.bReDraw[0]=TRUE;
- m_MainScreen.mSecondFD.bReDraw[1]=TRUE;
- m_MainScreen.mTalkFD.bReDraw[0]=TRUE;
- m_MainScreen.mTalkFD.bReDraw[1]=TRUE;
- // ReDraw();
- return FALSE;
- }
- BOOL CDragBar::OnMouseMove(POINT Pos)
- {
- if(bPreDrag)
- {
- rcDragBarBtn.top = (Pos.y - nMousey) + nDragBary;
- if(rcDragBarBtn.top <= rcUpBtn.bottom)
- rcDragBarBtn.top = rcUpBtn.bottom + 1;
- if(rcDragBarBtn.top >= rcDownBtn.top - 26)
- rcDragBarBtn.top = rcDownBtn.top - 27;
- rcDragBarBtn.bottom = rcDragBarBtn.top + 26;
- nDragBarUpSpace = rcDragBarBtn.top - rcUpBtn.bottom;
- nFirstPos = nDragBarUpSpace * (nRecordCount - nMax) / nDragBarSpace;
- m_MainScreen.mFirstFD.bReDraw[0]=TRUE;
- m_MainScreen.mFirstFD.bReDraw[1]=TRUE;
- m_MainScreen.mSecondFD.bReDraw[0]=TRUE;
- m_MainScreen.mSecondFD.bReDraw[1]=TRUE;
- m_MainScreen.mTalkFD.bReDraw[0]=TRUE;
- m_MainScreen.mTalkFD.bReDraw[1]=TRUE;
- // ReDraw();
- return TRUE;
- }
- else return FALSE;
- }
- void CDragBar::ReDraw()
- {
- if(nFirstPos < 0) nFirstPos = 0;
- else if(nRecordCount <= nMax)
- nFirstPos = 0;
- else if(nFirstPos > nRecordCount - nMax)
- nFirstPos = nRecordCount - nMax;
- bltObject(rcThis.left,
- rcThis.top,
- myglobs.g_lpDDSGameMenu,
- &rcThis,
- DDBLTFAST_SRCCOLORKEY);
- if(bUpBtnDown)//礶