2 * Copyright (c) 2017 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.
19 using System.Runtime.InteropServices;
21 using Tizen.NUI.UIComponents;
22 using Tizen.NUI.BaseComponents;
23 using Tizen.NUI.Constants;
27 class Example : NUIApplication
29 public Example() : base()
33 public Example(string stylesheet) : base(stylesheet)
37 public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
41 protected override void OnCreate()
47 public void Initialize()
49 Window window = Window.Instance;
50 window.BackgroundColor = Color.White;
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);
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);
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;
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);
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;
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;
103 field.InputMethodSettings = inputMethod.OutputMap;
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));
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));
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);
127 editor.TextChanged += (obj, e) => {
128 Tizen.Log.Debug("NUI", "editor line count: " + e.TextEditor.LineCount);
131 editor.ScrollStateChanged += (obj, e)=> {
132 Tizen.Log.Debug("NUI", "editor scroll state:" + e.ScrollState);
135 Tizen.Log.Debug("NUI", "editor id: " + editor.ID);
137 FocusManager.Instance.SetCurrentFocusView(editor);
138 editor.UpFocusableView = field;
139 field.DownFocusableView = editor;
143 static void _Main(string[] args)
145 Example example = new Example();