void SQRCheckButton::DrawWndBackground() { m_beBGDrawed = true; //处于选中状态 if( m_bCheck ) DrawBackImage( m_hWnd->m_Enable, m_hWnd->m_Disable, m_MouseOverImage, m_ClickDownImage, IsHeld() ); else { CFPos pt = GetCursorPos(); if( IsHeld() ) { SetEventStateMask(IP_UNCHECK_CLICKDOWN); DrawRect( m_UncheckClickDownImage ); } else if( IsInWndArea( pt.x, pt.y ) && IsEnable() && IsLastMouseMsgWnd() ) { SetEventStateMask(IP_UNCHECK_MOUSEOVER); DrawRect( m_UncheckMouseOverImage ); } else if( !IsEnable() ) { SetEventStateMask(IP_UNCHECK_DISABLE); DrawRect( m_UncheckDisableImage ); } else if( m_uFlashCircle && m_uFlashEndTime - m_uFlashStartTime > uint32(GetProcessTime()) - m_uFlashStartTime ) { float fAlpha = GetTransparent(); float fWeight = abs( (float)( ( uint32(GetProcessTime()) - m_uFlashStartTime )%( m_uFlashCircle*2 ) - m_uFlashCircle ) )/m_uFlashCircle; SetTransparent( fAlpha*fWeight ); SetEventStateMask(IP_UNCHECK_ENABLE); DrawRect( m_UncheckEnableImage ); SetTransparent( fAlpha*( 1.0f - fWeight ) ); SetEventStateMask(IP_UNCHECK_MOUSEOVER); DrawRect( m_UncheckMouseOverImage ); SetTransparent( fAlpha ); } else { SetEventStateMask(IP_UNCHECK_ENABLE); DrawRect( m_UncheckEnableImage ); } } }
/*! 対括弧の強調表示 @date 2002/09/18 ai @date 2003/02/18 ai 再描画対応の為大改造 */ void CEditView::DrawBracketPair( bool bDraw ) { // 03/03/06 ai すべて置換、すべて置換後のUndo&Redoがかなり遅い問題に対応 if( m_bDoing_UndoRedo || !GetDrawSwitch() ){ return; } if( !m_pTypeData->m_ColorInfoArr[COLORIDX_BRACKET_PAIR].m_bDisp ){ return; } // 括弧の強調表示位置が未登録の場合は終了 if( m_ptBracketPairPos_PHY.HasNegative() || m_ptBracketCaretPos_PHY.HasNegative() ){ return; } // 描画指定(bDraw=true) かつ // ( テキストが選択されている 又は // 選択範囲を描画している 又は // フォーカスを持っていない 又は // アクティブなペインではない ) 場合は終了 if( bDraw &&( GetSelectionInfo().IsTextSelected() || GetSelectionInfo().m_bDrawSelectArea || !m_bDrawBracketPairFlag || ( m_pcEditWnd->GetActivePane() != m_nMyIndex ) ) ){ return; } CGraphics gr; gr.Init(::GetDC(GetHwnd())); bool bCaretChange = false; gr.SetTextBackTransparent(true); for( int i = 0; i < 2; i++ ) { // i=0:対括弧,i=1:カーソル位置の括弧 // 2011.11.23 ryoji 対括弧 -> カーソル位置の括弧 の順に処理順序を変更 // # { と } が異なる行にある場合に { を BS で消すと } の強調表示が解除されない問題(Wiki BugReport/89)の対策 // # この順序変更によりカーソル位置が括弧でなくなっていても対括弧があれば対括弧側の強調表示は解除される CLayoutPoint ptColLine; if( i == 0 ){ m_pcEditDoc->m_cLayoutMgr.LogicToLayout( m_ptBracketPairPos_PHY, &ptColLine ); }else{ m_pcEditDoc->m_cLayoutMgr.LogicToLayout( m_ptBracketCaretPos_PHY, &ptColLine ); } if ( ( ptColLine.x >= GetTextArea().GetViewLeftCol() ) && ( ptColLine.x <= GetTextArea().GetRightCol() ) && ( ptColLine.y >= GetTextArea().GetViewTopLine() ) && ( ptColLine.y <= GetTextArea().GetBottomLine() ) ) { // 表示領域内の場合 if( !bDraw && GetSelectionInfo().m_bDrawSelectArea && ( 0 == IsCurrentPositionSelected( ptColLine ) ) ) { // 選択範囲描画済みで消去対象の括弧が選択範囲内の場合 continue; } const CLayout* pcLayout; CLogicInt nLineLen; const wchar_t* pLine = m_pcEditDoc->m_cLayoutMgr.GetLineStr( ptColLine.GetY2(), &nLineLen, &pcLayout ); if( pLine ) { EColorIndexType nColorIndex; CLogicInt OutputX = LineColumnToIndex( pcLayout, ptColLine.GetX2() ); if( bDraw ) { nColorIndex = COLORIDX_BRACKET_PAIR; } else{ if( IsBracket( pLine, OutputX, CLogicInt(1) ) ){ DispPos _sPos(0,0); // 注意:この値はダミー。CheckChangeColorでの参照位置は不正確 SColorStrategyInfo _sInfo; SColorStrategyInfo* pInfo = &_sInfo; pInfo->m_pDispPos = &_sPos; pInfo->m_pcView = this; // 03/10/24 ai 折り返し行のColorIndexが正しく取得できない問題に対応 // 2009.02.07 ryoji GetColorIndex に渡すインデックスの仕様変更(元はこっちの仕様だった模様) CColor3Setting cColor = GetColorIndex( pcLayout, ptColLine.GetY2(), OutputX, pInfo ); nColorIndex = cColor.eColorIndex2; } else{ SetBracketPairPos( false ); break; } } CTypeSupport cCuretLineBg(this,COLORIDX_CARETLINEBG); EColorIndexType nColorIndexBg = (cCuretLineBg.IsDisp() && ptColLine.GetY2() == GetCaret().GetCaretLayoutPos().GetY2() ? COLORIDX_CARETLINEBG : CTypeSupport(this,COLORIDX_EVENLINEBG).IsDisp() && ptColLine.GetY2() % 2 == 1 ? COLORIDX_EVENLINEBG : COLORIDX_TEXT); // 03/03/03 ai カーソルの左に括弧があり括弧が強調表示されている状態でShift+←で選択開始すると // 選択範囲内に反転表示されない部分がある問題の修正 CLayoutInt caretX = GetCaret().GetCaretLayoutPos().GetX2(); bool bCaretHide = (!bCaretChange && (ptColLine.x == caretX || ptColLine.x + 1 == caretX) && GetCaret().GetCaretShowFlag()); if( bCaretHide ){ bCaretChange = true; GetCaret().HideCaret_( GetHwnd() ); // キャレットが一瞬消えるのを防止 } { int nWidth = GetTextMetrics().GetHankakuDx(); int nHeight = GetTextMetrics().GetHankakuDy(); int nLeft = (GetTextArea().GetDocumentLeftClientPointX()) + GetTextMetrics().GetCharPxWidth(ptColLine.x); int nTop = (Int)( ptColLine.GetY2() - GetTextArea().GetViewTopLine() ) * nHeight + GetTextArea().GetAreaTop(); CLayoutXInt charsWidth = m_pcEditDoc->m_cLayoutMgr.GetLayoutXOfChar(pLine, nLineLen, OutputX); //色設定 CTypeSupport cTextType(this,COLORIDX_TEXT); cTextType.SetGraphicsState_WhileThisObj(gr); // 2013.05.24 背景色がテキストの背景色と同じならカーソル行の背景色を適用 CTypeSupport cColorIndexType(this,nColorIndex); CTypeSupport cColorIndexBgType(this,nColorIndexBg); CTypeSupport* pcColorBack = &cColorIndexType; if( cColorIndexType.GetBackColor() == cTextType.GetBackColor() && nColorIndexBg != COLORIDX_TEXT ){ pcColorBack = &cColorIndexBgType; } SetCurrentColor( gr, nColorIndex, nColorIndex, nColorIndexBg ); bool bTrans = false; // DEBUG_TRACE( _T("DrawBracket %d %d ") , ptColLine.y, ptColLine.x ); if( IsBkBitmap() && cTextType.GetBackColor() == pcColorBack->GetBackColor() ){ bTrans = true; RECT rcChar; rcChar.left = nLeft; rcChar.top = nTop; rcChar.right = nLeft + GetTextMetrics().GetCharPxWidth(charsWidth); rcChar.bottom = nTop + nHeight; HDC hdcBgImg = ::CreateCompatibleDC(gr); HBITMAP hBmpOld = (HBITMAP)::SelectObject(hdcBgImg, m_pcEditDoc->m_hBackImg); DrawBackImage(gr, rcChar, hdcBgImg); ::SelectObject(hdcBgImg, hBmpOld); ::DeleteDC(hdcBgImg); } DispPos sPos(nWidth, nHeight); sPos.InitDrawPos(CMyPoint(nLeft, nTop)); GetTextDrawer().DispText(gr, &sPos, 0, &pLine[OutputX], 1, bTrans); GetTextDrawer().DispNoteLine(gr, nTop, nTop + nHeight, nLeft, nLeft + (Int)charsWidth * nWidth); // 2006.04.30 Moca 対括弧の縦線対応 GetTextDrawer().DispVerticalLines(gr, nTop, nTop + nHeight, ptColLine.x, ptColLine.x + charsWidth); //※括弧が全角幅である場合を考慮 cTextType.RewindGraphicsState(gr); } if( ( m_pcEditWnd->GetActivePane() == m_nMyIndex ) && ( ( ptColLine.y == GetCaret().GetCaretLayoutPos().GetY() ) || ( ptColLine.y - 1 == GetCaret().GetCaretLayoutPos().GetY() ) ) ){ // 03/02/27 ai 行の間隔が"0"の時にアンダーラインが欠ける事がある為修正 GetCaret().m_cUnderLine.CaretUnderLineON( true, false ); } } } } if( bCaretChange ){ GetCaret().ShowCaret_( GetHwnd() ); // キャレットが一瞬消えるのを防止 } ::ReleaseDC( GetHwnd(), gr ); }
void SQRButton::DrawWndBackground() { m_beBGDrawed = true; if(m_hWnd->m_bIsShowBackground) DrawBackImage( m_hWnd->m_Enable, m_hWnd->m_Disable, m_MouseOverImage, m_ClickDownImage, IsHeld() ); }
/*! 通常の描画処理 new @param pPs pPs.rcPaint は正しい必要がある @param bDrawFromComptibleBmp TRUE 画面バッファからhdcに作画する(コピーするだけ)。 TRUEの場合、pPs.rcPaint領域外は作画されないが、FALSEの場合は作画される事がある。 互換DC/BMPが無い場合は、普通の作画処理をする。 @date 2007.09.09 Moca 元々無効化されていた第三パラメータのbUseMemoryDCをbDrawFromComptibleBmpに変更。 @date 2009.03.26 ryoji 行番号のみ描画を通常の行描画と分離(効率化) */ void CEditView::OnPaint2( HDC _hdc, PAINTSTRUCT *pPs, BOOL bDrawFromComptibleBmp ) { // MY_RUNNINGTIMER( cRunningTimer, "CEditView::OnPaint" ); CGraphics gr(_hdc); // 2004.01.28 Moca デスクトップに作画しないように if( NULL == GetHwnd() || NULL == _hdc )return; if( !GetDrawSwitch() )return; //@@@ #if 0 ::MYTRACE( _T("OnPaint(%d,%d)-(%d,%d) : %d\n"), pPs->rcPaint.left, pPs->rcPaint.top, pPs->rcPaint.right, pPs->rcPaint.bottom, bDrawFromComptibleBmp ); #endif // From Here 2007.09.09 Moca 互換BMPによる画面バッファ // 互換BMPからの転送のみによる作画 if( bDrawFromComptibleBmp && m_hdcCompatDC && m_hbmpCompatBMP ){ ::BitBlt( gr, pPs->rcPaint.left, pPs->rcPaint.top, pPs->rcPaint.right - pPs->rcPaint.left, pPs->rcPaint.bottom - pPs->rcPaint.top, m_hdcCompatDC, pPs->rcPaint.left, pPs->rcPaint.top, SRCCOPY ); if ( m_pcEditWnd->GetActivePane() == m_nMyIndex ){ /* アクティブペインは、アンダーライン描画 */ GetCaret().m_cUnderLine.CaretUnderLineON( true, false ); } return; } if( m_hdcCompatDC && NULL == m_hbmpCompatBMP || m_nCompatBMPWidth < (pPs->rcPaint.right - pPs->rcPaint.left) || m_nCompatBMPHeight < (pPs->rcPaint.bottom - pPs->rcPaint.top) ){ RECT rect; ::GetWindowRect( this->GetHwnd(), &rect ); CreateOrUpdateCompatibleBitmap( rect.right - rect.left, rect.bottom - rect.top ); } // To Here 2007.09.09 Moca // キャレットを隠す bool bCaretShowFlag_Old = GetCaret().GetCaretShowFlag(); // 2008.06.09 ryoji GetCaret().HideCaret_( this->GetHwnd() ); // 2002/07/22 novice RECT rc; int nLineHeight = GetTextMetrics().GetHankakuDy(); int nCharDx = GetTextMetrics().GetCharPxWidth(); //サポート CTypeSupport cTextType(this,COLORIDX_TEXT); //@@@ 2001.11.17 add start MIK //変更があればタイプ設定を行う。 if( m_pTypeData->m_bUseRegexKeyword || m_cRegexKeyword->m_bUseRegexKeyword ) //OFFなのに前回のデータが残ってる { //タイプ別設定をする。設定済みかどうかは呼び先でチェックする。 m_cRegexKeyword->RegexKeySetTypes(m_pTypeData); } //@@@ 2001.11.17 add end MIK bool bTransText = IsBkBitmap(); // メモリDCを利用した再描画の場合は描画先のDCを切り替える HDC hdcOld = 0; // 2007.09.09 Moca bUseMemoryDCを有効化。 // bUseMemoryDC = FALSE; BOOL bUseMemoryDC = (m_hdcCompatDC != NULL); assert_warning(gr != m_hdcCompatDC); bool bClipping = false; if( bUseMemoryDC ){ hdcOld = gr; gr = m_hdcCompatDC; }else{ if( bTransText || pPs->rcPaint.bottom - pPs->rcPaint.top <= 2 || pPs->rcPaint.right - pPs->rcPaint.left <= 2 ){ // 透過処理の場合フォントの輪郭が重ね塗りになるため自分でクリッピング領域を設定 // 2以下はたぶんアンダーライン・カーソル行縦線の作画 // MemoryDCの場合は転送が矩形クリッピングの代わりになっている gr.SetClipping(pPs->rcPaint); bClipping = true; } } /* 03/02/18 対括弧の強調表示(消去) ai */ if( !bUseMemoryDC ){ // MemoryDCだとスクロール時に先に括弧だけ表示されて不自然なので後でやる。 DrawBracketPair( false ); } CEditView& cActiveView = m_pcEditWnd->GetActiveView(); m_nPageViewTop = cActiveView.GetTextArea().GetViewTopLine(); m_nPageViewBottom = cActiveView.GetTextArea().GetBottomLine(); // 背景の表示 if( bTransText ){ HDC hdcBgImg = CreateCompatibleDC(gr); HBITMAP hOldBmp = (HBITMAP)::SelectObject(hdcBgImg, m_pcEditDoc->m_hBackImg); DrawBackImage(gr, pPs->rcPaint, hdcBgImg); SelectObject(hdcBgImg, hOldBmp); DeleteObject(hdcBgImg); } /* ルーラーとテキストの間の余白 */ //@@@ 2002.01.03 YAZAKI 余白が0のときは無駄でした。 if ( GetTextArea().GetTopYohaku() ){ if( !bTransText ){ rc.left = 0; rc.top = GetTextArea().GetRulerHeight(); rc.right = GetTextArea().GetAreaRight(); rc.bottom = GetTextArea().GetAreaTop(); cTextType.FillBack(gr,rc); } } /* 行番号の表示 */ // From Here Sep. 7, 2001 genta // Sep. 23, 2002 genta 行番号非表示でも行番号色の帯があるので隙間を埋める if( GetTextArea().GetTopYohaku() ){ if( bTransText && m_pTypeData->m_ColorInfoArr[COLORIDX_GYOU].m_sColorAttr.m_cBACK == cTextType.GetBackColor() ){ }else{ rc.left = 0; rc.top = GetTextArea().GetRulerHeight(); rc.right = GetTextArea().GetLineNumberWidth(); // Sep. 23 ,2002 genta 余白はテキスト色のまま残す rc.bottom = GetTextArea().GetAreaTop(); gr.SetTextBackColor(m_pTypeData->m_ColorInfoArr[COLORIDX_GYOU].m_sColorAttr.m_cBACK); gr.FillMyRectTextBackColor(rc); } } // To Here Sep. 7, 2001 genta ::SetBkMode( gr, TRANSPARENT ); cTextType.SetGraphicsState_WhileThisObj(gr); int nTop = pPs->rcPaint.top; // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // // 描画開始レイアウト絶対行 -> nLayoutLine // // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // CLayoutInt nLayoutLine; if( 0 > nTop - GetTextArea().GetAreaTop() ){ nLayoutLine = GetTextArea().GetViewTopLine(); //ビュー上部から描画 }else{ nLayoutLine = GetTextArea().GetViewTopLine() + CLayoutInt( ( nTop - GetTextArea().GetAreaTop() ) / nLineHeight ); //ビュー途中から描画 } // ※ ここにあった描画範囲の 260 文字ロールバック処理は GetColorIndex() に吸収 // 2009.02.11 ryoji // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // // 描画終了レイアウト絶対行 -> nLayoutLineTo // // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // CLayoutInt nLayoutLineTo = GetTextArea().GetViewTopLine() + CLayoutInt( ( pPs->rcPaint.bottom - GetTextArea().GetAreaTop() + (nLineHeight - 1) ) / nLineHeight ) - 1; // 2007.02.17 ryoji 計算を精密化 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // // 描画座標 // // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // DispPos sPos(nCharDx, GetTextMetrics().GetHankakuDy()); sPos.InitDrawPos(CMyPoint( GetTextArea().GetAreaLeft() - (Int)GetTextArea().GetViewLeftCol() * nCharDx, GetTextArea().GetAreaTop() + (Int)( nLayoutLine - GetTextArea().GetViewTopLine() ) * nLineHeight )); sPos.SetLayoutLineRef(nLayoutLine); // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // // 全部の行を描画 // // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // //必要な行を描画する // 2009.03.26 ryoji 行番号のみ描画を通常の行描画と分離(効率化) if(pPs->rcPaint.right <= GetTextArea().GetAreaLeft()){ while(sPos.GetLayoutLineRef() <= nLayoutLineTo) { if(!sPos.GetLayoutRef()) break; //1行描画(行番号のみ) GetTextDrawer().DispLineNumber( gr, sPos.GetLayoutLineRef(), sPos.GetDrawPos().y ); //行を進める sPos.ForwardDrawLine(1); //描画Y座標++ sPos.ForwardLayoutLineRef(1); //レイアウト行++ } }else{ while(sPos.GetLayoutLineRef() <= nLayoutLineTo) { //描画X位置リセット sPos.ResetDrawCol(); //1行描画 bool bDispResult = DrawLogicLine( gr, &sPos, nLayoutLineTo ); if(bDispResult){ // EOF再描画対応 nLayoutLineTo++; int nBackImageTop = pPs->rcPaint.bottom; pPs->rcPaint.bottom += nLineHeight; if(bClipping){ gr.SetClipping(pPs->rcPaint); } if(bTransText){ HDC hdcBgImg = CreateCompatibleDC(gr); HBITMAP hOldBmp = (HBITMAP)::SelectObject(hdcBgImg, m_pcEditDoc->m_hBackImg); RECT rc = pPs->rcPaint; rc.top = nBackImageTop; DrawBackImage(gr, rc, hdcBgImg); SelectObject(hdcBgImg, hOldBmp); DeleteObject(hdcBgImg); } } } } cTextType.RewindGraphicsState(gr); // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // // ルーラー描画 // // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // if ( pPs->rcPaint.top < GetTextArea().GetRulerHeight() ) { // ルーラーが再描画範囲にあるときのみ再描画する 2002.02.25 Add By KK GetRuler().SetRedrawFlag(); //2002.02.25 Add By KK ルーラー全体を描画。 GetRuler().DispRuler( gr ); } // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // // その他後始末など // // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // /* メモリDCを利用した再描画の場合はメモリDCに描画した内容を画面へコピーする */ if( bUseMemoryDC ){ // 2010.10.11 先に描くと背景固定のスクロールなどでの表示が不自然になる DrawBracketPair( false ); ::BitBlt( hdcOld, pPs->rcPaint.left, pPs->rcPaint.top, pPs->rcPaint.right - pPs->rcPaint.left, pPs->rcPaint.bottom - pPs->rcPaint.top, gr, pPs->rcPaint.left, pPs->rcPaint.top, SRCCOPY ); } // From Here 2007.09.09 Moca 互換BMPによる画面バッファ // アンダーライン描画をメモリDCからのコピー前処理から後に移動 if ( m_pcEditWnd->GetActivePane() == m_nMyIndex ){ /* アクティブペインは、アンダーライン描画 */ GetCaret().m_cUnderLine.CaretUnderLineON( true, false ); } // To Here 2007.09.09 Moca /* 03/02/18 対括弧の強調表示(描画) ai */ DrawBracketPair( true ); /* キャレットを現在位置に表示します */ if( bCaretShowFlag_Old ) // 2008.06.09 ryoji GetCaret().ShowCaret_( this->GetHwnd() ); // 2002/07/22 novice return; }