r24958: This is the final text, and the final version. I'll send the release
[jelmer/samba4-debian.git] / webapps / qooxdoo-0.6.5-sdk / frontend / framework / source / class / qx / ui / toolbar / RadioButton.js
1 /* ************************************************************************
2
3    qooxdoo - the new era of web development
4
5    http://qooxdoo.org
6
7    Copyright:
8      2004-2007 1&1 Internet AG, Germany, http://www.1and1.org
9
10    License:
11      LGPL: http://www.gnu.org/licenses/lgpl.html
12      EPL: http://www.eclipse.org/org/documents/epl-v10.php
13      See the LICENSE file in the project's top-level directory for details.
14
15    Authors:
16      * Sebastian Werner (wpbasti)
17      * Andreas Ecker (ecker)
18
19 ************************************************************************ */
20
21 /* ************************************************************************
22
23 #module(ui_toolbar)
24
25 ************************************************************************ */
26
27 qx.OO.defineClass("qx.ui.toolbar.RadioButton", qx.ui.toolbar.CheckBox,
28 function(vText, vIcon, vChecked) {
29   qx.ui.toolbar.CheckBox.call(this, vText, vIcon, vChecked);
30 });
31
32
33
34
35 /*
36 ---------------------------------------------------------------------------
37   PROPERTIES
38 ---------------------------------------------------------------------------
39 */
40
41 /*!
42   The assigned qx.manager.selection.RadioManager which handles the switching between registered buttons
43 */
44 qx.OO.addProperty({ name : "manager", type : "object", instance : "qx.manager.selection.RadioManager", allowNull : true });
45
46 /*!
47   The name of the radio group. All the radio elements in a group (registered by the same manager)
48   have the same name (and could have a different value).
49 */
50 qx.OO.addProperty({ name : "name", type : "string" });
51
52 /*!
53   Prohibit the deselction of the checked radio button when clicked on it.
54 */
55 qx.OO.addProperty({ name : "disableUncheck", type : "boolean", defaultValue : false });
56
57
58
59
60
61
62 /*
63 ---------------------------------------------------------------------------
64   MODIFIER
65 ---------------------------------------------------------------------------
66 */
67
68 qx.Proto._modifyChecked = function(propValue, propOldValue, propData)
69 {
70   qx.ui.toolbar.CheckBox.prototype._modifyChecked.call(this, propValue, propOldValue, propData);
71
72   var vManager = this.getManager();
73   if (vManager) {
74     vManager.handleItemChecked(this, propValue);
75   }
76
77   return true;
78 }
79
80 qx.Proto._modifyManager = function(propValue, propOldValue, propData)
81 {
82   if (propOldValue) {
83     propOldValue.remove(this);
84   }
85
86   if (propValue) {
87     propValue.add(this);
88   }
89
90   return true;
91 }
92
93
94
95
96
97 /*
98 ---------------------------------------------------------------------------
99   EVENTS
100 ---------------------------------------------------------------------------
101 */
102
103 qx.Proto._onmouseup = function(e)
104 {
105   this.setCapture(false);
106
107   if (!this.hasState("abandoned"))
108   {
109     this.addState("over");
110     this.setChecked(this.getDisableUncheck() || !this.getChecked());
111     this.execute();
112   }
113
114   this.removeState("abandoned");
115   this.removeState("pressed");
116
117   e.stopPropagation();
118 }