⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debug.cpp

📁 barcode readers [ from Image]
💻 CPP
字号:
//
// Debug.cp
//   Enables easy display of image during debugging.
//   To use this class, call the constructor as follows:
//      CDebug debug(SystemGc(), Rect());
//   where SystemGc is the system graphics context and Rect
//   is the system drawing rectangle.
// 
//   Then you can call the static routine
//      ShowImage(CImage)
//   to display an image.
//
// Copyright (C) 2003, 2006 by Jon A. Webb (Contact via GMail; username is jonawebb)
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This library 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
// Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//
#include "Debug.h"

#include "Image.h"

#include <fbs.h>

namespace Core
{
    CDebug::CDebug() :
		   ibDebugging(false),
		   ibDebuggingInitialized(false),
		   ipGc(NULL)
		   {}

    CDebug::~CDebug()
           {}

	void CDebug::ConstructL(CWindowGc& gc, TRect rect)
		{
			ibDebugging = true;
			ipGc = &gc;
			iRect = rect;
			ibDebuggingInitialized = true;
		}

	CDebug* CDebug::NewL(CWindowGc& gc, TRect rect)
	{
		CDebug *pMe = new (ELeave) CDebug;
		CleanupStack::PushL(pMe);
		pMe->ConstructL(gc, rect);
		CleanupStack::Pop(/*pMe*/);
		Dll::SetTls((TAny*)pMe);
		return pMe;
	}

	CDebug* CDebug::GetInitializedState()
	{
		return (CDebug*) Dll::Tls();
	}

	void CDebug::InitializeDebugging(CWindowGc& gc, TRect rect)
	{
		(void) NewL(gc, rect); // discard because its store into TLS
	}

    void CDebug::FinishDebugging()
    {
        CDebug* pState = CDebug::GetInitializedState();
        if (pState) {
            delete pState;
            Dll::SetTls(NULL);
        }
    }

	void CDebug::ShowImage(const CImage& image)
    {
		CDebug* pState = CDebug::GetInitializedState();
        if (pState) {
            pState->ShowImageLocal(image);
        }
    }

	void CDebug::ShowImageLocal(const CImage& image)
	{
		if (ibDebuggingInitialized && ibDebugging) { // debugging was activated
			ipGc->DrawBitmap(iRect, &image.iBitmap);
		}
	}

	void CDebug::ToggleDebugging(bool bDebuggingOn)
    {
		CDebug* pState = CDebug::GetInitializedState();
        if (pState) pState->ToggleDebuggingLocal(bDebuggingOn);

    }

	void CDebug::ToggleDebuggingLocal(bool bDebuggingOn)
	{
		CDebug* pState = CDebug::GetInitializedState();
		if (bDebuggingOn) {
			if (pState && pState->ibDebuggingInitialized) {
				pState->ibDebugging = true;
			} else {
				User::Leave(KErrGeneral);
			}
		} else {
			pState->ibDebugging = false;
		}
	}

};

⌨️ 快捷键说明

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