- visual_java_src.zip
- BATCH
- CLEAN.BAT
- MAKEBIN.BAT
- MAKEHELP.BAT
- RELEASE.BAT
- RELUSE.BAT
- USE.BAT
- BCGLIB
- CEXPAND.REG
- codetemplates__1.txt
- DISTRIB
- EDITPAD.TIP
- USRIMGS.BMP
- EDITPAD.DSP
- EDITPAD.DSW
- EDTLIB
- file0
- README.TXT
- VisualJava
- visual_java_demo.zip
- bcgcb453d.dll
- bcgcb453d.exp
- bcgcb453d.lib
- edtlibd.dll
- edtlibd.exp
- edtlibd.lib
- USRIMGS.BMP
- VisualJava.exe
- visual_java_demo1.zip
- bcgcb453d.dll
- bcgcb453d.exp
- bcgcb453d.lib
- edtlibd.dll
- edtlibd.exp
- edtlibd.lib
- USRIMGS.BMP
- VisualJava.exe
|
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// This source code is a part of BCGControlBar library.
// You may use, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES on your own risk.
//
// Stas Levin <stas@iet.co.il>
//*******************************************************************************
// CmdUsageCount.cpp: implementation of the CCmdUsageCount class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "bcgcontrolbar.h"
#include "CmdUsageCount.h"
#include "BCGToolBar.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
UINT CCmdUsageCount::m_nStartCount = 50;
UINT CCmdUsageCount::m_nMinUsagePercentage = 5;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CCmdUsageCount::CCmdUsageCount() :
m_nTotalUsage (0)
{
}
//*******************************************************************************
CCmdUsageCount::~CCmdUsageCount()
{
}
//*******************************************************************************
void CCmdUsageCount::Serialize (CArchive& ar)
{
if (ar.IsLoading ())
{
ar >> m_nTotalUsage;
}
else
{
ar << m_nTotalUsage;
}
m_CmdUsage.Serialize (ar);
}
//*******************************************************************************
void CCmdUsageCount::AddCmd (UINT uiCmd)
{
if (CBCGToolBar::IsCustomizeMode ())
{
return;
}
if ((uiCmd == 0 || uiCmd == (UINT) -1) || // Ignore submenus and separators,
CBCGToolBar::IsBasicCommand (uiCmd) || // basic commands and
IsStandardCommand (uiCmd)) // standard commands
{
return;
}
UINT uiCount = 0;
if (!m_CmdUsage.Lookup (uiCmd, uiCount))
{
uiCount = 0;
}
m_CmdUsage.SetAt (uiCmd, ++uiCount);
m_nTotalUsage ++;
}
//*******************************************************************************
void CCmdUsageCount::Reset ()
{
m_CmdUsage.RemoveAll ();
m_nTotalUsage = 0;
}
//*******************************************************************************
UINT CCmdUsageCount::GetCount (UINT uiCmd) const
{
UINT uiCount = 0;
m_CmdUsage.Lookup (uiCmd, uiCount);
return uiCount;
}
//*******************************************************************************
BOOL CCmdUsageCount::IsFreqeuntlyUsedCmd (UINT uiCmd) const
{
//-----------------------------------------------------
// I say, that the specific command is frequently used,
// if the command usage percentage is more than 20%
//-----------------------------------------------------
if (m_nTotalUsage == 0)
{
return FALSE;
}
UINT uiCount = GetCount (uiCmd);
UINT uiPercentage = uiCount * 100 / m_nTotalUsage;
return uiPercentage > m_nMinUsagePercentage;
}
//*******************************************************************************
BOOL CCmdUsageCount::HasEnouthInformation () const
{
return m_nTotalUsage > m_nStartCount;
}
//*******************************************************************************
BOOL CCmdUsageCount::SetOptions (UINT nStartCount, UINT nMinUsagePercentage)
{
if (nMinUsagePercentage >= 100)
{
ASSERT (FALSE);
return FALSE;
}
m_nStartCount = nStartCount;
m_nMinUsagePercentage = nMinUsagePercentage;
return TRUE;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.