⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cdlgfunclist.cpp

📁 日本的开源编辑器源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
			::SetFocus( ::GetDlgItem( m_hWnd, IDC_TREE1 ) );
		}else{
			::SetFocus( ::GetDlgItem( m_hWnd, IDC_LIST1 ) );
		}
		return TRUE;
	}
	/* 基底クラスメンバ */
	return CDialog::OnBnClicked( wID );
}

BOOL CDlgFuncList::OnNotify( WPARAM wParam, LPARAM lParam )
{
//	int				idCtrl;
	LPNMHDR			pnmh;
	NM_LISTVIEW*	pnlv;
	HWND			hwndList;
	HWND			hwndTree;
	NM_TREEVIEW*	pnmtv;
//	int				nLineTo;

//	idCtrl = (int) wParam;
	pnmh = (LPNMHDR) lParam;
	pnlv = (NM_LISTVIEW*)lParam;

	hwndList = ::GetDlgItem( m_hWnd, IDC_LIST1 );
	hwndTree = ::GetDlgItem( m_hWnd, IDC_TREE1 );

	if( hwndTree == pnmh->hwndFrom ){
		pnmtv = (NM_TREEVIEW *) lParam;
//		switch( pnmh->code ){
//		case TVN_BEGINDRAG:
//		case TVN_BEGINLABELEDIT:
//		case TVN_BEGINRDRAG:
//		case TVN_DELETEITEM:
//		case TVN_ENDLABELEDIT:
//		case TVN_GETDISPINFO:
//		case TVN_ITEMEXPANDED:
//		case TVN_ITEMEXPANDING:
//		case TVN_KEYDOWN:
//		case TVN_SELCHANGED:
//		case TVN_SELCHANGING:
//		case TVN_SETDISPINFO:
//			break;
//		default:
			switch( pnmtv->hdr.code ){
			case NM_DBLCLK:
				// 2002.02.16 hor Treeのダブルクリックでフォーカス移動できるように 3/4
				OnJump();
				m_bWaitTreeProcess=true;
				return TRUE;
				//return OnJump();
			case TVN_KEYDOWN:
				Key2Command( ((LV_KEYDOWN *)lParam)->wVKey );
				return TRUE;
//			case NM_CLICK:
			case NM_KILLFOCUS:
				// 2002.02.16 hor Treeのダブルクリックでフォーカス移動できるように 4/4
				if(m_bWaitTreeProcess){
					if(m_pShareData->m_Common.m_bFunclistSetFocusOnJump){
						::SetFocus(m_hwndParent);
					}
					m_bWaitTreeProcess=false;
				}
				return TRUE;
//			case NM_OUTOFMEMORY:
//			case NM_RCLICK:
//			case NM_RDBLCLK:
//			case NM_RETURN:
//			case NM_SETFOCUS:
//			default:
//				break;
			}
//			break;
//		}
	}else
	if( hwndList == pnmh->hwndFrom ){
		switch( pnmh->code ){
		case LVN_COLUMNCLICK:
//				MYTRACE( "LVN_COLUMNCLICK\n" );
			m_nSortCol =  pnlv->iSubItem;
			//	Apr. 23, 2005 genta 関数として独立させた
			SortListView( hwndList, m_nSortCol );
			return TRUE;
		case NM_DBLCLK:
			return OnJump();
		case LVN_KEYDOWN:
			Key2Command( ((LV_KEYDOWN *)lParam)->wVKey );
			return TRUE;
		}
	}
	return FALSE;
}
/*!
	指定されたカラムでリストビューをソートする.
	同時にヘッダも書き換える.

	ソート後はフォーカスが画面内に現れるように表示位置を調整する.

	@par 表示位置調整の小技
	EnsureVisibleの結果は,上スクロールの場合は上端に,下スクロールの場合は
	下端に目的の項目が現れる.端から少し離したい場合はオフセットを与える必要が
	あるが,スクロール方向がわからないと±がわからない
	そのため最初に一番下に一回スクロールさせることでEnsureVisibleでは
	かならず上スクロールになるようにすることで,ソート後の表示位置を
	固定する

	@param[in] hwndList	リストビューのウィンドウハンドル
	@param[in] sortcol	ソートするカラム番号(0-2)

	@date 2005.04.23 genta 関数として独立させた
	@date 2005.04.29 genta ソート後の表示位置調整
*/
void CDlgFuncList::SortListView(HWND hwndList, int sortcol)
{
	LV_COLUMN		col;

	//	Apr. 23, 2005 genta 行番号を左端へ
	if( sortcol == 1 ){
		col.mask = LVCF_TEXT;
	// From Here 2001.12.03 hor
	//	col.pszText = "関数名 *";
		if(OUTLINE_BOOKMARK == m_nListType){
			col.pszText = "テキスト *";
		}else{
			col.pszText = "関数名 *";
		}
	// To Here 2001.12.03 hor
		col.iSubItem = 0;
		ListView_SetColumn( hwndList, 1, &col );
		col.mask = LVCF_TEXT;
		col.pszText = "行";
		col.iSubItem = 0;
		ListView_SetColumn( hwndList, 0, &col );
	// From Here 2001.12.07 hor
		col.mask = LVCF_TEXT;
		col.pszText = "";
		col.iSubItem = 0;
		ListView_SetColumn( hwndList, 2, &col );
	// To Here 2001.12.07 hor
		ListView_SortItems( hwndList, _CompareFunc_, (LPARAM)this );
	}else
	if( sortcol == 0 ){
		col.mask = LVCF_TEXT;
	// From Here 2001.12.03 hor
	//	col.pszText = "関数名";
		if(OUTLINE_BOOKMARK == m_nListType){
			col.pszText = "テキスト";
		}else{
			col.pszText = "関数名";
		}
	// To Here 2001.12.03 hor
		col.iSubItem = 0;
		ListView_SetColumn( hwndList, 1, &col );
		col.mask = LVCF_TEXT;
		col.pszText = "行 *";
		col.iSubItem = 0;
		ListView_SetColumn( hwndList, 0, &col );
	// From Here 2001.12.07 hor
		col.mask = LVCF_TEXT;
		col.pszText = "";
		col.iSubItem = 0;
		ListView_SetColumn( hwndList, 2, &col );
	// To Here 2001.12.03 hor
		ListView_SortItems( hwndList, _CompareFunc_, (LPARAM)this );
	// From Here 2001.12.07 hor
	}else
	if( sortcol == 2 ){
		col.mask = LVCF_TEXT;
		if(OUTLINE_BOOKMARK == m_nListType){
			col.pszText = "テキスト";
		}else{
			col.pszText = "関数名";
		}
		col.iSubItem = 0;
		ListView_SetColumn( hwndList, 1, &col );
		col.mask = LVCF_TEXT;
		col.pszText = "行";
		col.iSubItem = 0;
		ListView_SetColumn( hwndList, 0, &col );
		col.mask = LVCF_TEXT;
		col.pszText = "*";
		col.iSubItem = 0;
		ListView_SetColumn( hwndList, 2, &col );
		ListView_SortItems( hwndList, _CompareFunc_, (LPARAM)this );
	// To Here 2001.12.07 hor
	}
	//	2005.04.23 zenryaku 選択された項目が見えるようにする

	//	Apr. 29, 2005 genta 一旦一番下にスクロールさせる
	ListView_EnsureVisible( hwndList,
		ListView_GetItemCount(hwndList) - 1,
		FALSE );
	ListView_EnsureVisible( hwndList,
		ListView_GetNextItem(hwndList, -1, LVNI_FOCUSED) - 2,
		FALSE );
}

