Review Elmsharp API cs files
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / ProgressBar.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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 using System;
18
19 namespace ElmSharp
20 {
21     /// <summary>
22     /// The ProgressBar is a widget for visually representing the progress status of a given job or task.
23     /// </summary>
24     /// <since_tizen> preview </since_tizen>
25     public class ProgressBar : Layout
26     {
27         SmartEvent _changed;
28
29         /// <summary>
30         /// Creates and initializes a new instance of the ProgressBar class.
31         /// </summary>
32         /// <param name="parent">The EvasObject to which the new ProgressBar will be attached as a child.</param>
33         /// <since_tizen> preview </since_tizen>
34         public ProgressBar(EvasObject parent) : base(parent)
35         {
36             _changed = new SmartEvent(this, this.RealHandle, "changed");
37             _changed.On += (s, e) =>
38             {
39                 ValueChanged?.Invoke(this, EventArgs.Empty);
40             };
41         }
42
43         /// <summary>
44         /// ValueChanged will be triggered when the value of the ProgressBar changes.
45         /// </summary>
46         /// <since_tizen> preview </since_tizen>
47         public event EventHandler ValueChanged;
48
49         /// <summary>
50         /// Sets or gets the value whether a given ProgressBar widget is at the "pulsing mode".
51         /// </summary>
52         /// <remarks>
53         /// By default, progress bars display values from low to high value boundaries.
54         /// There are, though, contexts in which the progress of a given task is unknown.
55         /// For such cases, one can set the progress bar widget to a "pulsing state",
56         /// to give the user an idea that some computation is being held,
57         /// but without the exact progress values. In the default theme,
58         /// it animates its bar with the contents filling in constantly and back to non-filled, in a loop.
59         /// </remarks>
60         /// <since_tizen> preview </since_tizen>
61         public bool IsPulseMode
62         {
63             get
64             {
65                 return Interop.Elementary.elm_progressbar_pulse_get(RealHandle);
66             }
67             set
68             {
69                 Interop.Elementary.elm_progressbar_pulse_set(RealHandle, value);
70             }
71         }
72
73         /// <summary>
74         /// Sets or gets the value of the ProgressBar.
75         /// </summary>
76         /// <remarks>
77         /// Use this property to set the progress bar levels.
78         /// If you pass a value out of the specified range (0.0~1.0),
79         /// it is interpreted as the closest of the boundary values in the range.
80         /// </remarks>
81         /// <since_tizen> preview </since_tizen>
82         public double Value
83         {
84             get
85             {
86                 return Interop.Elementary.elm_progressbar_value_get(RealHandle);
87             }
88             set
89             {
90                 Interop.Elementary.elm_progressbar_value_set(RealHandle, value);
91             }
92         }
93
94         /// <summary>
95         /// Sets or gets the span value of the ProgressBar.
96         /// </summary>
97         /// <since_tizen> preview </since_tizen>
98         public int SpanSize
99         {
100             get
101             {
102                 return Interop.Elementary.elm_progressbar_span_size_get(RealHandle);
103             }
104             set
105             {
106                 Interop.Elementary.elm_progressbar_span_size_set(RealHandle, value);
107             }
108         }
109
110         /// <summary>
111         /// Sets or gets the value whether a given ProgressBar widget is horizontal.
112         /// </summary>
113         /// <since_tizen> preview </since_tizen>
114         public bool IsHorizontal
115         {
116             get
117             {
118                 return Interop.Elementary.elm_progressbar_horizontal_get(RealHandle);
119             }
120             set
121             {
122                 Interop.Elementary.elm_progressbar_horizontal_set(RealHandle, value);
123             }
124         }
125
126         /// <summary>
127         /// Sets or gets the value whether a given progress bar widget's displaying values are inverted.
128         /// </summary>
129         /// <since_tizen> preview </since_tizen>
130         public bool IsInverted
131         {
132             get
133             {
134                 return Interop.Elementary.elm_progressbar_inverted_get(RealHandle);
135             }
136             set
137             {
138                 Interop.Elementary.elm_progressbar_inverted_set(RealHandle, value);
139             }
140         }
141
142         /// <summary>
143         /// Sets or gets the format string for a given progress bar widget's units label.
144         /// </summary>
145         /// <remarks>
146         /// If null is passed on format, it makes the object units area to be hidden completely.
147         /// If not, it sets the format string for the units label's text.
148         /// The units label are provided with a floating point value, so the units text displays at the most one floating point value.
149         /// Note that the units label is optional. Use a format string such as "%1.2f meters" for example.
150         /// </remarks>
151         /// <since_tizen> preview </since_tizen>
152         public string UnitFormat
153         {
154             get
155             {
156                 return Interop.Elementary.elm_progressbar_unit_format_get(RealHandle);
157             }
158             set
159             {
160                 Interop.Elementary.elm_progressbar_unit_format_set(RealHandle, value);
161             }
162         }
163
164         /// <summary>
165         /// Starts a given progress bar "pulsing" animation, if its under that mode.
166         /// </summary>
167         /// <since_tizen> preview </since_tizen>
168         public void PlayPulse()
169         {
170             Interop.Elementary.elm_progressbar_pulse(RealHandle, true);
171         }
172
173         /// <summary>
174         /// Stops a given progress bar "pulsing" animation, if its under that mode.
175         /// </summary>
176         /// <since_tizen> preview </since_tizen>
177         [Obsolete("use StopPulse instead")]
178         public void StopPluse()
179         {
180             Interop.Elementary.elm_progressbar_pulse(RealHandle, false);
181         }
182
183         /// <summary>
184         /// Stops a given progress bar "pulsing" animation, if its under that mode.
185         /// </summary>
186         /// <since_tizen> preview </since_tizen>
187         public void StopPulse()
188         {
189             Interop.Elementary.elm_progressbar_pulse(RealHandle, false);
190         }
191
192         /// <summary>
193         /// Gets the part value of a given part of the Progressbar.
194         /// </summary>
195         /// <param name="part">Part of the Progressbar.</param>
196         /// <returns>Value range is from 0.0 to 1.0.</returns>
197         /// <since_tizen> preview </since_tizen>
198         public double GetPartValue(string part)
199         {
200             return Interop.Elementary.elm_progressbar_part_value_get(RealHandle, part);
201         }
202
203         /// <summary>
204         /// Sets or gets the general or main color of the given Progressbar.
205         /// </summary>
206         /// <since_tizen> preview </since_tizen>
207         public override Color Color
208         {
209             get
210             {
211                 return GetPartColor("bar");
212             }
213             set
214             {
215                 SetPartColor("bar", value);
216             }
217         }
218
219         /// <summary>
220         /// Sets the part value of a given part of the Progressbar.
221         /// </summary>
222         /// <param name="part">Part of the Progressbar.</param>
223         /// <param name="value">Value range is from 0.0 to 1.0.</param>
224         /// <since_tizen> preview </since_tizen>
225         public void SetPartValue(string part, double value)
226         {
227             Interop.Elementary.elm_progressbar_part_value_set(RealHandle, part, value);
228         }
229
230         /// <summary>
231         /// Creates a widget handle.
232         /// </summary>
233         /// <param name="parent">Parent EvasObject.</param>
234         /// <returns>Handle IntPtr.</returns>
235         /// <since_tizen> preview </since_tizen>
236         protected override IntPtr CreateHandle(EvasObject parent)
237         {
238             IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
239             Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
240
241             RealHandle = Interop.Elementary.elm_progressbar_add(handle);
242             Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
243
244             return handle;
245         }
246     }
247 }