screenshotdata.h

来自「Symbian_OS_code 初学Symbian_OS学习代码, 屏幕截图软」· C头文件 代码 · 共 321 行

H
321
字号
/*
 * ScreenShotData.h
 *
 * 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/>.
 */

#ifndef SCREENSHOTDATA_H
#define SCREENSHOTDATA_H

// INCLUDES
#include <e32base.h>
#include <s32strm.h>

#if (__S60__ >= 300)
#include <caknmemoryselectiondialog.h> // used to select memory
#endif

#include "Bencoolen.hrh" // Needed to get KTextMaxLength.
						 // Can be assigned to KMaxFileName too.

// CONSTANTS
_LIT(KDefaultFileName,	"Screenshot");
#ifdef __UIQ__
_LIT(KDefaultDirectory,	"Unfiled\\");
#else
_LIT(KDefaultDirectory,	"Screenshots\\");
#endif

// CLASS DECLARATION

/**
 * CScreenShotData stores user's preferences of screen capturing.
 * There are several options can be set here, i.e.:
 *	- Capturing mode: single shot or interval.
 *	- Shortcut.
 *	- Format: JPEG, PNG, BMP, MBM.
 *	- Location: phone memory or memory card.
 *	- File name.
 *	- Directory name.
 *	- Delay of first shot.
 */
