Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions examples/nanoxcalc/nxcalc.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,25 +122,25 @@
int c;
int idx;

if (GrOpen() < 0)

Check failure on line 125 in examples/nanoxcalc/nxcalc.c

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found
{
fprintf(stderr, "nxcalc: cannot open Nano-X\n");
return 1;
}

win = GrNewWindowEx(GR_WM_PROPS_APPWINDOW, "nxcalc", GR_ROOT_WINDOW_ID, 10,

Check failure on line 131 in examples/nanoxcalc/nxcalc.c

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found
10, WIN_W, WIN_H, GrGetSysColor(GR_COLOR_WINDOW));

Check failure on line 132 in examples/nanoxcalc/nxcalc.c

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found

GrSelectEvents(win,

Check failure on line 134 in examples/nanoxcalc/nxcalc.c

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found
GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_BUTTON_DOWN |
GR_EVENT_MASK_BUTTON_UP | GR_EVENT_MASK_CLOSE_REQ);

gc_text = GrNewGC();

Check failure on line 138 in examples/nanoxcalc/nxcalc.c

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found
gc_button = GrNewGC();

Check failure on line 139 in examples/nanoxcalc/nxcalc.c

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found
gc_button_press = GrNewGC();

Check failure on line 140 in examples/nanoxcalc/nxcalc.c

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found
gc_border = GrNewGC();

Check failure on line 141 in examples/nanoxcalc/nxcalc.c

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found

GrSetGCForeground(gc_text, GrGetSysColor(GR_COLOR_WINDOWTEXT));

Check failure on line 143 in examples/nanoxcalc/nxcalc.c

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found

Check failure on line 143 in examples/nanoxcalc/nxcalc.c

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found
GrSetGCBackground(gc_text, GrGetSysColor(GR_COLOR_WINDOW));

GrSetGCForeground(gc_button, GrGetSysColor(GR_COLOR_BTNFACE));
Expand Down Expand Up @@ -176,6 +176,7 @@
{
int x = grid_x + c * cell_w;
int y = grid_y + r * cell_h;

btn_rects[r][c].x = x;
btn_rects[r][c].y = y;
btn_rects[r][c].width = cell_w - 6;
Expand Down Expand Up @@ -204,11 +205,13 @@
int mx = event.button.x;
int my = event.button.y;
int found = 0;

for (r = 0; r < ROWS && !found; r++)
{
for (c = 0; c < COLS && !found; c++)
{
GR_RECT *rc = &btn_rects[r][c];

if (mx >= rc->x && mx <= rc->x + rc->width &&
my >= rc->y && my <= rc->y + rc->height)
{
Expand All @@ -226,11 +229,13 @@
int mx = event.button.x;
int my = event.button.y;
int found = 0;

for (r = 0; r < ROWS && !found; r++)
{
for (c = 0; c < COLS && !found; c++)
{
GR_RECT *rc = &btn_rects[r][c];

if (mx >= rc->x && mx <= rc->x + rc->width &&
my >= rc->y && my <= rc->y + rc->height)
{
Expand All @@ -239,6 +244,7 @@
(int)(sizeof(btn_labels) /
sizeof(btn_labels[0]))?
btn_labels[idx] : NULL);

if (lbl)
{
press_button(lbl);
Expand Down Expand Up @@ -287,13 +293,14 @@
&th, &tb);

int x = WIN_W - 12 - tw;

if (x < 10)
{
x = 10;
}

GrText(win, gc_text, x, 5 + (DISP_H / 2) - 10, display, strlen(display),
GR_TFTOP);
GrText(win, gc_text, x, 5 + (DISP_H / 2) - 10, display, strlen(display),
GR_TFTOP);

/* draw buttons */

Expand Down Expand Up @@ -332,7 +339,6 @@

static void press_button(const char *label)
{
char tmp[128];
double val;

if (strcmp(label, "C") == 0)
Expand All @@ -349,6 +355,7 @@
if (strcmp(label, "<-") == 0)
{
int l = strlen(display);

if (l > 0)
{
if (display[l - 1] == '.')
Expand All @@ -375,13 +382,21 @@
}
else
{
if (strlen(display) == 0 || strcmp(display, "0") == 0)
int len = strlen(display);

if (len == 0 || strcmp(display, "0") == 0)
{
return;
}

snprintf(tmp, sizeof(tmp), "-%s", display);
strncpy(display, tmp, sizeof(display) - 1);
if (len > sizeof(display) - 2)
{
len = sizeof(display) - 2;
display[len] = '\0';
}

memmove(display + 1, display, len + 1);
display[0] = '-';
}

return;
Expand Down
2 changes: 1 addition & 1 deletion graphics/microwindows/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ MICROWINDOWS_DIR_NAME = microwindows

WD := ${shell echo $(CURDIR) | sed -e 's/ /\\ /g'}

MICROWINDOWS_COMMIT_HASH := 19d1890f67f7e099c17b2fd4529c5160327eedba
MICROWINDOWS_COMMIT_HASH := ac1063aec73d341db04d5f08aa8eb601215a69bc

CONFIG_GRAPH_MICROWINDOWS_URL ?= https://codeload.github.com/ghaerr/microwindows/zip/$(MICROWINDOWS_COMMIT_HASH)

Expand Down
Loading