2
|
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("../debugLibrary.js")
|
|
20 |
include("../renderLibrary.js")
|
|
21 |
|
|
22 |
include("../embeddedControlImplLibrary.js")
|
|
23 |
|
|
24 |
// Calculated drawing values
|
|
25 |
// this.xValueLabelPos -- x coordinate for drawing the value label
|
|
26 |
// this.yValueLabelPos -- y coordinate for drawing the value label
|
|
27 |
// this.ySlider -- y coordinate for drawing the slider line
|
|
28 |
// this.xSliderStart -- x coordinate for drawing the start of the slider line
|
|
29 |
// this.xSliderEnd -- x coordinate for drawing the end of the slider line
|
|
30 |
// this.xMinLabelPos -- x coordinate for drawing the min label
|
|
31 |
// this.yMinLabelPos -- y coordinate for drawing the min label
|
|
32 |
// this.xMaxLabelPos -- x coordinate for drawing the max label
|
|
33 |
// this.yMaxLabelPos -- y coordinate for drawing the max label
|
|
34 |
// this.requiredHeight -- calculated height for returning in getPreferredSize
|
|
35 |
// this.requiredWidth -- calculated width for returning in getPreferredSize
|
|
36 |
|
|
37 |
CAknSliderVisual.prototype.printValues = function() {
|
|
38 |
println("this.xValueLabelPos: " + this.xValueLabelPos);
|
|
39 |
println("this.yValueLabelPos: " + this.yValueLabelPos);
|
|
40 |
println("this.ySlider: " + this.ySlider);
|
|
41 |
println("this.xSliderStart: " + this.xSliderStart);
|
|
42 |
println("this.xSliderEnd: " + this.xSliderEnd);
|
|
43 |
println("this.xMinLabelPos: " + this.xMinLabelPos);
|
|
44 |
println("this.yMinLabelPos: " + this.yMinLabelPos);
|
|
45 |
println("this.xMaxLabelPos: " + this.xMaxLabelPos);
|
|
46 |
println("this.yMaxLabelPos: " + this.yMaxLabelPos);
|
|
47 |
println("this.requiredHeight: " + this.requiredHeight);
|
|
48 |
}
|
|
49 |
|
|
50 |
function CAknSliderVisual() {
|
|
51 |
}
|
|
52 |
|
|
53 |
CAknSliderVisual.prototype.drawContent = function(instance, laf, graphics, rect) {
|
|
54 |
var properties = instance.properties;
|
|
55 |
this.calcLayout(instance, properties.layout, laf, rect);
|
|
56 |
|
|
57 |
var y = rect.height/2;
|
|
58 |
var image = this.getImage(instance, laf);
|
|
59 |
var font = laf.getFont("NormalFont");
|
|
60 |
graphics.setFont(font);
|
|
61 |
var range = properties.maxValue - properties.minValue;
|
|
62 |
|
|
63 |
var sliderStart = rect.x + this.xSliderStart;
|
|
64 |
var sliderEnd = this.xSliderEnd;
|
|
65 |
var sliderY = rect.y + this.ySlider;
|
|
66 |
if (isSettingItemList(instance.parent))
|
|
67 |
graphics.setForeground(Colors.getColor(255, 255, 255));
|
|
68 |
else
|
|
69 |
graphics.setForeground(Colors.getColor(0, 0, 0));
|
|
70 |
graphics.setLineStyle(SWT.LINE_SOLID);
|
|
71 |
graphics.drawLine(sliderStart, sliderY, sliderEnd, sliderY);
|
|
72 |
|
|
73 |
if (image != null && range > 0) {
|
|
74 |
// slider image is centered around value. Account for image
|
|
75 |
// size so we can fully draw at the min and max values
|
|
76 |
var imageBounds = image.getBounds();
|
|
77 |
var valueWidth = sliderEnd - sliderStart - 8;
|
|
78 |
|
|
79 |
var value = properties.value;
|
|
80 |
if (value < properties.minValue)
|
|
81 |
value = properties.minValue;
|
|
82 |
else if (value > properties.maxValue)
|
|
83 |
value = properties.maxValue;
|
|
84 |
|
|
85 |
var xOffset = (((value - properties.minValue)/range) * 100) * valueWidth;
|
|
86 |
xOffset = xOffset/100 -2;
|
|
87 |
y = y - imageBounds.height/2;
|
|
88 |
graphics.drawImage(image, sliderStart + xOffset, sliderY - imageBounds.height/2 + 1);
|
|
89 |
}
|
|
90 |
|
|
91 |
graphics.setBackground(getBackgroundColor(instance, laf))
|
|
92 |
drawLabel(graphics, getFormattedValue(properties), this.xValueLabelPos, this.yValueLabelPos, rect);
|
|
93 |
drawLabel(graphics, properties.minLabel, this.xMinLabelPos, this.yMinLabelPos, rect);
|
|
94 |
drawLabel(graphics, properties.maxLabel, this.xMaxLabelPos - rect.x, this.yMaxLabelPos, rect);
|
|
95 |
}
|
|
96 |
|
|
97 |
CAknSliderVisual.prototype.getContentSize = function(instance, laf, size) {
|
|
98 |
var parentWidth = instance.parent.properties.size.width;
|
|
99 |
this.calcLayout(instance, instance.properties.layout, laf, new Rectangle(0, 0, parentWidth, size.y));
|
|
100 |
return new Point(this.requiredWidth, this.requiredHeight);
|
|
101 |
}
|
|
102 |
|
|
103 |
setupEmbeddedRendering(CAknSliderVisual.prototype);
|
|
104 |
|
|
105 |
///////////
|
|
106 |
|
|
107 |
function formatSymbianString(str, val) {
|
|
108 |
return str.replace("%U", val);
|
|
109 |
}
|
|
110 |
|
|
111 |
function getFormattedValue(properties) {
|
|
112 |
var valueLabel = "";
|
|
113 |
|
|
114 |
if (properties.valueType == "EAknSliderValueBareFigure") {
|
|
115 |
if (properties.value == 1 && properties.singularValueLabel != "")
|
|
116 |
valueLabel = formatSymbianString(properties.singularValueLabel, properties.value);
|
|
117 |
else
|
|
118 |
valueLabel = "" + properties.value;
|
|
119 |
}
|
|
120 |
else if (properties.valueType == "EAknSliderValuePercentage") {
|
|
121 |
var range = properties.maxValue - properties.minValue;
|
|
122 |
var val = properties.value - properties.minValue;
|
|
123 |
var pct = (100 * val) / range;
|
|
124 |
valueLabel = pct.toFixed() + "%";
|
|
125 |
}
|
|
126 |
else if (properties.valueType == "EAknSliderValueFraction") {
|
|
127 |
valueLabel = "" + properties.value + "/" + properties.maxValue;
|
|
128 |
}
|
|
129 |
else if (properties.valueType == "EAknSliderValueDecimal") {
|
|
130 |
var decPlaces = properties.decimalPlaces;
|
|
131 |
if (decPlaces < 0 || decPlaces > 9) {
|
|
132 |
decPlaces = 0;
|
|
133 |
}
|
|
134 |
valueLabel = properties.value.toFixed(decPlaces);
|
|
135 |
}
|
|
136 |
|
|
137 |
return valueLabel;
|
|
138 |
}
|
|
139 |
|
|
140 |
function drawLabel(graphics, text, xPos, yPos, rect) {
|
|
141 |
if (xPos >= 0 && xPos >= 0) {
|
|
142 |
var availableWidth = rect.width - xPos;
|
|
143 |
text = chooseScalableText(text, graphics.getFont(), availableWidth);
|
|
144 |
graphics.drawString(text, rect.x + xPos, rect.y + yPos, true);
|
|
145 |
}
|
|
146 |
}
|
|
147 |
|
|
148 |
function getContentBounds(instance, laf) {
|
|
149 |
if (isForm(instance.parent))
|
|
150 |
return getFormContentBounds(instance, laf);
|
|
151 |
else if (isSettingItemList(instance.parent))
|
|
152 |
return getSettingItemContentBounds(instance, laf);
|
|
153 |
else
|
|
154 |
return new Rectangle(0, 0,
|
|
155 |
instance.properties.size.width, instance.properties.size.height);
|
|
156 |
|
|
157 |
}
|
|
158 |
|
|
159 |
CAknSliderVisual.prototype.getMinLabelBounds = function(instance, laf) {
|
|
160 |
var properties = instance.properties;
|
|
161 |
var extent = getLabelFont(laf).formattedStringExtent("XXXXXX", new Point(0, 0), 0, 0);
|
|
162 |
var rect = getContentBounds(instance, laf);
|
|
163 |
return new Rectangle(rect.x + this.xMinLabelPos, rect.y + this.yMinLabelPos,
|
|
164 |
extent.x, extent.y);
|
|
165 |
}
|
|
166 |
|
|
167 |
CAknSliderVisual.prototype.getMaxLabelBounds = function(instance, laf) {
|
|
168 |
var properties = instance.properties;
|
|
169 |
var extent = getLabelFont(laf).formattedStringExtent("XXXXXX", new Point(0, 0), 0, 0);
|
|
170 |
var rect = getContentBounds(instance, laf);
|
|
171 |
return new Rectangle(rect.x + this.xMaxLabelPos, rect.y + this.yMaxLabelPos,
|
|
172 |
extent.x, extent.y);
|
|
173 |
}
|
|
174 |
|
|
175 |
CAknSliderVisual.prototype.getValueLabelBounds = function(instance, laf) {
|
|
176 |
var properties = instance.properties;
|
|
177 |
var extent = getLabelFont(laf).formattedStringExtent("XXXXXX", new Point(0, 0), 0, 0);
|
|
178 |
var rect = getContentBounds(instance, laf);
|
|
179 |
return new Rectangle(rect.x + this.xValueLabelPos, rect.y + this.yValueLabelPos,
|
|
180 |
extent.x, extent.y);
|
|
181 |
}
|
|
182 |
|
|
183 |
CAknSliderVisual.prototype.getImage = function(instance, laf) {
|
|
184 |
// TODO allow for custom image
|
|
185 |
var image;
|
|
186 |
if (isSettingItemList(instance.parent))
|
|
187 |
image = laf.getImage("slider.settingslist.image")
|
|
188 |
else
|
|
189 |
image = laf.getImage("slider.image");
|
|
190 |
return image;
|
|
191 |
}
|
|
192 |
|
|
193 |
function getInset(instance, laf) {
|
|
194 |
var parentIsForm = isForm(instance.parent);
|
|
195 |
var inset = laf.getInteger("form.divider.offset.single", 10) +
|
|
196 |
2*getFormPadding(laf);
|
|
197 |
if (parentIsForm && !isDoubleSpaced(instance.parent))
|
|
198 |
inset = 0;
|
|
199 |
return inset;
|
|
200 |
}
|
|
201 |
|
|
202 |
function getFormMargin(instance, laf) {
|
|
203 |
if (isForm(instance.parent))
|
|
204 |
return 10;
|
|
205 |
|
|
206 |
return 0;
|
|
207 |
}
|
|
208 |
|
|
209 |
function getLabelFont(laf) {
|
|
210 |
return laf.getFont("NormalFont");
|
|
211 |
}
|
|
212 |
|
|
213 |
function getRowSpacing(laf) {
|
|
214 |
return laf.getInteger("slider.rowSpacing", 8);
|
|
215 |
}
|
|
216 |
|
|
217 |
CAknSliderVisual.prototype.calcFormLayout1 = function(instance, laf, rect) {
|
|
218 |
// two "rows"
|
|
219 |
// left aligned value label on top
|
|
220 |
// slider below
|
|
221 |
var properties = instance.properties;
|
|
222 |
var font = getLabelFont(laf);
|
|
223 |
var image = this.getImage(instance, laf);
|
|
224 |
var inset = getInset(instance, laf);
|
|
225 |
var rowSpacing = getRowSpacing(laf);
|
|
226 |
var imageHeight = 11;
|
|
227 |
var imageWidth = 11;
|
|
228 |
if (image != null) {
|
|
229 |
var imageBounds = image.getBounds();
|
|
230 |
imageHeight = imageBounds.height;
|
|
231 |
imageWidth = imageBounds.width;
|
|
232 |
}
|
|
233 |
this.xValueLabelPos = inset;
|
|
234 |
this.yValueLabelPos = 0;
|
|
235 |
this.ySlider = font.getHeight() + imageHeight/2 + rowSpacing;
|
|
236 |
this.xSliderStart = inset;
|
|
237 |
this.xSliderEnd = rect.width - 2*getFormPadding(laf);
|
|
238 |
this.xMinLabelPos = -1;
|
|
239 |
this.yMinLabelPos = -1;
|
|
240 |
this.xMaxLabelPos = -1;
|
|
241 |
this.yMaxLabelPos = -1;
|
|
242 |
this.requiredHeight = font.getHeight() + imageHeight + rowSpacing
|
|
243 |
+ getFormMargin(instance, laf);
|
|
244 |
this.requiredWidth = instance.parent.properties.size.width;
|
|
245 |
}
|
|
246 |
|
|
247 |
CAknSliderVisual.prototype.calcFormLayout2 = function(instance, laf, rect) {
|
|
248 |
// two "rows"
|
|
249 |
// slider on top
|
|
250 |
// min label on left, max label on right
|
|
251 |
var properties = instance.properties;
|
|
252 |
var font = getLabelFont(laf);
|
|
253 |
var image = this.getImage(instance, laf);
|
|
254 |
var inset = getInset(instance, laf);
|
|
255 |
var rowSpacing = getRowSpacing(laf);
|
|
256 |
var imageHeight = 11;
|
|
257 |
var imageWidth = 11;
|
|
258 |
if (image != null) {
|
|
259 |
var imageBounds = image.getBounds();
|
|
260 |
imageHeight = imageBounds.height;
|
|
261 |
imageWidth = imageBounds.width;
|
|
262 |
}
|
|
263 |
this.ySlider = imageHeight/2;
|
|
264 |
this.xSliderStart = inset;
|
|
265 |
this.xSliderEnd = rect.width - 2*getFormPadding(laf);
|
|
266 |
|
|
267 |
this.xMinLabelPos = inset;
|
|
268 |
this.yMinLabelPos = imageHeight + rowSpacing;
|
|
269 |
|
|
270 |
// may need to be smarter about available width
|
|
271 |
var text = chooseScalableText(properties.maxLabel, font, rect.width);
|
|
272 |
var maxLabelExtent = font.stringExtent(text);
|
|
273 |
this.xMaxLabelPos = rect.width - maxLabelExtent.x;
|
|
274 |
this.yMaxLabelPos = this.yMinLabelPos;
|
|
275 |
|
|
276 |
this.xValueLabelPos = -1;
|
|
277 |
this.yValueLabelPos = -1;
|
|
278 |
this.requiredHeight = font.getHeight() + imageHeight + rowSpacing
|
|
279 |
+ getFormMargin(instance, laf);
|
|
280 |
this.requiredWidth = instance.parent.properties.size.width;
|
|
281 |
}
|
|
282 |
|
|
283 |
CAknSliderVisual.prototype.calcFormLayout3 = function(instance, laf, rect) {
|
|
284 |
// three "rows"
|
|
285 |
// 1: value on left
|
|
286 |
// 2: slider
|
|
287 |
// 3: min label on left, max label on right
|
|
288 |
var properties = instance.properties;
|
|
289 |
var font = getLabelFont(laf);
|
|
290 |
var image = this.getImage(instance, laf);
|
|
291 |
var inset = getInset(instance, laf);
|
|
292 |
var rowSpacing = getRowSpacing(laf);
|
|
293 |
var imageHeight = 11;
|
|
294 |
var imageWidth = 11;
|
|
295 |
if (image != null) {
|
|
296 |
var imageBounds = image.getBounds();
|
|
297 |
imageHeight = imageBounds.height;
|
|
298 |
imageWidth = imageBounds.width;
|
|
299 |
}
|
|
300 |
this.xValueLabelPos = inset;
|
|
301 |
this.yValueLabelPos = 0;
|
|
302 |
this.ySlider = font.getHeight() + imageHeight/2 + rowSpacing;
|
|
303 |
this.xSliderStart = inset;
|
|
304 |
this.xSliderEnd = rect.width - 2*getFormPadding(laf);
|
|
305 |
|
|
306 |
this.xMinLabelPos = inset;
|
|
307 |
this.yMinLabelPos = imageHeight + font.getHeight() + 2*rowSpacing;
|
|
308 |
|
|
309 |
// may need to be smarter about available width
|
|
310 |
var text = chooseScalableText(properties.maxLabel, font, rect.width);
|
|
311 |
var maxLabelExtent = font.stringExtent(text);
|
|
312 |
this.xMaxLabelPos = rect.width - maxLabelExtent.x;
|
|
313 |
this.yMaxLabelPos = this.yMinLabelPos;
|
|
314 |
|
|
315 |
this.requiredHeight = 2*font.getHeight() + imageHeight + 2*rowSpacing;
|
|
316 |
+ getFormMargin(instance, laf);
|
|
317 |
this.requiredWidth = instance.parent.properties.size.width;
|
|
318 |
}
|
|
319 |
|
|
320 |
// not used since we don't render the full screen
|
|
321 |
CAknSliderVisual.prototype.calcSettingsItemLayout_full = function(instance, laf, rect) {
|
|
322 |
// four "rows"
|
|
323 |
// 1: value label on left, indented
|
|
324 |
// 2: blank
|
|
325 |
// 3: slider
|
|
326 |
// 4: min label on left, max label on right
|
|
327 |
var properties = instance.properties;
|
|
328 |
var font = getLabelFont(laf);
|
|
329 |
var image = this.getImage(instance, laf);
|
|
330 |
var rowSpacing = getRowSpacing(laf);
|
|
331 |
var padding = getSILPaddingX(laf);
|
|
332 |
var imageHeight = 11;
|
|
333 |
var imageWidth = 11;
|
|
334 |
if (image != null) {
|
|
335 |
var imageBounds = image.getBounds();
|
|
336 |
imageHeight = imageBounds.height;
|
|
337 |
imageWidth = imageBounds.width;
|
|
338 |
}
|
|
339 |
var valueLabelIndent = 20; // TODO - determine indent
|
|
340 |
this.xValueLabelPos = valueLabelIndent;
|
|
341 |
this.yValueLabelPos = 0;
|
|
342 |
|
|
343 |
var blankRowHeight = font.getHeight()*2; // TODO - determine this height
|
|
344 |
|
|
345 |
this.ySlider = blankRowHeight + font.getHeight() + imageHeight/2 + rowSpacing;
|
|
346 |
this.xSliderStart = 10;
|
|
347 |
this.xSliderEnd = rect.width - (imageBounds.width/2 + 3*padding);
|
|
348 |
|
|
349 |
this.xMinLabelPos = this.xSliderStart;
|
|
350 |
this.yMinLabelPos = this.ySlider + imageHeight/2;
|
|
351 |
|
|
352 |
// may need to be smarter about available width
|
|
353 |
var text = chooseScalableText(properties.maxLabel, font, rect.width);
|
|
354 |
var maxLabelExtent = font.stringExtent(text);
|
|
355 |
this.xMaxLabelPos = rect.width - (maxLabelExtent.x + padding);
|
|
356 |
this.yMaxLabelPos = this.yMinLabelPos;
|
|
357 |
|
|
358 |
this.requiredHeight = this.yMaxLabelPos + maxLabelExtent.y;
|
|
359 |
this.requiredWidth = rect.width - padding;
|
|
360 |
}
|
|
361 |
|
|
362 |
// we show only the slider bar
|
|
363 |
CAknSliderVisual.prototype.calcSettingsItemLayout = function(instance, laf, rect) {
|
|
364 |
// one row
|
|
365 |
// 1: slider
|
|
366 |
var properties = instance.properties;
|
|
367 |
var font = getLabelFont(laf);
|
|
368 |
var image = this.getImage(instance, laf);
|
|
369 |
var rowSpacing = getRowSpacing(laf);
|
|
370 |
var padding = getSILPaddingX(laf);
|
|
371 |
var imageHeight = 12;
|
|
372 |
var imageWidth = 12;
|
|
373 |
if (image != null) {
|
|
374 |
var imageBounds = image.getBounds();
|
|
375 |
imageHeight = imageBounds.height;
|
|
376 |
imageWidth = imageBounds.width;
|
|
377 |
}
|
|
378 |
var blankRowHeight = font.getHeight();
|
|
379 |
this.ySlider = blankRowHeight / 2 ;
|
|
380 |
this.xSliderStart = 10;
|
|
381 |
this.xSliderEnd = rect.width - (imageBounds.width/2 + 3*padding);
|
|
382 |
|
|
383 |
this.xValueLabelPos = -1;
|
|
384 |
this.yValueLabelPos = -1;
|
|
385 |
this.xMinLabelPos = -1;
|
|
386 |
this.yMinLabelPos = -1;
|
|
387 |
this.xMaxLabelPos = -1;
|
|
388 |
this.yMaxLabelPos = -1;
|
|
389 |
|
|
390 |
this.requiredHeight = font.getHeight();
|
|
391 |
this.requiredWidth = rect.width - padding;
|
|
392 |
}
|
|
393 |
|
|
394 |
CAknSliderVisual.prototype.calcSettingsItemLayoutWithGraphics = function(instance, laf, rect) {
|
|
395 |
this.calcSettingsItemLayout(instance, laf, rect);
|
|
396 |
}
|
|
397 |
|
|
398 |
// use this form instead of switch()
|
|
399 |
layoutTable = {
|
|
400 |
"EAknFormSliderLayout1" : CAknSliderVisual.prototype.calcFormLayout1,
|
|
401 |
"EAknFormSliderLayout2" : CAknSliderVisual.prototype.calcFormLayout2,
|
|
402 |
"EAknFormSliderLayout3" : CAknSliderVisual.prototype.calcFormLayout3,
|
|
403 |
"EAknSettingsItemSliderLayout" : CAknSliderVisual.prototype.calcSettingsItemLayout,
|
|
404 |
"EAknSettingsItemSliderLayoutWithGraphics" : CAknSliderVisual.prototype.calcSettingsItemLayoutWithGraphics
|
|
405 |
}
|
|
406 |
|
|
407 |
CAknSliderVisual.prototype.calcLayout = function(instance, layout, laf, rect) {
|
|
408 |
// get the prototype function out of the table, and call the function
|
|
409 |
// apply calls the function
|
|
410 |
// this is passed explicitly and the other arguments are passed in an array
|
|
411 |
layoutTable[layout].apply(this, [instance, laf, rect]);
|
|
412 |
}
|
|
413 |
|
|
414 |
// IDirectLabelEdit
|
|
415 |
CAknSliderVisual.prototype.getPropertyPaths = function(instance) {
|
|
416 |
var properties = instance.properties;
|
|
417 |
var paths = new Array;
|
|
418 |
if (isForm(instance.parent))
|
|
419 |
paths = paths.concat(["prompt"]);
|
|
420 |
|
|
421 |
if (isSettingItemList(instance.parent))
|
|
422 |
paths = paths.concat(["itemTitle", "compulsoryLabel"]);
|
|
423 |
|
|
424 |
if (this.xValueLabelPos != -1)
|
|
425 |
paths = paths.concat(["value"]);
|
|
426 |
|
|
427 |
if (this.xMinLabelPos != -1)
|
|
428 |
paths = paths.concat = ["minLabel", "maxLabel"];
|
|
429 |
|
|
430 |
return paths;
|
|
431 |
}
|
|
432 |
|
|
433 |
CAknSliderVisual.prototype.getLabelBounds = function(instance, propertyPath, laf) {
|
|
434 |
if (isForm(instance.parent)) {
|
|
435 |
if (propertyPath == "prompt") {
|
|
436 |
return getFormItemRectangles(instance, laf)[PROMPT_LABEL_RECT_INDEX];
|
|
437 |
}
|
|
438 |
}
|
|
439 |
if (isSettingItemList(instance.parent)) {
|
|
440 |
var rects = getSettingItemRectangles(instance, laf);
|
|
441 |
if (propertyPath == "itemTitle") {
|
|
442 |
return rects[SIL_TITLE_RECT_INDEX];
|
|
443 |
}
|
|
444 |
if (propertyPath == "compulsoryLabel") {
|
|
445 |
return rects[SIL_INDICATOR_RECT_INDEX];
|
|
446 |
}
|
|
447 |
}
|
|
448 |
|
|
449 |
|
|
450 |
var properties = instance.properties;
|
|
451 |
var rect = getContentBounds(instance, laf);
|
|
452 |
this.calcLayout(instance, properties.layout, laf, rect);
|
|
453 |
|
|
454 |
if (propertyPath == "minLabel")
|
|
455 |
return this.getMinLabelBounds(instance, laf);
|
|
456 |
|
|
457 |
if (propertyPath == "maxLabel")
|
|
458 |
return this.getMaxLabelBounds(instance, laf);
|
|
459 |
|
|
460 |
if (propertyPath == "value")
|
|
461 |
return this.getValueLabelBounds(instance, laf);
|
|
462 |
|
|
463 |
return new Rectangle(0,0,0,0);
|
|
464 |
}
|
|
465 |
|
|
466 |
CAknSliderVisual.prototype.getFont = function(instance, propertyPath, laf) {
|
|
467 |
if (propertyPath == "prompt")
|
|
468 |
return getPromptFont(laf);
|
|
469 |
|
|
470 |
return getLabelFont(laf);
|
|
471 |
}
|
|
472 |
|
|
473 |
CAknSliderVisual.prototype.propertyChanged = function(instance, propertyID, laf) {
|
|
474 |
if (isForm(instance.parent) || isSettingItemList(instance.parent))
|
|
475 |
return;
|
|
476 |
var properties = instance.properties;
|
|
477 |
if (propertyID == "layout") {
|
|
478 |
var parentWidth = instance.parent.properties.size.width;
|
|
479 |
this.calcLayout(instance, instance.properties.layout, laf, new Rectangle(0, 0, parentWidth, 0));
|
|
480 |
if (this.requiredWidth == parentWidth &&
|
|
481 |
instance.properties.location != 0) {
|
|
482 |
instance.properties.location.x = 0;
|
|
483 |
}
|
|
484 |
instance.properties.size.width = this.requiredWidth;
|
|
485 |
instance.properties.size.height = this.requiredHeight;
|
|
486 |
}
|
|
487 |
// we need to guard against recursive notifications when changing
|
|
488 |
// the location property
|
|
489 |
else if (propertyID == "location" && !this.inLocationChanged) {
|
|
490 |
this.inLocationChanged = true;
|
|
491 |
var parentWidth = instance.parent.properties.size.width;
|
|
492 |
this.calcLayout(instance, instance.properties.layout, laf, new Rectangle(0, 0, parentWidth, 0));
|
|
493 |
if (this.requiredWidth == parentWidth &&
|
|
494 |
instance.properties.location != 0) {
|
|
495 |
instance.properties.location.x = 0;
|
|
496 |
}
|
|
497 |
this.inLocationChanged = false;
|
|
498 |
}
|
|
499 |
}
|
|
500 |
|
|
501 |
|
|
502 |
setupCommonEmbeddedDirectImageEditing(CAknSliderVisual.prototype);
|
|
503 |
setupEmbeddedImagePropertyInfo(CAknSliderVisual.prototype);
|
|
504 |
|
|
505 |
// note that laf will be null if a display model was not created
|
|
506 |
CAknSliderVisual.prototype.validate = function(instance, laf) {
|
|
507 |
return null;
|
|
508 |
}
|
|
509 |
|
|
510 |
// note that laf will be null if a display model was not created
|
|
511 |
CAknSliderVisual.prototype.queryPropertyChange = function(instance, propertyPath,
|
|
512 |
newValue, laf) {
|
|
513 |
var properties = instance.properties;
|
|
514 |
var message = null;
|
|
515 |
newValue = newValue - 0;
|
|
516 |
if (propertyPath == "maxValue") {
|
|
517 |
if (properties.minValue >= newValue || newValue < properties.value) {
|
|
518 |
message = formatString(lookupString("maxValueConstraint"),
|
|
519 |
newValue, properties.minValue, properties.value);
|
|
520 |
} else if ((newValue - properties.minValue) % properties.step != 0) {
|
|
521 |
message = formatString(lookupString("minMaxStepConstraint"),
|
|
522 |
newValue, properties.maxValue, properties.minValue,
|
|
523 |
properties.maxValue - properties.minValue);
|
|
524 |
}
|
|
525 |
} else if (propertyPath == "minValue") {
|
|
526 |
if (properties.maxValue <= newValue || newValue > properties.value) {
|
|
527 |
message = formatString(lookupString("minValueConstraint"),
|
|
528 |
newValue, properties.maxValue, properties.value);
|
|
529 |
} else if ((properties.maxValue - newValue) % properties.step != 0) {
|
|
530 |
message = formatString(lookupString("minMaxStepConstraint"),
|
|
531 |
newValue, properties.maxValue, properties.minValue,
|
|
532 |
properties.maxValue - properties.minValue);
|
|
533 |
}
|
|
534 |
} else if (propertyPath == "value") {
|
|
535 |
if (properties.maxValue < newValue || newValue < properties.minValue) {
|
|
536 |
message = formatString(lookupString("valueConstraint"),
|
|
537 |
newValue, properties.minValue, properties.maxValue);
|
|
538 |
} else if ((newValue - properties.minValue) % properties.step != 0) {
|
|
539 |
message = formatString(lookupString("valueStepConstraint"),
|
|
540 |
newValue, properties.minValue,
|
|
541 |
newValue - properties.minValue, properties.step);
|
|
542 |
}
|
|
543 |
} else if (propertyPath == "step") {
|
|
544 |
if ((properties.maxValue - properties.minValue) % newValue != 0) {
|
|
545 |
message = formatString(lookupString("stepConstraint"),
|
|
546 |
newValue, properties.maxValue, properties.minValue,
|
|
547 |
properties.maxValue - properties.minValue);
|
|
548 |
} else if ((properties.value - properties.minValue) % newValue != 0
|
|
549 |
|| (properties.maxValue - properties.value) % newValue != 0) {
|
|
550 |
message = formatString(lookupString("stepValueConstraint"),
|
|
551 |
newValue, properties.value, properties.minValue,
|
|
552 |
properties.value - properties.minValue);
|
|
553 |
}
|
|
554 |
}
|
|
555 |
return message;
|
|
556 |
}
|