📄 chxavcheckboxlistsettingitem.cpp
字号:
/************************************************************************
* chxavcheckboxlistsettingitem.cpp
* ----------------------
*
* Synopsis:
*
* settings page item comprising checkbox list for configuring mask value
*
* Target:
* Symbian OS
*
*
* (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
*
************************************************************************/
// Symbian includes...
#include <aknlists.h>
#include <aknutils.h>
#include <aknselectionlist.h>
// Includes from this project...
#include "chxavutil.h"
#include "chxavmisc.h"
#include "hxsym_debug.h"
#include "chxavcheckboxlistsettingitem.h"
#define D_TCPSOCKET 0x10000000
#define D_RESOLVER 0x10000000
#define D_AP_MANAGER 0x20000000
namespace
{
static const CHXAvUtil::KeyValEntry<TUint, const TCHAR*> g_maskTable[] =
{
// defined by our ui
Emit_(SYMP_INFO),
Emit_(SYMP_WSEVENTS),
Emit_(SYMP_FILE),
Emit_(SYMP_FILE_UI),
Emit_(SYMP_DIALOGS),
// defined in Helix core (in debug module and some private modules)
Emit_(D_ERROR),
Emit_(D_INFO),
Emit_(D_ALLOC),
Emit_(D_TCPSOCKET),
Emit_(D_AP_MANAGER)
};
} // locals
////////////////////////////////////////////
//
CHXAvCheckBoxListSettingItem::CHXAvCheckBoxListSettingItem(TInt aIdentifier, TUint& mask)
: CAknSettingItem(aIdentifier)
, m_mask(mask)
{
}
////////////////////////////////////////////
//
CHXAvCheckBoxListSettingItem::~CHXAvCheckBoxListSettingItem()
{
CleanupList();
}
////////////////////////////////////////////
//
void CHXAvCheckBoxListSettingItem::CleanupList()
{
if (m_pSelectionList)
{
// free items
m_pSelectionList->ResetAndDestroy();
HX_DELETE(m_pSelectionList);
}
}
const TDesC& CHXAvCheckBoxListSettingItem::SettingTextL()
{
_LIT(KHexFormat, "0x%X");
m_textBuf.Format(KHexFormat, m_mask);
return m_textBuf;
}
void CHXAvCheckBoxListSettingItem::StoreL()
{
// note: selection list will be null if page is not currently displayed
if( m_pSelectionList )
{
m_mask = CalculateMask();
}
CAknSettingItem::StoreL();
}
////////////////////////////////////////////
//
TUint CHXAvCheckBoxListSettingItem::CalculateMask()
{
HX_ASSERT(m_pSelectionList != 0);
TUint mask = 0;
TUint count = m_pSelectionList->Count();
for(TUint idx = 0; idx < count; ++idx)
{
CSelectableItem* pItem = m_pSelectionList->At(idx);
if( pItem->SelectionStatus() )
{
mask |= g_maskTable[idx].key;
}
}
return mask;
}
////////////////////////////////////////////
//
CSelectionItemList* CHXAvCheckBoxListSettingItem::CreateListL()
{
const TInt k_Granularity = 4; // arbitrary
CSelectionItemList* pList = new (ELeave) CSelectionItemList(k_Granularity);
AUTO_PUSH_POP(pList); // out
TUint count = ARRAY_COUNT(g_maskTable);
for (TUint idx = 0; idx < count; ++idx)
{
TUint maskVal = g_maskTable[idx].key;
bool bIsOn = ((m_mask & maskVal) == maskVal);
TPtrC maskText = reinterpret_cast<const TText*>((g_maskTable[idx].val));
CSelectableItem* pItem = new(ELeave)CSelectableItem(maskText, bIsOn);
AUTO_PUSH_POP(pItem);
pItem->ConstructL();
// transfer item ownership to list
pList->AppendL(pItem);
}
return pList;
}
////////////////////////////////////////////
// show the settings page associated with this settings item
//
void CHXAvCheckBoxListSettingItem::EditItemL( TBool /* aCalledFromMenu */)
{
CleanupList();
m_pSelectionList = CreateListL();
CHXAvCheckBoxListSettingPage* pDlg
= new( ELeave )CHXAvCheckBoxListSettingPage(SettingPageResourceId(), m_pSelectionList);
// save cleanupstack init until LD
{
AUTO_PUSH_POP(pDlg);
SetSettingPage(pDlg);
pDlg->SetSettingPageObserver(this);
SetUpStandardSettingPageL();
}
pDlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged);
SetSettingPage(0);
}
void CHXAvCheckBoxListSettingItem::HandleSettingPageEventL (CAknSettingPage* /*pSettingPage*/,
TAknSettingPageEvent eventType)
{
DPRINTF(SYMP_INFO, ("HandleSettingPageEventL(): %d\n", eventType));
switch(eventType)
{
case MAknSettingPageObserver::EEventSettingCancelled:
CleanupList();
break;
case MAknSettingPageObserver::EEventSettingOked:
StoreL();
// list box text (displayed in setting item) must be updated
UpdateListBoxTextL();
break;
default:
// nothing
break;
}
//CAknSettingItem::HandleSettingPageEventL(pSettingPage, eventType);
}
////////////////////////////////////////////////
// ctor
CHXAvCheckBoxListSettingPage::CHXAvCheckBoxListSettingPage(TInt idRes, CSelectionItemList* pItemArray)
: CAknCheckBoxSettingPage( idRes, pItemArray )
{
}
////////////////////////////////////////////////
//
void CHXAvCheckBoxListSettingPage::ProcessCommandL(TInt aCommandId)
{
DPRINTF(SYMP_INFO, ("process command %d\n", aCommandId));
switch (aCommandId)
{
case EAknSoftkeySelect:
HideMenu();
SelectCurrentItemL();
break;
default:
CAknCheckBoxSettingPage::ProcessCommandL(aCommandId);
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -