Changeset 806d761 in mainline for uspace/lib/ui
- Timestamp:
- 2024-02-07T23:44:59Z (18 months ago)
- Branches:
- master
- Children:
- 242e3c3
- Parents:
- 74cb6610
- Location:
- uspace/lib/ui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/include/ui/checkbox.h
r74cb6610 r806d761 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 52 52 extern void ui_checkbox_set_cb(ui_checkbox_t *, ui_checkbox_cb_t *, void *); 53 53 extern void ui_checkbox_set_rect(ui_checkbox_t *, gfx_rect_t *); 54 extern bool ui_checkbox_get_checked(ui_checkbox_t *); 55 extern void ui_checkbox_set_checked(ui_checkbox_t *, bool); 54 56 extern errno_t ui_checkbox_paint(ui_checkbox_t *); 55 57 extern void ui_checkbox_press(ui_checkbox_t *); -
uspace/lib/ui/src/checkbox.c
r74cb6610 r806d761 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 139 139 } 140 140 141 /** Set buttonrectangle.142 * 143 * @param checkbox Button144 * @param rect New buttonrectangle141 /** Set check box rectangle. 142 * 143 * @param checkbox Check box 144 * @param rect New check box rectangle 145 145 */ 146 146 void ui_checkbox_set_rect(ui_checkbox_t *checkbox, gfx_rect_t *rect) 147 147 { 148 148 checkbox->rect = *rect; 149 } 150 151 /** Return if check box is checked. 152 * 153 * @param checkbox Check box 154 * @return @c true iff check box is checked 155 */ 156 bool ui_checkbox_get_checked(ui_checkbox_t *checkbox) 157 { 158 return checkbox->checked; 159 } 160 161 /** Set check box checked state. 162 * 163 * @param checkbox Check box 164 * @param checked @c true iff checkbox should be checked 165 */ 166 void ui_checkbox_set_checked(ui_checkbox_t *checkbox, bool checked) 167 { 168 checkbox->checked = checked; 149 169 } 150 170 -
uspace/lib/ui/test/checkbox.c
r74cb6610 r806d761 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 151 151 } 152 152 153 /** Get check box checked returns internal field */ 154 PCUT_TEST(get_checked) 155 { 156 ui_checkbox_t *checkbox; 157 errno_t rc; 158 159 rc = ui_checkbox_create(NULL, "Hello", &checkbox); 160 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 161 162 checkbox->checked = false; 163 PCUT_ASSERT_FALSE(ui_checkbox_get_checked(checkbox)); 164 checkbox->checked = true; 165 PCUT_ASSERT_TRUE(ui_checkbox_get_checked(checkbox)); 166 167 ui_checkbox_destroy(checkbox); 168 } 169 170 /** Set check box checked sets internal field */ 171 PCUT_TEST(set_checked) 172 { 173 ui_checkbox_t *checkbox; 174 errno_t rc; 175 176 rc = ui_checkbox_create(NULL, "Hello", &checkbox); 177 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 178 179 ui_checkbox_set_checked(checkbox, true); 180 PCUT_ASSERT_TRUE(checkbox->checked); 181 ui_checkbox_set_checked(checkbox, false); 182 PCUT_ASSERT_FALSE(checkbox->checked); 183 184 ui_checkbox_destroy(checkbox); 185 } 186 153 187 /** Paint check box in graphics mode */ 154 188 PCUT_TEST(paint_gfx)
Note:
See TracChangeset
for help on using the changeset viewer.