r20517: re-add cleaned-up webapps
[sfrench/samba-autobuild/.git] / webapps / qooxdoo-0.6.3-sdk / frontend / framework / source / class / qx / ui / menu / CheckBox.js
1 /* ************************************************************************
2
3    qooxdoo - the new era of web development
4
5    http://qooxdoo.org
6
7    Copyright:
8      2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org
9
10    License:
11      LGPL 2.1: http://www.gnu.org/licenses/lgpl.html
12
13    Authors:
14      * Sebastian Werner (wpbasti)
15      * Andreas Ecker (ecker)
16
17 ************************************************************************ */
18
19 /* ************************************************************************
20
21 #module(ui_menu)
22
23 ************************************************************************ */
24
25 /*!
26   A checkbox for the menu system.
27 */
28 qx.OO.defineClass("qx.ui.menu.CheckBox", qx.ui.menu.Button,
29 function(vLabel, vCommand, vChecked)
30 {
31   qx.ui.menu.Button.call(this, vLabel, "static/image/blank.gif", vCommand);
32
33   if (qx.util.Validation.isValidBoolean(vChecked)) {
34     this.setChecked(vChecked);
35   }
36
37   qx.manager.object.ImageManager.getInstance().preload("widget/menu/checkbox.gif");
38 });
39
40
41
42 /*
43 ---------------------------------------------------------------------------
44   PROPERTIES
45 ---------------------------------------------------------------------------
46 */
47
48 qx.OO.changeProperty({ name : "appearance", type : "string", defaultValue : "menu-check-box" });
49 qx.OO.addProperty({ name : "name", type : "string" });
50 qx.OO.addProperty({ name : "value", type : "string" });
51 qx.OO.addProperty({ name : "checked", type : "boolean", defaultValue : false, getAlias : "isChecked" });
52
53
54
55
56
57 /*
58 ---------------------------------------------------------------------------
59   MODIFIERS
60 ---------------------------------------------------------------------------
61 */
62
63 qx.Proto._modifyChecked = function(propValue, propOldValue, propData)
64 {
65   propValue ? this.addState("checked") : this.removeState("checked");
66   this.getIconObject().setSource(propValue ? "widget/menu/checkbox.gif" : "static/image/blank.gif");
67
68   return true;
69 }
70
71
72
73
74
75 /*
76 ---------------------------------------------------------------------------
77   EXECUTE
78 ---------------------------------------------------------------------------
79 */
80
81 qx.Proto.execute = function()
82 {
83   this.setChecked(!this.getChecked());
84   qx.ui.menu.Button.prototype.execute.call(this);
85 }