/*!	ウィンドウサイズが変更された

	@date 2003.06.22 Moca コードの整理(コントロールの処理方法をテーブルに持たせる)
	@date 2003.08.16 genta 配列はstaticに(無駄な初期化を行わないため)
*/
BOOL CDlgFuncList::OnSize( WPARAM wParam, LPARAM lParam )
{
	/* 基底クラスメンバ */
	CDialog::OnSize( wParam, lParam );

	static const int Controls[][2] = {
		{IDC_CHECK_bFunclistSetFocusOnJump, 1},
		{IDC_CHECK_bMarkUpBlankLineEnable , 1},
		{IDC_CHECK_bAutoCloseDlgFuncList, 1},
		{IDC_BUTTON_COPY, 2},
		{IDOK, 2},
		{IDCANCEL, 2},
		{IDC_BUTTON_HELP, 2},
		{IDC_LIST1, 3},
		{IDC_TREE1, 3},
	};
	int		nControls = sizeof( Controls ) / sizeof( Controls[0] );
//	int		fwSizeType;
	int		nWidth;
	int		nHeight;
	int		i;
	int		nHeightCheckBox;
	int		nHeightButton;
	const int	nHeightMargin = 3;
	RECT	rc;
	HWND	hwndCtrl;
	POINT	po;

	nWidth = LOWORD(lParam);	// width of client area
	nHeight = HIWORD(lParam);	// height of client area


	::GetWindowRect( ::GetDlgItem( m_hWnd, IDC_CHECK_bAutoCloseDlgFuncList ), &rc );
	nHeightCheckBox = rc.bottom -  rc.top;
	::GetWindowRect( ::GetDlgItem( m_hWnd, IDOK ), &rc );	
	nHeightButton = rc.bottom - rc.top;

	for ( i = 0; i < nControls; ++i ){
		hwndCtrl = ::GetDlgItem( m_hWnd, Controls[i][0] );
		::GetWindowRect( hwndCtrl, &rc );
		po.x = rc.left;
		po.y = rc.top;
		::ScreenToClient( m_hWnd, &po );
		rc.left = po.x;
		rc.top  = po.y;
		po.x = rc.right;
		po.y = rc.bottom;
		::ScreenToClient( m_hWnd, &po );
		rc.right = po.x;
		rc.bottom  = po.y;
		//	2003.06.22 Moca テーブル上の種別によって処理方法を変える
		switch( Controls[i][1] ){
		case 1:
			::SetWindowPos( hwndCtrl, NULL, 
				rc.left,
				nHeight - nHeightCheckBox - nHeightMargin,
				0, 0, SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER );
			break;
// 2002/11/1 fozen ここから
		case 2:
			::SetWindowPos( hwndCtrl, NULL,
				rc.left,
				nHeight - nHeightCheckBox - nHeightButton - nHeightMargin * 2,
				0, 0, SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER );
			break;
		case 3:
			::SetWindowPos( hwndCtrl, NULL, 0, 0, 
				nWidth - 2 * rc.left,
				nHeight - rc.top - nHeightCheckBox - nHeightButton - 3 * nHeightMargin,
				SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER );
			break;
		}
// 2002/11/1 fozen ここまで
		::InvalidateRect( hwndCtrl, NULL, TRUE );
	}
	return TRUE;
}
int CALLBACK Compare_by_ItemData(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
	if( lParam1< lParam2 )
		return -1;
	if( lParam1 > lParam2 )
		return 1;
	else
		return 0;
}
BOOL CDlgFuncList::OnCbnSelChange( HWND hwndCtl, int wID )
{
	int nSelect = ::SendMessage(hwndCtl,CB_GETCURSEL, 0, 0L);
	switch(wID)
	{
	case IDC_COMBO_nSortType:
		if( m_nSortType != nSelect )
		{
			m_nSortType = nSelect;
			SortTree(::GetDlgItem( m_hWnd , IDC_TREE1),TVI_ROOT);
		}
		return TRUE;
	};
	return FALSE;

}
void  CDlgFuncList::SortTree(HWND hWndTree,HTREEITEM htiParent)
{
	if( m_nSortType == 1 )
		TreeView_SortChildren(hWndTree,htiParent,TRUE);
	else
	{
		TVSORTCB sort;
		sort.hParent =  htiParent;
		sort.lpfnCompare = Compare_by_ItemData;
		sort.lParam = 0;
		TreeView_SortChildrenCB(hWndTree , &sort , TRUE);
	}
	for(HTREEITEM htiItem = TreeView_GetChild( hWndTree, htiParent ); NULL != htiItem ; htiItem = TreeView_GetNextSibling( hWndTree, htiItem ))
		SortTree(hWndTree,htiItem);
}



