Changeset 8a9a41e in mainline for uspace/lib/ui/src/checkbox.c
- Timestamp:
- 2021-10-24T08:28:43Z (2 years ago)
- Children:
- fcb4e15
- Parents:
- 2ce943a (diff), cd981f2a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Erik Kučák <35500848+Riko196@…> (2021-10-24 08:28:43)
- git-committer:
- GitHub <noreply@…> (2021-10-24 08:28:43)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/checkbox.c
r2ce943a r8a9a41e 146 146 } 147 147 148 /** Paint check box .148 /** Paint check box in graphics mode. 149 149 * 150 150 * @param checkbox Check box 151 151 * @return EOK on success or an error code 152 152 */ 153 errno_t ui_checkbox_paint (ui_checkbox_t *checkbox)153 errno_t ui_checkbox_paint_gfx(ui_checkbox_t *checkbox) 154 154 { 155 155 gfx_coord2_t pos; … … 222 222 error: 223 223 return rc; 224 } 225 226 /** Paint check box in text mode. 227 * 228 * @param checkbox Check box 229 * @return EOK on success or an error code 230 */ 231 errno_t ui_checkbox_paint_text(ui_checkbox_t *checkbox) 232 { 233 gfx_coord2_t pos; 234 gfx_text_fmt_t fmt; 235 bool depressed; 236 errno_t rc; 237 238 /* Paint checkbox */ 239 240 depressed = checkbox->held && checkbox->inside; 241 242 pos.x = checkbox->rect.p0.x; 243 pos.y = checkbox->rect.p0.y; 244 245 gfx_text_fmt_init(&fmt); 246 fmt.color = depressed ? checkbox->res->entry_act_bg_color : 247 checkbox->res->wnd_text_color; 248 fmt.halign = gfx_halign_left; 249 fmt.valign = gfx_valign_top; 250 251 rc = gfx_puttext(checkbox->res->font, &pos, &fmt, 252 checkbox->checked ? "[X]" : "[ ]"); 253 if (rc != EOK) 254 goto error; 255 256 /* Paint checkbox label */ 257 258 pos.x += 4; 259 fmt.color = checkbox->res->wnd_text_color; 260 261 rc = gfx_puttext(checkbox->res->font, &pos, &fmt, checkbox->caption); 262 if (rc != EOK) 263 goto error; 264 265 rc = gfx_update(checkbox->res->gc); 266 if (rc != EOK) 267 goto error; 268 269 return EOK; 270 error: 271 return rc; 272 } 273 274 /** Paint check box. 275 * 276 * @param checkbox Check box 277 * @return EOK on success or an error code 278 */ 279 errno_t ui_checkbox_paint(ui_checkbox_t *checkbox) 280 { 281 if (checkbox->res->textmode) 282 return ui_checkbox_paint_text(checkbox); 283 else 284 return ui_checkbox_paint_gfx(checkbox); 224 285 } 225 286
Note:
See TracChangeset
for help on using the changeset viewer.