Skip to content

Commit

Permalink
#1246 の revert
Browse files Browse the repository at this point in the history
  • Loading branch information
beru committed May 6, 2020
1 parent ac1e9fb commit 49f29c7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 23 deletions.
4 changes: 1 addition & 3 deletions sakura_core/view/CCaret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ void CCaret::ShowCaretPosInfo()
}

auto& statusBar = m_pEditDoc->m_pcEditWnd->m_cStatusBar;
::SendMessage(statusBar.GetStatusHwnd(), WM_SETREDRAW, (WPARAM)FALSE, 0);

if( m_bClearStatus ){
statusBar.SetStatusText( 0, SBT_NOBORDERS, L"" );
}
Expand All @@ -846,8 +846,6 @@ void CCaret::ShowCaretPosInfo()
statusBar.SetStatusText( 4, 0, pszCodeName );
statusBar.SetStatusText( 5, SBT_OWNERDRAW, L"" );
statusBar.SetStatusText( 6, 0, szText_6 );
::SendMessage(statusBar.GetStatusHwnd(), WM_SETREDRAW, (WPARAM)TRUE, 0);
::RedrawWindow(statusBar.GetStatusHwnd(), NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
}
}

Expand Down
23 changes: 7 additions & 16 deletions sakura_core/window/CMainStatusBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void CMainStatusBar::DestroyStatusBar()
void CMainStatusBar::SendStatusMessage2( const WCHAR* msg )
{
if( NULL != m_hwndStatusBar ){
SetStatusText(0, SBT_NOBORDERS, msg, SIZE_MAX, false);
SetStatusText(0, SBT_NOBORDERS, msg);
}
}

Expand All @@ -107,14 +107,15 @@ void CMainStatusBar::SendStatusMessage2( const WCHAR* msg )
@param pszText [in] 表示テキスト
@param textLen [in] 表示テキストの文字数
*/
void CMainStatusBar::SetStatusText(int nIndex, int nOption, const WCHAR* pszText, size_t textLen /* = SIZE_MAX */, bool bSendMessage /* = true */)
void CMainStatusBar::SetStatusText(int nIndex, int nOption, const WCHAR* pszText, size_t textLen /* = SIZE_MAX */)
{
if( !m_hwndStatusBar ){
assert(m_hwndStatusBar != NULL);
return;
}
// SB_SETTEXT メッセージを発行するかどうかを判定するラムダ式
bool bNeedsToDraw = [&]() -> bool {
// StatusBar_SetText 関数を呼びだすかどうかを判定するラムダ式
// (StatusBar_SetText は SB_SETTEXT メッセージを SendMessage で送信する)
[&]() -> bool {
// オーナードローの場合は SB_SETTEXT メッセージを無条件に発行するように判定
// 本来表示に変化が無い場合には呼び出さない方が表示のちらつきが減るので好ましいが
// 判定が難しいので諦める
Expand Down Expand Up @@ -149,22 +150,12 @@ void CMainStatusBar::SetStatusText(int nIndex, int nOption, const WCHAR* pszText
return true;
}
if( prevTextLen > 0 ){
StatusBar_GetText( m_hwndStatusBar, nIndex, prev );
::StatusBar_GetText( m_hwndStatusBar, nIndex, prev );
// 設定済みの文字列と設定する文字列を比較して異なる場合は、SB_SETTEXT メッセージを発行
return (wcscmp(prev, pszText) != 0);
}
else{
return true;
}
}();
if (bNeedsToDraw) {
if (bSendMessage) {
::SendMessageW( m_hwndStatusBar, SB_SETTEXT, nIndex | nOption, (LPARAM)pszText );
}else {
std::unique_ptr<wchar_t[]> p(new wchar_t[textLen+1]);
std::copy(pszText, pszText+textLen+1, p.get());
::PostMessageW( m_hwndStatusBar, SB_SETTEXT, nIndex | nOption, (LPARAM)p.get() );
m_postponeBuffers[nIndex] = std::move(p);
}
};
}() ? StatusBar_SetText( m_hwndStatusBar, nIndex | nOption, pszText ) : 0;
}
5 changes: 1 addition & 4 deletions sakura_core/window/CMainStatusBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#pragma once

#include "doc/CDocListener.h"
#include <array>
#include <memory>

class CEditWnd;

Expand Down Expand Up @@ -54,10 +52,9 @@ class CMainStatusBar : public CDocListenerEx{
HWND GetProgressHwnd() const{ return m_hwndProgressBar; }

//設定
void SetStatusText(int nIndex, int nOption, const WCHAR* pszText, size_t textLen = SIZE_MAX, bool bSendMessage = true);
void SetStatusText(int nIndex, int nOption, const WCHAR* pszText, size_t textLen = SIZE_MAX);
private:
CEditWnd* m_pOwner;
HWND m_hwndStatusBar;
HWND m_hwndProgressBar;
std::array<std::unique_ptr<wchar_t[]>, 7> m_postponeBuffers;
};

0 comments on commit 49f29c7

Please sign in to comment.