65
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Browser View
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
#include <aknutils.h>
|
|
20 |
#include <gulicon.h>
|
|
21 |
#include <StringLoader.h>
|
|
22 |
#include <data_caging_path_literals.hrh>
|
|
23 |
#include <eikbtgpc.h>
|
|
24 |
#include <eikapp.h>
|
|
25 |
#include <AknsUtils.h>
|
|
26 |
#include <e32math.h>
|
|
27 |
#include <browser.mbg>
|
|
28 |
#include "BrowserShortcutKeyMap.h"
|
|
29 |
#include "BrowserContentViewContainer.h"
|
|
30 |
#include "BrowserPreferences.h"
|
|
31 |
#include "BrowserWindowManager.h"
|
|
32 |
#include "BrowserWindow.h"
|
|
33 |
#include "ApiProvider.h"
|
|
34 |
#include "BrowserUIVariant.hrh"
|
|
35 |
#include "BrowserAppUi.h"
|
|
36 |
#include <AknBidiTextUtils.h>
|
|
37 |
|
|
38 |
// CONSTANTS
|
|
39 |
_LIT( KKeyMapSvgFile, "browser.mif" );
|
|
40 |
|
|
41 |
// Value table for 70% Transparency
|
|
42 |
const TInt KTransparency[256] =
|
|
43 |
{
|
|
44 |
0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7,
|
|
45 |
8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 13, 13, 13,
|
|
46 |
14, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 19,
|
|
47 |
19, 19, 20, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 23, 24, 24,
|
|
48 |
24, 25, 25, 25, 26, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 29,
|
|
49 |
30, 30, 30, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35,
|
|
50 |
35, 35, 36, 36, 36, 37, 37, 37, 38, 38, 38, 38, 39, 39, 39, 40, 40, 40,
|
|
51 |
41, 41, 41, 41, 42, 42, 42, 43, 43, 43, 44, 44, 44, 44, 45, 45, 45, 46,
|
|
52 |
46, 46, 47, 47, 47, 47, 48, 48, 48, 49, 49, 49, 50, 50, 50, 50, 51, 51,
|
|
53 |
51, 52, 52, 52, 53, 53, 53, 53, 54, 54, 54, 55, 55, 55, 56, 56, 56, 56,
|
|
54 |
57, 57, 57, 58, 58, 58, 59, 59, 59, 59, 60, 60, 60, 61, 61, 61, 62, 62,
|
|
55 |
62, 62, 63, 63, 63, 64, 64, 64, 65, 65, 65, 65, 66, 66, 66, 67, 67, 67,
|
|
56 |
68, 68, 68, 68, 69, 69, 69, 70, 70, 70, 71, 71, 71, 71, 72, 72, 72, 73,
|
|
57 |
73, 73, 74, 74, 74, 74, 75, 75, 75, 76, 76, 76, 77, 77
|
|
58 |
};
|
|
59 |
|
|
60 |
|
|
61 |
// keymap is 3x4
|
|
62 |
#define KNumCellsX 3
|
|
63 |
#define KNumCellsY 4
|
|
64 |
#define KNumCells 12
|
|
65 |
|
|
66 |
// spacing in pixels for scroll bars
|
|
67 |
#define KKeymapHScrollbarSize 4
|
|
68 |
#define KKeymapVScrollbarSize 4
|
|
69 |
|
|
70 |
// sizing for entire keymap (not counting scrollbar)
|
|
71 |
// as a percentage of vertical and horizontal screen size
|
|
72 |
#define KKeymapVSize 0.90
|
|
73 |
#define KKeymapHSize 0.90
|
|
74 |
|
|
75 |
// margins for each cell
|
|
76 |
#define KCellTopMargin 2
|
|
77 |
#define KCellRightMargin 5
|
|
78 |
#define KCellBotMargin 2
|
|
79 |
#define KCellLeftMargin 5
|
|
80 |
|
|
81 |
// Create constant icon assignments for each command
|
|
82 |
// note that this follows TShortcutsCommandDecodeEntry in BrowserPreferences.h
|
|
83 |
|
|
84 |
typedef const TInt TShortcutsIconAndTextDecodeEntry[2];
|
|
85 |
|
|
86 |
#define KShortcutsIconAndTextAssignmentSize 22
|
|
87 |
#define KShortcutsIconAndTextDecodeMatrixText 0 // First entry is the Text
|
|
88 |
#define KShortcutsIconAndTextDecodeMatrixIcon 1 // Second entry is the Icon
|
|
89 |
|
|
90 |
static const TShortcutsIconAndTextDecodeEntry KShortcutsIconAndTextAssignmentMatrix[] =
|
|
91 |
{
|
|
92 |
/* 0 EWmlNoCmd, */ { R_BROWSER_KEYMAP_TEXT_NONE, EMbmBrowserQgn_indi_browser_tb_key_map },
|
|
93 |
/* 1 EWmlCmdHelp, */ { R_BROWSER_KEYMAP_TEXT_SHOW_HELP, EMbmBrowserQgn_indi_browser_tb_help },
|
|
94 |
/* 2 EWmlCmdSwitchWindow, */ { R_BROWSER_KEYMAP_TEXT_SWITCH_WINDOW, EMbmBrowserQgn_indi_browser_tb_switch_win },
|
|
95 |
/* 3 EWmlCmdSavePage, */ { R_BROWSER_KEYMAP_TEXT_SAVE_PAGE, EMbmBrowserQgn_indi_browser_tb_save_page },
|
|
96 |
/* 4 EWmlCmdShowImages, */ { R_BROWSER_KEYMAP_TEXT_VIEW_IMAGES, EMbmBrowserQgn_indi_browser_tb_view_images },
|
|
97 |
/* 5 EWmlCmdHistory, */ { R_BROWSER_KEYMAP_TEXT_VISUAL_HISTORY, EMbmBrowserQgn_indi_browser_tb_view_pages },
|
|
98 |
/* 6 EWmlCmdFavourites, */ { R_BROWSER_KEYMAP_TEXT_MANAGE_BOOKMARKS, EMbmBrowserQgn_indi_browser_tb_bm },
|
|
99 |
/* 7 EWmlCmdShowSubscribeList, */ { R_BROWSER_KEYMAP_TEXT_SUBSCRIBE_TO_FEEDS, EMbmBrowserQgn_indi_browser_tb_rss },
|
|
100 |
/* 8 EWmlCmdRotateDisplay, */ { R_BROWSER_KEYMAP_TEXT_ROTATE_SCREEN, EMbmBrowserQgn_indi_browser_tb_rotate },
|
|
101 |
/* 9 EWmlCmdPreferences, */ { R_BROWSER_KEYMAP_TEXT_SETTINGS, EMbmBrowserQgn_indi_browser_tb_settings },
|
|
102 |
/* 10 EWmlCmdZoomOut, */ { R_BROWSER_KEYMAP_TEXT_ZOOM_OUT, EMbmBrowserQgn_indi_browser_tb_zoom_out },
|
|
103 |
/* 11 EWmlCmdZoomIn, */ { R_BROWSER_KEYMAP_TEXT_ZOOM_IN, EMbmBrowserQgn_indi_browser_tb_zoom_in },
|
|
104 |
/* 12 EWmlCmdLaunchHomePage, */ { R_BROWSER_KEYMAP_TEXT_GO_TO_HOMEPAGE, EMbmBrowserQgn_indi_browser_tb_home },
|
|
105 |
/* 13 EWmlCmdOneStepBack, */ { R_BROWSER_KEYMAP_TEXT_PREVIOUS_PAGE, EMbmBrowserQgn_indi_browser_tb_back },
|
|
106 |
/* 14 EWmlCmdShowMiniature, */ { R_BROWSER_KEYMAP_TEXT_MINIATURE_SHOW, EMbmBrowserQgn_indi_browser_tb_page },
|
|
107 |
/* 15 EWmlCmdReload, */ { R_BROWSER_KEYMAP_TEXT_RELOAD, EMbmBrowserQgn_indi_browser_tb_reload },
|
|
108 |
/* 16 EWmlCmdFindKeyword, */ { R_BROWSER_KEYMAP_TEXT_FIND_KEYWORD, EMbmBrowserQgn_indi_browser_tb_find_kw },
|
|
109 |
/* 17 EWmlCmdSaveAsBookmark, */ { R_BROWSER_KEYMAP_TEXT_SAVE_AS_BOOKMARK, EMbmBrowserQgn_indi_browser_tb_save_bm },
|
|
110 |
/* 18 EWmlCmdGoToAddress, */ { R_BROWSER_KEYMAP_TEXT_GO_TO_WEB_ADDRESS, EMbmBrowserQgn_indi_browser_tb_goto },
|
|
111 |
/* 19 EWmlCmdShowToolBar, */ { R_BROWSER_KEYMAP_TEXT_SHOW_TOOLBAR, EMbmBrowserQgn_indi_browser_tb_tb },
|
|
112 |
/* 20 EWmlCmdShowShortcutKeymap, */ { R_BROWSER_KEYMAP_TEXT_SHOW_KEYMAP, EMbmBrowserQgn_indi_browser_tb_key_map },
|
|
113 |
/* 21 EWmlCmdEnterFullScreenBrowsing, */ { R_BROWSER_KEYMAP_TEXT_FULL_SCREEN, EMbmBrowserQgn_indi_button_exit_fs },
|
|
114 |
};
|
|
115 |
|
|
116 |
// key assignments
|
|
117 |
static const TInt KDialpadAssignments[] =
|
|
118 |
{
|
|
119 |
/* 0 */ R_BROWSER_KEYMAP_KEY0,
|
|
120 |
/* 1 */ R_BROWSER_KEYMAP_KEY1,
|
|
121 |
/* 2 */ R_BROWSER_KEYMAP_KEY2,
|
|
122 |
/* 3 */ R_BROWSER_KEYMAP_KEY3,
|
|
123 |
/* 4 */ R_BROWSER_KEYMAP_KEY4,
|
|
124 |
/* 5 */ R_BROWSER_KEYMAP_KEY5,
|
|
125 |
/* 6 */ R_BROWSER_KEYMAP_KEY6,
|
|
126 |
/* 7 */ R_BROWSER_KEYMAP_KEY7,
|
|
127 |
/* 8 */ R_BROWSER_KEYMAP_KEY8,
|
|
128 |
/* 9 */ R_BROWSER_KEYMAP_KEY9,
|
|
129 |
/* 10 */ R_BROWSER_KEYMAP_KEY10,
|
|
130 |
/* 11 */ R_BROWSER_KEYMAP_KEY11
|
|
131 |
};
|
|
132 |
|
|
133 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
134 |
|
|
135 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
136 |
|
|
137 |
// -----------------------------------------------------------------------------
|
|
138 |
// TKeymapCellData::TKeymapCellData
|
|
139 |
// TKeymapCellData Utility Class constructor
|
|
140 |
// -----------------------------------------------------------------------------
|
|
141 |
|
|
142 |
TKeymapCellData::TKeymapCellData() :
|
|
143 |
keyText(NULL),
|
|
144 |
lineText(NULL),
|
|
145 |
cmdRscId(NULL),
|
|
146 |
keyBitmapImage(NULL),
|
|
147 |
keyBitmapMask(NULL)
|
|
148 |
{
|
|
149 |
}
|
|
150 |
|
|
151 |
|
|
152 |
// -----------------------------------------------------------------------------
|
|
153 |
// TKeymapCellData::TKeymapCellData
|
|
154 |
// TKeymapCellData Utility Class destructor
|
|
155 |
// -----------------------------------------------------------------------------
|
|
156 |
TKeymapCellData::~TKeymapCellData()
|
|
157 |
{
|
|
158 |
if(keyText) delete keyText;
|
|
159 |
if(lineText) delete lineText;
|
|
160 |
if(keyBitmapImage) delete keyBitmapImage;
|
|
161 |
if(keyBitmapMask) delete keyBitmapMask;
|
|
162 |
}
|
|
163 |
|
|
164 |
// -----------------------------------------------------------------------------
|
|
165 |
// CBrowserShortcutKeyMap::NewL
|
|
166 |
// The two-phase Symbian constructor
|
|
167 |
// -----------------------------------------------------------------------------
|
|
168 |
//
|
|
169 |
CBrowserShortcutKeyMap* CBrowserShortcutKeyMap::NewL( CBrowserContentViewContainer* aContentViewContainer, MApiProvider& aApiProvider )
|
|
170 |
{
|
|
171 |
CBrowserShortcutKeyMap* self = new (ELeave) CBrowserShortcutKeyMap( aContentViewContainer, aApiProvider );
|
|
172 |
CleanupStack::PushL(self);
|
|
173 |
self->ConstructL();
|
|
174 |
CleanupStack::Pop(); //self
|
|
175 |
return self;
|
|
176 |
}
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
// -----------------------------------------------------------------------------
|
|
181 |
// Destructor
|
|
182 |
// -----------------------------------------------------------------------------
|
|
183 |
CBrowserShortcutKeyMap::~CBrowserShortcutKeyMap()
|
|
184 |
{
|
|
185 |
// Close out array and delete data members
|
|
186 |
iCellData.Close();
|
|
187 |
|
|
188 |
// cleanup svg mbm file name
|
|
189 |
if(iSvgMbmFile)
|
|
190 |
{
|
|
191 |
delete iSvgMbmFile;
|
|
192 |
iSvgMbmFile = NULL;
|
|
193 |
}
|
|
194 |
|
|
195 |
// Cleanup Sprite data
|
|
196 |
iSprite.Close();
|
|
197 |
if(iSpriteBitmapDevice)
|
|
198 |
{
|
|
199 |
delete iSpriteBitmapDevice;
|
|
200 |
iSpriteBitmapDevice = NULL;
|
|
201 |
}
|
|
202 |
if(iSpriteBitmapContext)
|
|
203 |
{
|
|
204 |
delete iSpriteBitmapContext;
|
|
205 |
iSpriteBitmapContext = NULL;
|
|
206 |
}
|
|
207 |
if(iSpriteBitmap)
|
|
208 |
{
|
|
209 |
delete iSpriteBitmap;
|
|
210 |
iSpriteBitmap = NULL;
|
|
211 |
}
|
|
212 |
|
|
213 |
if(iSpriteMaskBitmapDevice)
|
|
214 |
{
|
|
215 |
delete iSpriteMaskBitmapDevice;
|
|
216 |
iSpriteMaskBitmapDevice = NULL;
|
|
217 |
}
|
|
218 |
if(iSpriteMaskBitmapContext)
|
|
219 |
{
|
|
220 |
delete iSpriteMaskBitmapContext;
|
|
221 |
iSpriteMaskBitmapContext = NULL;
|
|
222 |
}
|
|
223 |
if(iSpriteMaskBitmap)
|
|
224 |
{
|
|
225 |
delete iSpriteMaskBitmap;
|
|
226 |
iSpriteMaskBitmap = NULL;
|
|
227 |
}
|
|
228 |
|
|
229 |
}
|
|
230 |
|
|
231 |
|
|
232 |
|
|
233 |
// -----------------------------------------------------------------------------
|
|
234 |
// CBrowserShortcutKeyMap::CBrowserShortcutKeyMap
|
|
235 |
// C++ default constructor can NOT contain any code, that
|
|
236 |
// might leave.
|
|
237 |
// -----------------------------------------------------------------------------
|
|
238 |
//
|
|
239 |
CBrowserShortcutKeyMap::CBrowserShortcutKeyMap( CBrowserContentViewContainer* aContentViewContainer, MApiProvider& aApiProvider )
|
|
240 |
: iContentViewContainer( aContentViewContainer ), iApiProvider( aApiProvider )
|
|
241 |
{
|
|
242 |
}
|
|
243 |
|
|
244 |
|
|
245 |
|
|
246 |
// -----------------------------------------------------------------------------
|
|
247 |
// CBrowserShortcutKeyMap::ConstructL
|
|
248 |
// The constructor that can contain code that might leave.
|
|
249 |
// -----------------------------------------------------------------------------
|
|
250 |
//
|
|
251 |
void CBrowserShortcutKeyMap::ConstructL()
|
|
252 |
{
|
|
253 |
//LoadResourceFileL();
|
|
254 |
iSvgMbmFile = GetCannedImageDirL();
|
|
255 |
iSvgMbmFile->Des().Append( KKeyMapSvgFile );
|
|
256 |
|
|
257 |
InitKeymap();
|
|
258 |
CreateBitmapAndContextL();
|
|
259 |
ConstructSprite();
|
|
260 |
}
|
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
// -----------------------------------------------------------------------------
|
|
265 |
// CBrowserShortcutKeyMap::InitKeymap
|
|
266 |
// Initialize Keymap properties
|
|
267 |
// -----------------------------------------------------------------------------
|
|
268 |
//
|
|
269 |
void CBrowserShortcutKeyMap::InitKeymap()
|
|
270 |
{
|
|
271 |
// derive keymap's size from the container's size
|
|
272 |
iTargetRect = iContentViewContainer->Rect();
|
|
273 |
|
|
274 |
// resize it to account for scrollbar width/height
|
|
275 |
iTargetRect.Resize(-TSize(KKeymapHScrollbarSize,KKeymapVScrollbarSize));
|
|
276 |
|
|
277 |
TBool landscape = iTargetRect.Size().iWidth > iTargetRect.Size().iHeight ;
|
|
278 |
|
|
279 |
//
|
|
280 |
// derive shrink amounts based on keymap size constants and shrink the rect
|
|
281 |
//
|
|
282 |
TInt newHeight = (KKeymapVSize * iTargetRect.Size().iHeight);
|
|
283 |
TInt newWidth = (KKeymapHSize * iTargetRect.Size().iWidth);
|
|
284 |
|
|
285 |
if(newWidth > KKeymapHSize * iTargetRect.Size().iWidth)
|
|
286 |
{
|
|
287 |
newWidth = (KKeymapHSize * iTargetRect.Size().iWidth);
|
|
288 |
}
|
|
289 |
|
|
290 |
// shrink the height and width slightly
|
|
291 |
// as necessary to be evenly divisible by the rows/cols later on
|
|
292 |
TReal remainder;
|
|
293 |
TInt result;
|
|
294 |
result = Math::Mod(remainder,newWidth,KNumCellsX);
|
|
295 |
if((result == KErrNone) && (remainder != 0))
|
|
296 |
{
|
|
297 |
newWidth -= remainder;
|
|
298 |
}
|
|
299 |
result = Math::Mod(remainder,newHeight,KNumCellsY);
|
|
300 |
if((result == KErrNone) && (remainder != 0))
|
|
301 |
{
|
|
302 |
newHeight -= remainder;
|
|
303 |
}
|
|
304 |
TInt hShrink = (iTargetRect.Size().iWidth - newWidth)/2;
|
|
305 |
TInt vShrink = (iTargetRect.Size().iHeight - newHeight)/2;
|
|
306 |
iTargetRect.Shrink(TSize(hShrink,vShrink));
|
|
307 |
|
|
308 |
// Set font types
|
|
309 |
iLineFont = LatinPlain12();
|
|
310 |
|
|
311 |
if (landscape)
|
|
312 |
{ // in landscape need to shrink the font or else it gets clipped
|
|
313 |
iKeyFont = LatinBold13();
|
|
314 |
}
|
|
315 |
else
|
|
316 |
{
|
|
317 |
iKeyFont = LatinBold16();
|
|
318 |
}
|
|
319 |
|
|
320 |
// init cell data
|
|
321 |
InitCellDataL();
|
|
322 |
}
|
|
323 |
|
|
324 |
|
|
325 |
|
|
326 |
// -----------------------------------------------------------------------------
|
|
327 |
// CBrowserShortcutKeyMap::InitCellDataL
|
|
328 |
// Initialize Keymap data kept for each cell of the map
|
|
329 |
// -----------------------------------------------------------------------------
|
|
330 |
|
|
331 |
void CBrowserShortcutKeyMap::InitCellDataL()
|
|
332 |
{
|
|
333 |
for(TInt i = 0; i < KNumCells; i++)
|
|
334 |
{
|
|
335 |
TKeymapCellData* cellData = new (ELeave) TKeymapCellData();
|
|
336 |
CleanupStack::PushL(cellData);
|
|
337 |
|
|
338 |
TInt shortcutAssign;
|
|
339 |
|
|
340 |
// get the shortcut assignment from Browser Prefs
|
|
341 |
switch(i)
|
|
342 |
{
|
|
343 |
case 0:
|
|
344 |
shortcutAssign = iApiProvider.Preferences().ShortcutKey1Cmd();
|
|
345 |
break;
|
|
346 |
case 1:
|
|
347 |
shortcutAssign = iApiProvider.Preferences().ShortcutKey2Cmd();
|
|
348 |
break;
|
|
349 |
case 2:
|
|
350 |
shortcutAssign = iApiProvider.Preferences().ShortcutKey3Cmd();
|
|
351 |
break;
|
|
352 |
case 3:
|
|
353 |
shortcutAssign = iApiProvider.Preferences().ShortcutKey4Cmd();
|
|
354 |
break;
|
|
355 |
case 4:
|
|
356 |
shortcutAssign = iApiProvider.Preferences().ShortcutKey5Cmd();
|
|
357 |
break;
|
|
358 |
case 5:
|
|
359 |
shortcutAssign = iApiProvider.Preferences().ShortcutKey6Cmd();
|
|
360 |
break;
|
|
361 |
case 6:
|
|
362 |
shortcutAssign = iApiProvider.Preferences().ShortcutKey7Cmd();
|
|
363 |
break;
|
|
364 |
case 7:
|
|
365 |
shortcutAssign = iApiProvider.Preferences().ShortcutKey8Cmd();
|
|
366 |
break;
|
|
367 |
case 8:
|
|
368 |
shortcutAssign = iApiProvider.Preferences().ShortcutKey9Cmd();
|
|
369 |
break;
|
|
370 |
case 9:
|
|
371 |
shortcutAssign = iApiProvider.Preferences().ShortcutKeyStarCmd();
|
|
372 |
break;
|
|
373 |
case 10:
|
|
374 |
shortcutAssign = iApiProvider.Preferences().ShortcutKey0Cmd();
|
|
375 |
break;
|
|
376 |
case 11:
|
|
377 |
shortcutAssign = iApiProvider.Preferences().ShortcutKeyHashCmd();
|
|
378 |
break;
|
|
379 |
default:
|
|
380 |
shortcutAssign = iApiProvider.Preferences().ShortcutKey1Cmd();
|
|
381 |
break;
|
|
382 |
}
|
|
383 |
|
|
384 |
cellData->cmdRscId = KShortcutsIconAndTextAssignmentMatrix[shortcutAssign][KShortcutsIconAndTextDecodeMatrixText];
|
|
385 |
cellData->lineText = StringLoader::LoadLC(cellData->cmdRscId);
|
|
386 |
|
|
387 |
// get shortcut key assignments and set dialpad assignments
|
|
388 |
cellData->keyText = StringLoader::LoadLC(KDialpadAssignments[i]);
|
|
389 |
|
|
390 |
// load the icon its mask (use a default if we're out of range)
|
|
391 |
TInt iconId = EMbmBrowserQgn_indi_browser_tb_key_map;
|
|
392 |
if(shortcutAssign < KShortcutsIconAndTextAssignmentSize)
|
|
393 |
{
|
|
394 |
iconId = KShortcutsIconAndTextAssignmentMatrix[shortcutAssign][KShortcutsIconAndTextDecodeMatrixIcon];
|
|
395 |
}
|
|
396 |
|
|
397 |
if(shortcutAssign == NULL)
|
|
398 |
{
|
|
399 |
cellData->keyBitmapImage = NULL;
|
|
400 |
cellData->keyBitmapMask = NULL;
|
|
401 |
}
|
|
402 |
else
|
|
403 |
{
|
|
404 |
LoadSvg(iconId,
|
|
405 |
*iSvgMbmFile,
|
|
406 |
cellData->keyBitmapImage,
|
|
407 |
cellData->keyBitmapMask);
|
|
408 |
}
|
|
409 |
|
|
410 |
// add to the data array
|
|
411 |
iCellData.Append(cellData);
|
|
412 |
|
|
413 |
// remove cellData, keytext, linetext from stack
|
|
414 |
CleanupStack::Pop(3);
|
|
415 |
}
|
|
416 |
}
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
// -----------------------------------------------------------------------------
|
|
421 |
// CBrowserShortcutKeyMap::CreateBitmapAndContextL
|
|
422 |
// Create the bitmap and context that will be used for the sprite
|
|
423 |
// -----------------------------------------------------------------------------
|
|
424 |
//
|
|
425 |
void CBrowserShortcutKeyMap::CreateBitmapAndContextL()
|
|
426 |
{
|
|
427 |
// Create Sprite Bitmap
|
|
428 |
iSpriteBitmap = new (ELeave) CFbsBitmap;
|
|
429 |
User::LeaveIfError( iSpriteBitmap->Create( iTargetRect.Size(), EColor16MA ) );
|
|
430 |
|
|
431 |
iSpriteBitmapDevice = CFbsBitmapDevice::NewL( iSpriteBitmap );
|
|
432 |
User::LeaveIfError( iSpriteBitmapDevice->CreateContext( iSpriteBitmapContext ) );
|
|
433 |
|
|
434 |
// Create Mask Bitmap
|
|
435 |
iSpriteMaskBitmap = new (ELeave) CFbsBitmap;
|
|
436 |
User::LeaveIfError( iSpriteMaskBitmap->Create( iTargetRect.Size(), EColor16MA ) );
|
|
437 |
iSpriteMaskBitmapDevice = CFbsBitmapDevice::NewL( iSpriteMaskBitmap );
|
|
438 |
User::LeaveIfError( iSpriteMaskBitmapDevice->CreateContext( iSpriteMaskBitmapContext ) );
|
|
439 |
|
|
440 |
TRect r( TPoint( 0, 0 ), iSpriteMaskBitmap->SizeInPixels());
|
|
441 |
|
|
442 |
iSpriteMaskBitmapContext->SetBrushStyle( CGraphicsContext::ESolidBrush );
|
|
443 |
iSpriteMaskBitmapContext->SetPenStyle( CGraphicsContext::ESolidPen );
|
|
444 |
iSpriteMaskBitmapContext->SetBrushColor( TRgb( 0, 0, 0) );
|
|
445 |
iSpriteMaskBitmapContext->SetPenColor( TRgb( 0, 0, 0) );
|
|
446 |
iSpriteMaskBitmapContext->DrawRect(r);
|
|
447 |
|
|
448 |
// Draw the rectangular outline
|
|
449 |
iSpriteBitmapContext->SetBrushStyle( CGraphicsContext::ESolidBrush );
|
|
450 |
iSpriteBitmapContext->SetPenStyle( CGraphicsContext::ESolidPen );
|
|
451 |
iSpriteBitmapContext->SetBrushColor( TRgb( 242, 244, 242) );
|
|
452 |
iSpriteBitmapContext->SetPenColor( TRgb( 100, 100, 0) );
|
|
453 |
iSpriteBitmapContext->SetPenSize( TSize(2,2) );
|
|
454 |
iSpriteBitmapContext->DrawRect(r);
|
|
455 |
|
|
456 |
TSize cellSize(r.Width()/KNumCellsX,r.Height()/KNumCellsY);
|
|
457 |
|
|
458 |
for(TInt i = 0; i < KNumCellsY; i++)
|
|
459 |
{
|
|
460 |
for(TInt j = 0; j < KNumCellsX; j++)
|
|
461 |
{
|
|
462 |
TInt cellIndex(i*KNumCellsX + j);
|
|
463 |
CreateCellLayout( cellIndex, TPoint(j*cellSize.iWidth,i*cellSize.iHeight),cellSize);
|
|
464 |
CreateSpriteCellL( cellIndex );
|
|
465 |
}
|
|
466 |
}
|
|
467 |
}
|
|
468 |
|
|
469 |
|
|
470 |
|
|
471 |
// -----------------------------------------------------------------------------
|
|
472 |
// CBrowserShortcutKeyMap::CreateCellLayout
|
|
473 |
// Calculate the layout of the sprite rects for a given cell
|
|
474 |
// -----------------------------------------------------------------------------
|
|
475 |
|
|
476 |
void CBrowserShortcutKeyMap::CreateCellLayout(const TInt& aCellIndex, const TPoint& aUpperL, const TSize& aSize)
|
|
477 |
{
|
|
478 |
// Create pointer for easy access curr Cell
|
|
479 |
TKeymapCellData* pCurrCell = iCellData[aCellIndex];
|
|
480 |
|
|
481 |
// Create rect for Cell
|
|
482 |
pCurrCell->r.SetRect(aUpperL, aSize);
|
|
483 |
|
|
484 |
// Internally, Our Cell is sized accounting for margin
|
|
485 |
// Setup this
|
|
486 |
TPoint marginOffset(KCellLeftMargin, KCellTopMargin);
|
|
487 |
TSize marginSize(KCellLeftMargin + KCellRightMargin, KCellTopMargin + KCellBotMargin);
|
|
488 |
pCurrCell->rCell.SetRect( aUpperL + marginOffset, aSize - marginSize );
|
|
489 |
|
|
490 |
// Upper LH key indicator
|
|
491 |
TInt keyFontHeight = iKeyFont->HeightInPixels() + iKeyFont->DescentInPixels();
|
|
492 |
pCurrCell->rKey.SetRect( pCurrCell->rCell.iTl, TSize(keyFontHeight, iKeyFont->MaxCharWidthInPixels()) );
|
|
493 |
|
|
494 |
// Prep the line rects, calculating the position based upon the font size
|
|
495 |
TInt lineFontHeight = iLineFont->HeightInPixels() + iLineFont->DescentInPixels();
|
|
496 |
TSize lineSize(pCurrCell->rCell.Width(),lineFontHeight);
|
|
497 |
TPoint lineAreaUpperLH(pCurrCell->rCell.iTl.iX, pCurrCell->rCell.iBr.iY - (2*lineSize.iHeight));
|
|
498 |
|
|
499 |
// Set this point to be the upper left of the line(s) of text.
|
|
500 |
// If we have two lines, this will be the upperLH of Line1
|
|
501 |
// If we have one line, this will be the upperLH of Line2
|
|
502 |
// This, we will use to set the rect size of the icon later
|
|
503 |
pCurrCell->rLine1.SetRect(lineAreaUpperLH,lineSize);
|
|
504 |
pCurrCell->rLine2.SetRect(lineAreaUpperLH + TPoint(0,lineSize.iHeight),lineSize);
|
|
505 |
TPoint linesUpperLH = pCurrCell->rLine1.iTl;
|
|
506 |
|
|
507 |
// CREATE the icon area from what is left over
|
|
508 |
TPoint iconUpperLH(pCurrCell->rCell.iTl + TPoint(pCurrCell->rKey.Size().iWidth,0));
|
|
509 |
TPoint iconLowerRH(pCurrCell->rCell.iBr.iX,linesUpperLH.iY);
|
|
510 |
pCurrCell->rIcon.SetRect(iconUpperLH,iconLowerRH);
|
|
511 |
|
|
512 |
// resize the icon rect to be square if its not already... according to its smallest dimension
|
|
513 |
if(pCurrCell->rIcon.Height() > pCurrCell->rIcon.Width())
|
|
514 |
{
|
|
515 |
TSize sizeChange(0,pCurrCell->rIcon.Width() - pCurrCell->rIcon.Height());
|
|
516 |
pCurrCell->rIcon.Resize(sizeChange);
|
|
517 |
pCurrCell->rIcon.Move(TPoint(0,-sizeChange.iHeight/2));
|
|
518 |
}
|
|
519 |
else if(pCurrCell->rIcon.Width() > pCurrCell->rIcon.Height())
|
|
520 |
{
|
|
521 |
TSize sizeChange(pCurrCell->rIcon.Height() - pCurrCell->rIcon.Width(),0);
|
|
522 |
pCurrCell->rIcon.Resize(sizeChange);
|
|
523 |
pCurrCell->rIcon.Move(TPoint(-sizeChange.iWidth/2,0));
|
|
524 |
}
|
|
525 |
}
|
|
526 |
|
|
527 |
|
|
528 |
|
|
529 |
// -----------------------------------------------------------------------------
|
|
530 |
// CBrowserShortcutKeyMap::CreateSpriteCellL
|
|
531 |
// Draw the sprite rects to the sprite bitmap
|
|
532 |
// ----------------------------------------------------------------------------
|
|
533 |
|
|
534 |
void CBrowserShortcutKeyMap::CreateSpriteCellL(const TInt& aCellIndex)
|
|
535 |
{
|
|
536 |
// Create pointer for easy access curr Cell
|
|
537 |
TKeymapCellData* pCurrCell = iCellData[aCellIndex];
|
|
538 |
|
|
539 |
TBool ShowDim = EFalse;
|
|
540 |
|
|
541 |
|
|
542 |
// Draw rect for Cell
|
|
543 |
iSpriteBitmapContext->SetPenSize( TSize(1,1) );
|
|
544 |
iSpriteBitmapContext->SetPenStyle( CGraphicsContext::ESolidPen );
|
|
545 |
iSpriteBitmapContext->SetPenColor( TRgb( 0, 0, 0) );
|
|
546 |
iSpriteBitmapContext->DrawRect(pCurrCell->r);
|
|
547 |
|
|
548 |
|
|
549 |
|
|
550 |
// DRAW TEXT
|
|
551 |
iSpriteBitmapContext->SetPenColor( TRgb( 0, 0, 0) );
|
|
552 |
|
|
553 |
// Draw key text
|
|
554 |
if(pCurrCell->keyText)
|
|
555 |
{
|
|
556 |
iSpriteBitmapContext->UseFont( iKeyFont );
|
|
557 |
iSpriteBitmapContext->DrawText(pCurrCell->keyText->Des(),
|
|
558 |
pCurrCell->rKey, iKeyFont->FontMaxHeight(), CGraphicsContext::ECenter, 0);
|
|
559 |
}
|
|
560 |
|
|
561 |
// For line1, line2 text, we need to first wrap them
|
|
562 |
// based upon the width of their enclosing rectangles
|
|
563 |
if(pCurrCell->lineText)
|
|
564 |
{
|
|
565 |
CArrayFixFlat<TInt> *lineWidthArray = new( ELeave ) CArrayFixFlat<TInt>(2);
|
|
566 |
lineWidthArray->AppendL(pCurrCell->rLine1.Width());
|
|
567 |
lineWidthArray->AppendL(pCurrCell->rLine2.Width());
|
|
568 |
|
|
569 |
CArrayFixFlat<TPtrC> *WrappedArray = new( ELeave ) CArrayFixFlat<TPtrC>(3);
|
|
570 |
pCurrCell->lineText = pCurrCell->lineText->ReAllocL(pCurrCell->lineText->Length() + lineWidthArray->Count() * KAknBidiExtraSpacePerLine);
|
|
571 |
TPtr ptr(pCurrCell->lineText->Des());
|
|
572 |
AknBidiTextUtils::ConvertToVisualAndWrapToArrayL( ptr,*lineWidthArray, *iLineFont, *WrappedArray, EFalse );
|
|
573 |
iSpriteBitmapContext->UseFont( iLineFont );
|
|
574 |
iSpriteBitmapContext->DrawText(WrappedArray->At(0),
|
|
575 |
pCurrCell->rLine2, iLineFont->FontMaxHeight(), CGraphicsContext::ECenter, 0);
|
|
576 |
|
|
577 |
if(WrappedArray->Count() >= 2)
|
|
578 |
{
|
|
579 |
iSpriteBitmapContext->DrawText(WrappedArray->At(0),
|
|
580 |
pCurrCell->rLine1, iLineFont->FontMaxHeight(), CGraphicsContext::ECenter, 0);
|
|
581 |
iSpriteBitmapContext->DrawText(WrappedArray->At(1),
|
|
582 |
pCurrCell->rLine2, iLineFont->FontMaxHeight(), CGraphicsContext::ECenter, 0);
|
|
583 |
}
|
|
584 |
|
|
585 |
|
|
586 |
// Set dim flag if needed
|
|
587 |
switch (pCurrCell->cmdRscId)
|
|
588 |
{
|
|
589 |
case R_BROWSER_KEYMAP_TEXT_SWITCH_WINDOW:
|
|
590 |
{ //EWmlCmdSwitchWindow;
|
|
591 |
ShowDim = ( !iApiProvider.Preferences().UiLocalFeatureSupported( KBrowserMultipleWindows ) ||
|
|
592 |
iApiProvider.IsEmbeddedModeOn() ||
|
|
593 |
iApiProvider.WindowMgr().WindowCount() < 2);
|
|
594 |
break;
|
|
595 |
}
|
|
596 |
|
|
597 |
case R_BROWSER_KEYMAP_TEXT_VIEW_IMAGES:
|
|
598 |
{ //EWmlCmdShowImages;
|
|
599 |
ShowDim = ( !iApiProvider.BrCtlInterface().ImageCountL() );
|
|
600 |
break;
|
|
601 |
}
|
|
602 |
|
|
603 |
case R_BROWSER_KEYMAP_TEXT_SUBSCRIBE_TO_FEEDS:
|
|
604 |
{ // EWmlCmdShowSubscribeList
|
|
605 |
CBrCtlInterface& brctl = iApiProvider.BrCtlInterface();
|
|
606 |
TBool subscribeToItems(EFalse);
|
|
607 |
TRAPD(err, const RPointerArray<TBrCtlSubscribeTo>& items = brctl.SubscribeToMenuItemsL();
|
|
608 |
subscribeToItems = (err == KErrNone && items.Count() > 0));
|
|
609 |
ShowDim = !subscribeToItems;
|
|
610 |
break;
|
|
611 |
}
|
|
612 |
|
|
613 |
case R_BROWSER_KEYMAP_TEXT_GO_TO_HOMEPAGE:
|
|
614 |
{ // EWmlCmdLaunchHomePage
|
|
615 |
ShowDim = iApiProvider.IsLaunchHomePageDimmedL();
|
|
616 |
break;
|
|
617 |
}
|
|
618 |
|
|
619 |
case R_BROWSER_KEYMAP_TEXT_PREVIOUS_PAGE:
|
|
620 |
{ // EWmlCmdOneStepBack
|
|
621 |
ShowDim = (!iApiProvider.BrCtlInterface().NavigationAvailable(TBrCtlDefs::ENavigationBack ) );
|
|
622 |
break;
|
|
623 |
}
|
|
624 |
|
|
625 |
case R_BROWSER_KEYMAP_TEXT_MINIATURE_SHOW:
|
|
626 |
{ //EWmlCmdShowMiniature;
|
|
627 |
ShowDim = ( !iApiProvider.Preferences().UiLocalFeatureSupported( KBrowserGraphicalPage ) ||
|
|
628 |
iApiProvider.WindowMgr().CurrentWindow()->HasWMLContent(ETrue) );
|
|
629 |
break;
|
|
630 |
}
|
|
631 |
|
|
632 |
case R_BROWSER_KEYMAP_TEXT_SHOW_TOOLBAR:
|
|
633 |
{ //EWmlCmdShowToolBar;
|
|
634 |
if ( !AknLayoutUtils::PenEnabled() && iApiProvider.Preferences().ShowToolbarOnOff() )
|
|
635 |
{
|
|
636 |
ShowDim = iApiProvider.WindowMgr().CurrentWindow()->WMLMode();
|
|
637 |
}
|
|
638 |
else
|
|
639 |
{
|
|
640 |
ShowDim = ETrue;
|
|
641 |
}
|
|
642 |
break;
|
|
643 |
}
|
|
644 |
|
|
645 |
case R_BROWSER_KEYMAP_TEXT_SAVE_AS_BOOKMARK:
|
|
646 |
{ //EWmlCmdSaveAsBookmark;
|
|
647 |
if ( iApiProvider.IsEmbeddedModeOn() && CBrowserAppUi::Static()->IsEmbeddedInOperatorMenu() )
|
|
648 |
{
|
|
649 |
ShowDim = ETrue;
|
|
650 |
}
|
|
651 |
else
|
|
652 |
{
|
|
653 |
HBufC *pageUrl = iApiProvider.BrCtlInterface().PageInfoLC( TBrCtlDefs::EPageInfoUrl );
|
|
654 |
if( ( pageUrl == NULL ) || ( pageUrl->Length() == 0 ) )
|
|
655 |
{
|
|
656 |
ShowDim = ETrue;
|
|
657 |
}
|
|
658 |
CleanupStack::PopAndDestroy( pageUrl );
|
|
659 |
}
|
|
660 |
break;
|
|
661 |
}
|
|
662 |
|
|
663 |
/* Zoom Mode currently disabled
|
|
664 |
case R_BROWSER_KEYMAP_TEXT_ZOOM_MODE:
|
|
665 |
{ //EWmlCmdZoomMode;
|
|
666 |
|
|
667 |
ShowDim = ( iApiProvider.WindowMgr().CurrentWindow()->WMLMode() ||
|
|
668 |
!iApiProvider.ContentDisplayed() ||
|
|
669 |
AknLayoutUtils::PenEnabled() );
|
|
670 |
break;
|
|
671 |
}
|
|
672 |
*/
|
|
673 |
|
|
674 |
default:
|
|
675 |
break;
|
|
676 |
}
|
|
677 |
}
|
|
678 |
|
|
679 |
// DRAW the icon,
|
|
680 |
// setting the icon size according to iconRect
|
|
681 |
if(pCurrCell->keyBitmapImage != NULL && pCurrCell->keyBitmapMask != NULL)
|
|
682 |
{
|
|
683 |
AknIconUtils::SetSize(pCurrCell->keyBitmapImage, pCurrCell->rIcon.Size() );
|
|
684 |
AknIconUtils::SetSize(pCurrCell->keyBitmapMask, pCurrCell->rIcon.Size() );
|
|
685 |
|
|
686 |
if (ShowDim)
|
|
687 |
{
|
|
688 |
CFbsBitmap* keyBitmapDimImage;
|
|
689 |
CFbsBitmap* keyBitmapDimMask;
|
|
690 |
|
|
691 |
CreateDimBitmapL(pCurrCell->keyBitmapImage,
|
|
692 |
pCurrCell->keyBitmapMask,
|
|
693 |
keyBitmapDimImage,
|
|
694 |
keyBitmapDimMask);
|
|
695 |
|
|
696 |
iSpriteBitmapContext->BitBltMasked(pCurrCell->rIcon.iTl,
|
|
697 |
keyBitmapDimImage,
|
|
698 |
TRect(TPoint(0, 0),pCurrCell->rIcon.Size() ),
|
|
699 |
keyBitmapDimMask,
|
|
700 |
ETrue);
|
|
701 |
|
|
702 |
delete keyBitmapDimImage;
|
|
703 |
delete keyBitmapDimMask;
|
|
704 |
}
|
|
705 |
else
|
|
706 |
{
|
|
707 |
iSpriteBitmapContext->BitBltMasked(pCurrCell->rIcon.iTl,
|
|
708 |
pCurrCell->keyBitmapImage,
|
|
709 |
TRect(TPoint(0, 0),pCurrCell->rIcon.Size() ),
|
|
710 |
pCurrCell->keyBitmapMask,
|
|
711 |
ETrue);
|
|
712 |
}
|
|
713 |
}
|
|
714 |
}
|
|
715 |
|
|
716 |
|
|
717 |
|
|
718 |
// -----------------------------------------------------------------------------
|
|
719 |
// CBrowserShortcutKeyMap::ConstructSprite
|
|
720 |
// Construct the Sprite from the bitmap and context
|
|
721 |
// -----------------------------------------------------------------------------
|
|
722 |
//
|
|
723 |
void CBrowserShortcutKeyMap::ConstructSprite()
|
|
724 |
{
|
|
725 |
iSprite = RWsSprite( CEikonEnv::Static()->WsSession() );
|
|
726 |
RWindowTreeNode *window = iContentViewContainer->DrawableWindow();
|
|
727 |
iSprite.Construct(*window,iTargetRect.iTl,ESpriteNoChildClip);
|
|
728 |
|
|
729 |
TSpriteMember spriteMem;
|
|
730 |
spriteMem.iBitmap = iSpriteBitmap;
|
|
731 |
spriteMem.iMaskBitmap = iSpriteMaskBitmap;
|
|
732 |
spriteMem.iInvertMask = ETrue;
|
|
733 |
iSprite.AppendMember(spriteMem);
|
|
734 |
|
|
735 |
iSprite.SetPosition(iTargetRect.iTl);
|
|
736 |
iSprite.Activate();
|
|
737 |
}
|
|
738 |
|
|
739 |
|
|
740 |
|
|
741 |
// -----------------------------------------------------------------------------
|
|
742 |
// CBrowserShortcutKeyMap::GetCannedImageDirL
|
|
743 |
// Utility: Get the folder where the canned image is located
|
|
744 |
// -----------------------------------------------------------------------------
|
|
745 |
//
|
|
746 |
HBufC* CBrowserShortcutKeyMap::GetCannedImageDirL( )
|
|
747 |
{
|
|
748 |
HBufC* mbmFile = NULL;
|
|
749 |
TParse parse;
|
|
750 |
|
|
751 |
// Get the drive letter where mbm resides.. it will be the same
|
|
752 |
// as this AppUi (browser ng)
|
|
753 |
CEikAppUi* pAppUI = (CEikAppUi*)(CCoeEnv::Static()->AppUi());
|
|
754 |
TFileName mbmDrive = pAppUI->Application()->DllName();
|
|
755 |
|
|
756 |
parse.Set( mbmDrive, NULL, NULL );
|
|
757 |
mbmDrive = parse.Drive();
|
|
758 |
|
|
759 |
// allocate memory for MBM file name
|
|
760 |
mbmFile = HBufC::NewL( KMaxFileName );
|
|
761 |
|
|
762 |
// assemble the MBM file name
|
|
763 |
TPtr ptr( mbmFile->Des() );
|
|
764 |
ptr.SetLength( 0 );
|
|
765 |
ptr.Append( mbmDrive );
|
|
766 |
ptr.Append( KDC_APP_BITMAP_DIR );
|
|
767 |
return mbmFile;
|
|
768 |
}
|
|
769 |
|
|
770 |
|
|
771 |
|
|
772 |
// -----------------------------------------------------------------------------
|
|
773 |
// CBrowserShortcutKeyMap::LoadSvg
|
|
774 |
// Utility: get the SVG bitmaps, etc, given its filename
|
|
775 |
// -----------------------------------------------------------------------------
|
|
776 |
//
|
|
777 |
void CBrowserShortcutKeyMap::LoadSvg(
|
|
778 |
TInt aImageId,
|
|
779 |
const TDesC& aFileName,
|
|
780 |
CFbsBitmap*& aImage ,
|
|
781 |
CFbsBitmap*& aImageMask )
|
|
782 |
{
|
|
783 |
// Don't skin icons--at least for now.
|
|
784 |
TRAPD(error, AknIconUtils::CreateIconL( aImage,
|
|
785 |
aImageMask,
|
|
786 |
aFileName,
|
|
787 |
aImageId,
|
|
788 |
aImageId+1));
|
|
789 |
|
|
790 |
if (error!=KErrNone)
|
|
791 |
{
|
|
792 |
return;
|
|
793 |
}
|
|
794 |
}
|
|
795 |
|
|
796 |
// -----------------------------------------------------------------------------
|
|
797 |
// CBrowserShortcutKeyMap::CreateDimBitmap
|
|
798 |
// Utility: Create Dimmed version of Bitmap
|
|
799 |
// -----------------------------------------------------------------------------
|
|
800 |
//
|
|
801 |
void CBrowserShortcutKeyMap::CreateDimBitmapL(
|
|
802 |
CFbsBitmap* aImage,
|
|
803 |
CFbsBitmap* aImageMask,
|
|
804 |
CFbsBitmap*& aDimImage,
|
|
805 |
CFbsBitmap*& aDimImageMask)
|
|
806 |
{
|
|
807 |
|
|
808 |
aDimImage = new ( ELeave ) CFbsBitmap;
|
|
809 |
CleanupStack::PushL( aDimImage );
|
|
810 |
|
|
811 |
aDimImage->Duplicate( aImage->Handle() );
|
|
812 |
|
|
813 |
aDimImageMask = new ( ELeave ) CFbsBitmap;
|
|
814 |
|
|
815 |
User::LeaveIfError( aDimImageMask->Create(aDimImage->SizeInPixels(),
|
|
816 |
EGray256 ) );
|
|
817 |
|
|
818 |
CleanupStack::PushL( aDimImageMask );
|
|
819 |
|
|
820 |
CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL( aDimImageMask );
|
|
821 |
CleanupStack::PushL( bitmapDevice );
|
|
822 |
|
|
823 |
CFbsBitGc* bitGc( NULL );
|
|
824 |
User::LeaveIfError( bitmapDevice->CreateContext( bitGc ) );
|
|
825 |
CleanupStack::PushL( bitGc );
|
|
826 |
|
|
827 |
bitGc->SetPenStyle( CGraphicsContext::ESolidPen );
|
|
828 |
bitGc->BitBlt( TPoint( 0, 0 ), aImageMask );
|
|
829 |
|
|
830 |
|
|
831 |
aDimImageMask->LockHeap();
|
|
832 |
TInt w = aImageMask->SizeInPixels().iWidth;
|
|
833 |
TInt h = aImageMask->SizeInPixels().iHeight;
|
|
834 |
TInt dataStride = aImageMask->DataStride() - w;
|
|
835 |
unsigned char* address = (unsigned char *)aDimImageMask->DataAddress();
|
|
836 |
|
|
837 |
for ( TInt i = 0; i < h; ++i )
|
|
838 |
{
|
|
839 |
for ( TInt j = 0; j < w; ++j )
|
|
840 |
{
|
|
841 |
*address = KTransparency[*address];
|
|
842 |
++address;
|
|
843 |
}
|
|
844 |
address += dataStride;
|
|
845 |
}
|
|
846 |
|
|
847 |
aDimImageMask->UnlockHeap();
|
|
848 |
|
|
849 |
CleanupStack::PopAndDestroy( 2 ); // bitmapDevice, bitGc
|
|
850 |
CleanupStack::Pop( 2 ); // aDimImage, aDimImageMask
|
|
851 |
|
|
852 |
|
|
853 |
}
|
|
854 |
|
|
855 |
// End of File
|