Add API comments
[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/task.
23     /// </summary>
24     public class ProgressBar : Layout
25     {
26         SmartEvent _changed;
27
28         /// <summary>
29         /// Creates and initializes a new instance of the ProgressBar class.
30         /// </summary>
31         /// <param name="parent">The EvasObject to which the new ProgressBar will be attached as a child.</param>
32         public ProgressBar(EvasObject parent) : base(parent)
33         {
34             _changed = new SmartEvent(this, this.RealHandle, "changed");
35             _changed.On += (s, e) =>
36             {
37                 ValueChanged?.Invoke(this, EventArgs.Empty);
38             };
39         }
40
41         /// <summary>
42         /// ValueChanged will be triggered when value of ProgressBar change.
43         /// </summary>
44         public event EventHandler ValueChanged;
45
46         /// <summary>
47         /// Sets or gets the value wheather a given ProgressBar widget is at the "pulsing mode".
48         /// </summary>
49         /// <remarks>
50         /// By default, progress bars display values from low to high value boundaries.
51         /// There are, though, contexts in which the progress of a given task is unknown.
52         /// For such cases, one can set a progress bar widget to a "pulsing state",
53         /// to give the user an idea that some computation is being held,
54         /// but without exact progress values. In the default theme,
55         /// it animates its bar with the contents filling in constantly and back to non-filled, in a loop.
56         /// </remarks>
57         public bool IsPulseMode
58         {
59             get
60             {
61                 return Interop.Elementary.elm_progressbar_pulse_get(RealHandle);
62             }
63             set
64             {
65                 Interop.Elementary.elm_progressbar_pulse_set(RealHandle, value);
66             }
67         }
68
69         /// <summary>
70         /// Sets or gets the value of ProgressBar.
71         /// </summary>
72         public double Value
73         {
74             get
75             {
76                 return Interop.Elementary.elm_progressbar_value_get(RealHandle);
77             }
78             set
79             {
80                 Interop.Elementary.elm_progressbar_value_set(RealHandle, value);
81             }
82         }
83
84         /// <summary>
85         /// Sets or gets the span value of ProgressBar.
86         /// </summary>
87         public int SpanSize
88         {
89             get
90             {
91                 return Interop.Elementary.elm_progressbar_span_size_get(RealHandle);
92             }
93             set
94             {
95                 Interop.Elementary.elm_progressbar_span_size_set(RealHandle, value);
96             }
97         }
98
99         /// <summary>
100         /// Sets or gets the value wheather a given ProgressBar widget is horizontal.
101         /// </summary>
102         public bool IsHorizontal
103         {
104             get
105             {
106                 return Interop.Elementary.elm_progressbar_horizontal_get(RealHandle);
107             }
108             set
109             {
110                 Interop.Elementary.elm_progressbar_horizontal_set(RealHandle, value);
111             }
112         }
113
114         /// <summary>
115         /// Sets or gets the value whether a given progress bar widget's displaying values are inverted.
116         /// </summary>
117         public bool IsInverted
118         {
119             get
120             {
121                 return Interop.Elementary.elm_progressbar_inverted_get(RealHandle);
122             }
123             set
124             {
125                 Interop.Elementary.elm_progressbar_inverted_set(RealHandle, value);
126             }
127         }
128
129         /// <summary>
130         /// Sets or gets format string for a given progress bar widget's units label.
131         /// </summary>
132         /// <remarks>
133         /// If NULL is passed on format, it makes obj units area to be hidden completely.
134         /// If not, it sets the format string for the units label's text.
135         /// The units label is provided with a floating point value, so the units text displays at most one floating point value.
136         /// Note that the units label is optional. Use a format string such as "%1.2f meters" for example.
137         /// The default format string for a progress bar is an integer percentage, as in "%.0f %%".
138         /// </remarks>
139         public string UnitFormat
140         {
141             get
142             {
143                 return Interop.Elementary.elm_progressbar_unit_format_get(RealHandle);
144             }
145             set
146             {
147                 Interop.Elementary.elm_progressbar_unit_format_set(RealHandle, value);
148             }
149         }
150
151         /// <summary>
152         /// Starts a given progress bar "pulsing" animation, if its under that mode.
153         /// </summary>
154         public void PlayPulse()
155         {
156             Interop.Elementary.elm_progressbar_pulse(RealHandle, true);
157         }
158
159         [Obsolete("use StopPulse instead")]
160         public void StopPluse()
161         {
162             Interop.Elementary.elm_progressbar_pulse(RealHandle, false);
163         }
164
165         /// <summary>
166         /// Stops a given progress bar "pulsing" animation, if its under that mode.
167         /// </summary>
168         public void StopPulse()
169         {
170             Interop.Elementary.elm_progressbar_pulse(RealHandle, false);
171         }
172
173         protected override IntPtr CreateHandle(EvasObject parent)
174         {
175             IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
176             Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
177
178             RealHandle = Interop.Elementary.elm_progressbar_add(handle);
179             Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
180
181             return handle;
182         }
183     }
184 }