2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 /// A class encapsulating the property map of the text visual.
23 /// <since_tizen> 3 </since_tizen>
24 public class TextVisual : VisualMap
26 static private float defaultPointSize = 18;
27 private string text = null;
28 private string fontFamily = null;
29 private PropertyMap fontStyle = null;
30 private float pointSize = defaultPointSize;
31 private bool? multiLine = null;
32 private string horizontalAlignment = null;
33 private string verticalAlignment = null;
34 private Color textColor = null;
35 private bool? enableMarkup = null;
36 private PropertyMap shadow = null;
37 private PropertyMap underline = null;
38 private PropertyMap outline = null;
39 private PropertyMap background = null;
44 /// <since_tizen> 3 </since_tizen>
45 public TextVisual() : base()
50 /// Gets or sets the text to display in the UTF-8 format.<br />
53 /// <since_tizen> 3 </since_tizen>
68 /// Gets or sets the requested font family to use.<br />
71 /// <since_tizen> 3 </since_tizen>
72 public string FontFamily
86 /// Gets or sets the requested font style to use.<br />
89 /// <since_tizen> 3 </since_tizen>
90 public PropertyMap FontStyle
104 /// Gets or sets the size of font in points.<br />
107 /// <since_tizen> 3 </since_tizen>
108 public float PointSize
122 /// Gets or sets the single-line or multi-line layout option.<br />
123 /// If not specified, the default is false.<br />
126 /// <since_tizen> 3 </since_tizen>
127 public bool MultiLine
131 return multiLine ?? (false);
141 /// Gets or sets the line horizontal alignment.<br />
142 /// If not specified, the default is begin.<br />
145 /// <since_tizen> 3 </since_tizen>
146 public HorizontalAlignment HorizontalAlignment
150 switch (horizontalAlignment)
153 return HorizontalAlignment.Begin;
155 return HorizontalAlignment.Center;
157 return HorizontalAlignment.End;
159 return HorizontalAlignment.Begin;
166 case HorizontalAlignment.Begin:
168 horizontalAlignment = "BEGIN";
171 case HorizontalAlignment.Center:
173 horizontalAlignment = "CENTER";
176 case HorizontalAlignment.End:
178 horizontalAlignment = "END";
183 horizontalAlignment = "BEGIN";
192 /// Gets or sets the line vertical alignment.<br />
193 /// If not specified, the default is top.<br />
196 /// <since_tizen> 3 </since_tizen>
197 public VerticalAlignment VerticalAlignment
201 switch (verticalAlignment)
204 return VerticalAlignment.Top;
206 return VerticalAlignment.Center;
208 return VerticalAlignment.Bottom;
210 return VerticalAlignment.Top;
217 case VerticalAlignment.Top:
219 verticalAlignment = "TOP";
222 case VerticalAlignment.Center:
224 verticalAlignment = "CENTER";
227 case VerticalAlignment.Bottom:
229 verticalAlignment = "BOTTOM";
234 verticalAlignment = "TOP";
243 /// Gets or sets the color of the text.<br />
246 /// <since_tizen> 3 </since_tizen>
247 public Color TextColor
261 /// Gets or sets whether the mark-up processing is enabled.<br />
264 /// <since_tizen> 3 </since_tizen>
265 public bool EnableMarkup
269 return enableMarkup ?? (false);
273 enableMarkup = value;
279 /// Gets or sets the shadow parameters.
281 /// <since_tizen> 5 </since_tizen>
282 public PropertyMap Shadow
296 /// Gets or sets the underline parameters.
298 /// <since_tizen> 5 </since_tizen>
299 public PropertyMap Underline
313 /// Gets or sets the outline parameters.
315 /// <since_tizen> 5 </since_tizen>
316 public PropertyMap Outline
330 /// Gets or sets the background parameters.
332 /// <since_tizen> 5 </since_tizen>
333 public PropertyMap Background
347 /// Compose the out visual map.
349 /// <since_tizen> 3 </since_tizen>
350 protected override void ComposingPropertyMap()
352 _outputVisualMap = new PropertyMap();
356 PropertyValue temp = new PropertyValue((int)Visual.Type.Text);
357 _outputVisualMap.Add(Visual.Property.Type, temp);
360 temp = new PropertyValue(text);
361 _outputVisualMap.Add(TextVisualProperty.Text, temp);
364 temp = new PropertyValue((float)pointSize);
365 _outputVisualMap.Add(TextVisualProperty.PointSize, temp);
368 if (fontFamily != null)
370 temp = new PropertyValue(fontFamily);
371 _outputVisualMap.Add(TextVisualProperty.FontFamily, temp);
374 if (fontStyle != null)
376 temp = new PropertyValue(fontStyle);
377 _outputVisualMap.Add(TextVisualProperty.FontStyle, temp);
380 if (multiLine != null)
382 temp = new PropertyValue((bool)multiLine);
383 _outputVisualMap.Add(TextVisualProperty.MultiLine, temp);
386 if (horizontalAlignment != null)
388 temp = new PropertyValue(horizontalAlignment);
389 _outputVisualMap.Add(TextVisualProperty.HorizontalAlignment, temp);
392 if (verticalAlignment != null)
394 temp = new PropertyValue(verticalAlignment);
395 _outputVisualMap.Add(TextVisualProperty.VerticalAlignment, temp);
398 if (textColor != null)
400 temp = new PropertyValue(textColor);
401 _outputVisualMap.Add(TextVisualProperty.TextColor, temp);
404 if (enableMarkup != null)
406 temp = new PropertyValue((bool)enableMarkup);
407 _outputVisualMap.Add(TextVisualProperty.EnableMarkup, temp);
412 temp = new PropertyValue(shadow);
413 _outputVisualMap.Add(TextVisualProperty.Shadow, temp);
416 if (underline != null)
418 temp = new PropertyValue(underline);
419 _outputVisualMap.Add(TextVisualProperty.Underline, temp);
424 temp = new PropertyValue(outline);
425 _outputVisualMap.Add(TextVisualProperty.Outline, temp);
428 if (background != null)
430 temp = new PropertyValue(background);
431 _outputVisualMap.Add(TextVisualProperty.Background, temp);
434 base.ComposingPropertyMap();