/*------------------------------------------------------------------- CVSplitter::MoveWin スプリッターを移動させる -------------------------------------------------------------------*/ bool CVSplitter::MoveWin(int x,int y,int nWidth,int nHeight){ FOOTY2_PRINTF( L"MoveWin y=%d, nHeight=%d\n", y, nHeight ); /*エラーチェック*/ if (x <= 0 || m_nBaseWidth < x)return false; if (nHeight < y)return false; /*アタッチされたビューを移動させる*/ if (m_pViews){ FOOTY2_PRINTF( L"MoveWinOK y=%d, nHeight=%d\n", y, nHeight ); if (m_nMode == SPLIT_DUAL){ m_pViews[0].MoveWin(m_nBaseX,m_nBaseY,x-m_nBaseX,nHeight); m_pViews[1].MoveWin(x+SPLIT_SIZE,m_nBaseY,nWidth-(x-m_nBaseX)-SPLIT_SIZE,nHeight); FOOTY2_PRINTF( L"MoveWinD y=%d, nHeight=%d\n", y, nHeight ); } else if (m_pOtherSplit){ m_pViews[0].MoveWin(m_nBaseX,y,x-m_nBaseX,m_pOtherSplit->GetY()-y); m_pViews[1].MoveWin(x+SPLIT_SIZE,y,nWidth-x-SPLIT_SIZE,m_pOtherSplit->GetY()-y); m_pViews[2].MoveWin(m_nBaseX,m_pOtherSplit->GetY()+SPLIT_SIZE, x-m_nBaseX,nHeight-(m_pOtherSplit->GetY()-y)-SPLIT_SIZE); m_pViews[3].MoveWin(x+SPLIT_SIZE,m_pOtherSplit->GetY()+SPLIT_SIZE, nWidth-x-SPLIT_SIZE,nHeight-(m_pOtherSplit->GetY()-y)-SPLIT_SIZE); FOOTY2_PRINTF( L"MoveWinQ y=%d, nHeight=%d\n", y, nHeight ); } } /*スプリットバーを移動させる*/ MoveWindow(GetWnd(),x,y,SPLIT_SIZE,nHeight,true); /*メンバ変数を代入*/ m_x = x; m_y = y; return true; }
/*------------------------------------------------------------------- CVSplitter::OnMouseMove マウスが動かされたときの処理 -------------------------------------------------------------------*/ void CVSplitter::OnMouseMove(int x,int y){ /*if (m_bDrag) MoveWin(m_x+x,m_y,m_nBaseWidth,m_nBaseHeight); CCursor::UseRightLeft();*/ // 中央でのドラッグ処理追加 by Tetr@pod if (m_bDrag) { if (m_nMode == SPLIT_QUAD && m_pOtherSplit && m_bIsCenter) {// 中心か? FOOTY2_PRINTF( L"Center dragging! x=%d, y=%d, mx=%d, my=%d, omx=%d, omy=%d\n", x, y, m_x, m_y, m_pOtherSplit->GetX(), m_pOtherSplit->GetY() ); MoveWin(m_x+x,m_y,m_nBaseWidth,m_nBaseHeight); m_pOtherSplit->OnBaseWindowMove(m_nBaseX,m_nBaseY,m_nBaseWidth,m_nBaseHeight); m_pOtherSplit->MoveWin(m_pOtherSplit->GetX(),y,m_nBaseWidth,m_nBaseHeight); CCursor::UseCross(); } else { MoveWin(m_x+x,m_y,m_nBaseWidth,m_nBaseHeight); CCursor::UseRightLeft(); } } else { if (m_nMode == SPLIT_QUAD && m_pOtherSplit && y >= m_pOtherSplit->GetY() - SPLIT_CENTER_RANGE1 && y < m_pOtherSplit->GetY() + SPLIT_CENTER_RANGE2) {// 中心か? CCursor::UseCross(); } else { CCursor::UseRightLeft(); } } }
/** * @brief 水平スクロールタイマーが実行されたときの処理 */ void CFootyView::OnAutoHorizontalTimer() { CEditPosition cNowPosition; int x = m_nNowMousePosX; int y = m_nNowMousePosY; 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) y = m_nRulerHeight; CalcInfoFromMouse( x, y, &cNowPosition ); // 最初に見える桁数を調整します int nMax = max( 0, min ( (int)m_pDocuments->GetLapelColumn(), (int)(cNowPosition.GetLinePointer()->GetLineLength() - m_nVisibleColumns / 2) )); m_nFirstVisibleColumn += m_nAutoScrollNumHorizontal; if (m_nFirstVisibleColumn < 0) { m_nFirstVisibleColumn = 0; } if ( m_nFirstVisibleColumn > nMax ) { m_nFirstVisibleColumn = nMax; } FOOTY2_PRINTF( L"OnAutoHorizontalTimer first visible column = %d", m_nFirstVisibleColumn ); // 現在の位置をキャレットに m_pDocuments->SetSelectEndNormal(&cNowPosition); *m_pDocuments->GetCaretPosition() = cNowPosition; // 再描画 Refresh(); }
/** * CFootyDoc::InsertString * @brief 現在のキャレット位置に文字を挿入します。 * @param pString 挿入する文字列(NULL終端) * @param bRecUndo trueのときアンドゥを記録する * @param bOverwritable INSERTキーによる上書きチェックを有効にする * @param bMemLineMode 改行コードをこの文章のコードとして保存する */ CFootyDoc::RedrawType CFootyDoc::InsertString (const wchar_t *pString,bool bRecUndo,bool bOverwritable,bool bMemLineMode) { FOOTY2_PRINTF( L"InsertString開始\n"); // 宣言 const wchar_t *pWork; //!< 改行位置検索用 std::wstring strRestLine; //!< 挿入位置以降のデータ LinePt pLine,pBeginLine; size_t nNumLines = 0; size_t nPos; CUndoBuffer cUndo; // エラーチェック if ( !pString )return REDRAW_FAILED; if ( IsReadOnly() ) return REDRAW_FAILED; // 上書きの場合は if (bOverwritable && !m_bInsertMode && !IsSelecting()) { // 長さを計測する size_t nStrLen = wcslen(pString); size_t nLineLeft = m_cCaretPos.GetLinePointer()->GetLineLength() - m_cCaretPos.GetPosition(); // 選択処理 SetSelectStart(); m_cCaretPos.MoveColumnForward(&m_lsLines,min(nLineLeft,nStrLen)); SetSelectEndNormal(); // そして、再帰 return InsertString(pString); } // 選択位置情報を削除してアンドゥ情報を代入 if (bRecUndo) { if (IsSelecting()) { DeleteSelected(&cUndo); cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_REPLACE; } else cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_INSERT; cUndo.m_cAfterStart = m_cCaretPos; cUndo.m_strAfter = pString; } else DeleteSelected(NULL); // キャレットの位置を取得する pLine = m_cCaretPos.GetLinePointer(); pBeginLine = pLine; nPos = m_cCaretPos.GetPosition(); // 文字を走査していく for (pWork=pString;;pWork++) { if (*pWork == L'\r') { if (*(pWork+1) == L'\n') // CRLF { ReturnLine(&pLine,&pString,pWork, nPos,&strRestLine,2,nNumLines==0); nNumLines++; pWork++; if (bMemLineMode)m_nLineMode = LM_CRLF; FOOTY2_PRINTF( L"InsertString CRLF発見\n"); } else // キャリッジリターンのみ { ReturnLine(&pLine,&pString,pWork, nPos,&strRestLine,1,nNumLines==0); nNumLines++; if (bMemLineMode)m_nLineMode = LM_CR; FOOTY2_PRINTF( L"InsertString CR発見\n"); } } else if (*pWork == L'\n') // ラインフィード { ReturnLine(&pLine,&pString,pWork, nPos,&strRestLine,1,nNumLines==0); nNumLines++; if (bMemLineMode)m_nLineMode = LM_LF; FOOTY2_PRINTF( L"InsertString LF発見\n"); } else if (*pWork == L'\0') // 終端文字 { FOOTY2_PRINTF( L"InsertString走査終了\n"); if (!nNumLines) // 今までに改行が無かったとき { FOOTY2_PRINTF( L"InsertString改行なし\n"); // その位置に全ての文字列を挿入する pLine->m_strLineData.insert(nPos,pString); FOOTY2_PRINTF( L"InsertString変更確定しそう\n"); SetLineInfo(pBeginLine, false/*改行を含むか by Tetr@pod*/); FOOTY2_PRINTF( L"InsertString変更確定\n"); // キャレット位置を移動させる m_cCaretPos.MoveColumnForward(&m_lsLines,(size_t)(pWork-pString)); } else // 改行があったとき { FOOTY2_PRINTF( L"InsertString改行あり\n"); // バックアップ文字列を代入する pLine->m_strLineData = pString + strRestLine; // 変更を確定する FOOTY2_PRINTF( L"InsertString変更確定しそう\n"); SetLineInfo(pBeginLine,pLine, true/*改行を含むか by Tetr@pod*/); FOOTY2_PRINTF( L"InsertString変更確定\n"); // キャレット位置を移動させる m_cCaretPos.MoveRealNext(&m_lsLines,nNumLines); m_cCaretPos.MoveColumnForward(&m_lsLines,(size_t)(pWork-pString)); } FOOTY2_PRINTF( L"InsertStringアンドゥ情報追加\n"); // アンドゥ情報を挿入する if (bRecUndo) { cUndo.m_cAfterEnd = m_cCaretPos; PushBackUndo(&cUndo); } break; } } FOOTY2_PRINTF( L"InsertString終了間際\n"); SendMoveCaretCallBack(); FOOTY2_PRINTF( L"InsertString終了\n"); return REDRAW_ALL; }
/** * @brief ビューウィンドウを作成する処理です * @param hWndParent [in] 親ウィンドウ * @param hInstance [in] DLLの実行インスタンス */ bool CFootyView::CreateFootyView( HWND hWndParent, HINSTANCE hInstance ) { if (!hWndParent || !hInstance ) { FOOTY2_PRINTF( L"invalid window handle\n" ); return false; } FOOTY2_ASSERT( m_pDocuments ); FOOTY2_ASSERT( m_pView ); FOOTY2_ASSERT( m_pFonts ); FOOTY2_ASSERT( m_pStatus ); // すでに生成済みの場合はいったん破棄 if ( m_hWnd ) { DestroyFootyView(); } // メンバ変数を設定 m_hOwner = hWndParent; FOOTY2_PRINTF( L"CFootyView::Create()\n" ); FOOTY2_PRINTF( L"m_hOwner = %d, m_nFootyID = %d\n", m_hOwner, m_nFootyID ); // Footyメインウィンドウの形成 WNDCLASSW wc; // ウィンドウクラス wc.style = CS_DBLCLKS #ifndef UNDER_CE | CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW #endif /*not defined UNDER_CE*/ ; wc.lpfnWndProc = FootyWinProc; wc.hInstance = hInstance; wc.hIcon = NULL; wc.hCursor = NULL; // 状態によって適宜変更する wc.hbrBackground = (HBRUSH)NULL; wc.lpszMenuName = NULL; wc.lpszClassName = FOOTY_WNDCLASSNAME; wc.cbClsExtra = 0; // 使用しない。0を指定 wc.cbWndExtra = 0; // 使用しない。0を指定 RegisterClass(&wc); // ウィンドウクラスの登録 m_hWnd = CreateWindowEx ( WS_EX_CLIENTEDGE,FOOTY_WNDCLASSNAME,FOOTY_WNDCLASSNAME, WS_CHILD | WS_VSCROLL | WS_HSCROLL, 0,0,0,0,hWndParent,NULL,hInstance,NULL ); if ( !m_hWnd ) { // ウィンドウが作成できなかった return false; } SetProp( m_hWnd, FOOTY_PROPNAME, (HANDLE)this ); // クラスを登録 // メンバ変数の初期化 m_nFirstVisibleColumn = 0; m_pDocuments->GetFirstVisible( m_nViewID )->SetPosition( m_pDocuments->GetLineList(), 0, 0 ); m_cCaret.SetParam( m_hWnd ); return true; }