source: EDIS/tags/ed/tracking-ui-core/src/main/flex/gov/va/med/edp/widget/LinkButtonTabBar.as@ 1240

Last change on this file since 1240 was 1240, checked in by George Lilly, 13 years ago

new version from the VA

File size: 5.4 KB
Line 
1package gov.va.med.edp.widget
2{
3import flash.display.Graphics;
4
5import mx.containers.BoxDirection;
6import mx.controls.TabBar;
7import mx.core.ClassFactory;
8import mx.core.EdgeMetrics;
9import mx.core.IFlexDisplayObject;
10import mx.core.mx_internal;
11import mx.styles.CSSStyleDeclaration;
12import mx.styles.StyleManager;
13
14use namespace mx_internal;
15
16/**
17 * Name of CSS style declaration that specifies the styles to use for the text
18 * of the selected tab navigation item.
19 *
20 * @default "selectedLinkStyle"
21 */
22[Style(name="selectedTabTextStyleName", type="String", inherit="no")]
23
24/**
25 * Name of CSS style declaration that specifies the styles to use for the tab
26 * navigation items.
27 *
28 * @default "LinkButtonTab"
29 */
30[Style(name="tabStyleName", type="String", inherit="no")]
31
32/**
33 * Background color of the LinkButton control as you press it.
34 *
35 * @default 0xCDFFC1
36 */
37[Style(name="selectionColor", type="uint", format="Color", inherit="yes")]
38
39/**
40 * Separator color used by the default separator skin.
41 *
42 * @default 0xC4CCCC
43 */
44[Style(name="separatorColor", type="uint", format="Color", inherit="yes")]
45
46/**
47 * Separator pixel width, in pixels.
48 *
49 * @default 1
50 */
51[Style(name="separatorWidth", type="Number", format="Length", inherit="yes")]
52
53/**
54 * Number of pixels between tab navigation items in the horizontal direction.
55 *
56 * @default 8
57 */
58[Style(name="horizontalGap", type="Number", format="Length", inherit="no")]
59
60/**
61 * Number of pixels between tab navigation items in the vertical direction.
62 *
63 * @default 8
64 */
65[Style(name="verticalGap", type="Number", format="Length", inherit="no")]
66
67[AccessibilityClass(implementation="gov.va.med.edp.widget.accessibility.LinkButtonTabBarAccImpl")]
68
69[DefaultProperty("dataProvider")]
70
71[MaxChildren(0)]
72
73public class LinkButtonTabBar extends TabBar
74{
75 mx_internal static var createAccessibilityImplementation:Function;
76
77 private static var classConstructed:Boolean = classConstruct();
78
79 private static function classConstruct():Boolean {
80 // If there is no CSS definition for our style,
81 // then create one and set the default value.
82 if (!StyleManager.getStyleDeclaration(".selectedLinkStyle"))
83 {
84 var linkStyle:CSSStyleDeclaration = new CSSStyleDeclaration();
85 linkStyle.defaultFactory = function():void {
86 this.color = 0xAAB3B3;
87 this.textRollOverColor = 0xAAB3B3;
88 }
89 StyleManager.setStyleDeclaration(".selectedLinkStyle", linkStyle, true);
90 }
91
92 if (!StyleManager.getStyleDeclaration("LinkButtonTabBar"))
93 {
94 var style:CSSStyleDeclaration = new CSSStyleDeclaration();
95 style.defaultFactory = function():void {
96 this.tabStyleName = "LinkButtonTab";
97
98 this.selectedTabTextStyleName = "selectedLinkStyle";
99
100 this.separatorColor = 0xC4CCCC;
101 this.separatorWidth = 1;
102 this.selectionColor = 0x0000FF;
103
104 this.horizontalGap = 8;
105 this.verticalGap = 8;
106 }
107 StyleManager.setStyleDeclaration("LinkButtonTabBar", style, true);
108 }
109 return true;
110 }
111
112 public function LinkButtonTabBar()
113 {
114 super();
115 navItemFactory = new ClassFactory(LinkButtonTab);
116 }
117
118 override protected function initializeAccessibility():void
119 {
120 if (LinkButtonTabBar.createAccessibilityImplementation != null)
121 LinkButtonTabBar.createAccessibilityImplementation(this);
122 }
123
124 override protected function updateDisplayList(unscaledWidth:Number,
125 unscaledHeight:Number):void
126 {
127 // The super method will lay out the LinkButtons.
128 super.updateDisplayList(unscaledWidth, unscaledHeight);
129
130 var separatorThickness:Number = getStyle("separatorWidth");
131 if (separatorThickness == 0 || separatorThickness == 0) return;
132
133 var separatorColor:uint = getStyle("separatorColor");
134
135 var vm:EdgeMetrics = viewMetricsAndPadding;
136
137 var horizontalGap:Number = getStyle("horizontalGap");
138 var verticalGap:Number = getStyle("verticalGap");
139
140 var barHeight:Number = unscaledHeight - (vm.top + vm.bottom);
141 var barWidth:Number = unscaledWidth - (vm.left + vm.right);
142
143 var g:Graphics = graphics;
144 g.clear();
145
146 g.lineStyle(separatorThickness, separatorColor);
147
148 var isVertical:Boolean = direction == BoxDirection.VERTICAL;
149
150 var x:Number;
151 var y:Number;
152 var h:Number = isVertical ? verticalGap : barHeight;
153 var w:Number = isVertical ? barWidth : horizontalGap;
154
155 // paint the separators.
156 var n:int = numChildren - 1;
157 for (var i:int = 0; i < n; i++)
158 {
159 var child:IFlexDisplayObject = IFlexDisplayObject(getChildAt(i));
160
161 if (isVertical)
162 {
163 x = child.x;
164 y = child.y + child.height;
165 g.moveTo(x + 4, y + h / 2);
166 g.lineTo(x + w - 4, y + h / 2);
167 } else {
168 x = child.x + child.width;
169 y = child.y;
170 g.moveTo(x + w / 2, y + 6);
171 g.lineTo(x + w / 2, y + h - 5);
172 }
173 }
174 }
175
176 override public function styleChanged(styleProp:String):void {
177 super.styleChanged(styleProp);
178
179 // Check to see if style changed.
180 if (styleProp == "separatorColor" || styleProp == "separatorWidth" || styleProp == "selectionColor")
181 {
182 invalidateDisplayList();
183 return;
184 }
185 }
186
187}
188}
Note: See TracBrowser for help on using the repository browser.