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("../renderLibrary.js")
|
|
20 |
include("../messageLibrary.js")
|
|
21 |
include("../cba/cbaLibrary.js")
|
|
22 |
include("popupDialogLibrary.js")
|
|
23 |
|
|
24 |
function ConfirmationQueryVisual() {
|
|
25 |
}
|
|
26 |
|
|
27 |
ConfirmationQueryVisual.prototype.draw = function(instance, laf, graphics) {
|
|
28 |
var properties = instance.properties;
|
|
29 |
|
|
30 |
// first draw the CBA
|
|
31 |
var leftText = lookupString("Yes");
|
|
32 |
var rightText = lookupString("No");
|
|
33 |
var middleText = "";
|
|
34 |
var r = laf.getRectangle("control.pane.bounds");
|
|
35 |
var rect = new Rectangle(r.x, r.y, r.width, r.height);
|
|
36 |
rect.x -= properties.location.x;
|
|
37 |
rect.y -= properties.location.y;
|
|
38 |
drawCBA(leftText, rightText, middleText, new Point(rect.x, rect.y), new Point(rect.width, rect.height), laf, graphics);
|
|
39 |
|
|
40 |
// then draw the query dialog
|
|
41 |
var iconRect = getIconRect(getLeftOfDialogWithCBA(laf), laf);
|
|
42 |
var flags = Font.ALIGN_LEFT | Font.WRAPPING_ENABLED;
|
|
43 |
rect = calculateQueryBounds(properties, laf, flags, iconRect);
|
|
44 |
drawPopupDialog(instance, laf, graphics, flags, rect, iconRect, getLeftOfDialogWithCBA(laf));
|
|
45 |
}
|
|
46 |
|
|
47 |
function calculateQueryBounds(properties, laf, flags, iconRect) {
|
|
48 |
var rect;
|
|
49 |
|
|
50 |
// calculate the bounds of the dialog (just like a note)
|
|
51 |
var bounds = calculateBounds(properties, laf, flags, iconRect.x, getLeftOfDialogWithCBA(laf));
|
|
52 |
var portrait = laf.getBoolean("is.portrait", true);
|
|
53 |
if (portrait)
|
|
54 |
rect = new Rectangle(bounds.x, 0, bounds.width, bounds.height);
|
|
55 |
else
|
|
56 |
rect = new Rectangle(0, bounds.y, bounds.width, bounds.height);
|
|
57 |
|
|
58 |
return rect;
|
|
59 |
}
|
|
60 |
|
|
61 |
ConfirmationQueryVisual.prototype.getPreferredSize = function(instance, laf, wHint, hHint) {
|
|
62 |
return null;
|
|
63 |
}
|
|
64 |
|
|
65 |
// IDirectLabelEdit
|
|
66 |
ConfirmationQueryVisual.prototype.getPropertyPaths = function(instance) {
|
|
67 |
return new Array("text");
|
|
68 |
}
|
|
69 |
|
|
70 |
ConfirmationQueryVisual.prototype.getLabelBounds = function(instance, propertyPath, laf) {
|
|
71 |
var properties = instance.properties;
|
|
72 |
var iconRect = getIconRect(getLeftOfDialogWithCBA(laf), laf);
|
|
73 |
var flags = Font.ALIGN_LEFT | Font.WRAPPING_ENABLED;
|
|
74 |
rect = calculateQueryBounds(properties, laf, flags, iconRect);
|
|
75 |
rect.width -= iconRect.width;
|
|
76 |
|
|
77 |
return rect;
|
|
78 |
}
|
|
79 |
|
|
80 |
ConfirmationQueryVisual.prototype.getLabelFont = function(instance, propertyPath, laf) {
|
|
81 |
return laf.getFont("message.font");
|
|
82 |
}
|
|
83 |
|
|
84 |
ConfirmationQueryVisual.prototype.layout = function(instance, laf) {
|
|
85 |
var properties = instance.properties;
|
|
86 |
var portrait = laf.getBoolean("is.portrait", true);
|
|
87 |
|
|
88 |
var flags = Font.ALIGN_LEFT | Font.WRAPPING_ENABLED;
|
|
89 |
var iconRect = getIconRect(getLeftOfDialogWithCBA(laf), laf);
|
|
90 |
var rect = calculateBounds(properties, laf, flags, iconRect.x, getLeftOfDialogWithCBA(laf));
|
|
91 |
var d = laf.getDimension("screen.size");
|
|
92 |
|
|
93 |
if (portrait) {
|
|
94 |
properties.location.x = 0;
|
|
95 |
properties.location.y = rect.y;
|
|
96 |
properties.size.width = d.x;
|
|
97 |
properties.size.height = d.y - rect.y;
|
|
98 |
}
|
|
99 |
else {
|
|
100 |
properties.location.x = rect.x;
|
|
101 |
properties.location.y = 0;
|
|
102 |
properties.size.width = d.x - rect.x;
|
|
103 |
properties.size.height = d.y;
|
|
104 |
}
|
|
105 |
}
|
|
106 |
|
|
107 |
ConfirmationQueryVisual.prototype.propertyChanged = function(instance, property) {
|
|
108 |
if (property == "text") {
|
|
109 |
instance.forceLayout();
|
|
110 |
}
|
|
111 |
}
|
|
112 |
|