class CScreenShotData: public CBase
	{
public: // enum
	enum TMode
		{
		// These are for S60 only.
		EModeOneShot = 1,
		EMode2Seconds = 3, // There is no 2 to maintain compatibility
		                   // with previous version.
		EMode5Seconds,
		EMode10Seconds,
		EModeEnd
		};

#ifdef __S60__
	enum TShortcut
		{
		// These are for S60 only.
		EShortcutConfirm = 1,
		EShortcutStar,
		EShortcutHash,
        EShortcutCamera,
		EShortcutC,
		EShortcutHashStar,
		EShortcutEnd,
		
		// Some shortcuts below were used for testing only.
		// That's why they are declared after EShortcutEnd
		EShortcutHash1,
		EShortcutHash7
        };
#else
	enum TShortcut
		{
		// And these shortcuts are for UIQ only.
		EShortcutCamera = 1,
		EShortcutBrowser,
		EShortcutEnd
		};
#endif // __S60__

#if (__S60__ >= 200) // S60 2.0 supports PNG
	enum TImageFormat
		{
		EFormatJpgHigh = 1,
		EFormatJpgNormal,
		EFormatJpgLow,
		EFormatPngDefault,
		EFormatPngSize,
		EFormatPngSpeed,
		EFormatBmp,
		EFormatBmp8bpp,
		EFormatMbm,
		EFormatMbm8bpp,
		EFormatGif,
		EFormatEnd
		};
#else
	enum TImageFormat
		{
		EFormatJpgHigh = 1,
		EFormatJpgNormal,
		EFormatJpgLow,
		EFormatBmp,
		EFormatBmp8bpp,
		EFormatMbm,
		EFormatMbm8bpp,
		EFormatPngDefault,
		EFormatPngSize,
		EFormatPngSpeed,
		EFormatGif,
		EFormatEnd
		};   
#endif // (__S60__ >= 200)

#if (__S60__ >= 300)
	// Although in the new version, there is CAknMemorySelectionDialog,
	// I want to maintain compatibility with previous versions.
	// That's why I still use TMemoryLocation; the values of its enum
	// point to CAknMemorySelectionDialog.
	enum TMemoryLocation
		{
		EPhoneMemory = CAknMemorySelectionDialog::EPhoneMemory,
		EMmcMemory = CAknMemorySelectionDialog::EMemoryCard,
		EMemoryEnd
		};	
#else
	// The memory location is only available for S60 platform.
	// In UIQ, we use categories to store the memory location
	enum TMemoryLocation
		{
		EPhoneMemory = 0,
		EMmcMemory,
		EMemoryEnd
		};
#endif // (__S60__ >= 300)

	// We can have delay when taking screenshot. So after the users
	// press the shortcut, the screenshot is not taken right away,
	// but after a few seconds.
	enum TDelay
		{
		ENoDelay = 1,
		EOneSecond,
		EFiveSeconds,
		ETenSeconds,
		EThirtySeconds,
		EDelayEnd
		};

public: // Constructor and destructor
	CScreenShotData();
	~CScreenShotData();

public: //  New methods.
	/**
	 * Gets the image format.
	 */
	const TImageFormat ImageFormat() const
	{ return iImageFormat; }

	/**
	 * Gets the image format.
	 */
	TImageFormat& ImageFormat()
	{ return iImageFormat; }

	/**
	 * Sets the image format
	 */
	void SetImageFormat(TImageFormat aImageFormat)
	{ iImageFormat = aImageFormat; }

	/**
	 * Gets the capturing mode, i.e. one shot only or interval (1, 2, 5, 10 seconds).
	 */
	const TMode Mode() const
	{ return iMode; }

	/**
	 * Gets the capturing mode, i.e. one shot only or interval (1, 2, 5, 10 seconds).
	 */
	TMode& Mode()
	{ return iMode; }

	/**
	 * Sets the capturing mode.
	 */
	void SetMode(TMode aMode)
	{ iMode = aMode; }

	/**
	 * Gets the shortcut.
	 */
	const TShortcut Shortcut() const
	{ return iShortcut; }

	/**
	 * Gets the shortcut.
	 */
	TShortcut& Shortcut()
	{ return iShortcut; }

	/**
	 * Sets the shortcut
	 */
	void SetShortcut(TShortcut aShortcut)
	{ iShortcut = aShortcut; }

	/**
	 * Gets the memory location.
	 */
	const TMemoryLocation MemoryLocation() const
	{ return iMemoryLocation; }

	/**
	 * Gets the memory location.
	 */
	TMemoryLocation& MemoryLocation()
	{ return iMemoryLocation; }

	/**
	 * Sets the memory location.
	 */
	void SetMemoryLocation(TMemoryLocation aMemoryLocation)
	{ iMemoryLocation = aMemoryLocation; }

	/**
	 * Gets the default directory.
	 */
	TPtrC Directory() const;
	void SetDirectoryL(const TDesC& aDirectory);

	/**
	 * Gets the prefix of file name.
	 * Note that the file name it stored in the formata of [prefix][number].[extension].
	 * For example of the prefix is "screenshot" and the extension is "png", the 
	 * file name would be screenshot0001.png, screenshot0002.png, etc.
	 */
	TPtrC FileName() const;

	/**
	 * Sets the prefix of file name.
	 */
	void SetFileNameL(const TDesC& aFileName);

	/**
	 * Gets the delay of first capturing.
	 */
	const TDelay Delay() const
	{ return iDelay; }

	/**
	 * Gets the delay of first capturing.
	 */
	TDelay& Delay()
	{ return iDelay; }

	/**
	 * Sets the delay of first capturing.
	 */
	void SetDelay(TDelay aDelay)
	{ iDelay = aDelay; }

	/**
	 * Gets the current index used for file naming.
	 */
	TInt StartingIndexFileName()
	{ return iStartingIndexFileName; }

	/**
	 * Sets the current index used for file naming.
	 */
	void SetStartingIndexFileName(TInt aStartingIndexFileName);

	/**
	 * Writes this object to the writer stream.
	 */
	void ExternalizeL(RWriteStream& aStream) const;

	/**
	 * Reads stream to this object.
	 */
	void InternalizeL(RReadStream& aStream);

private: // Data
	TMode			iMode;
	TShortcut		iShortcut;
	TImageFormat	 iImageFormat;
	TMemoryLocation  iMemoryLocation;
	HBufC*		   iDirectory;

	// iFileName must It muse be ended with backslash; otherwise
	// it might corrupt the file name.
	HBufC*		   iFileName;
	TDelay		   iDelay;
	TInt			 iStartingIndexFileName;

	};

#endif // SCREENSHOTDATA_H

// End of File

⌨️ 快捷键说明

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