2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrlProgress.h
20 * @brief This is the header file for the %Progress class.
22 * This header file contains the declarations of the %Progress class and its helper classes.
25 #ifndef _FUI_CTRL_PROGRESS_H_
26 #define _FUI_CTRL_PROGRESS_H_
28 #include <FBaseObject.h>
29 #include <FBaseTypes.h>
30 #include <FUiControl.h>
31 #include <FUiContainer.h>
32 #include <FUiCtrlControlsTypes.h>
34 namespace Tizen { namespace Ui { namespace Controls
39 * @brief This class is an implementation of a %Progress control.
43 * The %Progress class displays the progress of a lengthy operation in a progress bar.
45 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_progress.htm">Progress</a>.
47 * The following example demonstrates how to use the %Progress class.
50 // Sample code for ProgressSample.h
54 : public Tizen::Ui::Controls::Form
55 , public Tizen::Ui::IActionEventListener
62 bool Initialize(void);
63 virtual result OnInitializing(void);
64 virtual void OnActionPerformed(const Tizen::Ui::Control&, int);
67 static const int ID_BUTTON_CHECKED = 100;
69 Tizen::Ui::Controls::Progress* __pProgress;
75 // Sample code for ProgressSample.cpp
76 #include <FGraphics.h>
78 #include "ProgressSample.h"
80 using namespace Tizen::Graphics;
81 using namespace Tizen::Ui::Controls;
84 ProgressSample::Initialize(void)
86 Construct(FORM_STYLE_NORMAL);
91 ProgressSample::OnInitializing(void)
95 // Creates an instance of Progress
96 __pProgress = new Progress();
97 __pProgress->Construct(Rectangle(50, 50, GetClientAreaBounds().width - 100, 100), 0, 100);
98 __pProgress->SetValue(__pValue);
100 // Creates an instance of pButton to control progress value
101 Button* pButton = new Button();
102 pButton->Construct(Rectangle(50, 200, 150, 100), L"Here");
103 pButton->SetActionId(ID_BUTTON_CHECKED);
104 pButton->AddActionEventListener(*this);
106 // Adds the __pProgress and the pButton to the form
107 AddControl(*__pProgress);
108 AddControl(*pButton);
114 ProgressSample::OnActionPerformed(const Control& source, int actionId)
118 case ID_BUTTON_CHECKED :
128 __pProgress->SetValue(__pValue);
129 __pProgress->Invalidate(true);
139 class _OSP_EXPORT_ Progress
140 : public Tizen::Ui::Control
144 * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
152 * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
156 virtual ~Progress(void);
160 * Initializes this instance of %Progress with the specified parameters.
164 * @return An error code
165 * @param[in] rect An instance of the Rectangle class @n
166 * This instance represents the x and y coordinates of the top-left corner of the created window along with
167 * its width and height.
168 * @param[in] minValue The minimum value of the current instance of %Progress
169 * @param[in] maxValue The maximum value of the current instance of %Progress
170 * @exception E_SUCCESS The method is successful.
171 * @exception E_INVALID_ARG A specified input parameter is invalid.
172 * @exception E_OUT_OF_RANGE The value of an argument is outside the valid range defined by the method. @n
173 * The specified values should be positive and @c minValue should be less than @c maxValue.
174 * @exception E_SYSTEM A system error has occurred.
175 * @remarks A control is fully usable only after it has been added to a container, therefore some methods may fail if used earlier. @n
176 * @remarks The size of the control must be within the range defined by the minimum size and the maximum size.
178 result Construct(const Tizen::Graphics::Rectangle& rect, int minValue, int maxValue);
181 * Initializes this instance of %Progress with the specified parameters.
185 * @return An error code
186 * @param[in] rect An instance of the FloatRectangle class @n
187 * This instance represents the x and y coordinates of the top-left corner of the created window along with
188 * its width and height.
189 * @param[in] minValue The minimum value of the current instance of %Progress
190 * @param[in] maxValue The maximum value of the current instance of %Progress
191 * @exception E_SUCCESS The method is successful.
192 * @exception E_INVALID_ARG A specified input parameter is invalid.
193 * @exception E_OUT_OF_RANGE The value of an argument is outside the valid range defined by the method. @n
194 * The specified values should be positive and @c minValue should be less than @c maxValue.
195 * @exception E_SYSTEM A system error has occurred.
196 * @remarks A control is fully usable only after it has been added to a container, therefore some methods may fail if used earlier. @n
197 * @remarks The size of the control must be within the range defined by the minimum size and the maximum size.
199 result Construct(const Tizen::Graphics::FloatRectangle& rect, int minValue, int maxValue);
203 * Sets the current value of the %Progress control. @n
204 * If the given value is greater than the @c maxValue with which %Progress is constructed, it will be set to %maxValue. The same applies for @c minValue.
208 * @param[in] value The current progress value
210 void SetValue(int value);
214 * Sets the minimum and maximum value of the %Progress control.
218 * @return An error code
219 * @param[in] minValue The minimum value of the current instance of %Progress
220 * @param[in] maxValue The maximum value of the current instance of %Progress
221 * @exception E_SUCCESS The method is successful.
222 * @exception E_INVALID_ARG A specified input parameter is invalid.
223 * @exception E_OUT_OF_RANGE The value of an argument is outside the valid range defined by the method. @n
224 * The specified values should be positive.
225 * @exception E_SYSTEM A system error has occurred.
227 result SetRange(int minValue, int maxValue);
231 * Gets the current value of the %Progress control.
235 * @return An integer value representing the current value of progress, @n
236 * else @c -1 if an error occurs
238 int GetValue(void) const;
242 * Gets the minimum value and the maximum value of the %Progress control.
246 * @param[out] minValue The minimum value
247 * @param[out] maxValue The maximum value
249 void GetRange(int& minValue, int& maxValue) const;
253 * Gets the percent value of the %Progress control.
257 * @return The progress as a percentage, @n
258 * else @c -1 if an error occurs
260 int GetPercentComplete(void) const;
264 * Sets the color of the bar.
268 * @return An error code
269 * @param[in] color The color to set
270 * @exception E_SUCCESS The method is successful.
271 * @exception E_SYSTEM A system error has occurred.
272 * @remarks The method ignores the alpha value of the @c color parameter and sets the alpha value to @c 255.
274 result SetBarColor(const Tizen::Graphics::Color& color);
278 * Gets the color of the bar.
282 * @return The color of the bar, @n
283 * else RGBA(0, 0, 0, 0) if an error occurs
284 * @exception E_SUCCESS The method is successful.
285 * @remarks The specific error code can be accessed using the GetLastResult() method.
287 Tizen::Graphics::Color GetBarColor(void) const;
291 * Sets the background color of the bar.
295 * @param[in] color The color to be set
296 * @remarks The method ignores the alpha value of the @c color parameter and sets the alpha value to @c 255.
297 * @see GetBarBackgroundColor()
299 void SetBarBackgroundColor(const Tizen::Graphics::Color& barBackgroundColor);
302 * Gets the background color of the bar.
306 * @return The background color of the bar, @n
307 * else RGBA(0, 0, 0, 0) if an error occurs
308 * @remarks The specific error code can be accessed using the GetLastResult() method.
309 * @see SetBarBackgroundColor()
311 Tizen::Graphics::Color GetBarBackgroundColor(void) const;
316 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
318 Progress(const Progress& rhs);
321 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
323 Progress& operator =(const Progress& rhs);
325 friend class _ProgressImpl;
329 }}} // Tizen::Ui::Controls
331 #endif // _FUI_CTRL_PROGRESS_H_