BOOL CDlgFuncList::OnJump( bool bCheckAutoClose )	//2002.02.08 hor 引数追加
{
	int				nLineTo;
	/* ダイアログデータの取得 */
	if( 0 < ( nLineTo = GetData() ) ){
		if( m_bModal ){		/* モーダル ダイアログか */
			::EndDialog( m_hWnd, nLineTo );
		}else{
			/* カーソルを移動させる */
			POINT	poCaret;
			poCaret.x = 0;
			poCaret.y = nLineTo - 1;
			memcpy( m_pShareData->m_szWork, (void*)&poCaret, sizeof(poCaret) );
			::SendMessage( ::GetParent( ::GetParent( m_hwndParent ) ), MYWM_SETCARETPOS, 0, 0 );
			if( bCheckAutoClose ){
				/* アウトライン ダイアログを自動的に閉じる */
				if( m_pShareData->m_Common.m_bAutoCloseDlgFuncList ){
					::DestroyWindow( m_hWnd );
				}else
				if( m_pShareData->m_Common.m_bFunclistSetFocusOnJump ){
					::SetFocus( m_hwndParent );
				}
			}
		}
	}
	return TRUE;
}


//@@@ 2002.01.18 add start
LPVOID CDlgFuncList::GetHelpIdTable(void)
{
	return (LPVOID)p_helpids;
}
//@@@ 2002.01.18 add end


/*!	キー操作をコマンドに変換するヘルパー関数
	
*/
void CDlgFuncList::Key2Command(WORD KeyCode)
{
	CEditView*	pcEditView;
	int nIdx, nFuncCode;
// novice 2004/10/10
	/* Shift,Ctrl,Altキーが押されていたか */
	nIdx = getCtrlKeyState();
	nFuncCode=CKeyBind::GetFuncCode(
			((WORD)(((BYTE)(KeyCode)) | ((WORD)((BYTE)(nIdx))) << 8)),
			m_pShareData->m_nKeyNameArrNum,
			m_pShareData->m_pKeyNameArr
	);
	switch( nFuncCode ){
	case F_REDRAW:
		nFuncCode=

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -