Revert "[Tizen] make SetClass() as public"
[platform/core/csapi/nui.git] / NUISamples / NUISamples / NUISamples.TizenTV / examples / text-test.cs
1 /*
2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 *
16 */
17
18 using System;
19 using System.Runtime.InteropServices;
20 using Tizen.NUI;
21 using Tizen.NUI.UIComponents;
22 using Tizen.NUI.BaseComponents;
23 using Tizen.NUI.Constants;
24
25 namespace TextTest
26 {
27     class Example : NUIApplication
28     {
29         public Example() : base()
30         {
31         }
32
33         public Example(string stylesheet) : base(stylesheet)
34         {
35         }
36
37         public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
38         {
39         }
40
41         protected override void OnCreate()
42         {
43             base.OnCreate();
44             Initialize();
45         }
46
47         public void Initialize()
48         {
49             Window window = Window.Instance;
50             window.BackgroundColor = Color.White;
51
52             TextLabel pixelLabel = new TextLabel("Test Pixel Size 32.0f");
53             pixelLabel.Position2D = new Position2D(10, 10);
54             pixelLabel.PixelSize = 32.0f;
55             pixelLabel.BackgroundColor = Color.Magenta;
56             window.Add(pixelLabel);
57
58             TextLabel pointLabel = new TextLabel("Test Point Size 32.0f");
59             pointLabel.Position2D = new Position2D(10, 100);
60             pointLabel.PointSize = 32.0f;
61             pointLabel.BackgroundColor = Color.Red;
62             window.Add(pointLabel);
63
64             TextLabel ellipsis = new TextLabel("Ellipsis of TextLabel is enabled.");
65             ellipsis.Size2D = new Size2D(100, 80);
66             ellipsis.Position2D = new Position2D(10, 200);
67             ellipsis.PointSize = 20.0f;
68             ellipsis.Ellipsis = true;
69             ellipsis.BackgroundColor = Color.Cyan;
70             window.Add(ellipsis);
71
72             TextLabel autoScrollStopMode = new TextLabel("AutoScrollStopMode is finish-loop.");
73             autoScrollStopMode.Size2D = new Size2D(400, 50);
74             autoScrollStopMode.Position2D = new Position2D(10, 300);
75             autoScrollStopMode.PointSize = 15.0f;
76             autoScrollStopMode.BackgroundColor = Color.Green;
77             autoScrollStopMode.AutoScrollStopMode = AutoScrollStopMode.FinishLoop;
78             autoScrollStopMode.EnableAutoScroll = true;
79             window.Add(autoScrollStopMode);
80
81             TextField field = new TextField();
82             field.Size2D = new Size2D(400, 100);
83             field.Position2D = new Position2D(10, 400);
84             field.BackgroundColor = Color.Cyan;
85             field.PlaceholderText = "input someth...";
86             field.PlaceholderTextFocused = "input someth... focused";
87             field.Focusable = true;
88             PropertyMap hiddenMap = new PropertyMap();
89             hiddenMap.Add(HiddenInputProperty.Mode, new PropertyValue((int)HiddenInputModeType.ShowLastCharacter));
90             hiddenMap.Add(HiddenInputProperty.ShowDuration, new PropertyValue(2));
91             hiddenMap.Add(HiddenInputProperty.SubstituteCount, new PropertyValue(4));
92             hiddenMap.Add(HiddenInputProperty.SubstituteCharacter, new PropertyValue(0x23));
93             field.HiddenInputSettings = hiddenMap;
94             field.EnableSelection = true;
95             window.Add(field);
96
97             InputMethod inputMethod = new InputMethod();
98             inputMethod.PanelLayout = InputMethod.PanelLayoutType.Number;
99             inputMethod.ActionButton = InputMethod.ActionButtonTitleType.Go;
100             inputMethod.AutoCapital = InputMethod.AutoCapitalType.Word;
101             inputMethod.Variation = 1;
102
103             field.InputMethodSettings = inputMethod.OutputMap;
104
105             PropertyMap propertyMap = new PropertyMap();
106             propertyMap.Add("placeholderText", new PropertyValue("Setting Placeholder Text"));
107             propertyMap.Add("placeholderTextFocused", new PropertyValue("Placeholder Text Focused"));
108             propertyMap.Add("placeholderColor", new PropertyValue(Color.Red));
109             propertyMap.Add("placeholderPointSize", new PropertyValue(12.0f));
110
111             PropertyMap fontStyleMap = new PropertyMap();
112             fontStyleMap.Add("weight", new PropertyValue("bold"));
113             fontStyleMap.Add("width", new PropertyValue("condensed"));
114             fontStyleMap.Add("slant", new PropertyValue("italic"));
115             propertyMap.Add("placeholderFontStyle", new PropertyValue(fontStyleMap));
116
117             TextEditor editor = new TextEditor();
118             editor.Size2D = new Size2D(400, 100);
119             editor.Position2D = new Position2D(10, 550);
120             editor.BackgroundColor = Color.Magenta;
121             editor.EnableScrollBar = true;
122             editor.EnableSelection = true;
123             editor.Focusable = true;
124             editor.Placeholder = propertyMap;
125             FocusManager.Instance.SetCurrentFocusView(editor);
126             window.Add(editor);
127             editor.TextChanged += (obj, e) => {
128                 Tizen.Log.Debug("NUI", "editor line count: " + e.TextEditor.LineCount);
129             };
130
131             editor.ScrollStateChanged += (obj, e)=> {
132                 Tizen.Log.Debug("NUI", "editor scroll state:" + e.ScrollState);
133             };
134
135             Tizen.Log.Debug("NUI",  "editor id: " + editor.ID);
136
137             FocusManager.Instance.SetCurrentFocusView(editor);
138             editor.UpFocusableView = field;
139             field.DownFocusableView = editor;
140         }
141
142         [STAThread]
143         static void _Main(string[] args)
144         {
145             Example example = new Example();
146             example.Run(args);
147         }
148     }
149 }