Exemplo n.º 1
0
bool Ctrl::AddScroll(const Rect& sr, int dx, int dy)
{
	GuiLock __;
	if(!top)
		return true;
	for(int i = 0; i < top->scroll.GetCount(); i++) {
		Scroll& sc = top->scroll[i];
		if(sc.rect == sr && sgn(dx) == sgn(sc.dx) && sgn(dy) == sgn(sc.dy)) {
			sc.dx += dx;
			sc.dy += dy;
			ScrollRefresh(sc.rect, sc.dx, sc.dy);
			return false;
		}
		if(sc.rect.Intersects(sr)) {
			sc.rect |= sr;
			sc.dx = sc.dy = 0;
			WndInvalidateRect(sc.rect);
			return true;
		}
	}
	Scroll& sc = top->scroll.Add();
	sc.rect = sr;
	sc.dx = dx;
	sc.dy = dy;
	ScrollRefresh(sc.rect, sc.dx, sc.dy);
	return false;
}
Exemplo n.º 2
0
/**
 * @brief マウスが動かされたときに呼び出されます。
 * @param x マウス座標x
 * @param y マウス座標y
 * @param bFromScrollTimer スクロールタイマーから呼ばれたらtrue、ウィンドウメッセージから呼ばれたらfalse
 */
void CFootyView::OnMouseMove(int x, int y, bool bFromScrollTimer)
{
	// 宣言
	CEditPosition cNowPosition;
	CEditPosition cSelStart,cSelEnd;
	
	// 現在のマウス位置を設定
	m_nNowMousePosX = x;
	m_nNowMousePosY = y;
	
	// ドラッグしている情報に応じて分岐
	switch(m_nDragMode)
	{
//ドラッグしていない
	case DRAGMODE_NONE:
		// マウスカーソルを変更する
		if (m_nRulerHeight < y)
		{
			if (m_nLineCountWidth < x)
			{
				if (CalcInfoFromMouse(x,y,&cNowPosition) &&
					IsOnUrl(&cNowPosition,NULL) != ONURL_NONE)
					CCursor::UseUrlCursor();	// URL上
				else CCursor::UseIBeam();		// Iビーム
			}
			else CCursor::UseLineCount();		// 行番号表示領域
		}
		else CCursor::UseArrow();
		break;

//行番号表示領域をドラッグ中
	case DRAGMODE_LINE:
		if (y < m_nRulerHeight)
		{
			StartVerticalScrollTimer( (int)((y - m_nRulerHeight) / PIXEL_PER_LINESPEED) - 1 );
		}
		else if (y > m_nHeight)
		{
			StartVerticalScrollTimer( (int)((y - m_nHeight) / PIXEL_PER_LINESPEED) + 1 );
		}
		else
		{
			StopVerticalScrollTimer();
		}
		
		if (CalcLineCount(y,&cSelStart,&cSelEnd))		// きちんと取得できたときのみ選択
		{
			if (cSelStart < *m_pDocuments->GetLineSelStartA())
			{
				m_pDocuments->SetSelectStart(&cSelStart);
				m_pDocuments->SetSelectEndNormal(m_pDocuments->GetLineSelStartB());
				*m_pDocuments->GetCaretPosition() = cSelStart;
			}
			else 
			{
				m_pDocuments->SetSelectStart(m_pDocuments->GetLineSelStartA());
				m_pDocuments->SetSelectEndNormal(&cSelEnd);
				*m_pDocuments->GetCaretPosition() = cSelEnd;
			}
		}
		m_pDocuments->SendMoveCaretCallBack();

		// 再描画処理
		Refresh();
		m_cCaret.Hide();
		break;

//マウスでエディタ上をドラッグ中
	case DRAGMODE_MOUSE:
		// 水平方向
		if ( x < m_nLineCountWidth )	// 行番号表示領域より左
		{
			StartHorizontalScrollTimer((int)((x - m_nLineCountWidth) / PIXEL_PER_COLUMNSPEED) - 1);
			x = m_nLineCountWidth;
		}
		else if	( m_nWidth < x )		// 行番号表示領域より左
		{
			StartHorizontalScrollTimer((int)((x - m_nWidth) / PIXEL_PER_COLUMNSPEED) + 1);
			x = m_nWidth;
		}
		else
		{
			StopHorizontalScrollTimer();
		}
		// 垂直方向
		if ( y < m_nRulerHeight )		// ルーラーより上
		{
			StartVerticalScrollTimer((int)((y - m_nRulerHeight) / PIXEL_PER_LINESPEED) - 1);
			y = m_nRulerHeight;
		}
		else if ( y > m_nHeight )		// 画面より下
		{
			StartVerticalScrollTimer((int)((y - m_nHeight) / PIXEL_PER_LINESPEED) + 1);
			y = m_nHeight;
		}
		else
		{
			StopVerticalScrollTimer();
		}
		
		CalcInfoFromMouse( x, y, &cNowPosition );
		
		// キャレット位置が移動したときに再描画する
		if (cNowPosition != *m_pDocuments->GetCaretPosition())
		{
			m_pDocuments->SetSelectEndNormal(&cNowPosition);
			
			// 現在の位置をキャレットに
			LinePt pRenderStart = m_pDocuments->GetCaretPosition()->GetLinePointer();
			*m_pDocuments->GetCaretPosition() = cNowPosition;

			// 再描画をかける
			if (bFromScrollTimer)
			{
				ScrollRefresh();
			}
			else
			{
				LineChangedRefresh(pRenderStart,cNowPosition.GetLinePointer());
			}

			// キャレットは非表示に
			m_cCaret.Hide();
			m_pDocuments->SendMoveCaretCallBack();
		}
		break;
	}
}