📄 bcgptoolbarcustomizepages.cpp
字号:
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// This is a part of the BCGControlBar Library
// Copyright (C) 1998-2000 BCGSoft Ltd.
// All rights reserved.
//
// This source code can be used, distributed or modified
// only under terms and conditions
// of the accompanying license agreement.
//*******************************************************************************
// CBCGPToolbarCustomizePages.cpp : implementation file
//
#include "stdafx.h"
#ifndef BCG_NO_CUSTOMIZATION
#include <afxpriv.h>
#include "bcgprores.h"
#include "BCGPToolbarCustomize.h"
#include "BCGPToolbarCustomizePages.h"
#include "BCGPToolbar.h"
#include "BCGPToolbarButton.h"
#include "BCGPLocalResource.h"
#include "BCGPPopupMenuBar.h"
#include "ToolbarNameDlg.h"
#include "BCGPCommandManager.h"
#include "BCGPMDIFrameWnd.h"
#include "BCGPOleIPFrameWnd.h"
#include "BCGPFrameWnd.h"
#include "BCGPDropDown.h"
#include "BCGPMiniFrameWnd.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CBCGPCustomizePage, CPropertyPage)
IMPLEMENT_DYNCREATE(CBCGPToolbarsPage, CPropertyPage)
extern CObList gAllToolbars;
/////////////////////////////////////////////////////////////////////////////
// CBCGPCustomizePage property page
CBCGPCustomizePage::CBCGPCustomizePage() :
CPropertyPage(CBCGPCustomizePage::IDD)
{
//{{AFX_DATA_INIT(CBCGPCustomizePage)
m_strButtonDescription = _T("");
//}}AFX_DATA_INIT
}
CBCGPCustomizePage::~CBCGPCustomizePage()
{
}
void CBCGPCustomizePage::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBCGPCustomizePage)
DDX_Control(pDX, IDC_BCGBARRES_CATEGORY, m_wndCategory);
DDX_Control(pDX, IDC_BCGBARRES_USER_TOOLS, m_wndTools);
DDX_Text(pDX, IDC_BCGBARRES_BUTTON_DESCR, m_strButtonDescription);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBCGPCustomizePage, CPropertyPage)
//{{AFX_MSG_MAP(CBCGPCustomizePage)
ON_LBN_SELCHANGE(IDC_BCGBARRES_USER_TOOLS, OnSelchangeUserTools)
ON_LBN_SELCHANGE(IDC_BCGBARRES_CATEGORY, OnSelchangeCategory)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CBCGPCustomizePage::OnSelchangeCategory()
{
UpdateData ();
int iIndex = m_wndCategory.GetCurSel ();
if (iIndex == LB_ERR)
{
ASSERT (FALSE);
return;
}
CWaitCursor wait;
m_wndTools.SetRedraw (FALSE);
m_wndTools.ResetContent ();
//------------------------------------------
// Only "All commands" list shoud be sorted!
//------------------------------------------
CString strCategory;
m_wndCategory.GetText (iIndex, strCategory);
BOOL bAllCommands = (strCategory == m_strAllCategory);
OnChangeSelButton (NULL);
CObList* pCategoryButtonsList =
(CObList*) m_wndCategory.GetItemData (iIndex);
ASSERT_VALID (pCategoryButtonsList);
CBCGPToolbarCustomize* pWndParent = DYNAMIC_DOWNCAST (CBCGPToolbarCustomize, GetParent ());
ASSERT (pWndParent != NULL);
for (POSITION pos = pCategoryButtonsList->GetHeadPosition (); pos != NULL;)
{
CBCGPToolbarButton* pButton = (CBCGPToolbarButton*) pCategoryButtonsList->GetNext (pos);
ASSERT (pButton != NULL);
pButton->m_bUserButton = pButton->m_nID != (UINT) -1 &&
CMD_MGR.GetCmdImage (pButton->m_nID, FALSE) == -1;
CString strText = pButton->m_strText;
if (!pButton->m_strTextCustom.IsEmpty () &&
(bAllCommands || pWndParent->GetCountInCategory (strText, *pCategoryButtonsList) > 1))
{
strText = pButton->m_strTextCustom;
}
int iIndex = -1;
if (bAllCommands)
{
// Insert sortable:
for (int i = 0; iIndex == -1 && i < m_wndTools.GetCount (); i ++)
{
CString strCommand;
m_wndTools.GetText (i, strCommand);
if (strCommand > strText)
{
iIndex = m_wndTools.InsertString (i, strText);
}
}
}
if (iIndex == -1) // Not inserted yet
{
iIndex = m_wndTools.AddString (strText);
}
m_wndTools.SetItemData (iIndex, (DWORD) pButton);
}
m_wndTools.SetRedraw (TRUE);
}
//**************************************************************************************
void CBCGPCustomizePage::OnSelchangeUserTools()
{
int iIndex = m_wndTools.GetCurSel ();
if (iIndex == LB_ERR)
{
OnChangeSelButton (NULL);
}
else
{
OnChangeSelButton ((CBCGPToolbarButton*) m_wndTools.GetItemData (iIndex));
}
}
//**************************************************************************************
BOOL CBCGPCustomizePage::OnInitDialog()
{
CPropertyPage::OnInitDialog();
CBCGPToolbarCustomize* pWndParent = DYNAMIC_DOWNCAST (CBCGPToolbarCustomize, GetParent ());
ASSERT (pWndParent != NULL);
pWndParent->FillCategoriesListBox (m_wndCategory);
m_wndCategory.SetCurSel (0);
OnSelchangeCategory ();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//**********************************************************************************************
void CBCGPCustomizePage::OnChangeSelButton (CBCGPToolbarButton* pSelButton)
{
m_strButtonDescription = _T("");
if (pSelButton != NULL)
{
if (pSelButton->m_nID == 0)
{
m_strButtonDescription = pSelButton->m_strText;
}
else
{
CFrameWnd* pParent = GetParentFrame ();
if (pParent != NULL && pParent->GetSafeHwnd () != NULL)
{
pParent->GetMessageString (pSelButton->m_nID,
m_strButtonDescription);
}
}
}
m_pSelButton = pSelButton;
UpdateData (FALSE);
}
//*************************************************************************************
void CBCGPCustomizePage::SetUserCategory (LPCTSTR lpszCategory)
{
ASSERT (lpszCategory != NULL);
m_strUserCategory = lpszCategory;
}
//*************************************************************************************
void CBCGPCustomizePage::SetAllCategory (LPCTSTR lpszCategory)
{
ASSERT (lpszCategory != NULL);
m_strAllCategory = lpszCategory;
}
/////////////////////////////////////////////////////////////////////////////
// CBCGPToolbarsPage property page
CBCGPToolbarsPage::CBCGPToolbarsPage(CFrameWnd* pParentFrame) :
CPropertyPage(CBCGPToolbarsPage::IDD),
m_bUserDefinedToolbars (FALSE),
m_pParentFrame (pParentFrame)
{
//{{AFX_DATA_INIT(CBCGPToolbarsPage)
m_bTextLabels = FALSE;
//}}AFX_DATA_INIT
m_pSelectedToolbar = NULL;
ASSERT_VALID (m_pParentFrame);
}
CBCGPToolbarsPage::~CBCGPToolbarsPage()
{
}
void CBCGPToolbarsPage::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBCGPToolbarsPage)
DDX_Control(pDX, IDC_BCGBARRES_TEXT_LABELS, m_wndTextLabels);
DDX_Control(pDX, IDC_BCGBARRES_RENAME_TOOLBAR, m_bntRenameToolbar);
DDX_Control(pDX, IDC_BCGBARRES_NEW_TOOLBAR, m_btnNewToolbar);
DDX_Control(pDX, IDC_BCGBARRES_DELETE_TOOLBAR, m_btnDelete);
DDX_Control(pDX, IDC_BCGBARRES_RESET, m_btnReset);
DDX_Control(pDX, IDC_BCGBARRES_TOOLBAR_LIST, m_wndToolbarList);
DDX_Check(pDX, IDC_BCGBARRES_TEXT_LABELS, m_bTextLabels);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBCGPToolbarsPage, CPropertyPage)
//{{AFX_MSG_MAP(CBCGPToolbarsPage)
ON_LBN_SELCHANGE(IDC_BCGBARRES_TOOLBAR_LIST, OnSelchangeToolbarList)
ON_LBN_DBLCLK(IDC_BCGBARRES_TOOLBAR_LIST, OnDblclkToolbarList)
ON_BN_CLICKED(IDC_BCGBARRES_RESET, OnReset)
ON_BN_CLICKED(IDC_BCGBARRES_RESET_ALL, OnResetAll)
ON_BN_CLICKED(IDC_BCGBARRES_DELETE_TOOLBAR, OnDeleteToolbar)
ON_BN_CLICKED(IDC_BCGBARRES_NEW_TOOLBAR, OnNewToolbar)
ON_BN_CLICKED(IDC_BCGBARRES_RENAME_TOOLBAR, OnRenameToolbar)
ON_BN_CLICKED(IDC_BCGBARRES_TEXT_LABELS, OnBcgbarresTextLabels)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CBCGPToolbarsPage::OnInitDialog()
{
CPropertyPage::OnInitDialog();
if (!m_bUserDefinedToolbars)
{
m_btnNewToolbar.EnableWindow (FALSE);
m_btnNewToolbar.ShowWindow (SW_HIDE);
m_btnDelete.ShowWindow (SW_HIDE);
m_bntRenameToolbar.ShowWindow (SW_HIDE);
}
for (POSITION pos = gAllToolbars.GetHeadPosition (); pos != NULL;)
{
CBCGPToolBar* pToolBar = (CBCGPToolBar*) gAllToolbars.GetNext (pos);
ASSERT (pToolBar != NULL);
if (CWnd::FromHandlePermanent (pToolBar->m_hWnd) != NULL)
{
ASSERT_VALID(pToolBar);
//------------------------------
// Don't add dropdown toolbars!
//------------------------------
if (!pToolBar->IsKindOf (RUNTIME_CLASS (CBCGPDropDownToolBar)))
{
//----------------------------------------------------------------------
// Check, if toolbar belongs to this dialog's parent main frame window
//----------------------------------------------------------------------
if (m_pParentFrame->GetTopLevelFrame() ==
pToolBar->GetTopLevelFrame () &&
pToolBar->AllowShowOnList () &&
!pToolBar->m_bMasked)
{
CString strName;
pToolBar->GetWindowText (strName);
if (strName.IsEmpty ())
{
CBCGPLocalResource locaRes;
strName.LoadString (IDS_BCGBARRES_UNTITLED_TOOLBAR);
}
int iIndex = m_wndToolbarList.AddString (strName);
m_wndToolbarList.SetItemData (iIndex, (DWORD) pToolBar);
if (pToolBar->GetStyle () & WS_VISIBLE)
{
m_wndToolbarList.SetCheck (iIndex, 1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -