From 1a0e4a2af073c5771e581d3b95fd2903d696c958 Mon Sep 17 00:00:00 2001 From: steffen Date: Sun, 10 Mar 2013 23:32:27 +0000 Subject: [PATCH] checkbox added, config screen seems slowly to work.. --- android/jni/Android.mk | 2 +- draw/draw.c | 22 ++++++- draw/draw.h | 6 +- draw/draw_gui.c | 2 +- gui/Makefile | 1 + gui/gui.c | 42 ++++++++++---- gui/gui.h | 9 +++ gui/gui_button.c | 4 +- gui/gui_checkbox.c | 94 ++++++++++++++++++++++++++++++ gui/gui_entry.c | 10 +--- gui/gui_softkeyboard.c | 128 +++++++++++++++++++++++++++++++++++++---- main/gui_config.c | 20 ++++++- sdlgl/sdl_gfx.c | 4 +- 13 files changed, 303 insertions(+), 41 deletions(-) create mode 100644 gui/gui_checkbox.c diff --git a/android/jni/Android.mk b/android/jni/Android.mk index b35b19a..0ed5a1e 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -77,7 +77,7 @@ LOCAL_SRC_FILES := \ mapsys/map_webload.c mapsys/map_searchhash.c\ mapsys/map.c mapsys/map_loadsave.c mapsys/map_way.c \ gui/gui.c gui/gui_button.c gui/gui_entry.c gui/gui_image.c gui/gui_label.c \ - gui/gui_list.c gui/gui_window.c gui\gui_softkeyboard.c \ + gui/gui_list.c gui/gui_window.c gui\gui_softkeyboard.c gui\gui_checkbox.c \ draw/draw.c draw/draw_favorites.c draw/draw_gps.c draw/draw_gui.c draw/draw_route.c \ main/favorites.c main/gui_buttons.c main/gui_mainmenu.c main/guiw_gpsfile.c \ main/main.c main/routing.c main/gps.c main/gui_favorites.c \ diff --git a/draw/draw.c b/draw/draw.c index 9e5f7e5..2b7ed7f 100644 --- a/draw/draw.c +++ b/draw/draw.c @@ -151,6 +151,7 @@ void draw_setscalef (float newscale) { break; default: draw_type [i] = FALSE; + break; } } } @@ -166,6 +167,7 @@ void draw_setscalef (float newscale) { break; default: draw_type [i] = FALSE; + break; } } } @@ -339,6 +341,22 @@ void draw_rectangle (struct image *dimg, int x1, int y1, int x2, int y2, struct }; +void draw_fillrectangle (struct image *dimg, int x1, int y1, int x2, int y2, struct color *c) { + struct line_style ls; + + ls.c = *c; + ls.borderc = *c; + ls.width = 1.0; + + iPoint points[4] = { {x1, y1}, + {x2, y1}, + {x2, y2}, + {x1, y2} }; + + gfx_draw_polygon (dimg, points, 4, ls, c); +}; + + /* * lines */ @@ -383,7 +401,7 @@ void draw_polygonadd (int x, int y) { }; -void draw_polygonfinish (struct image *dimg, struct line_style ls, struct color c, int border) { +void draw_polygonfinish (struct image *dimg, struct line_style ls, struct color *c, int border) { int i; gfx_draw_polygon (dimg, _polypoints, _polycnt, ls, c); @@ -469,7 +487,7 @@ void draw_map () { p1 = draw_geo2screen (view_lon, view_lat, carea->p[n].lon, carea->p[n].lat); draw_polygonadd (p1.x + center.x, p1.y + center.y); } - draw_polygonfinish (img_map, tmplinestyle, color_polygon[carea->type], 0); + draw_polygonfinish (img_map, tmplinestyle, &color_polygon[carea->type], 0); } carea = carea->next; } diff --git a/draw/draw.h b/draw/draw.h index e64c39c..94c2b92 100644 --- a/draw/draw.h +++ b/draw/draw.h @@ -137,10 +137,10 @@ extern void draw_redrawmap (); extern void draw_line (struct image *img, int x1, int y1, int x2, int y2, struct line_style style); extern void draw_lineway (struct image *img, int x1, int y1, int x2, int y2, struct line_style style); extern void draw_rectangle (struct image *img, int x1, int y1, int x2, int y2, struct line_style style); +extern void draw_fillrectangle (struct image *img, int x1, int y1, int x2, int y2, struct color *c); extern void draw_polygonstart (); extern void draw_polygonadd (int x, int y); -extern void draw_polygonfinish (struct image *img, struct line_style ls, struct color c, int border); - +extern void draw_polygonfinish (struct image *img, struct line_style ls, struct color *c, int border); /* @@ -155,7 +155,7 @@ extern int gfx_color_alloc (struct color *c, unsigned short int r, unsigned shor extern void gfx_draw_img (struct image *dimg, int dx, int dy, int dw, int dh, struct image *simg, int sx, int sy); extern void gfx_draw_line (struct image *dimg, int x1, int y1, int x2, int y2, struct line_style style); extern void gfx_draw_text (struct image *dimg, int x, int y, char *text, struct color *c); -extern void gfx_draw_polygon (struct image *dimg, iPoint *p, int pcnt, struct line_style style, struct color c); +extern void gfx_draw_polygon (struct image *dimg, iPoint *p, int pcnt, struct line_style style, struct color *c); // extern void gfx_draw_rect (struct image *dimg, int x1, int y1, int x2, int y2, struct color *c); extern void gfx_clear (struct image *dimg, struct color *c); diff --git a/draw/draw_gui.c b/draw/draw_gui.c index e548bad..0548f14 100644 --- a/draw/draw_gui.c +++ b/draw/draw_gui.c @@ -193,7 +193,7 @@ void draw_gui () { draw_polygonadd (p2.x, p1.y); draw_polygonadd (p2.x, p2.y); draw_polygonadd (p1.x, p2.y); - draw_polygonfinish (NULL, ls, color[COLOR_blue][3], 1); + draw_polygonfinish (NULL, ls, &color[COLOR_blue][3], 1); gfx_draw_text (NULL, p1.x + 2, p1.y + 2, app.statusline_text, &color[COLOR_white][3]); } diff --git a/gui/Makefile b/gui/Makefile index eb3a65a..861d206 100644 --- a/gui/Makefile +++ b/gui/Makefile @@ -2,6 +2,7 @@ include ../Makefile.rules OBJ = gui.o \ gui_window.o \ + gui_checkbox.o \ gui_button.o \ gui_list.o \ gui_entry.o \ diff --git a/gui/gui.c b/gui/gui.c index 3797c93..794717d 100644 --- a/gui/gui.c +++ b/gui/gui.c @@ -1,4 +1,4 @@ -/* $Id: gui.c,v 1.19 2013/03/09 00:02:30 steffen Exp $ */ +/* $Id: gui.c,v 1.20 2013/03/10 23:32:28 steffen Exp $ */ /*************************************************************************** * gui.c * @@ -89,7 +89,7 @@ void gui_draw () { draw_polygonadd (0, currentwin->h); draw_polygonadd (currentwin->w, currentwin->h); draw_polygonadd (currentwin->w, 0); - draw_polygonfinish (currentwin->screen, ls, color[COLOR_white][0], 1); + draw_polygonfinish (currentwin->screen, ls, &color[COLOR_white][0], 1); gfx_draw_text (currentwin->screen, 4, 0, currentwin->title, &color[COLOR_white][3]); if (currentwin->title[0] != 0) gfx_draw_line (currentwin->screen, 0, 18, currentwin->w, 18, ls); } @@ -112,9 +112,9 @@ void gui_draw () { case (GUI_LIST): gui_list_draw (currentwin->items[i]); break; - // case (GUI_UNKNOWN): - // gui_UNKNOWN_draw ((GUIEntry*)currentwin->items[i].item); - // break; + case (GUI_CHECKBOX): + gui_checkbox_draw (currentwin->items[i]); + break; default: break; } @@ -143,9 +143,9 @@ void gui_draw () { /* drawing and display softkeyb */ gui_softkeyb_draw (); - gfx_draw_img (NULL, - (gfx_screensize.x-softkeyb->screen->width)/2, - gfx_screensize.y-softkeyb->screen->height, + softkeyb->offset.x = (gfx_screensize.x-softkeyb->screen->width)/2; + softkeyb->offset.y = gfx_screensize.y-softkeyb->screen->height; + gfx_draw_img (NULL, softkeyb->offset.x, softkeyb->offset.y, softkeyb->screen->width, softkeyb->screen->height, softkeyb->screen, 0, 0); /* drawing part of the screen where the entry element is set up.. */ @@ -172,18 +172,35 @@ int gui_event (GUIEvent event) { if (event_called) return 1; event_called = 1; +// d_printf ("********event: currentwin:%p, softkeyb:%p softkeyb->enabled:%d", currentwin, softkeyb, softkeyb == NULL ? 0 : softkeyb->enabled); if (currentwin) { winpos.x = event.mousepos.x - currentwin->x; winpos.y = event.mousepos.y - currentwin->y; item = currentwin->focus; - + + /* check if softkeyb if opened */ + if ((softkeyb && softkeyb->enabled) + && (event.event == EGUI_MOUSERELEASED || event.event == EGUI_MOUSEPRESSED)) { + int x1 = (gfx_screensize.x-softkeyb->screen->width)/2, + x2 = gfx_screensize.x-(gfx_screensize.x-softkeyb->screen->width)/2, + y1 = gfx_screensize.y-softkeyb->screen->height, + y2 = gfx_screensize.y; + + if ( x1 <= event.mousepos.x && x2 >= event.mousepos.x + && y1 <= event.mousepos.y && y2 >= event.mousepos.y) { + gui_softkeyb_event (event); + event_called = 0; + return 1; + } + } + for (i = 0; i < GUI_MAX_ITEM; i++) if (currentwin->items[i] != NULL) if (GUI_ITEM_IS_INSIDE (currentwin->items[i], winpos)) item = currentwin->items[i]; - d_printf ("item:%p , type:%d , focus:%p , event:%d", item, item ? item->type : -1, currentwin->focus, event.event); +// d_printf ("item:%p , type:%d , focus:%p , event:%d", item, item ? item->type : -1, currentwin->focus, event.event); if (item) switch (item->type) { case (GUI_BUTTON): @@ -203,6 +220,11 @@ int gui_event (GUIEvent event) { event_called = 0; return 1; break; + case (GUI_CHECKBOX): + gui_checkbox_event (item, &event); + event_called = 0; + return 1; + break; default: break; } diff --git a/gui/gui.h b/gui/gui.h index f825174..4cdd32c 100644 --- a/gui/gui.h +++ b/gui/gui.h @@ -150,7 +150,10 @@ struct _GUISoftkeyboard_ { int enabled; int linepos[2][4]; /* y positions of lines */ int btnpos[2][4]; /* holds position keys: Shift, Symbols, Space, Close */ + iPoint offset; /* screenoffset .. will be set during last draw */ struct image *screen; + int last_col; + int last_line; char keys[GUI_SOFTKEYB_MODE_MAX][GUI_SOFTKEYB_Y][GUI_SOFTKEYB_X]; } typedef GUISoftkeyboard; @@ -179,6 +182,12 @@ extern void gui_button_draw (GUIItem *item); extern int gui_button_event (GUIItem *item, GUIEvent *event); extern GUIItem *gui_button_new (char *name, int x, int y, int w, int h); +/* checkbox functions */ +#define GUI_CHECKBOX_T(_item_) ((GUICheckbox*)(_item_)->data) +extern void gui_checkbox_draw (GUIItem *item); +extern int gui_checkbox_event (GUIItem *item, GUIEvent *event); +extern GUIItem *gui_checkbox_new (char *text, int initialvalue, int x, int y); + /* label functions */ #define GUI_LABEL_T(_item_) ((GUILabel*)(_item_)->data) extern void gui_label_draw (GUIItem *item); diff --git a/gui/gui_button.c b/gui/gui_button.c index f022c25..e45cc8c 100644 --- a/gui/gui_button.c +++ b/gui/gui_button.c @@ -1,4 +1,4 @@ -/* $Id: gui_button.c,v 1.8 2013/03/10 00:09:40 steffen Exp $ */ +/* $Id: gui_button.c,v 1.9 2013/03/10 23:32:28 steffen Exp $ */ /*************************************************************************** * gui_button.c * @@ -51,7 +51,7 @@ void gui_button_draw (GUIItem *item) { draw_polygonadd (item->x, item->y + item->h); draw_polygonadd (item->x + item->w, item->y + item->h); draw_polygonadd (item->x + item->w, item->y); - draw_polygonfinish (currentwin->screen, ls, *button->col, 1); + draw_polygonfinish (currentwin->screen, ls, button->col, 1); gfx_draw_text (currentwin->screen, item->x + 2, item->y + 2, button->caption, button->textcol); }; diff --git a/gui/gui_checkbox.c b/gui/gui_checkbox.c new file mode 100644 index 0000000..f797f8f --- /dev/null +++ b/gui/gui_checkbox.c @@ -0,0 +1,94 @@ +/* $Id: gui_checkbox.c,v 1.1 2013/03/10 23:32:28 steffen Exp $ */ +/*************************************************************************** + * gui_checkbox.c + * + * Copyright (C) 2013 Steffen Pohle + * steffen@gulpe.de + *************************************************************************** + * checkbox gui element + ***************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * main.c is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + + +#include "osmroute.h" +#include "draw.h" +#include "gui.h" +#include "system.h" + +/**************************************************************************** + * label + */ +void gui_checkbox_draw (GUIItem *item) { + GUICheckbox *checkbox = NULL; + struct line_style ls; + if (item) checkbox = (GUICheckbox*) item->data; + + ls.c = color[COLOR_white][3]; + ls.width = 1.0; + ls.borderc = ls.c; + draw_rectangle (currentwin->screen, item->x , item->y, item->x + 15, item->y + 15, ls); + if (checkbox->checked) { + gfx_draw_line (currentwin->screen, item->x , item->y, item->x + 15, item->y + 15, ls); + gfx_draw_line (currentwin->screen, item->x + 15 , item->y, item->x, item->y + 15, ls); + } + gfx_draw_text (currentwin->screen, item->x + 17, item->y, checkbox->text, &ls.c); +}; + + +GUIItem *gui_checkbox_new (char *text, int initialvalue, int x, int y) { + GUIItem *item = (GUIItem*) ml_malloc (sizeof (GUICheckbox) + sizeof (GUIItem) + POINTERALIGNMENT); + GUICheckbox *checkbox = NULL; + if (item) checkbox = (GUICheckbox*) item->data; + + if (text == NULL) checkbox->text[0] = 0; + else strncpy (checkbox->text, text, GUI_TEXTLEN); + item->x = x; + item->y = y; + item->w = x + 15; + item->y = y + 15; + + checkbox->checked = initialvalue; + checkbox->callback_changed = NULL; + item->type = GUI_CHECKBOX; + + return item; +}; + + +int gui_checkbox_event (GUIItem *item, GUIEvent *event) { + GUICheckbox *checkbox = NULL; + if (item) checkbox = (GUICheckbox*) item->data; + + if (item == NULL || item->type != GUI_CHECKBOX) { + d_printf ("GUIButton %p not type GUICheckbox", item); + errorexit (-1); + } + + if (event->event == EGUI_MOUSEPRESSED) { + checkbox->checked = !checkbox->checked; + if (checkbox->callback_changed != NULL) { + gui_set_focus (NULL); + checkbox->callback_changed (); + } + currentwin->screen_changed = 1; + draw(); + return 1; + } + + return 0; +}; + diff --git a/gui/gui_entry.c b/gui/gui_entry.c index ec607c2..9b14e01 100644 --- a/gui/gui_entry.c +++ b/gui/gui_entry.c @@ -1,4 +1,4 @@ -/* $Id: gui_entry.c,v 1.11 2013/03/10 00:09:40 steffen Exp $ */ +/* $Id: gui_entry.c,v 1.12 2013/03/10 23:32:28 steffen Exp $ */ /*************************************************************************** * gui_entry.c * @@ -40,8 +40,6 @@ void gui_entry_draw (GUIItem *item) { if (item) entry = (GUIEntry *) item->data; else return; - d_printf ("draw entry: curpos:%d", entry->curpos); - ls.width = 1.0; if (currentwin->focus == (void*) item) ls.c = ls.borderc = color[COLOR_white][3]; @@ -77,15 +75,12 @@ int gui_entry_event (GUIItem *item, GUIEvent *event) { if (item) entry = (GUIEntry *) item->data; - d_printf ("gui_entry_event: %d pos: %d,%d key:%d", event->event, event->mousepos.x, event->mousepos.y, event->keyval); - - if (event->event == EGUI_MOUSERELEASED) { + if (event->event == EGUI_MOUSEPRESSED) { gui_set_focus (item); gui_softkeyb_show (TRUE); } else if (event->event == EGUI_KEYCHAR) { - d_printf ("gui_entry_event: curpos:%d len:%d text:%s char:%x", entry->curpos, strlen (entry->text), entry->text, event->keyval); if (event->keyval == 0x08) { // backspace if (entry->curpos > 0) { memset (text1, 0x0, GUI_TEXTLEN); @@ -116,7 +111,6 @@ int gui_entry_event (GUIItem *item, GUIEvent *event) { // ignore all the rest } else { - d_printf ("new char:"); strncpy (text1, entry->text, GUI_TEXTLEN ); snprintf (entry->text, GUI_TEXTLEN, "%s%c", text1, event->keyval); entry->curpos++; diff --git a/gui/gui_softkeyboard.c b/gui/gui_softkeyboard.c index e6f37b0..82a348a 100644 --- a/gui/gui_softkeyboard.c +++ b/gui/gui_softkeyboard.c @@ -1,4 +1,4 @@ -/* $Id: gui_softkeyboard.c,v 1.3 2013/03/10 00:09:40 steffen Exp $ */ +/* $Id: gui_softkeyboard.c,v 1.4 2013/03/10 23:32:28 steffen Exp $ */ /*************************************************************************** * gui_softkeyboard.c * @@ -37,8 +37,8 @@ void gui_softkeyb_getpos (int row, int btnnr, int *x1, int *x2, int *y1, int *y2 void gui_softkeyb_show (int enable) { /* keys which are displayed.. */ char line[GUI_SOFTKEYB_MODE_MAX][GUI_SOFTKEYB_X][GUI_SOFTKEYB_X] = { - { "qwertzuiop?", - "asdfghjkl??", + { "qwertzuiop\\", + "asdfghjkl/:", "yxcvbnm,.-_" }, { "QWERTZUIOP?", "ASDFGHIKL??", @@ -66,14 +66,16 @@ void gui_softkeyb_show (int enable) { softkeyb->enabled = TRUE; softkeyb->mode = GUI_SOFTKEYB_MODE_NORM; + softkeyb->last_line = -1; + softkeyb->last_col = -1; }; /* only preparing the screen image... copying to the screen will be done later... */ static float _linepos[2][4] = { { 5.0, 25.0, 45.0, 65.0 }, { 20.0, 40.0, 60.0, 95.0 } }; -static float _btnpos[2][4] = { { 5.0, 20.0, 35.0, 65.0 }, - { 15.0, 30.0, 60.0, 95.0 } }; +static float _btnpos[2][5] = { { 2.0, 16.0, 35.0, 62.0, 79.0 }, + { 14.0, 33.0, 60.0, 77.0, 98.0 } }; void gui_softkeyb_getpos (int row, int btnnr, int *x1, int *y1, int *x2, int *y2) { if (row < 3) { @@ -82,11 +84,18 @@ void gui_softkeyb_getpos (int row, int btnnr, int *x1, int *y1, int *x2, int *y2 *y1 = (_linepos[0][row] * softkeyb->screen->height)/100; *y2 = (_linepos[1][row] * softkeyb->screen->height)/100; } + else if (row == 3) { + *x1 = (_btnpos[0][btnnr] * softkeyb->screen->width)/100; + *x2 = (_btnpos[1][btnnr] * softkeyb->screen->width)/100; + *y1 = (_linepos[0][row] * softkeyb->screen->height)/100; + *y2 = (_linepos[1][row] * softkeyb->screen->height)/100; + } }; void gui_softkeyb_draw () { struct line_style ls; int i, j, x1, x2, y1, y2; + char c[16] = { 0 }; if (softkeyb == NULL || gfx_screensize.x < 0 || softkeyb->enabled == FALSE) return; if (softkeyb->screen == NULL || softkeyb->screen->width != gfx_screensize.x) { @@ -95,32 +104,131 @@ void gui_softkeyb_draw () { } /* setup the lines... */ - for (j = 0; j < 2; j++) for (i = 0; i < 4; i++) { - softkeyb->linepos[j][i] = _linepos[j][i] * softkeyb->screen->width; + for (j = 0; j < 2; j++) for (i = 0; i < 5; i++) { + if (i < 4) softkeyb->linepos[j][i] = _linepos[j][i] * softkeyb->screen->width; softkeyb->btnpos[j][i] = _btnpos[j][i] * softkeyb->screen->height; } /* draw border */ - ls.c = color[COLOR_white][2]; + ls.c = color[COLOR_red][2]; ls.width = 1; gfx_clear (softkeyb->screen, &color[COLOR_white][1]); draw_rectangle (softkeyb->screen, 1, 1, softkeyb->screen->width-2, softkeyb->screen->height-2, ls); /* draw 3 key rows.. */ - ls.c = color[COLOR_blue][2]; + ls.c = color[COLOR_white][2]; ls.width = 1; for (j = 0; j < 3; j++) { for (i = 0; i < GUI_SOFTKEYB_X; i++) { gui_softkeyb_getpos (j, i, &x1, &y1, &x2, &y2); + if (softkeyb->last_col == i && softkeyb->last_line == j) + draw_fillrectangle (softkeyb->screen, x1, y1, x2, y2, &color[COLOR_white][0]); draw_rectangle (softkeyb->screen, x1, y1, x2, y2, ls); + c[0] = softkeyb->keys[softkeyb->mode][j][i]; + gfx_draw_text (softkeyb->screen, x1+(x2-x1-12)/2, y1+(y2-y1-12)/2, c, &color[COLOR_white][3]); } } /* draw the last keys */ - + for (j = 3, i = 0; i < 5; i++) { + gui_softkeyb_getpos (j, i, &x1, &y1, &x2, &y2); + if (softkeyb->last_col == i && softkeyb->last_line == 3) + draw_fillrectangle (softkeyb->screen, x1, y1, x2, y2, &color[COLOR_white][0]); + draw_rectangle (softkeyb->screen, x1, y1, x2, y2, ls); + switch (i) { + case (0): + snprintf (c, 16, _("SYM")); + break; + case (1): + snprintf (c, 16, _("SHIFT")); + break; + case (2): + snprintf (c, 16, _(" ")); + break; + case (3): + snprintf (c, 16, _("Del")); + break; + case (4): + snprintf (c, 16, _("Close")); + break; + } + gfx_draw_text (softkeyb->screen, x1+(x2-x1-8*strlen (c))/2, y1+(y2-y1-12)/2, c, &color[COLOR_white][3]); + } }; int gui_softkeyb_event (GUIEvent event) { + int i, j, x1, y1, x2, y2; + GUIEvent newevent; + iPoint mp = { event.mousepos.x - softkeyb->offset.x, event.mousepos.y - softkeyb->offset.y }; + + if (event.event != EGUI_MOUSEPRESSED && event.event != EGUI_MOUSERELEASED) return 0; + + /* check if we pressed one of the keys.. */ + for (j = 0; j < 3; j++) + for (i = 0; i < GUI_SOFTKEYB_X; i++) { + gui_softkeyb_getpos (j, i, &x1, &y1, &x2, &y2); + if (x1 <= mp.x && mp.x <= x2 && y1 <= mp.y && mp.y <= y2) { + if (event.event == EGUI_MOUSEPRESSED) { + softkeyb->last_line = j; + softkeyb->last_col = i; + newevent.keyval = softkeyb->keys[softkeyb->mode][j][i]; + newevent.event = EGUI_KEYCHAR; + newevent.mousepos.x = -1; + newevent.mousepos.y = -1; + gui_entry_event (currentwin->focus, &newevent); + } + else { + softkeyb->last_line = -1; + softkeyb->last_col = -1; + } + return 1; + } + } + + for (i = 0; i < 5; i++) { + gui_softkeyb_getpos (3, i, &x1, &y1, &x2, &y2); + if (x1 <= mp.x && mp.x <= x2 && y1 <= mp.y && mp.y <= y2) { + if (event.event == EGUI_MOUSEPRESSED) { + softkeyb->last_line = 3; + softkeyb->last_col = i; + switch (i) { + case (0): + softkeyb->mode = (softkeyb->mode == GUI_SOFTKEYB_MODE_SYMBOL) ? 0 : GUI_SOFTKEYB_MODE_SYMBOL; + break; + case (1): + softkeyb->mode = (softkeyb->mode == GUI_SOFTKEYB_MODE_SHIFT) ? 0 : GUI_SOFTKEYB_MODE_SHIFT; + break; + case (2): + newevent.keyval = ' '; + newevent.event = EGUI_KEYCHAR; + newevent.mousepos.x = -1; + newevent.mousepos.y = -1; + gui_entry_event (currentwin->focus, &newevent); + return 1; + break; + case (3): + newevent.keyval = 0x08; + newevent.event = EGUI_KEYCHAR; + newevent.mousepos.x = -1; + newevent.mousepos.y = -1; + gui_entry_event (currentwin->focus, &newevent); + return 1; + break; + case (4): + softkeyb->enabled = 0; + currentwin->screen_changed = 1; + draw (); + return 1; + break; + } + } + else { + softkeyb->last_line = -1; + softkeyb->last_col = -1; + } + } + } + return 0; }; diff --git a/main/gui_config.c b/main/gui_config.c index 535e2cb..c36903a 100644 --- a/main/gui_config.c +++ b/main/gui_config.c @@ -37,13 +37,15 @@ GUIItem *map_seldir = NULL; GUIItem *gps_device = NULL; GUIItem *gps_list = NULL; GUIItem *gps_file = NULL; +GUIItem *log_file = NULL; +GUIItem *cb_debug = NULL; GUIItem *wcfg_close = NULL; GUIItem *label1 = NULL; GUIItem *label2 = NULL; void gui_config_show () { - if (wcfg.screen == NULL) gui_window_new (&wcfg, 220, 240, _("Config")); + if (wcfg.screen == NULL) gui_window_new (&wcfg, 220, 280, _("Config")); wcfg.screen_changed = 1; wcfg.style = WGUI_S_VCENTER | WGUI_S_HCENTER; gui_show (&wcfg); @@ -69,13 +71,27 @@ void gui_config_show () { GUI_BUTTON_T (gps_file)->callback_clicked = gui_config_gpsfile; gui_window_item_add (&wcfg, gps_file); - if (wcfg_close == NULL) wcfg_close = gui_button_new (_("Close"), 5, wcfg.h-25, wcfg.w-10, 20); + if (log_file == NULL) + log_file = gui_checkbox_new (_("Create GPS-Log"), cfg.gps_flags & GPSF_LOG, 10, 172); + gui_window_item_add (&wcfg, log_file); + + if (cb_debug == NULL) + cb_debug = gui_checkbox_new (_("Enable Debug-Logfile"), cfg.debug, 5, 200); + gui_window_item_add (&wcfg, cb_debug); + + if (wcfg_close == NULL) wcfg_close = + gui_button_new (_("Close"), 5, wcfg.h-25, wcfg.w-10, 20); GUI_BUTTON_T (wcfg_close)->callback_clicked = gui_config_close; gui_window_item_add (&wcfg, wcfg_close); }; void gui_config_close () { + strncpy (cfg.mappath, GUI_ENTRY_T(map_path)->text, LEN_FILENAME); + strncpy (cfg.gps_device, GUI_ENTRY_T(gps_device)->text, LEN_FILENAME); + cfg.debug = GUI_CHECKBOX_T(cb_debug)->checked; + if (GUI_CHECKBOX_T(log_file)->checked) cfg.gps_flags |= GPSF_LOG; + else cfg.gps_flags &= (0x0FFFF-GPSF_LOG); gui_close (); }; diff --git a/sdlgl/sdl_gfx.c b/sdlgl/sdl_gfx.c index 3080e2b..c41d2a4 100644 --- a/sdlgl/sdl_gfx.c +++ b/sdlgl/sdl_gfx.c @@ -151,12 +151,12 @@ void gfx_draw_line (struct image *dimg, int x1, int y1, int x2, int y2, struct l /* * draw polygon */ -void gfx_draw_polygon (struct image *dimg, iPoint *p, int pcnt, struct line_style style, struct color c) { +void gfx_draw_polygon (struct image *dimg, iPoint *p, int pcnt, struct line_style style, struct color *c) { int i; gfx_fbo_switch (dimg); glBegin (GL_POLYGON); - glColor4f (c.c.r, c.c.g, c.c.b, 1.0f); + glColor4f (c->c.r, c->c.g, c->c.b, 1.0f); for (i = 0; i < pcnt; i++) glVertex2i (p[i].x, p[i].y);