diff -r 4ea6f81c838a -r 0e9bb658ef58 widgetmodel/alfwidgetmodel/src/alfthememanagerutil.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgetmodel/alfwidgetmodel/src/alfthememanagerutil.cpp Wed Sep 01 12:23:18 2010 +0100 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of AlfThemeManagerUtil class, the class +* which is an interface to the ThemeManager component +* +*/ + +#include "alf/alfthememanagerutil.h" + + +#include "tm/themeitemmapper.h" +#include "tm/thememanager.h" +#include "tm/themeexception.h" +using namespace Alf; + +#include + +namespace Alf + { + +// --------------------------------------------------------------------------- +// Constructor +// --------------------------------------------------------------------------- +// +OSN_EXPORT AlfThemeManagerUtil::AlfThemeManagerUtil() + { + mThemeManager=NULL; + } + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +OSN_EXPORT AlfThemeManagerUtil::~AlfThemeManagerUtil() + { + if(mThemeManager) + { + ThemeManager::deleteThemeManager(); + mThemeManager = NULL; + } + } + +// --------------------------------------------------------------------------- +// Get Skin Image parameters. Given the logical name this method returns the skinid. +// --------------------------------------------------------------------------- +// +OSN_EXPORT TAknsItemID AlfThemeManagerUtil::getSkinId(const Utf8* aSkinLogicalName) + { + + TAknsItemID skinid; + skinid.Set(0,0); + + // Create ThemeManager instance + if(!mThemeManager) + { + mThemeManager = ThemeManager::createThemeManager(); + } + + // Query ThemeManager for an ItemMapper interface + IThemeItemMapper* itemMapper=NULL; + // Get Image data + ThemeItemDef item; + + try + { + mThemeManager->getItemMapperInterface(&itemMapper); + UString alfSkinLogicalname(aSkinLogicalName); + if(itemMapper) + { + item= itemMapper->findItem(alfSkinLogicalname); + } + } + catch(ThemeException& ex) + { + if(itemMapper) + mThemeManager->releaseItemMapperInterface(); + throw ex; + } + + skinid.iMajor= item.getMajorId(); + skinid.iMinor= item.getMinorId(); + + // Done with ItemMapper interface, release it + if(itemMapper) + mThemeManager->releaseItemMapperInterface(); + return skinid; + } + + }