Changeset f1f433d in mainline for uspace/lib/ui
- Timestamp:
- 2022-11-04T20:54:04Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3a6d44b7
- Parents:
- fc00f0d
- Location:
- uspace/lib/ui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/include/ui/pbutton.h
rfc00f0d rf1f433d 56 56 extern void ui_pbutton_set_rect(ui_pbutton_t *, gfx_rect_t *); 57 57 extern void ui_pbutton_set_default(ui_pbutton_t *, bool); 58 extern errno_t ui_pbutton_set_caption(ui_pbutton_t *, const char *); 58 59 extern errno_t ui_pbutton_paint(ui_pbutton_t *); 59 60 extern void ui_pbutton_press(ui_pbutton_t *); -
uspace/lib/ui/private/pbutton.h
rfc00f0d rf1f433d 62 62 gfx_rect_t rect; 63 63 /** Caption */ 64 c onst char *caption;64 char *caption; 65 65 /** Button is selected as default */ 66 66 bool isdefault; -
uspace/lib/ui/src/pbutton.c
rfc00f0d rf1f433d 114 114 115 115 ui_control_delete(pbutton->control); 116 free(pbutton->caption); 116 117 free(pbutton); 117 118 } … … 183 184 { 184 185 pbutton->isdefault = isdefault; 186 } 187 188 /** Set push button caption. 189 * 190 * @param pbutton Button 191 * @param caption New caption 192 * @return EOK on success, ENOMEM if out of memory 193 */ 194 errno_t ui_pbutton_set_caption(ui_pbutton_t *pbutton, const char *caption) 195 { 196 char *dcaption; 197 198 dcaption = str_dup(caption); 199 if (dcaption == NULL) 200 return ENOMEM; 201 202 free(pbutton->caption); 203 pbutton->caption = dcaption; 204 return EOK; 185 205 } 186 206 -
uspace/lib/ui/test/pbutton.c
rfc00f0d rf1f433d 190 190 } 191 191 192 /** Set caption sets internal field */ 193 PCUT_TEST(set_caption) 194 { 195 ui_pbutton_t *pbutton; 196 errno_t rc; 197 198 rc = ui_pbutton_create(NULL, "Hello", &pbutton); 199 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 200 201 PCUT_ASSERT_STR_EQUALS("Hello", pbutton->caption); 202 203 rc = ui_pbutton_set_caption(pbutton, "World"); 204 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 205 206 PCUT_ASSERT_STR_EQUALS("World", pbutton->caption); 207 208 ui_pbutton_destroy(pbutton); 209 } 210 192 211 /** Paint button */ 193 212 PCUT_TEST(paint)
Note:
See TracChangeset
for help on using the changeset viewer.