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 |
// Get the width and height of the toolbar in a Point.
|
|
20 |
// instance - the toolbar instance to get the width and height of
|
|
21 |
// laf - local laf
|
|
22 |
function getToolBarSize(instance, laf){
|
|
23 |
|
|
24 |
props = instance.properties;
|
|
25 |
var isSmallBar = props.smallToolbar == true ? true : false;
|
|
26 |
var toolBarMarginPadding = laf.getInteger("control.toolbar.margin", 0);
|
|
27 |
var toolBarWidth = laf.getInteger("control.toolbar.height", 0);
|
|
28 |
var toolBarHeight = toolBarWidth;
|
|
29 |
var isHorizontal = props.orientation == "Horizontal" ? true : false;
|
|
30 |
|
|
31 |
if (isSmallBar){
|
|
32 |
toolBarMarginPadding = 0;
|
|
33 |
toolBarHeight /= 2;
|
|
34 |
toolBarWidth /= 2;
|
|
35 |
}
|
|
36 |
|
|
37 |
var numChillens = instance.children.length;
|
|
38 |
var childWidth = 0;
|
|
39 |
|
|
40 |
if (isHorizontal) {
|
|
41 |
var lastChildWasNull = false; // for some reason the width is zero after dragging an item in from the main pane
|
|
42 |
for (var i in instance.children) {
|
|
43 |
var child = instance.children[i];
|
|
44 |
var childProperties = child.properties;
|
|
45 |
childWidth += childProperties.size.width;
|
|
46 |
if (lastChildWasNull == true) {
|
|
47 |
lastChildWasNull = false;
|
|
48 |
childWidth += childWidth;
|
|
49 |
}
|
|
50 |
if (childProperties.size.width == 0) {
|
|
51 |
lastChildWasNull = true;
|
|
52 |
}
|
|
53 |
}
|
|
54 |
|
|
55 |
childWidth += toolBarMarginPadding * (numChillens + 1);
|
|
56 |
|
|
57 |
if (numChillens == 0) {
|
|
58 |
// no items, set to default width
|
|
59 |
childWidth = laf.getInteger("control.toolbar.height", 0);
|
|
60 |
}
|
|
61 |
|
|
62 |
} else {
|
|
63 |
var lastChildWasNull = false; // for some reason the height is zero after dragging an item in from the main pane
|
|
64 |
childWidth = toolBarHeight;
|
|
65 |
toolBarHeight = 0;
|
|
66 |
for (var i in instance.children) {
|
|
67 |
var child = instance.children[i];
|
|
68 |
var childProperties = child.properties;
|
|
69 |
toolBarHeight += childProperties.size.height;
|
|
70 |
if (lastChildWasNull == true) {
|
|
71 |
lastChildWasNull = false;
|
|
72 |
toolBarHeight += toolBarHeight;
|
|
73 |
}
|
|
74 |
if (childProperties.size.height == 0) {
|
|
75 |
lastChildWasNull = true;
|
|
76 |
}
|
|
77 |
}
|
|
78 |
// Get default height of items
|
|
79 |
|
|
80 |
toolBarHeight += toolBarMarginPadding * (numChillens + 1)
|
|
81 |
|
|
82 |
if (numChillens == 0) {
|
|
83 |
// no items, set to default width
|
|
84 |
toolBarHeight = laf.getInteger("control.toolbar.height", 0);
|
|
85 |
}
|
|
86 |
}
|
|
87 |
|
|
88 |
return new Point(childWidth, toolBarHeight);
|
|
89 |
}
|
|
90 |
|