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 |
function NaviTextVisual() {
|
|
20 |
}
|
|
21 |
|
|
22 |
NaviTextVisual.prototype.draw = function(instance, laf, graphics) {
|
|
23 |
var properties = instance.properties;
|
|
24 |
|
|
25 |
var flags = Font.ANTIALIAS_OFF;
|
|
26 |
|
|
27 |
var align = laf.getInteger("navi.text.align.weight", -1);
|
|
28 |
switch (align) {
|
|
29 |
case 1:
|
|
30 |
flags |= Font.ALIGN_RIGHT;
|
|
31 |
break;
|
|
32 |
case 0:
|
|
33 |
flags |= Font.ALIGN_CENTER;
|
|
34 |
break;
|
|
35 |
default:
|
|
36 |
flags |= Font.ALIGN_LEFT;
|
|
37 |
break;
|
|
38 |
}
|
|
39 |
|
|
40 |
var rect = new Rectangle(0, 0,
|
|
41 |
properties.size.width, properties.size.height)
|
|
42 |
|
|
43 |
// oops, can't do this since we don't own the leftmost part...
|
|
44 |
graphics.setBackground(laf.getColor("status.bar.gradient.start"))
|
|
45 |
//graphics.fillRectangle(rect);
|
|
46 |
|
|
47 |
var color = laf.getColor("navi.pane.text");
|
|
48 |
|
|
49 |
var font = laf.getFont("navi.text.font");
|
|
50 |
graphics.setFont(font);
|
|
51 |
graphics.setForeground(color);
|
|
52 |
|
|
53 |
var text = chooseScalableText(properties.text, font, rect.width);
|
|
54 |
|
|
55 |
var extent = font.stringExtent(text);
|
|
56 |
var newrect = new Rectangle(0, (rect.height - extent.y) / 2, rect.width, rect.height)
|
|
57 |
graphics.drawFormattedString(properties.text,
|
|
58 |
newrect, flags, 0);
|
|
59 |
}
|
|
60 |
|
|
61 |
NaviTextVisual.prototype.getPreferredSize = function(instance, laf, wHint, hHint) {
|
|
62 |
return null; // needs implementation
|
|
63 |
}
|
|
64 |
|
|
65 |
// IDirectLabelEdit
|
|
66 |
NaviTextVisual.prototype.getPropertyPaths = function(instance) {
|
|
67 |
return new Array("text");
|
|
68 |
}
|
|
69 |
|
|
70 |
NaviTextVisual.prototype.getLabelBounds = function(instance, propertyPath, laf) {
|
|
71 |
return new Rectangle(0, 0,
|
|
72 |
instance.properties.size.width, instance.properties.size.height);
|
|
73 |
}
|
|
74 |
|
|
75 |
NaviTextVisual.prototype.getLabelFont = function(instance, propertyPath, laf) {
|
|
76 |
return laf.getFont("navi.text.font");
|
|
77 |
}
|
|
78 |
|