001: /*
002: * Copyright 2005-2007
003: * Wolfgang S. Kechel, data2c GmbH (www.data2c.com)
004: *
005: * Author: Wolfgang S. Kechel - wolfgang.kechel@data2c.com
006: *
007: * Licensed under the Apache License, Version 2.0 (the "License");
008: * you may not use this file except in compliance with the License.
009: * You may obtain a copy of the License at
010: *
011: * http://www.apache.org/licenses/LICENSE-2.0
012: *
013: * Unless required by applicable law or agreed to in writing, software
014: * distributed under the License is distributed on an "AS IS" BASIS,
015: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016: * See the License for the specific language governing permissions and
017: * limitations under the License.
018: */
019:
020: package org.hecl.midp20.lcdui;
021:
022: import java.util.Hashtable;
023: import java.util.Vector;
024:
025: import javax.microedition.lcdui.Alert;
026: import javax.microedition.lcdui.AlertType;
027: import javax.microedition.lcdui.Canvas;
028: import javax.microedition.lcdui.Choice;
029: import javax.microedition.lcdui.ChoiceGroup;
030: import javax.microedition.lcdui.Command;
031: import javax.microedition.lcdui.DateField;
032: import javax.microedition.lcdui.Font;
033: import javax.microedition.lcdui.Form;
034: import javax.microedition.lcdui.Gauge;
035: import javax.microedition.lcdui.Graphics;
036: import javax.microedition.lcdui.Image;
037: import javax.microedition.lcdui.ImageItem;
038: import javax.microedition.lcdui.Item;
039: import javax.microedition.lcdui.List;
040: import javax.microedition.lcdui.Spacer;
041: import javax.microedition.lcdui.StringItem;
042: import javax.microedition.lcdui.TextBox;
043: import javax.microedition.lcdui.TextField;
044: import javax.microedition.lcdui.Ticker;
045:
046: import org.hecl.HeclException;
047: import org.hecl.IntThing;
048: import org.hecl.ObjectThing;
049: import org.hecl.Properties;
050: import org.hecl.RealThing;
051: import org.hecl.Thing;
052:
053: import org.hecl.misc.HeclUtils;
054:
055: public class WidgetInfo {
056:
057: public static Object asWidget(Thing thing, Class clazz,
058: String clazzname, boolean allownull) throws HeclException {
059: if (allownull && thing.toString().length() == 0)
060: return null;
061: RealThing rt = thing.getVal();
062: if (rt instanceof ObjectThing) {
063: Object x = ((ObjectThing) rt).get();
064: if (allownull && x == null)
065: return null;
066: if (clazz.isAssignableFrom(x.getClass()))
067: return x;
068: }
069: if (clazzname != null) {
070: throw HeclException.createInvalidParameter(thing,
071: "parameter", clazzname + " widget required.");
072: }
073: return null;
074: }
075:
076: public static Command asCommand(Thing thing, boolean allownull,
077: boolean throwerror) throws HeclException {
078: return (Command) asWidget(thing, Command.class,
079: throwerror ? "Command" : null, allownull);
080: }
081:
082: public static Gauge asGauge(Thing thing, boolean allownull,
083: boolean throwerror) throws HeclException {
084: return (Gauge) asWidget(thing, Gauge.class,
085: throwerror ? "Gauge" : null, allownull);
086: }
087:
088: public static Image asImage(Thing thing, boolean allownull,
089: boolean throwerror) throws HeclException {
090: return (Image) asWidget(thing, Image.class,
091: throwerror ? "Image" : null, allownull);
092: }
093:
094: public static Item asItem(Thing thing, boolean allownull,
095: boolean throwerror) throws HeclException {
096: return (Item) asWidget(thing, Item.class, throwerror ? "Item"
097: : null, allownull);
098: }
099:
100: public static Ticker asTicker(Thing thing, boolean allownull,
101: boolean throwerror) throws HeclException {
102: return (Ticker) asWidget(thing, Ticker.class,
103: throwerror ? "Ticker" : null, allownull);
104: }
105:
106: public static AlertType toAlertType(Thing t) throws HeclException {
107: String s = t.toString().toLowerCase();
108: int l = alerttypenames.length;
109: for (int i = 0; i < l; ++i)
110: if (s.equals(alerttypenames[i]))
111: return alerttypevals[i];
112: throw new HeclException("Invalid alert type '" + s + "'!");
113: }
114:
115: public static Thing fromAlertType(AlertType t) throws HeclException {
116: int l = alerttypenames.length;
117: for (int i = 0; i < l; ++i)
118: if (t == alerttypevals[i])
119: return new Thing(alerttypenames[i]);
120: throw new HeclException("Invalid alert type value '" + t + "'!");
121: }
122:
123: protected static int t2int(Thing t, String nametab[], int valtab[],
124: String emsg) throws HeclException {
125: return s2int(t.toString().toLowerCase(), nametab, valtab, emsg);
126: }
127:
128: protected static int s2int(String s, String nametab[],
129: int valtab[], String emsg) throws HeclException {
130: int l = nametab.length;
131: for (int i = 0; i < l; ++i)
132: if (s.equals(nametab[i]))
133: return valtab[i];
134: throw new HeclException("Invalid " + emsg + " '" + s + "'.");
135: }
136:
137: protected static Thing int2t(int v, String nametab[], int valtab[],
138: String emsg) throws HeclException {
139: return new Thing(int2s(v, nametab, valtab, emsg));
140: }
141:
142: protected static String int2s(int v, String nametab[],
143: int valtab[], String emsg) throws HeclException {
144: int l = valtab.length;
145: for (int i = 0; i < l; ++i)
146: if (v == valtab[i])
147: return nametab[i];
148: throw new HeclException("Invalid " + emsg + " value '" + v
149: + "'.");
150: }
151:
152: public static int toColor(Thing t) throws HeclException {
153: String s = t.toString();
154: try {
155: return s2int(s.toLowerCase(), colornames, colorvals, "");
156: } catch (Exception e) {
157: }
158: return Integer.parseInt(s, 16);
159: }
160:
161: public static Thing fromColor(org.awt.Color color)
162: throws HeclException {
163: return fromColor(color.getRGB());
164: }
165:
166: public static Thing fromColor(int t) throws HeclException {
167: try {
168: return int2t(t, colornames, colorvals, "");
169: } catch (HeclException e) {
170: }
171: return new Thing(Integer.toHexString(t));
172: }
173:
174: public static int toCanvasAnchor(Thing t) throws HeclException {
175: return t2int(t, canchornames, canchorvals, "anchor");
176: }
177:
178: public static Thing fromCanvasAnchor(int t) throws HeclException {
179: return int2t(t, canchornames, canchorvals, "anchor");
180: }
181:
182: public static int toChoiceType(Thing t) throws HeclException {
183: return t2int(t, choicetypenames, choicetypevals, "choice type");
184: }
185:
186: public static Thing fromChoiceType(int t) throws HeclException {
187: return int2t(t, choicetypenames, choicetypevals, "choice type");
188: }
189:
190: public static int toListType(Thing t) throws HeclException {
191: int i = toChoiceType(t);
192: if (i == Choice.POPUP) {
193: throw new HeclException("Invalid list type '" + t + "'!");
194: }
195: return i;
196: }
197:
198: public static Thing fromListType(int t) throws HeclException {
199: try {
200: if (t != Choice.POPUP) {
201: return fromChoiceType(t);
202: }
203: } catch (HeclException e) {
204: }
205: throw new HeclException("Invalid list type value'" + t + "'!");
206: }
207:
208: public static int toTextType(Thing t) throws HeclException {
209: return t2int(t, texttypenames, texttypevals, "text type");
210: }
211:
212: public static Thing fromTextType(int t) throws HeclException {
213: return int2t(t & ~TextField.CONSTRAINT_MASK, texttypenames,
214: texttypevals, "text type");
215: }
216:
217: public static int toWrap(Thing t) throws HeclException {
218: return t2int(t, wrapnames, wrapvals, "wrap type");
219: }
220:
221: public static Thing fromWrap(int t) throws HeclException {
222: return int2t(t, wrapnames, wrapvals, "wrap type");
223: }
224:
225: public static String commandLabel(Command c, boolean shortonly) {
226: String l = shortonly ? null : c.getLongLabel();
227:
228: if (l == null || l.length() == 0) {
229: l = c.getLabel();
230: }
231: if (l == null && l.length() == 0) {
232: //#ifdef notdef
233: // unfortunately there is no way to detect the command type :-(
234: int t = c.getType();
235: for (int i = 0; i < cmdlabels.length; ++i) {
236: if (t == cmdtypes[i]) {
237: l = cmdlabels[i];
238: break;
239: }
240: }
241: //#endif
242: l = "???";
243: }
244: return l;
245: }
246:
247: public static int toCommandType(Thing t) throws HeclException {
248: return t2int(t, cmdtypenames, cmdtypevals, "command type");
249: }
250:
251: public static Thing fromCommandType(int t) throws HeclException {
252: return int2t(t, cmdtypenames, cmdtypevals, "command type");
253: }
254:
255: public static int toFontFace(Thing t) throws HeclException {
256: return t2int(t, fontfacenames, fontfacevals, "font face");
257: }
258:
259: public static int toFontFace(String s) throws HeclException {
260: return s2int(s.toLowerCase(), fontfacenames, fontfacevals,
261: "font face");
262: }
263:
264: public static Thing fromFontFace(int t) throws HeclException {
265: return int2t(t, fontfacenames, fontfacevals, "font face");
266: }
267:
268: public static int toFontSize(Thing t) throws HeclException {
269: return t2int(t, fontsizenames, fontsizevals, "font size");
270: }
271:
272: public static int toFontSize(String s) throws HeclException {
273: return s2int(s.toLowerCase(), fontsizenames, fontsizevals,
274: "font size");
275: }
276:
277: public static Thing fromFontSize(int t) throws HeclException {
278: return int2t(t, fontsizenames, fontsizevals, "font size");
279: }
280:
281: public static int toItemAnchor(Thing t) throws HeclException {
282: return t2int(t, anchornames, anchorvals, "anchor");
283: }
284:
285: public static Thing fromItemAnchor(int t) throws HeclException {
286: return int2t(t &= 0x33, anchornames, anchorvals, "anchor");
287: }
288:
289: public static int toItemAppearance(Thing t) throws HeclException {
290: return t2int(t, appearancenames, appearancevals, "appearance");
291: }
292:
293: public static Thing fromItemAppearance(int t) throws HeclException {
294: return int2t(t &= 0x33, appearancenames, appearancevals,
295: "appearance");
296: }
297:
298: public static int toDateFieldMode(Thing t) throws HeclException {
299: return t2int(t, dfmodenames, dfmodevals, "date field mode");
300: }
301:
302: public static Thing fromDateFieldMode(int t) throws HeclException {
303: return int2t(t &= 0x33, dfmodenames, dfmodevals,
304: "date field mode");
305: }
306:
307: public static int toGaugeInitial(Thing t) throws HeclException {
308: if (Character.isDigit(t.toString().charAt(0))) {
309: return HeclUtils.thing2int(t, true, 0);
310: }
311: return t2int(t, gaugeinitialnames, gaugeinitialvals,
312: "gauge initval");
313: }
314:
315: public static Thing fromGaugeInitial(int t) throws HeclException {
316: for (int i = 0; i < gaugeinitialvals.length; ++i) {
317: if (i == gaugeinitialvals[i])
318: return new Thing(gaugeinitialnames[i]);
319: }
320: return IntThing.create(t);
321: }
322:
323: public static int toGaugeMax(Thing t) throws HeclException {
324: if (Character.isDigit(t.toString().charAt(0))) {
325: return HeclUtils.thing2int(t, true, 0);
326: }
327: return t2int(t, gaugemaxnames, gaugemaxvals, "gauge initval");
328: }
329:
330: public static Thing fromGaugeMax(int t) throws HeclException {
331: for (int i = 0; i < gaugemaxvals.length; ++i) {
332: if (i == gaugeinitialvals[i])
333: return new Thing(gaugemaxnames[i]);
334: }
335: return IntThing.create(t);
336: }
337:
338: public static void showProps(Class c) {
339: Vector v = (Vector) widgetprops.get(c);
340: int n = v.size();
341: System.err.println("showProps(" + c + ")=");
342: for (int i = 0; i < n; ++i) {
343: String s = "<null>";
344:
345: WidgetProp wp = (WidgetProp) v.elementAt(i);
346: try {
347: s = wp.defaultvalue.toString();
348: } catch (NullPointerException e) {
349: }
350: System.err.println("\t" + wp.name + ": " + s);
351: }
352: }
353:
354: public static Properties defaultProps(Class c) {
355: Properties p = new Properties();
356: Vector v = (Vector) widgetprops.get(c);
357: int n = v.size();
358: for (int i = 0; i < n; ++i) {
359: WidgetProp wp = (WidgetProp) v.elementAt(i);
360: p.setProp(wp.name, wp.defaultvalue);
361: }
362: return p;
363: }
364:
365: /*
366: * Some command names (in alphabetical order)
367: */
368: public static final String NADDCOMMAND = "addcommand";
369: public static final String NAPPEND = "append";
370: public static final String NCGET = "cget";
371: public static final String NCONF = "conf";
372: public static final String NCONFIGURE = "configure";
373: public static final String NCREATE = "create";
374: public static final String NDELETE = "delete";
375: public static final String NITEM = "item";
376: public static final String NITEMCGET = "itemcget";
377: public static final String NITEMCONF = "itemconf";
378: public static final String NITEMCONFIGURE = "itemconfigure";
379: public static final String NREMOVECOMMAND = "removecommand";
380: public static final String NREPAINT = "repaint";
381: public static final String NSETCURRENT = "setcurrent";
382: public static final String NSIZE = "size";
383:
384: /*
385: * Some property names (in alphabetical order)
386: */
387: public static final String NAPPEARANCE = "-appearance";
388: public static final String NCLIPHEIGHT = "-clipheight";
389: public static final String NCLIPWIDTH = "-clipwidth";
390: public static final String NCLIPX = "-clipx";
391: public static final String NCLIPY = "-clipy";
392: public static final String NCODE = "-code";
393: public static final String NCOLOR = "-color";
394: public static final String NCOMMAND = "-command";
395: public static final String NCOMMANDACTION = "-commandaction";
396: public static final String NEXPAND = "-expand";
397: public static final String NFIT = "-fit";
398: public static final String NFONT = "-font";
399: public static final String NHEIGHT = "-height";
400: public static final String NIMAGE = "-image";
401: public static final String NINTERACTIVE = "-interactive";
402: public static final String NLABEL = "-label";
403: public static final String NLINETYPE = "-linetype";
404: public static final String NLONGLABEL = "-longlabel";
405: public static final String NMAXLEN = "-maxlength";
406: public static final String NMAXVALUE = "-maxvalue";
407: public static final String NMINHEIGHT = "-minheight";
408: public static final String NMINWIDTH = "-minwidth";
409: public static final String NPRIO = "-priority";
410: public static final String NPREFERREDWIDTH = "-preferredwidth";
411: public static final String NPREFERREDHEIGHT = "-preferredheight";
412: public static final String NSELECTMODE = "-selectmode";
413: public static final String NSELECTION = "-selection";
414: public static final String NSUPPRESSKEYS = "-suppresskeys";
415: public static final String NTEXT = "-text";
416: public static final String NTICKER = "-ticker";
417: public static final String NTITLE = "-title";
418: public static final String NTYPE = "-type";
419: public static final String NVALUE = "-value";
420: public static final String NVEXPAND = "-vexpand";
421: public static final String NWIDTH = "-width";
422:
423: static final Thing DEFAULTTHING = new Thing("default");
424: static final Thing ANYTHING = new Thing("any");
425: static final Thing ZERO = IntThing.create(0);
426: static final Thing ONE = IntThing.create(1);
427:
428: /*
429: * Common Widget properties and default values.
430: */
431: public static final WidgetProp codeprop = new WidgetProp(NCODE,
432: Thing.emptyThing());
433: public static final WidgetProp textprop = new WidgetProp(NTEXT,
434: Thing.emptyThing());
435: public static final WidgetProp labelprop = new WidgetProp(NLABEL,
436: Thing.emptyThing());
437: public static final WidgetProp longlabelprop = new WidgetProp(
438: NLONGLABEL, Thing.emptyThing());
439: public static final WidgetProp titleprop = new WidgetProp(NTITLE,
440: Thing.emptyThing());
441: public static final WidgetProp fitprop = new WidgetProp(NFIT,
442: DEFAULTTHING);
443: public static final WidgetProp selectprop = new WidgetProp(
444: NSELECTMODE, new Thing("exclusive"));
445: public static final WidgetProp tickerprop = new WidgetProp(NTICKER,
446: Thing.emptyThing());
447: public static final WidgetProp prioprop = new WidgetProp(NPRIO, ONE);
448: public static final WidgetProp appearanceprop = new WidgetProp(
449: NAPPEARANCE, new Thing("plain"));
450: public static final WidgetProp minwidthprop = new WidgetProp(
451: NMINWIDTH, ZERO);
452: public static final WidgetProp minheightprop = new WidgetProp(
453: NMINHEIGHT, ZERO);
454:
455: /*
456: * WIDGET attribute conversion tables (parallel arrays
457: */
458: static final String colornames[] = { "red", "green", "blue",
459: "yellow", "cyan", "magenta", "white", "black" };
460: static final int colorvals[] = { 0x0ff0000, 0x0ff00, 0x0ff,
461: 0x0ffff00, 0x0ffff, 0x0ff00ff, 0x0ffffff, 0 };
462:
463: // Alert type
464: static final String alerttypenames[] = { "none", "info", "warning",
465: "error", "alarm", "confirmation", "" };
466: static final AlertType alerttypevals[] = { null, AlertType.INFO,
467: AlertType.WARNING, AlertType.ERROR, AlertType.ALARM,
468: AlertType.CONFIRMATION, null };
469:
470: // Canvas stuff
471: // Linetype
472: static String clinetypenames[] = { "solid", "dotted", "default" };
473: static int clinetypevals[] = { Graphics.SOLID, Graphics.DOTTED,
474: Graphics.SOLID };
475: // Anchor points
476: static String canchornames[] = { "n", "ne", "e", "se", "s", "sw",
477: "w", "nw", "center", "default", "bl", "bc", "br" };
478: static int canchorvals[] = { Graphics.TOP | Graphics.HCENTER,
479: Graphics.TOP | Graphics.RIGHT,
480: Graphics.VCENTER | Graphics.RIGHT,
481: Graphics.BOTTOM | Graphics.RIGHT,
482: Graphics.BOTTOM | Graphics.HCENTER,
483: Graphics.BOTTOM | Graphics.LEFT,
484: Graphics.VCENTER | Graphics.LEFT,
485: Graphics.TOP | Graphics.LEFT,
486: Graphics.VCENTER | Graphics.HCENTER,
487: Graphics.TOP | Graphics.LEFT,
488: Graphics.LEFT | Graphics.BASELINE,
489: Graphics.HCENTER | Graphics.BASELINE,
490: Graphics.RIGHT | Graphics.BASELINE, };
491:
492: // Choice types
493: static final String choicetypenames[] = { "exclusive", "multiple",
494: "implicit", "popup" };
495: static final int choicetypevals[] = { Choice.EXCLUSIVE,
496: Choice.MULTIPLE, Choice.IMPLICIT, Choice.POPUP };
497:
498: // Textfield type
499: static final String texttypenames[] = { "any", "emailaddr",
500: "numeric", "phonenumber", "decimal" };
501:
502: static final int texttypevals[] = { TextField.ANY,
503: TextField.EMAILADDR, TextField.NUMERIC,
504: TextField.PHONENUMBER, TextField.DECIMAL };
505:
506: // Choice wrap specification
507: static final String wrapnames[] = { "default", "on", "off" };
508: static final int wrapvals[] = { Choice.TEXT_WRAP_DEFAULT,
509: Choice.TEXT_WRAP_ON, Choice.TEXT_WRAP_OFF };
510:
511: // Command types
512: static final String cmdtypenames[] = { "screen", "back", "cancel",
513: "ok", "help", "stop", "exit", "item" };
514: static final String cmdlabels[] = { "Screen", "Back", "Cancel",
515: "OK", "Help", "Stop", "Exit", "Item" };
516: static final int cmdtypevals[] = { Command.SCREEN, Command.BACK,
517: Command.CANCEL, Command.OK, Command.HELP, Command.STOP,
518: Command.EXIT, Command.ITEM };
519:
520: // Font face names
521: static final String fontfacenames[] = { "system", "proportional",
522: "monospace" };
523: static final int fontfacevals[] = { Font.FACE_SYSTEM,
524: Font.FACE_PROPORTIONAL, Font.FACE_MONOSPACE };
525:
526: // Font sizes
527: static final String fontsizenames[] = { "small", "medium", "large" };
528: static final int fontsizevals[] = { Font.SIZE_SMALL,
529: Font.SIZE_MEDIUM, Font.SIZE_LARGE };
530:
531: // Item anchor position (part of item layout).
532: static String anchornames[] = { "n", "ne", "e", "se", "s", "sw",
533: "w", "nw", "center", "default" };
534: static int anchorvals[] = { Item.LAYOUT_TOP | Item.LAYOUT_CENTER,
535: Item.LAYOUT_TOP | Item.LAYOUT_LEFT,
536: Item.LAYOUT_VCENTER | Item.LAYOUT_RIGHT,
537: Item.LAYOUT_BOTTOM | Item.LAYOUT_RIGHT,
538: Item.LAYOUT_BOTTOM | Item.LAYOUT_CENTER,
539: Item.LAYOUT_BOTTOM | Item.LAYOUT_LEFT,
540: Item.LAYOUT_VCENTER | Item.LAYOUT_LEFT,
541: Item.LAYOUT_TOP | Item.LAYOUT_LEFT,
542: Item.LAYOUT_VCENTER | Item.LAYOUT_CENTER,
543: Item.LAYOUT_DEFAULT };
544:
545: // Item appearance
546: static String appearancenames[] = { "plain", "button", "hyperlink" };
547: static int appearancevals[] = { Item.PLAIN, Item.BUTTON,
548: Item.HYPERLINK };
549:
550: // DateField modes
551: static String dfmodenames[] = { "date", "date_time", "time" };
552: static int dfmodevals[] = { DateField.DATE, DateField.DATE_TIME,
553: DateField.TIME };
554:
555: static String gaugeinitialnames[] = { "continuous-idle",
556: "continuous-running", "incremental-idle",
557: "incremental-updating" };
558: static int gaugeinitialvals[] = { Gauge.CONTINUOUS_IDLE,
559: Gauge.CONTINUOUS_RUNNING, Gauge.INCREMENTAL_IDLE,
560: Gauge.INCREMENTAL_UPDATING };
561:
562: static String gaugemaxnames[] = { "indefinite" };
563: static int gaugemaxvals[] = { Gauge.INDEFINITE };
564:
565: // A table holding widget property descriptions
566: public static final Hashtable widgetprops = new Hashtable();
567:
568: static {
569: /* Alert defaults */
570: Vector v = new Vector();
571: v.addElement(new WidgetProp(NTITLE, new Thing("Alert")));
572: v.addElement(new WidgetProp(NTYPE, new Thing("info"), true));
573: v.addElement(textprop);
574: widgetprops.put(Alert.class, v);
575:
576: /* Canvas defaults */
577: v = new Vector();
578: v.addElement(new WidgetProp(NTITLE, new Thing("Canvas")));
579: v.addElement(new WidgetProp(NSUPPRESSKEYS, new Thing("false"),
580: true));
581: widgetprops.put(Canvas.class, v);
582:
583: /* Command defaults */
584: v = new Vector();
585: v.addElement(labelprop);
586: v.addElement(longlabelprop);
587: v.addElement(new WidgetProp(NTYPE, new Thing("back"), true));
588: v.addElement(prioprop);
589: widgetprops.put(Command.class, v);
590:
591: /* Form defaults */
592: v = new Vector();
593: widgetprops.put(Form.class, v);
594:
595: /* List defaults */
596: v = new Vector();
597: v.addElement(new WidgetProp(NTITLE, new Thing("List")));
598: v
599: .addElement(new WidgetProp(NTYPE,
600: new Thing("implicit"), true));
601: v.addElement(fitprop);
602: widgetprops.put(List.class, v);
603:
604: /* TextBox defaults */
605: v = new Vector();
606: v.addElement(new WidgetProp(NTITLE, new Thing("TextBox")));
607: v.addElement(textprop);
608: v.addElement(tickerprop);
609: v.addElement(new WidgetProp(NTYPE, ANYTHING, true));
610: v.addElement(new WidgetProp(NMAXLEN, IntThing.create(256)));
611: widgetprops.put(TextBox.class, v);
612:
613: /* Ticker defaults */
614: v = new Vector();
615: v.addElement(textprop);
616: widgetprops.put(Ticker.class, v);
617:
618: /* ChoiceGroup defaults */
619: v = new Vector();
620: v.addElement(new WidgetProp(NLABEL, Thing.emptyThing()));
621: v
622: .addElement(new WidgetProp(NTYPE,
623: new Thing("exclusive"), true));
624: v.addElement(fitprop);
625: widgetprops.put(ChoiceGroup.class, v);
626:
627: /* ImageItem defaults */
628: v = new Vector();
629: v.addElement(textprop);
630: v.addElement(labelprop);
631: v.addElement(appearanceprop);
632: widgetprops.put(ImageItem.class, v);
633:
634: /* Spacer defaults */
635: v = new Vector();
636: v.addElement(minwidthprop);
637: v.addElement(minheightprop);
638: widgetprops.put(Spacer.class, v);
639:
640: /* StringItem defaults */
641: v = new Vector();
642: v.addElement(textprop);
643: v.addElement(labelprop);
644: v.addElement(appearanceprop);
645: widgetprops.put(StringItem.class, v);
646:
647: /* TextField defaults */
648: v = new Vector();
649: v.addElement(labelprop);
650: v.addElement(new WidgetProp(NMAXLEN, IntThing.create(256)));
651: v.addElement(new WidgetProp(NTYPE, ANYTHING, true));
652: widgetprops.put(TextField.class, v);
653:
654: /* DateField defaults */
655: v = new Vector();
656: v.addElement(labelprop);
657: v.addElement(new WidgetProp(NTYPE, new Thing(dfmodenames[1])));
658: widgetprops.put(DateField.class, v);
659:
660: /* Gauge defaults */
661: v = new Vector();
662: v.addElement(labelprop);
663: v.addElement(new WidgetProp(NINTERACTIVE, IntThing.create(0),
664: true));
665: v.addElement(new WidgetProp(NVALUE, new Thing(
666: "continuous-running")));
667: v
668: .addElement(new WidgetProp(NMAXVALUE, new Thing(
669: "indefinite")));
670: widgetprops.put(Gauge.class, v);
671: }
672: }
673:
674: // Variables:
675: // mode:java
676: // coding:utf-8
677: // End:
|