1
/* This notice must be untouched at all times.
4
The latest version is available at
5
http://www.openjacob.org
7
Copyright (c) 2006 Andreas Herz. All rights reserved.
8
Created 5. 11. 2006 by Andreas Herz (Web: http://www.freegroup.de )
12
This library is free software; you can redistribute it and/or
13
modify it under the terms of the GNU Lesser General Public
14
License (LGPL) as published by the Free Software Foundation; either
15
version 2.1 of the License, or (at your option) any later version.
17
This library is distributed in the hope that it will be useful,
18
but WITHOUT ANY WARRANTY; without even the implied warranty of
19
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
Lesser General Public License for more details.
22
You should have received a copy of the GNU Lesser General Public
23
License along with this library; if not, write to the Free Software
24
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA,
25
or see http://www.gnu.org/copyleft/lesser.html
31
* @author Andreas Herz
34
draw2d.ToggleButton=function(/*:draw2d.PaletteWindow*/ palette )
36
draw2d.Button.call(this,palette);
38
this.isDownFlag=false; /*:boolean*/
41
draw2d.ToggleButton.prototype = new draw2d.Button;
43
draw2d.ToggleButton.prototype.type="ToggleButton";
49
draw2d.ToggleButton.prototype.createHTMLElement=function()
51
var item = document.createElement('div');
53
item.style.position="absolute";
54
item.style.left = this.x+"px";
55
item.style.top = this.y+"px";
56
item.style.height = "24px";
57
item.style.width = "24px";
58
item.style.margin = "0px";
59
item.style.padding= "0px";
60
if(this.getImageUrl()!=null)
61
item.style.backgroundImage="url("+this.getImageUrl()+")";
63
item.style.backgroundImage="";
65
this.omousedown=function(event)
71
// Call the super method!!!!
72
draw2d.Button.prototype.setActive.call(oThis,true);
75
event.cancelBubble = true;
76
event.returnValue = false;
78
this.omouseup=function(event)
82
// Call the super method!!!!
84
draw2d.Button.prototype.setActive.call(oThis,false);
86
oThis.isDownFlag = !oThis.isDownFlag;
89
event.cancelBubble = true;
90
event.returnValue = false;
93
if (item.addEventListener)
95
item.addEventListener("mousedown", this.omousedown, false);
96
item.addEventListener("mouseup", this.omouseup, false);
98
else if (item.attachEvent)
100
item.attachEvent("onmousedown", this.omousedown);
101
item.attachEvent("onmouseup", this.omouseup);
107
draw2d.ToggleButton.prototype.isDown=function()
109
return this.isDownFlag;
115
draw2d.ToggleButton.prototype.setActive=function( /*:boolean*/ flag)
117
draw2d.Button.prototype.setActive.call(this,flag);
118
this.isDownFlag=flag;
125
draw2d.ToggleButton.prototype.execute=function()
b'\\ No newline at end of file'