001: // @@
002: // @@
003: /*
004: * Wi.Ser Framework
005: *
006: * Version: 1.8.1, 20-September-2007
007: * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library located in LGPL.txt in the
021: * license directory; if not, write to the
022: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023: * Boston, MA 02111-1307, USA.
024: *
025: * If this agreement does not cover your requirements, please contact us
026: * via email to get detailed information about the commercial license
027: * or our service offerings!
028: *
029: */
030: // @@
031: package de.ug2t.channel.markup.html.renderer;
032:
033: import java.awt.*;
034:
035: import de.ug2t.channel.markup.generic.*;
036: import de.ug2t.kernel.*;
037: import de.ug2t.unifiedGui.*;
038: import de.ug2t.unifiedGui.interfaces.*;
039: import de.ug2t.unifiedGui.views.*;
040:
041: public class HtmlSpinnerRenderer extends AMuGenericComponentRenderer {
042: private KeStringTemplate pcmf_insertFont(UnFontDescriptor xFont,
043: IUnComponent xComp) {
044: KeStringTemplate l_ret = null;
045: UnFontDescriptor l_font = xFont;
046:
047: MuGenericApplication l_appl = (MuGenericApplication) xComp
048: .pcmf_getAppl();
049: if (l_font == null)
050: l_font = l_appl.pcmf_getFont();
051:
052: if (l_font != null) {
053: l_ret = l_appl.pcmf_getTemplateKit().getFONT();
054:
055: KeTools.pcmf_stringSubst(l_ret, "$FNAME", l_font
056: .pcmf_getFontName());
057: KeTools.pcmf_stringSubst(l_ret, "$FSIZE", Integer
058: .toString(l_font.pcmf_getFontSize()));
059:
060: switch (l_font.pcmf_getFontStyle()) {
061: case Font.ITALIC:
062: KeTools.pcmf_stringSubst(l_ret, "$FSTYLE", "italic");
063: KeTools.pcmf_stringSubst(l_ret, "$BOLD", "normal");
064: break;
065: case Font.BOLD:
066: KeTools.pcmf_stringSubst(l_ret, "$BOLD", "bold");
067: KeTools.pcmf_stringSubst(l_ret, "$FSTYLE", "normal");
068: break;
069: default:
070: KeTools.pcmf_stringSubst(l_ret, "$BOLD", "normal");
071: KeTools.pcmf_stringSubst(l_ret, "$FSTYLE", "normal");
072: }
073: }
074: return l_ret;
075: }
076:
077: public String pcmf_render(MuGenericComponent xWidget) {
078: KeStringTemplate l_main = null;
079:
080: MuGenericSpinner l_spinner = (MuGenericSpinner) xWidget;
081:
082: l_main = l_spinner.pcmf_getMarkupString("MAIN");
083:
084: l_main = l_spinner.pcmf_insertToolTip(l_main);
085: l_main = l_spinner.pcmf_insertColorandFontandBorder(l_main);
086: l_main = l_spinner.pcmf_insertPosition(l_main);
087: l_main = l_spinner.pcmf_insertChannelandMenu(l_main);
088:
089: l_main.pcmf_beginTR();
090:
091: int l_talign = l_spinner.pcmf_getTextAlign();
092: if (l_talign == IUnInputField.TEXT_ALIGN_EAST)
093: KeTools.pcmf_stringSubst(l_main, "$TALIGN", "right");
094: else if (l_talign == IUnInputField.TEXT_ALIGN_CENTER)
095: KeTools.pcmf_stringSubst(l_main, "$TALIGN", "center");
096: else
097: KeTools.pcmf_stringSubst(l_main, "$TALIGN", "left");
098:
099: l_main = KeTools.pcmf_stringSubst(l_main, "$OID", l_spinner
100: .pcmf_getObjName());
101: l_main = KeTools.pcmf_stringSubst(l_main, "$UP", l_spinner
102: .pcmf_getUpKey().pcmf_execView().toString());
103: l_main = KeTools.pcmf_stringSubst(l_main, "$DOWN", l_spinner
104: .pcmf_getDownKey().pcmf_execView().toString());
105:
106: Object l_selection = l_spinner.pcmf_getValues().get(
107: l_spinner.pcmf_getValue());
108: if (l_selection != null) {
109: if (l_selection instanceof String)
110: l_selection = KeTools.pcmf_deRefObj(l_selection
111: .toString());
112:
113: if (l_selection instanceof MuGenericComponent) {
114: l_selection = ((MuGenericComponent) l_selection)
115: .pcmf_execView();
116: KeTools.pcmf_stringSubst(l_main, "$SEL_VAL",
117: l_selection.toString());
118: KeTools.pcmf_stringSubst(l_main, "$STRING", l_selection
119: .toString());
120: KeTools.pcmf_stringSubst(l_main, "$CFGCOL", l_spinner
121: .pcmf_getFgColor());
122: KeTools.pcmf_stringSubst(l_main, "$CBGCOL", l_spinner
123: .pcmf_getBgColor());
124: } else if (l_selection instanceof IKeViewable) {
125: IKeView l_view = ((IKeViewable) l_selection)
126: .pcmf_getView();
127:
128: if (l_view instanceof UnIconValueView) {
129: UnIconValueView l_iv = (UnIconValueView) l_view;
130:
131: if (l_iv.pcmf_getFg() != null)
132: KeTools.pcmf_stringSubst(l_main, "$CFGCOL",
133: l_iv.pcmf_getFg());
134: else
135: KeTools.pcmf_stringSubst(l_main, "$CFGCOL",
136: l_spinner.pcmf_getFgColor());
137:
138: if (l_iv.pcmf_getBg() != null)
139: KeTools.pcmf_stringSubst(l_main, "$CBGCOL",
140: l_iv.pcmf_getBg());
141: else
142: KeTools.pcmf_stringSubst(l_main, "$CBGCOL",
143: l_spinner.pcmf_getBgColor());
144:
145: KeStringTemplate l_fstring = this .pcmf_insertFont(
146: l_iv.pcmf_getFontDesc(), l_spinner);
147: if (l_fstring != null)
148: KeTools.pcmf_stringSubst(l_main, "$ITEM_FONT",
149: l_fstring.toString());
150:
151: if (l_iv.pcmf_getStdIcon() != null) {
152: l_selection = l_iv.pcmf_getStdIcon()
153: .pcmf_getUnComponent().pcmf_execView()
154: + l_selection.toString();
155: KeTools.pcmf_stringSubst(l_main, "$SEL_VAL",
156: l_selection.toString());
157: } else
158: KeTools.pcmf_stringSubst(l_main, "$SEL_VAL",
159: l_selection.toString());
160: } else {
161: KeTools.pcmf_stringSubst(l_main, "$SEL_VAL",
162: l_selection.toString());
163: KeTools.pcmf_stringSubst(l_main, "$CFGCOL",
164: l_spinner.pcmf_getFgColor());
165: KeTools.pcmf_stringSubst(l_main, "$CBGCOL",
166: l_spinner.pcmf_getBgColor());
167: KeTools.pcmf_stringSubst(l_main, "$ITEM_FONT", "");
168: }
169: } else {
170: KeTools.pcmf_stringSubst(l_main, "$SEL_VAL",
171: l_selection.toString());
172: KeTools.pcmf_stringSubst(l_main, "$CFGCOL", l_spinner
173: .pcmf_getFgColor());
174: KeTools.pcmf_stringSubst(l_main, "$CBGCOL", l_spinner
175: .pcmf_getBgColor());
176: KeTools.pcmf_stringSubst(l_main, "$ITEM_FONT", "");
177: }
178: } else {
179: l_main = KeTools.pcmf_stringSubst(l_main, "$SEL_VAL", "");
180: KeTools.pcmf_stringSubst(l_main, "$CFGCOL", l_spinner
181: .pcmf_getFgColor());
182: KeTools.pcmf_stringSubst(l_main, "$CBGCOL", l_spinner
183: .pcmf_getBgColor());
184: }
185:
186: l_main.pcmf_endTR(true);
187:
188: return (l_main.toString());
189: }
190: }
|