Changeset 1026cc4 in mainline for uspace/app/uidemo/uidemo.c
- Timestamp:
- 2022-03-20T19:51:09Z (2 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 26c90dd
- Parents:
- 5ef85c0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/uidemo/uidemo.c
r5ef85c0 r1026cc4 89 89 static void scrollbar_up(ui_scrollbar_t *, void *); 90 90 static void scrollbar_down(ui_scrollbar_t *, void *); 91 static void scrollbar_page_up(ui_scrollbar_t *, void *); 92 static void scrollbar_page_down(ui_scrollbar_t *, void *); 91 93 static void scrollbar_moved(ui_scrollbar_t *, void *, gfx_coord_t); 92 94 … … 94 96 .up = scrollbar_up, 95 97 .down = scrollbar_down, 98 .page_up = scrollbar_page_up, 99 .page_down = scrollbar_page_down, 96 100 .moved = scrollbar_moved 97 101 }; … … 232 236 static void scrollbar_up(ui_scrollbar_t *scrollbar, void *arg) 233 237 { 234 ui_demo_t *demo = (ui_demo_t *) arg;235 238 gfx_coord_t pos; 236 char *str;237 errno_t rc;238 int rv;239 239 240 240 pos = ui_scrollbar_get_pos(scrollbar); … … 242 242 243 243 pos = ui_scrollbar_get_pos(scrollbar); 244 245 rv = asprintf(&str, "Scrollbar: %d of %d", (int) pos, 246 ui_scrollbar_move_length(scrollbar)); 247 if (rv < 0) { 248 printf("Out of memory.\n"); 249 return; 250 } 251 252 rc = ui_entry_set_text(demo->entry, str); 253 if (rc != EOK) 254 printf("Error changing entry text.\n"); 255 (void) ui_entry_paint(demo->entry); 256 257 free(str); 244 scrollbar_moved(scrollbar, arg, pos); 258 245 } 259 246 … … 265 252 static void scrollbar_down(ui_scrollbar_t *scrollbar, void *arg) 266 253 { 267 ui_demo_t *demo = (ui_demo_t *) arg;268 254 gfx_coord_t pos; 269 char *str;270 errno_t rc;271 int rv;272 255 273 256 pos = ui_scrollbar_get_pos(scrollbar); … … 275 258 276 259 pos = ui_scrollbar_get_pos(scrollbar); 277 278 rv = asprintf(&str, "Scrollbar: %d of %d", (int) pos, 279 ui_scrollbar_move_length(scrollbar)); 280 if (rv < 0) { 281 printf("Out of memory.\n"); 282 return; 283 } 284 285 rc = ui_entry_set_text(demo->entry, str); 286 if (rc != EOK) 287 printf("Error changing entry text.\n"); 288 (void) ui_entry_paint(demo->entry); 289 290 free(str); 260 scrollbar_moved(scrollbar, arg, pos); 261 } 262 263 /** Scrollbar page up event. 264 * 265 * @param scrollbar Scrollbar 266 * @param arg Argument (demo) 267 */ 268 static void scrollbar_page_up(ui_scrollbar_t *scrollbar, void *arg) 269 { 270 gfx_coord_t pos; 271 272 pos = ui_scrollbar_get_pos(scrollbar); 273 ui_scrollbar_set_pos(scrollbar, pos - 274 ui_scrollbar_through_length(scrollbar) / 4); 275 276 pos = ui_scrollbar_get_pos(scrollbar); 277 scrollbar_moved(scrollbar, arg, pos); 278 } 279 280 /** Scrollbar page down event. 281 * 282 * @param scrollbar Scrollbar 283 * @param arg Argument (demo) 284 */ 285 static void scrollbar_page_down(ui_scrollbar_t *scrollbar, void *arg) 286 { 287 gfx_coord_t pos; 288 289 pos = ui_scrollbar_get_pos(scrollbar); 290 ui_scrollbar_set_pos(scrollbar, pos + 291 ui_scrollbar_through_length(scrollbar) / 4); 292 293 pos = ui_scrollbar_get_pos(scrollbar); 294 scrollbar_moved(scrollbar, arg, pos); 291 295 } 292 296
Note:
See TracChangeset
for help on using the changeset viewer.