| 1 |
# PFD UI Element - Highlight UI Element. Can have values set and retrieved |
| 2 |
# Highlighting flashes the element. |
| 3 |
var HighlightElement = |
| 4 |
{ |
| 5 |
new : func (pagename, svg, name, value="", style=nil) |
| 6 |
{ |
| 7 |
var obj = { |
| 8 |
parents : [ HighlightElement, PFD.UIElement ], |
| 9 |
_name : pagename ~ name, |
| 10 |
_value : value, |
| 11 |
_style : style, |
| 12 |
}; |
| 13 |
|
| 14 |
if (style == nil) obj._style = PFD.DefaultStyle; |
| 15 |
|
| 16 |
obj._symbol = svg.getElementById(obj._name); |
| 17 |
assert(obj._symbol != nil, "Unable to find element " ~ obj._name); |
| 18 |
|
| 19 |
# State and timer for flashing highlighting of elements |
| 20 |
# We need a separate Enabled flag as the timers are in a separate thread. |
| 21 |
obj._highlightEnabled = 0; |
| 22 |
obj._highlighted = 0; |
| 23 |
obj._flashTimer = nil; |
| 24 |
|
| 25 |
obj.setVisible(0); |
| 26 |
|
| 27 |
return obj; |
| 28 |
}, |
| 29 |
|
| 30 |
getName : func() { return me._name; }, |
| 31 |
getValue : func() { return me._value; }, |
| 32 |
setValue : func(value) { me._value = value; }, |
| 33 |
setVisible : func(vis) { me._symbol.setVisible(vis); }, |
| 34 |
|
| 35 |
_flashElement : func() { |
| 36 |
if (me._highlighted == 0) { |
| 37 |
me._symbol.setVisible(1); |
| 38 |
me._highlighted = 1; |
| 39 |
} else { |
| 40 |
me._symbol.setVisible(0); |
| 41 |
me._highlighted = 0; |
| 42 |
} |
| 43 |
}, |
| 44 |
highlightElement : func() { |
| 45 |
me._highlightEnabled = 1; |
| 46 |
me._highlighted = 0; |
| 47 |
# Force it to immediately display, rather than waiting for the timer |
| 48 |
me._symbol.setVisible(1); |
| 49 |
PFD.HighlightTimer.startHighlight(me, -1); |
| 50 |
}, |
| 51 |
unhighlightElement : func() { |
| 52 |
me._symbol.setVisible(0); |
| 53 |
me._highlighted = 0; |
| 54 |
me._highlightEnabled = 0; |
| 55 |
PFD.HighlightTimer.stopHighlight(me); |
| 56 |
}, |
| 57 |
isEditable : func () { return 0; }, |
| 58 |
isInEdit : func() { return 0; }, |
| 59 |
enterElement : func() { return me.getValue(); }, |
| 60 |
isHighlighted : func() { return me._highlighted; }, |
| 61 |
clearElement : func() { }, |
| 62 |
editElement : func() { }, |
| 63 |
incrSmall : func(value) { }, |
| 64 |
incrLarge : func(value) { }, |
| 65 |
}; |