1a3e0fd82Sopenharmony_ci/*
2a3e0fd82Sopenharmony_ci * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3a3e0fd82Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4a3e0fd82Sopenharmony_ci * you may not use this file except in compliance with the License.
5a3e0fd82Sopenharmony_ci * You may obtain a copy of the License at
6a3e0fd82Sopenharmony_ci *
7a3e0fd82Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8a3e0fd82Sopenharmony_ci *
9a3e0fd82Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10a3e0fd82Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11a3e0fd82Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12a3e0fd82Sopenharmony_ci * See the License for the specific language governing permissions and
13a3e0fd82Sopenharmony_ci * limitations under the License.
14a3e0fd82Sopenharmony_ci */
15a3e0fd82Sopenharmony_ci
16a3e0fd82Sopenharmony_ci#include "components/ui_time_picker.h"
17a3e0fd82Sopenharmony_ci#include <cstdio>
18a3e0fd82Sopenharmony_ci#include <ctime>
19a3e0fd82Sopenharmony_ci#include "draw/draw_rect.h"
20a3e0fd82Sopenharmony_ci#include "gfx_utils/graphic_log.h"
21a3e0fd82Sopenharmony_ci#include "securec.h"
22a3e0fd82Sopenharmony_ci#include "themes/theme_manager.h"
23a3e0fd82Sopenharmony_ci
24a3e0fd82Sopenharmony_cinamespace OHOS {
25a3e0fd82Sopenharmony_ciUITimePicker::UITimePicker()
26a3e0fd82Sopenharmony_ci    : selectedValue_{0},
27a3e0fd82Sopenharmony_ci      selectedHour_{0},
28a3e0fd82Sopenharmony_ci      selectedMinute_{0},
29a3e0fd82Sopenharmony_ci      selectedSecond_{0},
30a3e0fd82Sopenharmony_ci      secVisible_(false),
31a3e0fd82Sopenharmony_ci      loopState_{false},
32a3e0fd82Sopenharmony_ci      pickerWidth_(0),
33a3e0fd82Sopenharmony_ci      itemsHeight_(0),
34a3e0fd82Sopenharmony_ci      xPos_(0),
35a3e0fd82Sopenharmony_ci      backgroundFontSize_(0),
36a3e0fd82Sopenharmony_ci      highlightFontSize_(0),
37a3e0fd82Sopenharmony_ci      backgroundFontName_(nullptr),
38a3e0fd82Sopenharmony_ci      highlightFontName_(nullptr),
39a3e0fd82Sopenharmony_ci      pickerListener_(this),
40a3e0fd82Sopenharmony_ci      timePickerListener_(nullptr)
41a3e0fd82Sopenharmony_ci{
42a3e0fd82Sopenharmony_ci    Theme* theme = ThemeManager::GetInstance().GetCurrent();
43a3e0fd82Sopenharmony_ci    if (theme != nullptr) {
44a3e0fd82Sopenharmony_ci        style_ = &(theme->GetPickerBackgroundStyle());
45a3e0fd82Sopenharmony_ci    } else {
46a3e0fd82Sopenharmony_ci        style_ = &(StyleDefault::GetPickerBackgroundStyle());
47a3e0fd82Sopenharmony_ci    }
48a3e0fd82Sopenharmony_ci    backgroundFontId_ = style_->font_;
49a3e0fd82Sopenharmony_ci    backgroundColor_ = style_->textColor_;
50a3e0fd82Sopenharmony_ci    if (theme != nullptr) {
51a3e0fd82Sopenharmony_ci        style_ = &(theme->GetPickerHighlightStyle());
52a3e0fd82Sopenharmony_ci    } else {
53a3e0fd82Sopenharmony_ci        style_ = &(StyleDefault::GetPickerHighlightStyle());
54a3e0fd82Sopenharmony_ci    }
55a3e0fd82Sopenharmony_ci#if ENABLE_FOCUS_MANAGER
56a3e0fd82Sopenharmony_ci    focusable_ = true;
57a3e0fd82Sopenharmony_ci#endif
58a3e0fd82Sopenharmony_ci    highlightFontId_ = style_->font_;
59a3e0fd82Sopenharmony_ci    highlightColor_ = style_->textColor_;
60a3e0fd82Sopenharmony_ci
61a3e0fd82Sopenharmony_ci    hourPicker_ = nullptr;
62a3e0fd82Sopenharmony_ci    minutePicker_ = nullptr;
63a3e0fd82Sopenharmony_ci    secondPicker_ = nullptr;
64a3e0fd82Sopenharmony_ci}
65a3e0fd82Sopenharmony_ci
66a3e0fd82Sopenharmony_ciUITimePicker::~UITimePicker()
67a3e0fd82Sopenharmony_ci{
68a3e0fd82Sopenharmony_ci    DeInitTimePicker();
69a3e0fd82Sopenharmony_ci    if (backgroundFontName_ != nullptr) {
70a3e0fd82Sopenharmony_ci        UIFree(backgroundFontName_);
71a3e0fd82Sopenharmony_ci        backgroundFontName_ = nullptr;
72a3e0fd82Sopenharmony_ci    }
73a3e0fd82Sopenharmony_ci
74a3e0fd82Sopenharmony_ci    if (highlightFontName_ != nullptr) {
75a3e0fd82Sopenharmony_ci        UIFree(highlightFontName_);
76a3e0fd82Sopenharmony_ci        highlightFontName_ = nullptr;
77a3e0fd82Sopenharmony_ci    }
78a3e0fd82Sopenharmony_ci}
79a3e0fd82Sopenharmony_ci
80a3e0fd82Sopenharmony_civoid UITimePicker::InitTimePicker()
81a3e0fd82Sopenharmony_ci{
82a3e0fd82Sopenharmony_ci    xPos_ = 0;
83a3e0fd82Sopenharmony_ci    if (secVisible_) {
84a3e0fd82Sopenharmony_ci        pickerWidth_ = GetWidth() / SEC_VISIBLE_COUNT;
85a3e0fd82Sopenharmony_ci        InitPicker(hourPicker_, TIME_START, HOUR_END);
86a3e0fd82Sopenharmony_ci        xPos_ = pickerWidth_;
87a3e0fd82Sopenharmony_ci        InitPicker(minutePicker_, TIME_START, MIN_END);
88a3e0fd82Sopenharmony_ci        xPos_ *= (SEC_VISIBLE_COUNT - 1);
89a3e0fd82Sopenharmony_ci        InitPicker(secondPicker_, TIME_START, SEC_END);
90a3e0fd82Sopenharmony_ci        if (secondPicker_ != nullptr) {
91a3e0fd82Sopenharmony_ci            secondPicker_->SetLoopState(loopState_[PICKER_SEC]);
92a3e0fd82Sopenharmony_ci        }
93a3e0fd82Sopenharmony_ci    } else {
94a3e0fd82Sopenharmony_ci        pickerWidth_ = GetWidth() / SEC_INVISIBLE_COUNT;
95a3e0fd82Sopenharmony_ci        InitPicker(hourPicker_, TIME_START, HOUR_END);
96a3e0fd82Sopenharmony_ci        xPos_ = pickerWidth_;
97a3e0fd82Sopenharmony_ci        InitPicker(minutePicker_, TIME_START, MIN_END);
98a3e0fd82Sopenharmony_ci    }
99a3e0fd82Sopenharmony_ci    if (hourPicker_ != nullptr) {
100a3e0fd82Sopenharmony_ci        hourPicker_->SetLoopState(loopState_[PICKER_HOUR]);
101a3e0fd82Sopenharmony_ci    }
102a3e0fd82Sopenharmony_ci    if (minutePicker_ != nullptr) {
103a3e0fd82Sopenharmony_ci        minutePicker_->SetLoopState(loopState_[PICKER_MIN]);
104a3e0fd82Sopenharmony_ci    }
105a3e0fd82Sopenharmony_ci
106a3e0fd82Sopenharmony_ci    RefreshSelected(selectedValue_);
107a3e0fd82Sopenharmony_ci}
108a3e0fd82Sopenharmony_ci
109a3e0fd82Sopenharmony_civoid UITimePicker::DeInitTimePicker()
110a3e0fd82Sopenharmony_ci{
111a3e0fd82Sopenharmony_ci    DeInitPicker(secondPicker_);
112a3e0fd82Sopenharmony_ci    DeInitPicker(minutePicker_);
113a3e0fd82Sopenharmony_ci    DeInitPicker(hourPicker_);
114a3e0fd82Sopenharmony_ci}
115a3e0fd82Sopenharmony_ci
116a3e0fd82Sopenharmony_civoid UITimePicker::RefreshTimePicker()
117a3e0fd82Sopenharmony_ci{
118a3e0fd82Sopenharmony_ci    DeInitTimePicker();
119a3e0fd82Sopenharmony_ci    InitTimePicker();
120a3e0fd82Sopenharmony_ci}
121a3e0fd82Sopenharmony_ci
122a3e0fd82Sopenharmony_civoid UITimePicker::InitPicker(UIPicker*& picker, int16_t start, int16_t end)
123a3e0fd82Sopenharmony_ci{
124a3e0fd82Sopenharmony_ci    picker = new UIPicker();
125a3e0fd82Sopenharmony_ci    if (picker == nullptr) {
126a3e0fd82Sopenharmony_ci        GRAPHIC_LOGE("new UIPicker fail");
127a3e0fd82Sopenharmony_ci        return;
128a3e0fd82Sopenharmony_ci    }
129a3e0fd82Sopenharmony_ci    picker->SetPosition(xPos_, 0, pickerWidth_, GetHeight());
130a3e0fd82Sopenharmony_ci    picker->SetItemHeight(itemsHeight_);
131a3e0fd82Sopenharmony_ci    picker->SetFontId(backgroundFontId_, highlightFontId_);
132a3e0fd82Sopenharmony_ci    if ((backgroundFontName_ == nullptr) || (highlightFontName_ == nullptr)) {
133a3e0fd82Sopenharmony_ci        picker->SetFontId(backgroundFontId_, highlightFontId_);
134a3e0fd82Sopenharmony_ci    } else {
135a3e0fd82Sopenharmony_ci        picker->SetBackgroundFont(backgroundFontName_, backgroundFontSize_);
136a3e0fd82Sopenharmony_ci        picker->SetHighlightFont(highlightFontName_, highlightFontSize_);
137a3e0fd82Sopenharmony_ci    }
138a3e0fd82Sopenharmony_ci    picker->SetTextColor(backgroundColor_, highlightColor_);
139a3e0fd82Sopenharmony_ci    picker->SetValues(start, end);
140a3e0fd82Sopenharmony_ci    picker->RegisterSelectedListener(&pickerListener_);
141a3e0fd82Sopenharmony_ci    Add(picker);
142a3e0fd82Sopenharmony_ci
143a3e0fd82Sopenharmony_ci#if ENABLE_ROTATE_INPUT
144a3e0fd82Sopenharmony_ci    if (end == HOUR_END) {
145a3e0fd82Sopenharmony_ci        picker->GetChildrenHead()->SetViewId(HOUR_LIST_NAME);
146a3e0fd82Sopenharmony_ci    } else if (end == MIN_END && secondPicker_ == nullptr) {
147a3e0fd82Sopenharmony_ci        picker->GetChildrenHead()->SetViewId(MIN_LIST_NAME);
148a3e0fd82Sopenharmony_ci    } else if (end == SEC_END) {
149a3e0fd82Sopenharmony_ci        picker->GetChildrenHead()->SetViewId(SEC_LIST_NAME);
150a3e0fd82Sopenharmony_ci    }
151a3e0fd82Sopenharmony_ci#endif
152a3e0fd82Sopenharmony_ci}
153a3e0fd82Sopenharmony_ci
154a3e0fd82Sopenharmony_civoid UITimePicker::DeInitPicker(UIPicker*& picker)
155a3e0fd82Sopenharmony_ci{
156a3e0fd82Sopenharmony_ci    if (picker != nullptr) {
157a3e0fd82Sopenharmony_ci        Remove(picker);
158a3e0fd82Sopenharmony_ci        picker->ClearValues();
159a3e0fd82Sopenharmony_ci        delete picker;
160a3e0fd82Sopenharmony_ci        picker = nullptr;
161a3e0fd82Sopenharmony_ci    }
162a3e0fd82Sopenharmony_ci}
163a3e0fd82Sopenharmony_ci
164a3e0fd82Sopenharmony_civoid UITimePicker::TimeSelectedCallback()
165a3e0fd82Sopenharmony_ci{
166a3e0fd82Sopenharmony_ci    uint16_t hourSelect = hourPicker_->GetSelected();
167a3e0fd82Sopenharmony_ci    uint16_t minSelect = minutePicker_->GetSelected();
168a3e0fd82Sopenharmony_ci    GetValueByIndex(selectedHour_, BUF_SIZE, hourSelect, TIME_START, HOUR_END);
169a3e0fd82Sopenharmony_ci    GetValueByIndex(selectedMinute_, BUF_SIZE, minSelect, TIME_START, MIN_END);
170a3e0fd82Sopenharmony_ci
171a3e0fd82Sopenharmony_ci    if (memset_s(selectedValue_, SELECTED_VALUE_SIZE, 0, SELECTED_VALUE_SIZE) != EOK) {
172a3e0fd82Sopenharmony_ci        return;
173a3e0fd82Sopenharmony_ci    }
174a3e0fd82Sopenharmony_ci
175a3e0fd82Sopenharmony_ci    if (secVisible_) {
176a3e0fd82Sopenharmony_ci        uint16_t secSelect = secondPicker_->GetSelected();
177a3e0fd82Sopenharmony_ci        GetValueByIndex(selectedSecond_, BUF_SIZE, secSelect, TIME_START, SEC_END);
178a3e0fd82Sopenharmony_ci        if (sprintf_s(selectedValue_, SELECTED_VALUE_SIZE, "%s:%s:%s",
179a3e0fd82Sopenharmony_ci            selectedHour_, selectedMinute_, selectedSecond_) < 0) {
180a3e0fd82Sopenharmony_ci            return;
181a3e0fd82Sopenharmony_ci        }
182a3e0fd82Sopenharmony_ci    } else {
183a3e0fd82Sopenharmony_ci        if (sprintf_s(selectedValue_, SELECTED_VALUE_SIZE, "%s:%s", selectedHour_, selectedMinute_) < 0) {
184a3e0fd82Sopenharmony_ci            return;
185a3e0fd82Sopenharmony_ci        }
186a3e0fd82Sopenharmony_ci    }
187a3e0fd82Sopenharmony_ci
188a3e0fd82Sopenharmony_ci    if (timePickerListener_ != nullptr) {
189a3e0fd82Sopenharmony_ci        timePickerListener_->OnTimePickerStoped(*this);
190a3e0fd82Sopenharmony_ci    }
191a3e0fd82Sopenharmony_ci}
192a3e0fd82Sopenharmony_ci
193a3e0fd82Sopenharmony_civoid UITimePicker::GetValueByIndex(char* value, uint8_t len, uint16_t index, int16_t start, int16_t end)
194a3e0fd82Sopenharmony_ci{
195a3e0fd82Sopenharmony_ci    if ((value != nullptr) && (index < end - start + 1)) {
196a3e0fd82Sopenharmony_ci        if (sprintf_s(value, len, "%02u", index) < 0) {
197a3e0fd82Sopenharmony_ci            return;
198a3e0fd82Sopenharmony_ci        }
199a3e0fd82Sopenharmony_ci    }
200a3e0fd82Sopenharmony_ci}
201a3e0fd82Sopenharmony_ci
202a3e0fd82Sopenharmony_cibool UITimePicker::SetSelected(const char* value)
203a3e0fd82Sopenharmony_ci{
204a3e0fd82Sopenharmony_ci    if (value == nullptr) {
205a3e0fd82Sopenharmony_ci        return false;
206a3e0fd82Sopenharmony_ci    }
207a3e0fd82Sopenharmony_ci
208a3e0fd82Sopenharmony_ci    if (memset_s(selectedValue_, SELECTED_VALUE_SIZE, 0, SELECTED_VALUE_SIZE) != EOK) {
209a3e0fd82Sopenharmony_ci        return false;
210a3e0fd82Sopenharmony_ci    }
211a3e0fd82Sopenharmony_ci
212a3e0fd82Sopenharmony_ci    if (strcpy_s(selectedValue_, SELECTED_VALUE_SIZE, value) != EOK) {
213a3e0fd82Sopenharmony_ci        return false;
214a3e0fd82Sopenharmony_ci    }
215a3e0fd82Sopenharmony_ci    if (secVisible_) {
216a3e0fd82Sopenharmony_ci        if (sscanf_s(value, "%[^:]%*c%[^:]%*c%[^\n]", selectedHour_, BUF_SIZE,
217a3e0fd82Sopenharmony_ci                     selectedMinute_, BUF_SIZE, selectedSecond_, BUF_SIZE) < 3) { // 3: three variables
218a3e0fd82Sopenharmony_ci            return false;
219a3e0fd82Sopenharmony_ci        }
220a3e0fd82Sopenharmony_ci    } else {
221a3e0fd82Sopenharmony_ci        if (sscanf_s(value, "%[^:]%*c%[^\n]", selectedHour_, BUF_SIZE,
222a3e0fd82Sopenharmony_ci                     selectedMinute_, BUF_SIZE) < 2) { // 2: two variables
223a3e0fd82Sopenharmony_ci            return false;
224a3e0fd82Sopenharmony_ci        }
225a3e0fd82Sopenharmony_ci    }
226a3e0fd82Sopenharmony_ci    return RefreshSelected(selectedValue_);
227a3e0fd82Sopenharmony_ci}
228a3e0fd82Sopenharmony_ci
229a3e0fd82Sopenharmony_cibool UITimePicker::RefreshSelected(const char* value)
230a3e0fd82Sopenharmony_ci{
231a3e0fd82Sopenharmony_ci    uint32_t hourSelect;
232a3e0fd82Sopenharmony_ci    uint32_t minSelect;
233a3e0fd82Sopenharmony_ci
234a3e0fd82Sopenharmony_ci    if (value == nullptr) {
235a3e0fd82Sopenharmony_ci        return false;
236a3e0fd82Sopenharmony_ci    }
237a3e0fd82Sopenharmony_ci
238a3e0fd82Sopenharmony_ci    if (secVisible_) {
239a3e0fd82Sopenharmony_ci        uint32_t secSelect;
240a3e0fd82Sopenharmony_ci        // 3: three variables
241a3e0fd82Sopenharmony_ci        if (sscanf_s(value, "%u:%u:%u", &hourSelect, &minSelect, &secSelect) < 3) {
242a3e0fd82Sopenharmony_ci            return false;
243a3e0fd82Sopenharmony_ci        }
244a3e0fd82Sopenharmony_ci        secondPicker_->SetSelected(secSelect);
245a3e0fd82Sopenharmony_ci    } else {
246a3e0fd82Sopenharmony_ci        if (sscanf_s(value, "%u:%u", &hourSelect, &minSelect) < 2) { // 2: two variables
247a3e0fd82Sopenharmony_ci            return false;
248a3e0fd82Sopenharmony_ci        }
249a3e0fd82Sopenharmony_ci    }
250a3e0fd82Sopenharmony_ci
251a3e0fd82Sopenharmony_ci    hourPicker_->SetSelected(hourSelect);
252a3e0fd82Sopenharmony_ci    minutePicker_->SetSelected(minSelect);
253a3e0fd82Sopenharmony_ci    return true;
254a3e0fd82Sopenharmony_ci}
255a3e0fd82Sopenharmony_ci
256a3e0fd82Sopenharmony_cibool UITimePicker::OnPressEvent(const PressEvent& event)
257a3e0fd82Sopenharmony_ci{
258a3e0fd82Sopenharmony_ci    if (event.GetCurrentPos().x < (GetX() + hourPicker_->GetX() + hourPicker_->GetWidth())) {
259a3e0fd82Sopenharmony_ci        hourPicker_->RequestFocus();
260a3e0fd82Sopenharmony_ci    } else if (event.GetCurrentPos().x < (GetX() + minutePicker_->GetX() + minutePicker_->GetWidth())) {
261a3e0fd82Sopenharmony_ci        minutePicker_->RequestFocus();
262a3e0fd82Sopenharmony_ci    } else if (event.GetCurrentPos().x < (GetX() + secondPicker_->GetX() + secondPicker_->GetWidth())) {
263a3e0fd82Sopenharmony_ci        secondPicker_->RequestFocus();
264a3e0fd82Sopenharmony_ci    }
265a3e0fd82Sopenharmony_ci    return UIView::OnPressEvent(event);
266a3e0fd82Sopenharmony_ci}
267a3e0fd82Sopenharmony_ci
268a3e0fd82Sopenharmony_civoid UITimePicker::SetItemHeight(int16_t height)
269a3e0fd82Sopenharmony_ci{
270a3e0fd82Sopenharmony_ci    itemsHeight_ = height;
271a3e0fd82Sopenharmony_ci    RefreshTimePicker();
272a3e0fd82Sopenharmony_ci}
273a3e0fd82Sopenharmony_ci
274a3e0fd82Sopenharmony_civoid UITimePicker::EnableSecond(bool state)
275a3e0fd82Sopenharmony_ci{
276a3e0fd82Sopenharmony_ci    secVisible_ = state;
277a3e0fd82Sopenharmony_ci    RefreshTimePicker();
278a3e0fd82Sopenharmony_ci}
279a3e0fd82Sopenharmony_ci
280a3e0fd82Sopenharmony_civoid UITimePicker::SetTextStyle(uint16_t backgroundFontId,
281a3e0fd82Sopenharmony_ci                                uint16_t highlightFontId,
282a3e0fd82Sopenharmony_ci                                ColorType backgroundColor,
283a3e0fd82Sopenharmony_ci                                ColorType highlightColor)
284a3e0fd82Sopenharmony_ci{
285a3e0fd82Sopenharmony_ci    highlightFontId_ = highlightFontId;
286a3e0fd82Sopenharmony_ci    if (highlightFontName_ != nullptr) {
287a3e0fd82Sopenharmony_ci        UIFree(highlightFontName_);
288a3e0fd82Sopenharmony_ci        highlightFontName_ = nullptr;
289a3e0fd82Sopenharmony_ci    }
290a3e0fd82Sopenharmony_ci
291a3e0fd82Sopenharmony_ci    backgroundFontId_ = backgroundFontId;
292a3e0fd82Sopenharmony_ci    if (backgroundFontName_ != nullptr) {
293a3e0fd82Sopenharmony_ci        UIFree(backgroundFontName_);
294a3e0fd82Sopenharmony_ci        backgroundFontName_ = nullptr;
295a3e0fd82Sopenharmony_ci    }
296a3e0fd82Sopenharmony_ci
297a3e0fd82Sopenharmony_ci    highlightColor_ = highlightColor;
298a3e0fd82Sopenharmony_ci    backgroundColor_ = backgroundColor;
299a3e0fd82Sopenharmony_ci    RefreshTimePicker();
300a3e0fd82Sopenharmony_ci}
301a3e0fd82Sopenharmony_ci
302a3e0fd82Sopenharmony_civoid UITimePicker::SetTextColor(ColorType backgroundColor, ColorType highlightColor)
303a3e0fd82Sopenharmony_ci{
304a3e0fd82Sopenharmony_ci    backgroundColor_ = backgroundColor;
305a3e0fd82Sopenharmony_ci    highlightColor_ = highlightColor;
306a3e0fd82Sopenharmony_ci    RefreshTimePicker();
307a3e0fd82Sopenharmony_ci}
308a3e0fd82Sopenharmony_ci
309a3e0fd82Sopenharmony_civoid UITimePicker::SetBackgroundFont(const char* name, uint8_t size)
310a3e0fd82Sopenharmony_ci{
311a3e0fd82Sopenharmony_ci    Text::SetFont(name, size, backgroundFontName_, backgroundFontSize_);
312a3e0fd82Sopenharmony_ci    RefreshTimePicker();
313a3e0fd82Sopenharmony_ci}
314a3e0fd82Sopenharmony_ci
315a3e0fd82Sopenharmony_civoid UITimePicker::SetHighlightFont(const char* name, uint8_t size)
316a3e0fd82Sopenharmony_ci{
317a3e0fd82Sopenharmony_ci    Text::SetFont(name, size, highlightFontName_, highlightFontSize_);
318a3e0fd82Sopenharmony_ci    RefreshTimePicker();
319a3e0fd82Sopenharmony_ci}
320a3e0fd82Sopenharmony_ci
321a3e0fd82Sopenharmony_civoid UITimePicker::SetWidth(int16_t width)
322a3e0fd82Sopenharmony_ci{
323a3e0fd82Sopenharmony_ci    UIView::SetWidth(width);
324a3e0fd82Sopenharmony_ci    RefreshTimePicker();
325a3e0fd82Sopenharmony_ci}
326a3e0fd82Sopenharmony_ci
327a3e0fd82Sopenharmony_civoid UITimePicker::SetHeight(int16_t height)
328a3e0fd82Sopenharmony_ci{
329a3e0fd82Sopenharmony_ci    UIView::SetHeight(height);
330a3e0fd82Sopenharmony_ci    RefreshTimePicker();
331a3e0fd82Sopenharmony_ci}
332a3e0fd82Sopenharmony_ci
333a3e0fd82Sopenharmony_civoid UITimePicker::SetLoopState(const uint8_t pickerType, bool state)
334a3e0fd82Sopenharmony_ci{
335a3e0fd82Sopenharmony_ci    switch (pickerType) {
336a3e0fd82Sopenharmony_ci        case PICKER_HOUR:
337a3e0fd82Sopenharmony_ci            loopState_[PICKER_HOUR] = state;
338a3e0fd82Sopenharmony_ci            break;
339a3e0fd82Sopenharmony_ci        case PICKER_MIN:
340a3e0fd82Sopenharmony_ci            loopState_[PICKER_MIN] = state;
341a3e0fd82Sopenharmony_ci            break;
342a3e0fd82Sopenharmony_ci        case PICKER_SEC:
343a3e0fd82Sopenharmony_ci            loopState_[PICKER_SEC] = state;
344a3e0fd82Sopenharmony_ci            break;
345a3e0fd82Sopenharmony_ci        default:
346a3e0fd82Sopenharmony_ci            return;
347a3e0fd82Sopenharmony_ci    }
348a3e0fd82Sopenharmony_ci    RefreshTimePicker();
349a3e0fd82Sopenharmony_ci}
350a3e0fd82Sopenharmony_ci}
351