1 /*
2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "ui_test_box_progress.h"
17 #include "common/screen.h"
18 #include "components/ui_label.h"
19 #include "test_resource_config.h"
20
21 namespace OHOS {
22 namespace {
23 const int16_t LABEL_HEIGHT = 29;
24 const int16_t BUTTON_WIDTH = 120;
25 const int16_t BUTTON_HEIGHT = 40;
26 const int16_t DELTA_X_COORDINATE = 8;
27 const int16_t DELTA_X_COORDINATE_2 = 336;
28 const int16_t DELTA_Y_COORDINATE = 12;
29 const int16_t DELTA_Y_COORDINATE_2 = 19;
30 } // namespace
31
SetUp()32 void UITestBoxProgress::SetUp()
33 {
34 if (container_ == nullptr) {
35 positionX_ = 0;
36 positionY_ = 0;
37 container_ = new UIScrollView();
38 container_->Resize(Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight() - BACK_BUTTON_HEIGHT);
39 UIViewGroup* uiViewGroup = new UIViewGroup();
40 uiViewGroup->SetPosition(positionX_, positionY_, 320, 390); // 320: width; 390: height
41 container_->Add(uiViewGroup);
42 UILabel* label = new UILabel();
43 uiViewGroup->Add(label);
44 // 288: width; 48: height
45 label->SetPosition(TEXT_DISTANCE_TO_LEFT_SIDE, TEXT_DISTANCE_TO_TOP_SIDE, 288, 48);
46 label->SetText("UIBoxProgress效果");
47 label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
48 uiViewGroupFrame_ = new UIViewGroup();
49 uiViewGroup->Add(uiViewGroupFrame_);
50 // 288: width; 336: height
51 uiViewGroupFrame_->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE2, TEXT_DISTANCE_TO_LEFT_SIDE, 288, 336);
52 uiViewGroupFrame_->SetStyle(STYLE_BORDER_COLOR, Color::White().full);
53 uiViewGroupFrame_->SetStyle(STYLE_BORDER_OPA, HALF_OPA_OPAQUE);
54 uiViewGroupFrame_->SetStyle(STYLE_BORDER_WIDTH, VIEW_STYLE_BORDER_WIDTH);
55 uiViewGroupFrame_->SetStyle(STYLE_BORDER_RADIUS, VIEW_STYLE_BORDER_RADIUS);
56 uiViewGroupFrame_->SetStyle(STYLE_BACKGROUND_OPA, 0);
57
58 boxProgress_ = new UIBoxProgress();
59 boxProgress_->SetPosition(10, 10, 100, 10); // 10: x 10: y 100: width 10: height
60 boxProgress_->SetValue(20); // 20: value
61 boxProgress_->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
62 boxProgress_->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::Green().full);
63 boxProgress_->SetStyle(STYLE_BORDER_COLOR, Color::Yellow().full);
64 uiViewGroupFrame_->Add(boxProgress_);
65 boxProgress_->LayoutCenterOfParent();
66 }
67
68 if (scroll_ == nullptr) {
69 scroll_ = new UIScrollView();
70 scroll_->SetPosition(336, 11); // 336: x-coordinate; 11: y-coordinate
71 // 624: width; 100: Adjust the visible height of scroll
72 scroll_->Resize(624, Screen::GetInstance().GetHeight() - 100);
73 container_->Add(scroll_);
74 positionY_ = 0;
75 }
76 }
77
TearDown()78 void UITestBoxProgress::TearDown()
79 {
80 DeleteChildren(container_);
81 container_ = nullptr;
82 boxProgress_ = nullptr;
83 scroll_ = nullptr;
84 uiViewGroupFrame_ = nullptr;
85 }
86
GetTestView()87 const UIView* UITestBoxProgress::GetTestView()
88 {
89 UIKitBoxProgressTestUIBoxProgress001();
90 UIKitBoxProgressTestSetRange002();
91 UIKitBoxProgressTestSetValue003();
92 UIKitBoxProgressTestSetImage004();
93 UIKitBoxProgressTestSetStyle005();
94 UIKitBoxProgressTestGetStyle006();
95 UIKitBoxProgressTestSetCapType007();
96 UIKitBoxProgressTestSetDirection008();
97 UIKitBoxProgressTestEnableBackground009();
98 UIKitBoxProgressTestSetStep010();
99 UIKitBoxProgressTestSetValidSize011();
100 UIKitBoxProgressTestSetBorderAndPadding012();
101
102 return container_;
103 }
104
SetUpLabel(const char * title,int16_t x,int16_t y) const105 void UITestBoxProgress::SetUpLabel(const char* title, int16_t x, int16_t y) const
106 {
107 UILabel* label = new UILabel();
108 scroll_->Add(label);
109 label->SetPosition(x, y, 288, 30); // 288: width; 30: height
110 label->SetText(title);
111 label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
112 }
SetUpButton(UILabelButton * btn,const char * title,int16_t x,int16_t y)113 void UITestBoxProgress::SetUpButton(UILabelButton* btn, const char* title, int16_t x, int16_t y)
114 {
115 if (btn == nullptr) {
116 return;
117 }
118 scroll_->Add(btn);
119 btn->SetPosition(x, y, BUTTON_WIDHT2, BUTTON_HEIGHT2);
120 btn->SetText(title);
121 btn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_LABEL_SIZE);
122 btn->SetOnClickListener(this);
123 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::RELEASED);
124 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::PRESSED);
125 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::INACTIVE);
126 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::RELEASED);
127 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::PRESSED);
128 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::INACTIVE);
129 scroll_->Invalidate();
130 }
131
UIKitBoxProgressTestUIBoxProgress001()132 void UITestBoxProgress::UIKitBoxProgressTestUIBoxProgress001()
133 {
134 resetBtn_ = new UILabelButton();
135 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
136 positionY_ = 0;
137 SetUpLabel("创建条形进度条:", positionX_, positionY_);
138 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
139 SetUpButton(resetBtn_, "重置", positionX_, positionY_);
140 }
141
UIKitBoxProgressTestSetRange002()142 void UITestBoxProgress::UIKitBoxProgressTestSetRange002()
143 {
144 incMinProgressBtn_ = new UILabelButton();
145 decMinProgressBtn_ = new UILabelButton();
146 incMaxProgressBtn_ = new UILabelButton();
147 decMaxProgressBtn_ = new UILabelButton();
148 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
149 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
150 SetUpLabel("设置条形进度条范围:", positionX_, positionY_);
151 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
152 SetUpButton(incMinProgressBtn_, "下限+", positionX_, positionY_);
153 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
154 SetUpButton(decMinProgressBtn_, "下限-", positionX_, positionY_);
155 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
156 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE;
157 SetUpButton(incMaxProgressBtn_, "上限+", positionX_, positionY_);
158 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
159 SetUpButton(decMaxProgressBtn_, "上限-", positionX_, positionY_);
160 }
161
UIKitBoxProgressTestSetValue003()162 void UITestBoxProgress::UIKitBoxProgressTestSetValue003()
163 {
164 incProgressBtn_ = new UILabelButton();
165 decProgressBtn_ = new UILabelButton();
166 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
167 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
168 SetUpLabel("设置条形进度条当前值:", positionX_, positionY_);
169 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
170 SetUpButton(incProgressBtn_, "进度+", positionX_, positionY_);
171 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
172 SetUpButton(decProgressBtn_, "进度-", positionX_, positionY_);
173 }
174
UIKitBoxProgressTestSetImage004()175 void UITestBoxProgress::UIKitBoxProgressTestSetImage004()
176 {
177 imageBtn_ = new UILabelButton();
178 noImageBtn_ = new UILabelButton();
179 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
180 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
181 SetUpLabel("设置条形进度条图片:", positionX_, positionY_);
182 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
183 SetUpButton(imageBtn_, "设置图片", positionX_, positionY_);
184 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
185 SetUpButton(noImageBtn_, "取消图片", positionX_, positionY_);
186 }
187
UIKitBoxProgressTestSetStyle005()188 void UITestBoxProgress::UIKitBoxProgressTestSetStyle005()
189 {
190 setStyleBtn_ = new UILabelButton();
191 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
192 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
193 SetUpLabel("设置条形进度条样式:", positionX_, positionY_);
194 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
195 SetUpButton(setStyleBtn_, "设置样式", positionX_, positionY_);
196 }
197
UIKitBoxProgressTestGetStyle006()198 void UITestBoxProgress::UIKitBoxProgressTestGetStyle006()
199 {
200 getStyleBtn_ = new UILabelButton();
201 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
202 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
203 SetUpLabel("设置条形进度条样式:", positionX_, positionY_);
204 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
205 SetUpButton(getStyleBtn_, "设置样式", positionX_, positionY_);
206 }
207
UIKitBoxProgressTestSetCapType007()208 void UITestBoxProgress::UIKitBoxProgressTestSetCapType007()
209 {
210 roundCapBtn_ = new UILabelButton();
211 noneCapBtn_ = new UILabelButton();
212 positionX_ = DELTA_X_COORDINATE_2;
213 positionY_ = 0;
214 SetUpLabel("设置条形进度条端点:", positionX_, positionY_);
215 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
216 SetUpButton(roundCapBtn_, "圆形端点", positionX_, positionY_);
217 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
218 SetUpButton(noneCapBtn_, "方形端点", positionX_, positionY_);
219 }
220
UIKitBoxProgressTestSetDirection008()221 void UITestBoxProgress::UIKitBoxProgressTestSetDirection008()
222 {
223 dirL2RBtn_ = new UILabelButton();
224 dirR2LBtn_ = new UILabelButton();
225 dirT2BBtn_ = new UILabelButton();
226 dirB2TBtn_ = new UILabelButton();
227 positionX_ = DELTA_X_COORDINATE_2;
228 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
229 SetUpLabel("设置条形进度条方向:", positionX_, positionY_);
230 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
231 SetUpButton(dirL2RBtn_, "从左到右", positionX_, positionY_);
232 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
233 SetUpButton(dirR2LBtn_, "从右到左", positionX_, positionY_);
234 positionX_ = DELTA_X_COORDINATE_2;
235 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE;
236 SetUpButton(dirT2BBtn_, "从上到下", positionX_, positionY_);
237 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
238 SetUpButton(dirB2TBtn_, "从下到上", positionX_, positionY_);
239 }
240
UIKitBoxProgressTestEnableBackground009()241 void UITestBoxProgress::UIKitBoxProgressTestEnableBackground009()
242 {
243 enableBgBtn_ = new UILabelButton();
244 disableBgBtn_ = new UILabelButton();
245 positionX_ = DELTA_X_COORDINATE_2;
246 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
247 SetUpLabel("设置条形进度条背景:", positionX_, positionY_);
248 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
249 SetUpButton(enableBgBtn_, "设置背景", positionX_, positionY_);
250 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
251 SetUpButton(disableBgBtn_, "隐藏背景", positionX_, positionY_);
252 }
253
UIKitBoxProgressTestSetStep010()254 void UITestBoxProgress::UIKitBoxProgressTestSetStep010()
255 {
256 stepBtn_ = new UILabelButton();
257 positionX_ = DELTA_X_COORDINATE_2;
258 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
259 SetUpLabel("设置条形进度条步长:", positionX_, positionY_);
260 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
261 SetUpButton(stepBtn_, "步长+", positionX_, positionY_);
262 }
263
UIKitBoxProgressTestSetValidSize011()264 void UITestBoxProgress::UIKitBoxProgressTestSetValidSize011()
265 {
266 incWidthBtn_ = new UILabelButton();
267 incHeightBtn_ = new UILabelButton();
268 decWidthBtn_ = new UILabelButton();
269 decHeightBtn_ = new UILabelButton();
270 positionX_ = DELTA_X_COORDINATE_2;
271 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
272 SetUpLabel("设置条形进度条有效区域宽高:", positionX_, positionY_);
273 positionX_ = DELTA_X_COORDINATE_2;
274 positionY_ += LABEL_HEIGHT + DELTA_Y_COORDINATE_2;
275 SetUpButton(incHeightBtn_, "box高度+", positionX_, positionY_);
276 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE_2;
277 SetUpButton(incWidthBtn_, "box宽度+", positionX_, positionY_);
278 positionX_ = DELTA_X_COORDINATE_2;
279 positionY_ += LABEL_HEIGHT + DELTA_Y_COORDINATE_2;
280 SetUpButton(decHeightBtn_, "box高度-", positionX_, positionY_);
281 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE_2;
282 SetUpButton(decWidthBtn_, "box宽度-", positionX_, positionY_);
283 }
284
UIKitBoxProgressTestSetBorderAndPadding012()285 void UITestBoxProgress::UIKitBoxProgressTestSetBorderAndPadding012()
286 {
287 borderIncBtn_ = new UILabelButton();
288 borderDecBtn_ = new UILabelButton();
289 paddingLeftIncBtn_ = new UILabelButton();
290 paddingRightIncBtn_ = new UILabelButton();
291 paddingTopIncBtn_ = new UILabelButton();
292 paddingBottomIncBtn_ = new UILabelButton();
293 positionX_ = DELTA_X_COORDINATE_2;
294 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
295 SetUpLabel("设置边宽和内边距:", positionX_, positionY_);
296 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
297 SetUpButton(borderIncBtn_, "边宽+", positionX_, positionY_);
298 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE_2;
299 SetUpButton(borderDecBtn_, "边宽-", positionX_, positionY_);
300 positionX_ = DELTA_X_COORDINATE_2;
301 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
302 SetUpButton(paddingLeftIncBtn_, "左内边距+", positionX_, positionY_);
303 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE_2;
304 SetUpButton(paddingRightIncBtn_, "右内边距+", positionX_, positionY_);
305 positionX_ = DELTA_X_COORDINATE_2;
306 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
307 SetUpButton(paddingTopIncBtn_, "上内边距+", positionX_, positionY_);
308 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE_2;
309 SetUpButton(paddingBottomIncBtn_, "下内边距+", positionX_, positionY_);
310 }
311
OnClick(UIView & view,const ClickEvent & event)312 bool UITestBoxProgress::OnClick(UIView& view, const ClickEvent& event)
313 {
314 static uint16_t progress = 20; // 20: progress
315 static uint16_t step = 0;
316 static uint16_t width = 100; // 100: width
317 static uint16_t height = 10; // 10: height
318 static int16_t min = 0;
319 static int16_t max = 100; // 100: max value
320 if (&view == resetBtn_) {
321 boxProgress_->SetPosition(10, 10, 100, 10); // 10: x 10: y 100: width 15: height
322 progress = 20; // 20: progress
323 step = 0;
324 width = 100; // 100: width
325 height = 10; // 10: height
326 min = 0;
327 max = 100; // 100: max value
328 boxProgress_->SetDirection(UIBoxProgress::Direction::DIR_LEFT_TO_RIGHT);
329 boxProgress_->SetValidHeight(height);
330 boxProgress_->SetValidWidth(width);
331 boxProgress_->SetRange(max, min);
332 boxProgress_->SetValue(progress);
333 boxProgress_->SetStep(step);
334 // 182, 191: color
335 boxProgress_->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGB(0, 182, 191).full);
336 // 255, 152: color
337 boxProgress_->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGB(255, 152, 0).full);
338 boxProgress_->SetImage(static_cast<char*>(nullptr));
339 boxProgress_->EnableBackground(true);
340 boxProgress_->LayoutCenterOfParent();
341 } else if (&view == incProgressBtn_) {
342 progress++;
343 boxProgress_->SetValue(progress);
344 } else if (&view == decProgressBtn_) {
345 progress--;
346 boxProgress_->SetValue(progress);
347 } else if (&view == stepBtn_) {
348 step++;
349 boxProgress_->SetStep(step);
350 } else if (&view == incWidthBtn_) {
351 width++;
352 boxProgress_->SetValidWidth(width);
353 } else if (&view == incHeightBtn_) {
354 height++;
355 boxProgress_->SetValidHeight(height);
356 } else if (&view == decWidthBtn_) {
357 width--;
358 boxProgress_->SetValidWidth(width);
359 } else if (&view == decHeightBtn_) {
360 height--;
361 boxProgress_->SetValidHeight(height);
362 } else if (&view == incMinProgressBtn_) {
363 min++;
364 boxProgress_->SetRange(boxProgress_->GetRangeMax(), min);
365 } else if (&view == decMinProgressBtn_) {
366 min--;
367 boxProgress_->SetRange(boxProgress_->GetRangeMax(), min);
368 } else if (&view == incMaxProgressBtn_) {
369 max++;
370 boxProgress_->SetRange(max, boxProgress_->GetRangeMin());
371 } else if (&view == decMaxProgressBtn_) {
372 max--;
373 boxProgress_->SetRange(max, boxProgress_->GetRangeMin());
374 } else if (&view == dirL2RBtn_) {
375 width = 100; // 100: width
376 height = 10; // 10: height
377 boxProgress_->Resize(width, height);
378 boxProgress_->SetDirection(UIBoxProgress::Direction::DIR_LEFT_TO_RIGHT);
379 } else if (&view == dirR2LBtn_) {
380 width = 100; // 100: width
381 height = 10; // 10: height
382 boxProgress_->Resize(width, height);
383 boxProgress_->SetDirection(UIBoxProgress::Direction::DIR_RIGHT_TO_LEFT);
384 } else if (&view == dirT2BBtn_) {
385 width = 10; // 10: width
386 height = 100; // 100: height
387 boxProgress_->Resize(width, height);
388 boxProgress_->SetDirection(UIBoxProgress::Direction::DIR_TOP_TO_BOTTOM);
389 } else if (&view == dirB2TBtn_) {
390 width = 10; // 10: width
391 height = 100; // 100: height
392 boxProgress_->Resize(width, height);
393 boxProgress_->SetDirection(UIBoxProgress::Direction::DIR_BOTTOM_TO_TOP);
394 } else if (&view == imageBtn_) {
395 boxProgress_->SetImage(RED_IMAGE_PATH, BLUE_IMAGE_PATH);
396 } else if (&view == noImageBtn_) {
397 boxProgress_->SetImage(static_cast<ImageInfo*>(nullptr));
398 } else if (&view == setStyleBtn_) {
399 Style style = StyleDefault::GetDefaultStyle();
400 style.bgColor_ = Color::White();
401 boxProgress_->SetBackgroundStyle(style);
402 style.bgColor_ = Color::Blue();
403 boxProgress_->SetForegroundStyle(style);
404 } else if (&view == getStyleBtn_) {
405 boxProgress_->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, Color::White().full);
406 boxProgress_->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 128); // 128: opa
407 boxProgress_->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full);
408 } else if (&view == roundCapBtn_) {
409 boxProgress_->SetCapType(CapType::CAP_ROUND);
410 } else if (&view == noneCapBtn_) {
411 boxProgress_->SetCapType(CapType::CAP_NONE);
412 } else if (&view == enableBgBtn_) {
413 boxProgress_->EnableBackground(true);
414 } else if (&view == disableBgBtn_) {
415 boxProgress_->EnableBackground(false);
416 } else if (&view == borderIncBtn_) {
417 int64_t bodrderWidth = boxProgress_->GetStyle(STYLE_BORDER_WIDTH);
418 // 20: max width; 5: step
419 bodrderWidth = (bodrderWidth + 5 > 20) ? 20 : (bodrderWidth + 5);
420 boxProgress_->SetStyle(STYLE_BORDER_WIDTH, bodrderWidth);
421 } else if (&view == borderDecBtn_) {
422 int64_t bodrderWidth = boxProgress_->GetStyle(STYLE_BORDER_WIDTH);
423 // 0: min width; 5: step
424 bodrderWidth = (bodrderWidth - 5 < 0) ? 0 : (bodrderWidth - 5);
425 boxProgress_->SetStyle(STYLE_BORDER_WIDTH, bodrderWidth);
426 } else if (&view == paddingLeftIncBtn_) {
427 int64_t paddingWidth = boxProgress_->GetStyle(STYLE_PADDING_LEFT);
428 // 20: max width; 5: step
429 paddingWidth = (paddingWidth + 5 > 20) ? 20 : (paddingWidth + 5);
430 boxProgress_->SetStyle(STYLE_PADDING_LEFT, paddingWidth);
431 } else if (&view == paddingRightIncBtn_) {
432 int64_t paddingWidth = boxProgress_->GetStyle(STYLE_PADDING_RIGHT);
433 // 20: max width; 5: step
434 paddingWidth = (paddingWidth + 5 > 20) ? 20 : (paddingWidth + 5);
435 boxProgress_->SetStyle(STYLE_PADDING_RIGHT, paddingWidth);
436 } else if (&view == paddingTopIncBtn_) {
437 int64_t paddingWidth = boxProgress_->GetStyle(STYLE_PADDING_TOP);
438 // 20: max width; 5: step
439 paddingWidth = (paddingWidth + 5 > 20) ? 20 : (paddingWidth + 5);
440 boxProgress_->SetStyle(STYLE_PADDING_TOP, paddingWidth);
441 } else if (&view == paddingBottomIncBtn_) {
442 int64_t paddingWidth = boxProgress_->GetStyle(STYLE_PADDING_BOTTOM);
443 // 20: max width; 5: step
444 paddingWidth = (paddingWidth + 5 > 20) ? 20 : (paddingWidth + 5);
445 boxProgress_->SetStyle(STYLE_PADDING_BOTTOM, paddingWidth);
446 }
447 container_->Invalidate();
448 return true;
449 }
450 } // namespace OHOS
451