working on the gui..

master
steffen 13 years ago
parent c8eb9d6e0c
commit e752a97d6d

@ -159,6 +159,7 @@ clean:
for i in $(WINCEDIRS); do make -C $$i clean; done
for i in $(SDLGLDIRS); do make -C $$i clean; done
for i in $(ANDROIDDIRS); do rm -f android/jni/$$i; done
rm -rf android/assets
cd android; make clean; cd ..
rm -rf Makefile.rules

@ -76,11 +76,12 @@ LOCAL_SRC_FILES := \
mapsys/map_area.c mapsys/map_hash.c mapsys/map_nodepois.c \
mapsys/map_webload.c mapsys/map_searchhash.c\
mapsys/map.c mapsys/map_loadsave.c mapsys/map_way.c \
gui/gui.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 \
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 \
main/gui_search.c main/linux_gps.c
main/gui_search.c main/gui_config.c main/gui_selectdir.c main/linux_gps.c
# LOCAL_LDLIBS := -shared -llog -landroid -lEGL -lGLESv1_CM -lz
LOCAL_LDLIBS := -shared -llog -landroid -lEGL -lGLESv2 -lz
LOCAL_STATIC_LIBRARIES := android_native_app_glue zlib png freetype2-static

@ -63,6 +63,7 @@ void config_init () {
cfg.last_scale = 0.001;
cfg.last_lon = 11.183;
cfg.last_lat = 48.736;
cfg.softkeyboard = 1;
/* Android version will not need config and log path.. */
#if defined(ANDROID)
@ -194,6 +195,9 @@ void config_load () {
if (!strcmp (keyword, "debug")) {
cfg.debug = atoi (value);
}
if (!strcmp (keyword, "softkeyboard")) {
cfg.softkeyboard = atoi (value);
}
#endif
}
fclose (f);
@ -230,6 +234,7 @@ void config_save () {
fprintf (f, "gps_flags=%d\n", cfg.gps_flags);
fprintf (f, "gps_device=%s\n", cfg.gps_device);
fprintf (f, "debug=%d\n", cfg.debug);
fprintf (f, "softkeyboard=%d\n", cfg.softkeyboard);
#endif
fclose (f);
}

@ -6,7 +6,8 @@ OBJ = gui.o \
gui_list.o \
gui_entry.o \
gui_label.o \
gui_image.o
gui_image.o \
gui_softkeyboard.o
SRC = $(OBJ:%.o=%.c)

@ -1,4 +1,4 @@
/* $Id: gui.c,v 1.16 2013/03/01 19:56:56 steffen Exp $ */
/* $Id: gui.c,v 1.17 2013/03/06 23:27:25 steffen Exp $ */
/***************************************************************************
* gui.c
*
@ -212,6 +212,7 @@ void gui_event_addmousepos (GUIEvent *event, iPoint pos, int neg) {
void gui_set_focus (GUIItem *item) {
if (item == NULL || item->type != GUI_ENTRY) gui_softkeyb_show (FALSE);
currentwin->focus = item;
currentwin->screen_changed = 1;
};

@ -129,11 +129,31 @@ struct _GUIWindow_ {
int h;
int style;
void (*callback_clicked) (int x, int y);
GUIItem *items[GUI_MAX_ITEM];
GUIItem *focus;
} typedef GUIWindow;
#define GUI_SOFTKEYB_X 11
#define GUI_SOFTKEYB_Y 3
enum {
GUI_SOFTKEYB_MODE_NORM = 0,
GUI_SOFTKEYB_MODE_SHIFT,
GUI_SOFTKEYB_MODE_SYMBOL,
GUI_SOFTKEYB_MODE_MAX
};
struct _GUISoftkeyboard_ {
int mode;
int enabled;
struct image *screen;
char keys[GUI_SOFTKEYB_MODE_MAX][GUI_SOFTKEYB_Y][GUI_SOFTKEYB_X];
} typedef GUISoftkeyboard;
extern GUIWindow *currentwin;
extern GUISoftkeyboard *softkeyb;
extern void gui_show (GUIWindow *win);
extern void gui_draw ();
@ -146,6 +166,10 @@ extern void gui_window_new (GUIWindow *win, int w, int h, char *title);
extern void gui_window_close (GUIWindow *win);
extern void gui_window_item_add (GUIWindow *win, GUIItem *item);
/* softkeyboard functions. */
void gui_softkeyb_show (int enable);
/* button functions */
#define GUI_BUTTON_T(_item_) ((GUIButton*)(_item_)->data)
extern void gui_button_draw (GUIItem *item);

@ -1,4 +1,4 @@
/* $Id: gui_button.c,v 1.6 2013/02/27 22:21:35 steffen Exp $ */
/* $Id: gui_button.c,v 1.7 2013/03/06 23:27:25 steffen Exp $ */
/***************************************************************************
* gui_button.c
*
@ -88,6 +88,7 @@ void gui_button_event (GUIItem *item, GUIEvent *event) {
button = (GUIButton *) item->data;
if (button->callback_clicked != NULL && event->event == EGUI_MOUSEPRESSED) {
gui_set_focus (item);
button->callback_clicked (event->mousepos.x-item->x, event->mousepos.y-item->y);
}
};

@ -1,4 +1,4 @@
/* $Id: gui_entry.c,v 1.9 2013/03/01 19:56:56 steffen Exp $ */
/* $Id: gui_entry.c,v 1.10 2013/03/06 23:27:25 steffen Exp $ */
/***************************************************************************
* gui_entry.c
*
@ -79,7 +79,10 @@ void gui_entry_event (GUIItem *item, GUIEvent *event) {
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) gui_set_focus (item);
if (event->event == EGUI_MOUSERELEASED) {
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);

@ -1,4 +1,4 @@
/* $Id: gui_list.c,v 1.5 2013/02/27 22:21:35 steffen Exp $ */
/* $Id: gui_list.c,v 1.6 2013/03/06 23:27:25 steffen Exp $ */
/***************************************************************************
* gui_list.c
*
@ -90,8 +90,8 @@ void gui_list_event (GUIItem *item, GUIEvent *event) {
else list = (GUIList *) item->data;
/* set focus */
if (event->event == EGUI_MOUSERELEASED && x >= 0 && x <= item->w && y >= 0 && y <= item->h) {
currentwin->focus = (void *) item;
if (event->event == EGUI_MOUSERELEASED) {
gui_set_focus (item);
if (y <= 5 && x >= item->w - 10) list->vs--;
else if (y >= item->h - 5 && x >= item->w - 10) list->vs++;

@ -0,0 +1,78 @@
/* $Id: gui_softkeyboard.c,v 1.1 2013/03/06 23:28:15 steffen Exp $ */
/***************************************************************************
* gui_softkeyboard.c
*
* Copyright (C) 2013 Steffen Pohle
* steffen@gulpe.de
***************************************************************************
* softkeyboard: self written softkeyboard.
***************************************************************************/
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "osmroute.h"
#include "draw.h"
#include "gui.h"
#include "system.h"
GUISoftkeyboard *softkeyb = NULL;
void gui_softkeyb_show (int enable) {
/* keys which are displayed.. */
char line[GUI_SOFTKEYB_MODE_MAX][GUI_SOFTKEYB_X][GUI_SOFTKEYB_X] = {
{ "qwertzuiop?",
"asdfghjkl??",
"yxcvbnm,.-_" },
{ "QWERTZUIOP?",
"ASDFGHIKL??",
"YXCVBNM;:#+" },
{ "0123456789=",
" ",
" " }};
int i, j;
/* disable software keyboard */
if (cfg.softkeyboard == 0 || enable == 0) {
if (softkeyb) softkeyb->enabled = FALSE;
return;
}
/* check for allocation.. */
if (softkeyb == NULL) {
softkeyb = (GUISoftkeyboard*) ml_malloc (sizeof (GUISoftkeyboard));
memset (softkeyb, 0x0, sizeof (GUISoftkeyboard));
}
/* reset data */
for (i = 0; i < GUI_SOFTKEYB_MODE_MAX; i++) for (j = 0; j < 3; j++)
strncpy (softkeyb->keys[i][j], line[i][j], GUI_SOFTKEYB_X);
softkeyb->enabled = TRUE;
softkeyb->mode = GUI_SOFTKEYB_MODE_NORM;
};
/* only preparing the screen image... copying to the screen will be done later... */
void gui_softkeyb_draw () {
if (softkeyb == NULL || gfx_screensize.x < 0 || softkeyb->enabled == FALSE) return;
if (softkeyb->screen == NULL || softkeyb->screen->width != gfx_screensize.x) {
if (softkeyb->screen) gfx_img_free (softkeyb->screen);
softkeyb->screen = gfx_img_alloc (gfx_screensize.x, gfx_screensize.y * 0.8);
}
gfx_clear (softkeyb->screen, &color[COLOR_white][1]);
};

@ -1,4 +1,4 @@
/* $Id: gui_mainmenu.c,v 1.9 2013/02/27 22:21:35 steffen Exp $ */
/* $Id: gui_mainmenu.c,v 1.10 2013/03/06 23:27:25 steffen Exp $ */
/***************************************************************************
* gui_mainmenu.c
*
@ -59,8 +59,8 @@ void gui_mainmenu_show () {
}
gui_window_item_add (&wmmenu, mbtn_refresh);
if (mbtn_refreshidx == NULL) {
mbtn_refreshidx = gui_button_new (_("Update Index"), 105, 30, 90, 20);
if (mbtn_refreshidx == NULL) {
GUI_BUTTON_T(mbtn_refreshidx)->callback_clicked = (void*)gui_mainmenu_refreshidx;
}
gui_window_item_add (&wmmenu, mbtn_refreshidx);

@ -121,6 +121,9 @@ struct cfgdata {
float last_lon;
float last_lat;
float last_scale;
int softkeyboard;
int debug;
};

Loading…
Cancel
Save