~cdparra/gelee/trunk

« back to all changes in this revision

Viewing changes to webui/editor/draw2d/ToggleButton.js

  • Committer: parra
  • Date: 2010-03-15 15:56:56 UTC
  • Revision ID: svn-v4:ac5bba68-f036-4e09-846e-8f32731cc928:trunk/gelee:1448
merged gelee at svn

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This notice must be untouched at all times.
 
2
 
 
3
Open-jACOB Draw2D
 
4
The latest version is available at
 
5
http://www.openjacob.org
 
6
 
 
7
Copyright (c) 2006 Andreas Herz. All rights reserved.
 
8
Created 5. 11. 2006 by Andreas Herz (Web: http://www.freegroup.de )
 
9
 
 
10
LICENSE: LGPL
 
11
 
 
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.
 
16
 
 
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.
 
21
 
 
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
 
26
*/
 
27
 
 
28
/**
 
29
 * 
 
30
 * @version 0.9.14
 
31
 * @author Andreas Herz
 
32
 * @constructor
 
33
 */
 
34
draw2d.ToggleButton=function(/*:draw2d.PaletteWindow*/ palette )
 
35
{
 
36
  draw2d.Button.call(this,palette);
 
37
  /** @private **/
 
38
  this.isDownFlag=false; /*:boolean*/
 
39
}
 
40
 
 
41
draw2d.ToggleButton.prototype = new draw2d.Button;
 
42
/** @private **/
 
43
draw2d.ToggleButton.prototype.type="ToggleButton";
 
44
 
 
45
 
 
46
/**
 
47
 * @private
 
48
 **/
 
49
draw2d.ToggleButton.prototype.createHTMLElement=function()
 
50
{
 
51
    var item = document.createElement('div');
 
52
    item.id        = this.id;
 
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()+")";
 
62
    else
 
63
      item.style.backgroundImage="";
 
64
    var oThis = this;
 
65
    this.omousedown=function(event)
 
66
    {
 
67
       if(oThis.enabled)
 
68
       {
 
69
          if(!oThis.isDown())
 
70
          {
 
71
            // Call the super method!!!!
 
72
            draw2d.Button.prototype.setActive.call(oThis,true);
 
73
          }
 
74
       }
 
75
       event.cancelBubble = true;
 
76
       event.returnValue = false;
 
77
    }
 
78
    this.omouseup=function(event)
 
79
    {
 
80
       if(oThis.enabled)
 
81
       {
 
82
          // Call the super method!!!!
 
83
          if(oThis.isDown())
 
84
            draw2d.Button.prototype.setActive.call(oThis,false);
 
85
 
 
86
          oThis.isDownFlag = !oThis.isDownFlag;
 
87
          oThis.execute();
 
88
       }
 
89
       event.cancelBubble = true;
 
90
       event.returnValue = false;
 
91
    }
 
92
 
 
93
    if (item.addEventListener)
 
94
    {
 
95
      item.addEventListener("mousedown", this.omousedown, false);
 
96
      item.addEventListener("mouseup", this.omouseup, false);
 
97
    }
 
98
    else if (item.attachEvent)
 
99
    {
 
100
      item.attachEvent("onmousedown", this.omousedown);
 
101
      item.attachEvent("onmouseup", this.omouseup);
 
102
    }
 
103
 
 
104
    return item;
 
105
}
 
106
 
 
107
draw2d.ToggleButton.prototype.isDown=function()
 
108
{
 
109
  return this.isDownFlag;
 
110
}
 
111
 
 
112
/**
 
113
 * @private
 
114
 **/
 
115
draw2d.ToggleButton.prototype.setActive=function( /*:boolean*/ flag)
 
116
{
 
117
  draw2d.Button.prototype.setActive.call(this,flag);
 
118
  this.isDownFlag=flag;
 
119
}
 
120
 
 
121
 
 
122
/**
 
123
 *
 
124
 **/
 
125
draw2d.ToggleButton.prototype.execute=function()
 
126
{
 
127
}
 
 
b'\\ No newline at end of file'