r20517: re-add cleaned-up webapps
[kai/samba.git] / webapps / qooxdoo-0.6.3-sdk / frontend / framework / source / class / qx / ui / embed / TextEmbed.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_basic)
22 #require(qx.renderer.font.FontCache)
23 #after(qx.renderer.font.FontObject)
24
25 ************************************************************************ */
26
27 qx.OO.defineClass("qx.ui.embed.TextEmbed", qx.ui.basic.Terminator,
28 function(vText)
29 {
30   qx.ui.basic.Terminator.call(this);
31
32   if (qx.util.Validation.isValidString(vText)) {
33     this.setText(vText);
34   }
35 });
36
37
38
39
40 /*
41 ---------------------------------------------------------------------------
42   PROPERTIES
43 ---------------------------------------------------------------------------
44 */
45
46 /*!
47   Any text string which can contain TEXT, too
48 */
49 qx.OO.addProperty({ name : "text", type : "string" });
50
51 /*!
52   The font property describes how to paint the font on the widget.
53 */
54 qx.OO.addProperty({ name : "font", type : "object", instance : "qx.renderer.font.Font", convert : qx.renderer.font.FontCache, allowMultipleArguments : true });
55
56 /*!
57   Wrap the text?
58 */
59 qx.OO.addProperty({ name : "wrap", type : "boolean", defaultValue : true });
60
61 /** The horizontal alignment of the text. */
62 qx.OO.addProperty({ name : "textAlign", type : "string", defaultValue : "left", possibleValues : [ "left", "center", "right", "justify" ], allowNull : false });
63
64
65
66
67 /*
68 ---------------------------------------------------------------------------
69   MODIFIER
70 ---------------------------------------------------------------------------
71 */
72
73 qx.Proto._modifyText = function()
74 {
75   if (this._isCreated) {
76     this._syncText();
77   }
78
79   return true;
80 }
81
82 qx.Proto._modifyFont = function(propValue, propOldValue, propData)
83 {
84   if (propValue) {
85     propValue._applyWidget(this);
86   } else if (propOldValue) {
87     propOldValue._resetWidget(this);
88   }
89
90   return true;
91 }
92
93 qx.Proto._modifyWrap = function(propValue, propOldValue, propData)
94 {
95   this.setStyleProperty("whiteSpace", propValue ? "normal" : "nowrap");
96   return true;
97 }
98
99 // property modifier
100 qx.Proto._modifyTextAlign = function(propValue, propOldValue, propData) {
101   this.setStyleProperty("textAlign", propValue);
102   return true;
103 }
104
105
106
107
108
109 /*
110 ---------------------------------------------------------------------------
111   ELEMENT HANDLING
112 ---------------------------------------------------------------------------
113 */
114
115 qx.Proto._applyElementData = function() {
116   this.getElement().appendChild(document.createTextNode(this.getText()));
117 }
118
119 qx.Proto._syncText = function() {
120   this.getElement().firstChild.nodeValue = this.getText();
121 }