Changeset 03145ee in mainline for uspace/app/calculator/calculator.c


Ignore:
Timestamp:
2020-11-10T09:00:48Z (4 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.

File:
1 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");
Note: See TracChangeset for help on using the changeset viewer.