Changeset 03145ee in mainline


Ignore:
Timestamp:
2020-11-10T09:00:48Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d942ca4
Parents:
0d71fd6
git-author:
Jiri Svoboda <jiri@…> (2020-11-09 20:00:37)
git-committer:
Jiri Svoboda <jiri@…> (2020-11-10 09:00:48)
Message:

Add UI text entry (read-only)

We use the read-only text entry to display calculator output.

Location:
uspace
Files:
5 added
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/calculator/calculator.c

    r0d71fd6 r03145ee  
    4242#include <stdlib.h>
    4343#include <str.h>
    44 #include <ui/label.h>
     44#include <ui/entry.h>
    4545#include <ui/fixed.h>
    4646#include <ui/pbutton.h>
     
    133133
    134134static char *expr = NULL;
    135 static ui_label_t *display;
     135static ui_entry_t *display;
    136136
    137137static bool is_digit(char c)
     
    350350{
    351351        if (expr != NULL)
    352                 (void) ui_label_set_text(display, (void *) expr);
     352                (void) ui_entry_set_text(display, (void *) expr);
    353353        else
    354                 (void) ui_label_set_text(display, (void *) NULL_DISPLAY);
    355 
    356         ui_label_paint(display);
     354                (void) ui_entry_set_text(display, (void *) NULL_DISPLAY);
     355
     356        ui_entry_paint(display);
    357357}
    358358
     
    366366        switch (error_type) {
    367367        case ERROR_SYNTAX:
    368                 (void) ui_label_set_text(display,
     368                (void) ui_entry_set_text(display,
    369369                    (void *) SYNTAX_ERROR_DISPLAY);
    370370                break;
    371371        case ERROR_NUMERIC:
    372                 (void) ui_label_set_text(display,
     372                (void) ui_entry_set_text(display,
    373373                    (void *) NUMERIC_ERROR_DISPLAY);
    374374                break;
    375375        default:
    376                 (void) ui_label_set_text(display,
     376                (void) ui_entry_set_text(display,
    377377                    (void *) UNKNOWN_ERROR_DISPLAY);
    378378                break;
    379379        }
    380380
    381         ui_label_paint(display);
     381        ui_entry_paint(display);
    382382}
    383383
     
    618618        }
    619619
    620         rc = ui_label_create(ui_res, NULL_DISPLAY, &display);
     620        rc = ui_entry_create(ui_res, NULL_DISPLAY, &display);
    621621        if (rc != EOK) {
    622                 printf("Error creating label.\n");
     622                printf("Error creating text lentry.\n");
    623623                return rc;
    624624        }
    625625
    626626        rect.p0.x = 15;
    627         rect.p0.y = 50;
     627        rect.p0.y = 45;
    628628        rect.p1.x = 235;
    629629        rect.p1.y = 70;
    630         ui_label_set_rect(display, &rect);
    631         ui_label_set_halign(display, gfx_halign_right);
    632 
    633         rc = ui_fixed_add(fixed, ui_label_ctl(display));
     630        ui_entry_set_rect(display, &rect);
     631        ui_entry_set_halign(display, gfx_halign_right);
     632
     633        rc = ui_fixed_add(fixed, ui_entry_ctl(display));
    634634        if (rc != EOK) {
    635635                printf("Error adding control to layout.\n");
  • uspace/lib/ui/meson.build

    r0d71fd6 r03145ee  
    3131        'src/control.c',
    3232        'src/dummygc.c',
     33        'src/entry.c',
    3334        'src/fixed.c',
    3435        'src/image.c',
     
    4445test_src = files(
    4546        'test/control.c',
     47        'test/entry.c',
    4648        'test/fixed.c',
    4749        'test/image.c',
  • uspace/lib/ui/private/resource.h

    r0d71fd6 r03145ee  
    8787        /** Inactive titlebar text color */
    8888        gfx_color_t *tbar_inact_text_color;
     89
     90        /** Entry (text entry, checkbox, radio button) foreground color */
     91        gfx_color_t *entry_fg_color;
     92        /** Entry (text entry, checkbox, raido button) background color */
     93        gfx_color_t *entry_bg_color;
    8994};
    9095
  • uspace/lib/ui/src/resource.c

    r0d71fd6 r03145ee  
    7474        gfx_color_t *tbar_act_text_color = NULL;
    7575        gfx_color_t *tbar_inact_text_color = NULL;
     76        gfx_color_t *entry_fg_color = NULL;
     77        gfx_color_t *entry_bg_color = NULL;
    7678        errno_t rc;
    7779
     
    156158        rc = gfx_color_new_rgb_i16(0x5858, 0x5858, 0x5858,
    157159            &tbar_inact_text_color);
     160        if (rc != EOK)
     161                goto error;
     162
     163        rc = gfx_color_new_rgb_i16(0, 0, 0, &entry_fg_color);
     164        if (rc != EOK)
     165                goto error;
     166
     167        rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &entry_bg_color);
    158168        if (rc != EOK)
    159169                goto error;
     
    180190        resource->tbar_inact_bg_color = tbar_inact_bg_color;
    181191        resource->tbar_inact_text_color = tbar_inact_text_color;
     192
     193        resource->entry_fg_color = entry_fg_color;
     194        resource->entry_bg_color = entry_bg_color;
    182195
    183196        *rresource = resource;
     
    217230                gfx_color_delete(tbar_inact_text_color);
    218231
     232        if (entry_fg_color != NULL)
     233                gfx_color_delete(entry_fg_color);
     234        if (entry_bg_color != NULL)
     235                gfx_color_delete(entry_bg_color);
     236
    219237        if (tface != NULL)
    220238                gfx_typeface_destroy(tface);
     
    250268        gfx_color_delete(resource->tbar_inact_text_color);
    251269
     270        gfx_color_delete(resource->entry_fg_color);
     271        gfx_color_delete(resource->entry_bg_color);
     272
    252273        gfx_font_close(resource->font);
    253274        gfx_typeface_destroy(resource->tface);
  • uspace/lib/ui/test/main.c

    r0d71fd6 r03145ee  
    3232
    3333PCUT_IMPORT(control);
     34PCUT_IMPORT(entry);
    3435PCUT_IMPORT(fixed);
    3536PCUT_IMPORT(image);
Note: See TracChangeset for help on using the changeset viewer.