×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Internationalising images on Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot fixing redirect link.(Moving links from forum.nokia.com TO developer.nokia.com))
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot change of template (Template:CodeSnippet) - now using Template:ArticleMetaData)
Line 2: Line 2:
 
__NOEDITSECTION__
 
__NOEDITSECTION__
 
{{KBCS}}
 
{{KBCS}}
{{CodeSnippet
+
{{ArticleMetaData
 
|id=CS000858
 
|id=CS000858
 
|platform=S60 3rd Edition, MR<br />S60 3rd Edition, FP1<br />S60 3rd Edition, FP2 Beta
 
|platform=S60 3rd Edition, MR<br />S60 3rd Edition, FP1<br />S60 3rd Edition, FP2 Beta
Line 10: Line 10:
 
|creationdate=March 25, 2008
 
|creationdate=March 25, 2008
 
|keywords=TParse, StringLoader, CFbsBitmap, TParse::Set(), StringLoader::LoadLC(), CFbsBitmap::Load()
 
|keywords=TParse, StringLoader, CFbsBitmap, TParse::Set(), StringLoader::LoadLC(), CFbsBitmap::Load()
 +
 +
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
 +
|signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
 +
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices. -->)
 +
|author=[[User:Tapiolaitinen]]
 
}}
 
}}
  

Revision as of 11:19, 24 June 2011


Template:KBCS

Article Metadata
Tested with
Devices(s): Nokia E61i
Nokia E90 Communicator
Nokia N95 8GB
Nokia 6220 Classic
Compatibility
Platform(s): S60 3rd Edition, MR
S60 3rd Edition, FP1
S60 3rd Edition, FP2 Beta
S60 3rd Edition (initial release)
Platform Security
Capabilities: )
Article
Keywords: TParse, StringLoader, CFbsBitmap, TParse::Set(), StringLoader::LoadLC(), CFbsBitmap::Load()
Created: tapiolaitinen (25 Mar 2008)
Last edited: hamishwillee (24 Jun 2011)

Overview

This code snippet is one of the series of snippets that demonstrate how to implement support for international diversity. This snippet shows how to select a bitmap according to the locale settings of the device.

MMP file

The following libraries are required:

LIBRARY fbscli.lib

Resource files

data\[app].rls:

#ifndef __APP_LOC__
#define __APP_LOC__
 
#ifdef LANGUAGE_01 // Language code for UK
#include "..\data\app.l01"
#elif defined LANGUAGE_03 // Language code for German
#include "..\data\app.l03"
#endif
 
#endif // __APP_LOC__

Declare the location of the "English" bitmap into data\[app].l01:

// The paths in the following string are different for S60 3rd & 2nd Edition platforms
#ifdef EKA2
#define qtn_loc_bmpfile "%U\\resource\\apps\\Bitmap_01.mbm"
#else
#define qtn_loc_bmpfile "%U\\system\\apps\\Localization\\Bitmap_01.mbm"
#endif

Declare the location of the "German" bitmap into data\[app].l03:

// The paths in the following string are different for S60 3rd & 2nd Edition platforms
#ifdef EKA2
#define qtn_loc_bmpfile "%U\\resource\\apps\\Bitmap_03.mbm"
#else
#define qtn_loc_bmpfile "%U\\system\\apps\\Localization\\Bitmap_03.mbm"
#endif

In the resource file of the application (data\[app].rss), create a bitmap resource from the localized string:

RESOURCE TBUF256 r_loc_bmpfile { buf=qtn_loc_bmpfile; }

Source file

#include <stringloader.h>
// Find the drive where the application has been installed
TParse parse;
parse.Set(Application()->AppFullName(), 0, 0);
 
// Load the name of the bitmap from the resource file
HBufC* bmpFile = StringLoader::LoadLC(R_LOC_BMPFILE, parse.Drive());
 
// Create and load the bitmap
CFbsBitmap* bitmap = new (ELeave)CFbsBitmap;
CleanupStack::PushL(bitmap);
 
// Load the first bitmap (index 0) from a multi-bitmap file
User::LeaveIfError(bitmap->Load(*bmpFile, 0));
 
CleanupStack::Pop(bitmap);
 
// Draw the bitmap onto the screen
// ...
 
CleanupStack::PopAndDestroy(bmpFile);

Postconditions

A bitmap is selected according to the locale settings of the device.

See also

148 page views in the last 30 days.
×