From c83e5e5396c64407764dd6a706a2583354bcc8ea Mon Sep 17 00:00:00 2001 From: Mari Sano Date: Tue, 19 Oct 2021 21:24:09 +0900 Subject: [PATCH] =?UTF-8?q?CMiniMapView=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura/sakura.vcxproj | 2 ++ sakura/sakura.vcxproj.filters | 6 ++++ sakura_core/view/CMiniMapView.cpp | 36 +++++++++++++++++++ sakura_core/view/CMiniMapView.h | 39 +++++++++++++++++++++ sakura_core/window/CEditWnd.cpp | 57 ++++++++++++++----------------- sakura_core/window/CEditWnd.h | 5 +-- 6 files changed, 112 insertions(+), 33 deletions(-) create mode 100644 sakura_core/view/CMiniMapView.cpp create mode 100644 sakura_core/view/CMiniMapView.h diff --git a/sakura/sakura.vcxproj b/sakura/sakura.vcxproj index 521393bbba..ed9d56c47a 100644 --- a/sakura/sakura.vcxproj +++ b/sakura/sakura.vcxproj @@ -460,6 +460,7 @@ + @@ -870,6 +871,7 @@ + diff --git a/sakura/sakura.vcxproj.filters b/sakura/sakura.vcxproj.filters index baa41406b6..1b4b79ed93 100644 --- a/sakura/sakura.vcxproj.filters +++ b/sakura/sakura.vcxproj.filters @@ -1112,6 +1112,9 @@ Cpp Source Files\charset + + Cpp Source Files\view + @@ -2309,6 +2312,9 @@ Cpp Source Files\charset + + Cpp Source Files\view + diff --git a/sakura_core/view/CMiniMapView.cpp b/sakura_core/view/CMiniMapView.cpp new file mode 100644 index 0000000000..8b01472bcf --- /dev/null +++ b/sakura_core/view/CMiniMapView.cpp @@ -0,0 +1,36 @@ +/*! @file */ +/* + Copyright (C) 2012, Moca + Copyright (C) 2018-2021, Sakura Editor Organization + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; + you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment + in the product documentation would be appreciated but is + not required. + + 2. Altered source versions must be plainly marked as such, + and must not be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#include "StdAfx.h" +#include "view/CMiniMapView.h" + +#include "doc/CEditDoc.h" + +BOOL CMiniMapView::Create( HWND hWndParent ) +{ + auto pcEditDoc = CEditDoc::getInstance(); + return CEditView::Create( hWndParent, pcEditDoc, -1, FALSE, true ); +} \ No newline at end of file diff --git a/sakura_core/view/CMiniMapView.h b/sakura_core/view/CMiniMapView.h new file mode 100644 index 0000000000..8868b5e1ed --- /dev/null +++ b/sakura_core/view/CMiniMapView.h @@ -0,0 +1,39 @@ +/*! @file */ +/* + Copyright (C) 2012, Moca + Copyright (C) 2018-2021, Sakura Editor Organization + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; + you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment + in the product documentation would be appreciated but is + not required. + + 2. Altered source versions must be plainly marked as such, + and must not be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ +#pragma once + +#include "view/CEditView.h" + +/*! + ミニマップ + + 編集ビューのコードを流用して縮小ビューを表示する + */ +class CMiniMapView : public CEditView +{ +public: + BOOL Create( HWND hWndParent ); +}; diff --git a/sakura_core/window/CEditWnd.cpp b/sakura_core/window/CEditWnd.cpp index 57e896b798..59c839b5c3 100644 --- a/sakura_core/window/CEditWnd.cpp +++ b/sakura_core/window/CEditWnd.cpp @@ -246,9 +246,6 @@ CEditWnd::~CEditWnd() } m_pcEditView = NULL; - delete m_pcEditViewMiniMap; - m_pcEditViewMiniMap = NULL; - delete m_pcViewFont; m_pcViewFont = NULL; @@ -621,8 +618,6 @@ HWND CEditWnd::Create( m_pcViewFont = new CViewFont(&GetLogfont()); - m_pcEditViewMiniMap = new CEditView(); - m_pcViewFontMiniMap = new CViewFont(&GetLogfont(), true); wmemset( m_pszMenubarMessage, L' ', MENUBAR_MESSAGE_MAX_LEN ); // null終端は不要 @@ -1024,12 +1019,12 @@ void CEditWnd::LayoutTabBar( void ) void CEditWnd::LayoutMiniMap( void ) { if( m_pShareData->m_Common.m_sWindow.m_bDispMiniMap ){ /* タブバーを表示する */ - if( NULL == GetMiniMap().GetHwnd() ){ - GetMiniMap().Create( GetHwnd(), GetDocument(), -1, FALSE, true ); + if( !m_cMiniMapView.GetHwnd() ){ + m_cMiniMapView.Create( GetHwnd() ); } }else{ - if( NULL != GetMiniMap().GetHwnd() ){ - GetMiniMap().Close(); + if( m_cMiniMapView.GetHwnd() ){ + m_cMiniMapView.Close(); } } } @@ -1059,8 +1054,8 @@ void CEditWnd::EndLayoutBars( BOOL bAdjust/* = TRUE*/ ) // その後、ウィンドウの下部境界を上下ドラッグしてサイズ変更するとゴミが現れることがあった。 ::SetWindowPos( m_cDlgFuncList.GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE ); } - if (NULL != GetMiniMap().GetHwnd()) { - ::ShowWindow(GetMiniMap().GetHwnd(), nCmdShow); + if( m_cMiniMapView.GetHwnd() ){ + ::ShowWindow( m_cMiniMapView.GetHwnd(), nCmdShow ); } if( bAdjust ) @@ -2523,7 +2518,7 @@ void CEditWnd::InitMenu_Function(HMENU hMenu, EFunctionCode eFunc, const wchar_t break; case F_SHOWMINIMAP: SetMenuFuncSel( hMenu, eFunc, pszKey, - !m_pShareData->m_Common.m_sWindow.m_bMenuIcon | !GetMiniMap().GetHwnd() ); + !m_pShareData->m_Common.m_sWindow.m_bMenuIcon | !m_cMiniMapView.GetHwnd() ); break; case F_TOGGLE_KEY_SEARCH: SetMenuFuncSel( hMenu, eFunc, pszKey, @@ -2953,8 +2948,8 @@ void CEditWnd::PrintPreviewModeONOFF( void ) ::ShowWindow( m_cFuncKeyWnd.GetHwnd(), SW_SHOW ); ::ShowWindow( m_cTabWnd.GetHwnd(), SW_SHOW ); //@@@ 2003.06.25 MIK ::ShowWindow( m_cDlgFuncList.GetHwnd(), SW_SHOW ); // 2010.06.25 ryoji - if (NULL != GetMiniMap().GetHwnd()) { - ::ShowWindow(GetMiniMap().GetHwnd(), SW_SHOW); + if( m_cMiniMapView.GetHwnd() ){ + ::ShowWindow( m_cMiniMapView.GetHwnd(), SW_SHOW ); } // その他のモードレスダイアログも戻す // 2010.06.25 ryoji @@ -2987,8 +2982,8 @@ void CEditWnd::PrintPreviewModeONOFF( void ) ::ShowWindow( m_cFuncKeyWnd.GetHwnd(), SW_HIDE ); ::ShowWindow( m_cTabWnd.GetHwnd(), SW_HIDE ); //@@@ 2003.06.25 MIK ::ShowWindow( m_cDlgFuncList.GetHwnd(), SW_HIDE ); // 2010.06.25 ryoji - if (NULL != GetMiniMap().GetHwnd()) { - ::ShowWindow(GetMiniMap().GetHwnd(), SW_HIDE); + if( m_cMiniMapView.GetHwnd() ){ + ::ShowWindow( m_cMiniMapView.GetHwnd(), SW_HIDE ); } // その他のモードレスダイアログも隠す // 2010.06.25 ryoji @@ -3307,16 +3302,16 @@ LRESULT CEditWnd::OnSize2( WPARAM wParam, LPARAM lParam, bool bUpdateStatus ) // ミニマップ int nMiniMapWidth = 0; - if( GetMiniMap().GetHwnd() ){ + if( m_cMiniMapView.GetHwnd() ){ nMiniMapWidth = GetDllShareData().m_Common.m_sWindow.m_nMiniMapWidth; - ::MoveWindow( m_pcEditViewMiniMap->GetHwnd(), + ::MoveWindow( m_cMiniMapView.GetHwnd(), (eDockSideFL == DOCKSIDE_RIGHT)? cx - nFuncListWidth - nMiniMapWidth: cx - nMiniMapWidth, (eDockSideFL == DOCKSIDE_TOP)? nTop + nFuncListHeight: nTop, nMiniMapWidth, (eDockSideFL == DOCKSIDE_TOP || eDockSideFL == DOCKSIDE_BOTTOM)? nHeight - nFuncListHeight: nHeight, TRUE ); - GetMiniMap().SplitBoxOnOff( FALSE, FALSE, bMiniMapSizeBox ); + m_cMiniMapView.SplitBoxOnOff( FALSE, FALSE, bMiniMapSizeBox ); } ::MoveWindow( @@ -4312,7 +4307,7 @@ void CEditWnd::Views_DeleteCompatibleBitmap() GetView(i).DeleteCompatibleBitmap(); } } - GetMiniMap().DeleteCompatibleBitmap(); + m_cMiniMapView.DeleteCompatibleBitmap(); } LRESULT CEditWnd::Views_DispatchEvent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -4377,7 +4372,7 @@ void CEditWnd::InitAllViews() GetView(i).GetCaret().MoveCursor( CLayoutPoint(0, 0), true ); GetView(i).GetCaret().m_nCaretPosX_Prev = CLayoutInt(0); } - GetMiniMap().OnChangeSetting(); + m_cMiniMapView.OnChangeSetting(); } void CEditWnd::Views_RedrawAll() @@ -4388,7 +4383,7 @@ void CEditWnd::Views_RedrawAll() GetView(v).RedrawAll(); } } - GetMiniMap().RedrawAll(); + m_cMiniMapView.RedrawAll(); //アクティブを再描画 GetActiveView().RedrawAll(); } @@ -4400,7 +4395,7 @@ void CEditWnd::Views_Redraw() if( m_nActivePaneIndex != v ) GetView(v).Redraw(); } - GetMiniMap().Redraw(); + m_cMiniMapView.Redraw(); //アクティブを再描画 GetActiveView().Redraw(); } @@ -4475,7 +4470,7 @@ bool CEditWnd::SetDrawSwitchOfAllViews( bool bDraw ) for( i = 0; i < GetAllViewCount(); i++ ){ GetView(i).SetDrawSwitch( bDraw ); } - GetMiniMap().SetDrawSwitch( bDraw ); + m_cMiniMapView.SetDrawSwitch( bDraw ); return bDrawSwitchOld; } @@ -4503,8 +4498,8 @@ void CEditWnd::RedrawAllViews( CEditView* pcViewExclude ) pcView->AdjustScrollBars(); } } - GetMiniMap().Redraw(); - GetMiniMap().AdjustScrollBars(); + m_cMiniMapView.Redraw(); + m_cMiniMapView.AdjustScrollBars(); } void CEditWnd::Views_DisableSelectArea(bool bRedraw) @@ -4581,8 +4576,8 @@ BOOL CEditWnd::UpdateTextWrap( void ) for( int i = 0; i < GetAllViewCount(); i++ ){ ::UpdateWindow( GetView(i).GetHwnd() ); } - if( GetMiniMap().GetHwnd() ){ - ::UpdateWindow( GetMiniMap().GetHwnd() ); + if( m_cMiniMapView.GetHwnd() ){ + ::UpdateWindow( m_cMiniMapView.GetHwnd() ); } } return bWrap; // 画面更新=折り返し変更 @@ -4629,9 +4624,9 @@ void CEditWnd::ChangeLayoutParam( bool bShowProgress, CKetaXInt nTabSize, int nT GetView(i).AdjustScrollBars(); // 2008.06.18 ryoji } } - if( GetMiniMap().GetHwnd() ){ - InvalidateRect( GetMiniMap().GetHwnd(), NULL, TRUE ); - GetMiniMap().AdjustScrollBars(); + if( m_cMiniMapView.GetHwnd() ){ + InvalidateRect( m_cMiniMapView.GetHwnd(), NULL, TRUE ); + m_cMiniMapView.AdjustScrollBars(); } GetActiveView().GetCaret().ShowCaretPosInfo(); // 2009.07.25 ryoji diff --git a/sakura_core/window/CEditWnd.h b/sakura_core/window/CEditWnd.h index 5438b9cde8..72f7e91ec6 100644 --- a/sakura_core/window/CEditWnd.h +++ b/sakura_core/window/CEditWnd.h @@ -64,6 +64,7 @@ #include "doc/CDocListener.h" #include "uiparts/CMenuDrawer.h" #include "view/CViewFont.h" +#include "view/CMiniMapView.h" static const int MENUBAR_MESSAGE_MAX_LEN = 30; @@ -275,7 +276,7 @@ class CEditWnd CEditView& GetActiveView() { return *m_pcEditView; } const CEditView& GetView(int n) const { return *m_pcEditViewArr[n]; } CEditView& GetView(int n) { return *m_pcEditViewArr[n]; } - CEditView& GetMiniMap() { return *m_pcEditViewMiniMap; } + CMiniMapView& GetMiniMap( void ) { return m_cMiniMapView; } bool IsEnablePane(int n) const { return 0 <= n && n < m_nEditViewCount; } int GetAllViewCount() const { return m_nEditViewCount; } @@ -379,7 +380,7 @@ class CEditWnd CEditDoc* m_pcEditDoc; CEditView* m_pcEditViewArr[4]; //!< ビュー CEditView* m_pcEditView; //!< 有効なビュー - CEditView* m_pcEditViewMiniMap; //!< ミニマップ + CMiniMapView m_cMiniMapView; //!< ミニマップ int m_nActivePaneIndex; //!< 有効なビューのindex int m_nEditViewCount; //!< 有効なビューの数 const int m_nEditViewMaxCount;//!< ビューの最大数=4