Iterator.cpp
资源名称:视频会议系统.rar [点击查看]
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:5k
源码类别:
IP电话/视频会议
开发平台:
Visual C++
- // Iterator.cpp: implementation of the CIterator class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "Iterator.h"
- #include "..WB.h"
- #include "..DrawView.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CIterator::CIterator( CDrawView * view )
- {
- this->hCursor = ::AfxGetApp( )->LoadStandardCursor( MAKEINTRESOURCE( IDC_ARROW ) );
- this->hOldCursor = NULL;
- this->view = view;
- this->rect.SetRect( 0 , 0 , 33 , 22 );
- this->drag = false;
- this->dragPoint = CPoint( 0 , 0 );
- this->imglist.Create( IDB_WB_ITERATOR , 33 , 1 , RGB( 255 , 0 , 0 ) );
- this->m_bShow = false;
- }
- CIterator::~CIterator( )
- {
- if( this->hCursor )
- ::DestroyCursor( this->hCursor );
- this->view = NULL;
- }
- void CIterator::SetIterator( bool * m_bShow , CPoint * point )
- {
- if( m_bShow == NULL && point == NULL )
- {
- this->m_bShow = ! this->m_bShow;
- CPoint pt = this->view->GetScrollPosition( );
- if( pt.y >= this->rect.top )
- {
- CRect rc;
- this->view->GetClientRect( &rc );
- rc.OffsetRect( pt );
- this->rect.OffsetRect( rc.CenterPoint( ) - this->rect.TopLeft( ) );
- }
- this->view->Invalidate( );
- //通知外部指示器变化
- int size = 0;
- //用户名
- size += this->view->userName.GetLength( ) + sizeof( char );
- //id
- size += sizeof( int );
- //图元类型
- size += sizeof( int );
- //图元的操作
- size += sizeof( int );
- //图元的参数(包括 是否显示、坐标)
- size += 3 * sizeof( int );
- char * buffer = new char[ size ];
- char * now = buffer;
- //用户名
- strcpy( now , this->view->userName ); now += this->view->userName.GetLength( ) + sizeof( char );
- //图元id
- *( int * )now = 0; now += sizeof( int );
- //图元的类型
- *( int * )now = 0; now += sizeof( int );
- //图元的操作
- *( int * )now = CDrawView::ITERATOR; now += sizeof( int );
- //图元的参数
- *( int * )now = this->m_bShow; now += sizeof( int );
- //图元的坐标
- *( int * )now = this->rect.left; now += sizeof( int );
- *( int * )now = this->rect.top;
- //通知外部程序
- this->view->OnWB( this->view->pContext , this->view->GetParent( ) , buffer , size );
- delete buffer;
- }
- else
- {
- this->m_bShow = * m_bShow;
- this->rect.OffsetRect( * point - this->rect.TopLeft( ) );
- }
- }
- void CIterator::Draw( CDC * pDC )
- {
- if( this && this->m_bShow )
- this->imglist.Draw( pDC , 0 , this->rect.TopLeft( ) , ILD_TRANSPARENT );
- }
- bool CIterator::LButtonDown( UINT nFlags , CPoint point )
- {
- if( this && this->m_bShow && ( nFlags & MK_LBUTTON ) && this->rect.PtInRect( point ) )
- {
- this->dragPoint = point;
- this->drag = true;
- return true;
- }
- return false;
- }
- bool CIterator::LButtonUp( UINT nFlags , CPoint point )
- {
- if( this && this->m_bShow && this->drag )
- {
- this->drag = false;
- //通知外部指示器变化
- int size = 0;
- //用户名
- size += this->view->userName.GetLength( ) + sizeof( char );
- //id
- size += sizeof( int );
- //图元类型
- size += sizeof( int );
- //图元的操作
- size += sizeof( int );
- //图元的参数(包括 是否显示、坐标)
- size += 3 * sizeof( int );
- char * buffer = new char[ size ];
- char * now = buffer;
- //用户名
- strcpy( now , this->view->userName ); now += this->view->userName.GetLength( ) + sizeof( char );
- //图元id
- *( int * )now = 0; now += sizeof( int );
- //图元的类型
- *( int * )now = 0; now += sizeof( int );
- //图元的操作
- *( int * )now = CDrawView::ITERATOR; now += sizeof( int );
- //图元的参数
- *( int * )now = this->m_bShow; now += sizeof( int );
- //图元的坐标
- *( int * )now = this->rect.left; now += sizeof( int );
- *( int * )now = this->rect.top;
- //通知外部程序
- this->view->OnWB( this->view->pContext , this->view->GetParent( ) , buffer , size );
- delete buffer;
- return true;
- }
- return false;
- }
- bool CIterator::MouseMove( UINT nFlags , CPoint point )
- {
- if( this )
- {
- if( ! ( nFlags & MK_LBUTTON ) )
- {
- if( this->rect.PtInRect( point ) )
- {
- if( ! this->hOldCursor )
- this->hOldCursor = ( HCURSOR )::SetClassLong( this->view->GetSafeHwnd( ) , GCL_HCURSOR , ( long )this->hCursor );
- }
- else if( this->hOldCursor )
- {
- ::SetClassLong( this->view->GetSafeHwnd( ) , GCL_HCURSOR , ( long )this->hOldCursor );
- this->hOldCursor = NULL;
- }
- }
- if( ( nFlags & MK_LBUTTON ) && this->drag )
- {
- this->rect.OffsetRect( point - this->dragPoint );
- this->dragPoint = point;
- this->view->Invalidate( );
- return true;
- }
- }
- return false;
- }