Exemplo n.º 1
0
/**
 * @brief ダブルクリックしたときに呼び出されます。
 */
void CFootyView::OnMouseDouble(int x,int y)
{
	// 宣言
	CEditPosition cNowPosition;
	CUrlInfo cUrlInfo;
	RetOnUrl nRetURL;
	std::wstring strShellCommand;

	// フォーカスを合わせる
	::SetFocus(m_hWnd);
	
	// 通常のエディタ領域
	if (y > m_nRulerHeight && x > m_nLineCountWidth)
	{
		// キャレット位置を移動する
		CalcInfoFromMouse(x,y,&cNowPosition);
		// クリッカブル?
		nRetURL = IsOnUrl(&cNowPosition,&cUrlInfo);
		if (nRetURL == ONURL_URL)				// URL
		{
			strShellCommand = cNowPosition.GetLinePointer()->
				m_strLineData.substr(cUrlInfo.m_nStartPos,cUrlInfo.GetLength());
			StartApplication(strShellCommand.c_str());
		}
		else if (nRetURL == ONURL_MAIL)			// メールアドレス
		{
			strShellCommand = L"mailto:";
			strShellCommand += cNowPosition.GetLinePointer()->
				m_strLineData.substr(cUrlInfo.m_nStartPos,cUrlInfo.GetLength());
			StartApplication(strShellCommand.c_str());
		}
		else									// 何もない(単語の選択処理)
		{
			m_pDocuments->SelectWord();
			Refresh();
		}
	}
}
Exemplo n.º 2
0
/**
 * Footy2GetSel
 * @brief 選択の開始位置を取得する
 * @param nID FootyのID
 * @param pStartLine [out]選択開始行
 * @param pStartPos [out]選択開始桁
 * @param pEndLine [out]選択終了行
 * @param pEndPos [out]選択終了桁
 */
FOOTYEXPORT(int) Footy2GetSel(int nID,size_t *pStartLine,size_t *pStartPos,size_t *pEndLine,size_t *pEndPos){
	/*Footyを取得する*/
	CFooty *pFooty = GetFooty(nID);
	if (!pFooty)return FOOTY2ERR_NOID;
	/*選択位置を取得する*/
	if (pFooty->m_cDoc.IsSelecting()){
		CEditPosition *pStart = pFooty->m_cDoc.GetSelStart();
		CEditPosition *pEnd = pFooty->m_cDoc.GetSelEnd();
		/*ポインタに返す*/
		if (pStartLine)
			*pStartLine = pStart->GetLineNum();
		if (pStartPos)
			*pStartPos = pStart->GetPosition();
		if (pEndLine)
			*pEndLine = pEnd->GetLineNum();
		if (pEndPos)
			*pEndPos = pEnd->GetPosition();
		/*正常に終了した*/
		return FOOTY2ERR_NONE;
	}
	else
		return FOOTY2ERR_NOTSELECTED;
}
Exemplo n.º 3
0
/*-------------------------------------------------------------------
CPosInfo::CPosInfo
コンストラクタ
-------------------------------------------------------------------*/
size_t CUndoBuffer::CPosInfo::operator = (CEditPosition &cPos){
	m_nLineNum = cPos.GetLineNum();
	m_nPosition = cPos.GetPosition();
	return m_nLineNum;
}
Exemplo n.º 4
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;
	}
}