📄 screenshot.h
字号:
/*
* ScreenShot.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 SCREENSHOT_H
#define SCREENSHOT_H
// INCLUDE FILES
#include <e32std.h>
#include <ImageConversion.h>
#include "ScreenShotData.h"
// CONSTANTS
_LIT(KMimeTypeImage, "Image");
// FORWARD DECLARATIONS
class CFbsBitmap;
class CFakeOverlay;
// CLASS DECLARATIONS
/**
* Observer for CScreenShot class.
*/
class MScreenShotObserver
{
public:
/**
* Called when capturing process has completed, but not saved yet.
*/
virtual void OnCaptureCompleted(TInt aError) = 0;
/**
* Called when save process has completed.
*/
virtual void OnSaveCompleted(TInt aError) = 0;
};
/**
* CScreenShot is the main class of this project. It handles everything needed
* to capture screenshot.
*/
class CScreenShot: public CActive
{
public:
/**
* State machine of this class.
*/
enum TScreenShotStatus
{
EIdle,
EWaiting,
ECapturing,
ESaving,
EConverting
};
public: // Constructor and destructor
/**
* Two-phase constructor.
*/
static CScreenShot* NewL(MScreenShotObserver& aObserver, CCoeEnv& aCoeEnv,
CScreenShotData& aScreenShotData);
/**
* Virtual destructor.
*/
virtual ~CScreenShot();
public: // New methods
/**
* Returns bitmap that stores the result of screen capturing.
*/
const CFbsBitmap* Bitmap() const
{ return iBitmap; }
/**
* Captures the screenshot and store it to iFileName.
*/
void CaptureL();
/**
* Stops the capturing.
*/
void StopCapture();
/**
* Returns true when this class is still capturing or saving screenshot.
*/
TBool IsWaitingTimer()
{ return (EWaiting == iScreenShotStatus); }
/**
* Returns true when this class is doing nothing.
*/
TBool IsIdle()
{ return (EIdle == iScreenShotStatus); }
/**
* Returns the current file name.
*/
const HBufC* CurrentFileName() const
{ return iCurrentFileName; }
/**
* Gets the next file name.
*/
HBufC* GetNextFileNameLC() const;
void SetOverlay(CFakeOverlay* aOverlay)
{ iOverlay = aOverlay; }
private: // Constructors
/**
* Default constructor.
*/
CScreenShot(MScreenShotObserver& aObserver, CCoeEnv& aCoeEnv,
CScreenShotData& aScreenShotData);
/**
* Second phase constructor.
*/
void ConstructL();
private: // from CActive
void RunL();
void DoCancel();
private: // New methods
/**
* Captures screenshot.
*/
void DoCaptureL();
/**
* Saves screenshot to a file.
*/
void DoSaveL();
/**
* Returns MIME type based on the parameter, aImageFormat.
*/
const TDesC8& GetMimeType(CScreenShotData::TImageFormat aImageFormat);
/**
* Creates image frame data baseed on the parameter, aImageFormat.
*/
CFrameImageData* CreateFrameImageDataLC(
CScreenShotData::TImageFormat aImageFormat);
/**
* Fires an event.
*/
void Fire(TScreenShotStatus aStatus);
/**
* Fires capture event after aTime.
*/
void FireCapture(TTimeIntervalMicroSeconds32 aTime);
private: // Data
MScreenShotObserver& iObserver;
CCoeEnv& iCoeEnv;
CScreenShotData& iScreenShotData;
CImageEncoder* iImageEncoder;
CFbsBitmap* iBitmap;
HBufC* iCurrentFileName;
TScreenShotStatus iScreenShotStatus;
RTimer iTimer;
TBool iIsCapturing;
CFakeOverlay* iOverlay; // trick to solve direct screen access
};
#endif // SCREENSHOT_H
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -