Changeset c88d7f99 in mainline for uspace/lib/ui/src/menuentry.c


Ignore:
Timestamp:
2022-03-10T17:44:35Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c38ab6c
Parents:
96c6a00
Message:

Menu entry accelerators

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/src/menuentry.c

    r96c6a00 rc88d7f99  
    4343#include <stdlib.h>
    4444#include <str.h>
     45#include <ui/accel.h>
    4546#include <ui/control.h>
    4647#include <ui/paint.h>
     
    245246        res = ui_window_get_res(mentry->menu->mbar->window);
    246247
    247         *caption_w = gfx_text_width(res->font, mentry->caption);
    248         *shortcut_w = gfx_text_width(res->font, mentry->shortcut);
     248        *caption_w = ui_text_width(res->font, mentry->caption);
     249        *shortcut_w = ui_text_width(res->font, mentry->shortcut);
    249250}
    250251
     
    331332}
    332333
     334/** Get menu entry accelerator character.
     335 *
     336 * @param mentry Menu entry
     337 * @return Accelerator character (lowercase) or the null character if
     338 *         the menu entry has no accelerator.
     339 */
     340char32_t ui_menu_entry_get_accel(ui_menu_entry_t *mentry)
     341{
     342        return ui_accel_get(mentry->caption);
     343}
     344
    333345/** Paint menu entry.
    334346 *
     
    340352{
    341353        ui_resource_t *res;
    342         gfx_text_fmt_t fmt;
     354        ui_text_fmt_t fmt;
    343355        gfx_color_t *bg_color;
    344356        ui_menu_entry_geom_t geom;
     
    350362        ui_menu_entry_get_geom(mentry, pos, &geom);
    351363
    352         gfx_text_fmt_init(&fmt);
     364        ui_text_fmt_init(&fmt);
    353365        fmt.font = res->font;
    354366        fmt.halign = gfx_halign_left;
     
    358370            mentry == mentry->menu->selected) {
    359371                fmt.color = res->wnd_sel_text_color;
     372                fmt.hgl_color = res->wnd_sel_text_hgl_color;
    360373                bg_color = res->wnd_sel_text_bg_color;
    361374        } else {
    362375                fmt.color = res->wnd_text_color;
     376                fmt.hgl_color = res->wnd_text_hgl_color;
    363377                bg_color = res->wnd_face_color;
    364378        }
     
    372386                goto error;
    373387
    374         rc = gfx_puttext(&geom.caption_pos, &fmt, mentry->caption);
     388        rc = ui_paint_text(&geom.caption_pos, &fmt, mentry->caption);
    375389        if (rc != EOK)
    376390                goto error;
     
    378392        fmt.halign = gfx_halign_right;
    379393
    380         rc = gfx_puttext(&geom.shortcut_pos, &fmt, mentry->shortcut);
     394        rc = ui_paint_text(&geom.shortcut_pos, &fmt, mentry->shortcut);
    381395        if (rc != EOK)
    382396                goto error;
Note: See TracChangeset for help on using the changeset viewer.