bencoolensettingslistbox.cpp

来自「Symbian_OS_code 初学Symbian_OS学习代码, 屏幕截图软」· C++ 代码 · 共 170 行

CPP
170
字号
/*
 * BencoolenSettingsListBox.cpp
 *
 * Copyright 2005 - 2008, Antony Pranata
 * http://www.antonypranata.com
 *
 * Project: Screenshot for Symbian OS.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

// INCLUDE FILES
#include <symbianvariant.h>

#include <aknsettingitemlist.h>
#if (__S60__ >= 300)
#include <caknmemoryselectionsettingitem.h> 
#endif

#include "BencoolenSettingsListbox.h"
#include "ScreenShotData.h"
#include "Bencoolen.hrh"

// MEMBER FUNCTIONS

// --------------------------------------------------------------------------
// Updates descripter array for list box.
// --------------------------------------------------------------------------
CAknSettingItem* CBencoolenSettingsListBox::CreateSettingItemL(TInt aIdentifier)
	{
	CAknSettingItem* settingItem = NULL;

	switch (aIdentifier)
		{
		case EBencoolenDlgMode:
			{
			settingItem = new (ELeave) CAknEnumeratedTextPopupSettingItem(
				aIdentifier, (TInt&) iScreenShotData->Mode());
			break;
			}

		case EBencoolenDlgShortcut:
			{
			settingItem = new (ELeave) CAknEnumeratedTextPopupSettingItem(
				aIdentifier, (TInt&) iScreenShotData->Shortcut());
			break;
			}

		case EBencoolenDlgImageFormat:
			settingItem = new (ELeave) CAknEnumeratedTextPopupSettingItem(
				aIdentifier, (TInt&) iScreenShotData->ImageFormat());
			break;

#if (__S60__ < 300)

		case EBencoolenDlgLocation:
			settingItem = new (ELeave) CAknBinaryPopupSettingItem(
				aIdentifier, (TInt&) iScreenShotData->MemoryLocation());
			break;
			
#else
			
		case EBencoolenDlgLocation:
			settingItem = new (ELeave) CAknMemorySelectionSettingItem(
				aIdentifier,
				(CAknMemorySelectionDialog::TMemory&) iScreenShotData->MemoryLocation());
			break;
			
#endif

		case EBencoolenDlgFileName:
			settingItem = new (ELeave) CAknTextSettingItem(aIdentifier, iFileName);
			break;

		case EBencoolenDlgDirectory:
			settingItem = new (ELeave) CAknTextSettingItem(aIdentifier, iDirectory);
			break;

		case EBencoolenDlgDelay:
			settingItem = new (ELeave) CAknEnumeratedTextPopupSettingItem(
				aIdentifier, (TInt&) iScreenShotData->Delay());
			break;

		default:
			User::Invariant();
			break;
		}
	return settingItem;
	}

// --------------------------------------------------------------------------
// Sets list item data.
// --------------------------------------------------------------------------
void CBencoolenSettingsListBox::SetData(CScreenShotData* aScreenShotData)
	{
	iScreenShotData = aScreenShotData;

	if ((iScreenShotData) && (iScreenShotData->FileName().Length() > 0))
		{
		iFileName.Copy(iScreenShotData->FileName());
		}

	if ((iScreenShotData) && (iScreenShotData->Directory().Length() > 0))
		{
		// We have to remove the last character, which is backslash.
		iDirectory.Copy(iScreenShotData->Directory());
		iDirectory.Delete(iDirectory.Length() - 1, 1);
		}
	}

// --------------------------------------------------------------------------
// This has to be called when the list box is deactivated. The reason is
// because we have to update CScreenShotData with the value entered by the
// users (by calling StoreSettingsL()). And we have to set the file name
// and directory name too.
// --------------------------------------------------------------------------
void CBencoolenSettingsListBox::UpdateData()
	{
	TRAP_IGNORE(
		StoreSettingsL();
		iScreenShotData->SetFileNameL(iFileName);
		iScreenShotData->SetDirectoryL(iDirectory);
		);
	}

#if (__S60__ >= 203)

// --------------------------------------------------------------------------
// Called when the screen size/resolution is changed.
// --------------------------------------------------------------------------
void CBencoolenSettingsListBox::HandleResourceChange(TInt aType)
	{
	CAknSettingItemList::HandleResourceChange(aType);

	// ADDED FOR SCALABLE UI SUPPORT
	// *****************************
	if ( aType==KEikDynamicLayoutVariantSwitch )
		{
		TRect rect;
		AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
		SetRect(rect);
		}
	}

#endif

// --------------------------------------------------------------------------
// Called by framework when the view size is changed.
// --------------------------------------------------------------------------
void CBencoolenSettingsListBox::SizeChanged()
	{
	if (ListBox())
		{
		ListBox()->SetRect(Rect());
		}
	}

// End of File

⌨️ 快捷键说明

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