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.util.*;
034:
035: import de.ug2t.channel.markup.generic.*;
036: import de.ug2t.channel.markup.html.*;
037: import de.ug2t.kernel.*;
038: import de.ug2t.unifiedGui.*;
039: import de.ug2t.unifiedGui.interfaces.*;
040:
041: public class HtmlBoxRenderer extends AMuGenericComponentRenderer {
042: public String pcmf_render(MuGenericComponent xWidget) {
043: MuGenericBox l_box = (MuGenericBox) xWidget;
044:
045: l_box.pcmf_checkConstraints();
046:
047: KeStringTemplate l_main = null;
048: KeStringTemplate l_body = null;
049: KeStringTemplate l_flex = null;
050: KeStringTemplate l_borders = l_box
051: .pcmf_getMarkupString("BORDERSTYLES");
052:
053: if (l_box.pcmf_getBoxType() == IUnBox.LAYOUTED) {
054: if (l_box.pcmf_getBoxHVType() == IUnBox.HBOX) {
055: l_main = l_box.pcmf_getMarkupString("MAINH");
056: l_body = l_box.pcmf_getMarkupString("BODYH");
057: l_flex = l_box.pcmf_getMarkupString("FLEXH");
058: } else {
059: l_main = l_box.pcmf_getMarkupString("MAINV");
060: l_body = l_box.pcmf_getMarkupString("BODYV");
061: l_flex = l_box.pcmf_getMarkupString("FLEXV");
062: }
063: } else if (l_box.pcmf_getBoxType() == IUnBox.SIMPLE) {
064: if (l_box.pcmf_getBoxHVType() == IUnBox.HBOX) {
065: l_main = l_box.pcmf_getMarkupString("MAINHS");
066: l_body = l_box.pcmf_getMarkupString("BODYHS");
067: l_flex = l_box.pcmf_getMarkupString("FLEXHS");
068: } else {
069: l_main = l_box.pcmf_getMarkupString("MAINVS");
070: l_body = l_box.pcmf_getMarkupString("BODYVS");
071: l_flex = l_box.pcmf_getMarkupString("FLEXVS");
072: }
073: } else {
074: l_main = l_box.pcmf_getMarkupString("MAINSP");
075: // l_body = l_box.pcmf_getMarkupString("{$BODY}");
076: // l_flex = l_box.pcmf_getMarkupString("");
077: }
078:
079: Iterator l_it = l_box.pcmf_getSubIterator();
080:
081: KeStringTemplate l_mbody = new KeStringTemplate("");
082: KeTreeElement l_el = null;
083:
084: while (l_it.hasNext()) {
085: l_el = (KeTreeElement) l_it.next();
086:
087: if (l_box.pcmf_getBoxType() != IUnBox.SINGLE) {
088: KeStringTemplate l_bodypart = new KeStringTemplate(
089: l_body);
090:
091: l_bodypart.pcmf_beginTR();
092:
093: int l_constraint = l_box
094: .pcmf_getConstaint((UnComponent) l_el);
095:
096: switch (l_constraint) {
097: case IUnBox.BOX_CONSTRAINT_FLEXFILLX:
098: ((MuGenericComponent) l_el).pcmf_setFill(true,
099: false);
100: l_bodypart = l_bodypart.pcmf_stringSubst("$FLEX",
101: l_box.pcmf_getMarkupString("FLEXH")
102: .toString());
103: break;
104: case IUnBox.BOX_CONSTRAINT_FLEXFILLY:
105: ((MuGenericComponent) l_el).pcmf_setFill(false,
106: true);
107: l_bodypart = l_bodypart.pcmf_stringSubst("$FLEX",
108: l_box.pcmf_getMarkupString("FLEXV")
109: .toString());
110: break;
111: case IUnBox.BOX_CONSTRAINT_FLEXFILLXY:
112: ((MuGenericComponent) l_el)
113: .pcmf_setFill(true, true);
114: l_bodypart = l_bodypart.pcmf_stringSubst("$FLEX",
115: l_box.pcmf_getMarkupString("FLEXHV")
116: .toString());
117: break;
118: case IUnBox.BOX_CONSTRAINT_FLEX:
119: l_bodypart = l_bodypart.pcmf_stringSubst("$FLEX",
120: l_flex.toString());
121: break;
122: default:
123: l_bodypart = l_bodypart.pcmf_stringSubst("$FLEX",
124: "");
125: }
126:
127: l_bodypart = l_bodypart.pcmf_stringSubst("$GAP",
128: Integer.toString(l_box.pcmf_getGap()));
129:
130: l_bodypart = l_bodypart.pcmf_stringSubst("$VALIGN",
131: HtmlTools.pcmf_getAlignCssVertical(l_box
132: .pcmf_getBoxAlign()));
133: l_bodypart = l_bodypart.pcmf_stringSubst("$HALIGN",
134: HtmlTools.pcmf_getAlignCssText(l_box
135: .pcmf_getBoxAlign()));
136: l_bodypart = l_bodypart.pcmf_stringSubst("$BODY", l_el
137: .pcmf_execView().toString());
138:
139: l_bodypart.pcmf_endTR(true);
140:
141: l_mbody.pcmf_stringAddEnd(l_bodypart);
142: }
143: }
144:
145: l_main = l_box.pcmf_insertToolTip(l_main);
146: l_main = l_box.pcmf_insertColorandFontandBorder(l_main);
147: l_main = l_box.pcmf_insertPosition(l_main);
148: l_main = l_box.pcmf_insertChannelandMenu(l_main);
149:
150: l_main.pcmf_beginTR();
151:
152: UnFixedSize l_fsize = l_box.pcmf_getFixedSize();
153: boolean l_hf = false;
154: boolean l_wf = false;
155:
156: if (l_fsize != null) {
157: l_hf = l_fsize.pcmf_getH() != -2;
158: l_wf = l_fsize.pcmf_getW() != -2;
159: }
160:
161: if (l_box.pcmf_getBoxHVType() == IUnBox.HBOX
162: && (l_box.pcmf_getHFill() || l_wf))
163: l_main = l_main
164: .pcmf_stringSubst("$BFILL", "width=\"100%\"");
165: else if (l_box.pcmf_getBoxHVType() == IUnBox.VBOX
166: && (l_box.pcmf_getVFill() || l_hf))
167: l_main = l_main.pcmf_stringSubst("$BFILL",
168: "height=\"100%\"");
169: else
170: l_main = l_main.pcmf_stringSubst("$BFILL", "");
171:
172: UnBoxBorder l_bl = l_box.pcmf_getBorder(IUnBox.LEFT);
173: UnBoxBorder l_br = l_box.pcmf_getBorder(IUnBox.RIGHT);
174: UnBoxBorder l_bb = l_box.pcmf_getBorder(IUnBox.BOTTOM);
175: UnBoxBorder l_bt = l_box.pcmf_getBorder(IUnBox.TOP);
176:
177: l_main = l_main.pcmf_stringSubst("$OID", l_box
178: .pcmf_getObjName());
179:
180: if (l_bl == null && l_br == null && l_bb == null
181: && l_bt == null)
182: l_main.pcmf_stringSubst("$BORDERSTYLES", "");
183: else {
184: l_main.pcmf_stringdirectSubst("$BORDERSTYLES",
185: new KeStringTemplate(l_borders));
186:
187: if (l_bl != null) {
188: l_main = l_main.pcmf_stringSubst("$BWL", Integer
189: .toString(l_bl.pcm_width));
190: l_main = l_main
191: .pcmf_stringSubst("$BCL", l_bl.pcm_color);
192: l_main = l_main.pcmf_stringSubst("$BSL",
193: IUnBox.BORDER_STYLES[l_bl.pcm_style]);
194: } else {
195: l_main = l_main.pcmf_stringSubst("$BWL", "0");
196: l_main = l_main.pcmf_stringSubst("$BCL", "black");
197: l_main = l_main.pcmf_stringSubst("$BSL", "none");
198: }
199:
200: if (l_br != null) {
201: l_main = l_main.pcmf_stringSubst("$BWR", Integer
202: .toString(l_br.pcm_width));
203: l_main = l_main
204: .pcmf_stringSubst("$BCR", l_br.pcm_color);
205: l_main = l_main.pcmf_stringSubst("$BSR",
206: IUnBox.BORDER_STYLES[l_br.pcm_style]);
207: } else {
208: l_main = l_main.pcmf_stringSubst("$BWR", "0");
209: l_main = l_main.pcmf_stringSubst("$BCR", "black");
210: l_main = l_main.pcmf_stringSubst("$BSR", "none");
211: }
212:
213: if (l_bt != null) {
214: l_main = l_main.pcmf_stringSubst("$BWT", Integer
215: .toString(l_bt.pcm_width));
216: l_main = l_main
217: .pcmf_stringSubst("$BCT", l_bt.pcm_color);
218: l_main = l_main.pcmf_stringSubst("$BST",
219: IUnBox.BORDER_STYLES[l_bt.pcm_style]);
220: } else {
221: l_main = l_main.pcmf_stringSubst("$BWT", "0");
222: l_main = l_main.pcmf_stringSubst("$BCT", "black");
223: l_main = l_main.pcmf_stringSubst("$BST", "none");
224: }
225:
226: if (l_bb != null) {
227: l_main = l_main.pcmf_stringSubst("$BWB", Integer
228: .toString(l_bb.pcm_width));
229: l_main = l_main
230: .pcmf_stringSubst("$BCB", l_bb.pcm_color);
231: l_main = l_main.pcmf_stringSubst("$BSB",
232: IUnBox.BORDER_STYLES[l_bb.pcm_style]);
233: } else {
234: l_main = l_main.pcmf_stringSubst("$BWB", "0");
235: l_main = l_main.pcmf_stringSubst("$BCB", "black");
236: l_main = l_main.pcmf_stringSubst("$BSB", "none");
237: }
238: }
239:
240: if (l_box.pcmf_getBoxType() == IUnBox.SINGLE) {
241: l_main = l_main.pcmf_stringSubst("$BODY", l_el
242: .pcmf_execView().toString());
243:
244: if (l_box.pcmf_getAlign().toUpperCase().endsWith("EAST"))
245: l_main = l_main.pcmf_stringSubst("$FLOAT", "right");
246: else
247: l_main = l_main.pcmf_stringSubst("$FLOAT", "left");
248: }
249:
250: if (l_box.pcmf_getMargin(IUnBox.LEFT) != 0
251: || l_box.pcmf_getMargin(IUnBox.TOP) != 0
252: || l_box.pcmf_getMargin(IUnBox.RIGHT) != 0
253: || l_box.pcmf_getMargin(IUnBox.BOTTOM) != 0) {
254: l_main.pcmf_stringdirectSingleSubst("$MARGIN", l_box
255: .pcmf_getMarkupString("MARGIN"));
256:
257: l_main = l_main.pcmf_stringSubst("$ML", Integer
258: .toString(l_box.pcmf_getMargin(IUnBox.LEFT)));
259: l_main = l_main.pcmf_stringSubst("$MT", Integer
260: .toString(l_box.pcmf_getMargin(IUnBox.TOP)));
261: l_main = l_main.pcmf_stringSubst("$MB", Integer
262: .toString(l_box.pcmf_getMargin(IUnBox.BOTTOM)));
263: l_main = l_main.pcmf_stringSubst("$MR", Integer
264: .toString(l_box.pcmf_getMargin(IUnBox.RIGHT)));
265: } else
266: l_main.pcmf_stringdirectSingleSubst("$MARGIN", "");
267:
268: if (l_box.pcmf_getPadding(IUnBox.LEFT) != 0
269: || l_box.pcmf_getPadding(IUnBox.TOP) != 0
270: || l_box.pcmf_getPadding(IUnBox.RIGHT) != 0
271: || l_box.pcmf_getPadding(IUnBox.BOTTOM) != 0) {
272: l_main.pcmf_stringdirectSingleSubst("$PADDING", l_box
273: .pcmf_getMarkupString("PADDING"));
274:
275: l_main = l_main.pcmf_stringSubst("$PL", Integer
276: .toString(l_box.pcmf_getPadding(IUnBox.LEFT)));
277: l_main = l_main.pcmf_stringSubst("$PT", Integer
278: .toString(l_box.pcmf_getPadding(IUnBox.TOP)));
279: l_main = l_main.pcmf_stringSubst("$PB", Integer
280: .toString(l_box.pcmf_getPadding(IUnBox.BOTTOM)));
281: l_main = l_main.pcmf_stringSubst("$PR", Integer
282: .toString(l_box.pcmf_getPadding(IUnBox.RIGHT)));
283: } else
284: l_main.pcmf_stringdirectSingleSubst("$PADDING", "");
285:
286: l_main = l_main.pcmf_stringSubst("$VALIGN", HtmlTools
287: .pcmf_getAlignCssVertical(l_box.pcmf_getBoxAlign()));
288: l_main = l_main.pcmf_stringSubst("$HALIGN", HtmlTools
289: .pcmf_getAlignCssText(l_box.pcmf_getBoxAlign()));
290:
291: l_main.pcmf_endTR(true);
292:
293: l_main = l_main.pcmf_stringSubst("$BODY", l_mbody.toString());
294:
295: return (l_main.toString());
296: }
297: }
|