readbarcappview.h
来自「barcode readers [ from Image]」· C头文件 代码 · 共 285 行
H
285 行
/*
ReadBarCAppView. View control for ReadBarC application.
This code is a derivative work of the SnapShot example
application distributed with the Symbian 6.0 SDK.
Copyright (C) 2006 Jon A. Webb
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 2
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __READBARCAPPVIEW_H__
#define __READBARCAPPVIEW_H__
#include <coecntrl.h>
#include <CameraServ.h>
#include "Array.h"
#include "CameraManager.h"
#include "Image.h"
class CFindBarcode;
class CReadBarcode;
enum TShowState {
ENotReady,
EViewFinder,
ESnappedImage,
ESnappingImage
};
/*!
@class MMyCameraObserver
@discussion Abstract class that allows the camera interface to
update the view as images are captured and so on.
*/
class MMyCameraObserver
{
public:
MMyCameraObserver() {};
virtual ~MMyCameraObserver() {};
public:
/*!
@function DrawImage
@discussion Show the current image to the user. Used by
the viewfinder.
@param aImage the image.
*/
virtual void DrawImage(CFbsBitmap* aImage) const = 0;
/*!
@function DrawBorders
@discussion Erase the edges of the image around the
viewfinder window.
@param aSize the size of the viewfinder window.
*/
virtual TPoint DrawBorders(const TSize& aSize) const = 0;
/*!
@function ErrorNotifyL
@discussion Notify the user of an error from the camera.
@param aErrorTxt text describing source of error.
@param aError the error number.
@param aNotify if true then tell the user even if the error
is KErrorNone.
*/
virtual void ErrorNotifyL(const TDesC16 &aErrorTxt, TInt aError, TBool aNotify) = 0;
/*!
@function PictureTaken
@discussion Called when the camera has finished taking a picture
*/
virtual void PictureTaken() = 0;
/*!
@function SetBitmap
@discussion Called when a new bitmap is provided by the
camera, or the old bitmap should be cleared.
@param aBitmap the bitmap
*/
virtual void SetBitmap(CFbsBitmap* aBitmap) = 0;
};
/*!
@class CReadBarCAppView
@discussion An instance of class CReadBarCAppView is the Application View object
for the ReadBarC example application
*/
class CReadBarCAppView : public CCoeControl, public MMyCameraObserver
{
public: // from CCoeControl
/*!
@function Draw
@discussion Draw this CReadBarCAppView to the screen
@param aRect the rectangle of this view that needs updating
*/
void Draw(const TRect& aRect) const;
public: // from MMyCameraObserver
/*!
@function DrawImage
@discussion Show the current image to the user. Used by
the viewfinder.
@param aImage the image.
*/
void DrawImage(CFbsBitmap* aImage) const;
/*!
@function DrawBorders
@discussion Erase the edges of the image around the
viewfinder window.
@param aSize the size of the viewfinder window.
*/
TPoint DrawBorders(const TSize& aSize) const;
/*!
@function ErrorNotifyL
@discussion Notify the user of an error from the camera.
@param aErrorTxt text describing source of error.
@param aError the error number.
@param aNotify if true then tell the user even if the error
is KErrorNone.
*/
void ErrorNotifyL(const TDesC16 &aErrorTxt, TInt aError, TBool aNotify);
/*!
@function PictureTaken
@discussion Called when the camera has finished taking a picture
*/
void PictureTaken();
/*!
@function SetBitmap
@discussion Called when a new bitmap is provided by the
camera, or the old bitmap should be cleared.
@param aBitmap the bitmap
*/
void SetBitmap(CFbsBitmap* aBitmap);
// Lifecycle
private:
/*!
@function CReadBarCAppView
@discussion Perform the first phase of two phase construction
*/
CReadBarCAppView();
public:
/*!
@function NewL
@discussion Create a CReadBarCAppView object, which will draw itself to aRect
@param aRect the rectangle this view will be drawn to
@result a pointer to the created instance of CReadBarCAppView
*/
static CReadBarCAppView* NewL(const TRect& aRect);
/*!
@function NewLC
@discussion Create a CReadBarCAppView object, which will draw itself to aRect
@param aRect the rectangle this view will be drawn to
@result a pointer to the created instance of CReadBarCAppView
*/
static CReadBarCAppView* NewLC(const TRect& aRect);
private:
/*!
@function ConstructL
@discussion Perform the second phase construction of a CReadBarCAppView object
@param aRect the rectangle this view will be drawn to
*/
void ConstructL(const TRect& aRect);
public:
/*!
@function ~CReadBarCAppView
@discussion Destroy the object and release all memory objects
*/
~CReadBarCAppView();
// Operations
public:
/*!
@function Snap
@discussion Take a picture
*/
void Snap();
/*!
@function ViewFinder
@discussion Turn the viewfinder on
*/
void ViewFinder();
/*!
@function SaveCapturedImageL
@discussion Saves captured image to BMP file.
searchName format is drive:\directory\file??.bmp where ?? is a wild card replased
with two characters.
*/
void SaveCapturedImageL ();
private:
/*!
@function GetErrText
@discussion Helper function to translate error number into
text.
@param aText the resulting text
@param aError the error number
*/
static TDesC16& GetErrText(TDes16 &aText, TInt aError);
/*!
@function OfferKeyEventL
@discussion Handle the user pressing a key
@param aKeyEvent Details of the event that has occured
@param aType The type of event that has occured
@result Is key used?
*/
TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
/*!
@function GetNextFileName
@discussion Search the next captured image BMP file name.
This function searchs next filename for the file mask drive:\directory\file??.bmp
where ?? is between 00-99.
*/
TDesC16& GetNextFileName (TDes16& aName, TDesC16& aSearchName);
// Accessors
public:
/*
@function ViewState
@discussion the current state of the camera, as understood
by this view.
*/
TShowState ViewState() const;
// Attributes
private:
/*! @var iBarcodeFrame: rectangle where the barcode should appear */
TRect iBarcodeFrame;
/*! @var iCameraManager the manager for the camera */
CCameraManager* iCameraManager;
/*! @var iBitmap where to put the picture */
CFbsBitmap* iBitmap;
/*! @var iFindBarcode class for locating barcode */
CFindBarcode* iFindBarcode;
/*! @var iProcessedImage the image has been processed */
bool iProcessedImage;
/*! @var iReadBarcode class for reading barcode */
CReadBarcode* iReadBarcode;
/*! @var iState: whether we're showing the viewfinder or the snapped image */
TShowState iState;
};
#endif // __READBARCAPPVIEW_H__
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?