From f6afe7f426d983f4661ad59649b18fb087095521 Mon Sep 17 00:00:00 2001 From: steffen Date: Tue, 18 Jun 2013 22:24:20 +0000 Subject: [PATCH] softkeyboard adding enter key. --- gui/gui.c | 6 +++++- gui/gui.h | 4 ++-- gui/gui_softkeyboard.c | 22 +++++++++++++++++----- gui/gui_window.c | 9 ++++++++- main/Makefile | 8 ++++---- main/gui_mainmenu.c | 4 +++- main/wnd_routing.c | 38 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 77 insertions(+), 14 deletions(-) create mode 100644 main/wnd_routing.c diff --git a/gui/gui.c b/gui/gui.c index 9a67b1d..6f38c08 100644 --- a/gui/gui.c +++ b/gui/gui.c @@ -1,4 +1,4 @@ -/* $Id: gui.c,v 1.23 2013/04/03 21:52:27 steffen Exp $ */ +/* $Id: gui.c,v 1.24 2013/06/18 22:24:20 steffen Exp $ */ /*************************************************************************** * gui.c * @@ -169,6 +169,10 @@ int gui_event (GUIEvent event) { event.guiwin_mpos.y = event.scr_mpos.y - currentwin->y; if (gui_window_event (currentwin, &event)) return 1; } + else { + event.guiwin_mpos.x = -1; + event.guiwin_mpos.y = -1; + } /* no gui active nor any window is responsible.. */ // d_printf ("no event.."); diff --git a/gui/gui.h b/gui/gui.h index b3acd85..08ed049 100644 --- a/gui/gui.h +++ b/gui/gui.h @@ -157,7 +157,7 @@ struct _GUISoftkeyboard_ { int mode; int enabled; int linepos[2][4]; /* y positions of lines */ - int btnpos[2][7]; /* holds position keys: Left, Right, Shift, Symbols, Space, Del, Close */ + int btnpos[2][8]; /* holds position keys: Left, Right, Shift, Symbols, Space, Del, Close */ iPoint offset; /* screenoffset .. will be set during last draw */ struct image *screen; int last_col; @@ -228,5 +228,5 @@ extern void gui_mainmenu_show (); extern void gui_buttons_show (); extern void gui_config_show (); extern void gpswin_show (); - +extern void wnd_routing_show (); #endif diff --git a/gui/gui_softkeyboard.c b/gui/gui_softkeyboard.c index 4a110c0..3f42cb2 100644 --- a/gui/gui_softkeyboard.c +++ b/gui/gui_softkeyboard.c @@ -1,4 +1,4 @@ -/* $Id: gui_softkeyboard.c,v 1.9 2013/06/17 20:42:58 steffen Exp $ */ +/* $Id: gui_softkeyboard.c,v 1.10 2013/06/18 22:24:21 steffen Exp $ */ /*************************************************************************** * gui_softkeyboard.c * @@ -80,8 +80,8 @@ void gui_softkeyb_show (int enable) { /* 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][7] = { { 2.0, 6.0, 12.0, 20.0, 32.0, 70.0, 80.0 }, - { 6.0, 10.0, 18.0, 30.0, 68.0, 78.0, 98.0 } }; +static float _btnpos[2][8] = { { 2.0, 6.0, 10.0, 16.0, 28.0, 70.0, 80.0, 90.0 }, + { 6.0, 10.0, 16.0, 26.0, 68.0, 80.0, 90.0, 98.0 } }; void gui_softkeyb_getpos (int row, int btnnr, int *x1, int *y1, int *x2, int *y2) { if (row < 3) { @@ -136,7 +136,7 @@ void gui_softkeyb_draw () { } /* draw the last keys */ - for (j = 3, i = 0; i < 7; i++) { + for (j = 3, i = 0; i < 8; 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]); @@ -161,6 +161,9 @@ void gui_softkeyb_draw () { snprintf (c, 16, _("Del")); break; case (6): + snprintf (c, 16, _("Enter")); + break; + case (7): snprintf (c, 16, _("Close")); break; } @@ -202,7 +205,7 @@ int gui_softkeyb_event (GUIEvent *event) { } } - for (i = 0; i < 7; i++) { + for (i = 0; i < 8; 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) { @@ -250,6 +253,15 @@ int gui_softkeyb_event (GUIEvent *event) { return 1; break; case (6): + newevent.key = 0x0d; + newevent.keychar = 0x0; + newevent.event = EGUI_KEYCHAR; + newevent.guiwin_mpos.x = newevent.scr_mpos.x = -1; + newevent.guiwin_mpos.y = newevent.scr_mpos.y = -1; + gui_entry_event (currentwin->focus, &newevent); + return 1; + break; + case (7): softkeyb->enabled = 0; currentwin->screen_changed = 1; draw (); diff --git a/gui/gui_window.c b/gui/gui_window.c index 240aa54..ea5712e 100644 --- a/gui/gui_window.c +++ b/gui/gui_window.c @@ -1,4 +1,4 @@ -/* $Id: gui_window.c,v 1.8 2013/04/03 21:52:27 steffen Exp $ */ +/* $Id: gui_window.c,v 1.9 2013/06/18 22:24:21 steffen Exp $ */ /*************************************************************************** * gui_window.c * @@ -148,5 +148,12 @@ int gui_window_event (GUIWindow *win, GUIEvent *event) { } win->event_called = 0; + + if (event->event == EGUI_MOUSERELEASED || event->event == EGUI_MOUSEPRESSED) { + if (event->guiwin_mpos.x >=0 && event->guiwin_mpos.x < win->w + && event->guiwin_mpos.y >=0 && event->guiwin_mpos.y < win->h) + return 1; + } + return 0; }; diff --git a/main/Makefile b/main/Makefile index 3fcfeec..402e358 100644 --- a/main/Makefile +++ b/main/Makefile @@ -3,7 +3,7 @@ include ../Makefile.rules OBJBASE = favorites.o main.o ifeq "$(GTKVERSION)" "1" -GTK = linux_gps.o gps.o routing.o gui_selectdir.o gui_config.o gui_buttons.o gui_favorites.o gui_mainmenu.o gui_search.o guiw_gpsfile.o +GTK = linux_gps.o gps.o routing.o gui_selectdir.o gui_config.o gui_buttons.o gui_favorites.o gui_mainmenu.o gui_search.o guiw_gpsfile.o wnd_routing.o endif ifeq "$(NCURSESVERSION)" "1" @@ -11,15 +11,15 @@ CURSES = ncurses_main.o endif ifeq "$(WINVERSION)" "1" -WIN = gps.o routing.o gui_buttons.o gui_config.o gui_selectdir.o gui_favorites.o gui_mainmenu.o gui_search.o guiw_gpsfile.o +WIN = gps.o routing.o gui_buttons.o gui_config.o gui_selectdir.o gui_favorites.o gui_mainmenu.o gui_search.o guiw_gpsfile.o wnd_routing.o endif ifeq "$(WINCEVERSION)" "1" -WIN = gps.o routing.o gui_buttons.o gui_config.o gui_favorites.o gui_selectdir.o gui_mainmenu.o gui_search.o guiw_gpsfile.o +WIN = gps.o routing.o gui_buttons.o gui_config.o gui_favorites.o gui_selectdir.o gui_mainmenu.o gui_search.o guiw_gpsfile.o wnd_routing.o endif ifeq "$(SDLGLVERSION)" "1" -SDLGL = linux_gps.o gps.o routing.o gui_config.o gui_buttons.o gui_favorites.o gui_selectdir.o gui_mainmenu.o gui_search.o guiw_gpsfile.o +SDLGL = linux_gps.o gps.o routing.o gui_config.o gui_buttons.o gui_favorites.o gui_selectdir.o gui_mainmenu.o gui_search.o guiw_gpsfile.o wnd_routing.o endif diff --git a/main/gui_mainmenu.c b/main/gui_mainmenu.c index f04ef5e..850f2b0 100644 --- a/main/gui_mainmenu.c +++ b/main/gui_mainmenu.c @@ -1,4 +1,4 @@ -/* $Id: gui_mainmenu.c,v 1.11 2013/05/29 14:08:41 steffen Exp $ */ +/* $Id: gui_mainmenu.c,v 1.13 2013/06/18 22:25:57 steffen Exp $ */ /*************************************************************************** * gui_mainmenu.c * @@ -105,6 +105,8 @@ void gui_mainmenu_close () { void gui_mainmenu_routing () { + gui_close (); + wnd_routing_show (); }; diff --git a/main/wnd_routing.c b/main/wnd_routing.c new file mode 100644 index 0000000..d7a5f3f --- /dev/null +++ b/main/wnd_routing.c @@ -0,0 +1,38 @@ +/* $Id: wnd_routing.c,v 1.2 2013/06/18 22:26:16 steffen Exp $ */ +/*************************************************************************** + * wnd_routing.c + * + * Created on: 18.06.2013 + * Copyright (C) 2011 Steffen Pohle + * steffen@gulpe.de + ****************************************************************************/ + +/* + * 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" + +static GUIWindow wrouting = {0}; + +void wnd_routing_show () { + if (wrouting.screen == NULL) gui_window_new (&wrouting, 220, 260, _("Routing..")); + wrouting.screen_changed = 1; + wrouting.style = WGUI_S_VCENTER | WGUI_S_HCENTER; + + gui_show (&wrouting); +};