|
1 /* |
|
2 * Copyright (c) 2006 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 include("../implLibrary.js") |
|
20 include("../renderLibrary.js") |
|
21 include("../srcgenLibrary.js") |
|
22 |
|
23 function NaviVolumeVisual() { |
|
24 } |
|
25 |
|
26 function getNaviSize(instance, laf) { |
|
27 var properties = instance.properties; |
|
28 return new Point(properties.size.width, properties.size.height); |
|
29 } |
|
30 |
|
31 function getIconRect(instance, laf) { |
|
32 |
|
33 var iconRect = (0,0,10,10); |
|
34 return iconRect; |
|
35 } |
|
36 |
|
37 function volumeImage(instance, laf) { |
|
38 var properties = instance.properties; |
|
39 var icon = laf.getImage("volume_speaker_indicator"); // default |
|
40 |
|
41 switch (properties.volumeType) { |
|
42 case "R_AVKON_NAVI_PANE_VOLUME_INDICATOR": |
|
43 icon = laf.getImage("volume_speaker_indicator"); |
|
44 break; |
|
45 case "R_AVKON_NAVI_PANE_RECORDER_VOLUME_INDICATOR": |
|
46 icon = laf.getImage("volume_mic_indicator"); |
|
47 break; |
|
48 case "R_AVKON_NAVI_PANE_EARPIECE_VOLUME_INDICATOR": |
|
49 icon = laf.getImage("volume_earpiece_indicator"); |
|
50 break; |
|
51 } |
|
52 return icon; |
|
53 } |
|
54 |
|
55 NaviVolumeVisual.prototype.draw = function(instance, laf, graphics) { |
|
56 |
|
57 var icon = volumeImage(instance, laf); |
|
58 var iconRect = getIconRect(instance, laf); |
|
59 var size = getNaviSize(instance, laf); |
|
60 var rect = new Rectangle(0, 0, size.x, size.y); |
|
61 |
|
62 var rectIcon = new Rectangle(0, 0, size.y, size.y); |
|
63 var rectBar = new Rectangle(0, 0, (size.x - rectIcon.width), size.y); |
|
64 var doBlend = false; |
|
65 if (icon != null) { |
|
66 var imageData = icon.getImageData(); |
|
67 graphics.setBackground(getBackgroundColor(instance, laf)); |
|
68 var screenBackground = laf.getColor("screen.background"); |
|
69 graphics.setBackground(screenBackground); |
|
70 drawImage(instance, graphics, icon, rectIcon, doBlend); |
|
71 } |
|
72 |
|
73 //println(graphics.getBackground()); |
|
74 |
|
75 drawBar (instance, laf, graphics, rectBar); |
|
76 } |
|
77 |
|
78 |
|
79 function drawBar(instance, laf, graphics, rect) { |
|
80 var properties = instance.properties; |
|
81 |
|
82 var arcWidth = laf.getInteger("naviVolume.bar.arcWidth", 2); |
|
83 var arcHeight = laf.getInteger("naviVolume.bar.arcHeight", 2); |
|
84 var barSize = laf.getInteger("naviVolume.bar.width", 4); |
|
85 var space = laf.getInteger ("naviVolume.bar.space", 1); |
|
86 |
|
87 var barSpace = barSize + space; |
|
88 var hpadding = rect.width - barSpace * 10 +40; |
|
89 var vpadding = laf.getInteger("volume.padding.height", 4)+2; |
|
90 var width = rect.width - hpadding; |
|
91 var height = rect.height - vpadding; |
|
92 |
|
93 var onColor = laf.getColor("volume.settingitem.onColor"); |
|
94 var offColor = laf.getColor("volume.settingitem.offColor"); |
|
95 |
|
96 for (var v = 0; v < 10; v++) { |
|
97 if (v <= properties.value) |
|
98 graphics.setBackground(onColor); |
|
99 else |
|
100 graphics.setBackground(offColor); |
|
101 |
|
102 var x = Math.floor(hpadding/2 + v * barSpace); |
|
103 var barHeight = Math.floor((v + 1) * height / 10)+2; |
|
104 var y = (height - barHeight + vpadding/2); |
|
105 |
|
106 graphics.fillRoundRectangle(x, y, barSize, barHeight, arcWidth, arcHeight); |
|
107 graphics.setForeground(laf.getColor("navi.volume.shade")); |
|
108 graphics.drawRoundRectangle(x, y, barSize, barHeight, arcWidth, arcHeight); |
|
109 |
|
110 } |
|
111 } |