Skip to content

Commit

Permalink
Merge pull request #1748 from sanomari/feature/add_cminimapview
Browse files Browse the repository at this point in the history
ミニマップの実装クラスを分割する
  • Loading branch information
sanomari committed Oct 24, 2021
2 parents 8565cdb + c83e5e5 commit 0dd4391
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 33 deletions.
2 changes: 2 additions & 0 deletions sakura/sakura.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@
<ClInclude Include="..\sakura_core\view\CCaret.h" />
<ClInclude Include="..\sakura_core\view\CEditView.h" />
<ClInclude Include="..\sakura_core\view\CEditView_Paint.h" />
<ClInclude Include="..\sakura_core\view\CMiniMapView.h" />
<ClInclude Include="..\sakura_core\view\colors\CColorStrategy.h" />
<ClInclude Include="..\sakura_core\view\colors\CColor_Comment.h" />
<ClInclude Include="..\sakura_core\view\colors\CColor_Found.h" />
Expand Down Expand Up @@ -870,6 +871,7 @@
<ClCompile Include="..\sakura_core\view\CEditView_Paint_Bracket.cpp" />
<ClCompile Include="..\sakura_core\view\CEditView_Scroll.cpp" />
<ClCompile Include="..\sakura_core\view\CEditView_Search.cpp" />
<ClCompile Include="..\sakura_core\view\CMiniMapView.cpp" />
<ClCompile Include="..\sakura_core\view\colors\CColorStrategy.cpp" />
<ClCompile Include="..\sakura_core\view\colors\CColor_Comment.cpp" />
<ClCompile Include="..\sakura_core\view\colors\CColor_Found.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions sakura/sakura.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,9 @@
<ClInclude Include="..\sakura_core\charset\CharsetDetector.h">
<Filter>Cpp Source Files\charset</Filter>
</ClInclude>
<ClInclude Include="..\sakura_core\view\CMiniMapView.h">
<Filter>Cpp Source Files\view</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\resource\auto_scroll_center.cur">
Expand Down Expand Up @@ -2309,6 +2312,9 @@
<ClCompile Include="..\sakura_core\charset\CharsetDetector.cpp">
<Filter>Cpp Source Files\charset</Filter>
</ClCompile>
<ClCompile Include="..\sakura_core\view\CMiniMapView.cpp">
<Filter>Cpp Source Files\view</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Image Include="..\resource\auto_scroll_center.bmp">
Expand Down
36 changes: 36 additions & 0 deletions sakura_core/view/CMiniMapView.cpp
Original file line number Diff line number Diff line change
@@ -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 );
}
39 changes: 39 additions & 0 deletions sakura_core/view/CMiniMapView.h
Original file line number Diff line number Diff line change
@@ -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 );
};
57 changes: 26 additions & 31 deletions sakura_core/window/CEditWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,6 @@ CEditWnd::~CEditWnd()
}
m_pcEditView = NULL;

delete m_pcEditViewMiniMap;
m_pcEditViewMiniMap = NULL;

delete m_pcViewFont;
m_pcViewFont = NULL;

Expand Down Expand Up @@ -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終端は不要
Expand Down Expand Up @@ -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();
}
}
}
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -4388,7 +4383,7 @@ void CEditWnd::Views_RedrawAll()
GetView(v).RedrawAll();
}
}
GetMiniMap().RedrawAll();
m_cMiniMapView.RedrawAll();
//アクティブを再描画
GetActiveView().RedrawAll();
}
Expand All @@ -4400,7 +4395,7 @@ void CEditWnd::Views_Redraw()
if( m_nActivePaneIndex != v )
GetView(v).Redraw();
}
GetMiniMap().Redraw();
m_cMiniMapView.Redraw();
//アクティブを再描画
GetActiveView().Redraw();
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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; // 画面更新=折り返し変更
Expand Down Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions sakura_core/window/CEditWnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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; }

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0dd4391

Please sign in to comment.