Skip to content

Commit 3b0614b

Browse files
committed
CEditViewからCMiniMapViewを切り離す
全部は無理なので少しずつ対応する。
1 parent 366f01f commit 3b0614b

5 files changed

Lines changed: 71 additions & 30 deletions

File tree

sakura_core/view/CEditView.cpp

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ BOOL CEditView::Create(
310310
/* スクロールバー作成 */
311311
CreateScrollBar(); // 2006.12.19 ryoji
312312

313-
SetFont();
313+
SetFont(GetHwnd());
314314

315315
if( bShow ){
316316
ShowWindow( GetHwnd(), SW_SHOW );
@@ -570,9 +570,6 @@ LRESULT CEditView::DispatchEvent(
570570
// 2004.04.27 To Here
571571

572572
case WM_LBUTTONDBLCLK:
573-
if( m_bMiniMap ){
574-
return 0L;
575-
}
576573
// 2007.10.02 nasukoji 非アクティブウィンドウのダブルクリック時はここでカーソルを移動する
577574
// 2007.10.12 genta フォーカス移動のため,OnLBUTTONDBLCLKより移動
578575
if(m_bActivateByMouse){
@@ -987,11 +984,8 @@ void CEditView::OnSize( int cx, int cy )
987984
}
988985

989986
/* 入力フォーカスを受け取ったときの処理 */
990-
void CEditView::OnSetFocus( void )
987+
void CEditView::OnSetFocus()
991988
{
992-
if( m_bMiniMap ){
993-
return;
994-
}
995989
// 2004.04.02 Moca EOFのみのレイアウト行は、0桁目のみ有効.EOFより下の行のある場合は、EOF位置にする
996990
{
997991
CLayoutPoint ptPos = GetCaret().GetCaretLayoutPos();
@@ -1026,11 +1020,8 @@ void CEditView::OnSetFocus( void )
10261020
}
10271021

10281022
/* 入力フォーカスを失ったときの処理 */
1029-
void CEditView::OnKillFocus( void )
1023+
void CEditView::OnKillFocus()
10301024
{
1031-
if( m_bMiniMap ){
1032-
return;
1033-
}
10341025
// 03/02/18 対括弧の強調表示(消去) ai
10351026
DrawBracketPair( false );
10361027
m_bDrawBracketPairFlag = FALSE;
@@ -1066,18 +1057,14 @@ void CEditView::OnKillFocus( void )
10661057
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
10671058

10681059
/* フォントの変更 */
1069-
void CEditView::SetFont( void )
1060+
void CEditView::SetFont(HWND hWnd)
10701061
{
1071-
HDC hdc = ::GetDC( GetHwnd() );
1062+
using WindowDcHolder = cxx::ResourceHolder<&::ReleaseDC>;
1063+
WindowDcHolder hdc{ hWnd };
1064+
hdc = ::GetDC(hWnd);
10721065

10731066
// メトリクス更新
1074-
if( m_bMiniMap ){
1075-
GetTextMetrics().Update(hdc, GetFontset().GetFontHan(), 0, 0);
1076-
}else{
1077-
GetTextMetrics().Update(hdc, GetFontset().GetFontHan(), DpiScaleY(m_pTypeData->m_nLineSpace), DpiScaleX(m_pTypeData->m_nColumnSpace));
1078-
}
1079-
1080-
::ReleaseDC( GetHwnd(), hdc );
1067+
GetTextMetrics().Update(hdc, GetFontset().GetFontHan(), DpiScaleY(m_pTypeData->m_nLineSpace), DpiScaleX(m_pTypeData->m_nColumnSpace));
10811068

10821069
// エリア情報を更新
10831070
GetTextArea().UpdateAreaMetrics();
@@ -1086,7 +1073,7 @@ void CEditView::SetFont( void )
10861073
GetTextArea().DetectWidthOfLineNumberArea( false );
10871074

10881075
// ぜんぶ再描画
1089-
::InvalidateRect( GetHwnd(), nullptr, TRUE );
1076+
::InvalidateRect(hWnd, nullptr, TRUE);
10901077

10911078
// Oct. 11, 2002 genta IMEのフォントも変更
10921079
SetIMECompFormFont();
@@ -1656,7 +1643,7 @@ void CEditView::OnChangeSetting()
16561643
GetTextArea().SetLeftYohaku(DpiScaleX(GetDllShareData().m_Common.m_sWindow.m_nLineNumRightSpace));
16571644

16581645
/* フォントの変更 */
1659-
SetFont();
1646+
SetFont(GetHwnd());
16601647

16611648
/* フォントが変わっているかもしれないので、カーソル移動 */
16621649
// スクロールバーが移動するので呼び出し元でやる

sakura_core/view/CEditView.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,16 @@ class CEditView
198198
void OnSize(int cx, int cy); /* ウィンドウサイズの変更処理 */
199199
void OnMove(int x, int y, int nWidth, int nHeight);
200200
//フォーカス
201-
void OnSetFocus( void );
202-
void OnKillFocus( void );
201+
virtual void OnSetFocus();
202+
virtual void OnKillFocus();
203203
//スクロール
204204
CLayoutInt OnVScroll(int nScrollCode, int nPos); /* 垂直スクロールバーメッセージ処理 */
205205
CLayoutInt OnHScroll(int nScrollCode, int nPos); /* 水平スクロールバーメッセージ処理 */
206206
//マウス
207207
void OnLBUTTONDOWN(WPARAM fwKeys, int _xPos, int _yPos); /* マウス左ボタン押下 */
208208
void OnMOUSEMOVE(WPARAM fwKeys, int xPos_, int yPos_); /* マウス移動のメッセージ処理 */
209209
void OnLBUTTONUP(WPARAM fwKeys, int xPos, int yPos); /* マウス左ボタン開放のメッセージ処理 */
210-
void OnLBUTTONDBLCLK(WPARAM fwKeys, int _xPos, int _yPos); /* マウス左ボタンダブルクリック */
210+
virtual void OnLBUTTONDBLCLK(WPARAM fwKeys, int _xPos, int _yPos); /* マウス左ボタンダブルクリック */
211211
void OnRBUTTONDOWN(WPARAM fwKeys, int xPos, int yPos); /* マウス右ボタン押下 */
212212
void OnRBUTTONUP(WPARAM fwKeys, int xPos, int yPos); /* マウス右ボタン開放 */
213213
void OnMBUTTONDOWN(WPARAM fwKeys, int xPos, int yPos); /* マウス中ボタン押下 */
@@ -546,7 +546,7 @@ class CEditView
546546
TOGGLE_WRAP_ACTION GetWrapMode( CKetaXInt* newKetas );
547547
void SmartIndent_CPP(wchar_t wcChar); /* C/C++スマートインデント処理 */
548548
/* コマンド操作 */
549-
void SetFont( void ); /* フォントの変更 */
549+
virtual void SetFont(HWND hWnd); /* フォントの変更 */
550550
void SplitBoxOnOff(BOOL bVert, BOOL bHorz, BOOL bSizeBox); /* 縦・横の分割ボックス・サイズボックスのON/OFF */
551551

552552
// 2001/06/18 asa-o

sakura_core/view/CMiniMapView.cpp

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*! @file */
22
/*
33
Copyright (C) 2012, Moca
4-
Copyright (C) 2018-2022, Sakura Editor Organization
4+
Copyright (C) 2018-2026, Sakura Editor Organization
55
66
SPDX-License-Identifier: Zlib
77
*/
@@ -10,9 +10,39 @@
1010
#include "view/CMiniMapView.h"
1111

1212
#include "doc/CEditDoc.h"
13+
#include "window/CEditWnd.h"
1314

1415
BOOL CMiniMapView::Create( HWND hWndParent )
1516
{
1617
auto pcEditDoc = CEditDoc::getInstance();
1718
return CEditView::Create( hWndParent, pcEditDoc, -1, FALSE, true );
18-
}
19+
}
20+
21+
void CMiniMapView::OnSetFocus()
22+
{
23+
// no operation, CEditミニマップは CEditView と振る舞いを変える。
24+
}
25+
26+
void CMiniMapView::OnKillFocus()
27+
{
28+
// no operation, CEditミニマップは CEditView と振る舞いを変える。
29+
}
30+
31+
void CMiniMapView::OnLBUTTONDBLCLK([[maybe_unused]] WPARAM fwKeys, [[maybe_unused]] int _xPos, [[maybe_unused]] int _yPos)
32+
{
33+
// no operation, CEditミニマップは CEditView と振る舞いを変える。
34+
}
35+
36+
void CMiniMapView::SetFont(HWND hWnd)
37+
{
38+
using WindowDcHolder = cxx::ResourceHolder<&::ReleaseDC>;
39+
WindowDcHolder hdc{ hWnd };
40+
hdc = ::GetDC(hWnd);
41+
42+
GetTextMetrics().Update(hdc, GetFontset().GetFontHan(), 0, 0);
43+
44+
GetTextArea().UpdateAreaMetrics();
45+
GetTextArea().DetectWidthOfLineNumberArea(false);
46+
47+
::InvalidateRect(hWnd, nullptr, TRUE);
48+
}

sakura_core/view/CMiniMapView.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*! @file */
22
/*
33
Copyright (C) 2012, Moca
4-
Copyright (C) 2018-2022, Sakura Editor Organization
4+
Copyright (C) 2018-2026, Sakura Editor Organization
55
66
SPDX-License-Identifier: Zlib
77
*/
@@ -16,6 +16,19 @@
1616
*/
1717
class CMiniMapView : public CEditView
1818
{
19+
private:
20+
using Base = CEditView;
21+
using Me = CMiniMapView;
22+
1923
public:
24+
//コンストラクタは流用する
25+
using Base::Base;
26+
2027
BOOL Create( HWND hWndParent );
28+
29+
void SetFont(HWND hWnd) override;
30+
31+
void OnKillFocus() override;
32+
void OnLBUTTONDBLCLK(WPARAM fwKeys, int _xPos, int _yPos) override;
33+
void OnSetFocus() override;
2134
};

src/test/cpp/tests1/test-window.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,17 @@ TEST_F(EditWndTest, FileSaveWithBackupAgent001)
416416
std::filesystem::remove(backupPath);
417417
}
418418

419+
/*!
420+
* ミニマップの何もしないメソッド群の呼出テスト
421+
*/
422+
TEST_F(EditWndTest, MiniMapNoopMethods)
423+
{
424+
auto& minimap = pcEditWnd->GetMiniMap();
425+
426+
minimap.OnKillFocus();
427+
minimap.OnLBUTTONDBLCLK(0, 0, 0);
428+
minimap.OnSetFocus();
429+
}
419430
/*!
420431
* キャンセルダイアログの表示テスト
421432
*/

0 commit comments

Comments
 (0)