2 * QLIB 1.0 Button Control
\r
3 * Copyright (C) 2002 2003, Quazzle.com Serge Dolgov
\r
4 * This program is free software; you can redistribute it and/or
\r
5 * modify it under the terms of the GNU General Public License
\r
6 * as published by the Free Software Foundation; either version 2
\r
7 * of the License, or (at your option) any later version.
\r
8 * http://qlib.quazzle.com
\r
11 function QButton_update() {
\r
13 image.src = ((!enabled && res.imgD) || (value ? res.imgP : res.imgN)).src;
\r
17 function QButton_doEvent() {
\r
20 if (res.style == 1) {
\r
21 this.value = value ? 0 : 1;
\r
24 onClick(value, tag);
\r
30 function QButton_enable(state) {
\r
31 this.enabled = state;
\r
35 function QButton_set(value) {
\r
37 this.value = value ? 1 : 0;
\r
43 function QButton(parent, name, res, tooltip) {
\r
44 this.init(parent, name);
\r
47 this.tip = tooltip || "";
\r
48 this.enabled = true;
\r
50 this.set = QButton_set;
\r
51 this.enable = QButton_enable;
\r
52 this.update = QButton_update;
\r
53 this.doEvent = QButton_doEvent;
\r
54 this.onClick = QControl.event;
\r
56 document.write('<a href="#" hidefocus="true" unselectable="on"' +
\r
57 (tip ? ' title="' + tip + '"' : '') + ' onClick="return ' + name +
\r
58 '.doEvent()" onMouseOver="' + (res.style == 2 ? name + '.set(1);' : '') +
\r
59 'window.top.status=' + name + '.tip;return true" onMouseOut="' +
\r
60 (!res.style || (res.style == 2) ? name + '.set();' : '') + 'window.top.status=\'\'"' +
\r
61 (!res.style ? ' onMouseDown="return ' + name + '.set(1)" onMouseUp="return ' + name + '.set()"' : '') +
\r
62 '><img class="qbutton" name="' + id + '" src="' + res.imgN.src + '" border="0" width="' +
\r
63 res.width + '" height="' + res.height + '"></a>');
\r
64 this.image = document.images[id] || new Image(1, 1);
\r
67 this.document.write("invalid resource");
\r
70 QButton.prototype = new QControl();
\r
72 QButton.CHECKBOX = 1;
\r