From 78da5864202c7902cb340598f0f4e421cf4b3316 Mon Sep 17 00:00:00 2001 From: miwa Date: Sun, 6 Sep 2020 11:51:48 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=E3=82=A2=E3=82=A6=E3=83=88=E3=83=A9?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E9=81=B8=E6=8A=9E=E4=BD=8D=E7=BD=AE=E3=81=AE?= =?UTF-8?q?=E8=87=AA=E5=8B=95=E8=BF=BD=E5=BE=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/outline/CDlgFuncList.cpp | 433 +++++++++++++++++---------- sakura_core/outline/CDlgFuncList.h | 5 + sakura_core/view/CCaret.cpp | 4 + 3 files changed, 292 insertions(+), 150 deletions(-) diff --git a/sakura_core/outline/CDlgFuncList.cpp b/sakura_core/outline/CDlgFuncList.cpp index 75542335d9..4f191b95d5 100644 --- a/sakura_core/outline/CDlgFuncList.cpp +++ b/sakura_core/outline/CDlgFuncList.cpp @@ -537,6 +537,7 @@ void CDlgFuncList::SetData() ::SetWindowText( GetHwnd(), L"" ); break; } + // May 18, 2001 genta // Windowがいなくなると後で都合が悪いので、表示しないだけにしておく //::DestroyWindow( hwndTree ); @@ -545,14 +546,14 @@ void CDlgFuncList::SetData() WCHAR szText[2048]; const CFuncInfo* pcFuncInfo; LV_ITEM item; - bool bSelected; - CLayoutInt nFuncLineOld(-1); - CLayoutInt nFuncColOld(-1); - CLayoutInt nFuncLineTop(INT_MAX); - CLayoutInt nFuncColTop(INT_MAX); - int nSelectedLineTop = 0; - int nSelectedLine = 0; - RECT rc; + //bool bSelected; + //CLayoutInt nFuncLineOld(-1); + //CLayoutInt nFuncColOld(-1); + //CLayoutInt nFuncLineTop(INT_MAX); + //CLayoutInt nFuncColTop(INT_MAX); + //int nSelectedLineTop = 0; + //int nSelectedLine = 0; + //RECT rc; m_cmemClipText.SetString(L""); /* クリップボードコピー用テキスト */ { @@ -567,33 +568,33 @@ void CDlgFuncList::SetData() } ::EnableWindow( GetItemHwnd( IDC_BUTTON_COPY ), TRUE ); - bSelected = false; - for( i = 0; i < m_pcFuncInfoArr->GetNum(); ++i ){ - pcFuncInfo = m_pcFuncInfoArr->GetAt( i ); - if( !bSelected ){ - if( pcFuncInfo->m_nFuncLineLAYOUT < nFuncLineTop - || (pcFuncInfo->m_nFuncLineLAYOUT == nFuncLineTop && pcFuncInfo->m_nFuncColLAYOUT <= nFuncColTop) ){ - nFuncLineTop = pcFuncInfo->m_nFuncLineLAYOUT; - nFuncColTop = pcFuncInfo->m_nFuncColLAYOUT; - nSelectedLineTop = i; - } - } - { - if( (nFuncLineOld < pcFuncInfo->m_nFuncLineLAYOUT - || (nFuncLineOld == pcFuncInfo->m_nFuncColLAYOUT && nFuncColOld <= pcFuncInfo->m_nFuncColLAYOUT)) - && (pcFuncInfo->m_nFuncLineLAYOUT < m_nCurLine - || (pcFuncInfo->m_nFuncLineLAYOUT == m_nCurLine && pcFuncInfo->m_nFuncColLAYOUT <= m_nCurCol)) ){ - nFuncLineOld = pcFuncInfo->m_nFuncLineLAYOUT; - nFuncColOld = pcFuncInfo->m_nFuncColLAYOUT; - bSelected = true; - nSelectedLine = i; - } - } - } - if( 0 < m_pcFuncInfoArr->GetNum() && !bSelected ){ - bSelected = true; - nSelectedLine = nSelectedLineTop; - } + //bSelected = false; + //for( i = 0; i < m_pcFuncInfoArr->GetNum(); ++i ){ + // pcFuncInfo = m_pcFuncInfoArr->GetAt( i ); + // if( !bSelected ){ + // if( pcFuncInfo->m_nFuncLineLAYOUT < nFuncLineTop + // || (pcFuncInfo->m_nFuncLineLAYOUT == nFuncLineTop && pcFuncInfo->m_nFuncColLAYOUT <= nFuncColTop) ){ + // nFuncLineTop = pcFuncInfo->m_nFuncLineLAYOUT; + // nFuncColTop = pcFuncInfo->m_nFuncColLAYOUT; + // nSelectedLineTop = i; + // } + // } + // { + // if( (nFuncLineOld < pcFuncInfo->m_nFuncLineLAYOUT + // || (nFuncLineOld == pcFuncInfo->m_nFuncColLAYOUT && nFuncColOld <= pcFuncInfo->m_nFuncColLAYOUT)) + // && (pcFuncInfo->m_nFuncLineLAYOUT < m_nCurLine + // || (pcFuncInfo->m_nFuncLineLAYOUT == m_nCurLine && pcFuncInfo->m_nFuncColLAYOUT <= m_nCurCol)) ){ + // nFuncLineOld = pcFuncInfo->m_nFuncLineLAYOUT; + // nFuncColOld = pcFuncInfo->m_nFuncColLAYOUT; + // bSelected = true; + // nSelectedLine = i; + // } + // } + //} + //if( 0 < m_pcFuncInfoArr->GetNum() && !bSelected ){ + // bSelected = true; + // nSelectedLine = nSelectedLineTop; + //} for( i = 0; i < m_pcFuncInfoArr->GetNum(); ++i ){ /* 現在の解析結果要素 */ pcFuncInfo = m_pcFuncInfoArr->GetAt( i ); @@ -699,12 +700,18 @@ void CDlgFuncList::SetData() dwExStyle |= LVS_EX_FULLROWSELECT; ListView_SetExtendedListViewStyle( hwndList, dwExStyle ); - if( bSelected ){ - ListView_GetItemRect( hwndList, 0, &rc, LVIR_BOUNDS ); - ListView_Scroll( hwndList, 0, nSelectedLine * ( rc.bottom - rc.top ) ); - ListView_SetItemState( hwndList, nSelectedLine, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED ); - } + //if( bSelected ){ + // ListView_GetItemRect( hwndList, 0, &rc, LVIR_BOUNDS ); + // ListView_Scroll( hwndList, 0, nSelectedLine * ( rc.bottom - rc.top ) ); + // ListView_SetItemState( hwndList, nSelectedLine, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED ); + //} + } + + int nFuncInfoIndex = -1; + if( GetFuncInfoIndex( m_nCurLine, m_nCurCol, &nFuncInfoIndex ) ){ + SetItemSelection( nFuncInfoIndex ); } + /* アウトライン ダイアログを自動的に閉じる */ ::CheckDlgButton( GetHwnd(), IDC_CHECK_bAutoCloseDlgFuncList, m_pShareData->m_Common.m_sOutline.m_bAutoCloseDlgFuncList ); /* アウトライン ブックマーク一覧で空行を無視する */ @@ -1171,26 +1178,26 @@ void CDlgFuncList::SetTreeJava( HWND hwndDlg, BOOL bAddClass ) m_cmemClipText.AppendString(FL_OBJ_DECLARE == pcFuncInfo->m_nInfo ? m_pcFuncInfoArr->GetAppendText( FL_OBJ_DECLARE ).c_str() : L"" ); // Jan. 04, 2001 genta C++で使用 m_cmemClipText.AppendString(L"\r\n"); - /* 現在カーソル位置のメソッドかどうか調べる */ - if( !bSelected ){ - if( pcFuncInfo->m_nFuncLineLAYOUT < nFuncLineTop - || (pcFuncInfo->m_nFuncLineLAYOUT == nFuncLineTop && pcFuncInfo->m_nFuncColLAYOUT <= nFuncColTop) ){ - nFuncLineTop = pcFuncInfo->m_nFuncLineLAYOUT; - nFuncColTop = pcFuncInfo->m_nFuncColLAYOUT; - htiSelectedTop = htiItem; - } - } - { - if( (nFuncLineOld < pcFuncInfo->m_nFuncLineLAYOUT - || (nFuncLineOld == pcFuncInfo->m_nFuncColLAYOUT && nFuncColOld <= pcFuncInfo->m_nFuncColLAYOUT)) - && (pcFuncInfo->m_nFuncLineLAYOUT < m_nCurLine - || (pcFuncInfo->m_nFuncLineLAYOUT == m_nCurLine && pcFuncInfo->m_nFuncColLAYOUT <= m_nCurCol)) ){ - nFuncLineOld = pcFuncInfo->m_nFuncLineLAYOUT; - nFuncColOld = pcFuncInfo->m_nFuncColLAYOUT; - bSelected = TRUE; - htiSelected = htiItem; - } - } + ///* 現在カーソル位置のメソッドかどうか調べる */ + //if( !bSelected ){ + // if( pcFuncInfo->m_nFuncLineLAYOUT < nFuncLineTop + // || (pcFuncInfo->m_nFuncLineLAYOUT == nFuncLineTop && pcFuncInfo->m_nFuncColLAYOUT <= nFuncColTop) ){ + // nFuncLineTop = pcFuncInfo->m_nFuncLineLAYOUT; + // nFuncColTop = pcFuncInfo->m_nFuncColLAYOUT; + // htiSelectedTop = htiItem; + // } + //} + //{ + // if( (nFuncLineOld < pcFuncInfo->m_nFuncLineLAYOUT + // || (nFuncLineOld == pcFuncInfo->m_nFuncColLAYOUT && nFuncColOld <= pcFuncInfo->m_nFuncColLAYOUT)) + // && (pcFuncInfo->m_nFuncLineLAYOUT < m_nCurLine + // || (pcFuncInfo->m_nFuncLineLAYOUT == m_nCurLine && pcFuncInfo->m_nFuncColLAYOUT <= m_nCurCol)) ){ + // nFuncLineOld = pcFuncInfo->m_nFuncLineLAYOUT; + // nFuncColOld = pcFuncInfo->m_nFuncColLAYOUT; + // bSelected = TRUE; + // htiSelected = htiItem; + // } + //} // Jan. 04, 2001 genta // deleteはその都度行うのでここでは不要 } @@ -1202,12 +1209,12 @@ void CDlgFuncList::SetTreeJava( HWND hwndDlg, BOOL bAddClass ) TreeView_Expand( hwndTree, htiClass, TVE_EXPAND ); htiClass = TreeView_GetNextSibling( hwndTree, htiClass ); } - /* 現在カーソル位置のメソッドを選択状態にする */ - if( bSelected ){ - TreeView_SelectItem( hwndTree, htiSelected ); - }else{ - TreeView_SelectItem( hwndTree, htiSelectedTop ); - } + ///* 現在カーソル位置のメソッドを選択状態にする */ + //if( bSelected ){ + // TreeView_SelectItem( hwndTree, htiSelected ); + //}else{ + // TreeView_SelectItem( hwndTree, htiSelectedTop ); + //} // GetTreeTextNext( hwndTree, NULL, 0 ); m_nTreeItemCount = nlParamCount; return; @@ -1227,11 +1234,11 @@ void CDlgFuncList::SetListVB (void) const CFuncInfo* pcFuncInfo; LV_ITEM item; HWND hwndList; - int bSelected; - CLayoutInt nFuncLineOld; - CLayoutInt nFuncColOld; - int nSelectedLine = 0; - RECT rc; + //int bSelected; + //CLayoutInt nFuncLineOld; + //CLayoutInt nFuncColOld; + //int nSelectedLine = 0; + //RECT rc; ::EnableWindow( GetItemHwnd( IDC_BUTTON_COPY ), TRUE ); @@ -1249,38 +1256,38 @@ void CDlgFuncList::SetListVB (void) m_cmemClipText.AllocStringBuffer( nBuffLen + nBuffLenTag * nNum ); } - nFuncLineOld = CLayoutInt(-1); - nFuncColOld = CLayoutInt(-1); - CLayoutInt nFuncLineTop(INT_MAX); - CLayoutInt nFuncColTop(INT_MAX); - int nSelectedLineTop = 0; - bSelected = FALSE; - for( i = 0; i < m_pcFuncInfoArr->GetNum(); ++i ){ - pcFuncInfo = m_pcFuncInfoArr->GetAt( i ); - if( !bSelected ){ - if( pcFuncInfo->m_nFuncLineLAYOUT < nFuncLineTop - || (pcFuncInfo->m_nFuncLineLAYOUT == nFuncLineTop && pcFuncInfo->m_nFuncColLAYOUT <= nFuncColTop) ){ - nFuncLineTop = pcFuncInfo->m_nFuncLineLAYOUT; - nFuncColTop = pcFuncInfo->m_nFuncColLAYOUT; - nSelectedLineTop = i; - } - } - { - if( (nFuncLineOld < pcFuncInfo->m_nFuncLineLAYOUT - || (nFuncLineOld == pcFuncInfo->m_nFuncColLAYOUT && nFuncColOld <= pcFuncInfo->m_nFuncColLAYOUT)) - && (pcFuncInfo->m_nFuncLineLAYOUT < m_nCurLine - || (pcFuncInfo->m_nFuncLineLAYOUT == m_nCurLine && pcFuncInfo->m_nFuncColLAYOUT <= m_nCurCol)) ){ - nFuncLineOld = pcFuncInfo->m_nFuncLineLAYOUT; - nFuncColOld = pcFuncInfo->m_nFuncColLAYOUT; - bSelected = TRUE; - nSelectedLine = i; - } - } - } - if( 0 < m_pcFuncInfoArr->GetNum() && !bSelected ){ - bSelected = TRUE; - nSelectedLine = nSelectedLineTop; - } + //nFuncLineOld = CLayoutInt(-1); + //nFuncColOld = CLayoutInt(-1); + //CLayoutInt nFuncLineTop(INT_MAX); + //CLayoutInt nFuncColTop(INT_MAX); + //int nSelectedLineTop = 0; + //bSelected = FALSE; + //for( i = 0; i < m_pcFuncInfoArr->GetNum(); ++i ){ + // pcFuncInfo = m_pcFuncInfoArr->GetAt( i ); + // if( !bSelected ){ + // if( pcFuncInfo->m_nFuncLineLAYOUT < nFuncLineTop + // || (pcFuncInfo->m_nFuncLineLAYOUT == nFuncLineTop && pcFuncInfo->m_nFuncColLAYOUT <= nFuncColTop) ){ + // nFuncLineTop = pcFuncInfo->m_nFuncLineLAYOUT; + // nFuncColTop = pcFuncInfo->m_nFuncColLAYOUT; + // nSelectedLineTop = i; + // } + // } + // { + // if( (nFuncLineOld < pcFuncInfo->m_nFuncLineLAYOUT + // || (nFuncLineOld == pcFuncInfo->m_nFuncColLAYOUT && nFuncColOld <= pcFuncInfo->m_nFuncColLAYOUT)) + // && (pcFuncInfo->m_nFuncLineLAYOUT < m_nCurLine + // || (pcFuncInfo->m_nFuncLineLAYOUT == m_nCurLine && pcFuncInfo->m_nFuncColLAYOUT <= m_nCurCol)) ){ + // nFuncLineOld = pcFuncInfo->m_nFuncLineLAYOUT; + // nFuncColOld = pcFuncInfo->m_nFuncColLAYOUT; + // bSelected = TRUE; + // nSelectedLine = i; + // } + // } + //} + //if( 0 < m_pcFuncInfoArr->GetNum() && !bSelected ){ + // bSelected = TRUE; + // nSelectedLine = nSelectedLineTop; + //} WCHAR szText[2048]; for( i = 0; i < m_pcFuncInfoArr->GetNum(); ++i ){ @@ -1450,11 +1457,11 @@ void CDlgFuncList::SetListVB (void) ListView_SetColumnWidth( hwndList, FL_COL_COL, ListView_GetColumnWidth( hwndList, FL_COL_COL ) + 16 ); ListView_SetColumnWidth( hwndList, FL_COL_NAME, ListView_GetColumnWidth( hwndList, FL_COL_NAME ) + 16 ); ListView_SetColumnWidth( hwndList, FL_COL_REMARK, ListView_GetColumnWidth( hwndList, FL_COL_REMARK ) + 16 ); - if( bSelected ){ - ListView_GetItemRect( hwndList, 0, &rc, LVIR_BOUNDS ); - ListView_Scroll( hwndList, 0, nSelectedLine * ( rc.bottom - rc.top ) ); - ListView_SetItemState( hwndList, nSelectedLine, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED ); - } + //if( bSelected ){ + // ListView_GetItemRect( hwndList, 0, &rc, LVIR_BOUNDS ); + // ListView_Scroll( hwndList, 0, nSelectedLine * ( rc.bottom - rc.top ) ); + // ListView_SetItemState( hwndList, nSelectedLine, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED ); + //} return; } @@ -1471,8 +1478,8 @@ void CDlgFuncList::SetListVB (void) */ void CDlgFuncList::SetTree(bool tagjump, bool nolabel) { - HTREEITEM hItemSelected = NULL; - HTREEITEM hItemSelectedTop = NULL; + //HTREEITEM hItemSelected = NULL; + //HTREEITEM hItemSelectedTop = NULL; HWND hwndTree = GetItemHwnd( IDC_TREE_FL ); int i; @@ -1482,11 +1489,11 @@ void CDlgFuncList::SetTree(bool tagjump, bool nolabel) HTREEITEM* phParentStack; phParentStack = (HTREEITEM*)malloc( nStackDepth * sizeof( HTREEITEM ) ); phParentStack[ nStackPointer ] = TVI_ROOT; - CLayoutInt nFuncLineOld(-1); - CLayoutInt nFuncColOld(-1); - CLayoutInt nFuncLineTop(INT_MAX); - CLayoutInt nFuncColTop(INT_MAX); - bool bSelected = false; + //CLayoutInt nFuncLineOld(-1); + //CLayoutInt nFuncColOld(-1); + //CLayoutInt nFuncLineTop(INT_MAX); + //CLayoutInt nFuncColTop(INT_MAX); + //bool bSelected = false; m_cmemClipText.SetString(L""); { @@ -1545,35 +1552,35 @@ void CDlgFuncList::SetTree(bool tagjump, bool nolabel) hItem = TreeView_InsertItem( hwndTree, &cTVInsertStruct ); phParentStack[ nStackPointer+1 ] = hItem; - /* pcFuncInfoに登録されている行数、桁を確認して、選択するアイテムを考える - */ - bool bFileSelect = false; - if( pcFuncInfo->m_cmemFileName.GetStringPtr() && m_pcFuncInfoArr->m_szFilePath[0] ){ - if( 0 == wmemicmp( pcFuncInfo->m_cmemFileName.GetStringPtr(), m_pcFuncInfoArr->m_szFilePath.c_str() ) ){ - bFileSelect = true; - } - }else{ - bFileSelect = true; - } - if( bFileSelect ){ - if( !bSelected ){ - if( pcFuncInfo->m_nFuncLineLAYOUT < nFuncLineTop - || (pcFuncInfo->m_nFuncLineLAYOUT == nFuncLineTop && pcFuncInfo->m_nFuncColLAYOUT <= nFuncColTop) ){ - nFuncLineTop = pcFuncInfo->m_nFuncLineLAYOUT; - nFuncColTop = pcFuncInfo->m_nFuncColLAYOUT; - hItemSelectedTop = hItem; - } - } - if( (nFuncLineOld < pcFuncInfo->m_nFuncLineLAYOUT - || (nFuncLineOld == pcFuncInfo->m_nFuncColLAYOUT && nFuncColOld <= pcFuncInfo->m_nFuncColLAYOUT)) - && (pcFuncInfo->m_nFuncLineLAYOUT < m_nCurLine - || (pcFuncInfo->m_nFuncLineLAYOUT == m_nCurLine && pcFuncInfo->m_nFuncColLAYOUT <= m_nCurCol)) ){ - nFuncLineOld = pcFuncInfo->m_nFuncLineLAYOUT; - nFuncColOld = pcFuncInfo->m_nFuncColLAYOUT; - hItemSelected = hItem; - bSelected = true; - } - } + ///* pcFuncInfoに登録されている行数、桁を確認して、選択するアイテムを考える + //*/ + //bool bFileSelect = false; + //if( pcFuncInfo->m_cmemFileName.GetStringPtr() && m_pcFuncInfoArr->m_szFilePath[0] ){ + // if( 0 == wmemicmp( pcFuncInfo->m_cmemFileName.GetStringPtr(), m_pcFuncInfoArr->m_szFilePath.c_str() ) ){ + // bFileSelect = true; + // } + //}else{ + // bFileSelect = true; + //} + //if( bFileSelect ){ + // if( !bSelected ){ + // if( pcFuncInfo->m_nFuncLineLAYOUT < nFuncLineTop + // || (pcFuncInfo->m_nFuncLineLAYOUT == nFuncLineTop && pcFuncInfo->m_nFuncColLAYOUT <= nFuncColTop) ){ + // nFuncLineTop = pcFuncInfo->m_nFuncLineLAYOUT; + // nFuncColTop = pcFuncInfo->m_nFuncColLAYOUT; + // hItemSelectedTop = hItem; + // } + // } + // if( (nFuncLineOld < pcFuncInfo->m_nFuncLineLAYOUT + // || (nFuncLineOld == pcFuncInfo->m_nFuncColLAYOUT && nFuncColOld <= pcFuncInfo->m_nFuncColLAYOUT)) + // && (pcFuncInfo->m_nFuncLineLAYOUT < m_nCurLine + // || (pcFuncInfo->m_nFuncLineLAYOUT == m_nCurLine && pcFuncInfo->m_nFuncColLAYOUT <= m_nCurCol)) ){ + // nFuncLineOld = pcFuncInfo->m_nFuncLineLAYOUT; + // nFuncColOld = pcFuncInfo->m_nFuncColLAYOUT; + // hItemSelected = hItem; + // bSelected = true; + // } + //} /* クリップボードコピー用テキストを作成する */ // 2003.06.22 Moca dummy要素はツリーに入れるがTAGJUMPには加えない @@ -1620,12 +1627,12 @@ end_of_func:; ::EnableWindow( GetItemHwnd( IDC_BUTTON_COPY ), TRUE ); - if( NULL != hItemSelected ){ - /* 現在カーソル位置のメソッドを選択状態にする */ - TreeView_SelectItem( hwndTree, hItemSelected ); - }else if( NULL != hItemSelectedTop ){ - TreeView_SelectItem( hwndTree, hItemSelectedTop ); - } + //if( NULL != hItemSelected ){ + // /* 現在カーソル位置のメソッドを選択状態にする */ + // TreeView_SelectItem( hwndTree, hItemSelected ); + //}else if( NULL != hItemSelectedTop ){ + // TreeView_SelectItem( hwndTree, hItemSelectedTop ); + //} free( phParentStack ); } @@ -4043,3 +4050,129 @@ void CDlgFuncList::LoadFileTreeSetting( CFileTreeSetting& data, SFilePath& IniDi } } } + +void CDlgFuncList::UpdateItemSelection( CLayoutInt nCurLine, CLayoutInt nCurCol ) +{ + if( !::IsWindowVisible( this->GetHwnd() ) ){ + return; + } + + m_nCurLine = nCurLine; + m_nCurCol = nCurCol; + + int nFuncInfoIndex = -1; + if( GetFuncInfoIndex( nCurLine, nCurCol, &nFuncInfoIndex ) ){ + SetItemSelection( nFuncInfoIndex ); + } + + return; +} + +// nFuncInfoIndexが0未満の時は選択をすべて解除 +void CDlgFuncList::SetItemSelection( int nFuncInfoIndex ) +{ + if( m_nViewType == VIEWTYPE_TREE ){ + HWND hwndTree = GetItemHwnd( IDC_TREE_FL ); + SetItemSelectionForTreeView( hwndTree, nFuncInfoIndex ); + }else if( m_nViewType == VIEWTYPE_LIST ){ + HWND hwndList = GetItemHwnd( IDC_LIST_FL ); + SetItemSelectionForListView( hwndList, nFuncInfoIndex ); + }else{ + ; + } + + return; +} + +void CDlgFuncList::SetItemSelectionForTreeView( HWND hwndTree, int nFuncInfoIndex ) +{ + // 関数情報のインデックスに該当するアイテム探してを選択状態に + std::vector htiStack; + htiStack.reserve( TreeView_GetCount( hwndTree ) ); + htiStack.push_back( TreeView_GetRoot( hwndTree ) ); + int nStackIndex = 0; + bool bFound = false; + while( !bFound && nStackIndex < htiStack.size() ){ + HTREEITEM htiCurrent = htiStack[nStackIndex]; + for( ; NULL != htiCurrent ; htiCurrent = TreeView_GetNextSibling( hwndTree, htiCurrent )){ + TVITEM tvItem = {}; + tvItem.mask = TVIF_HANDLE | TVIF_PARAM; + tvItem.hItem = htiCurrent; + TreeView_GetItem( hwndTree, &tvItem ); + if( nFuncInfoIndex == TreeDummylParamToFuncInfoIndex(m_vecDummylParams, tvItem.lParam) ){ + // 発見 + TreeView_SelectItem( hwndTree, htiCurrent ); + bFound = true; + break; + } + + HTREEITEM htiChild = TreeView_GetChild( hwndTree, htiCurrent ); + if( htiChild != NULL ){ + htiStack.push_back( htiChild ); + } + } + ++nStackIndex; + } + + return; +} + +void CDlgFuncList::SetItemSelectionForListView( HWND hwndList, int nFuncInfoIndex ) +{ + ListView_SetItemState( hwndList, nFuncInfoIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED ); + ListView_EnsureVisible( hwndList, nFuncInfoIndex, FALSE ); + + return; +} + +bool CDlgFuncList::GetFuncInfoIndex( CLayoutInt nCurLine, CLayoutInt nCurCol, int* pIndexOut ) +{ + const CFuncInfo* pcFuncInfo = NULL; + CLayoutInt nFuncLineOld(-1); + CLayoutInt nFuncColOld(-1); + CLayoutInt nFuncLineTop(INT_MAX); + CLayoutInt nFuncColTop(INT_MAX); + int nFoundIndex = -1; + int i; + + if( m_pcFuncInfoArr == NULL || pIndexOut == NULL ){ + return false; + } + + // カーソル位置に該当する関数情報のインデックスを得る + for( i = 0; i < m_pcFuncInfoArr->GetNum(); ++i ){ + pcFuncInfo = m_pcFuncInfoArr->GetAt( i ); + + if( (pcFuncInfo->m_cmemFileName.GetStringPtr() && m_pcFuncInfoArr->m_szFilePath[0]) ){ + if( 0 != wmemicmp( pcFuncInfo->m_cmemFileName.GetStringPtr(), m_pcFuncInfoArr->m_szFilePath.c_str() ) ){ + continue; + } + } + + if( nFoundIndex == -1 ){ + if( pcFuncInfo->m_nFuncLineLAYOUT < nFuncLineTop + || (pcFuncInfo->m_nFuncLineLAYOUT == nFuncLineTop && pcFuncInfo->m_nFuncColLAYOUT <= nFuncColTop) ){ + nFuncLineTop = pcFuncInfo->m_nFuncLineLAYOUT; + nFuncColTop = pcFuncInfo->m_nFuncColLAYOUT; + nFoundIndex = i; + } + }else{ + if( (nFuncLineOld < pcFuncInfo->m_nFuncLineLAYOUT + || (nFuncLineOld == pcFuncInfo->m_nFuncLineLAYOUT && nFuncColOld <= pcFuncInfo->m_nFuncColLAYOUT)) + && (pcFuncInfo->m_nFuncLineLAYOUT < m_nCurLine + || (pcFuncInfo->m_nFuncLineLAYOUT == m_nCurLine && pcFuncInfo->m_nFuncColLAYOUT <= m_nCurCol)) ){ + nFuncLineOld = pcFuncInfo->m_nFuncLineLAYOUT; + nFuncColOld = pcFuncInfo->m_nFuncColLAYOUT; + nFoundIndex = i; + } + } + } + + if( nFoundIndex == -1 ){ + return false; + } + + *pIndexOut = nFoundIndex; + + return true; +} diff --git a/sakura_core/outline/CDlgFuncList.h b/sakura_core/outline/CDlgFuncList.h index 03c6012ea6..c0c67cba0b 100644 --- a/sakura_core/outline/CDlgFuncList.h +++ b/sakura_core/outline/CDlgFuncList.h @@ -101,6 +101,7 @@ class CDlgFuncList final : public CDialog void SetWindowText( const WCHAR* szTitle ); //ダイアログタイトルの設定 EFunctionCode GetFuncCodeRedraw(int outlineType); void LoadFileTreeSetting( CFileTreeSetting& data, SFilePath& IniDirPath ); + void UpdateItemSelection( CLayoutInt nCurLine, CLayoutInt nCurCol ); protected: bool m_bInChangeLayout; @@ -139,6 +140,10 @@ class CDlgFuncList final : public CDialog void SetTreeFile(); // ツリーコントロールの初期化:ファイルツリー void SetListVB( void ); /* リストビューコントロールの初期化:VisualBasic */ // Jul 10, 2003 little YOSHI void SetDocLineFuncList(); + void SetItemSelection( int nSelectItemIndex ); + void SetItemSelectionForTreeView( HWND hwndTree, int nSelectItemIndex ); + void SetItemSelectionForListView( HWND hwndList, int nSelectItemIndex ); + bool GetFuncInfoIndex( CLayoutInt nCurLine, CLayoutInt nCurCol, int* pIndexOut ); void SetTreeFileSub(HTREEITEM hParent, const WCHAR* pszFile); // 2002/11/1 frozen diff --git a/sakura_core/view/CCaret.cpp b/sakura_core/view/CCaret.cpp index bf501ea97b..651ced2161 100644 --- a/sakura_core/view/CCaret.cpp +++ b/sakura_core/view/CCaret.cpp @@ -376,6 +376,10 @@ CLayoutInt CCaret::MoveCursor( m_pEditView->DrawBracketPair( true ); // 02/09/18 対括弧の強調表示 ai End 03/02/18 ai mod E + // アウトライン表示の選択位置を更新 + CLayoutPoint poCaret = GetCaretLayoutPos(); + m_pEditDoc->m_pcEditWnd->m_cDlgFuncList.UpdateItemSelection( poCaret.GetY2() + 1, poCaret.GetX2() + 1 ); + return nScrollRowNum; } From 0316519f1435033e6d1c054bfa58905cd1fcad12 Mon Sep 17 00:00:00 2001 From: miwa Date: Sun, 6 Sep 2020 21:56:49 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=E3=83=86=E3=82=AD=E3=82=B9=E3=83=88?= =?UTF-8?q?=E7=B7=A8=E9=9B=86=E3=81=97=E3=81=9F=E3=82=89=E8=BF=BD=E5=BE=93?= =?UTF-8?q?=E8=A7=A3=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/cmd/CViewCommander_Outline.cpp | 3 +- sakura_core/doc/CDocEditor.cpp | 2 + sakura_core/outline/CDlgFuncList.cpp | 61 ++++++++++++++++------ sakura_core/outline/CDlgFuncList.h | 4 ++ 4 files changed, 52 insertions(+), 18 deletions(-) diff --git a/sakura_core/cmd/CViewCommander_Outline.cpp b/sakura_core/cmd/CViewCommander_Outline.cpp index c935c2ecde..3e0fcd2a93 100644 --- a/sakura_core/cmd/CViewCommander_Outline.cpp +++ b/sakura_core/cmd/CViewCommander_Outline.cpp @@ -72,7 +72,8 @@ BOOL CViewCommander::Command_FUNCLIST( case SHOW_NORMAL: // アクティブにする // 開いているものと種別が同じならActiveにするだけ.異なれば再解析 GetEditWindow()->m_cDlgFuncList.SyncColor(); - if( GetEditWindow()->m_cDlgFuncList.CheckListType( nOutlineType )){ + if( GetEditWindow()->m_cDlgFuncList.CheckListType( nOutlineType ) + && GetEditWindow()->m_cDlgFuncList.IsUpToDate() ){ if( bForeground ){ ::SetFocus( GetEditWindow()->m_cDlgFuncList.GetHwnd() ); } diff --git a/sakura_core/doc/CDocEditor.cpp b/sakura_core/doc/CDocEditor.cpp index 1cb80474f0..53eaf01632 100644 --- a/sakura_core/doc/CDocEditor.cpp +++ b/sakura_core/doc/CDocEditor.cpp @@ -55,6 +55,8 @@ CDocEditor::CDocEditor(CEditDoc* pcDoc) */ void CDocEditor::SetModified( bool flag, bool redraw) { + m_pcDocRef->m_pcEditWnd->m_cDlgFuncList.NotifyDocModification(); + if( m_bIsDocModified == flag ) // 変更がなければ何もしない return; diff --git a/sakura_core/outline/CDlgFuncList.cpp b/sakura_core/outline/CDlgFuncList.cpp index 4f191b95d5..d136496bf0 100644 --- a/sakura_core/outline/CDlgFuncList.cpp +++ b/sakura_core/outline/CDlgFuncList.cpp @@ -346,6 +346,7 @@ HWND CDlgFuncList::DoModeless( CEditView* pcEditView=(CEditView*)lParam; if( !pcEditView ) return NULL; m_pcFuncInfoArr = pcFuncInfoArr; /* 関数情報配列 */ + m_bFuncInfoArrIsUpToDate = true; m_nCurLine = nCurLine; /* 現在行 */ m_nCurCol = nCurCol; /* 現在桁 */ m_nOutlineType = nOutlineType; /* アウトライン解析の種別 */ @@ -2702,6 +2703,7 @@ void CDlgFuncList::Redraw( int nOutLineType, int nListType, CFuncInfoArr* pcFunc m_nOutlineType = nOutLineType; m_nListType = nListType; m_pcFuncInfoArr = pcFuncInfoArr; /* 関数情報配列 */ + m_bFuncInfoArrIsUpToDate = true; m_nCurLine = nCurLine; /* 現在行 */ m_nCurCol = nCurCol; /* 現在桁 */ @@ -4057,6 +4059,14 @@ void CDlgFuncList::UpdateItemSelection( CLayoutInt nCurLine, CLayoutInt nCurCol return; } + if( !m_bFuncInfoArrIsUpToDate ){ + return; + } + + if( m_nCurLine == nCurLine && m_nCurCol == nCurCol ){ + return; + } + m_nCurLine = nCurLine; m_nCurCol = nCurCol; @@ -4068,7 +4078,15 @@ void CDlgFuncList::UpdateItemSelection( CLayoutInt nCurLine, CLayoutInt nCurCol return; } -// nFuncInfoIndexが0未満の時は選択をすべて解除 +void CDlgFuncList::NotifyDocModification() +{ + // もう最新ではなくなりました + m_bFuncInfoArrIsUpToDate = false; + + // 選択を解除するどうか悩ましいところ + //SetItemSelection( -1 ); +} + void CDlgFuncList::SetItemSelection( int nFuncInfoIndex ) { if( m_nViewType == VIEWTYPE_TREE ){ @@ -4086,29 +4104,34 @@ void CDlgFuncList::SetItemSelection( int nFuncInfoIndex ) void CDlgFuncList::SetItemSelectionForTreeView( HWND hwndTree, int nFuncInfoIndex ) { - // 関数情報のインデックスに該当するアイテム探してを選択状態に + if( nFuncInfoIndex == -1 ){ + TreeView_SelectItem( hwndTree, NULL ); + return; + } + std::vector htiStack; htiStack.reserve( TreeView_GetCount( hwndTree ) ); htiStack.push_back( TreeView_GetRoot( hwndTree ) ); - int nStackIndex = 0; + size_t nStackIndex = 0; bool bFound = false; while( !bFound && nStackIndex < htiStack.size() ){ HTREEITEM htiCurrent = htiStack[nStackIndex]; - for( ; NULL != htiCurrent ; htiCurrent = TreeView_GetNextSibling( hwndTree, htiCurrent )){ - TVITEM tvItem = {}; - tvItem.mask = TVIF_HANDLE | TVIF_PARAM; - tvItem.hItem = htiCurrent; - TreeView_GetItem( hwndTree, &tvItem ); - if( nFuncInfoIndex == TreeDummylParamToFuncInfoIndex(m_vecDummylParams, tvItem.lParam) ){ - // 発見 - TreeView_SelectItem( hwndTree, htiCurrent ); - bFound = true; - break; - } - + for( ; NULL != htiCurrent ; htiCurrent = TreeView_GetNextSibling( hwndTree, htiCurrent ) ){ HTREEITEM htiChild = TreeView_GetChild( hwndTree, htiCurrent ); if( htiChild != NULL ){ + // 中間ノードは選択対象に非ず htiStack.push_back( htiChild ); + }else{ + TVITEM tvItem = {}; + tvItem.mask = TVIF_HANDLE | TVIF_PARAM; + tvItem.hItem = htiCurrent; + TreeView_GetItem( hwndTree, &tvItem ); + if( nFuncInfoIndex == TreeDummylParamToFuncInfoIndex( m_vecDummylParams, tvItem.lParam ) ){ + // 発見 + TreeView_SelectItem( hwndTree, htiCurrent ); + bFound = true; + break; + } } } ++nStackIndex; @@ -4119,8 +4142,12 @@ void CDlgFuncList::SetItemSelectionForTreeView( HWND hwndTree, int nFuncInfoInde void CDlgFuncList::SetItemSelectionForListView( HWND hwndList, int nFuncInfoIndex ) { - ListView_SetItemState( hwndList, nFuncInfoIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED ); - ListView_EnsureVisible( hwndList, nFuncInfoIndex, FALSE ); + if( nFuncInfoIndex != -1 ){ + ListView_SetItemState( hwndList, nFuncInfoIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED ); + ListView_EnsureVisible( hwndList, nFuncInfoIndex, FALSE ); + }else{ + ListView_SetItemState( hwndList, nFuncInfoIndex, 0, LVIS_SELECTED | LVIS_FOCUSED ); + } return; } diff --git a/sakura_core/outline/CDlgFuncList.h b/sakura_core/outline/CDlgFuncList.h index c0c67cba0b..b5e72f9ce1 100644 --- a/sakura_core/outline/CDlgFuncList.h +++ b/sakura_core/outline/CDlgFuncList.h @@ -102,6 +102,8 @@ class CDlgFuncList final : public CDialog EFunctionCode GetFuncCodeRedraw(int outlineType); void LoadFileTreeSetting( CFileTreeSetting& data, SFilePath& IniDirPath ); void UpdateItemSelection( CLayoutInt nCurLine, CLayoutInt nCurCol ); + bool IsUpToDate() { return m_bFuncInfoArrIsUpToDate; } + void NotifyDocModification(); protected: bool m_bInChangeLayout; @@ -227,5 +229,7 @@ class CDlgFuncList final : public CDialog POINT m_ptDefaultSize; POINT m_ptDefaultSizeClient; RECT m_rcItems[12]; + + bool m_bFuncInfoArrIsUpToDate; }; #endif /* SAKURA_CDLGFUNCLIST_B22A3877_572A_49B7_B683_50ECA451A6F8_H_ */ From a576688ac62ddefb6255e95c0909b5cce10b6b42 Mon Sep 17 00:00:00 2001 From: miwa Date: Thu, 10 Sep 2020 00:55:31 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=E4=B8=AD=E9=96=93=E3=83=8E=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=82=82=E9=81=B8=E6=8A=9E=E5=AF=BE=E8=B1=A1=E3=81=AB?= =?UTF-8?q?=E5=90=AB=E3=82=81=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/outline/CDlgFuncList.cpp | 26 +++++++++++++------------- sakura_core/outline/CDlgFuncList.h | 4 ++-- sakura_core/view/CCaret.cpp | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/sakura_core/outline/CDlgFuncList.cpp b/sakura_core/outline/CDlgFuncList.cpp index d136496bf0..52ca46100b 100644 --- a/sakura_core/outline/CDlgFuncList.cpp +++ b/sakura_core/outline/CDlgFuncList.cpp @@ -4053,7 +4053,7 @@ void CDlgFuncList::LoadFileTreeSetting( CFileTreeSetting& data, SFilePath& IniDi } } -void CDlgFuncList::UpdateItemSelection( CLayoutInt nCurLine, CLayoutInt nCurCol ) +void CDlgFuncList::NotifyCaretMovement( CLayoutInt nCurLine, CLayoutInt nCurCol ) { if( !::IsWindowVisible( this->GetHwnd() ) ){ return; @@ -4117,21 +4117,21 @@ void CDlgFuncList::SetItemSelectionForTreeView( HWND hwndTree, int nFuncInfoInde while( !bFound && nStackIndex < htiStack.size() ){ HTREEITEM htiCurrent = htiStack[nStackIndex]; for( ; NULL != htiCurrent ; htiCurrent = TreeView_GetNextSibling( hwndTree, htiCurrent ) ){ + TVITEM tvItem = {}; + tvItem.mask = TVIF_HANDLE | TVIF_PARAM; + tvItem.hItem = htiCurrent; + TreeView_GetItem( hwndTree, &tvItem ); + if( nFuncInfoIndex == TreeDummylParamToFuncInfoIndex( m_vecDummylParams, tvItem.lParam ) ){ + // 発見 + TreeView_SelectItem( hwndTree, htiCurrent ); + TreeView_EnsureVisible( hwndTree, htiCurrent ); + bFound = true; + break; + } + HTREEITEM htiChild = TreeView_GetChild( hwndTree, htiCurrent ); if( htiChild != NULL ){ - // 中間ノードは選択対象に非ず htiStack.push_back( htiChild ); - }else{ - TVITEM tvItem = {}; - tvItem.mask = TVIF_HANDLE | TVIF_PARAM; - tvItem.hItem = htiCurrent; - TreeView_GetItem( hwndTree, &tvItem ); - if( nFuncInfoIndex == TreeDummylParamToFuncInfoIndex( m_vecDummylParams, tvItem.lParam ) ){ - // 発見 - TreeView_SelectItem( hwndTree, htiCurrent ); - bFound = true; - break; - } } } ++nStackIndex; diff --git a/sakura_core/outline/CDlgFuncList.h b/sakura_core/outline/CDlgFuncList.h index b5e72f9ce1..9c1ad1bf74 100644 --- a/sakura_core/outline/CDlgFuncList.h +++ b/sakura_core/outline/CDlgFuncList.h @@ -101,9 +101,9 @@ class CDlgFuncList final : public CDialog void SetWindowText( const WCHAR* szTitle ); //ダイアログタイトルの設定 EFunctionCode GetFuncCodeRedraw(int outlineType); void LoadFileTreeSetting( CFileTreeSetting& data, SFilePath& IniDirPath ); - void UpdateItemSelection( CLayoutInt nCurLine, CLayoutInt nCurCol ); - bool IsUpToDate() { return m_bFuncInfoArrIsUpToDate; } + void NotifyCaretMovement( CLayoutInt nCurLine, CLayoutInt nCurCol ); void NotifyDocModification(); + bool IsUpToDate() { return m_bFuncInfoArrIsUpToDate; } protected: bool m_bInChangeLayout; diff --git a/sakura_core/view/CCaret.cpp b/sakura_core/view/CCaret.cpp index 651ced2161..1b62d7e0e3 100644 --- a/sakura_core/view/CCaret.cpp +++ b/sakura_core/view/CCaret.cpp @@ -378,7 +378,7 @@ CLayoutInt CCaret::MoveCursor( // アウトライン表示の選択位置を更新 CLayoutPoint poCaret = GetCaretLayoutPos(); - m_pEditDoc->m_pcEditWnd->m_cDlgFuncList.UpdateItemSelection( poCaret.GetY2() + 1, poCaret.GetX2() + 1 ); + m_pEditDoc->m_pcEditWnd->m_cDlgFuncList.NotifyCaretMovement( poCaret.GetY2() + 1, poCaret.GetX2() + 1 ); return nScrollRowNum; } From 3d16a61f1a4a0f840a54502270419c328f3996d4 Mon Sep 17 00:00:00 2001 From: miwa Date: Sat, 12 Sep 2020 12:03:49 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=99=82=E3=81=AB=E8=BF=BD=E5=BE=93=E3=81=8C?= =?UTF-8?q?=E5=A4=96=E3=82=8C=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/doc/CDocEditor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sakura_core/doc/CDocEditor.cpp b/sakura_core/doc/CDocEditor.cpp index 53eaf01632..8d21c9b712 100644 --- a/sakura_core/doc/CDocEditor.cpp +++ b/sakura_core/doc/CDocEditor.cpp @@ -55,7 +55,9 @@ CDocEditor::CDocEditor(CEditDoc* pcDoc) */ void CDocEditor::SetModified( bool flag, bool redraw) { - m_pcDocRef->m_pcEditWnd->m_cDlgFuncList.NotifyDocModification(); + if( redraw ){ + m_pcDocRef->m_pcEditWnd->m_cDlgFuncList.NotifyDocModification(); + } if( m_bIsDocModified == flag ) // 変更がなければ何もしない return; From 534ed6c5c6b8c33a28247fa983f246955c833d40 Mon Sep 17 00:00:00 2001 From: miwa Date: Sat, 12 Sep 2020 12:31:00 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E3=81=A8=E5=89=8A=E9=99=A4=E8=A1=8C=E3=81=AE?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/cmd/CViewCommander_Outline.cpp | 2 +- sakura_core/outline/CDlgFuncList.cpp | 197 ++++----------------- 2 files changed, 39 insertions(+), 160 deletions(-) diff --git a/sakura_core/cmd/CViewCommander_Outline.cpp b/sakura_core/cmd/CViewCommander_Outline.cpp index 3e0fcd2a93..56ab986b35 100644 --- a/sakura_core/cmd/CViewCommander_Outline.cpp +++ b/sakura_core/cmd/CViewCommander_Outline.cpp @@ -70,7 +70,7 @@ BOOL CViewCommander::Command_FUNCLIST( if( NULL != GetEditWindow()->m_cDlgFuncList.GetHwnd() && nAction != SHOW_RELOAD ){ switch(nAction ){ case SHOW_NORMAL: // アクティブにする - // 開いているものと種別が同じならActiveにするだけ.異なれば再解析 + // 開いているものと種別が同じかつ内容が最新ならActiveにするだけ.それ以外なら再解析 GetEditWindow()->m_cDlgFuncList.SyncColor(); if( GetEditWindow()->m_cDlgFuncList.CheckListType( nOutlineType ) && GetEditWindow()->m_cDlgFuncList.IsUpToDate() ){ diff --git a/sakura_core/outline/CDlgFuncList.cpp b/sakura_core/outline/CDlgFuncList.cpp index 52ca46100b..75d9f5d337 100644 --- a/sakura_core/outline/CDlgFuncList.cpp +++ b/sakura_core/outline/CDlgFuncList.cpp @@ -538,7 +538,6 @@ void CDlgFuncList::SetData() ::SetWindowText( GetHwnd(), L"" ); break; } - // May 18, 2001 genta // Windowがいなくなると後で都合が悪いので、表示しないだけにしておく //::DestroyWindow( hwndTree ); @@ -547,14 +546,6 @@ void CDlgFuncList::SetData() WCHAR szText[2048]; const CFuncInfo* pcFuncInfo; LV_ITEM item; - //bool bSelected; - //CLayoutInt nFuncLineOld(-1); - //CLayoutInt nFuncColOld(-1); - //CLayoutInt nFuncLineTop(INT_MAX); - //CLayoutInt nFuncColTop(INT_MAX); - //int nSelectedLineTop = 0; - //int nSelectedLine = 0; - //RECT rc; m_cmemClipText.SetString(L""); /* クリップボードコピー用テキスト */ { @@ -569,33 +560,7 @@ void CDlgFuncList::SetData() } ::EnableWindow( GetItemHwnd( IDC_BUTTON_COPY ), TRUE ); - //bSelected = false; - //for( i = 0; i < m_pcFuncInfoArr->GetNum(); ++i ){ - // pcFuncInfo = m_pcFuncInfoArr->GetAt( i ); - // if( !bSelected ){ - // if( pcFuncInfo->m_nFuncLineLAYOUT < nFuncLineTop - // || (pcFuncInfo->m_nFuncLineLAYOUT == nFuncLineTop && pcFuncInfo->m_nFuncColLAYOUT <= nFuncColTop) ){ - // nFuncLineTop = pcFuncInfo->m_nFuncLineLAYOUT; - // nFuncColTop = pcFuncInfo->m_nFuncColLAYOUT; - // nSelectedLineTop = i; - // } - // } - // { - // if( (nFuncLineOld < pcFuncInfo->m_nFuncLineLAYOUT - // || (nFuncLineOld == pcFuncInfo->m_nFuncColLAYOUT && nFuncColOld <= pcFuncInfo->m_nFuncColLAYOUT)) - // && (pcFuncInfo->m_nFuncLineLAYOUT < m_nCurLine - // || (pcFuncInfo->m_nFuncLineLAYOUT == m_nCurLine && pcFuncInfo->m_nFuncColLAYOUT <= m_nCurCol)) ){ - // nFuncLineOld = pcFuncInfo->m_nFuncLineLAYOUT; - // nFuncColOld = pcFuncInfo->m_nFuncColLAYOUT; - // bSelected = true; - // nSelectedLine = i; - // } - // } - //} - //if( 0 < m_pcFuncInfoArr->GetNum() && !bSelected ){ - // bSelected = true; - // nSelectedLine = nSelectedLineTop; - //} + for( i = 0; i < m_pcFuncInfoArr->GetNum(); ++i ){ /* 現在の解析結果要素 */ pcFuncInfo = m_pcFuncInfoArr->GetAt( i ); @@ -700,14 +665,9 @@ void CDlgFuncList::SetData() DWORD dwExStyle = ListView_GetExtendedListViewStyle( hwndList ); dwExStyle |= LVS_EX_FULLROWSELECT; ListView_SetExtendedListViewStyle( hwndList, dwExStyle ); - - //if( bSelected ){ - // ListView_GetItemRect( hwndList, 0, &rc, LVIR_BOUNDS ); - // ListView_Scroll( hwndList, 0, nSelectedLine * ( rc.bottom - rc.top ) ); - // ListView_SetItemState( hwndList, nSelectedLine, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED ); - //} } + // 選択状態更新 int nFuncInfoIndex = -1; if( GetFuncInfoIndex( m_nCurLine, m_nCurCol, &nFuncInfoIndex ) ){ SetItemSelection( nFuncInfoIndex ); @@ -921,6 +881,7 @@ int CDlgFuncList::GetData( void ) Java Method Treeの構築: 関数リストを元にTreeControlを初期化する。 @date 2002.01.04 genta C++ツリーを統合 + @date 2020.09.12 選択処理をGetFuncInfoIndex,SetItemSelectionへ移動 */ void CDlgFuncList::SetTreeJava( HWND hwndDlg, BOOL bAddClass ) { @@ -1179,26 +1140,6 @@ void CDlgFuncList::SetTreeJava( HWND hwndDlg, BOOL bAddClass ) m_cmemClipText.AppendString(FL_OBJ_DECLARE == pcFuncInfo->m_nInfo ? m_pcFuncInfoArr->GetAppendText( FL_OBJ_DECLARE ).c_str() : L"" ); // Jan. 04, 2001 genta C++で使用 m_cmemClipText.AppendString(L"\r\n"); - ///* 現在カーソル位置のメソッドかどうか調べる */ - //if( !bSelected ){ - // if( pcFuncInfo->m_nFuncLineLAYOUT < nFuncLineTop - // || (pcFuncInfo->m_nFuncLineLAYOUT == nFuncLineTop && pcFuncInfo->m_nFuncColLAYOUT <= nFuncColTop) ){ - // nFuncLineTop = pcFuncInfo->m_nFuncLineLAYOUT; - // nFuncColTop = pcFuncInfo->m_nFuncColLAYOUT; - // htiSelectedTop = htiItem; - // } - //} - //{ - // if( (nFuncLineOld < pcFuncInfo->m_nFuncLineLAYOUT - // || (nFuncLineOld == pcFuncInfo->m_nFuncColLAYOUT && nFuncColOld <= pcFuncInfo->m_nFuncColLAYOUT)) - // && (pcFuncInfo->m_nFuncLineLAYOUT < m_nCurLine - // || (pcFuncInfo->m_nFuncLineLAYOUT == m_nCurLine && pcFuncInfo->m_nFuncColLAYOUT <= m_nCurCol)) ){ - // nFuncLineOld = pcFuncInfo->m_nFuncLineLAYOUT; - // nFuncColOld = pcFuncInfo->m_nFuncColLAYOUT; - // bSelected = TRUE; - // htiSelected = htiItem; - // } - //} // Jan. 04, 2001 genta // deleteはその都度行うのでここでは不要 } @@ -1210,12 +1151,7 @@ void CDlgFuncList::SetTreeJava( HWND hwndDlg, BOOL bAddClass ) TreeView_Expand( hwndTree, htiClass, TVE_EXPAND ); htiClass = TreeView_GetNextSibling( hwndTree, htiClass ); } - ///* 現在カーソル位置のメソッドを選択状態にする */ - //if( bSelected ){ - // TreeView_SelectItem( hwndTree, htiSelected ); - //}else{ - // TreeView_SelectItem( hwndTree, htiSelectedTop ); - //} + // GetTreeTextNext( hwndTree, NULL, 0 ); m_nTreeItemCount = nlParamCount; return; @@ -1226,6 +1162,7 @@ void CDlgFuncList::SetTreeJava( HWND hwndDlg, BOOL bAddClass ) 長くなったので独立させました。 @date Jul 10, 2003 little YOSHI + @date 2020.09.12 選択処理をGetFuncInfoIndex,SetItemSelectionへ移動 */ void CDlgFuncList::SetListVB (void) { @@ -1235,11 +1172,6 @@ void CDlgFuncList::SetListVB (void) const CFuncInfo* pcFuncInfo; LV_ITEM item; HWND hwndList; - //int bSelected; - //CLayoutInt nFuncLineOld; - //CLayoutInt nFuncColOld; - //int nSelectedLine = 0; - //RECT rc; ::EnableWindow( GetItemHwnd( IDC_BUTTON_COPY ), TRUE ); @@ -1257,39 +1189,6 @@ void CDlgFuncList::SetListVB (void) m_cmemClipText.AllocStringBuffer( nBuffLen + nBuffLenTag * nNum ); } - //nFuncLineOld = CLayoutInt(-1); - //nFuncColOld = CLayoutInt(-1); - //CLayoutInt nFuncLineTop(INT_MAX); - //CLayoutInt nFuncColTop(INT_MAX); - //int nSelectedLineTop = 0; - //bSelected = FALSE; - //for( i = 0; i < m_pcFuncInfoArr->GetNum(); ++i ){ - // pcFuncInfo = m_pcFuncInfoArr->GetAt( i ); - // if( !bSelected ){ - // if( pcFuncInfo->m_nFuncLineLAYOUT < nFuncLineTop - // || (pcFuncInfo->m_nFuncLineLAYOUT == nFuncLineTop && pcFuncInfo->m_nFuncColLAYOUT <= nFuncColTop) ){ - // nFuncLineTop = pcFuncInfo->m_nFuncLineLAYOUT; - // nFuncColTop = pcFuncInfo->m_nFuncColLAYOUT; - // nSelectedLineTop = i; - // } - // } - // { - // if( (nFuncLineOld < pcFuncInfo->m_nFuncLineLAYOUT - // || (nFuncLineOld == pcFuncInfo->m_nFuncColLAYOUT && nFuncColOld <= pcFuncInfo->m_nFuncColLAYOUT)) - // && (pcFuncInfo->m_nFuncLineLAYOUT < m_nCurLine - // || (pcFuncInfo->m_nFuncLineLAYOUT == m_nCurLine && pcFuncInfo->m_nFuncColLAYOUT <= m_nCurCol)) ){ - // nFuncLineOld = pcFuncInfo->m_nFuncLineLAYOUT; - // nFuncColOld = pcFuncInfo->m_nFuncColLAYOUT; - // bSelected = TRUE; - // nSelectedLine = i; - // } - // } - //} - //if( 0 < m_pcFuncInfoArr->GetNum() && !bSelected ){ - // bSelected = TRUE; - // nSelectedLine = nSelectedLineTop; - //} - WCHAR szText[2048]; for( i = 0; i < m_pcFuncInfoArr->GetNum(); ++i ){ /* 現在の解析結果要素 */ @@ -1458,11 +1357,6 @@ void CDlgFuncList::SetListVB (void) ListView_SetColumnWidth( hwndList, FL_COL_COL, ListView_GetColumnWidth( hwndList, FL_COL_COL ) + 16 ); ListView_SetColumnWidth( hwndList, FL_COL_NAME, ListView_GetColumnWidth( hwndList, FL_COL_NAME ) + 16 ); ListView_SetColumnWidth( hwndList, FL_COL_REMARK, ListView_GetColumnWidth( hwndList, FL_COL_REMARK ) + 16 ); - //if( bSelected ){ - // ListView_GetItemRect( hwndList, 0, &rc, LVIR_BOUNDS ); - // ListView_Scroll( hwndList, 0, nSelectedLine * ( rc.bottom - rc.top ) ); - // ListView_SetItemState( hwndList, nSelectedLine, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED ); - //} return; } @@ -1476,11 +1370,10 @@ void CDlgFuncList::SetListVB (void) @date 2007.02.25 genta クリップボード出力をタブジャンプ可能な書式に変更 @date 2007.03.04 genta タブジャンプ可能な書式に変更するかどうかのフラグを追加 @date 2014.06.06 Moca 他ファイルへのタグジャンプ機能を追加 + @date 2020.09.12 選択処理をGetFuncInfoIndex,SetItemSelectionへ移動 */ void CDlgFuncList::SetTree(bool tagjump, bool nolabel) { - //HTREEITEM hItemSelected = NULL; - //HTREEITEM hItemSelectedTop = NULL; HWND hwndTree = GetItemHwnd( IDC_TREE_FL ); int i; @@ -1490,11 +1383,6 @@ void CDlgFuncList::SetTree(bool tagjump, bool nolabel) HTREEITEM* phParentStack; phParentStack = (HTREEITEM*)malloc( nStackDepth * sizeof( HTREEITEM ) ); phParentStack[ nStackPointer ] = TVI_ROOT; - //CLayoutInt nFuncLineOld(-1); - //CLayoutInt nFuncColOld(-1); - //CLayoutInt nFuncLineTop(INT_MAX); - //CLayoutInt nFuncColTop(INT_MAX); - //bool bSelected = false; m_cmemClipText.SetString(L""); { @@ -1553,36 +1441,6 @@ void CDlgFuncList::SetTree(bool tagjump, bool nolabel) hItem = TreeView_InsertItem( hwndTree, &cTVInsertStruct ); phParentStack[ nStackPointer+1 ] = hItem; - ///* pcFuncInfoに登録されている行数、桁を確認して、選択するアイテムを考える - //*/ - //bool bFileSelect = false; - //if( pcFuncInfo->m_cmemFileName.GetStringPtr() && m_pcFuncInfoArr->m_szFilePath[0] ){ - // if( 0 == wmemicmp( pcFuncInfo->m_cmemFileName.GetStringPtr(), m_pcFuncInfoArr->m_szFilePath.c_str() ) ){ - // bFileSelect = true; - // } - //}else{ - // bFileSelect = true; - //} - //if( bFileSelect ){ - // if( !bSelected ){ - // if( pcFuncInfo->m_nFuncLineLAYOUT < nFuncLineTop - // || (pcFuncInfo->m_nFuncLineLAYOUT == nFuncLineTop && pcFuncInfo->m_nFuncColLAYOUT <= nFuncColTop) ){ - // nFuncLineTop = pcFuncInfo->m_nFuncLineLAYOUT; - // nFuncColTop = pcFuncInfo->m_nFuncColLAYOUT; - // hItemSelectedTop = hItem; - // } - // } - // if( (nFuncLineOld < pcFuncInfo->m_nFuncLineLAYOUT - // || (nFuncLineOld == pcFuncInfo->m_nFuncColLAYOUT && nFuncColOld <= pcFuncInfo->m_nFuncColLAYOUT)) - // && (pcFuncInfo->m_nFuncLineLAYOUT < m_nCurLine - // || (pcFuncInfo->m_nFuncLineLAYOUT == m_nCurLine && pcFuncInfo->m_nFuncColLAYOUT <= m_nCurCol)) ){ - // nFuncLineOld = pcFuncInfo->m_nFuncLineLAYOUT; - // nFuncColOld = pcFuncInfo->m_nFuncColLAYOUT; - // hItemSelected = hItem; - // bSelected = true; - // } - //} - /* クリップボードコピー用テキストを作成する */ // 2003.06.22 Moca dummy要素はツリーに入れるがTAGJUMPには加えない if( pcFuncInfo->IsAddClipText() ){ @@ -1628,13 +1486,6 @@ end_of_func:; ::EnableWindow( GetItemHwnd( IDC_BUTTON_COPY ), TRUE ); - //if( NULL != hItemSelected ){ - // /* 現在カーソル位置のメソッドを選択状態にする */ - // TreeView_SelectItem( hwndTree, hItemSelected ); - //}else if( NULL != hItemSelectedTop ){ - // TreeView_SelectItem( hwndTree, hItemSelectedTop ); - //} - free( phParentStack ); } @@ -4053,6 +3904,11 @@ void CDlgFuncList::LoadFileTreeSetting( CFileTreeSetting& data, SFilePath& IniDi } } +/*! + キャレットの移動を通知 + @param[in] nCurLine 移動後の行 + @param[in] nCurCol 移動後の桁 +*/ void CDlgFuncList::NotifyCaretMovement( CLayoutInt nCurLine, CLayoutInt nCurCol ) { if( !::IsWindowVisible( this->GetHwnd() ) ){ @@ -4078,15 +3934,19 @@ void CDlgFuncList::NotifyCaretMovement( CLayoutInt nCurLine, CLayoutInt nCurCol return; } +/*! + ドキュメントの変更を通知 +*/ void CDlgFuncList::NotifyDocModification() { // もう最新ではなくなりました m_bFuncInfoArrIsUpToDate = false; - - // 選択を解除するどうか悩ましいところ - //SetItemSelection( -1 ); } +/*! + リスト/ツリービュー上のアイテムを選択または選択解除 + @param[in] nFuncInfoIndex 選択対象とする関数情報配列のインデックス(-1の場合は選択解除) +*/ void CDlgFuncList::SetItemSelection( int nFuncInfoIndex ) { if( m_nViewType == VIEWTYPE_TREE ){ @@ -4102,6 +3962,11 @@ void CDlgFuncList::SetItemSelection( int nFuncInfoIndex ) return; } +/*! + ツリービュー上のアイテムを選択または選択解除 + @param[in] hwndTree 対象とするツリービューのハンドル + @param[in] nFuncInfoIndex 選択対象とする関数情報配列のインデックス(-1の場合は選択解除) +*/ void CDlgFuncList::SetItemSelectionForTreeView( HWND hwndTree, int nFuncInfoIndex ) { if( nFuncInfoIndex == -1 ){ @@ -4140,6 +4005,11 @@ void CDlgFuncList::SetItemSelectionForTreeView( HWND hwndTree, int nFuncInfoInde return; } +/*! + リストビュー上のアイテムを選択または選択解除 + @param[in] hwndList 対象とするリストビューのハンドル + @param[in] nFuncInfoIndex 選択対象とする関数情報配列のインデックス(-1の場合は選択解除) +*/ void CDlgFuncList::SetItemSelectionForListView( HWND hwndList, int nFuncInfoIndex ) { if( nFuncInfoIndex != -1 ){ @@ -4152,6 +4022,14 @@ void CDlgFuncList::SetItemSelectionForListView( HWND hwndList, int nFuncInfoInde return; } +/*! + 指定した位置に該当する関数情報のインデックスを取得 + @param[in] nCurLine 行 + @param[in] nCurCol 桁 + @param[out] pIndexOut 該当する関数情報のインデックスを格納 + @retval true 該当あり + @retval false 該当なし(出力引数には何も設定せず) +*/ bool CDlgFuncList::GetFuncInfoIndex( CLayoutInt nCurLine, CLayoutInt nCurCol, int* pIndexOut ) { const CFuncInfo* pcFuncInfo = NULL; @@ -4166,7 +4044,8 @@ bool CDlgFuncList::GetFuncInfoIndex( CLayoutInt nCurLine, CLayoutInt nCurCol, in return false; } - // カーソル位置に該当する関数情報のインデックスを得る + // SetTree,SetTreeJava,SetListVB,SetDataにあった処理を持ってきました + for( i = 0; i < m_pcFuncInfoArr->GetNum(); ++i ){ pcFuncInfo = m_pcFuncInfoArr->GetAt( i ); From 27829ebe34ca25c978c542e6d38efb4924759872 Mon Sep 17 00:00:00 2001 From: miwa Date: Sat, 12 Sep 2020 21:57:23 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=E8=BF=BD=E5=BE=93=E6=99=82=E3=81=AB?= =?UTF-8?q?=E3=81=AF=E3=83=84=E3=83=AA=E3=83=BC=E3=81=AE=E5=B1=95=E9=96=8B?= =?UTF-8?q?=E7=8A=B6=E6=85=8B=E3=82=92=E3=82=AD=E3=83=BC=E3=83=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/cmd/CViewCommander_Outline.cpp | 5 +-- sakura_core/outline/CDlgFuncList.cpp | 51 ++++++++++++++++------ sakura_core/outline/CDlgFuncList.h | 5 +-- 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/sakura_core/cmd/CViewCommander_Outline.cpp b/sakura_core/cmd/CViewCommander_Outline.cpp index 56ab986b35..c935c2ecde 100644 --- a/sakura_core/cmd/CViewCommander_Outline.cpp +++ b/sakura_core/cmd/CViewCommander_Outline.cpp @@ -70,10 +70,9 @@ BOOL CViewCommander::Command_FUNCLIST( if( NULL != GetEditWindow()->m_cDlgFuncList.GetHwnd() && nAction != SHOW_RELOAD ){ switch(nAction ){ case SHOW_NORMAL: // アクティブにする - // 開いているものと種別が同じかつ内容が最新ならActiveにするだけ.それ以外なら再解析 + // 開いているものと種別が同じならActiveにするだけ.異なれば再解析 GetEditWindow()->m_cDlgFuncList.SyncColor(); - if( GetEditWindow()->m_cDlgFuncList.CheckListType( nOutlineType ) - && GetEditWindow()->m_cDlgFuncList.IsUpToDate() ){ + if( GetEditWindow()->m_cDlgFuncList.CheckListType( nOutlineType )){ if( bForeground ){ ::SetFocus( GetEditWindow()->m_cDlgFuncList.GetHwnd() ); } diff --git a/sakura_core/outline/CDlgFuncList.cpp b/sakura_core/outline/CDlgFuncList.cpp index 75d9f5d337..3c2866ec84 100644 --- a/sakura_core/outline/CDlgFuncList.cpp +++ b/sakura_core/outline/CDlgFuncList.cpp @@ -670,7 +670,7 @@ void CDlgFuncList::SetData() // 選択状態更新 int nFuncInfoIndex = -1; if( GetFuncInfoIndex( m_nCurLine, m_nCurCol, &nFuncInfoIndex ) ){ - SetItemSelection( nFuncInfoIndex ); + SetItemSelection( nFuncInfoIndex, true ); } /* アウトライン ダイアログを自動的に閉じる */ @@ -3928,7 +3928,7 @@ void CDlgFuncList::NotifyCaretMovement( CLayoutInt nCurLine, CLayoutInt nCurCol int nFuncInfoIndex = -1; if( GetFuncInfoIndex( nCurLine, nCurCol, &nFuncInfoIndex ) ){ - SetItemSelection( nFuncInfoIndex ); + SetItemSelection( nFuncInfoIndex, false ); } return; @@ -3946,12 +3946,13 @@ void CDlgFuncList::NotifyDocModification() /*! リスト/ツリービュー上のアイテムを選択または選択解除 @param[in] nFuncInfoIndex 選択対象とする関数情報配列のインデックス(-1の場合は選択解除) + @param[in] bAllowExpand 選択対象を含むノードを展開するかどうか(ツリービュー以外では無視) */ -void CDlgFuncList::SetItemSelection( int nFuncInfoIndex ) +void CDlgFuncList::SetItemSelection( int nFuncInfoIndex, bool bAllowExpand ) { if( m_nViewType == VIEWTYPE_TREE ){ HWND hwndTree = GetItemHwnd( IDC_TREE_FL ); - SetItemSelectionForTreeView( hwndTree, nFuncInfoIndex ); + SetItemSelectionForTreeView( hwndTree, nFuncInfoIndex, bAllowExpand ); }else if( m_nViewType == VIEWTYPE_LIST ){ HWND hwndList = GetItemHwnd( IDC_LIST_FL ); SetItemSelectionForListView( hwndList, nFuncInfoIndex ); @@ -3966,8 +3967,9 @@ void CDlgFuncList::SetItemSelection( int nFuncInfoIndex ) ツリービュー上のアイテムを選択または選択解除 @param[in] hwndTree 対象とするツリービューのハンドル @param[in] nFuncInfoIndex 選択対象とする関数情報配列のインデックス(-1の場合は選択解除) + @param[in] bAllowExpand 選択対象を含むノードを展開するかどうか */ -void CDlgFuncList::SetItemSelectionForTreeView( HWND hwndTree, int nFuncInfoIndex ) +void CDlgFuncList::SetItemSelectionForTreeView( HWND hwndTree, int nFuncInfoIndex, bool bAllowExpand ) { if( nFuncInfoIndex == -1 ){ TreeView_SelectItem( hwndTree, NULL ); @@ -3975,11 +3977,11 @@ void CDlgFuncList::SetItemSelectionForTreeView( HWND hwndTree, int nFuncInfoInde } std::vector htiStack; + HTREEITEM htiFound = NULL; htiStack.reserve( TreeView_GetCount( hwndTree ) ); htiStack.push_back( TreeView_GetRoot( hwndTree ) ); size_t nStackIndex = 0; - bool bFound = false; - while( !bFound && nStackIndex < htiStack.size() ){ + while( htiFound == NULL && nStackIndex < htiStack.size() ){ HTREEITEM htiCurrent = htiStack[nStackIndex]; for( ; NULL != htiCurrent ; htiCurrent = TreeView_GetNextSibling( hwndTree, htiCurrent ) ){ TVITEM tvItem = {}; @@ -3988,9 +3990,7 @@ void CDlgFuncList::SetItemSelectionForTreeView( HWND hwndTree, int nFuncInfoInde TreeView_GetItem( hwndTree, &tvItem ); if( nFuncInfoIndex == TreeDummylParamToFuncInfoIndex( m_vecDummylParams, tvItem.lParam ) ){ // 発見 - TreeView_SelectItem( hwndTree, htiCurrent ); - TreeView_EnsureVisible( hwndTree, htiCurrent ); - bFound = true; + htiFound = htiCurrent; break; } @@ -4002,6 +4002,29 @@ void CDlgFuncList::SetItemSelectionForTreeView( HWND hwndTree, int nFuncInfoInde ++nStackIndex; } + if( htiFound != NULL ){ + HTREEITEM htiSelect = htiFound; + if( !bAllowExpand ){ + // 未展開のアイテムは勝手に開けないよう気を付けて選択 + + HTREEITEM htiParent = TreeView_GetParent( hwndTree, htiFound ); + if( htiParent == NULL || (TreeView_GetItemState( hwndTree, htiParent, TVIS_EXPANDED ) & TVIS_EXPANDED) != 0 ){ + htiSelect = htiFound; + }else{ + // [A] 展開 + // +-[B] 未展開 <<< ここを探します + // +-[C] 未展開 + // +-[htiFound] + do{ + htiSelect = htiParent; + htiParent = TreeView_GetParent( hwndTree, htiParent ); + }while( htiParent != NULL && (TreeView_GetItemState( hwndTree, htiParent, TVIS_EXPANDED ) & TVIS_EXPANDED) == 0 ); + } + } + TreeView_SelectItem( hwndTree, htiSelect ); + TreeView_EnsureVisible( hwndTree, htiSelect ); + } + return; } @@ -4026,11 +4049,11 @@ void CDlgFuncList::SetItemSelectionForListView( HWND hwndList, int nFuncInfoInde 指定した位置に該当する関数情報のインデックスを取得 @param[in] nCurLine 行 @param[in] nCurCol 桁 - @param[out] pIndexOut 該当する関数情報のインデックスを格納 + @param[out] pnIndexOut 該当する関数情報のインデックスを格納 @retval true 該当あり @retval false 該当なし(出力引数には何も設定せず) */ -bool CDlgFuncList::GetFuncInfoIndex( CLayoutInt nCurLine, CLayoutInt nCurCol, int* pIndexOut ) +bool CDlgFuncList::GetFuncInfoIndex( CLayoutInt nCurLine, CLayoutInt nCurCol, int* pnIndexOut ) { const CFuncInfo* pcFuncInfo = NULL; CLayoutInt nFuncLineOld(-1); @@ -4040,7 +4063,7 @@ bool CDlgFuncList::GetFuncInfoIndex( CLayoutInt nCurLine, CLayoutInt nCurCol, in int nFoundIndex = -1; int i; - if( m_pcFuncInfoArr == NULL || pIndexOut == NULL ){ + if( m_pcFuncInfoArr == NULL || pnIndexOut == NULL ){ return false; } @@ -4078,7 +4101,7 @@ bool CDlgFuncList::GetFuncInfoIndex( CLayoutInt nCurLine, CLayoutInt nCurCol, in return false; } - *pIndexOut = nFoundIndex; + *pnIndexOut = nFoundIndex; return true; } diff --git a/sakura_core/outline/CDlgFuncList.h b/sakura_core/outline/CDlgFuncList.h index 9c1ad1bf74..0c2a7d6f11 100644 --- a/sakura_core/outline/CDlgFuncList.h +++ b/sakura_core/outline/CDlgFuncList.h @@ -103,7 +103,6 @@ class CDlgFuncList final : public CDialog void LoadFileTreeSetting( CFileTreeSetting& data, SFilePath& IniDirPath ); void NotifyCaretMovement( CLayoutInt nCurLine, CLayoutInt nCurCol ); void NotifyDocModification(); - bool IsUpToDate() { return m_bFuncInfoArrIsUpToDate; } protected: bool m_bInChangeLayout; @@ -142,8 +141,8 @@ class CDlgFuncList final : public CDialog void SetTreeFile(); // ツリーコントロールの初期化:ファイルツリー void SetListVB( void ); /* リストビューコントロールの初期化:VisualBasic */ // Jul 10, 2003 little YOSHI void SetDocLineFuncList(); - void SetItemSelection( int nSelectItemIndex ); - void SetItemSelectionForTreeView( HWND hwndTree, int nSelectItemIndex ); + void SetItemSelection( int nSelectItemIndex, bool allowExpand ); + void SetItemSelectionForTreeView( HWND hwndTree, int nSelectItemIndex, bool allowExpand ); void SetItemSelectionForListView( HWND hwndList, int nSelectItemIndex ); bool GetFuncInfoIndex( CLayoutInt nCurLine, CLayoutInt nCurCol, int* pIndexOut );