|
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("../containers/containerLibrary.js") |
|
23 include("popupDialogLibrary.js") |
|
24 |
|
25 function MultiLineDataQueryVisual() { |
|
26 } |
|
27 |
|
28 MultiLineDataQueryVisual.prototype.draw = function(instance, laf, graphics) { |
|
29 var properties = instance.properties; |
|
30 |
|
31 // first draw the CBA |
|
32 var leftText = lookupString("Ok"); |
|
33 var rightText = lookupString("Cancel"); |
|
34 var middleText = ""; |
|
35 var r = laf.getRectangle("control.pane.bounds"); |
|
36 var rect = new Rectangle(r.x, r.y, r.width, r.height); |
|
37 rect.x -= properties.location.x; |
|
38 rect.y -= properties.location.y; |
|
39 drawCBA(leftText, rightText, middleText, new Point(rect.x, rect.y), new Point(rect.width, rect.height), laf, graphics); |
|
40 |
|
41 // then draw the query dialog |
|
42 var flags = Font.ALIGN_LEFT; |
|
43 rect = calculateMultiDataQueryBounds(properties, laf, flags); |
|
44 drawPopupDialog(instance, laf, graphics, flags, rect, getIconRect(0, laf), 0); |
|
45 } |
|
46 |
|
47 function calculateMultiDataQueryBounds(properties, laf, flags) { |
|
48 var rect; |
|
49 |
|
50 // calculate the bounds of the dialog (just like a note) |
|
51 var bounds = calculateBounds(properties, laf, flags, 0, 0); |
|
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 MultiLineDataQueryVisual.prototype.getPreferredSize = function(instance, laf, wHint, hHint) { |
|
62 return null; |
|
63 } |
|
64 |
|
65 // IDirectLabelEdit |
|
66 MultiLineDataQueryVisual.prototype.getPropertyPaths = function(instance) { |
|
67 return ["text", "text2"]; |
|
68 } |
|
69 |
|
70 MultiLineDataQueryVisual.prototype.getLabelBounds = function(instance, propertyPath, laf) { |
|
71 var properties = instance.properties; |
|
72 var flags = Font.ALIGN_LEFT; |
|
73 rect = calculateMultiDataQueryBounds(properties, laf, flags); |
|
74 |
|
75 return rect; |
|
76 } |
|
77 |
|
78 MultiLineDataQueryVisual.prototype.getLabelFont = function(instance, propertyPath, laf) { |
|
79 return laf.getFont("message.font"); |
|
80 } |
|
81 |
|
82 MultiLineDataQueryVisual.prototype.layout = function(instance, laf) { |
|
83 var properties = instance.properties; |
|
84 var portrait = laf.getBoolean("is.portrait", true); |
|
85 |
|
86 var flags = Font.ALIGN_LEFT; |
|
87 var rect = calculateBounds(properties, laf, flags, 0, 0); |
|
88 var d = laf.getDimension("screen.size"); |
|
89 |
|
90 if (portrait) { |
|
91 properties.location.x = 0; |
|
92 properties.location.y = rect.y; |
|
93 properties.size.width = d.x; |
|
94 properties.size.height = d.y - rect.y; |
|
95 } |
|
96 else { |
|
97 properties.location.x = rect.x; |
|
98 properties.location.y = 0; |
|
99 properties.size.width = d.x - rect.x; |
|
100 properties.size.height = d.y; |
|
101 } |
|
102 |
|
103 // println("rect="+rect); |
|
104 var child0 = instance.children[0]; |
|
105 if (child0 != null) { |
|
106 var dims = laf.getRectangle("query.editor"); |
|
107 // println("dims0="+dims); |
|
108 if (portrait) { |
|
109 child0.properties.location.x = rect.x + dims.x; |
|
110 child0.properties.location.y = dims.y; |
|
111 } |
|
112 else { |
|
113 child0.properties.location.x = dims.x; |
|
114 child0.properties.location.y = rect.y + dims.y; |
|
115 } |
|
116 child0.properties.size.width = rect.width - dims.width; |
|
117 child0.properties.size.height = dims.height; |
|
118 } |
|
119 |
|
120 var child1 = instance.children[0]; |
|
121 if (child1 != null) { |
|
122 var dims = laf.getRectangle("query.editor"); |
|
123 //println("dims1="+dims); |
|
124 if (portrait) { |
|
125 child1.properties.location.x = rect.x + dims.x; |
|
126 child1.properties.location.y = dims.y; |
|
127 } |
|
128 else { |
|
129 child1.properties.location.x = dims.x; |
|
130 child1.properties.location.y = rect.y + dims.y; |
|
131 } |
|
132 child1.properties.size.width = rect.width - dims.width; |
|
133 child1.properties.size.height = dims.height; |
|
134 } |
|
135 } |
|
136 |
|
137 ///////////////////// |
|
138 |
|
139 |
|
140 function MultiLineDataQueryContainment() { |
|
141 } |
|
142 |
|
143 function hasChildren(instance) { |
|
144 return (instance.children != null) && (instance.children.length > 1); |
|
145 } |
|
146 |
|
147 MultiLineDataQueryContainment.prototype.canContainComponent = function(instance, otherComponent) { |
|
148 if (hasChildren(instance)) { |
|
149 return buildSimpleContainmentErrorStatus( |
|
150 lookupString("twoChildContainmentError"), null); |
|
151 } |
|
152 |
|
153 return null; |
|
154 } |
|
155 |
|
156 MultiLineDataQueryContainment.prototype.canContainChild = function(instance, child) { |
|
157 if (hasChildren(instance)) { |
|
158 return buildSimpleContainmentErrorStatus( |
|
159 lookupString("twoChildContainmentError"), null); |
|
160 } |
|
161 |
|
162 return null; |
|
163 } |
|
164 |
|
165 MultiLineDataQueryContainment.prototype.canRemoveChild = function(instance, child) { |
|
166 return false; |
|
167 } |
|
168 |
|
169 MultiLineDataQueryContainment.prototype.isValidComponentInPalette = function(instance, otherComponent) { |
|
170 return true; |
|
171 } |
|
172 |
|
173 MultiLineDataQueryContainment.prototype.getAllowedAttribute = function() { |
|
174 return "is-dataquery-content"; |
|
175 } |
|
176 |
|
177 setupAttributeBasedQueryContainment(MultiLineDataQueryContainment.prototype); |
|
178 |
|
179 MultiLineDataQueryContainment.prototype.propertyChanged = function(instance, property) { |
|
180 if ((property == "text") || (property == "text2")) { |
|
181 instance.forceLayout(); |
|
182 } |
|
183 } |
|
184 |
|
185 |