3 // Permission is hereby granted, free of charge, to any person obtaining
4 // a copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to
8 // permit persons to whom the Software is furnished to do so, subject to
9 // the following conditions:
11 // The above copyright notice and this permission notice shall be
12 // included in all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 * Namespace : System.Web.UI.MobileControls.Adapters
25 * Class : HtmlMobileTextWriter
26 * Author : Gaurav Vaish
28 * Copyright : 2003 with Gaurav Vaish, and with
34 using System.Web.Mobile;
36 namespace System.Web.UI.MobileControls.Adapters
38 public class HtmlMobileTextWriter : MobileTextWriter
40 private bool beforeFirstControlWritten = true;
41 private bool maintainState = true;
42 private bool renderBodyColor = true;
43 private bool renderBold = true;
44 private bool renderDivAlign = true;
45 private bool renderDivNoWrap = false;
46 private bool renderFontColor = true;
47 private bool renderFontName = true;
48 private bool renderFontSize = true;
49 private bool renderItalic = true;
50 private bool requiresNoBreak = false;
51 private bool shouldEnsureStyle = true;
53 private WriterState currentState;
56 public HtmlMobileTextWriter(TextWriter writer,
57 MobileCapabilities capabilities)
58 : base(writer, capabilities)
60 RenderBold = capabilities.SupportsBold;
61 RenderItalic = capabilities.SupportsItalic;
62 RenderFontSize = capabilities.SupportsFontSize;
63 RenderFontName = capabilities.SupportsFontName;
64 RenderFontColor = capabilities.SupportsFontColor;
65 RenderBodyColor = capabilities.SupportsBodyColor;
66 RenderDivAlign = capabilities.SupportsDivAlign;
67 RenderDivNoWrap = capabilities.SupportsDivNoWrap;
68 RequiresNoBreakInFormatting = capabilities.RequiresNoBreakInFormatting;
70 currentState = new WriterState(this);
73 public bool BeforeFirstControlWritten
77 return beforeFirstControlWritten;
81 beforeFirstControlWritten = value;
85 public bool MaintainState
93 maintainState = value;
97 public bool RenderBodyColor
101 return renderBodyColor;
105 renderBodyColor = value;
109 public bool RenderBold
121 public bool RenderDivAlign
125 return renderDivAlign;
129 renderDivAlign = value;
133 public bool RenderDivNoWrap
137 return renderDivNoWrap;
141 renderDivNoWrap = value;
145 public bool RenderFontColor
149 return renderFontColor;
153 renderFontColor = value;
157 public bool RenderFontName
161 return renderFontName;
165 renderFontName = value;
169 public bool RenderFontSize
173 return renderFontSize;
177 renderFontSize = value;
181 public bool RenderItalic
189 renderItalic = value;
193 public bool RequiresNoBreakInFormatting
197 return requiresNoBreak;
201 requiresNoBreak = value;
205 public bool ShouldEnsureStyle
209 return shouldEnsureStyle;
213 shouldEnsureStyle = value;
218 public void EnterLayout(Style style)
220 throw new NotImplementedException();
224 public void ExitLayout(Style style, bool breakAfter)
226 throw new NotImplementedException();
230 public void EnterStyle(System.Web.UI.MobileControls.Style style)
232 throw new NotImplementedException();
235 private void EnterStyle(WriterStyle style)
237 currentState.Push(style);
240 public void ExitStyle(Style style)
242 ExitStyle(style, false);
246 public void ExitStyle(Style style, bool breakAfter)
248 throw new NotImplementedException();
252 public void WriteText(string text, bool encode)
254 throw new NotImplementedException();
258 public override void Write(char c)
260 throw new NotImplementedException();
264 public override void Write(string text)
266 throw new NotImplementedException();
269 public void BeginStyleContext()
271 if(currentState.IsBreakPending)
274 currentState.IsBreakPending = false;
276 currentState.PushState();
277 EnterStyle(new WriterStyle());
280 public void EndStyleContext()
282 if(currentState.IsBreakPending)
285 currentState.IsBreakPending = false;
287 currentState.PopState();
289 currentState.Transition(new WriterStyle());
292 public void EnterFormat(Style style)
294 WriterStyle wstyle = new WriterStyle(style);
295 wstyle.Layout = false;
299 public virtual void ExitFormat(Style style)
304 public void WriteBreak()
309 public override void WriteLine(string text)
312 base.WriteLine(text);
315 internal void EnsureStyle()
317 if(shouldEnsureStyle)
319 if(currentState.Count > 0)
321 currentState.Transition(currentState.Peek());
323 shouldEnsureStyle = false;
325 if(BeforeFirstControlWritten)
327 BeforeFirstControlWritten = false;