readbarcappui.cpp

来自「barcode readers [ from Image]」· C++ 代码 · 共 181 行

CPP
181
字号
/*
	ReadBarCAppUi. User interface 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.

*/
#include <aknnotewrappers.h>
#include <avkon.hrh>
#include <eikmenup.h>
#include <hlplch.h> 

#include "CameraServ.h"
#include "HelpfulForm.h"
#include "ReadBarC.hlp.hrh"
#include "ReadBarC.rsg"
#include "ReadBarC.pan"
#include "ReadBarCApplication.h"
#include "ReadBarCAppUi.h"
#include "ReadBarCAppView.h"
#include "ReadBarC.hrh"

void CReadBarCAppUi::ConstructL()
    {
    BaseConstructL();

    iAppView = CReadBarCAppView::NewL(ClientRect());    

    AddToStackL(iAppView);
    }

CReadBarCAppUi::CReadBarCAppUi() :
	inSavePicture(0)
    {
    // add any construction that cannot leave here
    }

CReadBarCAppUi::~CReadBarCAppUi()
    {
    if (iAppView)
        {
        RemoveFromStack(iAppView);
        }

    delete iAppView;
    iAppView = NULL;
    }

void CReadBarCAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
    {
    if (aResourceId == R_READBARC_MENU)
        {
			if (iAppView->ViewState() == ESnappedImage)
            {
				if (inSavePicture == -1) {
					aMenuPane->SetItemDimmed(EReadBarCSavePicture, EFalse);
				}
            aMenuPane->SetItemDimmed(EReadBarCTakePicture, ETrue);
            aMenuPane->SetItemDimmed(EReadBarCViewFinder, EFalse);
            }
		else if (iAppView->ViewState() == EViewFinder) 
            {
				if (inSavePicture == -1) {
					aMenuPane->SetItemDimmed(EReadBarCSavePicture, ETrue);
				}
            aMenuPane->SetItemDimmed(EReadBarCTakePicture, EFalse);
            aMenuPane->SetItemDimmed(EReadBarCViewFinder, ETrue);
            }
		else if (iAppView->ViewState() == ESnappingImage) 
            {
				if (inSavePicture == -1) {
					aMenuPane->SetItemDimmed(EReadBarCSavePicture, ETrue);
				}
            aMenuPane->SetItemDimmed(EReadBarCTakePicture, ETrue);
            aMenuPane->SetItemDimmed(EReadBarCViewFinder, ETrue);
            }
		else {
				if (inSavePicture == -1) {
					aMenuPane->SetItemDimmed(EReadBarCSavePicture, ETrue);
				}
            aMenuPane->SetItemDimmed(EReadBarCTakePicture, ETrue);
            aMenuPane->SetItemDimmed(EReadBarCViewFinder, ETrue);
		}
        }
    }

void CReadBarCAppUi::HandleCommandL(TInt aCommand)
    {
    switch(aCommand)
        {
        case EAknSoftkeyExit:
            Exit();
            break;

        case EReadBarCTakePicture:
			if (inSavePicture >= 0) {
				inSavePicture = 0;
			}
            iAppView->Snap();
            break;

		case EReadBarCViewFinder:
			if (inSavePicture == 3) {
				inSavePicture = -1;
			} else {
				inSavePicture = 0;
			}
			iAppView->ViewFinder();
			break;

		case EReadBarCSavePicture:
			iAppView->SaveCapturedImageL();
			break;

        case EReadBarCHelp:
            {
			if (inSavePicture >= 0) {
				inSavePicture = 0;
			}
            CHelpfulForm* dlg = CHelpfulForm::NewL(R_FORM_MENUBAR);
            dlg->ExecuteLD(R_HELPFUL_DIALOG);
            }
            break;

        case ELaunchHelpForContext:
            {
				if (inSavePicture >= 0) {
					if (inSavePicture < 3) {
						inSavePicture++;
					} else {
						inSavePicture = 0;
					}
				}
            CArrayFix<TCoeHelpContext>* buf = CCoeAppUi::AppHelpContextL();
            HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), buf);
            }
            break;

		case EReadBarCAbout:
			{
				if (inSavePicture >= 0) {
					inSavePicture = 0;
				}
				CAknInformationNote* informationNote = new (ELeave) CAknInformationNote();
				CleanupStack::PushL(informationNote);
				informationNote->ExecuteLD(
					_L("ReadBarC\nCopyright (c) 2006 by Jon A. Webb.\nSee help for licensing.")); 
				CleanupStack::Pop(informationNote);
			}
			break;
        default:
            User::Panic (_L("ReadBarC"), ECameraBasicUi);
            break;
        }
    }

CArrayFix<TCoeHelpContext>* CReadBarCAppUi::HelpContextL() const
    {
    CArrayFixFlat<TCoeHelpContext>* array = 
                new(ELeave)CArrayFixFlat<TCoeHelpContext>(1);
    CleanupStack::PushL(array);
    array->AppendL(TCoeHelpContext(KUidReadBarCApp, KContextApplication));
    CleanupStack::Pop(array);
    return array;
    }

⌨️ 快捷键说明

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