Compare commits

..

1 Commits

Author SHA1 Message Date
steffen 3fcded144a initial import
13 years ago

@ -1,85 +1,6 @@
Version 0.0.2: name changed to spOSMroute, since on there had been another Version 0.0.2: name changed to spOSMroute, since on there had been another
OSMroute already. OSMroute already.
============================================================================= =============================================================================
(2014-02-27):
- fixed: progressbar is back working again.
- fixed: during start up the draw_setscalef function wasn't called.
- got all systems back working again: Windows, WindowsCE, SDLGL, Android
and GTK
(2014-02-12):
- fixed: quiting while in routing did not work.
- fixed: gui_list elements where almost unable use.
(2014-02-05):
- fixed: windowsCE version is running again.
- fixed: pressing the button long time did not work.
(2014-01-20):
- fixed: disabled screensaver on Android
(2013-08-28):
- fixed: some search messages created a crash on 32bit systems.
- fixed: saving of last position works now from inside the main menu.
(2013-08-01):
- moving around the map works better.
(2013-07-23):
- added map_way_append_to_hash and map_area_append_to_hash to speedup
map_hash_realloc, which took most almost 30% of all time.
(2013-07-19):
- speeding up converting process.
(2013-06-17):
- fixed: softkeyboard is working now with utf8.
(2013-06-16):
- fixed: searching for citys is back working again and this time it seems
working fine.
(2013-06-09):
- fixed: utf8 will now also work in gui entry, delete and cursor movement
is also working now.
- fixed: changing map data location is working fine.
- fixed: on reloading the map, no need to change scale to draw the map.
(2013-06-06):
- fixed: utf8 will be displayed on OpenGL and OpenGLES devices correctly.
(2013-05-28):
- fixed: on android devices gps seems to work now fine.
(2013-05-15):
- fixed: areas will be split into peaces if there is an angle above 180°.
needed for displaying on GLES supported devices..
(2013-05-02):
- fixed: ncurses version fixed, the last patches made it impossible to
compile.
- fixed: areas haven't been updated right.
- added: areas have subid now.
- changed: saving subid within the id by shifting bits to the left.
saving 2 bytes each way.
- fixed: areas get split into different parts on each inside angle above 180°
should fix displaying issues on opengl and opengles devices.
(2013-03-11):
- rewrote most parts of the gui handling.
- added software keyboard.
- added config screen (config map, gps device, softkeyboard, debug).
(2013-02-14): (2013-02-14):
- android: changed to GLES2.0. Offscreen rendering works fine. Enabled - android: changed to GLES2.0. Offscreen rendering works fine. Enabled
gui on android. gui on android.

@ -20,7 +20,7 @@ sposmedit:
do if ! make -C $$i; then \ do if ! make -C $$i; then \
exit -2; \ exit -2; \
fi done fi done
$(CC) -o sposmedit -lm -lmain -lncurses -lmapsys -lbase -lmain -Lbase -Lmapsys -Lmain `pkg-config --libs libxml-2.0` -lbz2 -lm -ggdb -pg $(DEBUG) $(CC) -o sposmedit -lmain -lncurses -lmapsys -lbase -lmain -Lbase -Lmapsys -Lmain `pkg-config --libs libxml-2.0` -lbz2 -ggdb -pg $(DEBUG)
cleanapp: cleanapp:
rm -rf sposmedit rm -rf sposmedit
@ -39,7 +39,7 @@ sposmroutegl:
do if ! make -C $$i; then \ do if ! make -C $$i; then \
exit -2; \ exit -2; \
fi done fi done
$(CC) -o sposmroute -lsdlgl -lm -lmain -lgui -lmain -lmapsys -ldraw -lsdlgl -lbase -lmain -Lbase -Lmain -Lsdlgl -Ldraw -Lgui -Lmapsys -lbz2 $(DEBUG) -lm `sdl-config --libs` `pkg-config --libs freetype2 libpng` -lm -lGL -lGLU -L/usr/X11R6/lib -L/usr/lib $(CC) -o sposmroute -lsdlgl -lmain -lgui -lmain -lmapsys -ldraw -lsdlgl -lbase -Lbase -Lmain -Lsdlgl -Ldraw -Lgui -Lmapsys -lbz2 $(DEBUG) `sdl-config --libs` `pkg-config --libs freetype2 libpng` -lGL -lGLU -L/usr/X11R6/lib -L/usr/lib
cleanapp: cleanapp:
rm -rf sposmroutegl rm -rf sposmroutegl
endif endif
@ -56,7 +56,7 @@ sposmroute:
do if ! make -C $$i; then \ do if ! make -C $$i; then \
exit -2; \ exit -2; \
fi done fi done
$(CC) -o sposmroute -lgtk -lmapsys -lgui -ldraw -lmain -lbase -lgui -Lbase -Lmain -Lgtk -Ldraw -Lgui -Lmapsys `pkg-config --libs gtk+-3.0 gmodule-export-2.0 libxml-2.0` -lbz2 -lm $(DEBUG) $(CC) -o sposmroute -lgtk -lmapsys -lgui -ldraw -lmain -lbase -Lbase -Lmain -Lgtk -Ldraw -Lgui -Lmapsys `pkg-config --libs gtk+-2.0 libxml-2.0` -lbz2 $(DEBUG)
cleanapp: cleanapp:
rm -rf sposmroute rm -rf sposmroute
@ -95,8 +95,7 @@ sposmroutece.exe:
do if ! make -C $$i; then \ do if ! make -C $$i; then \
exit -2; \ exit -2; \
fi done fi done
$(CC) -o sposmroutece.exe wince/wince.rsc `for i in \`make -sf wince/Makefile displayobj\`; do echo wince/$$i; done` -ldraw -lmapsys -lgui -lmain -lbase -Lbase -Lmain -Ldraw -Lgui -Lmapsys -Lwince $(LIBS) $(DEBUG) $(CC) -o sposmroutece.exe wince/wince.rsc -lwince -lmapsys -ldraw -lbase -lgui -lmain -Lbase -Lmain -Ldraw -Lgui -Lmapsys -Lwince $(LIBS) $(DEBUG)
# $(CC) -o sposmroutece.exe wince/wince.rsc -lwince -lmapsys -ldraw -lbase -lgui -lmain -Lbase -Lmain -Ldraw -Lgui -Lmapsys -Lwince $(LIBS) $(DEBUG)
cleanapp: cleanapp:
rm -rf sposmroutece.exe rm -rf sposmroutece.exe
@ -116,6 +115,7 @@ endif
help: help:
echo "no configuration found yet, please run" echo "no configuration found yet, please run"
echo " make configwin to configure windows version" echo " make configwin to configure windows version"
@ -127,9 +127,6 @@ help:
configandroid: clean configandroid: clean
cp -f Makefile.rules.android Makefile.rules cp -f Makefile.rules.android Makefile.rules
mkdir android/assets
cp -f data/*.ttf android/assets
cp -f data/*.png android/assets
for i in $(ANDROIDDIRS); do ln -s ../../$$i android/jni/ ; done for i in $(ANDROIDDIRS); do ln -s ../../$$i android/jni/ ; done
configwin: clean configwin: clean
@ -157,9 +154,7 @@ clean:
for i in $(NCURSESDIRS); do make -C $$i clean; done for i in $(NCURSESDIRS); do make -C $$i clean; done
for i in $(GTKDIRS); do make -C $$i clean; done for i in $(GTKDIRS); do make -C $$i clean; done
for i in $(WINCEDIRS); do make -C $$i clean; done 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 for i in $(ANDROIDDIRS); do rm -f android/jni/$$i; done
rm -rf android/assets
cd android; make clean; cd .. cd android; make clean; cd ..
rm -rf Makefile.rules rm -rf Makefile.rules
@ -170,7 +165,6 @@ cleanall:
for i in $(WINCEDIRS); do make -C $$i clean; done for i in $(WINCEDIRS); do make -C $$i clean; done
for i in $(SDLGLDIRS); 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 for i in $(ANDROIDDIRS); do rm -f android/jni/$$i; done
rm -rf android/assets
cd android; make clean; cd .. cd android; make clean; cd ..
rm -rf sposmroute rm -rf sposmroute
rm -rf sposmroutegl rm -rf sposmroutegl

@ -6,7 +6,7 @@ DEPENDFILE = .depend
DEBUG = -ggdb -pg DEBUG = -ggdb -pg
AR = /usr/bin/ar AR = /usr/bin/ar
CC = /usr/bin/gcc CC = /usr/bin/gcc
CFLAGS = -Wall -g -I../main -I../ -I../mapsys -I../gui -I../gtk -I../wince -I../draw -I../base -DSPOSMROUTE -DHAVE_LOCALE_H -DHAVE_GTK `pkg-config --cflags libxml-2.0 gtk+-3.0 gmodule-export-2.0` $(DEBUG) -Wl,--export-dynamic CFLAGS = -Wall -g -I../main -I../ -I../mapsys -I../gui -I../gtk -I../wince -I../draw -I../base -DSPOSMROUTE -DHAVE_LOCALE_H -DHAVE_GTK `pkg-config --cflags libxml-2.0 gtk+-2.0` $(DEBUG) -Wl,--export-dynamic
%.o: %.c %.o: %.c
$(CC) $(CFLAGS) -c $< $(CC) $(CFLAGS) -c $<

@ -5,8 +5,7 @@ DEPENDFILE = .depend
DEBUG = -ggdb DEBUG = -ggdb
AR = i586-mingw32msvc-ar AR = i586-mingw32msvc-ar
CC = i586-mingw32msvc-gcc CC = i586-mingw32msvc-gcc
# CFLAGS = -Wall -I../main -I../ -I../mapsys -I../gui -I../wince -I../draw -I../base -DSPOSMROUTE -DHAVE_WINAPI -D_WIN32_IE=0x400 $(DEBUG) CFLAGS = -Wall -I../main -I../ -I../mapsys -I../gui -I../wince -I../draw -I../base -DSPOSMROUTE -DHAVE_WINAPI -D_WIN32_IE=0x400 $(DEBUG)
CFLAGS = -Wall -I../main -I../ -I../mapsys -I../gui -I../wince -I../draw -I../base -DSPOSMROUTE -DHAVE_WINAPI $(DEBUG)
WINRES = i586-mingw32msvc-windres WINRES = i586-mingw32msvc-windres
LIBS = -lgdi32 -lcomdlg32 -lwsock32 LIBS = -lgdi32 -lcomdlg32 -lwsock32

@ -3,10 +3,10 @@
WINCEVERSION = 1 WINCEVERSION = 1
DEPENDFILE = .depend DEPENDFILE = .depend
DEBUG = -ggdb DEBUG = -ggdb
AR = arm-mingw32ce-ar AR = /opt/mingw32ce/bin/arm-mingw32ce-ar
CC = arm-mingw32ce-gcc CC = /opt/mingw32ce/bin/arm-mingw32ce-gcc
CFLAGS = -Wall -g -I../main -I../ -I../mapsys -I../gui -I../wince -I../draw -I../base -DSPOSMROUTE -DHAVE_WINAPI -D_WIN32_IE=0x400 $(DEBUG) CFLAGS = -Wall -g -I../main -I../ -I../mapsys -I../gui -I../wince -I../draw -I../base -DSPOSMROUTE -DHAVE_WINAPI -D_WIN32_IE=0x400 $(DEBUG)
WINRES = arm-mingw32ce-windres WINRES = /opt/mingw32ce/bin/arm-mingw32ce-windres
LIBS = -lcommctrl -laygshell -lws2 LIBS = -lcommctrl -laygshell -lws2
%.o: %.c %.o: %.c

@ -9,11 +9,11 @@
<uses-sdk android:minSdkVersion="9" /> <uses-sdk android:minSdkVersion="9" />
<!-- This .apk has no Java code itself, so set hasCode to false. --> <!-- This .apk has no Java code itself, so set hasCode to false. -->
<application android:label="@string/app_name" android:hasCode="true" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> <application android:label="@string/app_name" android:hasCode="false" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<!-- Our activity is the built-in NativeActivity framework class. <!-- Our activity is the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. --> This will take care of integrating with our NDK code. -->
<activity android:name="de.gulpe.sposmroute.spOSMrNActivity" <activity android:name="android.app.NativeActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden"> android:configChanges="orientation|keyboardHidden">
<!-- Tell NativeActivity the name of or .so --> <!-- Tell NativeActivity the name of or .so -->
@ -26,10 +26,10 @@
</activity> </activity>
</application> </application>
<uses-feature android:glEsVersion="0x00020000" /> <uses-feature android:glEsVersion="0x00020000" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> </uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> </uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest> </manifest>
<!-- END_INCLUDE(manifest) --> <!-- END_INCLUDE(manifest) -->

@ -34,7 +34,7 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS) include $(CLEAR_VARS)
FREETYPE_SRC_PATH := freetype2/ FREETYPE_SRC_PATH := freetype2/
LOCAL_MODULE := freetype2-static LOCAL_MODULE := freetype2-static
LOCAL_CFLAGS := -DANDROID_NDK -DFT2_BUILD_LIBRARY=1 -DSPOSMROUTE LOCAL_CFLAGS := -DANDROID_NDK -DFT2_BUILD_LIBRARY=1
LOCAL_C_INCLUDES := \ LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/$(FREETYPE_SRC_PATH)/include \ $(LOCAL_PATH)/$(FREETYPE_SRC_PATH)/include \
$(LOCAL_PATH)/$(FREETYPE_SRC_PATH)/src $(LOCAL_PATH)/$(FREETYPE_SRC_PATH)/src
@ -72,18 +72,15 @@ LOCAL_CFLAGS := -DANDROID -DSPOSMROUTE -I$(LOCAL_PATH)/base -I$(LOCAL_PATH)/gui
-I$(LOCAL_PATH)/freetype2/include -I$(LOCAL_PATH)/freetype2/include
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
main.c android_gfx.c android_font.c \ main.c android_gfx.c android_font.c \
base/config.c base/memoryleak.c base/system.c base/vector.c base/utf8.c \ base/config.c base/memoryleak.c base/system.c base/vector.c \
mapsys/map_area.c mapsys/map_hash.c mapsys/map_nodepois.c \ mapsys/map_area.c mapsys/map_hash.c mapsys/map_nodepois.c \
mapsys/map_webload.c mapsys/map_searchhash.c\ mapsys/map_webload.c mapsys/map_searchhash.c\
mapsys/map.c mapsys/map_loadsave.c mapsys/map_way.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.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 \ 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/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/main.c main/routing.c main/gps.c main/gui_favorites.c \
main/gui_search.c main/gui_config.c main/gui_selectdir.c main/gui_selectfile.c \ main/gui_search.c main/linux_gps.c
main/linux_gps.c main/wnd_routing.c main/wnd_mapcontext.c
# LOCAL_LDLIBS := -shared -llog -landroid -lEGL -lGLESv1_CM -lz # LOCAL_LDLIBS := -shared -llog -landroid -lEGL -lGLESv1_CM -lz
LOCAL_LDLIBS := -shared -llog -landroid -lEGL -lGLESv2 -lz LOCAL_LDLIBS := -shared -llog -landroid -lEGL -lGLESv2 -lz
LOCAL_STATIC_LIBRARIES := android_native_app_glue zlib png freetype2-static LOCAL_STATIC_LIBRARIES := android_native_app_glue zlib png freetype2-static

@ -4,7 +4,6 @@
#include "osmroute.h" #include "osmroute.h"
#include "system.h" #include "system.h"
#include "utf8.h"
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
@ -59,7 +58,6 @@ struct font* font_load(char *fname) {
FT_Set_Pixel_Sizes(f->face, 0, 16); FT_Set_Pixel_Sizes(f->face, 0, 16);
d_printf ("font loaded (size:%d).", f->buffersize); d_printf ("font loaded (size:%d).", f->buffersize);
FT_Select_Charmap(f->face, FT_ENCODING_UNICODE);
return f; return f;
} }
@ -71,7 +69,6 @@ struct font* font_load(char *fname) {
void font_draw (struct font *f, char *text, float x, float y, float sx, float sy) { void font_draw (struct font *f, char *text, float x, float y, float sx, float sy) {
char *p; char *p;
int i; int i;
uint32_t u8chr;
GLfloat vp[12] = { 0.0, 0.0, 0.0, GLfloat vp[12] = { 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
@ -102,16 +99,10 @@ void font_draw (struct font *f, char *text, float x, float y, float sx, float sy
glUniform1i(engine.gles_txsampler, 0); glUniform1i(engine.gles_txsampler, 0);
/* Loop through all characters */ /* Loop through all characters */
for (p = text; *p;) { for (p = text; *p; p++) {
u8chr = u8_decode (p, &i);
if (i == 0) {
p++;
continue;
}
p = p + i;
/* Try to load and render the character */ /* Try to load and render the character */
if ((i = FT_Load_Char(f->face, u8chr, FT_LOAD_RENDER))) { if ((i = FT_Load_Char(f->face, *p, FT_LOAD_RENDER))) {
d_printf ("error:%d", i); d_printf ("error:%d", i);
continue; continue;
} }
@ -130,8 +121,8 @@ void font_draw (struct font *f, char *text, float x, float y, float sx, float sy
glVertexAttribPointer (engine.gles_txcoord, 2, GL_FLOAT, GL_FALSE, 0, vt); glVertexAttribPointer (engine.gles_txcoord, 2, GL_FLOAT, GL_FALSE, 0, vt);
glDrawArrays(GL_TRIANGLE_FAN,0,4); glDrawArrays(GL_TRIANGLE_FAN,0,4);
// glVertexAttribPointer (engine.gles_pos, 3, GL_FLOAT, GL_FALSE, 0, vp); glVertexAttribPointer (engine.gles_pos, 3, GL_FLOAT, GL_FALSE, 0, vp);
// glDrawArrays(GL_LINES,0,2); glDrawArrays(GL_LINES,0,2);
/* Advance the cursor to the start of the next character */ /* Advance the cursor to the start of the next character */

@ -239,7 +239,7 @@ void gfx_draw_line (struct image *dimg, int x1, int y1, int x2, int y2, struct l
/* /*
* draw polygon * 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) {
static GLfloat *polygon = NULL; static GLfloat *polygon = NULL;
static int polygon_cnt = 0; static int polygon_cnt = 0;
int i; int i;
@ -262,19 +262,9 @@ void gfx_draw_polygon (struct image *dimg, iPoint *p, int pcnt, struct line_styl
glUseProgram (engine.gles_prgobject); glUseProgram (engine.gles_prgobject);
glUniform1i (engine.gles_txenabled, 0); glUniform1i (engine.gles_txenabled, 0);
glUniform4fv(engine.gles_color, 1, c->c.array); glUniform4fv(engine.gles_color, 1, c.c.array);
glVertexAttribPointer (engine.gles_pos, 3, GL_FLOAT, GL_FALSE, 0, polygon); glVertexAttribPointer (engine.gles_pos, 3, GL_FLOAT, GL_FALSE, 0, polygon);
glDrawArrays (GL_TRIANGLE_FAN, 0, pcnt); glDrawArrays (GL_TRIANGLE_FAN, 0, pcnt);
// if (style.width < 1.0) style.width = 1.0;
// glLineWidth (style.width);
//
// glUseProgram (engine.gles_prgobject);
// glUniform1i (engine.gles_txenabled, 0);
// glUniform4fv(engine.gles_color, 1, style.c.c.array);
// glVertexAttribPointer (engine.gles_pos, 3, GL_FLOAT, GL_FALSE, 0, polygon);
// glDrawArrays (GL_LINE_LOOP, 0, pcnt);
}; };
@ -566,8 +556,3 @@ struct image* gfx_img_load (char *name) {
return img; return img;
}; };
/******************************************************************
* convert polygon into triangles..
*/

@ -17,13 +17,14 @@
#include <jni.h> #include <jni.h>
#include <errno.h> #include <errno.h>
#include <EGL/egl.h> #include <EGL/egl.h>
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <android/sensor.h> #include <android/sensor.h>
#include <android/log.h> #include <android/log.h>
#include <android_native_app_glue.h> #include <android_native_app_glue.h>
#include "android_port.h"
#include "osmroute.h" #include "osmroute.h"
#include "gui.h" #include "gui.h"
#include "system.h" #include "system.h"
@ -31,16 +32,79 @@
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sposmroute", __VA_ARGS__)) #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sposmroute", __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "sposmroute", __VA_ARGS__)) #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "sposmroute", __VA_ARGS__))
#define MAX_EVENTS 128
GUIEvent eventlist[MAX_EVENTS] = {0};
int eventcnt = 0;
int gevent_push (GUIEvent *event);
int gevent_pop (GUIEvent *event);
void gevent_clear ();
struct engine engine; struct engine engine;
/*************************************************************************
*
* only needed for testing
*
*************************************************************************/
struct image *img, *img1;
void test_img () {
struct line_style style;
d_printf ("*** test_img () ***");
style.width = 1;
style.c = color[COLOR_green][3];
img = gfx_img_alloc (400, 300);
gfx_clear (img, &color[COLOR_blue][2]);
img1 = gfx_img_load ("sample_01.png");
gfx_draw_img (img, 10, 10, 150, 150, img1, 100, 250);
gfx_draw_text (img, 20, 10, "sample_01.png nur ein toller test bla bla", &color[COLOR_yellow][3]);
gfx_draw_text (img, 20, 30, "sample_01.png nur ein toller test bla bla", &color[COLOR_yellow][3]);
gfx_draw_text (NULL, 20, 10, "sample_01.png nur ein toller test bla bla", &color[COLOR_yellow][3]);
gfx_draw_text (NULL, 20, 30, "sample_01.png nur ein toller test bla bla", &color[COLOR_yellow][3]);
gfx_draw_line (img, 0, 0, 200, 200, style);
};
#define TEST_WIDTH 200
void test_draw () {
static int once = 1;
static int _tmpx, _tmpy = 0;
static int _tmpdx = 1, _tmpdy = 1;
struct line_style style;
GLfloat vp[] = {500, 210, 540, 210};
gfx_clear (NULL, &color[COLOR_white][0]);
if (once) {
once = 0;
test_img ();
}
if (_tmpx > img->width-TEST_WIDTH) _tmpdx = -1;
if (_tmpx < 0) _tmpdx = 1;
_tmpx += _tmpdx;
if (_tmpy > img->height-TEST_WIDTH) _tmpdy = -1;
if (_tmpy < 0) _tmpdy = 1;
_tmpy += _tmpdy;
style.width = 1;
style.c = color[COLOR_white][3];
gfx_draw_line (NULL, 0, gfx_screensize.y, gfx_screensize.x, 0, style);
gfx_draw_line (NULL, gfx_screensize.x, gfx_screensize.y, 0, 0, style);
glLineWidth (style.width);
gfx_draw_img (NULL, 10, 10, TEST_WIDTH, TEST_WIDTH, img, _tmpx, _tmpy);
style.c = color[COLOR_yellow][3];
gfx_draw_line (NULL, gfx_screensize.x, 0, 0, 10, style);
gfx_draw_text (NULL, 10, 300, "sollte gehen", &color[COLOR_red][3]);
gfx_draw_img (NULL, 20, 320, 150, 150, img1, 200, 200);
gfx_flip();
};
/** /**
* Initialize an EGL context for the current display. * Initialize an EGL context for the current display.
*/ */
@ -99,6 +163,7 @@ static int engine_init_display(struct engine* engine) {
engine->width = w; engine->width = w;
engine->height = h; engine->height = h;
engine->state.angle = 0; engine->state.angle = 0;
gfx_init (w, h); gfx_init (w, h);
return 0; return 0;
} }
@ -126,7 +191,6 @@ static void engine_term_display(struct engine* engine) {
/** /**
* Process the next input event. * Process the next input event.
* save events inside a EVENT list.
*/ */
static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) { static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) {
GUIEvent gevent; GUIEvent gevent;
@ -135,26 +199,27 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
struct engine* engine = (struct engine*)app->userData; struct engine* engine = (struct engine*)app->userData;
if (type == AINPUT_EVENT_TYPE_MOTION) { if (type == AINPUT_EVENT_TYPE_MOTION) {
int32_t subtype = AMotionEvent_getAction (event); int32_t subtype = AMotionEvent_getAction (event);
gevent.scr_mpos.x = AMotionEvent_getX(event, 0); gevent.mousepos.x = AMotionEvent_getX(event, 0);
gevent.scr_mpos.y = AMotionEvent_getY(event, 0); gevent.mousepos.y = AMotionEvent_getY(event, 0);
if (subtype == AMOTION_EVENT_ACTION_MOVE) { if (subtype == AMOTION_EVENT_ACTION_MOVE) {
gevent.event = EGUI_MOUSEMOVE; gevent.event = EGUI_MOUSEMOVE;
gevent_push (&gevent);
if (gui_event (gevent) == 0) draw_mousemove (gevent.mousepos.x, gevent.mousepos.y, 0);
return 1; return 1;
} }
else if (subtype == AMOTION_EVENT_ACTION_UP) { else if (subtype == AMOTION_EVENT_ACTION_UP) {
gevent.mousebtn = 1; gevent.mousebtn = 1;
gevent.event = EGUI_MOUSERELEASED; gevent.event = EGUI_MOUSERELEASED;
gevent_push (&gevent); if (gui_event (gevent) == 0) draw_mousebtnup (gevent.mousepos.x, gevent.mousepos.y, 1);
return 1; return;
} }
else if (subtype == AMOTION_EVENT_ACTION_DOWN) { else if (subtype == AMOTION_EVENT_ACTION_DOWN) {
char *tmp; char *tmp;
gevent.mousebtn = 1; gevent.mousebtn = 1;
gevent.event = EGUI_MOUSEPRESSED; gevent.event = EGUI_MOUSEPRESSED;
gevent_push (&gevent); if (gui_event (gevent) == 0) draw_mousebtndown (gevent.mousepos.x, gevent.mousepos.y, 1);
return 1; return;
} }
} }
@ -232,56 +297,6 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
} }
} }
void main_event () {
// Read all pending events.
time_t t1 = time(NULL), t2 = time(NULL);
struct gps_data *gpspos;
int ident;
int events;
int t = 0;
GUIEvent event;
struct android_poll_source* source;
// If not animating, we will block forever waiting for events.
// If animating, we loop until all events are read, then continue
// to draw the next frame of animation.
while ((ident=ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0) {
// Process this event.
if (source != NULL) {
source->process(engine.app, source);
}
// If a sensor has data, process it now.
if (ident == LOOPER_ID_USER) {
if (engine.accelerometerSensor != NULL) {
ASensorEvent event;
while (ASensorEventQueue_getEvents(engine.sensorEventQueue,
&event, 1) > 0) {
// LOGI("accelerometer: x=%f y=%f z=%f",
// event.acceleration.x, event.acceleration.y,
// event.acceleration.z);
}
}
}
// Check if we are exiting.
if (engine.app->destroyRequested != 0) {
engine_term_display(&engine);
return;
}
}
while (gevent_pop(&event)) {
gui_event (event);
}
t1 = time(NULL);
if (t1 != t2) {
t2 = t1;
app_loop ();
}
}
/** /**
* This is the main entry point of a native application that is using * This is the main entry point of a native application that is using
* android_native_app_glue. It runs in its own thread, with its own * android_native_app_glue. It runs in its own thread, with its own
@ -316,129 +331,66 @@ void android_main(struct android_app* state) {
app_init (0, NULL); app_init (0, NULL);
// loop waiting for stuff to do. // loop waiting for stuff to do.
while (app.status != APPSTATUS_quit) { while (1) {
main_event (); // Read all pending events.
int ident;
int events;
struct android_poll_source* source;
// If not animating, we will block forever waiting for events.
// If animating, we loop until all events are read, then continue
// to draw the next frame of animation.
while ((ident=ALooper_pollAll(engine.animating ? 0 : -1, NULL, &events,
(void**)&source)) >= 0) {
// Process this event.
if (source != NULL) {
source->process(state, source);
}
// If a sensor has data, process it now.
if (ident == LOOPER_ID_USER) {
if (engine.accelerometerSensor != NULL) {
ASensorEvent event;
while (ASensorEventQueue_getEvents(engine.sensorEventQueue,
&event, 1) > 0) {
// LOGI("accelerometer: x=%f y=%f z=%f",
// event.acceleration.x, event.acceleration.y,
// event.acceleration.z);
}
}
}
// Check if we are exiting.
if (state->destroyRequested != 0) {
engine_term_display(&engine);
return;
}
}
if (engine.animating) {
// Done with events; draw next animation frame.
engine.state.angle += .01f;
if (engine.state.angle > 1) {
engine.state.angle = 0;
}
// Drawing is throttled to the screen update rate, so there
// is no need to do timing here.
draw();
// test_draw ();
}
} }
d_printf ("shutdown?");
app_shutdown ();
exit (0);
} }
/************************************************************************* /*************************************************************************
* main functions for sposmroute... * main functions for sposmroute...
*/ */
void main_wnd_update () { void main_wnd_loop (long long int cur, long long int max) {
main_event ();
} }
void main_wnd_update () {
/************************************************************************* }
*
* calling java code here for using the internal GPS devices.
*
*************************************************************************/
int gps_android_device_open () {
d_printf ("gps_android_device_open:");
ANativeActivity* activity = engine.app->activity;
JavaVM* jvm = engine.app->activity->vm;
JNIEnv* env = NULL;
(*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_6);
jint res = (*jvm)->AttachCurrentThread(jvm, &env, NULL);
if (res == JNI_ERR) {
// Failed to retrieve JVM environment
d_printf ("gps_android_device_open: JNI_Error");
return 0;
}
jclass clazz = (*env)->GetObjectClass(env, activity->clazz);
jmethodID methodID = (*env)->GetMethodID(env, clazz, "GPSDataStart", "()V");
(*env)->CallVoidMethod(env, activity->clazz, methodID);
(*jvm)->DetachCurrentThread(jvm);
return 1;
};
void gps_android_device_close () {
d_printf ("gps_android_device_close:");
ANativeActivity* activity = engine.app->activity;
JavaVM* jvm = engine.app->activity->vm;
JNIEnv* env = NULL;
(*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_6);
jint res = (*jvm)->AttachCurrentThread(jvm, &env, NULL);
if (res == JNI_ERR) {
// Failed to retrieve JVM environment
d_printf ("gps_android_device_close: JNI_Error");
return;
}
jclass clazz = (*env)->GetObjectClass(env, activity->clazz);
jmethodID methodID = (*env)->GetMethodID(env, clazz, "GPSDataStop", "()V");
(*env)->CallVoidMethod(env, activity->clazz, methodID);
(*jvm)->DetachCurrentThread(jvm);
return;
};
int gps_android_device_read (char *ptr, int ptrsize) {
ANativeActivity* activity = engine.app->activity;
JavaVM* jvm = engine.app->activity->vm;
JNIEnv* env = NULL;
jstring jstr;
const char *str;
d_printf ("gps_android_device_read:");
(*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_6);
jint res = (*jvm)->AttachCurrentThread(jvm, &env, NULL);
if (res == JNI_ERR) {
// Failed to retrieve JVM environment
d_printf ("gps_android_device_read: JNI_Error");
return 0;
}
/* call up the java method to prepare a new line */
jclass clazz = (*env)->GetObjectClass(env, activity->clazz);
jmethodID methodID = (*env)->GetMethodID(env, clazz, "GPSDataGetLine", "()V");
(*env)->CallVoidMethod(env, activity->clazz, methodID);
/* retrieve the new line, copy new line, release new line */
jfieldID fid = (*env)->GetFieldID(env, clazz, "gpsline", "Ljava/lang/String;");
jstr = (*env)->GetObjectField(env, activity->clazz, fid);
str = (*env)->GetStringUTFChars(env, jstr, 0);
if (str != NULL) {
// d_printf ("str:ptrsize:%d strsize:%d '%s'", ptrsize, strlen(str), str);
strncpy (ptr, str, ptrsize);
}
else ptr[0] = 0;
(*env)->ReleaseStringUTFChars(env, jstr, str);
(*jvm)->DetachCurrentThread(jvm);
return strlen (ptr);
};
int gevent_push (GUIEvent *event) {
if (eventcnt < MAX_EVENTS) {
memcpy (&eventlist[eventcnt], event, sizeof (GUIEvent));
eventcnt++;
return 1;
}
return 0;
};
int gevent_pop (GUIEvent *event) {
if (eventcnt > 0) {
eventcnt--;
memcpy (event, &eventlist[eventcnt], sizeof (GUIEvent));
return 1;
}
return 0;
};
void gevent_clear () {
int i;
memset (eventlist, 0x0, MAX_EVENTS * sizeof (GUIEvent));
};

@ -1,85 +0,0 @@
package de.gulpe.sposmroute;
import android.app.NativeActivity;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.content.Context;
import android.location.GpsStatus.NmeaListener;
import android.view.WindowManager;
import android.view.ViewGroup.LayoutParams;
public class spOSMrNActivity extends NativeActivity {
private static final String TAG = "spOSMroute Java";
spOSMrNActivity _activity;
String gpsline;
String nmealine;
boolean started = false;
private LocationManager mLocMan;
private LocationListener mLocListener;
public void onCreate(Bundle savedInstanceState) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
mLocMan = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
mLocListener = new MyLocationListener();
mLocMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mLocListener);
mLocMan.addNmeaListener(new NmeaListener() {
public void onNmeaReceived(long timestamp, String nmea) {
if (started) {
nmealine = nmealine + nmea;
}
// Log.i(TAG, "GPSData (cur nmea:"+nmealine+")");
}
});
super.onCreate(savedInstanceState);
_activity = this;
}
private class MyLocationListener implements LocationListener {
@Override
public void onLocationChanged(Location loc) {
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
}
// get gps data fill one line into gpsline
public void GPSDataGetLine() {
// Log.i(TAG, "GPSDataGetLine called sending:'"+nmealine+"'");
gpsline = nmealine;
nmealine = "";
}
// start gps part
public void GPSDataStart() {
Log.i(TAG, "GPSDataStart called");
started = true;
}
// stop gps part
public void GPSDataStop() {
Log.i(TAG, "GPSDataStop called");
started = false;
}
// Do some cleanup
@Override
public void onDestroy() {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
super.onDestroy();
}
}

@ -3,8 +3,7 @@ include ../Makefile.rules
OBJBASE = config.o \ OBJBASE = config.o \
system.o \ system.o \
vector.o \ vector.o \
memoryleak.o \ memoryleak.o
utf8.o
OBJ = $(OBJBASE) OBJ = $(OBJBASE)
SRC = $(OBJ:%.o=%.c) SRC = $(OBJ:%.o=%.c)

@ -54,7 +54,7 @@ void config_init () {
struct stat sb; struct stat sb;
strcpy (cfg.mappath, "map/"); strcpy (cfg.mappath, "map/");
strcpy (cfg.appdatapath, "data"); strcpy (cfg.appdatapath, "android/assets");
strcpy (cfg.cachepath, "cache/"); strcpy (cfg.cachepath, "cache/");
strcpy (cfg.configpath, ""); strcpy (cfg.configpath, "");
strcpy (cfg.logpath, "logs/"); strcpy (cfg.logpath, "logs/");
@ -63,41 +63,36 @@ void config_init () {
cfg.last_scale = 0.001; cfg.last_scale = 0.001;
cfg.last_lon = 11.183; cfg.last_lon = 11.183;
cfg.last_lat = 48.736; cfg.last_lat = 48.736;
cfg.softkeyboard = 1;
/* Android version will not need config and log path.. */ /* Android version will not need config and log path.. */
#if defined(ANDROID) #if defined(ANDROID)
strcpy (cfg.appdatapath, "android/assets"); if (engine.app->activity->internalDataPath == NULL)
if (engine.app->activity->internalDataPath == NULL) {
strncpy (cfg.configpath, "/data/data/de.gulpe.sposmroute/", LEN_FILENAME); strncpy (cfg.configpath, "/data/data/de.gulpe.sposmroute/", LEN_FILENAME);
strncpy (cfg.logpath, "/data/data/de.gulpe.sposmroute/", LEN_FILENAME); else
}
else {
strncpy (cfg.configpath, engine.app->activity->internalDataPath, LEN_FILENAME); strncpy (cfg.configpath, engine.app->activity->internalDataPath, LEN_FILENAME);
strncpy (cfg.logpath, engine.app->activity->internalDataPath, LEN_FILENAME);
}
/* std::string dataPath(internalPath); /* std::string dataPath(internalPath);
// internalDataPath points directly to the files/ directory // internalDataPath points directly to the files/ directory
std::string configFile = dataPath + "/app_config.xml"; std::string configFile = dataPath + "/app_config.xml";
*/ */
#else #else
/* windows ce version */ /* windows ce version */
#if defined(__MINGW32CE__) || defined(_WIN32_WCE) #if defined(__MINGW32CE__) || defined(_WIN32_WCE)
strcpy (cfg.mappath, "\\Storage Card\\map\\"); strcpy (cfg.mappath, "\\Storage Card\\map\\");
strcpy (cfg.configpath, "\\My Documents\\wOSMroute\\"); strcpy (cfg.configpath, "\\My Documents\\wOSMroute\\");
strcpy (cfg.logpath, "\\My Documents\\wOSMroute\\Logdir\\"); strcpy (cfg.logpath, "\\My Documents\\wOSMroute\\Logdir\\");
#endif #endif
/* windows version */ /* windows version */
#if defined(__MINGW32__) && !defined(__MINGW32CE__) && !defined(_WIN32_WCE) #if defined(__MINGW32__) && !defined(__MINGW32CE__) && !defined(_WIN32_WCE)
TCHAR szPath[MAX_PATH]; TCHAR szPath[MAX_PATH];
if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, NULL, 0, szPath))) { if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, NULL, 0, szPath))) {
snprintf (cfg.configpath, LEN_FILENAME, "%s\\wOSMroute\\", szPath); snprintf (cfg.configpath, LEN_FILENAME, "%s\\wOSMroute\\", szPath);
snprintf (cfg.logpath, LEN_FILENAME, "%s\\wOSMroute\\Logdir\\", szPath); snprintf (cfg.logpath, LEN_FILENAME, "%s\\wOSMroute\\Logdir\\", szPath);
} }
#endif #endif
/* linux version */ /* linux version */
#if !defined(__MINGW32CE__) && !defined(_WIN32_WCE) && !defined(__MINGW32__) #if !defined(__MINGW32CE__) && !defined(_WIN32_WCE) && !defined(__MINGW32__)
char *hd; char *hd;
if ((hd = getenv ("HOME")) == NULL) { if ((hd = getenv ("HOME")) == NULL) {
@ -109,7 +104,7 @@ void config_init () {
snprintf (cfg.configpath, LEN_FILENAME, "%s/.OSMroute/", hd); snprintf (cfg.configpath, LEN_FILENAME, "%s/.OSMroute/", hd);
snprintf (cfg.logpath, LEN_FILENAME, "%s/.OSMroute/Logdir/", hd); snprintf (cfg.logpath, LEN_FILENAME, "%s/.OSMroute/Logdir/", hd);
} }
#endif #endif
d_print_init(); d_print_init();
if (stat(cfg.configpath, &sb) == -1) { if (stat(cfg.configpath, &sb) == -1) {
@ -117,15 +112,12 @@ void config_init () {
strncpy (fn, cfg.configpath, LEN_FILENAME); strncpy (fn, cfg.configpath, LEN_FILENAME);
fn[strlen(fn)-1] = 0; fn[strlen(fn)-1] = 0;
d_printf ("create config dir:%s", fn); d_printf ("create config dir:%s", fn);
#if !defined(__MINGW32CE__) && !defined(_WIN32_WCE) && !defined(__MINGW32__) #if !defined(__MINGW32CE__) && !defined(_WIN32_WCE) && !defined(__MINGW32__)
mkdir (fn, 0755); mkdir (fn, 0755);
#else #else
mkdir (fn); mkdir (fn);
#endif
}
#endif #endif
}
config_load ();
if (stat(cfg.logpath, &sb) == -1) { if (stat(cfg.logpath, &sb) == -1) {
char fn[LEN_FILENAME]; char fn[LEN_FILENAME];
@ -138,28 +130,9 @@ void config_init () {
mkdir (fn); mkdir (fn);
#endif #endif
} }
if (stat(cfg.mappath, &sb) == -1) {
char fn[LEN_FILENAME];
strncpy (fn, cfg.mappath, LEN_FILENAME);
fn[strlen(fn)-1] = 0;
d_printf ("create map dir:%s", fn);
#if !defined(__MINGW32CE__) && !defined(_WIN32_WCE) && !defined(__MINGW32__)
mkdir (fn, 0755);
#else
mkdir (fn);
#endif #endif
} config_load ();
config_save (); config_save ();
#if defined(SPOSMROUTE)
if (cfg.gps_flags) SETFLAG(gpsflags, GPSF_LOG);
else DELFLAG(gpsflags, GPSF_LOG);
if (cfg.debug) SETFLAG(view_flags, DRAW_DEBUG);
else DELFLAG(view_flags, DRAW_DEBUG);
#endif
}; };
@ -203,8 +176,6 @@ void config_load () {
strncpy (cfg.mappath, value, LEN_FILENAME); strncpy (cfg.mappath, value, LEN_FILENAME);
if (!strcmp (keyword, "temppath")) if (!strcmp (keyword, "temppath"))
strncpy (cfg.temppath, value, LEN_FILENAME); strncpy (cfg.temppath, value, LEN_FILENAME);
if (!strcmp (keyword, "cachepath"))
strncpy (cfg.cachepath, value, LEN_FILENAME);
if (!strcmp (keyword, "logpath")) if (!strcmp (keyword, "logpath"))
strncpy (cfg.logpath, value, LEN_FILENAME); strncpy (cfg.logpath, value, LEN_FILENAME);
#if defined(SPOSMROUTE) #if defined(SPOSMROUTE)
@ -222,9 +193,6 @@ void config_load () {
if (!strcmp (keyword, "debug")) { if (!strcmp (keyword, "debug")) {
cfg.debug = atoi (value); cfg.debug = atoi (value);
} }
if (!strcmp (keyword, "softkeyboard")) {
cfg.softkeyboard = atoi (value);
}
#endif #endif
} }
fclose (f); fclose (f);
@ -252,7 +220,6 @@ void config_save () {
fprintf (f, "# config file for osmroute\n\n"); fprintf (f, "# config file for osmroute\n\n");
fprintf (f, "mappath=%s\n", cfg.mappath); fprintf (f, "mappath=%s\n", cfg.mappath);
fprintf (f, "logpath=%s\n", cfg.logpath); fprintf (f, "logpath=%s\n", cfg.logpath);
fprintf (f, "cachepath=%s\n", cfg.cachepath);
fprintf (f, "temppath=%s\n", cfg.temppath); fprintf (f, "temppath=%s\n", cfg.temppath);
#if defined(SPOSMROUTE) #if defined(SPOSMROUTE)
fprintf (f, "last_lon=%f\n", cfg.last_lon); fprintf (f, "last_lon=%f\n", cfg.last_lon);
@ -262,7 +229,6 @@ void config_save () {
fprintf (f, "gps_flags=%d\n", cfg.gps_flags); fprintf (f, "gps_flags=%d\n", cfg.gps_flags);
fprintf (f, "gps_device=%s\n", cfg.gps_device); fprintf (f, "gps_device=%s\n", cfg.gps_device);
fprintf (f, "debug=%d\n", cfg.debug); fprintf (f, "debug=%d\n", cfg.debug);
fprintf (f, "softkeyboard=%d\n", cfg.softkeyboard);
#endif #endif
fclose (f); fclose (f);
} }

@ -92,7 +92,7 @@ int execwait (struct s_execcall *p) {
#endif #endif
// #ifndef ANDROID #ifndef ANDROID
void d_printf (char *fmt,...) { void d_printf (char *fmt,...) {
va_list args; va_list args;
char text1[1024]; char text1[1024];
@ -103,14 +103,14 @@ void d_printf (char *fmt,...) {
// return; // return;
#endif #endif
va_start (args, fmt); va_start (args, fmt);
vsnprintf (text1, 1023, fmt, args); vsnprintf (text1, 1024, fmt, args);
va_end (args); va_end (args);
text1[1023] = 0; text1[1023] = 0;
text2[1023] = 0; text2[1023] = 0;
snprintf (fn, LEN_FILENAME, "%slogfile.txt", cfg.logpath); snprintf (fn, LEN_FILENAME, "%slogfile.txt", cfg.logpath);
snprintf (text2, 1023, "%-6d %s", (int)(time(NULL) - starttime), text1); snprintf (text2, 1024, "%-6d %s", (int)(time(NULL) - starttime), text1);
#ifndef COSMROUTE #ifndef COSMROUTE
fprintf (stderr, "%s\n", text2); fprintf (stderr, "%s\n", text2);
@ -128,7 +128,7 @@ void d_printf (char *fmt,...) {
close (f); close (f);
} }
}; };
// #endif #endif
void d_print_init() { void d_print_init() {
@ -169,38 +169,6 @@ void d_print_init() {
}; };
#define D_PRINT_COL 16
void d_print_data (char *data, int len) {
int i, j;
int val;
char txt1 [256] = {0};
char txt2 [256] = {0};
char left [256] = {0};
char right [256] = {0};
d_printf ("memdump: len:%d", len);
for (i = 0; i < len; i++) {
val = data[i] & 0x00FF;
sprintf (txt1, "%2x ", val);
if (data[i] >= ' ' && data[i] <= '~') sprintf (txt2, "%c", data[i]);
else sprintf (txt2, ".");
strncat (left, txt1, 256);
strncat (right, txt2, 256);
if ((i%D_PRINT_COL)==D_PRINT_COL-1 || i == len-1) {
sprintf (txt1, " ");
sprintf (txt2, " ");
for (j = i%D_PRINT_COL; j != 0 && j < D_PRINT_COL; j++) {
strncat (left, txt1, 256);
strncat (right, txt2, 256);
}
d_printf (" |%s | %s |", left, right);
memset (left, 0x0, 256);
memset (right, 0x0, 256);
}
}
};
unsigned long long int getticks () { unsigned long long int getticks () {
static unsigned long long int ticks = 0; static unsigned long long int ticks = 0;
@ -335,24 +303,24 @@ void memswap (void *mem1, void *mem2, int size) {
}; };
#endif #endif
int file_exist (char *fn) { struct stat *file_exist (char *fn) {
struct stat fs; static struct stat fs;
if (stat(fn, &fs) != 0) if (stat(fn, &fs) != 0)
return 0; return NULL;
return 1; return &fs;
}; };
int dir_exist (char *fn) { struct stat *dir_exist (char *fn) {
struct stat fs; static struct stat fs;
if (stat(fn, &fs) == 0) { if (stat(fn, &fs) == 0) {
if (S_ISDIR(fs.st_mode)) if (S_ISDIR(fs.st_mode))
return 1; return &fs;
} }
return 0; return NULL;
} }

@ -54,14 +54,11 @@
#if defined(__MINGW32CE__) || defined(_WIN32_WCE) #if defined(__MINGW32CE__) || defined(_WIN32_WCE)
#define DIR_SEP '/' #define DIR_SEP '/'
#define ROOT_DIR "/"
#else #else
#if defined(__MINGW32__) #if defined(__MINGW32__)
#define DIR_SEP '\\' #define DIR_SEP '\\'
#define ROOT_DIR "C:\\"
#else #else
#define DIR_SEP '/' #define DIR_SEP '/'
#define ROOT_DIR "/"
#endif #endif
#endif #endif
@ -90,8 +87,7 @@ extern int cmpd (double d1, double d2);
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sposmroute", __VA_ARGS__)) #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sposmroute", __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "sposmroute", __VA_ARGS__)) #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "sposmroute", __VA_ARGS__))
// #define d_printf(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sposmroute", __VA_ARGS__)) #define d_printf(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sposmroute", __VA_ARGS__))
extern void d_printf (char *fmt,...);
#else #else
extern void d_printf (char *fmt,...); extern void d_printf (char *fmt,...);
@ -99,7 +95,6 @@ extern void d_printf (char *fmt,...);
extern void d_print_init(); extern void d_print_init();
extern void d_print_backtrace (); extern void d_print_backtrace ();
extern void d_print_stat (); extern void d_print_stat ();
extern void d_print_data (char *data, int len);
extern void errorexit (int nr); extern void errorexit (int nr);
extern int execcall (struct s_execcall *p, char *prg, char **argv); extern int execcall (struct s_execcall *p, char *prg, char **argv);
@ -116,8 +111,8 @@ extern char *memstrpop (void *mem, void *dest, int *size);
extern void memswap (void *mem1, void *mem2, int size); // maximum 32 bytes extern void memswap (void *mem1, void *mem2, int size); // maximum 32 bytes
#endif #endif
int file_exist (char *fn); struct stat *file_exist (char *fn);
int dir_exist (char *fn); struct stat *dir_exist (char *fn);
extern char* flags2text (int f, char *text); extern char* flags2text (int f, char *text);

@ -1,238 +0,0 @@
/* $Id: utf8.c,v 1.3 2013/06/09 20:11:30 steffen Exp $ */
/* utf8.c
* Copyright (C) Steffen Pohle 2013 <steffen@gulpe.de>
*
* spOSMroute 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.
*
* spOSMroute 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 <stdlib.h>
#include <strings.h>
#include "system.h"
#include "utf8.h"
/*
* 84218421 84218421 84218421 84218421
* -----------------------------------
* 00000000 00000000 00000000 0aaaaaaa = FF FF FF 80 > 0
* 00000000 00000000 00000bbb bbaaaaaa = FF FF F8 00 > 1
* 00000000 00000000 ccccbbbb bbaaaaaa = FF FF 00 00 > 2
* 00000000 000dddcc ccccbbbb bbaaaaaa = FF E0 00 00 > 3
* 000000ee ddddddcc ccccbbbb bbaaaaaa = FC 00 00 00 > 4
* 0feeeeee ddddddcc ccccbbbb bbaaaaaa > 5
*/
void u8_encode (char *dest, uint32_t key) {
uint8_t maskor = 0;
uint8_t maskand = 0;
int blocks = 0;
if ((key & 0xFFFFFF80) == 0) {
blocks = 0;
maskand = 0x7F;
maskor = 0x00;
}
else if ((key & 0xFFFFF800) == 0) {
blocks = 1;
maskand = 0x1F;
maskor = 0xC0;
}
else if ((key & 0xFFFF0000) == 0) {
blocks = 2;
maskand = 0x0F;
maskor = 0xE0;
}
else if ((key & 0xFFE00000) == 0) {
blocks = 3;
maskand = 0x07;
maskor = 0xF0;
}
else if ((key & 0xFC000000) == 0) {
blocks = 4;
maskand = 0x03;
maskor = 0xF8;
}
else {
blocks = 5;
maskand = 0x01;
maskor = 0xFC;
}
dest[blocks+1] = 0;
while (blocks>0) {
dest[blocks] = (uint8_t)((key & 0x3F) | 0x80);
key = key >> 6;
blocks--;
}
*dest = (key & maskand) | maskor;
};
uint32_t u8_decode (char *str, int *charsize) {
uint32_t chr = 0;
int block = 0;
uint8_t c = 0;
/* check how many elements */
c = *str;
if ((c & 0x80) == 0) {
block = 0;
chr = c;
}
else if ((c & 0xE0) == 0xC0) { // (str[0] & 111x xxxx) == 110x xxxx
block = 1;
chr = c & 0x1F;
}
else if ((c & 0xF0) == 0xE0) { // (str[0] & 1111 xxxx) == 1110 xxxx
block = 2;
chr = c & 0x0F;
}
else if ((c & 0xF8) == 0xF0) { // (str[0] & 1111 1xxx) == 1111 0xxx
block = 3;
chr = c & 0x07;
}
else if ((c & 0xFC) == 0xF8) { // (str[0] & 1111 11xx) == 1111 10xx
block = 4;
chr = c & 0x03;
}
else if ((c & 0xFE) == 0xFC) { // (str[0] & 1111 111x) == 1111 110x
block = 5;
chr = c & 0x01;
}
else {
/* error: no valid code */
if (charsize != NULL) *charsize = 0;
return 0;
}
if (charsize != NULL) *charsize = block+1; /* return size in bytes for utf8 char */
str++;
for (;block > 0; block--) {
c = *str;
if ((c & 0xC0) != 0X80) {
/* error: no valid code */
*charsize = 0;
return 0;
}
chr <<= 6;
chr |= (c & 0x3F);
str++;
}
return chr;
};
/* return the size in chars not in bytes. */
int u8_strlen (char *str) {
int cnt, i, j;
int bytelen = strlen (str);
for (cnt = 0, i = 0; i < bytelen;) {
if (u8_decode (str+i, &j) == 0) {
d_printf ("u8_strlen: something went wrong. str:%s i:%d str+i:%s", str, i, str+i);
return 0;
}
cnt++;
i += j;
}
return cnt;
};
void u8_strcpy (char *dest, char *src, int pos, int len) {
int curpos = 0;
int size = 0;
while (*src != 0 && curpos < pos+len) {
u8_decode (src, &size);
if (curpos >= pos) {
memcpy (dest, src, size);
dest += size;
}
curpos++;
src += size;
}
*dest = 0;
};
void u8_strncat (char *dest, int size, char *src) {
int len;
len = strlen (src)+1;
if (len + strlen(dest) > size)
len = size - strlen(dest) - 1;
memcpy (dest+strlen(dest), src, len);
dest[size-1] = 0;
};
void u8_strdel (char *str, int start, int len) {
int curpos = 0;
char *nstr = str;
int slen = u8_strlen (str);
int size = 0;
int clen = strlen (str);
while (*nstr != 0 && curpos < slen) {
u8_decode (nstr, &size);
if (curpos >= start && curpos < start+len) memmove (nstr, nstr+size, clen-(nstr-str));
else nstr += size;
curpos++;
}
*nstr = 0;
};
void u8_strninsert (char *str, int size, char *text, int pos) {
char *nstr = str;
int curpos = 0;
int chrsize = 0;
int len = u8_strlen (str);
int clen = strlen (str);
while (curpos <= len && curpos <= pos) { // no need to move
if (curpos == pos) {
int cnt = strlen (text);
if (nstr-str + cnt >= size) {
memcpy (nstr, text, size-(nstr-str)-1);
str[size-1] = 0;
break;
}
else if (clen + strlen(text) >= size) { // need to move only part
memmove (nstr+cnt, nstr, size-(nstr-str)-strlen(text));
str[size-1] = 0;
}
else { // no overrun
memmove (nstr+cnt, nstr, clen-(nstr-str));
str[clen+cnt] = 0;
}
memcpy (nstr, text, strlen(text));
break;
}
u8_decode (nstr, &chrsize);
curpos++;
nstr += chrsize;
}
};

@ -1,34 +0,0 @@
/* $Id: utf8.h,v 1.4 2021/07/06 20:52:00 steffen Exp $ */
/* utf8.h
* Copyright (C) Steffen Pohle 2013 <steffen@gulpe.de>
*
* spOSMroute 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.
*
* spOSMroute 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/>.
*/
#ifndef _UTF8_H_
#define _UTF8_H_
#include <stdint.h>
uint32_t u8_decode (char *str, int *size);
void u8_encode (char *dest, uint32_t key);
int u8_strlen (char *str);
void u8_strcpy (char *dest, char *src, int pos, int len);
void u8_strncat (char *dest, int size, char *src);
void u8_strdel (char *str, int start, int len);
void u8_strninsert (char *str, int size, char *text, int pos);
#endif

@ -21,11 +21,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include <math.h>
#include "osmroute.h" #include "osmroute.h"
#include "vector.h" #include "vector.h"
inline fPoint vec_add (fPoint veca, fPoint vecb) { fPoint vec_add (fPoint veca, fPoint vecb) {
fPoint r; fPoint r;
r.x = veca.x + vecb.x; r.x = veca.x + vecb.x;
@ -35,7 +34,7 @@ inline fPoint vec_add (fPoint veca, fPoint vecb) {
}; };
inline fPoint vec_sub (fPoint veca, fPoint vecb) { fPoint vec_sub (fPoint veca, fPoint vecb) {
fPoint r; fPoint r;
r.x = veca.x - vecb.x; r.x = veca.x - vecb.x;
@ -109,23 +108,3 @@ fPoint vec_mul (fPoint v, float f) {
a.y = f * v.y; a.y = f * v.y;
return a; return a;
}; };
/* calc angle of three points assuming v2 is the center.. */
float point_angle (fPoint v1, fPoint v2, fPoint v3) {
float a1;
float a3;
float delta;
v1 = vec_sub (v1, v2);
v3 = vec_sub (v3, v2);
a1 = atan2f (v1.y, v1.x);
a3 = atan2f (v3.y, v3.x);
if (a1 < 0.0) a1 += 2.0*M_PI;
if (a3 < 0.0) a3 += 2.0*M_PI;
if ((delta = a1-a3) < 0.0) delta += 2.0*M_PI;
return delta;
};

@ -35,6 +35,4 @@ extern fPoint vec_mirror (fPoint veca);
extern float vec_len (fPoint veca); extern float vec_len (fPoint veca);
extern fPoint vec_mul (fPoint v, float f); extern fPoint vec_mul (fPoint v, float f);
extern float point_angle (fPoint v1, fPoint v2, fPoint v3);
#endif #endif

Binary file not shown.

Binary file not shown.

@ -151,7 +151,6 @@ void draw_setscalef (float newscale) {
break; break;
default: default:
draw_type [i] = FALSE; draw_type [i] = FALSE;
break;
} }
} }
} }
@ -167,7 +166,6 @@ void draw_setscalef (float newscale) {
break; break;
default: default:
draw_type [i] = FALSE; draw_type [i] = FALSE;
break;
} }
} }
} }
@ -198,7 +196,7 @@ void draw_init () {
view_lon = cfg.last_lon; view_lon = cfg.last_lon;
view_lat = cfg.last_lat; view_lat = cfg.last_lat;
draw_setscalef (cfg.last_scale); view_scale = cfg.last_scale;
}; };
void draw_init_color () { void draw_init_color () {
@ -284,7 +282,7 @@ void draw_init_color () {
case (MWAY_unknown): case (MWAY_unknown):
case (MWAY_unknown_way): case (MWAY_unknown_way):
default: default:
gfx_color_alloc (&draw_linestyle[n].c, 0xA000,0x5000,0x5000); gfx_color_alloc (&draw_linestyle[n].c, 0x7000,0x5000,0x5000);
break; break;
} }
} }
@ -341,22 +339,6 @@ 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 * lines
*/ */
@ -401,7 +383,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; int i;
gfx_draw_polygon (dimg, _polypoints, _polycnt, ls, c); gfx_draw_polygon (dimg, _polypoints, _polycnt, ls, c);
@ -485,22 +467,16 @@ void draw_map () {
|| ((view_scale < 0.1 && (n % 2) == 0) || carea->p_cnt < 5) || ((view_scale < 0.1 && (n % 2) == 0) || carea->p_cnt < 5)
|| ((view_scale < 0.1 && (n % 4) == 0) || carea->p_cnt < 10)) { || ((view_scale < 0.1 && (n % 4) == 0) || carea->p_cnt < 10)) {
p1 = draw_geo2screen (view_lon, view_lat, carea->p[n].lon, carea->p[n].lat); p1 = draw_geo2screen (view_lon, view_lat, carea->p[n].lon, carea->p[n].lat);
// if (n == 0) {
// draw_line (img_map, p1.x + center.x - 5, p1.y + center.y - 5, p1.x + center.x + 5, p1.y + center.y + 5, tmplinestyle);
// draw_line (img_map, p1.x + center.x + 5, p1.y + center.y - 5, p1.x + center.x - 5, p1.y + center.y + 5, tmplinestyle);
// }
// if (n == 0) sprintf (text, "%d:%d", n, carea->subid);
// else sprintf (text, "%d", n);
// gfx_draw_text (img_map, p1.x + center.x - 20, p1.y + center.y - 10, text, &color[COLOR_white][3]);
draw_polygonadd (p1.x + center.x, p1.y + center.y); 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; carea = carea->next;
} }
} }
} }
/* /*
* draw ways * draw ways
*/ */
@ -685,6 +661,7 @@ void draw_map () {
} }
} }
/* /*
* draw places, pois just on top layers * draw places, pois just on top layers
*/ */
@ -747,7 +724,6 @@ void draw_map () {
default: default:
sprintf (text, "?"); sprintf (text, "?");
c = &color[COLOR_red][3]; c = &color[COLOR_red][3];
break;
} }
gfx_draw_text (img_map, p1.x-4, p1.y-4, text, c); gfx_draw_text (img_map, p1.x-4, p1.y-4, text, c);
gfx_draw_text (img_map, p1.x-strlen(cpoi->name)*2, p1.y+8, cpoi->name, c); gfx_draw_text (img_map, p1.x-strlen(cpoi->name)*2, p1.y+8, cpoi->name, c);

@ -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_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_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_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_polygonstart ();
extern void draw_polygonadd (int x, int y); 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,8 +155,8 @@ 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_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_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_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_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); extern void gfx_clear (struct image *dimg, struct color *c);
extern struct image *gfx_img_alloc (int w, int h); extern struct image *gfx_img_alloc (int w, int h);

@ -37,8 +37,7 @@
iPoint mousepos; iPoint mousepos;
int mousebtn; int mousebtn;
time_t mousebtnpresstime; time_t mousebtnpresstime;
iPoint mousebtnpresspos = {0.0, 0.0}; iPoint mousebtnpresspos = {0 , 0};
struct map_pos mousebtnpressgpos = {0, 0};
int mousebtnpresslongtime = 0; int mousebtnpresslongtime = 0;
unsigned long long int mouse_over_way_id = 0; unsigned long long int mouse_over_way_id = 0;
unsigned short int mouse_over_way_sid = 0; unsigned short int mouse_over_way_sid = 0;
@ -52,24 +51,8 @@ char mouse_over_way_name[MAP_W_NAMELEN] = "\0";
* if btn == -1 mean no button pressed or selected * if btn == -1 mean no button pressed or selected
*/ */
void draw_mousemove (int x, int y, int btn) { void draw_mousemove (int x, int y, int btn) {
float lon, lat, lonold, latold;
mousepos.x = x; mousepos.x = x;
mousepos.y = y; mousepos.y = y;
if (mousebtn) {
latold = -map_km2lat(((float)(mousebtnpresspos.y-gfx_screensize.y/2)) * view_scale);
lonold = map_km2lon(((float)(mousebtnpresspos.x-gfx_screensize.x/2)) * view_scale, view_lat + latold);
lat = -map_km2lat(((float)(y-gfx_screensize.y/2)) * view_scale);
lon = map_km2lon(((float)(x-gfx_screensize.x/2)) * view_scale, view_lat + lat);
lat = lat - latold;
lon = lon - lonold;
view_lat = mousebtnpressgpos.lat - lat;
view_lon = mousebtnpressgpos.lon - lon;
draw_del_flag (DRAW_GPSFOLLOW);
}
draw (); draw ();
}; };
@ -78,19 +61,15 @@ void draw_mousebtndown (int x, int y, int btn) {
mousebtnpresstime = time (NULL); mousebtnpresstime = time (NULL);
mousebtnpresspos.x = x; mousebtnpresspos.x = x;
mousebtnpresspos.y = y; mousebtnpresspos.y = y;
mousebtnpressgpos.lon = view_lon;
mousebtnpressgpos.lat = view_lat;
mousebtn = btn; mousebtn = btn;
mousebtnpresslongtime = 0; mousebtnpresslongtime = 0;
draw (); draw ();
}; };
void draw_mousebtnup (int x, int y, int btn) void draw_mousebtnup (int x, int y, int btn) {
{
time_t t = time(NULL); time_t t = time(NULL);
float lon, lat; float lon, lat;
int dx, dy;
if (!mousebtn) return; /* button is no longer pressed */ if (!mousebtn) return; /* button is no longer pressed */
mousebtn = 0; mousebtn = 0;
@ -105,26 +84,24 @@ void draw_mousebtnup (int x, int y, int btn)
lat = -map_km2lat(((float)(y-gfx_screensize.y/2)) * view_scale); lat = -map_km2lat(((float)(y-gfx_screensize.y/2)) * view_scale);
lon = map_km2lon(((float)(x-gfx_screensize.x/2)) * view_scale, view_lat + lat); lon = map_km2lon(((float)(x-gfx_screensize.x/2)) * view_scale, view_lat + lat);
dx = abs (mousebtnpresspos.x-x)*100/gfx_screensize.x; if (t - mousebtnpresstime <= 1) {
dy = abs (mousebtnpresspos.y-y)*100/gfx_screensize.y; /* short time button pressing */
if (btn == 1) {
/* short time button pressing */ view_lat = view_lat + lat;
d_printf ("released mouse button.."); view_lon = view_lon + lon;
if (t - mousebtnpresstime <= 1) { draw_del_flag (DRAW_GPSFOLLOW);
if (dx < 10 && dy < 10) {
if (select_enabled) {
select_enabled = 0;
}
else {
select_enabled = 1;
select_pos.lat = view_lat + lat;
select_pos.lon = view_lon + lon;
}
} }
} }
else if (mousebtnpresslongtime && dx < 10 && dy < 10) { else {
/* long time button pressed */ /* long time button pressed */
wnd_mapcontext_show (); if (select_enabled) {
select_enabled = 0;
}
else {
select_enabled = 1;
select_pos.lat = view_lat + lat;
select_pos.lon = view_lon + lon;
}
} }
} }
@ -137,7 +114,6 @@ void draw_mouseloop () {
if (mousebtn && t - mousebtnpresstime > 1) { if (mousebtn && t - mousebtnpresstime > 1) {
mousebtnpresslongtime = 1; mousebtnpresslongtime = 1;
d_printf ("draw_mouseloop: long press..");
draw (); draw ();
} }
@ -180,6 +156,7 @@ void draw_gui () {
tmplinestyle.c = tmplinestyle.borderc = color[COLOR_white][3]; tmplinestyle.c = tmplinestyle.borderc = color[COLOR_white][3];
draw_line (NULL, mousepos.x-5, mousepos.y-5, mousepos.x+5, mousepos.y+5, tmplinestyle); draw_line (NULL, mousepos.x-5, mousepos.y-5, mousepos.x+5, mousepos.y+5, tmplinestyle);
draw_line (NULL, mousepos.x+5, mousepos.y-5, mousepos.x-5, mousepos.y+5, tmplinestyle); draw_line (NULL, mousepos.x+5, mousepos.y-5, mousepos.x-5, mousepos.y+5, tmplinestyle);
gfx_draw_text (NULL, mousepos.x, mousepos.y, "nur ein test.", &color[COLOR_yellow][2]);
/* /*
* draw selected position * draw selected position
@ -207,8 +184,8 @@ void draw_gui () {
ls.width = 1.0; ls.width = 1.0;
ls.c = ls.borderc = color[COLOR_white][3]; ls.c = ls.borderc = color[COLOR_white][3];
p1.x = gfx_screensize.x/2-101; p1.x = gfx_screensize.x/2-100;
p2.x = gfx_screensize.x/2+101; p2.x = gfx_screensize.x/2+100;
p1.y = gfx_screensize.y-32; p1.y = gfx_screensize.y-32;
p2.y = gfx_screensize.y-10; p2.y = gfx_screensize.y-10;
@ -217,21 +194,8 @@ void draw_gui () {
draw_polygonadd (p2.x, p1.y); draw_polygonadd (p2.x, p1.y);
draw_polygonadd (p2.x, p2.y); draw_polygonadd (p2.x, p2.y);
draw_polygonadd (p1.x, p2.y); draw_polygonadd (p1.x, p2.y);
draw_polygonfinish (NULL, ls, &color[COLOR_white][0], 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]);
p1.x = gfx_screensize.x/2-(float)(100.0*app.statusline_progress);
p2.x = gfx_screensize.x/2+(float)(100.0*app.statusline_progress);
p1.y = gfx_screensize.y-31;
p2.y = gfx_screensize.y-11;
draw_polygonstart ();
draw_polygonadd (p1.x, p1.y);
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], 0);
gfx_draw_text (NULL, gfx_screensize.x/2-98, p1.y + 2, app.statusline_text, &color[COLOR_white][3]);
} }
/* /*

@ -152,7 +152,7 @@ void gfx_draw_text (struct image *dimg, int x, int y, char *text, struct color *
}; };
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) {
static GdkPoint *polygon = NULL; static GdkPoint *polygon = NULL;
static int polygon_cnt = 0; static int polygon_cnt = 0;
int i; int i;
@ -171,7 +171,7 @@ void gfx_draw_polygon (struct image *dimg, iPoint *p, int pcnt, struct line_styl
polygon[i].y = p[i].y; polygon[i].y = p[i].y;
} }
gdk_gc_set_foreground (dimg->gc, &c->c); gdk_gc_set_foreground (dimg->gc, &c.c);
gdk_draw_polygon (dimg->pixmap, dimg->gc, TRUE, polygon, pcnt); gdk_draw_polygon (dimg->pixmap, dimg->gc, TRUE, polygon, pcnt);
}; };

@ -63,7 +63,7 @@ void main_menu_refresh () {
he.lon = view_lon + 2.0 * map_km2lon(view_scale * ((float)ss.x/10), he.lat); he.lon = view_lon + 2.0 * map_km2lon(view_scale * ((float)ss.x/10), he.lat);
map_load_web (hs, he); map_load_web (hs, he);
app_status (-1, "", 0.0); app_status ("", -1);
draw (); draw ();
} }
}; };
@ -80,9 +80,9 @@ void main_menu_mapdefrag () {
void main_menu_saveall () { void main_menu_saveall () {
app_status (-1,_("save all"), 0.0); app_status (_("save all"), -1);
map_save_all(); map_save_all();
app_status (-1, "", 0.0); app_status ("", -1);
}; };
@ -127,13 +127,14 @@ void main_menu_osmimport () {
osm_loadfile (fn); osm_loadfile (fn);
draw_redrawmap (); draw_redrawmap ();
} }
app_status (APPSTATUS_nothing, "", 0.0); app_status ("", -1);
app.status = APPSTATUS_nothing;
}; };
void main_menu_map_searchsort () { void main_menu_map_searchsort () {
map_search_sort (); map_search_sort ();
app_status (-1, "", 0.0); app_status ("", -1);
}; };
@ -144,7 +145,7 @@ void main_menu_map_searchrefresh () {
map_search_get_filename (lfn, LEN_FILENAME); map_search_get_filename (lfn, LEN_FILENAME);
map_webload (rfn, lfn, NULL); map_webload (rfn, lfn, NULL);
app_status (-1, "", 0.0); app_status ("", -1);
}; };

@ -107,12 +107,18 @@ static gboolean main_wnd_delete_event(GtkWidget *widget, GdkEvent *event, gpoint
* callback function for the cyclic loop * callback function for the cyclic loop
*/ */
gboolean main_wnd_cyclicloop (gpointer data) { gboolean main_wnd_cyclicloop (gpointer data) {
// d_printf ("%s:%d main_wnd_cyclicloop", __FILE__, __LINE__); struct gps_data *gpspos;
while (gtk_events_pending()) // make sure we handle also other GTK events.. while (gtk_events_pending()) // make sure we handle also other GTK events..
gtk_main_iteration(); gtk_main_iteration();
app_loop (); if (gps_isrunning () > 0) {
if ((gpspos = gps_loop ())) {
drawgps_set_pos (gpspos);
}
}
draw_mouseloop ();
return TRUE; return TRUE;
}; };
@ -211,7 +217,7 @@ void main_wnd_loop (long long int cur, long long int max) {
t1 = time (NULL); t1 = time (NULL);
if (to != t1) { if (to != t1) {
app_status (-1, NULL, 0.0); app_status (NULL, 0);
to = t1; to = t1;
} }

@ -36,7 +36,7 @@ GtkWidget *map_da = NULL;
GdkGC *gc; GdkGC *gc;
GdkGCValues gcvalues; GdkGCValues gcvalues;
GdkColormap *colormap = NULL; GdkColormap *colormap = NULL;
guint last_event_keyval;
/* /*
* draw event callback * draw event callback
@ -58,8 +58,8 @@ gboolean map_da_button_press_event (GtkWidget *widget, GdkEventButton *event, gp
if (event->button == 2) btn = 4; if (event->button == 2) btn = 4;
if (event->button == 3) btn = 2; if (event->button == 3) btn = 2;
gevent.scr_mpos.x = x; gevent.mousepos.x = x;
gevent.scr_mpos.y = y; gevent.mousepos.y = y;
gevent.mousebtn = btn; gevent.mousebtn = btn;
gevent.event = EGUI_MOUSEPRESSED; gevent.event = EGUI_MOUSEPRESSED;
if (gui_event (gevent) == 0) draw_mousebtndown (x, y, btn); if (gui_event (gevent) == 0) draw_mousebtndown (x, y, btn);
@ -78,8 +78,8 @@ gboolean map_da_button_release_event (GtkWidget *widget, GdkEventButton *event,
if (event->button == 2) btn = 4; if (event->button == 2) btn = 4;
if (event->button == 3) btn = 2; if (event->button == 3) btn = 2;
gevent.scr_mpos.x = x; gevent.mousepos.x = x;
gevent.scr_mpos.y = y; gevent.mousepos.y = y;
gevent.mousebtn = btn; gevent.mousebtn = btn;
gevent.event = EGUI_MOUSERELEASED; gevent.event = EGUI_MOUSERELEASED;
if (gui_event (gevent) == 0) draw_mousebtnup (x, y, btn); if (gui_event (gevent) == 0) draw_mousebtnup (x, y, btn);
@ -93,8 +93,8 @@ gboolean map_da_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, g
int y = event->y; int y = event->y;
GUIEvent gevent; GUIEvent gevent;
gevent.scr_mpos.x = x; gevent.mousepos.x = x;
gevent.scr_mpos.y = y; gevent.mousepos.y = y;
gevent.mousebtn = 0; gevent.mousebtn = 0;
gevent.event = EGUI_MOUSEMOVE; gevent.event = EGUI_MOUSEMOVE;
@ -107,37 +107,18 @@ gboolean map_da_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, g
gboolean map_da_key_release_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { gboolean map_da_key_release_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) {
last_event_keyval = 0;
return FALSE;
};
gboolean map_da_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) {
GUIEvent gevent = {0}; GUIEvent gevent = {0};
int lo, hi;
if (last_event_keyval == event->keyval) return FALSE;
lo = event->keyval & 0x00FF; gevent.keyval = event->keyval;
hi = (event->keyval & 0xFF00) > 8; gevent.event = EGUI_KEYRELEASED;
if (gui_event (gevent) == 0) {
if (hi == 0) gevent.keychar = lo; if (event->keyval == '+') draw_setscale (- 1);
if (hi == 1 && lo == 0x08) gevent.keychar = lo; if (event->keyval == '-') draw_setscale (+ 1);
if (hi == 1 && lo == 0x1b) gevent.keychar = lo; }
if (hi == 1 && lo == 0x0d) gevent.keychar = lo;
if (hi == 1 && lo == 0x51) gevent.keychar = lo;
if (hi == 1 && lo == 0x53) gevent.keychar = lo;
d_printf ("keyval: '%c' lo(%x) hi(%x) gevent:%lx", event->keyval, lo, hi, gevent.keychar);
gevent.event = EGUI_KEYCHAR;
gui_event (gevent);
main_wnd_update (); main_wnd_update ();
draw (); draw ();
last_event_keyval = event->keyval;
return FALSE; return FALSE;
}; };
@ -180,7 +161,6 @@ GtkWidget *map_da_create () {
g_signal_connect (G_OBJECT (map_da), "button_press_event", G_CALLBACK (map_da_button_press_event), NULL); g_signal_connect (G_OBJECT (map_da), "button_press_event", G_CALLBACK (map_da_button_press_event), NULL);
g_signal_connect (G_OBJECT (map_da), "button_release_event", G_CALLBACK (map_da_button_release_event), NULL); g_signal_connect (G_OBJECT (map_da), "button_release_event", G_CALLBACK (map_da_button_release_event), NULL);
g_signal_connect (G_OBJECT (map_da), "scroll_event", G_CALLBACK (map_da_scroll_event), NULL); g_signal_connect (G_OBJECT (map_da), "scroll_event", G_CALLBACK (map_da_scroll_event), NULL);
g_signal_connect (G_OBJECT (map_da), "key_press_event", G_CALLBACK (map_da_key_press_event), NULL);
g_signal_connect (G_OBJECT (map_da), "key_release_event", G_CALLBACK (map_da_key_release_event), NULL); g_signal_connect (G_OBJECT (map_da), "key_release_event", G_CALLBACK (map_da_key_release_event), NULL);
g_signal_connect (G_OBJECT (map_da), "motion_notify_event", G_CALLBACK (map_da_motion_notify_event), NULL); g_signal_connect (G_OBJECT (map_da), "motion_notify_event", G_CALLBACK (map_da_motion_notify_event), NULL);
gfx_resize (100, 100); gfx_resize (100, 100);

@ -1,14 +1,6 @@
include ../Makefile.rules include ../Makefile.rules
OBJ = gui.o \ OBJ = gui.o
gui_window.o \
gui_checkbox.o \
gui_button.o \
gui_list.o \
gui_entry.o \
gui_label.o \
gui_image.o \
gui_softkeyboard.o
SRC = $(OBJ:%.o=%.c) SRC = $(OBJ:%.o=%.c)

@ -1,4 +1,3 @@
/* $Id: gui.c,v 1.28 2014/03/06 22:21:46 steffen Exp $ */
/*************************************************************************** /***************************************************************************
* gui.c * gui.c
* *
@ -29,12 +28,6 @@
GUIWindow *currentwin = NULL; GUIWindow *currentwin = NULL;
int gui_is_inside (int x, int y, int w, int h, iPoint pos) {
if (x <= pos.x && x+w >= pos.x && y <= pos.y && y+h >= pos.y) return 1;
else return 0;
};
/* /*
* show window * show window
*/ */
@ -71,9 +64,7 @@ void gui_draw () {
if (currentwin == NULL) gui_buttons_show (); if (currentwin == NULL) gui_buttons_show ();
if (currentwin->screen == NULL) { if (currentwin->screen == NULL) {
currentwin->screen = gfx_img_alloc (currentwin->w, currentwin->h); currentwin->screen = gfx_img_alloc (currentwin->w, currentwin->h);
currentwin->screen_changed = 1;
} }
// d_printf ("GUI draw: %p %s screen:%p(changed:%d) pos: %d,%d size:%d,%d", currentwin, currentwin->title, currentwin->screen, currentwin->screen_changed, currentwin->x, currentwin->y, currentwin->w, currentwin->h); // d_printf ("GUI draw: %p %s screen:%p(changed:%d) pos: %d,%d size:%d,%d", currentwin, currentwin->title, currentwin->screen, currentwin->screen_changed, currentwin->x, currentwin->y, currentwin->w, currentwin->h);
if (currentwin && (currentwin->screen_changed || now-1 > lastupdate || now < lastupdate)) { if (currentwin && (currentwin->screen_changed || now-1 > lastupdate || now < lastupdate)) {
lastupdate = now; lastupdate = now;
@ -82,79 +73,46 @@ void gui_draw () {
} }
else { else {
ls.width = 1.0; ls.width = 1.0;
ls.c = ls.borderc = color[COLOR_red][3]; ls.c = ls.borderc = color[COLOR_white][3];
draw_polygonstart (); draw_polygonstart ();
draw_polygonadd (0, 0); draw_polygonadd (0, 0);
draw_polygonadd (0, currentwin->h); draw_polygonadd (0, currentwin->h-1);
draw_polygonadd (currentwin->w, currentwin->h); draw_polygonadd (currentwin->w-1, currentwin->h-1);
draw_polygonadd (currentwin->w, 0); draw_polygonadd (currentwin->w-1, 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]); 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); }
}
for (i = 0; i < GUI_WIN_BUTTONS; i++) if (currentwin->buttons[i].id != 0) {
/* draw items.. */ if (currentwin->buttons[i].callback_draw != NULL)
for (i = 0; i < GUI_MAX_ITEM; i++) if (currentwin->items[i]) currentwin->buttons[i].callback_draw (&currentwin->buttons[i]);
switch (currentwin->items[i]->type) { else gui_button_draw (&currentwin->buttons[i]);
case (GUI_BUTTON): { }
GUIButton *button = (GUIButton *) currentwin->items[i]->data; for (i = 0; i < GUI_WIN_LABELS; i++) if (currentwin->labels[i].id != 0) {
if (button->func_draw != NULL) button->func_draw (currentwin->items[i]); gui_label_draw (&currentwin->labels[i]);
else gui_button_draw (currentwin->items[i]); }
} for (i = 0; i < GUI_WIN_ENTRYS; i++) if (currentwin->entrys[i].id != 0) {
break; gui_entry_draw (&currentwin->entrys[i]);
case (GUI_LABEL): }
gui_label_draw (currentwin->items[i]); for (i = 0; i < GUI_WIN_LISTS; i++) if (currentwin->lists[i].id != 0) {
break; gui_list_draw (&currentwin->lists[i]);
case (GUI_ENTRY): }
gui_entry_draw (currentwin->items[i]); for (i = 0; i < GUI_WIN_CHECKBOXES; i++) if (currentwin->checkboxes[i].id != 0) {
break; // gui_draw_label (&currentwin->labels[i]);
case (GUI_LIST): }
gui_list_draw (currentwin->items[i]);
break;
case (GUI_CHECKBOX):
gui_checkbox_draw (currentwin->items[i]);
break;
default:
break;
}
currentwin->screen_changed = 0; currentwin->screen_changed = 0;
} }
if (currentwin) { if (currentwin) {
if ((currentwin->style & WGUI_S_VCENTER) == WGUI_S_VCENTER) if ((currentwin->style & WGUI_S_VCENTER) == WGUI_S_VCENTER) currentwin->x = gfx_screensize.x/2 - currentwin->w/2;
currentwin->x = gfx_screensize.x/2 - currentwin->w/2; if ((currentwin->style & WGUI_S_VCENTER) == WGUI_S_VLEFT) currentwin->x = 0;
if ((currentwin->style & WGUI_S_VCENTER) == WGUI_S_VLEFT) if ((currentwin->style & WGUI_S_VCENTER) == WGUI_S_VRIGHT) currentwin->x = gfx_screensize.x - currentwin->w;
currentwin->x = 0;
if ((currentwin->style & WGUI_S_VCENTER) == WGUI_S_VRIGHT) if ((currentwin->style & WGUI_S_HCENTER) == WGUI_S_HCENTER) currentwin->y = gfx_screensize.y/2 - currentwin->h/2;
currentwin->x = gfx_screensize.x - currentwin->w; if ((currentwin->style & WGUI_S_HCENTER) == WGUI_S_HTOP) currentwin->y = 0;
if ((currentwin->style & WGUI_S_HCENTER) == WGUI_S_HCENTER) if ((currentwin->style & WGUI_S_HCENTER) == WGUI_S_HBOTTOM) currentwin->y = gfx_screensize.y - currentwin->h;
currentwin->y = gfx_screensize.y/2 - currentwin->h/2;
if ((currentwin->style & WGUI_S_HCENTER) == WGUI_S_HTOP) gfx_draw_img (NULL, currentwin->x, currentwin->y, currentwin->w, currentwin->h, currentwin->screen, 0, 0);
currentwin->y = 0;
if ((currentwin->style & WGUI_S_HCENTER) == WGUI_S_HBOTTOM)
currentwin->y = gfx_screensize.y - currentwin->h;
/* draw the windows or just the part of the entry which is focused
* and draw the softkeyb
*/
if (currentwin->focus && softkeyb && softkeyb->enabled) {
int ys, yh;
/* drawing and display softkeyb */
gui_softkeyb_draw ();
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.. */
ys = currentwin->focus->y- 16;
yh = gfx_screensize.y-softkeyb->screen->height;
currentwin->y = -ys;
if ((currentwin->h - (currentwin->focus->y-16)) < yh) yh = currentwin->h - (currentwin->focus->y - 16);
gfx_draw_img (NULL, currentwin->x, 0, currentwin->w, yh, currentwin->screen, 0, ys);
}
else gfx_draw_img (NULL, currentwin->x, currentwin->y, currentwin->w, currentwin->h, currentwin->screen, 0, 0);
} }
}; };
@ -164,46 +122,361 @@ void gui_draw () {
* return 0 for nothing done.. or 1 for eventhandling done * return 0 for nothing done.. or 1 for eventhandling done
*/ */
int gui_event (GUIEvent event) { int gui_event (GUIEvent event) {
d_printf ("gui_event..."); int i;
if (currentwin) { static int event_called = 0;
event.guiwin_mpos.x = event.scr_mpos.x - currentwin->x;
event.guiwin_mpos.y = event.scr_mpos.y - currentwin->y; if (currentwin == NULL) return 0;
if (gui_window_event (currentwin, &event)) return 1;
event.mousepos.x -= currentwin->x;
event.mousepos.y -= currentwin->y;
if (currentwin->focus == NULL && (event.mousepos.x < 0 || event.mousepos.x > currentwin->w
|| event.mousepos.y < 0 || event.mousepos.y > currentwin->h)) {
event_called = 0;
return 0;
}
// d_printf ("event called %d event:%d mousepos:(%d,%d)", __LINE__, event.event, event.mousepos.x, event.mousepos.y);
if (event_called) return 1;
event_called = 1;
for (i = 0; i < GUI_WIN_BUTTONS; i++) {
// if (currentwin->buttons[i].id != 0)
// d_printf ("%d %d,%d %d,%d - %d,%d", currentwin->buttons[i].id, currentwin->buttons[i].x, currentwin->buttons[i].y, currentwin->buttons[i].w, currentwin->buttons[i].h, event.mousepos.x, event.mousepos.y);
if (currentwin->buttons[i].id != 0
&& currentwin->buttons[i].x <= event.mousepos.x && currentwin->buttons[i].x+currentwin->buttons[i].w >= event.mousepos.x
&& currentwin->buttons[i].y <= event.mousepos.y && currentwin->buttons[i].y+currentwin->buttons[i].h >= event.mousepos.y) {
if (currentwin->buttons[i].callback_clicked != NULL && event.event == EGUI_MOUSEPRESSED) {
d_printf ("GUI BUTTON PRESSED: %d:%s", currentwin->buttons[i].id, currentwin->buttons[i].caption);
currentwin->buttons[i].callback_clicked (event.mousepos.x-currentwin->buttons[i].x, event.mousepos.y-currentwin->buttons[i].y);
event_called = 0;
currentwin->screen_changed = 1;
return 1;
}
}
}
for (i = 0; i < GUI_WIN_LABELS; i++) if (currentwin->labels[i].id != 0) {
// gui_event_label (&currentwin->labels[i]);
}
for (i = 0; i < GUI_WIN_ENTRYS; i++) if (currentwin->entrys[i].id != 0) {
if (currentwin->entrys[i].id != 0
&& currentwin->entrys[i].x <= event.mousepos.x && currentwin->entrys[i].x+currentwin->entrys[i].w >= event.mousepos.x
&& currentwin->entrys[i].y <= event.mousepos.y && currentwin->entrys[i].y+currentwin->entrys[i].h >= event.mousepos.y) {
gui_entry_event (&currentwin->entrys[i], &event);
event_called = 0;
return 1;
}
}
for (i = 0; i < GUI_WIN_LISTS; i++) if (currentwin->lists[i].id != 0) {
if (currentwin->lists[i].x <= event.mousepos.x && currentwin->lists[i].x+currentwin->lists[i].w >= event.mousepos.x
&& currentwin->lists[i].y <= event.mousepos.y && currentwin->lists[i].y+currentwin->lists[i].h >= event.mousepos.y) {
gui_list_event (&currentwin->lists[i], &event);
event_called = 0;
return 1;
}
}
for (i = 0; i < GUI_WIN_CHECKBOXES; i++) if (currentwin->checkboxes[i].id != 0) {
// gui_event_label (&currentwin->labels[i]);
}
if (currentwin->focus != NULL) {
for (i = 0; i < GUI_WIN_ENTRYS; i++) if (currentwin->focus == &currentwin->entrys[i]) {
gui_entry_event (&currentwin->entrys[i], &event);
event_called = 0;
return 1;
}
for (i = 0; i < GUI_WIN_LISTS; i++) if (currentwin->focus == &currentwin->lists[i]) {
gui_list_event (&currentwin->lists[i], &event);
event_called = 0;
return 1;
}
}
event_called = 0;
return 1;
};
/***************************************************************************
* basic windows functions
***************************************************************************/
void guiwindow_new (GUIWindow *win, int w, int h) {
int i;
for (i = 0; i < GUI_WIN_BUTTONS; i++) {
win->buttons[i].caption[0] = '\0';
win->buttons[i].id = 0;
win->buttons[i].col = &color[COLOR_white][2];
win->buttons[i].textcol = &color[COLOR_white][3];
win->buttons[i].callback_clicked = NULL;
win->buttons[i].callback_draw = NULL;
}
for (i = 0; i < GUI_WIN_LABELS; i++) {
win->labels[i].text[0] = '\0';
win->labels[i].textcol = &color[COLOR_white][2];
win->labels[i].id = 0;
}
for (i = 0; i < GUI_WIN_LISTS; i++) {
win->lists[i].id = 0;
win->lists[i].selected = -1;
win->lists[i].callback_selectitem = NULL;
}
for (i = 0; i < GUI_WIN_ENTRYS; i++) {
win->entrys[i].text[0] = '\0';
win->entrys[i].callback_enter = NULL;
win->entrys[i].callback_changed = NULL;
win->entrys[i].id = 0;
}
for (i = 0; i < GUI_WIN_CHECKBOXES; i++) {
win->checkboxes[i].text[0] = '\0';
win->checkboxes[i].callback_changed = NULL;
win->checkboxes[i].id = 0;
win->labels[i].text[0] = '\0';
}
win->title[0] = 0;
win->screen = NULL;
win->screen_changed = 1;
win->h = h;
win->w = w;
win->focus = NULL;
d_printf ("guiwindow_new %p width:%d height:%d", win, w, h);
};
/*
* set focus
*/
/*
* closes the window, but does not free the memory.
*/
void guiwindow_close (GUIWindow *win) {
int i;
for (i = 0; i < GUI_WIN_BUTTONS; i++) {
win->buttons[i].caption[0] = '\0';
win->buttons[i].id = 0;
win->buttons[i].callback_clicked = NULL;
win->buttons[i].callback_draw = NULL;
}
for (i = 0; i < GUI_WIN_LABELS; i++) {
win->labels[i].text[0] = '\0';
win->labels[i].textcol = &color[COLOR_white][2];
win->labels[i].id = 0;
}
for (i = 0; i < GUI_WIN_ENTRYS; i++) {
win->entrys[i].text[0] = '\0';
win->entrys[i].callback_enter = NULL;
win->entrys[i].callback_changed = NULL;
win->entrys[i].id = 0;
}
for (i = 0; i < GUI_WIN_CHECKBOXES; i++) {
win->checkboxes[i].text[0] = '\0';
win->checkboxes[i].callback_changed = NULL;
win->checkboxes[i].id = 0;
}
win->title[0] = 0;
gfx_img_free (win->screen);
win->screen = NULL;
win->screen_changed = 1;
win->h = 0;
win->w = 0;
};
/****************************************************************************
****************************************************************************
** gui elements
**
**/
/****************************************************************************
* button
*/
void gui_button_draw (GUIButton *button) {
struct line_style ls;
ls.width = 1.0;
ls.c = ls.borderc = color[COLOR_white][3];
draw_polygonstart ();
draw_polygonadd (button->x, button->y);
draw_polygonadd (button->x, button->y + button->h);
draw_polygonadd (button->x + button->w, button->y + button->h);
draw_polygonadd (button->x + button->w, button->y);
draw_polygonfinish (currentwin->screen, ls, *button->col, 1);
gfx_draw_text (currentwin->screen, button->x + 2, button->y + 2, button->caption, button->textcol);
};
/****************************************************************************
* label
*/
void gui_label_draw (GUILabel *label) {
struct line_style ls;
ls.width = 1.0;
ls.c = ls.borderc = color[COLOR_white][3];
gfx_draw_text (currentwin->screen, label->x, label->y, label->text, label->textcol);
};
/****************************************************************************
* entry
*/
void gui_entry_draw (GUIEntry *entry) {
char text1[GUI_TEXTLEN];
char text2[GUI_TEXTLEN];
struct line_style ls;
ls.width = 1.0;
if (currentwin->focus == entry)
ls.c = ls.borderc = color[COLOR_white][3];
else
ls.c = ls.borderc = color[COLOR_white][2];
gfx_draw_line (currentwin->screen, entry->x, entry->y+entry->h, entry->x+entry->w, entry->y+entry->h, ls);
gfx_draw_line (currentwin->screen, entry->x, entry->y+entry->h, entry->x, entry->y+entry->h-2, ls);
gfx_draw_line (currentwin->screen, entry->x+entry->w, entry->y+entry->h, entry->x+entry->w, entry->y+entry->h-2, ls);
if (entry->curpos >= strlen (entry->text)) {
entry->curpos = strlen (entry->text);
snprintf (text1, GUI_TEXTLEN, "%s|", entry->text);
}
else if (entry->curpos <= 0) {
entry->curpos = 0;
snprintf (text1, GUI_TEXTLEN, "|%s", entry->text);
} }
else { else {
event.guiwin_mpos.x = -1; strncpy (text2, entry->text, entry->curpos);
event.guiwin_mpos.y = -1; snprintf (text1, GUI_TEXTLEN, "%s|%s", text2, entry->text+entry->curpos);
} }
gfx_draw_text (currentwin->screen, entry->x+2, entry->y, text1, &color[COLOR_white][3]);
/* no gui active nor any window is responsible.. */
//d_printf ("no event..");
switch (event.event) {
case (EGUI_MOUSERELEASED):
draw_mousebtnup (event.scr_mpos.x, event.scr_mpos.y, event.mousebtn);
break;
case (EGUI_MOUSEPRESSED):
draw_mousebtndown (event.scr_mpos.x, event.scr_mpos.y, event.mousebtn);
break;
case (EGUI_MOUSEMOVE):
draw_mousemove (event.scr_mpos.x, event.scr_mpos.y, event.mousebtn);
break;
default:
break;
}
return 0;
}; };
void gui_event_addmousepos (GUIEvent *event, iPoint pos, int neg) { /*
event->scr_mpos.x += neg ? pos.x : -pos.x; * event handling
event->scr_mpos.y += neg ? pos.y : -pos.y; */
void gui_entry_event (GUIEntry *entry, GUIEvent *event) {
char text1[GUI_TEXTLEN];
if (event->event == EGUI_MOUSERELEASED
&& entry->x <= event->mousepos.x && entry->x+entry->w >= event->mousepos.x
&& entry->y <= event->mousepos.y && entry->y+entry->h >= event->mousepos.y) {
d_printf ("gui_entry_event set focus");
currentwin->focus = entry;
}
else if (event->event == EGUI_KEYRELEASED) {
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 == 0xff08) { // backspace
// strncpy (text1, entry->text, entry->curpos-1);
// snprintf (text2, GUI_TEXTLEN, "%s%s", text1, entry->text+entry->curpos);
// strncpy (entry->text, text2, GUI_TEXTLEN);
// entry->curpos--;
entry->text[0] = 0;
entry->curpos = 0;
}
else if (event->keyval == 0xff1b) { // esc
gui_close ();
}
else if (event->keyval == 0xff0d) { // enter
if (entry->callback_enter) entry->callback_enter ();
}
else if (event->keyval == 0xff51) { // left
// entry->curpos--;
}
else if (event->keyval == 0xff53) { // right
// entry->curpos++;
}
else if ((event->keyval & 0xff00) == 0xff00) {
// ignore all the rest
}
else {
strncpy (text1, entry->text, GUI_TEXTLEN );
snprintf (entry->text, GUI_TEXTLEN, "%s%c", text1, event->keyval);
entry->curpos++;
}
}
currentwin->screen_changed = 1;
return; return;
}; };
void gui_set_focus (GUIItem *item) { /****************************************************************************
if (item == NULL || item->type != GUI_ENTRY) gui_softkeyb_show (FALSE); * list
currentwin->focus = item; */
void gui_list_draw (GUIList *list) {
struct line_style ls;
int max, i, x, y, j;
ls.width = 1.0;
if (currentwin->focus == list)
ls.c = ls.borderc = color[COLOR_white][3];
else
ls.c = ls.borderc = color[COLOR_white][2];
gfx_draw_line (currentwin->screen, list->x, list->y, list->x+list->w, list->y, ls);
gfx_draw_line (currentwin->screen, list->x+list->w, list->y, list->x+list->w, list->y+list->h, ls);
gfx_draw_line (currentwin->screen, list->x+list->w, list->y+list->h, list->x, list->y+list->h, ls);
gfx_draw_line (currentwin->screen, list->x, list->y+list->h, list->x, list->y, ls);
if (list->data == NULL) return;
for (max = 0; list->data[max] != NULL; max++);
/* range to display */
i = max - list->h/16;
if (i < list->vs) list->vs = i;
if (list->vs < 0) list->vs = 0;
for (i = list->vs; i < (list->vs + list->h/16) && i < max; i++) {
if (i == list->selected) gfx_draw_text (currentwin->screen, list->x + 5, list->y + 5 + 16 * (i - list->vs), list->data[i], &color[COLOR_red][1]);
else gfx_draw_text (currentwin->screen, list->x + 5, list->y + 5 + 16 * (i - list->vs), list->data[i], &color[COLOR_white][3]);
}
ls.c = ls.borderc = color[COLOR_white][3];
for (i = -1; i < 2; i += 2) {
if (i < 0) y = list->y + list->h;
else y = list->y;
x = list->x + list->w;
for (j = 0; j <= 5; j++) {
gfx_draw_line (currentwin->screen, x - 5, y, x-j, y + i*5, ls);
gfx_draw_line (currentwin->screen, x - 5 -j, y+ i*5, x-5, y, ls);
}
}
};
/*
* event handling
*/
void gui_list_event (GUIList *list, GUIEvent *event) {
int x = event->mousepos.x - list->x;
int y = event->mousepos.y - list->y;
int i;
/* set focus */
if (event->event == EGUI_MOUSERELEASED && x >= 0 && x <= list->w && y >= 0 && y <= list->h) {
currentwin->focus = list;
if (y <= 5 && x >= list->w - 10) list->vs--;
else if (y >= list->h - 5 && x >= list->w - 10) list->vs++;
else { /* select entry */
i = (y-5)/16 + list->vs;
list->selected = i;
if (list->callback_selectitem) list->callback_selectitem (i);
d_printf ("selected nr: %d", i);
}
}
currentwin->screen_changed = 1; currentwin->screen_changed = 1;
draw ();
}; };

@ -28,24 +28,16 @@
#include "osmroute.h" #include "osmroute.h"
#define GUI_TEXTLEN 256 #define GUI_TEXTLEN 256
#define GUI_MAX_ITEM 256
enum { enum {
EGUI_NONE, EGUI_NONE,
EGUI_KEYCHAR, EGUI_KEYPRESSED,
EGUI_KEYRELEASED,
EGUI_MOUSEMOVE, EGUI_MOUSEMOVE,
EGUI_MOUSEPRESSED, EGUI_MOUSEPRESSED,
EGUI_MOUSERELEASED EGUI_MOUSERELEASED
}; };
enum {
GUI_NONE,
GUI_BUTTON,
GUI_LIST,
GUI_ENTRY,
GUI_CHECKBOX,
GUI_LABEL
};
/* /*
* styles for the windows.. * styles for the windows..
@ -60,40 +52,28 @@ enum {
// #define WGUI_S_**** 0x0080 // #define WGUI_S_**** 0x0080
#define WGUI_S_MODAL 0x0100 #define WGUI_S_MODAL 0x0100
#define GUIKEY_UP 0x0111
#define GUIKEY_DOWN 0x0112
#define GUIKEY_RIGHT 0x0113
#define GUIKEY_LEFT 0x0114
struct _GUIEvent_ { struct _GUIEvent_ {
int event; int event;
uint16_t key; // the key which was pressed uint32_t keyval; // needed for utf8 (max was 32bit?)
uint32_t keychar; // the utf char for this key iPoint mousepos;
iPoint scr_mpos; // mousepos on screen
iPoint guiwin_mpos; // mousepos on gui (setup from gui_event)
int mousebtn; int mousebtn;
} typedef GUIEvent; } typedef GUIEvent;
struct _GUIItem_ {
int type;
int x, y, w, h;
char data[];
} typedef GUIItem;
struct _GUIButton_ { struct _GUIButton_ {
int x, y, w, h;
int id;
char caption[GUI_TEXTLEN]; char caption[GUI_TEXTLEN];
struct color *col; struct color *col;
struct color *textcol; struct color *textcol;
void (*callback_clicked) (int x, int y); void (*callback_clicked) (int x, int y);
void (*func_draw) (GUIItem *item); void (*callback_draw) (struct _GUIButton_ *btn);
} typedef GUIButton; } typedef GUIButton;
struct _GUIList_ { struct _GUIList_ {
int x, y, w, h;
int id;
char **data; char **data;
int vs; // first element to draw int vs; // first element to draw
int selected; int selected;
@ -102,35 +82,57 @@ struct _GUIList_ {
struct { struct {
int x, y;
int id;
char text[GUI_TEXTLEN]; char text[GUI_TEXTLEN];
struct color *textcol; struct color *textcol;
} typedef GUILabel; } typedef GUILabel;
struct { struct {
int x, y, w, h;
int id;
char text[GUI_TEXTLEN]; char text[GUI_TEXTLEN];
int curpos; int curpos;
int overwrite; int overwrite;
void (*callback_enter) (); void (*callback_enter) ();
void (*callback_esc) ();
void (*callback_changed) (); void (*callback_changed) ();
} typedef GUIEntry; } typedef GUIEntry;
struct { struct {
int x, y, w, h;
int id;
char text[GUI_TEXTLEN]; char text[GUI_TEXTLEN];
int checked; int checked;
void (*callback_changed) (); void (*callback_changed) ();
} typedef GUICheckbox; } typedef GUICheckbox;
#define GUI_WIN_BUTTONS 16
#define GUI_WIN_ENTRYS 8
#define GUI_WIN_LABELS 16
#define GUI_WIN_CHECKBOXES 16
#define GUI_WIN_LISTS 4
#define GUI_WIN_ELEMENTS 32
enum {
GUINONE,
GUIBUTTON,
GUILIST,
GUIENTRY,
GUICHECKBOX,
GUILABEL
};
struct _GUIWindow_ { struct _GUIWindow_ {
void (*callback_close) (); void (*callback_close) ();
struct _GUIWindow_ *parent; struct _GUIWindow_ *parent;
struct image *screen; struct image *screen;
int screen_changed; int screen_changed;
int event_called; // mark if we proceed any event call already.
char title[GUI_TEXTLEN]; char title[GUI_TEXTLEN];
int x; int x;
int y; int y;
@ -138,87 +140,41 @@ struct _GUIWindow_ {
int h; int h;
int style; int style;
void (*callback_clicked) (int x, int y); GUIButton buttons[GUI_WIN_BUTTONS];
GUIEntry entrys[GUI_WIN_ENTRYS];
GUIItem *items[GUI_MAX_ITEM]; GUICheckbox checkboxes[GUI_WIN_CHECKBOXES];
GUIItem *focus; GUILabel labels[GUI_WIN_LABELS];
} typedef GUIWindow; GUIList lists[GUI_WIN_LISTS];
#define GUI_SOFTKEYB_X 11 void *focus; // element which holds the focus
#define GUI_SOFTKEYB_Y 3
enum {
GUI_SOFTKEYB_MODE_NORM = 0,
GUI_SOFTKEYB_MODE_SHIFT,
GUI_SOFTKEYB_MODE_SYMBOL,
GUI_SOFTKEYB_MODE_MAX } typedef GUIWindow;
};
struct _GUISoftkeyboard_ {
int mode;
int enabled;
int linepos[2][4]; /* y positions of lines */
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;
int last_line;
uint32_t keys[GUI_SOFTKEYB_MODE_MAX][GUI_SOFTKEYB_Y][GUI_SOFTKEYB_X];
} typedef GUISoftkeyboard;
extern GUIWindow *currentwin; extern GUIWindow *currentwin;
extern GUISoftkeyboard *softkeyb;
extern void gui_show (GUIWindow *win); extern void gui_show (GUIWindow *win);
extern void gui_draw (); extern void gui_draw ();
extern void gui_close (); extern void gui_close ();
extern int gui_event (GUIEvent event); extern int gui_event (GUIEvent event);
extern void gui_event_addmousepos (GUIEvent *event, iPoint pos, int neg);
extern void gui_set_focus (GUIItem *item);
#define GUI_ITEM_IS_INSIDE(__item__,__pos__) gui_is_inside(__item__->x, __item__->y, __item__->w, __item__->h, __pos__)
extern int gui_is_inside (int x, int y, int w, int h, iPoint pos);
extern void gui_window_new (GUIWindow *win, int w, int h, char *title); extern void guiwindow_new (GUIWindow *win, int w, int h);
extern void gui_window_close (GUIWindow *win); extern void guiwindow_close (GUIWindow *win);
extern void gui_window_item_add (GUIWindow *win, GUIItem *item);
extern int gui_window_event (GUIWindow *win, GUIEvent *event);
/* softkeyboard functions. */
extern void gui_softkeyb_show (int enable);
extern int gui_softkeyb_event (GUIEvent *event);
extern void gui_softkeyb_draw ();
/* button functions */ /* button functions */
#define GUI_BUTTON_T(_item_) ((GUIButton*)(_item_)->data) extern void gui_button_draw (GUIButton *button);
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 */ /* label functions */
#define GUI_LABEL_T(_item_) ((GUILabel*)(_item_)->data) extern void gui_label_draw (GUILabel *label);
extern void gui_label_draw (GUIItem *item);
extern GUIItem *gui_label_new (char *text, int x, int y);
/* entry functions */ /* entry functions */
#define GUI_ENTRY_T(_item_) ((GUIEntry*)(_item_)->data) extern void gui_entry_draw (GUIEntry *entry);
extern void gui_entry_draw (GUIItem *item); extern void gui_entry_event (GUIEntry *entry, GUIEvent *event);
extern int gui_entry_event (GUIItem *item, GUIEvent *event);
extern GUIItem *gui_entry_new (char *text, int x, int y, int w, int h);
extern void gui_entry_settext (GUIItem *item, char *text);
/* list functions */ /* list functions */
#define GUI_LIST_T(_item_) ((GUIList*)(_item_)->data) extern void gui_list_draw (GUIList *list);
extern void gui_list_draw (GUIItem *item); extern void gui_list_event (GUIList *list, GUIEvent *event);
extern int gui_list_event (GUIItem *item, GUIEvent *event); extern void gui_list_setselect (GUIList *list);
extern void gui_list_setselect (GUIItem *item);
extern GUIItem *gui_list_new (int x, int y, int w, int h);
/************************************************************************** /**************************************************************************
* gui windows * gui windows
@ -227,10 +183,6 @@ extern void gui_search_show ();
extern void gui_fav_show (); extern void gui_fav_show ();
extern void gui_mainmenu_show (); extern void gui_mainmenu_show ();
extern void gui_buttons_show (); extern void gui_buttons_show ();
extern char *gui_sfile_show (char *startpath);
extern void gui_config_show ();
extern void gpswin_show (); extern void gpswin_show ();
extern void wnd_routing_show ();
extern void wnd_mapcontext_show ();
#endif #endif

@ -1,97 +0,0 @@
/* $Id: gui_button.c,v 1.11 2013/04/03 21:52:27 steffen Exp $ */
/***************************************************************************
* gui_button.c
*
* Copyright (C) 2013 Steffen Pohle
* steffen@gulpe.de
***************************************************************************
* basic windows functions
***************************************************************************/
/*
* 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"
/****************************************************************************
* button
*/
void gui_button_draw (GUIItem *item) {
struct line_style ls;
GUIButton *button = NULL;
if (item == NULL || item->type != GUI_BUTTON) {
d_printf ("GUIButton %p not type GUIButton", item);
errorexit (-1);
}
button = (GUIButton *) item->data;
ls.width = 1.0;
ls.c = ls.borderc = color[COLOR_white][3];
// d_printf ("gui_button_draw \"%s\" %d,%d,%d,%d", button->caption, item->x, item->y, item->w, item->h);
draw_polygonstart ();
draw_polygonadd (item->x, item->y);
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);
gfx_draw_text (currentwin->screen, item->x + 2, item->y + 2, button->caption, button->textcol);
};
GUIItem *gui_button_new (char *caption, int x, int y, int w, int h) {
GUIItem *item = (GUIItem*) ml_malloc (sizeof (GUIItem) + sizeof (GUIButton) + POINTERALIGNMENT);
GUIButton *button = (GUIButton *) item->data;
memset (item, 0x0, sizeof (GUIItem) + sizeof (GUIButton) + POINTERALIGNMENT);
if (caption == NULL) button->caption[0] = 0;
else strncpy (button->caption, caption, GUI_TEXTLEN);
item->x = x;
item->y = y;
item->w = w;
item->h = h;
item->type = GUI_BUTTON;
button->col = &color[COLOR_white][1];
button->textcol = &color[COLOR_white][3];
button->callback_clicked = NULL;
button->func_draw = NULL;
return item;
};
int gui_button_event (GUIItem *item, GUIEvent *event) {
GUIButton *button = NULL;
if (item == NULL || item->type != GUI_BUTTON) {
d_printf ("GUIButton %p not type GUIButton", item);
errorexit (-1);
}
button = (GUIButton *) item->data;
if (button->callback_clicked != NULL && event->event == EGUI_MOUSEPRESSED) {
gui_set_focus (NULL);
button->callback_clicked (event->guiwin_mpos.x-item->x, event->guiwin_mpos.y-item->y);
}
return 1;
};

@ -1,95 +0,0 @@
/* $Id: gui_checkbox.c,v 1.3 2013/04/03 21:52:27 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 <http://www.gnu.org/licenses/>.
*/
#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 = 15;
item->h = 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);
}
d_printf ("checkbox:%s %d,%d,%d,%d %d,%d", checkbox->text, item->x, item->y, item->w, item->h, event->guiwin_mpos.x, event->guiwin_mpos.y);
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;
};

@ -1,165 +0,0 @@
/* $Id: gui_entry.c,v 1.18 2013/06/20 21:28:04 steffen Exp $ */
/***************************************************************************
* gui_entry.c
*
* Copyright (C) 2013 Steffen Pohle
* steffen@gulpe.de
***************************************************************************
* basic windows functions
***************************************************************************/
/*
* 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"
#include "utf8.h"
/****************************************************************************
* entry
*/
void gui_entry_draw (GUIItem *item) {
char text1[GUI_TEXTLEN];
char text2[GUI_TEXTLEN];
struct line_style ls;
GUIEntry *entry = NULL;
if (item) entry = (GUIEntry *) item->data;
else return;
// d_printf ("gui_entry curpos:%d len:%d", entry->curpos, strlen(entry->text));
// d_print_data (entry->text, strlen (entry->text)+1);
ls.width = 1.0;
if (currentwin->focus == (void*) item)
ls.c = ls.borderc = color[COLOR_white][3];
else
ls.c = ls.borderc = color[COLOR_white][2];
gfx_draw_line (currentwin->screen, item->x, item->y+item->h, item->x+item->w, item->y+item->h, ls);
gfx_draw_line (currentwin->screen, item->x, item->y+item->h, item->x, item->y+item->h-2, ls);
gfx_draw_line (currentwin->screen, item->x+item->w, item->y+item->h, item->x+item->w, item->y+item->h-2, ls);
if (entry->curpos >= strlen (entry->text)) {
entry->curpos = strlen (entry->text);
snprintf (text1, GUI_TEXTLEN, "%s|", entry->text);
}
else if (entry->curpos <= 0) {
entry->curpos = 0;
snprintf (text1, GUI_TEXTLEN, "|%s", entry->text);
}
else {
u8_strcpy (text1, entry->text, 0, entry->curpos);
u8_strcpy (text2, "|", 0, 1);
u8_strncat (text1, GUI_TEXTLEN, text2);
u8_strcpy (text2, entry->text, entry->curpos, u8_strlen (entry->text)-entry->curpos);
u8_strncat (text1, GUI_TEXTLEN, text2);
}
gfx_draw_text (currentwin->screen, item->x+2, item->y, text1, &color[COLOR_white][3]);
};
/*
* event handling
*/
int gui_entry_event (GUIItem *item, GUIEvent *event) {
char u8chr[12] = {0};
GUIEntry *entry = NULL;
if (item) entry = (GUIEntry *) item->data;
if (event->event == EGUI_MOUSEPRESSED) {
gui_set_focus (item);
gui_softkeyb_show (TRUE);
}
else if (event->event == EGUI_KEYCHAR) {
d_printf ("gui_entry curpos:%d key:%lx keychar:%lx", entry->curpos, event->key, event->keychar);
if (entry->curpos < 0) entry->curpos = 0;
if (entry->curpos > u8_strlen (entry->text)) entry->curpos = u8_strlen (entry->text);
if (event->key == 0x08) { // backspace
d_printf ("gui_entry:backspace");
if (entry->curpos > 0) {
u8_strdel (entry->text, entry->curpos-1, 1);
entry->curpos--;
}
}
else if (event->key == 0x7f) { // delete
d_printf ("gui_entry:delete");
if (entry->curpos >= 0 && entry->curpos-1 < u8_strlen (entry->text)) {
u8_strdel (entry->text, entry->curpos, 1);
}
}
else if (event->key == 0x1b) { // esc
d_printf ("gui_entry:esc");
if (entry->callback_esc) entry->callback_esc ();
}
else if (event->key == 0x0d) { // enter
d_printf ("gui_entry:enter");
if (entry->callback_enter) entry->callback_enter ();
}
else if (event->key == GUIKEY_LEFT) { // left
d_printf ("gui_entry:curpos--");
if (entry->curpos > 0) entry->curpos--;
}
else if (event->key == GUIKEY_RIGHT) { // right
d_printf ("gui_entry:curpos++");
if (entry->curpos < u8_strlen (entry->text)) entry->curpos++;
}
else if (event->keychar != 0) {
u8_encode (u8chr, event->keychar);
u8_strninsert (entry->text, GUI_TEXTLEN, u8chr, entry->curpos);
entry->curpos++;
}
}
currentwin->screen_changed = 1;
draw ();
return 1;
};
GUIItem *gui_entry_new (char *text, int x, int y, int w, int h) {
GUIItem *item = (GUIItem*) ml_malloc (sizeof (GUIItem) + sizeof (GUIEntry) + POINTERALIGNMENT);
GUIEntry *entry = NULL;
if (item) entry = (GUIEntry *) item->data;
if (text == NULL) entry->text[0] = 0;
else strncpy (entry->text, text, GUI_TEXTLEN);
item->x = x;
item->y = y;
item->w = w;
item->h = h;
item->type = GUI_ENTRY;
entry->callback_changed = NULL;
entry->callback_enter = NULL;
entry->callback_esc = NULL;
return item;
};
void gui_entry_settext (GUIItem *item, char *text) {
GUIEntry *entry = NULL;
if (item) entry = (GUIEntry *) item->data;
strncpy (entry->text, text, GUI_TEXTLEN);
entry->curpos = strlen (entry->text);
currentwin->screen_changed = 1;
};

@ -1,30 +0,0 @@
/* $Id: gui_image.c,v 1.1 2013/02/17 00:52:20 steffen Exp $ */
/***************************************************************************
* gui_image.c
*
* Copyright (C) 2013 Steffen Pohle
* steffen@gulpe.de
***************************************************************************
* basic windows functions
***************************************************************************/
/*
* 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"

@ -1,62 +0,0 @@
/* $Id: gui_label.c,v 1.3 2013/02/27 22:21:35 steffen Exp $ */
/***************************************************************************
* gui_label.c
*
* Copyright (C) 2013 Steffen Pohle
* steffen@gulpe.de
***************************************************************************
* basic windows functions
***************************************************************************/
/*
* 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"
/****************************************************************************
* label
*/
void gui_label_draw (GUIItem *item) {
GUILabel *label = NULL;
if (item) label = (GUILabel*) item->data;
struct line_style ls;
ls.width = 1.0;
ls.c = ls.borderc = color[COLOR_white][3];
gfx_draw_text (currentwin->screen, item->x, item->y, label->text, label->textcol);
};
GUIItem *gui_label_new (char *text, int x, int y) {
GUIItem *item = (GUIItem*) ml_malloc (sizeof (GUILabel) + sizeof (GUIItem) + POINTERALIGNMENT);
GUILabel *label = NULL;
if (item) label = (GUILabel*) item->data;
if (text == NULL) label->text[0] = 0;
else strncpy (label->text, text, GUI_TEXTLEN);
item->x = x;
item->y = y;
label->textcol = &color[COLOR_white][2];
item->type = GUI_LABEL;
return item;
};

@ -1,134 +0,0 @@
/* $Id: gui_list.c,v 1.13 2014/02/12 21:21:07 steffen Exp $ */
/***************************************************************************
* gui_list.c
*
* Copyright (C) 2013 Steffen Pohle
* steffen@gulpe.de
***************************************************************************
* basic windows functions
***************************************************************************/
/*
* 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"
#define GUI_ARROW_WIDTH 16
#define GUI_ARROW_HEIGHT 16
/****************************************************************************
* list
*/
void gui_list_draw (GUIItem *item) {
struct line_style ls;
int max, i, x, y, j;
GUIList *list = NULL;
if (item == NULL) return;
else list = (GUIList *) item->data;
ls.width = 1.0;
if (currentwin->focus == item)
ls.c = ls.borderc = color[COLOR_white][3];
else
ls.c = ls.borderc = color[COLOR_white][2];
gfx_draw_line (currentwin->screen, item->x, item->y, item->x+item->w, item->y, ls);
gfx_draw_line (currentwin->screen, item->x+item->w, item->y, item->x+item->w, item->y+item->h, ls);
gfx_draw_line (currentwin->screen, item->x+item->w, item->y+item->h, item->x, item->y+item->h, ls);
gfx_draw_line (currentwin->screen, item->x, item->y+item->h, item->x, item->y, ls);
/* find last max */
max = 0;
if (list->data == NULL) max = 0;
else for (max = 0; list->data[max] != NULL; max++);
/* range to display */
i = max - item->h/16;
if (i < list->vs) list->vs = i;
if (list->vs < 0) list->vs = 0;
for (i = list->vs; i < (list->vs + item->h/16) && i < max; i++) {
if (i == list->selected) gfx_draw_text (currentwin->screen, item->x + 5, item->y + 5 + 16 * (i - list->vs), list->data[i], &color[COLOR_red][2]);
else gfx_draw_text (currentwin->screen, item->x + 5, item->y + 5 + 16 * (i - list->vs), list->data[i], &color[COLOR_white][3]);
}
ls.c = ls.borderc = color[COLOR_white][3];
for (i = -1; i < 2; i += 2) {
if (i < 0) y = item->y + item->h;
else y = item->y;
x = item->x + item->w;
for (j = 0; j <= GUI_ARROW_WIDTH/2; j++) {
gfx_draw_line (currentwin->screen, x - GUI_ARROW_WIDTH/2, y, x-j, y + i*GUI_ARROW_HEIGHT, ls);
gfx_draw_line (currentwin->screen, x - GUI_ARROW_WIDTH/2 -j, y+ i*GUI_ARROW_HEIGHT, x-GUI_ARROW_WIDTH/2, y, ls);
}
}
};
/*
* event handling
*/
int gui_list_event (GUIItem *item, GUIEvent *event) {
int x = event->guiwin_mpos.x - item->x;
int y = event->guiwin_mpos.y - item->y;
int i;
GUIList *list = NULL;
static GUIItem *olditem = NULL;
if (item == NULL) return 0;
else list = (GUIList *) item->data;
/* set focus */
if (event->event == EGUI_MOUSEPRESSED) {
olditem = item;
}
else if (event->event == EGUI_MOUSERELEASED && olditem == item &&
x >= 0 && y >= 0 && x <= item->w && y <= item->h) {
gui_set_focus (item);
if (y <= GUI_ARROW_HEIGHT && x >= item->w - GUI_ARROW_WIDTH) list->vs--;
else if (y >= item->h - GUI_ARROW_HEIGHT && x >= item->w - GUI_ARROW_WIDTH) list->vs++;
else { /* select entry */
i = (y-5)/16 + list->vs;
list->selected = i;
if (list->callback_selectitem) list->callback_selectitem (i);
}
}
currentwin->screen_changed = 1;
draw ();
return 1;
};
GUIItem *gui_list_new (int x, int y, int w, int h) {
GUIItem *item = (GUIItem *) ml_malloc (sizeof (GUIList) + sizeof (GUIItem) + POINTERALIGNMENT);
GUIList *list = (GUIList *) item->data;
item->type = GUI_LIST;
item->x = x;
item->y = y;
item->w = w;
item->h = h;
list->selected = -1;
list->vs = 0;
list->callback_selectitem = NULL;
list->data = NULL;
return item;
};

@ -1,280 +0,0 @@
/* $Id: gui_softkeyboard.c,v 1.10 2013/06/18 22:24:21 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"
#include "utf8.h"
GUISoftkeyboard *softkeyb = NULL;
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_Y] = {
{ "qwertzuiopü",
"asdfghjklöä",
"yxcvbnm,.-/" },
{ "QWERTZUIOPÜ",
"ASDFGHIKLÖÄ",
"YXCVBNM;:+\\" },
{ "0123456789=",
"{([])} ",
"!\"§$%&<>~ " }};
int i, j, x, size;
/* 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++) {
char *str = line[i][j];
for (x = 0; x < GUI_SOFTKEYB_X; x++) {
softkeyb->keys[i][j][x] = u8_decode (str, &size);
str += size;
}
}
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][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) {
*x1 = 5 + (btnnr * (softkeyb->screen->width - 10)) / GUI_SOFTKEYB_X;
*x2 = 5 + ((btnnr + 1) * (softkeyb->screen->width - 10)) / GUI_SOFTKEYB_X;
*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) {
if (softkeyb->screen) gfx_img_free (softkeyb->screen);
softkeyb->screen = gfx_img_alloc (gfx_screensize.x, gfx_screensize.y * 0.8);
}
/* setup the lines... */
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_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_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);
u8_encode (c, 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 < 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]);
draw_rectangle (softkeyb->screen, x1, y1, x2, y2, ls);
switch (i) {
case (0):
snprintf (c, 16, _("<"));
break;
case (1):
snprintf (c, 16, _(">"));
break;
case (2):
snprintf (c, 16, _("SYM"));
break;
case (3):
snprintf (c, 16, _("SHIFT"));
break;
case (4):
snprintf (c, 16, _(" "));
break;
case (5):
snprintf (c, 16, _("Del"));
break;
case (6):
snprintf (c, 16, _("Enter"));
break;
case (7):
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->scr_mpos.x - softkeyb->offset.x, event->scr_mpos.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) {
d_printf ("softkey: %d %d %d", softkeyb->mode, j, i);
softkeyb->last_line = j;
softkeyb->last_col = i;
newevent.key = softkeyb->keys[softkeyb->mode][j][i];
newevent.keychar = softkeyb->keys[softkeyb->mode][j][i];
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);
}
else {
softkeyb->last_line = -1;
softkeyb->last_col = -1;
}
currentwin->screen_changed = 1;
draw ();
return 1;
}
}
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) {
softkeyb->last_line = 3;
softkeyb->last_col = i;
switch (i) {
case (0):
newevent.key = GUIKEY_LEFT;
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);
break;
case (1):
newevent.key = GUIKEY_RIGHT;
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);
break;
case (2):
softkeyb->mode = (softkeyb->mode == GUI_SOFTKEYB_MODE_SYMBOL) ? 0 : GUI_SOFTKEYB_MODE_SYMBOL;
break;
case (3):
softkeyb->mode = (softkeyb->mode == GUI_SOFTKEYB_MODE_SHIFT) ? 0 : GUI_SOFTKEYB_MODE_SHIFT;
break;
case (4):
newevent.key = ' ';
newevent.keychar = u8_decode (" ", NULL);
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 (5):
newevent.key = 0x08;
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 (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 ();
return 1;
break;
}
}
else {
softkeyb->last_line = -1;
softkeyb->last_col = -1;
}
}
}
return 0;
};

@ -1,159 +0,0 @@
/* $Id: gui_window.c,v 1.9 2013/06/18 22:24:21 steffen Exp $ */
/***************************************************************************
* gui_window.c
*
* Copyright (C) 2013 Steffen Pohle
* steffen@gulpe.de
***************************************************************************
* basic windows functions
***************************************************************************/
/*
* 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"
/*
* reset all window data, do not allocate anything
*/
void gui_window_new (GUIWindow *win, int w, int h, char *title) {
int i;
for (i = 0; i < GUI_MAX_ITEM; i++) win->items[i] = NULL;
if (title == NULL) win->title[0] = 0;
else strncpy (win->title, title, GUI_TEXTLEN);
win->screen = NULL;
win->screen_changed = 1;
win->h = h;
win->w = w;
win->focus = NULL;
d_printf ("gui_window_new [%s] %p width:%d height:%d", title, win, w, h);
};
/*
* closes the window, but does not free the memory.
*/
void gui_window_close (GUIWindow *win) {
d_printf ("gui_window_close [%s] %p", win->title, win);
/* delete screen so we know it's disabled.. */
if (win->screen) gfx_img_free (win->screen);
win->screen = NULL;
win->screen_changed = 1;
if (currentwin == win) currentwin = NULL;
};
/*
* add pointer to item to the window data structure..
* the items will have to be hold inside the application
*/
void gui_window_item_add (GUIWindow *win, GUIItem *item) {
int i, ifree = -1;
if (item == NULL || win == NULL) return;
for (i = 0; i < GUI_MAX_ITEM; i++) {
if (win->items[i] == NULL && ifree == -1) ifree = i;
if (win->items[i] == item) {
d_printf ("item already added to item list.");
ifree = i;
}
}
if (ifree == -1) {
d_printf ("no free item slot");
exit (1);
}
win->items[ifree] = item;
win->screen_changed = 1;
d_printf ("gui_window_item_add win:%p ifree:%d item:%p", win, ifree, item);
};
/*
* Handle gui events within the gui.
*/
int gui_window_event (GUIWindow *win, GUIEvent *event) {
GUIItem *item = win->focus;
int i;
if (win->event_called) return -1;
win->event_called = 1;
/* check if softkeyb is opened */
if ((softkeyb && softkeyb->enabled && softkeyb->screen)
&& (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->scr_mpos.x && x2 >= event->scr_mpos.x
&& y1 <= event->scr_mpos.y && y2 >= event->scr_mpos.y) {
gui_softkeyb_event (event);
win->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], event->guiwin_mpos))
item = currentwin->items[i];
if (item) switch (item->type) {
case (GUI_BUTTON):
gui_button_event (item, event);
win->event_called = 0;
return 1;
break;
case (GUI_ENTRY):
gui_entry_event (item, event);
win->event_called = 0;
return 1;
break;
case (GUI_LIST):
gui_list_event (item, event);
win->event_called = 0;
return 1;
break;
case (GUI_CHECKBOX):
gui_checkbox_event (item, event);
win->event_called = 0;
return 1;
break;
default:
break;
}
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;
};

@ -3,7 +3,7 @@ include ../Makefile.rules
OBJBASE = favorites.o main.o OBJBASE = favorites.o main.o
ifeq "$(GTKVERSION)" "1" ifeq "$(GTKVERSION)" "1"
GTK = linux_gps.o gps.o routing.o gui_selectdir.o gui_selectfile.o gui_config.o gui_buttons.o gui_favorites.o gui_mainmenu.o gui_search.o guiw_gpsfile.o wnd_routing.o wnd_mapcontext.o GTK = linux_gps.o gps.o routing.o gui_buttons.o gui_favorites.o gui_mainmenu.o gui_search.o guiw_gpsfile.o
endif endif
ifeq "$(NCURSESVERSION)" "1" ifeq "$(NCURSESVERSION)" "1"
@ -11,15 +11,15 @@ CURSES = ncurses_main.o
endif endif
ifeq "$(WINVERSION)" "1" ifeq "$(WINVERSION)" "1"
WIN = gps.o routing.o gui_buttons.o gui_config.o gui_selectdir.o gui_selectfile.o gui_favorites.o gui_mainmenu.o gui_search.o guiw_gpsfile.o wnd_routing.o wnd_mapcontext.o WIN = gps.o routing.o gui_buttons.o gui_favorites.o gui_mainmenu.o gui_search.o guiw_gpsfile.o
endif endif
ifeq "$(WINCEVERSION)" "1" ifeq "$(WINCEVERSION)" "1"
WIN = gps.o routing.o gui_buttons.o gui_config.o gui_favorites.o gui_selectdir.o gui_selectfile.o gui_mainmenu.o gui_search.o guiw_gpsfile.o wnd_routing.o wnd_mapcontext.o WIN = gps.o routing.o gui_buttons.o gui_favorites.o gui_mainmenu.o gui_search.o guiw_gpsfile.o
endif endif
ifeq "$(SDLGLVERSION)" "1" ifeq "$(SDLGLVERSION)" "1"
SDLGL = linux_gps.o gps.o routing.o gui_config.o gui_buttons.o gui_favorites.o gui_selectdir.o gui_selectfile.o gui_mainmenu.o gui_search.o guiw_gpsfile.o wnd_routing.o wnd_mapcontext.o SDLGL = linux_gps.o gps.o routing.o gui_buttons.o gui_favorites.o gui_mainmenu.o gui_search.o guiw_gpsfile.o
endif endif

@ -47,13 +47,9 @@ struct gps_data gpspos;
struct gps_data gpsposvalid; struct gps_data gpsposvalid;
#if !defined(__MINGW32CE__) && !defined(_WIN32_WCE) && !defined(__MINGW32__) #if !defined(__MINGW32CE__) && !defined(_WIN32_WCE) && !defined(__MINGW32__)
#if defined ANDROID char gpsdevice[GPS_DEVICELEN] = "serial:/dev/rfcomm0";
char gpsdevice[GPS_DEVICELEN] = "android:";
#else
char gpsdevice[GPS_DEVICELEN] = "serial:/dev/rfcomm0";
#endif
#else #else
char gpsdevice[GPS_DEVICELEN] = "serial:com1,38400"; char gpsdevice[GPS_DEVICELEN] = "serial:com1,38400";
#endif #endif
int gpsflags = GPSF_LOG; int gpsflags = GPSF_LOG;
@ -391,7 +387,6 @@ float gps_getlat (char *text) {
int gps_get_devicetype () { int gps_get_devicetype () {
if (strncmp (gpsdevice, "serial:", 7) == 0) return GPS_T_SERIAL; if (strncmp (gpsdevice, "serial:", 7) == 0) return GPS_T_SERIAL;
else if (strncmp (gpsdevice, "file:", 5) == 0) return GPS_T_FILE; else if (strncmp (gpsdevice, "file:", 5) == 0) return GPS_T_FILE;
else if (strncmp (gpsdevice, "android:", 8) == 0) return GPS_T_ANDROID;
else return GPS_T_NONE; else return GPS_T_NONE;
}; };
@ -438,9 +433,6 @@ void gps_start () {
gpslasttype = gps_get_devicetype (); gpslasttype = gps_get_devicetype ();
if (gpslasttype == GPS_T_SERIAL) error = gps_serial_device_open (); if (gpslasttype == GPS_T_SERIAL) error = gps_serial_device_open ();
else if (gpslasttype == GPS_T_FILE) error = gps_file_device_open (); else if (gpslasttype == GPS_T_FILE) error = gps_file_device_open ();
#ifdef ANDROID
else if (gpslasttype == GPS_T_ANDROID) error = gps_android_device_open ();
#endif
else error = 0; else error = 0;
if (error) { if (error) {
@ -455,16 +447,12 @@ void gps_start () {
} }
gpsdatalen = 0; gpsdatalen = 0;
draw ();
}; };
void gps_stop () { void gps_stop () {
d_printf ("%s:%d gps_stop", __FILE__, __LINE__); d_printf ("%s:%d gps_stop", __FILE__, __LINE__);
if (gpslasttype == GPS_T_SERIAL) gps_serial_device_close (); if (gpslasttype == GPS_T_SERIAL) gps_serial_device_close ();
#ifdef ANDROID
else if (gpslasttype == GPS_T_ANDROID) gps_android_device_close ();
#endif
else if (gpslasttype == GPS_T_FILE) gps_file_device_close (); else if (gpslasttype == GPS_T_FILE) gps_file_device_close ();
gpsstatus = 0; gpsstatus = 0;
gpsdatalen = 0; gpsdatalen = 0;
@ -636,8 +624,6 @@ struct gps_data *gps_loop () {
setlocale(LC_ALL, "C"); setlocale(LC_ALL, "C");
#endif #endif
d_printf ("gps_loop");
gpspos.valid = gpsposvalid.valid = 0; gpspos.valid = gpsposvalid.valid = 0;
call = time (NULL); call = time (NULL);
/* /*
@ -648,26 +634,19 @@ struct gps_data *gps_loop () {
/* /*
* check if gps is open and fillup the buffer * check if gps is open and fillup the buffer
*/ */
if (gpsstatus <= 0) { if (gpsstatus <= 0) return NULL;
d_printf ("gps loop : status:%d", gpsstatus);
return NULL;
}
if (gpslasttype == GPS_T_SERIAL) dataread = gps_serial_device_read (gpsdata + gpsdatalen, GPS_INBUFSIZE - gpsdatalen); if (gpslasttype == GPS_T_SERIAL) dataread = gps_serial_device_read (gpsdata + gpsdatalen, GPS_INBUFSIZE - gpsdatalen);
#ifdef ANDROID
else if (gpslasttype == GPS_T_ANDROID) dataread = gps_android_device_read (gpsdata + gpsdatalen, GPS_INBUFSIZE - gpsdatalen);
#endif
else if (gpslasttype == GPS_T_FILE) dataread = gps_file_device_read (gpsdata + gpsdatalen, GPS_INBUFSIZE - gpsdatalen); else if (gpslasttype == GPS_T_FILE) dataread = gps_file_device_read (gpsdata + gpsdatalen, GPS_INBUFSIZE - gpsdatalen);
else dataread = -1; else dataread = -1;
if (dataread < 0) { if (dataread < 0) {
d_printf ("gps_loop data read < 0");
gps_stop(); gps_stop();
gpsstatus = -1; gpsstatus = -1;
return NULL;
} }
else if (dataread+gpsdatalen > GPS_INBUFSIZE) { else if (dataread+gpsdatalen > GPS_INBUFSIZE) {
d_printf ("%s:%d gps_loop: ERROR datapos(%d) > GPS_INBUFSIZE(%d)", __FILE__, __LINE__, gpsdatalen + dataread, GPS_INBUFSIZE); d_printf ("%s:%d gps_loop: ERROR datapos(%d) > GPS_INBUFSIZE(%d)", __FILE__, __LINE__, gpsdatalen + dataread, GPS_INBUFSIZE);
gpsdatalen = GPS_INBUFSIZE; gpsdatalen = GPS_INBUFSIZE;
gps_stop ();
} }
else gpsdatalen += dataread; else gpsdatalen += dataread;
@ -688,7 +667,6 @@ struct gps_data *gps_loop () {
line[i] = 0; line[i] = 0;
/* write into logfile */ /* write into logfile */
// d_printf ("gps line:'%s'", line);
if (i > 0) { if (i > 0) {
if (gpslasttype != GPS_T_FILE && gpsflags & GPSF_LOG) gps_save_log (logfile, line); if (gpslasttype != GPS_T_FILE && gpsflags & GPSF_LOG) gps_save_log (logfile, line);
if (gps_convert_line (line, &gpspos) == 0) gpspos.valid = 0; if (gps_convert_line (line, &gpspos) == 0) gpspos.valid = 0;

@ -37,7 +37,7 @@
#define GPS_DEVICELEN 256 #define GPS_DEVICELEN 256
#define GPS_ROUTEPOILEN 128 #define GPS_ROUTEPOILEN 128
#define GPS_INBUFSIZE 2048 #define GPS_INBUFSIZE 128
#define GPS_LINELEN 100 #define GPS_LINELEN 100
#define GPS_MAXSAT 32 #define GPS_MAXSAT 32
@ -50,7 +50,6 @@
enum { enum {
GPS_T_NONE, GPS_T_NONE,
GPS_T_SERIAL, GPS_T_SERIAL,
GPS_T_ANDROID,
GPS_T_FILE GPS_T_FILE
}; };
@ -150,11 +149,5 @@ extern void gps_file_set_pos (int newpos);
extern int gps_file_get_pos (); extern int gps_file_get_pos ();
extern int gps_file_get_size (); extern int gps_file_get_size ();
#ifdef ANDROID
extern int gps_android_device_open ();
extern void gps_android_device_close ();
extern int gps_android_device_read (char *ptr, int ptrsize);
#endif
#endif #endif

@ -38,13 +38,8 @@ enum {
static GUIWindow wbutton = {0}; static GUIWindow wbutton = {0};
static GUIItem *btn_zoomin = NULL,
*btn_zoomout = NULL,
*btn_gps = NULL,
*btn_menu = NULL,
*btn_fav = NULL;
void gui_buttons_closecallback (); void gui_buttons_closecallback ();
void gui_buttons_draw (GUIItem *btn); void gui_buttons_draw (GUIButton *btn);
void gui_buttons_zoomin(); void gui_buttons_zoomin();
void gui_buttons_zoomout(); void gui_buttons_zoomout();
void gui_buttons_gps(); void gui_buttons_gps();
@ -53,49 +48,62 @@ void gui_buttons_fav();
void gui_buttons_show () { void gui_buttons_show () {
d_printf ("GUI: buttons show screen:%p", wbutton.screen);
if (wbutton.screen == NULL) guiwindow_new (&wbutton, 192, 32);
wbutton.screen_changed = 1; wbutton.screen_changed = 1;
wbutton.callback_close = (void*)gui_buttons_closecallback; wbutton.callback_close = (void*)gui_buttons_closecallback;
wbutton.style = WGUI_S_VCENTER | WGUI_S_HTOP; wbutton.style = WGUI_S_VCENTER | WGUI_S_HTOP;
/* add buttons */ /* add buttons */
if (btn_zoomin == NULL) { strncpy (wbutton.buttons[0].caption, _("+"), GUI_TEXTLEN);
btn_zoomin = gui_button_new (_("+"), 1, 1, 30, 30); wbutton.buttons[0].callback_clicked = (void*)gui_buttons_zoomin;
GUI_BUTTON_T(btn_zoomin)->callback_clicked = (void*)gui_buttons_zoomin; wbutton.buttons[0].callback_draw = (void*)gui_buttons_draw;
GUI_BUTTON_T(btn_zoomin)->func_draw = (void*)gui_buttons_draw; wbutton.buttons[0].id = BTNWIN_ZIN;
} wbutton.buttons[0].w = 31;
wbutton.buttons[0].h = 31;
if (btn_zoomout == NULL) { wbutton.buttons[0].x = 0;
btn_zoomout = gui_button_new (_("-"), 41, 1, 30, 30); wbutton.buttons[0].y = 0;
GUI_BUTTON_T(btn_zoomout)->callback_clicked = (void*)gui_buttons_zoomout;
GUI_BUTTON_T(btn_zoomout)->func_draw = (void*)gui_buttons_draw;
} strncpy (wbutton.buttons[1].caption, _("-"), GUI_TEXTLEN);
wbutton.buttons[1].callback_clicked = (void*)gui_buttons_zoomout;
if (btn_gps == NULL) { wbutton.buttons[1].callback_draw = (void*)gui_buttons_draw;
btn_gps = gui_button_new (_("GPS"), 81, 1, 30, 30); wbutton.buttons[1].id = BTNWIN_ZOUT;
GUI_BUTTON_T(btn_gps)->callback_clicked = (void*)gui_buttons_gps; wbutton.buttons[1].w = 31;
GUI_BUTTON_T(btn_gps)->func_draw = (void*)gui_buttons_draw; wbutton.buttons[1].h = 31;
} wbutton.buttons[1].x = 40;
wbutton.buttons[1].y = 0;
if (btn_menu == NULL) {
btn_menu = gui_button_new (_("M"), 121, 1, 30, 30);
GUI_BUTTON_T(btn_menu)->callback_clicked = (void*)gui_buttons_menu; strncpy (wbutton.buttons[2].caption, _("GPS"), GUI_TEXTLEN);
GUI_BUTTON_T(btn_menu)->func_draw = (void*)gui_buttons_draw; wbutton.buttons[2].callback_clicked = (void*)gui_buttons_gps;
} wbutton.buttons[2].callback_draw = (void*)gui_buttons_draw;
wbutton.buttons[2].id = BTNWIN_GPS;
if (btn_fav == NULL) { wbutton.buttons[2].w = 31;
btn_fav = gui_button_new (_("F"), 161, 1, 30, 30); wbutton.buttons[2].h = 31;
GUI_BUTTON_T(btn_fav)->callback_clicked = (void*)gui_buttons_fav; wbutton.buttons[2].x = 80;
GUI_BUTTON_T(btn_fav)->func_draw = (void*)gui_buttons_draw; wbutton.buttons[2].y = 0;
}
if (wbutton.screen == NULL) { strncpy (wbutton.buttons[3].caption, _("M"), GUI_TEXTLEN);
gui_window_new (&wbutton, 192, 32, NULL); wbutton.buttons[3].callback_clicked = (void*)gui_buttons_menu;
gui_window_item_add (&wbutton, btn_fav); wbutton.buttons[3].callback_draw = (void*)gui_buttons_draw;
gui_window_item_add (&wbutton, btn_zoomin); wbutton.buttons[3].id = BTNWIN_MENU;
gui_window_item_add (&wbutton, btn_zoomout); wbutton.buttons[3].w = 31;
gui_window_item_add (&wbutton, btn_gps); wbutton.buttons[3].h = 31;
gui_window_item_add (&wbutton, btn_menu); wbutton.buttons[3].x = 120;
} wbutton.buttons[3].y = 0;
strncpy (wbutton.buttons[4].caption, _("Fav"), GUI_TEXTLEN);
wbutton.buttons[4].callback_clicked = (void*)gui_buttons_fav;
wbutton.buttons[4].callback_draw = (void*)gui_buttons_draw;
wbutton.buttons[4].id = BTNWIN_FAV;
wbutton.buttons[4].w = 31;
wbutton.buttons[4].h = 31;
wbutton.buttons[4].x = 160;
wbutton.buttons[4].y = 0;
gui_show (&wbutton); gui_show (&wbutton);
}; };
@ -104,19 +112,19 @@ void gui_buttons_show () {
void gui_buttons_closecallback () { void gui_buttons_closecallback () {
d_printf ("GUI: buttons close"); d_printf ("GUI: buttons close");
gui_window_close (&wbutton); guiwindow_close (&wbutton);
}; };
void gui_buttons_draw (GUIItem *btn) { void gui_buttons_draw (GUIButton *btn) {
int j; int j;
if (btn == btn_gps) { if (btn->id == BTNWIN_GPS) {
j = gps_isrunning (); j = gps_isrunning ();
if (j == 0) GUI_BUTTON_T(btn)->col = &color[COLOR_white][2]; if (j == 0) btn->col = &color[COLOR_white][2];
else if (j < 0) GUI_BUTTON_T(btn)->col = &color[COLOR_red][2]; else if (j < 0) btn->col = &color[COLOR_red][2];
else if (view_flags & DRAW_GPSFOLLOW) GUI_BUTTON_T(btn)->col = &color[COLOR_green][3]; else if (view_flags & DRAW_GPSFOLLOW) btn->col = &color[COLOR_green][3];
else GUI_BUTTON_T(btn)->col = &color[COLOR_green][2]; else btn->col = &color[COLOR_green][2];
} }
gui_button_draw (btn); gui_button_draw (btn);
@ -137,6 +145,7 @@ void gui_buttons_zoomout() {
void gui_buttons_gps() { void gui_buttons_gps() {
if (gps_isrunning () <= 0) { if (gps_isrunning () <= 0) {
gps_start (); gps_start ();
main_wnd_update();
} }
else { else {
if (view_flags & DRAW_GPSFOLLOW) { if (view_flags & DRAW_GPSFOLLOW) {

@ -1,177 +0,0 @@
/* %Id: Exp $ */
/***************************************************************************
* gui_config.c
*
* Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
*/
#include "osmroute.h"
#include "draw.h"
#include "gui.h"
#include "system.h"
void gui_config_close ();
void gui_config_seldir ();
void gui_config_gpsfile ();
void gui_config_gpslist (int nr);
void gui_config_checkbox_changed ();
GUIWindow wcfg = {0};
GUIItem *map_path = NULL;
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 *cb_softkeyb = NULL;
GUIItem *wcfg_close = NULL;
GUIItem *label1 = NULL;
GUIItem *label2 = NULL;
char gpscfg_dev[8][LEN_FILENAME] = {
#ifdef ANDROID
"android:",
#else
"serial:/dev/rfcomm0",
#endif
"serial:com1,38400",
"serial:com1,4800",
"",
"",
"",
"",
""};
char *gpscfg_dev_ptr[8] = {
gpscfg_dev[0],
gpscfg_dev[1],
gpscfg_dev[2],
NULL,
NULL,
NULL,
NULL,
NULL
};
void gui_config_show () {
if (wcfg.screen == NULL) gui_window_new (&wcfg, 220, 280, _("Config"));
wcfg.screen_changed = 1;
wcfg.style = WGUI_S_VCENTER | WGUI_S_HCENTER;
if (label1 == NULL) label1 = gui_label_new (_("mapdata path:"), 5, 20);
gui_window_item_add (&wcfg, label1);
if (map_path == NULL) map_path = gui_entry_new (cfg.mappath, 10, 36, 150, 20);
gui_window_item_add (&wcfg, map_path);
if (map_seldir == NULL) map_seldir = gui_button_new (_("Browse"), 170, 36, 40, 20);
GUI_BUTTON_T (map_seldir)->callback_clicked = gui_config_seldir;
gui_window_item_add (&wcfg, map_seldir);
if (label2 == NULL) label2 = gui_label_new (_("gps device:"), 5, 66);
gui_window_item_add (&wcfg, label2);
if (gps_device == NULL) gps_device = gui_entry_new (cfg.gps_device, 10, 82, 150, 20);
gui_window_item_add (&wcfg, gps_device);
if (gps_list == NULL) gps_list = gui_list_new (10, 112, 150, 60);
GUI_LIST_T (gps_list)->callback_selectitem = gui_config_gpslist;
GUI_LIST_T (gps_list)->data = gpscfg_dev_ptr;
gui_window_item_add (&wcfg, gps_list);
if (gps_file == NULL) gps_file = gui_button_new (_("File"), 170, 112, 40, 20);
GUI_BUTTON_T (gps_file)->callback_clicked = gui_config_gpsfile;
gui_window_item_add (&wcfg, gps_file);
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);
GUI_CHECKBOX_T (log_file)->callback_changed = gui_config_checkbox_changed;
if (cb_debug == NULL)
cb_debug = gui_checkbox_new (_("Debug"), cfg.debug, 5, 200);
gui_window_item_add (&wcfg, cb_debug);
GUI_CHECKBOX_T (cb_debug)->callback_changed = gui_config_checkbox_changed;
if (cb_softkeyb == NULL)
cb_softkeyb = gui_checkbox_new (_("Softkeyboard"), cfg.softkeyboard, 100, 200);
gui_window_item_add (&wcfg, cb_softkeyb);
GUI_CHECKBOX_T (cb_softkeyb)->callback_changed = gui_config_checkbox_changed;
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);
gui_show (&wcfg);
};
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);
gui_config_checkbox_changed ();
gui_close ();
map_clear ();
map_init ();
draw_redrawmap ();
};
void gui_config_checkbox_changed () {
if ((cfg.debug = GUI_CHECKBOX_T(cb_debug)->checked)) SETFLAG(view_flags, DRAW_DEBUG);
else DELFLAG(view_flags, DRAW_DEBUG);
cfg.softkeyboard = GUI_CHECKBOX_T(cb_softkeyb)->checked;
if (GUI_CHECKBOX_T(log_file)->checked) cfg.gps_flags |= GPSF_LOG;
else cfg.gps_flags &= (0x0FFFF-GPSF_LOG);
if (cfg.gps_flags) SETFLAG(gpsflags, GPSF_LOG);
else DELFLAG(gpsflags, GPSF_LOG);
};
void gui_config_gpslist (int nr) {
d_printf ("select nr:%d", nr);
if (nr >= 0 && nr < 8)
gui_entry_settext (gps_device, gpscfg_dev[nr]);
};
void gui_config_seldir () {
char *new_dir = NULL;
new_dir = gui_sdir_show (GUI_ENTRY_T(map_path)->text);
d_printf ("new_dir:%s", new_dir);
gui_entry_settext (map_path, new_dir);
d_printf ("mapdir:%s", GUI_ENTRY_T(map_path)->text);
};
void gui_config_gpsfile () {
char *new_file = NULL;
char text[LEN_FILENAME];
d_printf ("select gps file...");
new_file = gui_sfile_show ("");
if (new_file != NULL) {
snprintf (text, LEN_FILENAME, "file:%s", new_file);
gui_entry_settext (gps_device, text);
d_printf ("gpsdevice:%s", GUI_ENTRY_T(gps_device)->text);
}
};

@ -28,6 +28,17 @@
#include "memoryleak.h" #include "memoryleak.h"
#include "system.h" #include "system.h"
enum {
FAVWIN_UNDEF = 0,
FAVWIN_LIST,
FAVWIN_ADD,
FAVWIN_REN,
FAVWIN_DEL,
FAVWIN_NAME,
FAVWIN_CLOSE
};
void gui_fav_close (); void gui_fav_close ();
void gui_fav_add (); void gui_fav_add ();
void gui_fav_del (); void gui_fav_del ();
@ -39,18 +50,86 @@ void gui_fav_selitem (int nr);
void gui_fav_fl_create (); void gui_fav_fl_create ();
void gui_fav_fl_free (); void gui_fav_fl_free ();
GUIItem *favlist = NULL; GUIList *fav_list = NULL;
GUIItem *faventry_name = NULL; GUIEntry *fav_name = NULL;
GUIItem *favbtn_close = NULL;
GUIItem *favbtn_add = NULL;
GUIItem *favbtn_ren = NULL;
GUIItem *favbtn_del = NULL;
char **fl_array = NULL; // array to all elements char **fl_array = NULL; // array to all elements
int fl_array_cnt = 0; int fl_array_cnt = 0;
static GUIWindow wfav = {0}; static GUIWindow wfav = {0};
void gui_fav_show () {
int btn = 0;
fav_new ();
fav_load (fav_getfilename());
if (wfav.screen == NULL) guiwindow_new (&wfav, 220, 240);
wfav.screen_changed = 1;
wfav.callback_close = (void*)gui_fav_callback_close;
wfav.screen_changed = 1;
wfav.style = WGUI_S_VCENTER | WGUI_S_HCENTER;
strncpy (wfav.title, _("Favorites"), GUI_TEXTLEN);
/* favotires buttons */
strncpy (wfav.buttons[btn].caption, _("Close"), GUI_TEXTLEN);
wfav.buttons[btn].callback_clicked = (void*)gui_fav_close;
wfav.buttons[btn].id = FAVWIN_CLOSE;
wfav.buttons[btn].w = 60;
wfav.buttons[btn].h = 20;
wfav.buttons[btn].x = 5;
wfav.buttons[btn].y = 210;
strncpy (wfav.buttons[++btn].caption, _("Add"), GUI_TEXTLEN);
wfav.buttons[btn].callback_clicked = (void*)gui_fav_add;
wfav.buttons[btn].id = FAVWIN_ADD;
wfav.buttons[btn].w = 60;
wfav.buttons[btn].h = 20;
wfav.buttons[btn].x = 5;
wfav.buttons[btn].y = 15;
strncpy (wfav.buttons[++btn].caption, _("Del"), GUI_TEXTLEN);
wfav.buttons[btn].callback_clicked = (void*)gui_fav_del;
wfav.buttons[btn].id = FAVWIN_DEL;
wfav.buttons[btn].w = 60;
wfav.buttons[btn].h = 20;
wfav.buttons[btn].x = 70;
wfav.buttons[btn].y = 15;
strncpy (wfav.buttons[++btn].caption, _("Ren"), GUI_TEXTLEN);
wfav.buttons[btn].callback_clicked = (void*)gui_fav_ren;
wfav.buttons[btn].id = FAVWIN_REN;
wfav.buttons[btn].w = 60;
wfav.buttons[btn].h = 20;
wfav.buttons[btn].x = 135;
wfav.buttons[btn].y = 15;
/* add the list */
btn = 0;
wfav.lists[btn].callback_selectitem = (void*)gui_fav_selitem;
wfav.lists[btn].id = FAVWIN_LIST;
wfav.lists[btn].w = 210;
wfav.lists[btn].h = 130;
wfav.lists[btn].x = 5;
wfav.lists[btn].y = 45;
fav_list = &wfav.lists[btn];
/* add entry */
btn = 0;
wfav.entrys[btn].id = FAVWIN_NAME;
wfav.entrys[btn].w = 210;
wfav.entrys[btn].h = 20;
wfav.entrys[btn].x = 5;
wfav.entrys[btn].y = 180;
fav_name = &wfav.entrys[btn];
fav_name->text[0] = 0;
gui_fav_refresh ();
gui_show (&wfav);
};
void gui_fav_close () { void gui_fav_close () {
gui_close (); gui_close ();
}; };
@ -58,9 +137,9 @@ void gui_fav_close () {
void gui_fav_add () { void gui_fav_add () {
struct favorite f; struct favorite f;
if (GUI_ENTRY_T(faventry_name)->text[0] == 0) return; if (fav_name->text[0] == 0) return;
d_printf ("gui_fav_add: '%s'", GUI_ENTRY_T(faventry_name)->text); d_printf ("gui_fav_add: '%s'", fav_name->text);
strncpy (f.name, GUI_ENTRY_T(faventry_name)->text, FAV_NAME_LEN); strncpy (f.name, fav_name->text, FAV_NAME_LEN);
f.pos.lon = view_lon; f.pos.lon = view_lon;
f.pos.lat = view_lat; f.pos.lat = view_lat;
fav_add (-1, &f); fav_add (-1, &f);
@ -69,28 +148,28 @@ void gui_fav_add () {
void gui_fav_del () { void gui_fav_del () {
if (GUI_LIST_T(favlist)->selected < 0) return; if (fav_list->selected < 0) return;
fav_del (GUI_LIST_T(favlist)->selected); fav_del (fav_list->selected);
gui_fav_refresh (); gui_fav_refresh ();
}; };
void gui_fav_ren () { void gui_fav_ren () {
if (GUI_LIST_T(favlist)->selected < 0 || GUI_ENTRY_T(faventry_name)->text[0] == 0) return; if (fav_list->selected < 0 || fav_name->text[0] == 0) return;
strncpy (favorites[GUI_LIST_T(favlist)->selected].name, GUI_ENTRY_T(faventry_name)->text, FAV_NAME_LEN); strncpy (favorites[fav_list->selected].name, fav_name->text, FAV_NAME_LEN);
gui_fav_refresh (); gui_fav_refresh ();
}; };
void gui_fav_selitem (int nr) { void gui_fav_selitem (int nr) {
if (nr < favorites_cnt) { if (nr < favorites_cnt) {
strncpy (GUI_ENTRY_T(faventry_name)->text, favorites[nr].name, GUI_TEXTLEN); strncpy (fav_name->text, favorites[nr].name, GUI_TEXTLEN);
view_lon = favorites[nr].pos.lon; view_lon = favorites[nr].pos.lon;
view_lat = favorites[nr].pos.lat; view_lat = favorites[nr].pos.lat;
gui_close (); gui_close ();
draw_del_flag (DRAW_GPSFOLLOW); draw_del_flag (DRAW_GPSFOLLOW);
} }
else GUI_ENTRY_T(faventry_name)->text[0] = 0; else fav_name->text[0] = 0;
}; };
@ -102,8 +181,8 @@ void gui_fav_callback_close () {
void gui_fav_refresh () { void gui_fav_refresh () {
gui_fav_fl_create (); gui_fav_fl_create ();
GUI_ENTRY_T(faventry_name)->text[0] = 0; fav_name->text[0] = 0;
GUI_LIST_T(favlist)->data = fl_array; fav_list->data = fl_array;
}; };
@ -129,52 +208,3 @@ void gui_fav_fl_free () {
fl_array_cnt = 0; fl_array_cnt = 0;
}; };
void gui_fav_show () {
fav_new ();
fav_load (fav_getfilename());
if (wfav.screen == NULL) gui_window_new (&wfav, 220, 240, _("Favorites"));
wfav.callback_close = (void*)gui_fav_callback_close;
wfav.screen_changed = 1;
wfav.style = WGUI_S_VCENTER | WGUI_S_HCENTER;
/* favotires buttons */
if (favbtn_close == NULL) {
favbtn_close = gui_button_new (_("Close"), 5, 210, 60, 20);
GUI_BUTTON_T(favbtn_close)->callback_clicked = (void*)gui_fav_close;
}
if (favbtn_add == NULL) {
favbtn_add = gui_button_new (_("Add"), 5, 15, 60, 20);
GUI_BUTTON_T(favbtn_add)->callback_clicked = (void*)gui_fav_add;
}
if (favbtn_del == NULL) {
favbtn_del = gui_button_new (_("Del"), 70, 15, 60, 20);
GUI_BUTTON_T(favbtn_del)->callback_clicked = (void*)gui_fav_ren;
}
if (favbtn_ren == NULL) {
favbtn_ren = gui_button_new (_("Ren"), 135, 15, 60, 20);
GUI_BUTTON_T(favbtn_ren)->callback_clicked = (void*)gui_fav_ren;
}
if (favlist == NULL) {
favlist = gui_list_new (5, 45, 210, 130);
GUI_LIST_T(favlist)->callback_selectitem = (void*)gui_fav_selitem;
}
if (faventry_name == NULL) {
faventry_name = gui_entry_new (NULL, 5, 180, 210, 20);
}
gui_window_item_add (&wfav, faventry_name);
gui_window_item_add (&wfav, favlist);
gui_window_item_add (&wfav, favbtn_ren);
gui_window_item_add (&wfav, favbtn_del);
gui_window_item_add (&wfav, favbtn_add);
gui_window_item_add (&wfav, favbtn_close);
gui_fav_refresh ();
gui_show (&wfav);
};

@ -1,4 +1,3 @@
/* $Id: gui_mainmenu.c,v 1.15 2014/03/06 22:21:46 steffen Exp $ */
/*************************************************************************** /***************************************************************************
* gui_mainmenu.c * gui_mainmenu.c
* *
@ -28,72 +27,124 @@
#include "system.h" #include "system.h"
#include "routing.h" #include "routing.h"
enum {
MMENWIN_UNDEF = 0,
MMENWIN_SEARCH,
MMENWIN_MAPREFRESH,
MMENWIN_IDXREFRESH,
MMENWIN_GPSCONFIG,
MMENWIN_GPSSTARTSTOP,
MMENWIN_MAPCONFIG,
MMENWIN_CLOSE,
MMENWIN_SETDEST,
MMENWIN_DEBUG,
MMENWIN_QUIT
};
void gui_mainmenu_close (); void gui_mainmenu_close ();
void gui_mainmenu_refresh ();
void gui_mainmenu_refreshidx ();
void gui_mainmenu_search (); void gui_mainmenu_search ();
void gui_mainmenu_quit (); void gui_mainmenu_quit ();
void gui_mainmenu_routing (); void gui_mainmenu_refresh ();
void gui_mainmenu_config (); void gui_mainmenu_refreshidx ();
void gui_mainmenu_gpsconfig ();
GUIItem *mbtn_close = NULL; void gui_mainmenu_gpsstartstop ();
GUIItem *mbtn_quit = NULL; void gui_mainmenu_mapconfig ();
GUIItem *mbtn_refreshidx = NULL; void gui_mainmenu_setdest ();
GUIItem *mbtn_refresh = NULL; void gui_mainmenu_debug ();
GUIItem *mbtn_search = NULL;
GUIItem *mbtn_routing= NULL;
GUIItem *mbtn_config= NULL;
static GUIWindow wmmenu = {0}; static GUIWindow wmmenu = {0};
void gui_mainmenu_show () { void gui_mainmenu_show () {
if (wmmenu.screen == NULL) gui_window_new (&wmmenu, 200, 200, _("OSMroute Menu")); int item = 0;
if (wmmenu.screen == NULL) guiwindow_new (&wmmenu, 175, 200);
wmmenu.screen_changed = 1; wmmenu.screen_changed = 1;
// wmmenu.callback_close = (void*)gui_mainmenu_closecallback;
wmmenu.style = WGUI_S_VCENTER | WGUI_S_HCENTER; wmmenu.style = WGUI_S_VCENTER | WGUI_S_HCENTER;
strncpy (wmmenu.title, _("OSMroute Menu"), GUI_TEXTLEN);
/* add buttons */ /* add buttons */
if (mbtn_refresh == NULL) { strncpy (wmmenu.buttons[item].caption, _("Close"), GUI_TEXTLEN);
mbtn_refresh = gui_button_new (_("Update Map"), 5, 30, 90, 20); wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_close;
GUI_BUTTON_T(mbtn_refresh)->callback_clicked = (void*)gui_mainmenu_refresh; wmmenu.buttons[item].id = MMENWIN_CLOSE;
} wmmenu.buttons[item].w = 80;
gui_window_item_add (&wmmenu, mbtn_refresh); wmmenu.buttons[item].h = 25;
wmmenu.buttons[item].x = 5;
if (mbtn_refreshidx == NULL) { wmmenu.buttons[item].y = 170;
mbtn_refreshidx = gui_button_new (_("Update Index"), 105, 30, 90, 20);
GUI_BUTTON_T(mbtn_refreshidx)->callback_clicked = (void*)gui_mainmenu_refreshidx; strncpy (wmmenu.buttons[++item].caption, _("Quit"), GUI_TEXTLEN);
} wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_quit;
gui_window_item_add (&wmmenu, mbtn_refreshidx); wmmenu.buttons[item].id = MMENWIN_QUIT;
wmmenu.buttons[item].w = 80;
if (mbtn_routing == NULL) { wmmenu.buttons[item].h = 25;
mbtn_routing = gui_button_new (_("Routing"), 5, 60, 190, 20); wmmenu.buttons[item].x = 90;
GUI_BUTTON_T(mbtn_routing)->callback_clicked = (void*)gui_mainmenu_routing; wmmenu.buttons[item].y = 170;
}
gui_window_item_add (&wmmenu, mbtn_routing); strncpy (wmmenu.buttons[++item].caption, _("GPS Config"), GUI_TEXTLEN);
wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_gpsconfig;
if (mbtn_search == NULL) { wmmenu.buttons[item].id = MMENWIN_GPSCONFIG;
mbtn_search = gui_button_new (_("Search"), 5, 90, 190, 20); wmmenu.buttons[item].w = 80;
GUI_BUTTON_T(mbtn_search)->callback_clicked = (void*)gui_mainmenu_search; wmmenu.buttons[item].h = 25;
} wmmenu.buttons[item].x = 5;
gui_window_item_add (&wmmenu, mbtn_search); wmmenu.buttons[item].y = 140;
if (mbtn_config == NULL) { strncpy (wmmenu.buttons[++item].caption, _("GPS On/Off"), GUI_TEXTLEN);
mbtn_config = gui_button_new (_("Config"), 5, 120, 130, 20); wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_gpsstartstop;
GUI_BUTTON_T(mbtn_config)->callback_clicked = (void*)gui_mainmenu_config; wmmenu.buttons[item].id = MMENWIN_GPSSTARTSTOP;
} wmmenu.buttons[item].w = 80;
gui_window_item_add (&wmmenu, mbtn_config); wmmenu.buttons[item].h = 25;
wmmenu.buttons[item].x = 5;
if (mbtn_quit == NULL) { wmmenu.buttons[item].y = 110;
mbtn_quit = gui_button_new (_("Quit"), 145, 120, 50, 20);
GUI_BUTTON_T(mbtn_quit)->callback_clicked = (void*)gui_mainmenu_quit; strncpy (wmmenu.buttons[++item].caption, _("MAP Config"), GUI_TEXTLEN);
} wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_mapconfig;
gui_window_item_add (&wmmenu, mbtn_quit); wmmenu.buttons[item].id = MMENWIN_MAPCONFIG;
wmmenu.buttons[item].w = 80;
if (mbtn_close == NULL) { wmmenu.buttons[item].h = 25;
mbtn_close = gui_button_new (_("Close"), 5, 155, 190, 20); wmmenu.buttons[item].x = 90;
GUI_BUTTON_T(mbtn_close)->callback_clicked = (void*)gui_mainmenu_close; wmmenu.buttons[item].y = 140;
}
gui_window_item_add (&wmmenu, mbtn_close); strncpy (wmmenu.buttons[++item].caption, _("MAP Refresh"), GUI_TEXTLEN);
wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_refresh;
wmmenu.buttons[item].id = MMENWIN_MAPREFRESH;
wmmenu.buttons[item].w = 80;
wmmenu.buttons[item].h = 25;
wmmenu.buttons[item].x = 90;
wmmenu.buttons[item].y = 110;
strncpy (wmmenu.buttons[++item].caption, _("Debug"), GUI_TEXTLEN);
wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_debug;
wmmenu.buttons[item].id = MMENWIN_DEBUG;
wmmenu.buttons[item].w = 80;
wmmenu.buttons[item].h = 25;
wmmenu.buttons[item].x = 5;
wmmenu.buttons[item].y = 80;
strncpy (wmmenu.buttons[++item].caption, _("IDX Refresh"), GUI_TEXTLEN);
wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_refreshidx;
wmmenu.buttons[item].id = MMENWIN_IDXREFRESH;
wmmenu.buttons[item].w = 80;
wmmenu.buttons[item].h = 25;
wmmenu.buttons[item].x = 90;
wmmenu.buttons[item].y = 80;
strncpy (wmmenu.buttons[++item].caption, _("Set Destination"), GUI_TEXTLEN);
wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_setdest;
wmmenu.buttons[item].id = MMENWIN_SETDEST;
wmmenu.buttons[item].w = 165;
wmmenu.buttons[item].h = 25;
wmmenu.buttons[item].x = 5;
wmmenu.buttons[item].y = 15;
strncpy (wmmenu.buttons[++item].caption, _("Search"), GUI_TEXTLEN);
wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_search;
wmmenu.buttons[item].id = MMENWIN_SEARCH;
wmmenu.buttons[item].w = 165;
wmmenu.buttons[item].h = 25;
wmmenu.buttons[item].x = 5;
wmmenu.buttons[item].y = 45;
gui_show (&wmmenu); gui_show (&wmmenu);
}; };
@ -104,18 +155,6 @@ void gui_mainmenu_close () {
}; };
void gui_mainmenu_routing () {
gui_close ();
wnd_routing_show ();
};
void gui_mainmenu_config () {
gui_close ();
gui_config_show ();
};
void gui_mainmenu_search () { void gui_mainmenu_search () {
gui_close (); gui_close ();
gui_search_show (); gui_search_show ();
@ -142,6 +181,19 @@ void gui_mainmenu_setdest () {
}; };
void gui_mainmenu_gpsconfig () {
gui_close ();
#ifdef HAVE_WINAPI
gps_wince_settings ();
#else
#ifdef HAVE_GTK
gpssetting_wnd_show (main_wnd);
#endif
#endif
config_save ();
};
void gui_mainmenu_gpsstartstop () { void gui_mainmenu_gpsstartstop () {
gui_close (); gui_close ();
if (gps_isrunning () != 0) gps_stop (); if (gps_isrunning () != 0) gps_stop ();
@ -199,21 +251,18 @@ void gui_mainmenu_refresh () {
void gui_mainmenu_refreshidx () { void gui_mainmenu_refreshidx () {
static int _working = 0;
if (_working) return;
_working = 1;
#ifndef _WINDOWSCE_
char lfn[LEN_FILENAME]; char lfn[LEN_FILENAME];
#ifndef _WINDOWSCE_
char rfn[LEN_FILENAME] = "search.mapidx"; char rfn[LEN_FILENAME] = "search.mapidx";
#endif
gui_close (); gui_close ();
map_search_get_filename (lfn, LEN_FILENAME); map_search_get_filename (lfn, LEN_FILENAME);
#ifndef _WINDOWSCE_
map_webload (rfn, lfn, NULL); map_webload (rfn, lfn, NULL);
#endif
map_search_sort (); map_search_sort ();
draw_redrawmap (); draw_redrawmap ();
#endif
}; };
@ -222,7 +271,10 @@ void gui_mainmenu_quit () {
#ifdef _WINDOWSCE_ #ifdef _WINDOWSCE_
wince_taskbar (hMainWnd, TRUE); wince_taskbar (hMainWnd, TRUE);
#endif #endif
app.status = APPSTATUS_quit; route_stop ();
map_save_all ();
config_save ();
exit (0);
}; };

@ -26,107 +26,139 @@
#include "gui.h" #include "gui.h"
#include "system.h" #include "system.h"
enum {
SEARCHWIN_UNDEF = 0,
SEARCHWIN_SEARCH,
SEARCHWIN_NEXT,
SEARCHWIN_PREV,
SEARCHWIN_CLOSE,
SEARCHWIN_LABEL,
SEARCHWIN_REFRESH,
SEARCHWIN_TEXT
};
#define SEARCH_MAXRESULT 32 #define SEARCH_MAXRESULT 32
void gui_search_close (); void gui_search_close ();
void gui_search_city (); void gui_search_refresh ();
void gui_search_next ();
void gui_search_prev ();
void gui_search_search ();
void gui_search_switch (int pos); void gui_search_switch (int pos);
struct map_search_dataex {
float distance;
char text[GUI_TEXTLEN];
};
struct map_search_data search_data[SEARCH_MAXRESULT]; struct map_search_data search_data[SEARCH_MAXRESULT];
struct map_search_dataex search_dataex[SEARCH_MAXRESULT];
char *search_chars[SEARCH_MAXRESULT+1];
struct map_pos search_pos;
int search_data_cnt = 0; int search_data_cnt = 0;
int search_data_cur = -1; int search_data_cur = -1;
static GUIWindow wsearch = {0}; static GUIWindow wsearch = {0};
GUIItem *ws_entryname = NULL;
GUIItem *ws_labelname = NULL;
GUIItem *ws_entrystreet = NULL;
GUIItem *ws_labelstreet = NULL;
GUIItem *ws_btnok = NULL;
GUIItem *ws_btncancel = NULL;
GUIItem *ws_list = NULL;
GUIItem *ws_map = NULL; /* need to finish working on: gui_images and map_view */
void gui_search_show () { void gui_search_show () {
int i; int btn = 0;
if (wsearch.screen == NULL) gui_window_new (&wsearch, 220, 260, _("Search..")); if (wsearch.screen == NULL) guiwindow_new (&wsearch, 220, 60);
wsearch.screen_changed = 1; wsearch.screen_changed = 1;
wsearch.style = WGUI_S_VCENTER | WGUI_S_HCENTER;
strncpy (wsearch.title, _("Search"), GUI_TEXTLEN);
/* Name Ok Button */
if (ws_labelname == NULL) ws_labelname = gui_label_new (_("City:"), 5, 10);
gui_window_item_add (&wsearch, ws_labelname);
if (ws_entryname == NULL) ws_entryname = gui_entry_new (_(""), 50, 10, 100, 20); // wmmenu.callback_close = (void*)gui_mainmenu_closecallback;
gui_window_item_add (&wsearch, ws_entryname); wsearch.screen_changed = 1;
GUI_ENTRY_T (ws_entryname)->callback_enter = gui_search_city; wsearch.style = WGUI_S_VCENTER | WGUI_S_HTOP;
wsearch.title[0] = 0;
if (ws_btnok == NULL) ws_btnok = gui_button_new (_("Ok"), 165, 5, 50, 20);
GUI_BUTTON_T (ws_btnok)->callback_clicked = (void*) gui_search_close; /* search buttons */
gui_window_item_add (&wsearch, ws_btnok); strncpy (wsearch.buttons[btn].caption, _("<"), GUI_TEXTLEN);
wsearch.buttons[btn].callback_clicked = (void*)gui_search_prev;
wsearch.buttons[btn].id = SEARCHWIN_PREV;
wsearch.buttons[btn].w = 20;
wsearch.buttons[btn].h = 20;
wsearch.buttons[btn].x = 5;
wsearch.buttons[btn].y = 35;
strncpy (wsearch.buttons[++btn].caption, _(">"), GUI_TEXTLEN);
wsearch.buttons[btn].callback_clicked = (void*)gui_search_next;
wsearch.buttons[btn].id = SEARCHWIN_NEXT;
wsearch.buttons[btn].w = 20;
wsearch.buttons[btn].h = 20;
wsearch.buttons[btn].x = 85;
wsearch.buttons[btn].y = 35;
strncpy (wsearch.buttons[++btn].caption, _("Search"), GUI_TEXTLEN);
wsearch.buttons[btn].callback_clicked = (void*)gui_search_search;
wsearch.buttons[btn].id = SEARCHWIN_SEARCH;
wsearch.buttons[btn].w = 50;
wsearch.buttons[btn].h = 20;
wsearch.buttons[btn].x = 110;
wsearch.buttons[btn].y = 35;
strncpy (wsearch.buttons[++btn].caption, _("Ref"), GUI_TEXTLEN);
wsearch.buttons[btn].callback_clicked = (void*)gui_search_refresh;
wsearch.buttons[btn].id = SEARCHWIN_REFRESH;
wsearch.buttons[btn].w = 30;
wsearch.buttons[btn].h = 20;
wsearch.buttons[btn].x = 165;
wsearch.buttons[btn].y = 35;
strncpy (wsearch.buttons[++btn].caption, _("X"), GUI_TEXTLEN);
wsearch.buttons[btn].callback_clicked = (void*)gui_search_close;
wsearch.buttons[btn].id = SEARCHWIN_CLOSE;
wsearch.buttons[btn].w = 15;
wsearch.buttons[btn].h = 20;
wsearch.buttons[btn].x = 200;
wsearch.buttons[btn].y = 35;
/* add label */
btn = 0;
strncpy (wsearch.labels[btn].text, "0/0", GUI_TEXTLEN);
wsearch.labels[btn].x = 35;
wsearch.labels[btn].y = 37;
wsearch.labels[btn].id = SEARCHWIN_LABEL;
wsearch.labels[btn].textcol = &color[COLOR_white][3];
/* add entry box */
btn = 0;
strncpy (wsearch.entrys[btn].text, "", GUI_TEXTLEN);
wsearch.entrys[btn].id = SEARCHWIN_TEXT;
wsearch.entrys[btn].x = 5;
wsearch.entrys[btn].y = 5;
wsearch.entrys[btn].w = 210;
wsearch.entrys[btn].h = 20;
wsearch.entrys[btn].curpos = 4;
wsearch.entrys[btn].overwrite = 0;
wsearch.entrys[btn].callback_enter = (void*)gui_search_search;
/* street Cancel Button */ gui_show (&wsearch);
if (ws_labelstreet == NULL) ws_labelstreet = gui_label_new (_("Street:"), 5, 35); };
gui_window_item_add (&wsearch, ws_labelstreet);
if (ws_entrystreet == NULL) ws_entrystreet = gui_entry_new (_(""), 50, 30, 100, 20);
gui_window_item_add (&wsearch, ws_entrystreet);
if (ws_btncancel == NULL) ws_btncancel = gui_button_new (_("Cancel"), 165, 30, 50, 20); void gui_search_close () {
GUI_BUTTON_T (ws_btncancel)->callback_clicked = (void*) gui_search_close; gui_close ();
gui_window_item_add (&wsearch, ws_btncancel); };
/* result list */
if (ws_list == NULL) ws_list = gui_list_new (5, 55, 210, 100);
GUI_LIST_T(ws_list)->callback_selectitem = (void*) gui_search_switch;
gui_window_item_add (&wsearch, ws_list);
if (gps_isrunning()) { void gui_search_refresh () {
struct gps_data *gpsdata = gps_getposition (); map_refresh (view_lon, view_lat);
search_pos.lon = gpsdata->lon; draw_redrawmap ();
search_pos.lat = gpsdata->lat; draw ();
} };
else {
search_pos.lon = view_lon;
search_pos.lat = view_lat;
}
for (i = 0; i < SEARCH_MAXRESULT+1; i++) search_chars[i] = NULL;
gui_show (&wsearch); void gui_search_prev () {
d_printf ("search_data_cur:%d", search_data_cur);
gui_search_switch (search_data_cur-1);
d_printf ("search_data_cur:%d", search_data_cur);
}; };
void gui_search_close () { void gui_search_next () {
gui_close (); d_printf ("search_data_cur:%d", search_data_cur);
gui_search_switch (search_data_cur+1);
d_printf ("search_data_cur:%d", search_data_cur);
}; };
void gui_search_city () { void gui_search_search () {
int i; d_printf ("search for %s", wsearch.entrys[0].text);
struct map_pos pos;
search_data_cnt = map_search (GUI_ENTRY_T(ws_entryname)->text, search_data, SEARCH_MAXRESULT); search_data_cnt = map_search (wsearch.entrys[0].text, search_data, SEARCH_MAXRESULT);
for (i = 0; i < search_data_cnt && i < SEARCH_MAXRESULT; i++) { gui_search_switch (0);
pos.lon = search_data[i].lon;
pos.lat = search_data[i].lat;
search_dataex[i].distance = map_getdistance (pos, search_pos);
snprintf (search_dataex[i].text, GUI_TEXTLEN, "%4.0fkm %s", search_dataex[i].distance, search_data[i].name);
search_chars[i] = search_dataex[i].text;
d_printf (" %-3d:%s distance:%f '%s'",i , search_data[i].name, search_dataex[i].distance, search_dataex[i].text);
}
search_chars[i] = NULL;
GUI_LIST_T(ws_list)->data = search_chars;
}; };
@ -137,10 +169,14 @@ void gui_search_switch (int pos) {
else if (search_data_cur >= search_data_cnt) search_data_cur = 0; else if (search_data_cur >= search_data_cnt) search_data_cur = 0;
else if (search_data_cur < 0) search_data_cur = search_data_cnt - 1; else if (search_data_cur < 0) search_data_cur = search_data_cnt - 1;
if (search_data_cur >= 0) { if (search_data_cur == -1) strncpy (wsearch.labels[0].text, _("0"), GUI_TEXTLEN);
else {
snprintf (wsearch.labels[0].text, GUI_TEXTLEN, _("%d of %d"), search_data_cur+1, search_data_cnt);
strncpy (wsearch.entrys[0].text, search_data[search_data_cur].name, GUI_TEXTLEN);
view_lon = search_data[search_data_cur].lon; view_lon = search_data[search_data_cur].lon;
view_lat = search_data[search_data_cur].lat; view_lat = search_data[search_data_cur].lat;
wsearch.screen_changed = 1; wsearch.screen_changed = 1;
wsearch.entrys[0].curpos = strlen (wsearch.entrys[0].text);
draw (); draw ();
} }
}; };

@ -1,200 +0,0 @@
/* %Id: Exp $ */
/***************************************************************************
* gui_selectdir.c
*
* Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
*/
#include "osmroute.h"
#include "draw.h"
#include "gui.h"
#include "system.h"
#include <sys/types.h>
#include <dirent.h>
void gui_sdir_close ();
void gui_sdir_update ();
void gui_sdir_clear ();
void gui_sdir_clicklist (int nr);
GUIWindow wsdir = {0};
GUIItem *wsd_close = NULL;
GUIItem *wsd_path = NULL;
GUIItem *wsd_dirlist = NULL;
char **wsd_list = NULL;
int wsd_listmax = 0;
char wsd_select_dir[LEN_FILENAME];
char *gui_sdir_show (char *startpath) {
if (wsdir.screen == NULL) gui_window_new (&wsdir, 220, 250, _("Select Dir"));
wsdir.screen_changed = 1;
wsdir.style = WGUI_S_VCENTER | WGUI_S_HCENTER;
/* close Button */
if (wsd_close == NULL) wsd_close = gui_button_new (_("Close"), 50, 220, 100, 20);
GUI_BUTTON_T (wsd_close)->callback_clicked = (void*) gui_sdir_close;
gui_window_item_add (&wsdir, wsd_close);
if (wsd_path == NULL) wsd_path = gui_entry_new (startpath, 10, 25, 200, 25);
gui_window_item_add (&wsdir, wsd_path);
if (wsd_dirlist == NULL) wsd_dirlist = gui_list_new (10, 55, 200, 140);
GUI_LIST_T (wsd_dirlist)->callback_selectitem = gui_sdir_clicklist;
GUI_LIST_T (wsd_dirlist)->data = wsd_list;
gui_window_item_add (&wsdir, wsd_dirlist);
gui_sdir_update ();
gui_show (&wsdir);
while (currentwin == &wsdir) {
main_wnd_update ();
}
strncpy (wsd_select_dir, GUI_ENTRY_T(wsd_path)->text, LEN_FILENAME-1);
if (wsd_select_dir[strlen(wsd_select_dir)-1] != DIR_SEP) {
int i = strlen(wsd_select_dir);
wsd_select_dir[i] = DIR_SEP;
wsd_select_dir[i+1] = '\0';
}
return wsd_select_dir;
};
void gui_sdir_close () {
gui_close ();
};
void gui_sdir_clicklist (int nr) {
char fname[LEN_FILENAME];
char *seperate;
d_printf ("selected nr:%d '%s'", nr, nr < wsd_listmax ? wsd_list[nr] : "nr >= wsd_listmax");
if (nr >= wsd_listmax || wsd_list[nr] == NULL) return;
if (strcmp (wsd_list[nr], ".") == 0) return;
if (strcmp (wsd_list[nr], "..") == 0) {
strncpy (fname, GUI_ENTRY_T(wsd_path)->text, LEN_FILENAME);
while (strlen (fname)>1 && fname[strlen (fname) -1] == DIR_SEP)
fname[strlen (fname)-1] = '\0';
if (strlen (fname) > 1) {
seperate = strrchr(fname, DIR_SEP);
if (seperate != NULL) {
seperate[0] = '\0';
}
}
gui_entry_settext (wsd_path, fname);
}
else {
if (GUI_ENTRY_T(wsd_path)->text[strlen (GUI_ENTRY_T(wsd_path)->text)-1] == DIR_SEP)
snprintf (fname, LEN_FILENAME, "%s%s", GUI_ENTRY_T(wsd_path)->text, wsd_list[nr]);
else
snprintf (fname, LEN_FILENAME, "%s%c%s", GUI_ENTRY_T(wsd_path)->text, DIR_SEP, wsd_list[nr]);
gui_entry_settext (wsd_path, fname);
}
gui_sdir_update ();
// wsdir.screen_changed = 1;
// draw ();
};
void gui_sdir_update () {
int cnt;
DIR *dir = NULL;
struct dirent *direntry = NULL;
char fname[LEN_FILENAME];
struct stat stbuf;
/* clear list and reopen directory */
gui_sdir_clear ();
if ((dir = opendir (GUI_ENTRY_T(wsd_path)->text)) == NULL) {
/* if open fails, reopen with ROOT_DIR which is defined in system.h */
gui_entry_settext (wsd_path, ROOT_DIR);
if ((dir = opendir (GUI_ENTRY_T(wsd_path)->text)) == NULL) {
d_printf ("could not open dir for reading. errno:%d '%s'", errno, strerror(errno));
return;
}
}
/* go through the directory but only add directory entries */
cnt = wsd_listmax = 0;
/* need more memory? */
while ((direntry = readdir (dir))) {
if (GUI_ENTRY_T(wsd_path)->text[strlen (GUI_ENTRY_T(wsd_path)->text)-1] == DIR_SEP)
snprintf (fname, LEN_FILENAME, "%s%s", GUI_ENTRY_T(wsd_path)->text, direntry->d_name);
else
snprintf (fname, LEN_FILENAME, "%s%c%s", GUI_ENTRY_T(wsd_path)->text, DIR_SEP, direntry->d_name);
if (stat(fname, &stbuf) == -1) {
d_printf ("could not read stat of file: %s", fname);
continue;
}
d_printf ("dir:%s", fname);
if (S_ISDIR(stbuf.st_mode)) {
/* need more memory? */
if (cnt >= wsd_listmax) {
/* save old pointer and counter */
char **tmp = wsd_list;
int i = wsd_listmax-1;
/* allocate new list */
wsd_listmax += 512;
wsd_list = ml_malloc (wsd_listmax * sizeof(void*));
memset (wsd_list, 0x0, wsd_listmax * sizeof(void*));
/* copy list */
if (tmp) {
for (; i >= 0; i--) wsd_list[i] = tmp[i];
ml_free (tmp);
}
/* setup new list */
GUI_LIST_T (wsd_dirlist)->data = wsd_list;
}
wsd_list[cnt] = ml_malloc (LEN_FILENAME);
strncpy (wsd_list[cnt], direntry->d_name, LEN_FILENAME);
d_printf ("added entry:%-3d '%s'", cnt, direntry->d_name);
cnt++;
}
}
closedir (dir);
};
/*
* remove all listentrys and free list
*/
void gui_sdir_clear () {
int i;
if (wsd_list == NULL) return;
for (i = 0; wsd_list[i]; i++) {
if (wsd_list[i]) ml_free (wsd_list[i]);
wsd_list[i] = NULL;
}
};

@ -1,192 +0,0 @@
/* $Id: gui_selectfile.c,v 1.4 2014/02/12 23:05:35 steffen Exp $ */
/***************************************************************************
* gui_selectdir.c
*
* Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
*/
#include "osmroute.h"
#include "draw.h"
#include "gui.h"
#include "system.h"
#include <sys/types.h>
#include <dirent.h>
void gui_sfile_close ();
void gui_sfile_update ();
void gui_sfile_clear ();
void gui_sfile_clicklist (int nr);
GUIWindow wsfile = {0};
GUIItem *wsf_close = NULL;
GUIItem *wsf_file = NULL;
GUIItem *wsf_flist = NULL;
char **wsf_list = NULL;
int wsf_listmax = 0;
char wsf_select_file[LEN_FILENAME];
char *gui_sfile_show (char *startpath) {
if (wsfile.screen == NULL) gui_window_new (&wsfile, 220, 250, _("Select File"));
wsfile.screen_changed = 1;
wsfile.style = WGUI_S_VCENTER | WGUI_S_HCENTER;
/* close Button */
if (wsf_close == NULL) wsf_close = gui_button_new (_("Close"), 50, 220, 100, 20);
GUI_BUTTON_T (wsf_close)->callback_clicked = (void*) gui_sfile_close;
gui_window_item_add (&wsfile, wsf_close);
if (wsf_file == NULL) wsf_file = gui_entry_new (startpath, 10, 25, 200, 25);
gui_window_item_add (&wsfile, wsf_file);
if (wsf_flist == NULL) wsf_flist = gui_list_new (10, 55, 200, 140);
GUI_LIST_T (wsf_flist)->callback_selectitem = gui_sfile_clicklist;
GUI_LIST_T (wsf_flist)->data = wsf_list;
gui_window_item_add (&wsfile, wsf_flist);
gui_sfile_update ();
gui_show (&wsfile);
while (currentwin == &wsfile) {
main_wnd_update ();
}
strncpy (wsf_select_file, GUI_ENTRY_T(wsf_file)->text, LEN_FILENAME-1);
return wsf_select_file;
};
void gui_sfile_close () {
gui_close ();
};
void gui_sfile_clicklist (int nr) {
char fname[LEN_FILENAME];
char *seperate;
d_printf ("selected nr:%d '%s'", nr, nr < wsf_listmax ? wsf_list[nr] : "nr >= wsf_listmax");
if (nr >= wsf_listmax || wsf_list[nr] == NULL) return;
if (strcmp (wsf_list[nr], ".") == 0) return;
if (strcmp (wsf_list[nr], "..") == 0) {
strncpy (fname, GUI_ENTRY_T(wsf_file)->text, LEN_FILENAME);
while (strlen (fname)>1 && fname[strlen (fname) -1] == DIR_SEP)
fname[strlen (fname)-1] = '\0';
if (strlen (fname) > 1) {
seperate = strrchr(fname, DIR_SEP);
if (seperate != NULL) {
seperate[0] = '\0';
}
}
gui_entry_settext (wsf_file, fname);
}
else {
if (GUI_ENTRY_T(wsf_file)->text[strlen (GUI_ENTRY_T(wsf_file)->text)-1] == DIR_SEP)
snprintf (fname, LEN_FILENAME, "%s%s", GUI_ENTRY_T(wsf_file)->text, wsf_list[nr]);
else
snprintf (fname, LEN_FILENAME, "%s%c%s", GUI_ENTRY_T(wsf_file)->text, DIR_SEP, wsf_list[nr]);
gui_entry_settext (wsf_file, fname);
}
gui_sfile_update ();
};
void gui_sfile_update () {
int cnt;
DIR *dir = NULL;
struct dirent *direntry = NULL;
char fname[LEN_FILENAME];
struct stat stbuf;
/* clear list and reopen directory */
gui_sfile_clear ();
if ((dir = opendir (GUI_ENTRY_T(wsf_file)->text)) == NULL) {
/* if open fails, reopen with ROOT_DIR which is defined in system.h */
gui_entry_settext (wsf_file, ROOT_DIR);
if ((dir = opendir (GUI_ENTRY_T(wsf_file)->text)) == NULL) {
d_printf ("could not open dir for reading. errno:%d '%s'", errno, strerror(errno));
return;
}
}
/* go through the directory but only add directory entries */
cnt = wsf_listmax = 0;
/* need more memory? */
while ((direntry = readdir (dir))) {
if (GUI_ENTRY_T(wsf_file)->text[strlen (GUI_ENTRY_T(wsf_file)->text)-1] == DIR_SEP)
snprintf (fname, LEN_FILENAME, "%s%s", GUI_ENTRY_T(wsf_file)->text, direntry->d_name);
else
snprintf (fname, LEN_FILENAME, "%s%c%s", GUI_ENTRY_T(wsf_file)->text, DIR_SEP, direntry->d_name);
if (stat(fname, &stbuf) == -1) {
d_printf ("could not read stat of file: %s", fname);
continue;
}
d_printf ("dir:%s", fname);
if (cnt >= wsf_listmax) {
/* save old pointer and counter */
char **tmp = wsf_list;
int i = wsf_listmax-1;
/* allocate new list */
wsf_listmax += 512;
wsf_list = ml_malloc (wsf_listmax * sizeof(void*));
memset (wsf_list, 0x0, wsf_listmax * sizeof(void*));
/* copy list */
if (tmp) {
for (; i >= 0; i--) wsf_list[i] = tmp[i];
ml_free (tmp);
}
/* setup new list */
GUI_LIST_T (wsf_flist)->data = wsf_list;
}
wsf_list[cnt] = ml_malloc (LEN_FILENAME);
if (S_ISDIR(stbuf.st_mode)) snprintf (wsf_list[cnt], LEN_FILENAME, "[%s]", direntry->d_name);
else snprintf (wsf_list[cnt], LEN_FILENAME, "%s", direntry->d_name);
d_printf ("added entry:%-3d '%s'", cnt, direntry->d_name);
cnt++;
}
closedir (dir);
};
/*
* remove all listentrys and free list
*/
void gui_sfile_clear () {
int i;
if (wsf_list == NULL) return;
for (i = 0; wsf_list[i]; i++) {
if (wsf_list[i]) ml_free (wsf_list[i]);
wsf_list[i] = NULL;
}
};

@ -43,14 +43,14 @@ void gpswin_btnclose(int x, int y);
void gpswin_show () { void gpswin_show () {
d_printf ("GUI: gps file screen"); d_printf ("GUI: gps file screen");
if (gpswin.screen == NULL) gui_window_new (&gpswin, 250, 32, _("GPS")); if (gpswin.screen == NULL) guiwindow_new (&gpswin, 250, 32);
gpswin.screen_changed = 1; gpswin.screen_changed = 1;
gpswin.callback_close = (void*)gpswin_closecallback; gpswin.callback_close = (void*)gpswin_closecallback;
gpswin.style = WGUI_S_VCENTER | WGUI_S_HBOTTOM; gpswin.style = WGUI_S_VCENTER | WGUI_S_HBOTTOM;
/* add buttons */ /* add buttons */
/* strncpy (gpswin.buttons[0].caption, _("P"), GUI_TEXTLEN); strncpy (gpswin.buttons[0].caption, _("P"), GUI_TEXTLEN);
gpswin.buttons[0].callback_clicked = (void*)gpswin_btnpauseplay; gpswin.buttons[0].callback_clicked = (void*)gpswin_btnpauseplay;
gpswin.buttons[0].id = GPSWIN_PAUSEPLAY; gpswin.buttons[0].id = GPSWIN_PAUSEPLAY;
gpswin.buttons[0].callback_draw = (void*)gpswin_btndraw; gpswin.buttons[0].callback_draw = (void*)gpswin_btndraw;
@ -75,7 +75,7 @@ void gpswin_show () {
gpswin.buttons[2].h = 31; gpswin.buttons[2].h = 31;
gpswin.buttons[2].x = 250-32; gpswin.buttons[2].x = 250-32;
gpswin.buttons[2].y = 0; gpswin.buttons[2].y = 0;
*/
gui_show (&gpswin); gui_show (&gpswin);
}; };
@ -83,12 +83,13 @@ void gpswin_show () {
void gpswin_closecallback () { void gpswin_closecallback () {
d_printf ("GUI: gps win close"); d_printf ("GUI: gps win close");
gui_window_close (&gpswin); guiwindow_close (&gpswin);
}; };
void gpswin_btndraw (GUIButton *btn) { void gpswin_btndraw (GUIButton *btn) {
/* if (btn->id == GPSWIN_PAUSEPLAY) { int i;
if (btn->id == GPSWIN_PAUSEPLAY) {
i = gps_file_get_state (); i = gps_file_get_state ();
if (i == GPSF_END) btn->col = &color[COLOR_white][1]; if (i == GPSF_END) btn->col = &color[COLOR_white][1];
else if (i == GPSF_INIT) btn->col = &color[COLOR_green][0]; else if (i == GPSF_INIT) btn->col = &color[COLOR_green][0];
@ -124,7 +125,6 @@ void gpswin_btndraw (GUIButton *btn) {
draw_line (currentwin->screen, btn->x + x, btn->y, btn->x + x, btn->y + btn->h, ls); draw_line (currentwin->screen, btn->x + x, btn->y, btn->x + x, btn->y + btn->h, ls);
} }
*/
}; };

@ -18,11 +18,15 @@ int app_init (int argc, char **argv) {
app.status = APPSTATUS_nothing; app.status = APPSTATUS_nothing;
config_init (); config_init ();
d_printf ("************ cfg.last_scale:%f", cfg.last_scale);
map_init (); map_init ();
d_printf ("************ cfg.last_scale:%f", cfg.last_scale);
#ifdef SPOSMROUTE #ifdef SPOSMROUTE
draw_init (); draw_init ();
d_printf ("************ cfg.last_scale:%f", cfg.last_scale);
fav_load (fav_getfilename ()); fav_load (fav_getfilename ());
d_printf ("************ cfg.last_scale:%f", cfg.last_scale);
#endif #endif
return 0; return 0;
}; };
@ -44,35 +48,15 @@ int app_shutdown () {
}; };
int app_loop () {
#ifdef SPOSMROUTE
struct gps_data *gpspos;
if (gps_isrunning () > 0) {
if ((gpspos = gps_loop ())) {
drawgps_set_pos (gpspos);
}
}
draw_mouseloop ();
#endif
return 0;
};
/****************************************************************************** /******************************************************************************
* update stausbar * update stausbar
*/ */
void app_status (int status, char *text, float progress) { void app_status (char *text, int progress) {
static char oldtext[255]; static char oldtext[255];
if (text) strncpy (app.statusline_text, text, 255); if (text) strncpy (app.statusline_text, text, 255);
else strncpy (app.statusline_text, oldtext, 255); else strncpy (app.statusline_text, oldtext, 255);
app.statusline_progress = progress;
if (status >= 0) app.status = status;
if (progress < 0.0) app.statusline_progress = 0.0;
else if (progress > 1.0) app.statusline_progress = 1.0;
else app.statusline_progress = progress;
#ifdef SPOSMROUTE #ifdef SPOSMROUTE
if (currentwin) currentwin->screen_changed = 1; if (currentwin) currentwin->screen_changed = 1;

@ -47,7 +47,7 @@
#include "memoryleak.h" #include "memoryleak.h"
#include "map.h" #include "map.h"
#include "ncurses_port.h" #include "convert_port.h"
#include "system.h" #include "system.h"
char curfile[LEN_FILENAME]; char curfile[LEN_FILENAME];
@ -307,8 +307,8 @@ int main (int argc, char *argv[]) {
mkdir (cfg.cachepath, 0755); mkdir (cfg.cachepath, 0755);
} }
if (stat(cfg.mappath, &sb) == -1) { if (stat(cfg.datapath, &sb) == -1) {
mkdir (cfg.mappath, 0755); mkdir (cfg.datapath, 0755);
} }
config_init (); config_init ();

@ -42,26 +42,16 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#ifndef FALSE #ifdef HAVE_SDL
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
/* #ifdef HAVE_SDL
#include <SDL.h> #include <SDL.h>
#define FALSE 0 #define FALSE 0
#define TRUE 1 #define TRUE 1
#endif #endif
#ifdef ANDROID #ifdef ANDROID
#define FALSE 0 #define FALSE 0
#define TRUE 1 #define TRUE 1
#endif #endif
*/
/* /*
* Standard gettext macros. * Standard gettext macros.
@ -96,7 +86,6 @@
#include "map.h" #include "map.h"
#include "system.h" #include "system.h"
#include "memoryleak.h"
enum { /* what we're doing at the moment */ enum { /* what we're doing at the moment */
APPSTATUS_nothing, APPSTATUS_nothing,
@ -131,15 +120,12 @@ struct cfgdata {
float last_lon; float last_lon;
float last_lat; float last_lat;
float last_scale; float last_scale;
int softkeyboard;
int debug; int debug;
}; };
struct appdata { struct appdata {
char statusline_text[255]; char statusline_text[255];
float statusline_progress; // value in 0.0 to 1.0 int statusline_progress;
int status; int status;
float debug_lon; float debug_lon;
float debug_lat; float debug_lat;
@ -174,8 +160,7 @@ extern struct appdata app;
*/ */
extern int app_init (int argc, char **argv); extern int app_init (int argc, char **argv);
extern int app_shutdown (); extern int app_shutdown ();
extern void app_status (int status, char *text, float progress); extern void app_status (char *text, int progress);
extern int app_loop ();
extern void config_init (); extern void config_init ();
extern void config_draw_load (char *fn); extern void config_draw_load (char *fn);
@ -190,6 +175,4 @@ extern void main_wnd_enable (int enabled);
extern void main_wnd_loop (long long int cur, long long int max); extern void main_wnd_loop (long long int cur, long long int max);
extern void main_wnd_update (); extern void main_wnd_update ();
extern char *gui_sdir_show (char *startpath);
#endif #endif

@ -143,7 +143,7 @@ void rtrl_addwayname (struct rtdata *r, struct rtreflist *rtrl, struct map_way *
int nr; // segment number int nr; // segment number
int i, n; int i, n;
struct rtref *ref; // pointer to reference data struct rtref *ref; // pointer to reference data
// static struct rtwayid _rtrl_wlist [RTRL_MAXWAYS]; // only create this once, saves time.. static struct rtwayid _rtrl_wlist [RTRL_MAXWAYS]; // only create this once, saves time..
int _rtrl_wlist_cnt = 0; // re-init with zero elements int _rtrl_wlist_cnt = 0; // re-init with zero elements
d_printf (" rtrl_addwayname '%s' id:%lld:%d mw->ref:%s", name, mw->id, mw->subid, mw->ref); d_printf (" rtrl_addwayname '%s' id:%lld:%d mw->ref:%s", name, mw->id, mw->subid, mw->ref);
@ -202,7 +202,7 @@ void rtrl_addwayname (struct rtdata *r, struct rtreflist *rtrl, struct map_way *
struct map_way *mwtmp = NULL; struct map_way *mwtmp = NULL;
struct rtwayid fromdir[2]; /* 0.. left, 1.. right */ struct rtwayid fromdir[2]; /* 0.. left, 1.. right */
struct map_way *mwdir[2] = {NULL, NULL}; struct map_way *mwdir[2] = {NULL, NULL};
// int pnrdir[2] = {-1, -1}; /* pnr: where we entered the way */ int pnrdir[2] = {-1, -1}; /* pnr: where we entered the way */
int dir; int dir;
d_printf (" found closest way nr:%d way:%lld:%d dist:%f", d_printf (" found closest way nr:%d way:%lld:%d dist:%f",
@ -237,11 +237,11 @@ void rtrl_addwayname (struct rtdata *r, struct rtreflist *rtrl, struct map_way *
/* found way */ /* found way */
if (mwdir[0] == NULL) { if (mwdir[0] == NULL) {
mwdir[0]= mwtmp1; mwdir[0]= mwtmp1;
// pnrdir[0] = mwtmp->n[i].d_pnr; pnrdir[0] = mwtmp->n[i].d_pnr;
} }
else if (mwdir[1] == NULL) { else if (mwdir[1] == NULL) {
mwdir[1]= mwtmp1; mwdir[1]= mwtmp1;
// pnrdir[1] = mwtmp->n[i].d_pnr; pnrdir[1] = mwtmp->n[i].d_pnr;
} }
else { else {
d_printf ("%s:%d %s: why there are three connecting referneces? ignoring way:%lld:%d", d_printf ("%s:%d %s: why there are three connecting referneces? ignoring way:%lld:%d",
@ -272,7 +272,7 @@ void rtrl_addwayname (struct rtdata *r, struct rtreflist *rtrl, struct map_way *
if (map_way_getdistance (mwtmp1, &ref->ways[nr].pos, NULL) * 1.5 < dist) { if (map_way_getdistance (mwtmp1, &ref->ways[nr].pos, NULL) * 1.5 < dist) {
fromdir[dir].id = mwdir[dir]->id; fromdir[dir].id = mwdir[dir]->id;
fromdir[dir].sid = mwdir[dir]->subid; fromdir[dir].sid = mwdir[dir]->subid;
// pnrdir[dir] = mwdir[dir]->n[i].d_pnr; pnrdir[dir] = mwdir[dir]->n[i].d_pnr;
mwdir[dir] = mwtmp1; mwdir[dir] = mwtmp1;
} }
else mwdir[dir] = NULL; else mwdir[dir] = NULL;
@ -968,8 +968,6 @@ void route_start (struct map_pos dest) {
} }
} }
if (app.status == APPSTATUS_quit) route_stop ();
if (route->state == ROUTING_CALC) { if (route->state == ROUTING_CALC) {
if ((++calcto) % 200 == 0) main_wnd_update (); if ((++calcto) % 200 == 0) main_wnd_update ();
} }

@ -1,103 +0,0 @@
/* $Id: wnd_mapcontext.c,v 1.2 2014/03/06 22:21:46 steffen Exp $ */
/***************************************************************************
* wnd_mapcontext.c
*
* 2014-02-12
* Copyright (C) 2014 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.
*
* sposmroute 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"
#include "routing.h"
void wnd_mapcontext_close ();
void wnd_mapcontext_addfav ();
void wnd_mapcontext_setdest ();
GUIItem *mcbtn_close = NULL;
GUIItem *mcbtn_addfav = NULL;
GUIItem *mcbtn_setdest = NULL;
static GUIWindow wmmapc = {0};
void wnd_mapcontext_show () {
if (wmmapc.screen == NULL) gui_window_new (&wmmapc, 200, 200, _("Map Menu"));
wmmapc.screen_changed = 1;
wmmapc.style = WGUI_S_VCENTER | WGUI_S_HCENTER;
/* add buttons */
if (mcbtn_addfav == NULL) mcbtn_addfav = gui_button_new (_("Add Favorites"), 5, 30, 110, 20);
if (mcbtn_setdest == NULL) mcbtn_setdest = gui_button_new (_("Set Destination"), 5, 60, 110, 20);
if (select_enabled) {
GUI_BUTTON_T(mcbtn_setdest)->col = GUI_BUTTON_T(mcbtn_addfav)->col = &color[COLOR_white][1];
GUI_BUTTON_T(mcbtn_setdest)->textcol = GUI_BUTTON_T(mcbtn_addfav)->textcol = &color[COLOR_white][3];
GUI_BUTTON_T(mcbtn_addfav)->callback_clicked = (void*)wnd_mapcontext_addfav;
GUI_BUTTON_T(mcbtn_setdest)->callback_clicked = (void*)wnd_mapcontext_setdest;
}
else {
GUI_BUTTON_T(mcbtn_setdest)->col = GUI_BUTTON_T(mcbtn_addfav)->col = &color[COLOR_white][1];
GUI_BUTTON_T(mcbtn_setdest)->textcol = GUI_BUTTON_T(mcbtn_addfav)->textcol = &color[COLOR_white][2];
GUI_BUTTON_T(mcbtn_addfav)->callback_clicked = NULL;
GUI_BUTTON_T(mcbtn_setdest)->callback_clicked = NULL;
}
gui_window_item_add (&wmmapc, mcbtn_addfav);
gui_window_item_add (&wmmapc, mcbtn_setdest);
if (mcbtn_close == NULL) {
mcbtn_close = gui_button_new (_("Close"), 5, 90, 110, 20);
GUI_BUTTON_T(mcbtn_close)->callback_clicked = (void*)wnd_mapcontext_close;
}
gui_window_item_add (&wmmapc, mcbtn_close);
gui_show (&wmmapc);
};
void wnd_mapcontext_close () {
d_printf ("gui_mapcontext_close");
gui_close ();
};
void wnd_mapcontext_setdest () {
static int _setdest = 0;
wmmapc.event_called = 0; // make events possible, because route_start will
// not come back until routing is finished or aborted.
d_printf ("gui_mapcontext_setdest");
d_printf ("set destination routing start");
gui_close ();
if (select_enabled == 0) d_printf ("no destination selected.");
if (_setdest == 1) d_printf ("routing already active");
else {
_setdest = 1;
route_start (select_pos);
_setdest = 0;
}
};
void wnd_mapcontext_addfav () {
d_printf ("gui_mapcontext_addfav");
gui_close ();
};

@ -1,112 +0,0 @@
/* $Id: wnd_routing.c,v 1.3 2013/06/20 21:28:04 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 <http://www.gnu.org/licenses/>.
*/
#include "osmroute.h"
#include "draw.h"
#include "gui.h"
#include "system.h"
static GUIWindow wrouting = {0};
GUIItem *wr_label[5] = { NULL };
GUIItem *wr_entrytxt = NULL;
GUIItem *wr_entrylon = NULL;
GUIItem *wr_entrylat = NULL;
GUIItem *wr_labellon = NULL;
GUIItem *wr_labellat = NULL;
GUIItem *wr_labeldest = NULL;
GUIItem *wr_btnfav = NULL;
GUIItem *wr_btnsearch = NULL;
GUIItem *wr_btnnavigate = NULL;
GUIItem *wr_btnclose = NULL;
void wnd_routing_search ();
void wnd_routing_navigate ();
void wnd_routing_close ();
void wnd_routing_fav ();
void wnd_routing_show () {
char text[128];
if (wrouting.screen == NULL) gui_window_new (&wrouting, 220, 130, NULL);
wrouting.screen_changed = 1;
wrouting.style = WGUI_S_VCENTER | WGUI_S_HCENTER;
if (wr_label[0] == NULL) wr_label[0] = gui_label_new (_("destination:"), 5, 5);
gui_window_item_add (&wrouting, wr_label[0]);
if (wr_entrytxt == NULL) wr_entrytxt = gui_entry_new ("", 80, 5, 100, 20);
gui_window_item_add (&wrouting, wr_entrytxt);
if (wr_btnsearch == NULL) wr_btnsearch = gui_button_new (_("Search"), 25, 55, 70, 20);
GUI_BUTTON_T(wr_btnsearch)->callback_clicked = wnd_routing_search;
gui_window_item_add (&wrouting, wr_btnsearch);
if (wr_btnfav == NULL) wr_btnfav = gui_button_new (_("Favorites"), 100, 55, 70, 20);
GUI_BUTTON_T(wr_btnfav)->callback_clicked = wnd_routing_fav;
gui_window_item_add (&wrouting, wr_btnfav);
if (wr_label[1] == NULL) wr_label[1] = gui_label_new (_("lon:"), 5, 30);
gui_window_item_add (&wrouting, wr_label[1]);
if (wr_entrylon == NULL) {
sprintf (text, "%9.6f", view_lon);
wr_entrylon = gui_entry_new (text, 30, 30, 75, 20);
}
gui_window_item_add (&wrouting, wr_entrylon);
if (wr_label[2] == NULL) wr_label[2] = gui_label_new (_("lat:"), 110, 30);
gui_window_item_add (&wrouting, wr_label[2]);
if (wr_entrylat == NULL) {
sprintf (text, "%9.6f", view_lat);
wr_entrylat = gui_entry_new (text, 135, 30, 75, 20);
}
gui_window_item_add (&wrouting, wr_entrylat);
if (wr_btnnavigate == NULL) wr_btnnavigate = gui_button_new (_("Navigate"), 60, 105, 75, 20);
GUI_BUTTON_T(wr_btnnavigate)->callback_clicked = wnd_routing_navigate;
gui_window_item_add (&wrouting, wr_btnnavigate);
if (wr_btnclose == NULL) wr_btnclose = gui_button_new (_("Close"), 140, 105, 75, 20);
GUI_BUTTON_T(wr_btnclose)->callback_clicked = wnd_routing_close;
gui_window_item_add (&wrouting, wr_btnclose);
gui_show (&wrouting);
};
void wnd_routing_fav () {
};
void wnd_routing_search () {
};
void wnd_routing_navigate () {
};
void wnd_routing_close () {
gui_close ();
};

@ -30,6 +30,7 @@
struct map_hash **mhash = NULL; struct map_hash **mhash = NULL;
int mhash_max = 0; int mhash_max = 0;
int mhash_pos = 0;
struct map_lsstat *mlsstat = NULL; struct map_lsstat *mlsstat = NULL;
int map_busy = 0; int map_busy = 0;
extern int map_search_fd; extern int map_search_fd;
@ -41,25 +42,12 @@ extern int map_search_fd;
*/ */
void map_init () { void map_init () {
int i, j; int i, j;
char fn[LEN_FILENAME];
d_printf ("map_init"); d_printf ("map_init");
d_printf (" MAP_HASH_DEGFACTOR:%f", MAP_HASH_DEGFACTOR); d_printf (" MAP_HASH_DEGFACTOR:%f", MAP_HASH_DEGFACTOR);
d_printf (" MAP_OSMWEB_DELTA:%f", MAP_OSMWEB_DELTA); d_printf (" MAP_OSMWEB_DELTA:%f", MAP_OSMWEB_DELTA);
d_printf (" MAP_LSHASHFACTOR:%d", MAP_LSHASHFACTOR); d_printf (" MAP_LSHASHFACTOR:%d", MAP_LSHASHFACTOR);
d_printf (" MAP_LSSTAT_MAX:%d", MAP_LSSTAT_MAX); d_printf (" MAP_LSSTAT_MAX:%d", MAP_LSSTAT_MAX);
d_printf (" Directory: %s", cfg.mappath);
strncpy (fn, cfg.mappath, LEN_FILENAME);
if (fn[(i=strlen(fn))-1] == DIR_SEP) fn[i] = '\0';
else {
d_printf (" append '%c' to mappath.", DIR_SEP);
cfg.mappath[strlen(cfg.mappath)+1] = '\0';
cfg.mappath[strlen(cfg.mappath)] = DIR_SEP;
}
if (!dir_exist (fn)) {
d_printf ("***************** dir does not exist **************************");
}
if (mlsstat == NULL) if (mlsstat == NULL)
mlsstat = (struct map_lsstat*) ml_malloc (MAP_LSSTAT_MAX*sizeof (struct map_lsstat)); mlsstat = (struct map_lsstat*) ml_malloc (MAP_LSSTAT_MAX*sizeof (struct map_lsstat));
@ -82,6 +70,7 @@ void map_init () {
mhash_max = MAP_HASH_MAX; mhash_max = MAP_HASH_MAX;
mhash = (struct map_hash**) ml_malloc (sizeof (void*) * (mhash_max)); mhash = (struct map_hash**) ml_malloc (sizeof (void*) * (mhash_max));
mhash_pos = mhash_max/2;
for (i = 0; i < mhash_max; i++) for (i = 0; i < mhash_max; i++)
mhash[i] = NULL; mhash[i] = NULL;
}; };
@ -251,9 +240,6 @@ void map_refresh (float lon, float lat) {
map_ls_get_filename (rfn, LEN_FILENAME, map_geo2igeo (lon), map_geo2igeo (lat)); map_ls_get_filename (rfn, LEN_FILENAME, map_geo2igeo (lon), map_geo2igeo (lat));
#if defined(SPOSMROUTE) #if defined(SPOSMROUTE)
map_webload (fn, rfn, NULL); map_webload (fn, rfn, NULL);
map_clear ();
map_init ();
draw_redrawmap ();
#endif #endif
}; };
@ -307,12 +293,6 @@ void map_refreshblock (struct map_pos start, struct map_pos end, float delta) {
#endif #endif
} }
} }
map_clear ();
map_init ();
#if defined(SPOSMROUTE)
draw_redrawmap ();
#endif
}; };

@ -34,7 +34,7 @@
#define MAP_W_NAMELEN 64 #define MAP_W_NAMELEN 64
#define MAP_HASH_DEGFACTOR 80.0f #define MAP_HASH_DEGFACTOR 80.0f
#define MAP_OSMWEB_DELTA 0.0125f #define MAP_OSMWEB_DELTA 0.025f
#define MAP_LSHASHFACTOR 80 #define MAP_LSHASHFACTOR 80
#define MAP_LSFREECNT 4096 #define MAP_LSFREECNT 4096
@ -44,7 +44,7 @@
#define MAP_LSSTAT_MAX 128 #define MAP_LSSTAT_MAX 128
#endif #endif
#define MAP_LSSIZE_HASH 28 #define MAP_LSSIZE_HASH 28
#define MAP_LSSIZE_WAY 14 #define MAP_LSSIZE_WAY 16
#define MAP_LSSIZE_WAYNODE 23 #define MAP_LSSIZE_WAYNODE 23
#define MAP_LSSIZE_POS 8 #define MAP_LSSIZE_POS 8
#define MAP_LSSIZE_AREA 12 #define MAP_LSSIZE_AREA 12
@ -53,7 +53,7 @@
#define MAP_SEARCHLINE_LEN 128 #define MAP_SEARCHLINE_LEN 128
#define MAP_HASH_DEFAULTSIZE 0x20000 #define MAP_HASH_DEFAULTSIZE 4096
#if defined(__MINGW32CE__) || defined(_WIN32_WCE) #if defined(__MINGW32CE__) || defined(_WIN32_WCE)
#define MAP_HASH_MAX 128 #define MAP_HASH_MAX 128
@ -176,7 +176,6 @@ struct map_way {
struct map_area { struct map_area {
char status; char status;
unsigned long long int id; unsigned long long int id;
unsigned short int subid;
unsigned char type; unsigned char type;
unsigned char flags; unsigned char flags;
@ -376,7 +375,6 @@ extern struct map_way *map_way_find (struct map_hash *mh, unsigned long long int
extern void map_way_copy (struct map_way *dest, struct map_way *src); extern void map_way_copy (struct map_way *dest, struct map_way *src);
extern int map_way_add (struct map_way *way, int loadflags); extern int map_way_add (struct map_way *way, int loadflags);
extern int map_way_add_to_hash (struct map_hash *mh, struct map_way *mw); extern int map_way_add_to_hash (struct map_hash *mh, struct map_way *mw);
extern int map_way_append_to_hash (struct map_hash *mh, struct map_way *mw);
extern int map_way_getsize (struct map_way *way); extern int map_way_getsize (struct map_way *way);
extern int map_way_findclosest (struct map_pos *pos, struct map_pos *waypos, int idh, char *name, int namelen, unsigned long long int *closest_id, unsigned short int *closest_sid); extern int map_way_findclosest (struct map_pos *pos, struct map_pos *waypos, int idh, char *name, int namelen, unsigned long long int *closest_id, unsigned short int *closest_sid);
extern float map_way_getdistance (struct map_way *mw, struct map_pos *pos, struct map_pos *waypos); extern float map_way_getdistance (struct map_way *mw, struct map_pos *pos, struct map_pos *waypos);
@ -391,7 +389,6 @@ extern struct map_area *map_area_find (struct map_hash *mh, unsigned long long i
extern void map_area_copy (struct map_area *dest, struct map_area *src); extern void map_area_copy (struct map_area *dest, struct map_area *src);
extern int map_area_add (struct map_area *area, int loadflags); extern int map_area_add (struct map_area *area, int loadflags);
extern int map_area_add_to_hash (struct map_hash *mh, struct map_area *ma); extern int map_area_add_to_hash (struct map_hash *mh, struct map_area *ma);
extern int map_area_append_to_hash (struct map_hash *mh, struct map_area *ma);
extern int map_area_getsize (struct map_area *area); extern int map_area_getsize (struct map_area *area);

@ -32,27 +32,6 @@
* *
*/ */
/*
* add the area without checking for it's size, also no update is done
*/
int map_area_append_to_hash (struct map_hash *mh, struct map_area *ma) {
int size;
struct map_area *a = mh->areas;
mh->areas = (struct map_area*) map_hash_getfree_aligned (mh, POINTERALIGNMENT);
/* copy the area data to the free entry
* calc size and set free entry to it's new place */
size = map_area_getsize (ma);
map_area_copy (mh->areas, ma);
mh->areas->next = a;
mh->free = mh->free + size;
mh->areascnt++;
SETFLAG(mh->status, MS_changed);
return 1;
};
/* /*
* add the area without checking for it's size, but do an update * add the area without checking for it's size, but do an update
*/ */
@ -60,18 +39,11 @@ int map_area_add_to_hash (struct map_hash *mh, struct map_area *ma) {
int size; int size;
struct map_area *a; struct map_area *a;
/* check if the first element is already the one we want to update */
if (mh->areas && mh->areas->id == ma->id && mh->areas->subid == ma->subid) {
mh->areas = mh->areas->next;
mh->areascnt--;
}
/* find possible update and go to the end */
if (mh->areas) { if (mh->areas) {
/* find last way */ /* find last way */
a = mh->areas; a = mh->areas;
while (a && a->next) { while (a && a->next) {
if (a->next->id == ma->id && a->next->subid == a->subid) { if (a->next->id == ma->id) {
/* found old way.. just delete .. */ /* found old way.. just delete .. */
a->next = a->next->next; a->next = a->next->next;
mh->areascnt--; mh->areascnt--;
@ -113,8 +85,6 @@ int map_area_add (struct map_area *area, int loadflags) {
int size; int size;
if (area->p == NULL || area->p_cnt == 0) return 0; if (area->p == NULL || area->p_cnt == 0) return 0;
// area->type = area->subid % MAREA_campsite + 1;
// d_printf ("subid:%d type:%d cnt:%d", area->subid, area->type, area->p_cnt);
size = map_area_getsize (area); size = map_area_getsize (area);
mh = map_hash_get (area->p[0].lon, area->p[0].lat, loadflags); mh = map_hash_get (area->p[0].lon, area->p[0].lat, loadflags);
@ -140,7 +110,6 @@ void map_area_copy (struct map_area *dest, struct map_area *src) {
int i; int i;
dest->id = src->id; dest->id = src->id;
dest->subid = src->subid;
dest->type = src->type; dest->type = src->type;
dest->p_cnt = src->p_cnt; dest->p_cnt = src->p_cnt;
dest->p = (struct map_pos*) (dest->data); dest->p = (struct map_pos*) (dest->data);

@ -73,26 +73,37 @@ struct map_hash *map_hash_geti (int ilon, int ilat, int loadflags) {
struct map_hash *res = NULL; struct map_hash *res = NULL;
int hi; int hi;
for (hi = 0; hi < mhash_max; hi++) hi = mhash_pos;
if (mhash[hi] && mhash[hi]->pos.ilon == ilon && mhash[hi]->pos.ilat == ilat) { if (mhash[hi] && mhash[hi]->pos.ilon == ilon && mhash[hi]->pos.ilat == ilat) res = mhash[hi];
res = mhash[hi]; else {
for (; hi > 0; hi--) mhash[hi] = mhash[hi-1]; hi = mhash_pos+1;
mhash[0] = res; if (hi >= mhash_max) hi = 0;
return res; while (hi != mhash_pos) {
} if (mhash[hi] && mhash[hi]->pos.ilon == ilon && mhash[hi]->pos.ilat == ilat) {
res = mhash[hi];
break;
}
if (loadflags & MHLOAD_RELOAD) { if (++hi >= mhash_max) hi = 0;
if (mhash[mhash_max-1]) {
map_hash_free (mhash[mhash_max-1], 1);
mhash[mhash_max-1] = NULL;
} }
memmove (&mhash[1], &mhash[0], sizeof (struct map_hash*)*mhash_max-1);
mhash[0] = NULL;
res = map_load_hash (ilon, ilat); if (res == NULL && loadflags & MHLOAD_RELOAD) {
if (res) { res = map_load_hash (ilon, ilat);
mhash[0] = res; if (res) {
DELFLAG (res->status, MS_changed); if ((--mhash_pos) < 0) mhash_pos = mhash_max-1;
/* add on the givin place, delete old entry */
if (mhash[mhash_pos]) {
map_hash_free (mhash[mhash_pos], 1);
mhash[mhash_pos] = NULL;
}
/* add or update */
if (mhash[mhash_pos] != NULL) d_printf ("%s:%d map_hash_add: memory leak: not free spot", __FILE__, __LINE__);
mhash[mhash_pos] = res;
DELFLAG (res->status, MS_changed);
}
} }
} }
@ -105,22 +116,18 @@ struct map_hash *map_hash_geti (int ilon, int ilat, int loadflags) {
* if it already excist exchange it and free the old hash data from the memory * if it already excist exchange it and free the old hash data from the memory
*/ */
int map_hash_add (struct map_hash *mh) { int map_hash_add (struct map_hash *mh) {
int i, fi = -1; /* fi: free hash position */ int i;
struct map_hash *mhold = NULL; struct map_hash *mhold = NULL;
if (mh == NULL) return 0; if (mh == NULL) return 0;
/* check if we need to "UPDATE" or to add the hash data */ /* check if we need to "UPDATE" or to add the hash data */
for (mhold = NULL, i = 0; i < mhash_max; i++) { for (mhold = NULL, i = 0; i < mhash_max; i++) if (mhash[i]) {
if (mhash[i]) {
if (mhash[i]->pos.ilon == mh->pos.ilon && mhash[i]->pos.ilat == mh->pos.ilat) { if (mhash[i]->pos.ilon == mh->pos.ilon && mhash[i]->pos.ilat == mh->pos.ilat) {
mhold = mhash[i]; mhold = mhash[i];
fi = i;
break; break;
} }
} }
else if (fi == -1) fi = i;
}
if (mhold != NULL) { /* update !! NOSAVEING !! */ if (mhold != NULL) { /* update !! NOSAVEING !! */
mhash[i] = NULL; mhash[i] = NULL;
@ -128,18 +135,18 @@ int map_hash_add (struct map_hash *mh) {
mhold = NULL; mhold = NULL;
} }
if ((--mhash_pos) < 0) mhash_pos = mhash_max-1;
/* add on the givin place, delete old entry */ /* add on the givin place, delete old entry */
if (fi == -1) { mhold = NULL;
if (mhash[mhash_max-1]) { if (mhash[mhash_pos]) {
map_hash_free (mhash[mhash_max-1], 1); map_hash_free (mhash[mhash_pos], 1);
mhash[mhash_max-1] = NULL; mhash[mhash_pos] = NULL;
}
memmove (&mhash[0], &mhash[1], sizeof (struct map_hash*)*mhash_max-1);
mhash[0] = NULL;
mhash[0] = mh;
} }
else
mhash[fi] = mh; /* add or update */
if (mhash[mhash_pos] != NULL) d_printf ("%s:%d map_hash_add: memory leak: not free spot", __FILE__, __LINE__);
mhash[mhash_pos] = mh;
return 1; return 1;
}; };
@ -167,11 +174,10 @@ void map_hash_free (struct map_hash *mh, int noremove) {
* allocate new memory, copy all the data and free the momory again. * allocate new memory, copy all the data and free the momory again.
*/ */
struct map_hash *map_hash_realloc (struct map_hash *mhorg, int memsize) { struct map_hash *map_hash_realloc (struct map_hash *mhorg, int memsize) {
struct map_hash *res = NULL; struct map_hash *res;
int i = memsize; int i = memsize;
if (i < mhorg->datasize) return res; if (i < mhorg->datasize) i = mhorg->datasize;
res = map_hash_alloc (i); res = map_hash_alloc (i);
map_hash_copy (res, mhorg); map_hash_copy (res, mhorg);
@ -208,7 +214,7 @@ void map_hash_copy (struct map_hash *hd, struct map_hash *hs) {
i = 0; i = 0;
mw = hs->ways; mw = hs->ways;
while (mw && i < hs->wayscnt) { while (mw && i < hs->wayscnt) {
map_way_append_to_hash (hd, mw); map_way_add_to_hash (hd, mw);
mw = mw->next; mw = mw->next;
i++; i++;
} }
@ -220,7 +226,7 @@ void map_hash_copy (struct map_hash *hd, struct map_hash *hs) {
ma = hs->areas; ma = hs->areas;
i = 0; i = 0;
while (ma && i < hs->areascnt) { while (ma && i < hs->areascnt) {
map_area_append_to_hash (hd, ma); map_area_add_to_hash (hd, ma);
ma = ma->next; ma = ma->next;
i++; i++;
} }

@ -38,8 +38,6 @@
#include "memoryleak.h" #include "memoryleak.h"
#include "osmroute.h" #include "osmroute.h"
#define MAP_BITS_SUBID 8
char *lsrw_data = NULL; char *lsrw_data = NULL;
int lsrw_data_size = 0; int lsrw_data_size = 0;
char *lshash_data = NULL; char *lshash_data = NULL;
@ -217,7 +215,7 @@ struct map_lsstat *map_ls_statopen (char *fname) {
mlss.r_fd = mlss.w_fd = 0; mlss.r_fd = mlss.w_fd = 0;
mlss.changed = 0; mlss.changed = 0;
if (file_exist (mlss.fname) == 0) { if (file_exist (mlss.fname) == NULL) {
d_printf ("map_ls_statopen file '%s' not found.", mlss.fname); d_printf ("map_ls_statopen file '%s' not found.", mlss.fname);
mlss.r_fd = 0; mlss.r_fd = 0;
return &mlss; return &mlss;
@ -578,8 +576,9 @@ char *map_ls_hash2data (struct map_hash *mh, int *size) {
/* save the basic data */ /* save the basic data */
ui64 = mw->id; /* id */ ui64 = mw->id; /* id */
ui64 = (ui64 << MAP_BITS_SUBID) | mw->subid;
woutpos = mempush (woutpos, &ui64, 8); woutpos = mempush (woutpos, &ui64, 8);
ui16 = mw->subid; /* subid */
woutpos = mempush (woutpos, &ui16, 2);
ui8 = mw->type; /* type */ ui8 = mw->type; /* type */
woutpos = mempush (woutpos, &ui8, 1); woutpos = mempush (woutpos, &ui8, 1);
ui8 = mw->flags; /* flags */ ui8 = mw->flags; /* flags */
@ -645,7 +644,7 @@ char *map_ls_hash2data (struct map_hash *mh, int *size) {
map_ls_hashdatacheckpos (*size, &woutpos); map_ls_hashdatacheckpos (*size, &woutpos);
/* save the basic data */ /* save the basic data */
ui64 = (ma->id << MAP_BITS_SUBID) | ma->subid; /* id */ ui64 = ma->id; /* id */
woutpos = mempush (woutpos, &ui64, 8); woutpos = mempush (woutpos, &ui64, 8);
ui8 = ma->type; /* type */ ui8 = ma->type; /* type */
woutpos = mempush (woutpos, &ui8, 1); woutpos = mempush (woutpos, &ui8, 1);
@ -840,8 +839,9 @@ struct map_hash *map_ls_data2hash (char *data, int size) {
for (cnt = 0; cnt < lsh.ways; cnt++) { for (cnt = 0; cnt < lsh.ways; cnt++) {
/* load basic data */ /* load basic data */
inpos = mempop (inpos, &ui64, 8); inpos = mempop (inpos, &ui64, 8);
way->subid = ui64 % (1<<MAP_BITS_SUBID); way->id = ui64;
way->id = (ui64 >> MAP_BITS_SUBID); inpos = mempop (inpos, &ui16, 2);
way->subid = ui16;
inpos = mempop (inpos, &ui8, 1); inpos = mempop (inpos, &ui8, 1);
way->type = ui8; way->type = ui8;
inpos = mempop (inpos, &ui8, 1); inpos = mempop (inpos, &ui8, 1);
@ -914,7 +914,6 @@ struct map_hash *map_ls_data2hash (char *data, int size) {
area->next = NULL; area->next = NULL;
inpos = mempop (inpos, &ui64, 8); inpos = mempop (inpos, &ui64, 8);
area->subid = ui64 % (1<<MAP_BITS_SUBID);
area->id = ui64; area->id = ui64;
inpos = mempop (inpos, &ui8, 1); inpos = mempop (inpos, &ui8, 1);
area->type = ui8; area->type = ui8;
@ -1115,7 +1114,7 @@ void map_save_all () {
if (map_save_hash (mhash[i]) == 0) DELFLAG(mhash[i]->status, MS_changed); if (map_save_hash (mhash[i]) == 0) DELFLAG(mhash[i]->status, MS_changed);
break; break;
} }
main_wnd_update (); main_wnd_loop (i, mhash_max);
} }
for (i = 0; i < MAP_LSSTAT_MAX; i++) { for (i = 0; i < MAP_LSSTAT_MAX; i++) {

@ -34,7 +34,6 @@
#include "map.h" #include "map.h"
#include "system.h" #include "system.h"
#include "memoryleak.h" #include "memoryleak.h"
#include "vector.h"
#include <locale.h> #include <locale.h>
#include <unistd.h> #include <unistd.h>
@ -120,9 +119,7 @@ struct s_osm_xmlcallback {
long long int filepos; long long int filepos;
}; };
// #define OSM_HASHNODES 16
// number of Hashnodes to keep in memory
#define OSM_HASHNODES 32
static struct s_osm_hashnodes _hashnodes[OSM_HASHNODES]; static struct s_osm_hashnodes _hashnodes[OSM_HASHNODES];
static struct s_osm_hashnodes *hashnodes[OSM_HASHNODES]; static struct s_osm_hashnodes *hashnodes[OSM_HASHNODES];
@ -193,7 +190,6 @@ void osm_waynodes_checknode (struct s_osm_hashnodes *nhash, struct osm_node *nod
void osm_marea_new (struct s_osmmarea *a, int max); void osm_marea_new (struct s_osmmarea *a, int max);
void osm_area_save (struct osm_way *oway, struct s_osmmarea *marea); void osm_area_save (struct osm_way *oway, struct s_osmmarea *marea);
int osm_area_split_add (struct s_osmmarea *marea);
void osm_nodedetail_save (struct osm_nodedetail *onoded, struct osm_node *node); void osm_nodedetail_save (struct osm_nodedetail *onoded, struct osm_node *node);
@ -417,7 +413,7 @@ struct s_osm_hashnodes *osm_hashnodes_load (short int hid, int loadhash) {
/* /*
* all data will be saved immediately so we need only to close the file * all data will be saved imedatly so we need only to close the file
*/ */
void osm_hashnodes_free (struct s_osm_hashnodes *hnode) { void osm_hashnodes_free (struct s_osm_hashnodes *hnode) {
if (hnode->hid == -1) return; if (hnode->hid == -1) return;
@ -663,8 +659,7 @@ int osm_node_load (struct osm_node *node, unsigned long long int id) {
* save the waynode data inside the hash file to read all needed data later on * save the waynode data inside the hash file to read all needed data later on
* and check the waynodes inside the map files. * and check the waynodes inside the map files.
*/ */
void osm_waynode_add (struct osm_node *node, long long int nodepos, unsigned long long int id, void osm_waynode_add (struct osm_node *node, long long int nodepos, unsigned long long int id, unsigned short int subid, unsigned short int pnr) {
unsigned short int subid, unsigned short int pnr) {
struct s_osm_hashnodes *hnodes = NULL; struct s_osm_hashnodes *hnodes = NULL;
struct osm_nodehash hash; struct osm_nodehash hash;
struct osm_waynode wn; struct osm_waynode wn;
@ -700,8 +695,7 @@ void osm_waynode_add (struct osm_node *node, long long int nodepos, unsigned lon
do { do {
lseek (hnodes->nodes_fd, wpos, SEEK_SET); lseek (hnodes->nodes_fd, wpos, SEEK_SET);
if (read (hnodes->nodes_fd, &wn, sizeof (struct osm_waynode)) < sizeof (struct osm_waynode)) { if (read (hnodes->nodes_fd, &wn, sizeof (struct osm_waynode)) < sizeof (struct osm_waynode)) {
d_printf ("%s:%d could not read data from file:%s pos:%d", __FILE__, __LINE__, d_printf ("%s:%d could not read data from file:%s pos:%d", __FILE__, __LINE__, hnodes->fnnodes, hash.pos);
hnodes->fnnodes, hash.pos);
errorexit (-1); errorexit (-1);
} }
wpos = wn.next; wpos = wn.next;
@ -712,8 +706,7 @@ void osm_waynode_add (struct osm_node *node, long long int nodepos, unsigned lon
pos = 0 - (long long int)sizeof (struct osm_waynode); pos = 0 - (long long int)sizeof (struct osm_waynode);
lseek (hnodes->nodes_fd, pos, SEEK_CUR); lseek (hnodes->nodes_fd, pos, SEEK_CUR);
if (write (hnodes->nodes_fd, &wn, sizeof (struct osm_waynode)) < sizeof (struct osm_waynode)) { if (write (hnodes->nodes_fd, &wn, sizeof (struct osm_waynode)) < sizeof (struct osm_waynode)) {
d_printf ("%s:%d could not write data to file:%s pos:%d", __FILE__, __LINE__, d_printf ("%s:%d could not write data to file:%s pos:%d", __FILE__, __LINE__, hnodes->fnnodes, hash.pos);
hnodes->fnnodes, hash.pos);
errorexit (-1); errorexit (-1);
} }
} }
@ -725,6 +718,7 @@ void osm_waynode_add (struct osm_node *node, long long int nodepos, unsigned lon
d_printf ("%s:%d could not read data from file:%s pos:%d", __FILE__, __LINE__, hnodes->fnnodes, hash.pos); d_printf ("%s:%d could not read data from file:%s pos:%d", __FILE__, __LINE__, hnodes->fnnodes, hash.pos);
errorexit (-1); errorexit (-1);
} }
return; return;
}; };
@ -739,15 +733,14 @@ void osm_waynodes_check () {
for (hid = 0; hid < osm_hidmax; hid++) { for (hid = 0; hid < osm_hidmax; hid++) {
sprintf (text, _("checking for waynodes in hid %d"), hid); sprintf (text, _("checking for waynodes in hid %d"), hid);
app_status (-1, text, 0.0); app_status (text, 0);
ohash = osm_hashnodes_load (hid, 1); ohash = osm_hashnodes_load (hid, 1);
for (i = 0; i < ohash->hash_cnt; i++) { for (i = 0; i < ohash->hash_cnt; i++) {
if ((i%1024) == 0) main_wnd_loop (i, ohash->hash_cnt); if ((i%1024) == 0) main_wnd_loop (i, ohash->hash_cnt);
/* read node */ /* read node */
lseek (ohash->nodes_fd, ohash->hash[i].pos, SEEK_SET); lseek (ohash->nodes_fd, ohash->hash[i].pos, SEEK_SET);
if (read (ohash->nodes_fd, &node, sizeof (struct osm_node)) < sizeof (struct osm_node)) { if (read (ohash->nodes_fd, &node, sizeof (struct osm_node)) < sizeof (struct osm_node)) {
d_printf ("%s:%d could not read data from file:%s pos:%d", __FILE__, __LINE__, d_printf ("%s:%d could not read data from file:%s pos:%d", __FILE__, __LINE__, ohash->fnnodes, ohash->hash[i].pos);
ohash->fnnodes, ohash->hash[i].pos);
errorexit (-1); errorexit (-1);
} }
osm_waynodes_checknode (ohash, &node); osm_waynodes_checknode (ohash, &node);
@ -783,8 +776,7 @@ void osm_waynodes_checknode (struct s_osm_hashnodes *ohash, struct osm_node *nod
do { do {
/* read waynode */ /* read waynode */
if (read (ohash->nodes_fd, &osm_wnode[wncnt], sizeof (struct osm_waynode)) < sizeof (struct osm_waynode)) { if (read (ohash->nodes_fd, &osm_wnode[wncnt], sizeof (struct osm_waynode)) < sizeof (struct osm_waynode)) {
d_printf ("%s:%d could not read data from file:%s pos:%d", d_printf ("%s:%d could not read data from file:%s pos:%d", __FILE__, __LINE__, ohash->fnnodes, osm_wnode[wncnt].next);
__FILE__, __LINE__, ohash->fnnodes, osm_wnode[wncnt].next);
errorexit (-1); errorexit (-1);
} }
lseek (ohash->nodes_fd, osm_wnode[wncnt].next, SEEK_SET); lseek (ohash->nodes_fd, osm_wnode[wncnt].next, SEEK_SET);
@ -1020,7 +1012,6 @@ void osm_marea_new (struct s_osmmarea *a, int max) {
} }
a->marea->id = 0; a->marea->id = 0;
a->marea->subid = 0;
a->marea->type = MAREA_unknown; a->marea->type = MAREA_unknown;
a->marea->p = (struct map_pos*) a->marea->data; a->marea->p = (struct map_pos*) a->marea->data;
a->marea->p_cnt = 0; a->marea->p_cnt = 0;
@ -1032,8 +1023,7 @@ void osm_marea_new (struct s_osmmarea *a, int max) {
* hash data block. I case the way goes over more hash segments the * hash data block. I case the way goes over more hash segments the
* way will be slit into peaces * way will be slit into peaces
* *
* splitting into peaces does not work yet, also taking care of the * splitting into peaces does not work yet
* polygons, no angles over 180°.
* *
* CALL with NULL will free all unneeded memory * CALL with NULL will free all unneeded memory
*/ */
@ -1044,7 +1034,6 @@ void osm_area_save (struct osm_way *oway, struct s_osmmarea *area ) {
static int nodestat_alloc = 0; // size of the struct static int nodestat_alloc = 0; // size of the struct
struct map_pos pos, p1; // current hash, pos struct map_pos pos, p1; // current hash, pos
struct osm_node curnode, node; // current node, node struct osm_node curnode, node; // current node, node
int sid = 0;
/* check if we just need to free all data */ /* check if we just need to free all data */
if (oway == NULL) { if (oway == NULL) {
@ -1114,7 +1103,6 @@ void osm_area_save (struct osm_way *oway, struct s_osmmarea *area ) {
/* save first node */ /* save first node */
area->marea->id = oway->wid; area->marea->id = oway->wid;
area->marea->subid = sid;
area->marea->type = oway->type; area->marea->type = oway->type;
area->marea->p_cnt = 1; area->marea->p_cnt = 1;
area->marea->p = (struct map_pos *) area->marea->data; area->marea->p = (struct map_pos *) area->marea->data;
@ -1130,8 +1118,7 @@ void osm_area_save (struct osm_way *oway, struct s_osmmarea *area ) {
if (++nd >= oway->ncnt) nd = 0; /* count +1, check for overrun */ if (++nd >= oway->ncnt) nd = 0; /* count +1, check for overrun */
while (nd != ndfirst) { while (nd != ndfirst) {
if (osm_node_load (&node, oway->nid[nd]) == -1) { if (osm_node_load (&node, oway->nid[nd]) == -1) {
d_printf ("%s:%d osm_area_save count not find node number: %lld", d_printf ("%s:%d osm_area_save count not find node number: %lld", __FILE__, __LINE__, oway->nid[nd]);
__FILE__, __LINE__, oway->nid[nd]);
return; return;
} }
pos.lon = node.lon; pos.lon = node.lon;
@ -1161,7 +1148,7 @@ void osm_area_save (struct osm_way *oway, struct s_osmmarea *area ) {
} }
if (++nd >= oway->ncnt) nd = 0; /* count +1, check for overrun */ if (++nd >= oway->ncnt) nd = 0; /* count +1, check for overrun */
} }
osm_area_split_add (area); map_area_add (area->marea, MHLOAD_RELOAD);
} }
} while (ndfirst < oway->ncnt); } while (ndfirst < oway->ncnt);
@ -1169,218 +1156,10 @@ void osm_area_save (struct osm_way *oway, struct s_osmmarea *area ) {
}; };
/*
* convert area into a polygon without angles above 180°
* it saves time late in drawing on slow devices.
* only needed because of GL_TRIANGLE_STRIP and return
* last subid saved.
*/
struct s_osmareapnt {
int pnr;
fPoint km;
float angle;
float sel_dist;
float sel_angle;
};
#define MAX_SUBID 250
int osm_area_split_add (struct s_osmmarea *marea) {
/* allocate enought memory */
struct map_area *a = NULL;
struct s_osmareapnt *pt = ml_malloc (sizeof (struct s_osmareapnt) * marea->marea->p_cnt);
int i, st, pt_c, c;
int _debug = 0, rotated = 0;
float angle_sum;
// if (marea->marea->id == 22963835) _debug = 1;
// else return 1;
// d_printf ("marea: %lld cnt:%d", marea->marea->id, marea->marea->p_cnt);
// map_area_add (marea->marea, MHLOAD_RELOAD);
// return 1;
if (_debug) d_printf ("area:%lld:%d", marea->marea->id, marea->marea->subid);
a = ml_malloc (map_area_getsize (marea->marea));
map_area_copy (a, marea->marea);
/* calculate all klon, klat and prepare start struct, also
* ignore double entrys */
for (pt_c = 0, i = 0; i < marea->marea->p_cnt; i++) {
if (i == 0) st = marea->marea->p_cnt-1;
else st = i-1;
if (marea->marea->p[i].lon == marea->marea->p[st].lon
&& marea->marea->p[i].lat == marea->marea->p[st].lat) continue;
pt[pt_c].pnr = i;
pt[pt_c].angle = -1.0;
pt[pt_c].km.x = map_lon2km (marea->marea->p[i].lon, marea->marea->p[i].lat);
pt[pt_c].km.y = map_lat2km (marea->marea->p[i].lat);
if (_debug) d_printf ("pt[%-3d].pnr:%d km.x:%f km.y:%f", pt_c, pt[pt_c].pnr, pt[pt_c].km.x, pt[pt_c].km.y);
pt_c++;
}
while (pt[0].pnr >= 0 && pt_c > 2 && a->subid < MAX_SUBID) {
/* st - will keep first pt to start checking polygon
* c - count how many angles are above 180° */
if (_debug) d_printf ("**************** subid:%d pt_c:%d", a->subid, pt_c);
for (angle_sum = 0.0, st = -1, c = 0, i = 0; i < pt_c; i++) {
if (i == pt_c-1) pt[i].angle = point_angle (pt[i-1].km, pt[i].km, pt[0].km);
else if (i == 0) pt[i].angle = point_angle (pt[pt_c-1].km, pt[i].km, pt[i+1].km);
else pt[i].angle = point_angle (pt[i-1].km, pt[i].km, pt[i+1].km);
if (pt[i].angle > M_PI) { /* only select first pt */
if (st == -1) st = i;
else if (pt[st].angle < pt[i].angle) st = i;
c++;
}
angle_sum += pt[i].angle;
if (_debug) d_printf ("i:%-2d pnr:%-2d angle:%f",i, pt[i].pnr, pt[i].angle);
}
angle_sum /= (float)pt_c;
if (_debug) d_printf ("c:%d pt_c:%d st:%d angle_sum:%f",c, pt_c, st, angle_sum);
/* make sure we going counterclock direction, only first area */
if (rotated == 0 && angle_sum > M_PI && a->subid == marea->marea->subid) {
struct s_osmareapnt *pt_ = ml_malloc (sizeof (struct s_osmareapnt) * pt_c);
if (_debug) d_printf ("change rotation ...");
for (i = 0; i < pt_c; i++) pt_[pt_c - i - 1] = pt[i];
ml_free (pt);
pt = pt_;
rotated = 1;
continue;
}
/* if c==0 save last areapart */
else if (c == 0) {
a->p_cnt = 0;
for (i = 0; i < pt_c; i++) {
if (_debug) d_printf ("0: added %d pnr:%d", a->p_cnt, pt[i].pnr);
a->p[a->p_cnt++] = marea->marea->p[pt[i].pnr];
pt[i].pnr = -1;
}
map_area_add (a, MHLOAD_RELOAD);
a->subid++;
}
/* if c==1 select j as 0 then quit, if GL_TRIANGLE_STRIP gets kicked out of
* openGL we need to change this */
else if (c == 1) {
for (a->p_cnt = 0, i = st; a->p_cnt < pt_c;) {
if (_debug) d_printf ("1: added %d pnr:%d", a->p_cnt, pt[i].pnr);
a->p[a->p_cnt++] = marea->marea->p[pt[i].pnr];
pt[i].pnr = -1;
if (i < pt_c-1) i++;
else i = 0;
}
map_area_add (a, MHLOAD_RELOAD);
a->subid++;
}
/* check again for the part to split the area. */
else {
int j, sel, s, i_old, c;
float dist;
float angle;
/* check if selected start is working for us */
sel = st;
i_old = -1;
do {
/* fill up all sel_angles and sel_dists */
if (sel < pt_c-1) s = sel + 1;
else s = 0;
if (_debug) d_printf ("select %d [pnr:%d] second:%d", sel, pt[sel].pnr, s);
for (i = 0; i < pt_c; i++) {
if (i != sel) {
pt[i].sel_angle = point_angle (pt[i].km, pt[sel].km, pt[s].km);
pt[i].sel_dist = vec_len (vec_sub (pt[i].km, pt[sel].km));
}
else {
pt[i].sel_angle = -2.0;
pt[i].sel_dist = -2.0;
}
if (_debug) d_printf (" %-2d pnr:%-2d angle:%f dist:%f", i, pt[i].pnr, pt[i].sel_angle, pt[i].sel_dist);
}
a->p_cnt = 0;
a->p[a->p_cnt++] = marea->marea->p[pt[sel].pnr];
angle = 0.0;
if (_debug) d_printf (" check for possible loop: i:%d s:%d st:%d sel:%d angle:%f pt[i].sel_angle:%f", i, s, st, sel, angle, pt[i].sel_angle);
for (i_old = -1, i = s, angle = 0.0; i != sel && angle <= pt[i].sel_angle;) {
if (_debug) d_printf (" i:%d sel:%d angle:%f pt[i].sel_angle:%f", i, st, angle, pt[i].sel_angle);
for (j = i; j != sel;) {
if (_debug) d_printf (" j:%d (pnr:%d, angle:%f, dist:%f) i:%d (pnr:%d, angle:%f, dist:%f) ", j, pt[j].pnr, pt[j].sel_angle, pt[j].sel_dist, i, pt[i].pnr, pt[i].sel_angle, pt[i].sel_dist);
if (pt[i].sel_angle > pt[j].sel_angle && pt[i].sel_dist > pt[j].sel_dist) {
if (_debug) d_printf (" break 1");
break;
}
j++; if (j >= pt_c) j = 0;
}
if (j != sel) {
/* something is in the way */
if (_debug) d_printf (" break 2");
break;
}
else {
/* found something */
if (i_old >= 0) pt[i_old].pnr = -1; /* already second pass */
a->p[a->p_cnt++] = marea->marea->p[pt[i].pnr];
if (_debug) d_printf ("add nr:%d pnr:%d", a->p_cnt-1, pt[i].pnr);
angle = pt[i].sel_angle;
}
i_old = i;
i++; if (i >= pt_c) i = 0;
}
if (a->p_cnt < 3) {
/* found nothing try next one */
sel++; if (sel >= pt_c) sel = 0;
}
} while (sel != st && a->p_cnt < 3);
/* add element */
if (a->p_cnt >= 3) {
map_area_add (a, MHLOAD_RELOAD);
a->subid++;
}
}
/* recreate pall list, delete unneeded elements (pnr == -1) */
for (c = 0, i = 0; i < pt_c; i++) if (pt[i].pnr != -1) pt[c++] = pt[i];
if (pt_c == c) {
d_printf ("%s:%d pt_c == c : nothing deleted.. something went wrong.", __FILE__, __LINE__);
d_printf (" rotated:%d", rotated);
break;
}
pt_c = c;
}
if (a->subid >= MAX_SUBID) {
d_printf ("%s:%d max subid reached. area id:%lld", __FILE__, __LINE__, a->id);
}
if (pt[0].pnr >= 0 && pt_c > 2) {
d_printf ("%s:%d osm_area_split_add: something went very wrong", __FILE__, __LINE__);
d_printf (" marea->id: %lld:%d", a->id, a->subid);
d_printf (" pt[0].pnr:%d pt[1].pnr:%d pall_cnt: %d", pt[0].pnr, pt[1].pnr, pt_c);
}
/* free unneeded memory and return to caller */
ml_free (a);
ml_free (pt);
return a->subid;
};
/******************************************************************** /********************************************************************
* save detail information of the node. This will also create the * save detail information of the node. This will also create the
* search index. * search table.
*/ */
void osm_nodedetail_save (struct osm_nodedetail *onoded, struct osm_node *node) { void osm_nodedetail_save (struct osm_nodedetail *onoded, struct osm_node *node) {
int i, j; int i, j;
@ -1607,7 +1386,7 @@ void osm_processdata (xmlTextReaderPtr reader) {
osm.oway->type -= MWAY_MAX; osm.oway->type -= MWAY_MAX;
osm_area_cnt++; osm_area_cnt++;
if (osm.oway->type != MAREA_ignore) osm_area_save (osm.oway, &osm.area); osm_area_save (osm.oway, &osm.area);
} }
else { else {
osm_ways_cnt++; osm_ways_cnt++;
@ -1667,7 +1446,7 @@ void osm_processdata (xmlTextReaderPtr reader) {
return; return;
} }
onoded.id = onode.id; onoded.id = onoded.id;
osm_nodedetail_append (&onoded, (char*)k, (char*)v); osm_nodedetail_append (&onoded, (char*)k, (char*)v);
free ((void *)k); free ((void *)k);
free ((void *)v); free ((void *)v);
@ -1726,7 +1505,7 @@ void osm_processdata (xmlTextReaderPtr reader) {
else if (strcmp ((char*) v, (char*) "steps") == 0) osm.oway->type = MWAY_footway; else if (strcmp ((char*) v, (char*) "steps") == 0) osm.oway->type = MWAY_footway;
else { else {
osm.oway->type = MWAY_unknown_way; osm.oway->type = MWAY_unknown_way;
printf ("unknown highway:'%s'\n", v); // printf ("unknown highway:'%s'\n", v);
} }
} }
@ -1924,7 +1703,7 @@ void osm_loadfile (char *fn) {
osm_init (); osm_init ();
if (fn == NULL) return; if (fn == NULL) return;
app_status (-1, _("converting file"), 0.0); app_status (_("converting file"), 0);
d_printf ("osm_loadfile (%s)", fn); d_printf ("osm_loadfile (%s)", fn);
/* check the extension of the osm file */ /* check the extension of the osm file */
@ -1986,7 +1765,7 @@ void osm_loadfile (char *fn) {
/* reset the locale setting back to the environment setting */ /* reset the locale setting back to the environment setting */
setlocale (LC_ALL, NULL); setlocale (LC_ALL, NULL);
osm_free (); osm_free ();
app_status (-1, _(""), 0.0); app_status (_(""), -1);
}; };
@ -2006,26 +1785,11 @@ void map_load_web (struct map_pos hs, struct map_pos he) {
char fcache[LEN_FILENAME]; char fcache[LEN_FILENAME];
} wl[MLWEBMAX]; } wl[MLWEBMAX];
d_printf ("map_load_web: (%f , %f) --> (%f , %f)", hs.lon, hs.lat, he.lon, he.lat);
/* check for cache directory */
if (stat(cfg.cachepath, &sb) == -1) {
char fn[LEN_FILENAME];
strncpy (fn, cfg.cachepath, LEN_FILENAME);
fn[strlen(fn)-1] = 0;
d_printf ("create cache dir:%s", fn);
#if !defined(__MINGW32CE__) && !defined(_WIN32_WCE) && !defined(__MINGW32__)
mkdir (fn, 0755);
#else
mkdir (fn);
#endif
}
app.status = APPSTATUS_loadfromweb; app.status = APPSTATUS_loadfromweb;
#if defined (_LINUX_) #if defined (_LINUX_)
osm_load_from_web_end = he; osm_load_from_web_end = he;
osm_load_from_web_start = hs; osm_load_from_web_start = hs;
app_status (-1, _("refresh from OpenStreetMap.org"), 0.0); app_status (_("refresh from OpenStreetMap.org"), 0);
for (ret = 0; ret < MLWEBMAX; ret++) wl[ret].p.used = 0; for (ret = 0; ret < MLWEBMAX; ret++) wl[ret].p.used = 0;
for (ret = 0; ret < 13; ret++) args[ret] = NULL; for (ret = 0; ret < 13; ret++) args[ret] = NULL;
@ -2034,14 +1798,12 @@ void map_load_web (struct map_pos hs, struct map_pos he) {
for (h.lat = hs.lat; h.lat < he.lat || cmpf(h.lat, he.lat); h.lat = h.lat + MAP_OSMWEB_DELTA) { for (h.lat = hs.lat; h.lat < he.lat || cmpf(h.lat, he.lat); h.lat = h.lat + MAP_OSMWEB_DELTA) {
do { do {
main_wnd_loop (-1,-1); main_wnd_loop (-1,-1);
/* check for any finished forked processes
* if so, call osm_loadfile */
for (i = 0; i < MLWEBMAX; i++) { for (i = 0; i < MLWEBMAX; i++) {
if (wl[i].p.used) { if (wl[i].p.used) {
ret = execwait (&wl[i].p); ret = execwait (&wl[i].p);
if (ret == 1) { if (ret == 1) {
osm_loadfile (wl[i].fcache); osm_loadfile (wl[i].fcache);
app_status (-1, _("refresh from OpenStreetMap.org"), 0.0); app_status (_("refresh from OpenStreetMap.org"), 0);
main_wnd_update (); main_wnd_update ();
} }
} }
@ -2049,7 +1811,7 @@ void map_load_web (struct map_pos hs, struct map_pos he) {
for (i = 0; i < MLWEBMAX && wl[i].p.used == 1; i++); for (i = 0; i < MLWEBMAX && wl[i].p.used == 1; i++);
} }
while (i >= MLWEBMAX); /* exit if we can fork another process */ while (i >= MLWEBMAX);
y1 = CALC_START (h.lon, MAP_OSMWEB_DELTA); y1 = CALC_START (h.lon, MAP_OSMWEB_DELTA);
x1 = CALC_START (h.lat, MAP_OSMWEB_DELTA); x1 = CALC_START (h.lat, MAP_OSMWEB_DELTA);

@ -116,11 +116,10 @@ void map_search_add (char *country, char *name, unsigned long long int id, float
/* copy country */ /* copy country */
cp = dataline; cp = dataline;
strncpy (cp, n, MAP_SEARCHLINE_LEN-(cp-dataline)-3); strncpy (cp, n, MAP_SEARCHLINE_LEN-(cp-dataline));
cp = cp + strlen (cp); cp[0] = 0; cp++; cp = cp + strlen (cp); cp[0] = 0; cp++;
strncpy (cp, c, MAP_SEARCHLINE_LEN-(cp-dataline));
strncpy (cp, c, MAP_SEARCHLINE_LEN-(cp-dataline)-2);
cp = cp + strlen (cp); cp[0] = 0; cp++; cp = cp + strlen (cp); cp[0] = 0; cp++;
snprintf (cp, MAP_SEARCHLINE_LEN-(cp-dataline), "%lld %f %f\n", id, lon, lat); snprintf (cp, MAP_SEARCHLINE_LEN-(cp-dataline), "%lld %f %f\n", id, lon, lat);
@ -201,7 +200,7 @@ void map_search_sort_alg1 (struct maps_sort *data) {
} }
if (j % 100 == 0) { if (j % 100 == 0) {
sprintf (text, _("Sorting search.mapidx %d/%d"), j, data->cnt); sprintf (text, _("Sorting search.mapidx %d/%d"), j, data->cnt);
app_status (-1, text, 0.0); app_status (text, 0);
main_wnd_update (); main_wnd_update ();
} }
} }
@ -351,7 +350,7 @@ void map_search_sort_alg2 (struct maps_sort *data) {
/* display update on the screen */ /* display update on the screen */
if (to++ < 0 || to > 250) { if (to++ < 0 || to > 250) {
sprintf (text, _("sorting search.mapidx %d"), maps_qs_pos); sprintf (text, _("sorting search.mapidx %d"), maps_qs_pos);
app_status (-1, text, 0.0); app_status (text, 0);
main_wnd_update (); main_wnd_update ();
to = 0; to = 0;
} }
@ -441,7 +440,7 @@ void map_search_sort () {
lid = msd.id; lid = msd.id;
if (i % 10000 == 0) { if (i % 10000 == 0) {
sprintf (text, _("save search.mapidx %d"), i); sprintf (text, _("save search.mapidx %d"), i);
app_status (-1, text, 0.0); app_status (text, 0);
main_wnd_update (); main_wnd_update ();
} }
} }
@ -472,8 +471,8 @@ void map_search_sort () {
* the size on file. * the size on file.
*/ */
static char maps_line[MAP_SEARCHLINE_LEN*4]; static char maps_line[MAP_SEARCHLINE_LEN*4];
#warning maps_readpos.. read current position without checking #warning maps_readpos.. read current position without checing and return
#warning and return start of next line. #warning start of next line.
/* /*
* read an random position, check if we are at the start of valid data. If not * read an random position, check if we are at the start of valid data. If not
@ -481,7 +480,7 @@ static char maps_line[MAP_SEARCHLINE_LEN*4];
* parameter: pos - entry position inside file * parameter: pos - entry position inside file
* data - destination of found data * data - destination of found data
* size - size of data block * size - size of data block
* return: final start of current data block * return: next position to read data.
*/ */
unsigned long int maps_readpos (unsigned long int pos, struct map_search_data *data, int *size) { unsigned long int maps_readpos (unsigned long int pos, struct map_search_data *data, int *size) {
size_t realpos; size_t realpos;
@ -497,37 +496,33 @@ unsigned long int maps_readpos (unsigned long int pos, struct map_search_data *d
if (readsize <= 0) return -1; if (readsize <= 0) return -1;
/* search where the current line starts (go to the left) */ /* search where the current line starts (go to the left) */
// d_printf ("start at: pos:%ld realpos:%d start:%d", pos, realpos, pos-realpos); for (start = pos-realpos; start > 0; start--)
for (start = pos-realpos; start > 0; start--) {
// d_printf (" found:start:%-4d %x '%c' delta:%d", start, maps_line[start], maps_line[start], realpos+start-pos);
if (maps_line[start] == '\n') { if (maps_line[start] == '\n') {
start++; start++;
break; break;
} }
}
if (start < 0) { /* underrun buffer? */ if (start < 0) { /* underrun buffer? */
d_printf ("maps_readpos: found no start. pos:%ld realpos:%lld", pos, realpos); d_printf ("maps_readpos: found no start. pos:%ld realpos:%lld", pos, realpos);
return -1; return -1;
} }
// d_printf (" maps_readpos pos:%ld start:%d delta:%d", pos, start, (realpos+start)-pos); d_printf ("start:%d", start);
/* search where the current line ends */ /* search where the current line ends */
for (end = start; end < readsize && maps_line[end] != '\n'; end++); for (end = start; end < readsize && maps_line[end] != '\n'; end++);
if (end >= readsize) { if (end >= readsize) {
d_printf ("maps_readpos: found no end."); // d_printf ("maps_readpos: found no end.");
return -1; return -1;
} }
*data = map_search_line2data (maps_line+start); *data = map_search_line2data (maps_line+start);
*size = end-start; *size = end-start;
// d_printf (" size:%d", *size);
return realpos+start; return realpos+start;
}; };
int map_search (char *name, struct map_search_data *data, int datasize) { int map_search (char *name, struct map_search_data *data, int datasize) {
uint64_t blocksize, blockstart, realstart; size_t blocksize, blockstart;
struct stat buf; struct stat buf;
int i, j, cmpres, k; int i, j, cmpres, k;
@ -540,65 +535,33 @@ int map_search (char *name, struct map_search_data *data, int datasize) {
blocksize = buf.st_size; blocksize = buf.st_size;
blockstart = 0; blockstart = 0;
/* search for name inside the data */
do { do {
realstart = maps_readpos (blocksize/2+blockstart, data, &j); i = maps_readpos (blocksize/2+blockstart, data, &j);
if (realstart < 0) { if (i < 0) {
d_printf ("map_search something went wrong. realstart < 0 name:%s", name); d_printf ("map_search something went wrong. i < 0 name:%s", name);
return 0; return 0;
} }
d_printf ("search blocksize:%lld blockstart:%lld realstart:%lld j:%d", (long long int)blocksize, (long long int)blockstart, (long long int)realstart, j, data->name); d_printf ("search blocksize:%lld blockstart:%lld i:%d j:%d", blocksize, blockstart, i, j);
if ((cmpres = strncasecmp (name, data->name, strlen (name)))> 0) {
if ((cmpres = strcasecmp (name, data->name)) > 0) {
/* name is lager than data */ /* name is lager than data */
blocksize = blocksize - (realstart+j-blockstart); blocksize = blocksize - ((i+j) - blockstart);
blockstart = realstart+j+1; blockstart = i+j;
} }
else if (cmpres < 0) { else if (cmpres < 0) {
/* name is smaller than data */ /* name is smaller than data */
blocksize = realstart - blockstart; blocksize = i - blockstart;
} }
d_printf ("compare: '%s' with '%s' returns:%d", name, data->name, cmpres);
} while (cmpres != 0 && blocksize > MAP_SEARCHLINE_LEN*2); } while (cmpres != 0 && blocksize > MAP_SEARCHLINE_LEN*2);
d_printf ("found blockstart:%lld datasize:%d, i:%d", blockstart, datasize, i);
/* find first data inside list, go backwards until no match found */ blockstart = i-MAP_SEARCHLINE_LEN;
d_printf ("found blockstart:%lld blocksize:%lld, realstart:%lld text:'%-12s'", (long long int)blockstart,
(long long int)blocksize, (long long int)realstart, data->name);
j = 0;
if (cmpres <= 0) {
blockstart = realstart;
d_printf ("<=0 blockstart:%lld realstart:%lld name:%s", (long long int)blockstart,
(long long int)realstart, name);
do {
realstart = maps_readpos (blockstart, data, &j);
d_printf ("blockstart:%lld realstart:%lld data->name:%s", (long long int) blockstart, (long long int) realstart, data->name);
blockstart = realstart-2;
cmpres = strncasecmp (name, data->name, strlen (name));
d_printf (" cmpres:%d", cmpres);
} while (blockstart >= 0 && cmpres <= 0 && realstart >= 0);
blockstart = realstart+j;
}
else if (cmpres > 0) {
blockstart = realstart;
d_printf (">0 blockstart:%lld realstart:%lld name:%s", (long long int) blockstart, (long long int) realstart, name);
do {
realstart = maps_readpos (blockstart, data, &j);
d_printf ("blockstart:%lld realstart:%lld data->name:%s", (long long int)blockstart, (long long int)realstart, data->name);
blockstart = realstart+j;
cmpres = strncasecmp (name, data->name, strlen (name));
d_printf (" cmpres:%d", cmpres);
} while (cmpres > 0 && realstart >= 0);
blockstart = realstart;
}
if (realstart < 0) return 0;
if (blockstart < 0) blockstart = 0; if (blockstart < 0) blockstart = 0;
for (i = 0, k = 0; i < datasize*2 && k < datasize; i++) { for (i = 0, k = 0; i < datasize*2 && k < datasize; i++) {
realstart = maps_readpos (blockstart, data+k, &j); blockstart = maps_readpos (blockstart, data+k, &j);
d_printf ("create list: k:%d i:%d blockstart:%lld j:%d '%s'", k, i, (long long int)blockstart, j, data[k].name); d_printf ("create list: k:%d i:%d blockstart:%lld j:%d", k, i, blockstart, j);
if (realstart < 0) break; if (blockstart < 0) break;
blockstart = realstart + j; blockstart += j;
if (strncasecmp (name, data[k].name, strlen (name)) == 0) k++; if (strncasecmp (name, data[k].name, strlen (name)) == 0) k++;
} }

@ -88,36 +88,6 @@ int map_way_add_to_hash (struct map_hash *mh, struct map_way *mw) {
}; };
/*
* append the way without checking for it's size or double entry, no update done
*/
int map_way_append_to_hash (struct map_hash *mh, struct map_way *mw) {
int size;
struct map_way *w = mh->ways;
/* check if the hash pos and the waypos are valid */
if (mw->p_cnt > 0) if (map_geo2igeo (mw->p[0].lon) != mh->pos.ilon ||
map_geo2igeo (mw->p[0].lat) != mh->pos.ilat) {
d_printf ("p[0]:%d,%d mhpos:%d,%d way does not bleong to hash.", __FUNCTION__, map_geo2igeo (mw->p[0].lon), map_geo2igeo (mw->p[0].lat), mh->pos.ilon, mh->pos.ilat);
errorexit (-1);
}
/* check if the first element is already the one we want to update */
mh->ways = (struct map_way*) map_hash_getfree_aligned (mh, POINTERALIGNMENT);
/* copy the way data to the free entry
* calc size and set free entry to it's new place */
size = map_way_getsize (mw);
map_way_copy (mh->ways, mw);
mh->ways->next = w;
mh->free = mh->free + size;
mh->wayscnt++;
SETFLAG(mh->status, MS_changed);
return 1;
};
/****************************************************************************** /******************************************************************************
* Add/Update way information * Add/Update way information
* - load/ get hash table * - load/ get hash table

@ -346,7 +346,7 @@ int map_webload (char *remotefn, char *localfn, char *statustext) {
else strncpy (_statustext, statustext, 255); else strncpy (_statustext, statustext, 255);
d_printf ("map_webload started"); d_printf ("map_webload started");
app_status(APPSTATUS_loadfromweb, NULL, 0.0); app.status = APPSTATUS_loadfromweb;
strncpy (host, HOST, NET_HOSTLEN); strncpy (host, HOST, NET_HOSTLEN);
strncpy (port, PORT, NET_PORTLEN); strncpy (port, PORT, NET_PORTLEN);
@ -399,7 +399,6 @@ int map_webload (char *remotefn, char *localfn, char *statustext) {
to = time(NULL); to = time(NULL);
if (filesize > 0) sprintf (text, _("%s%d/%dkb loaded"), _statustext, filelen/1024, filesize/1024); if (filesize > 0) sprintf (text, _("%s%d/%dkb loaded"), _statustext, filelen/1024, filesize/1024);
else sprintf (text, _("%s%dkb loaded"), _statustext, filelen/1024); else sprintf (text, _("%s%dkb loaded"), _statustext, filelen/1024);
app_status(-1, text, (float)((float)filelen/(float)filesize));
main_wnd_update (); main_wnd_update ();
} }
} }
@ -419,7 +418,9 @@ int map_webload (char *remotefn, char *localfn, char *statustext) {
if (file_exist (tmpfn)) unlink (tmpfn); if (file_exist (tmpfn)) unlink (tmpfn);
} }
app_status(APPSTATUS_nothing, NULL, 0.0); map_clear ();
app.status = APPSTATUS_nothing;
app_status(NULL, -1);
return 0; return 0;
}; };

@ -2,7 +2,6 @@
#include "osmroute.h" #include "osmroute.h"
#include "system.h" #include "system.h"
#include "memoryleak.h" #include "memoryleak.h"
#include "utf8.h"
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
@ -56,12 +55,9 @@ struct font* font_load(char *name) {
exit (1);; exit (1);;
} }
FT_Set_Pixel_Sizes(f->face, 0, 12); FT_Set_Pixel_Sizes(f->face, 0, 16);
d_printf ("font loaded (size:%d).", f->buffersize); d_printf ("font loaded (size:%d).", f->buffersize);
if (FT_Select_Charmap(f->face, FT_ENCODING_UNICODE))
d_printf ("FT_Select_Charmap: error");
return f; return f;
} }
@ -72,7 +68,6 @@ struct font* font_load(char *name) {
*/ */
void font_draw (struct font *f, char *text, float x, float y, float sx, float sy) { void font_draw (struct font *f, char *text, float x, float y, float sx, float sy) {
char *p; char *p;
uint32_t u8chr;
int i; int i;
GLfloat vp[8]; GLfloat vp[8];
GLfloat vt[8] = {0, 1, GLfloat vt[8] = {0, 1,
@ -98,16 +93,10 @@ void font_draw (struct font *f, char *text, float x, float y, float sx, float sy
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
/* Loop through all characters */ /* Loop through all characters */
for (p = text; *p;) { for (p = text; *p; p++) {
u8chr = u8_decode (p, &i);
if (i == 0) {
p++;
continue;
}
p = p + i;
/* Try to load and render the character */ /* Try to load and render the character */
if ((i = FT_Load_Char(f->face, u8chr, FT_LOAD_RENDER))) { if ((i = FT_Load_Char(f->face, *p, FT_LOAD_RENDER))) {
d_printf ("error:%d", i); d_printf ("error:%d", i);
continue; continue;
} }
@ -115,7 +104,7 @@ void font_draw (struct font *f, char *text, float x, float y, float sx, float sy
/* Upload the "bitmap", which contains an 8-bit grayscale image, as an alpha texture */ /* Upload the "bitmap", which contains an 8-bit grayscale image, as an alpha texture */
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, g->bitmap.width, g->bitmap.rows, 0, GL_ALPHA, GL_UNSIGNED_BYTE, g->bitmap.buffer); glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, g->bitmap.width, g->bitmap.rows, 0, GL_ALPHA, GL_UNSIGNED_BYTE, g->bitmap.buffer);
/* Calculate the vertex and texture coordinates */ /* Calculate the vertex and texture coordinates */
// d_printf ("char:%c bitmap.rows:%d bitmap_top:%d", *p, g->bitmap.rows, g->bitmap_top); // d_printf ("x: %f advance:%d %d", x, g->advance.x, g->advance.x >> 6);
vp[0] = x; vp[1] = y + g->bitmap.rows - g->bitmap_top; vp[0] = x; vp[1] = y + g->bitmap.rows - g->bitmap_top;
vp[2] = x + g->bitmap.width; vp[3] = y + g->bitmap.rows - g->bitmap_top; vp[2] = x + g->bitmap.width; vp[3] = y + g->bitmap.rows - g->bitmap_top;
@ -127,10 +116,11 @@ void font_draw (struct font *f, char *text, float x, float y, float sx, float sy
glDrawArrays(GL_TRIANGLE_FAN,0,4); glDrawArrays(GL_TRIANGLE_FAN,0,4);
// glEnableClientState(GL_VERTEX_ARRAY); // glEnableClientState(GL_VERTEX_ARRAY);
// glVertexPointer(2, GL_FLOAT, 0, vp); glVertexPointer(2, GL_FLOAT, 0, vp);
// glDrawArrays(GL_LINES,0,2); glDrawArrays(GL_LINES,0,2);
// glDisableClientState(GL_VERTEX_ARRAY); // glDisableClientState(GL_VERTEX_ARRAY);
/* Advance the cursor to the start of the next character */ /* Advance the cursor to the start of the next character */
// x += (g->advance.x >> 6); // x += (g->advance.x >> 6);
// y -= (g->advance.y >> 6); // y -= (g->advance.y >> 6);

@ -39,7 +39,7 @@
iPoint gfx_screensize = {0, 0}; iPoint gfx_screensize = {0, 0};
int gfx_last_alloc_img = 0; int gfx_last_alloc_img = 0;
int gfx_last_img_fbo = 0; int gfx_last_img_fbo = 0;
struct font *font = NULL;
void gfx_fbo_switch (struct image *img); void gfx_fbo_switch (struct image *img);
/*****************************************************************************/ /*****************************************************************************/
@ -64,9 +64,6 @@ void gfx_init (int width, int height) {
gfx_screensize.x = width; gfx_screensize.x = width;
gfx_screensize.y = height; gfx_screensize.y = height;
gfx_resize (width, height); gfx_resize (width, height);
font_init ();
font = font_load ("FreeSans.ttf");
}; };
@ -141,13 +138,8 @@ void gfx_draw_line (struct image *dimg, int x1, int y1, int x2, int y2, struct l
/* polygon mit runden ecken....? bei width > 1 */ /* polygon mit runden ecken....? bei width > 1 */
gfx_fbo_switch (dimg); gfx_fbo_switch (dimg);
if (style.width < 1.0) style.width = 1.0; if (style.width < 1.0) style.width = 1.0;
glColor4f(style.c.c.r, style.c.c.g, style.c.c.b, 1.0);
glPointSize(style.width*0.5);
glBegin (GL_POINTS);
glVertex2i (x1, y1);
glVertex2i (x2, y2);
glEnd ();
glLineWidth (style.width); glLineWidth (style.width);
glColor3f (style.c.c.r, style.c.c.g, style.c.c.b);
glBegin (GL_LINES); glBegin (GL_LINES);
glVertex2i (x1, y1); glVertex2i (x1, y1);
glVertex2i (x2, y2); glVertex2i (x2, y2);
@ -158,16 +150,23 @@ void gfx_draw_line (struct image *dimg, int x1, int y1, int x2, int y2, struct l
/* /*
* draw polygon * 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; int i;
gfx_fbo_switch (dimg); gfx_fbo_switch (dimg);
glBegin (GL_POLYGON); 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++) for (i = 0; i < pcnt; i++)
glVertex2i (p[i].x, p[i].y); glVertex2i (p[i].x, p[i].y);
glEnd (); glEnd ();
// glBegin (GL_LINES);
// d_printf ("line width: %f",style.width);
// glLineWidth (style.width/2.0);
// glColor4f (style.c.c.r, style.c.c.g, style.c.c.b, 1.0f);
// for (i = 0; i < pcnt; i++)
// glVertex2i (p[i].x, p[i].y);
// glEnd ();
}; };
@ -176,8 +175,6 @@ void gfx_draw_polygon (struct image *dimg, iPoint *p, int pcnt, struct line_styl
*/ */
void gfx_draw_text (struct image *dimg, int x, int y, char *text, struct color *c) { void gfx_draw_text (struct image *dimg, int x, int y, char *text, struct color *c) {
gfx_fbo_switch (dimg); gfx_fbo_switch (dimg);
glColor4f (c->c.r, c->c.g, c->c.b, 1.0f);
font_draw (font, text, x, y+12.0, 1.0, 1.0);
}; };
@ -194,10 +191,10 @@ void gfx_draw_img (struct image *dimg, int dx, int dy, int dw, int dh, struct im
glBegin (GL_QUADS); glBegin (GL_QUADS);
glColor4f (1.0f, 1.0f, 1.0f, 1.0f); glColor4f (1.0f, 1.0f, 1.0f, 1.0f);
fx = (float) sx/(float) (simg->width); fx = (float) sx/(float) simg->width;
fy = (float) sy/(float) (simg->height); fy = (float) sy/(float) simg->height;
fw = (float) dw/(float) (simg->width); fw = (float) dw/(float) simg->width;
fh = (float) dh/(float) (simg->height); fh = (float) dh/(float) simg->height;
glTexCoord2d (fx, fy); glTexCoord2d (fx, fy);
glVertex2i (dx, dy); glVertex2i (dx, dy);
@ -295,6 +292,11 @@ void gfx_img_free (struct image *img) {
}; };
void gfx_draw_rect (struct image *dimg, int x1, int y1, int x2, int y2, struct color *c) {
};
#define HEADER_SIZE 8 #define HEADER_SIZE 8
int gfxpng_fd = 0; int gfxpng_fd = 0;
void png_fd_read(png_structp png, png_bytep data, png_size_t size) { void png_fd_read(png_structp png, png_bytep data, png_size_t size) {

@ -1,4 +1,4 @@
/* $Id: sdl_main.c,v 1.16 2014/03/06 22:21:46 steffen Exp $ */
#include <SDL.h> #include <SDL.h>
#include "osmroute.h" #include "osmroute.h"
#include "system.h" #include "system.h"
@ -61,7 +61,7 @@ void test_draw () {
} }
if (_tmpx > img->width-TEST_WIDTH) _tmpdx = -1; if (_tmpx > img->width-TEST_WIDTH) _tmpdx = -1;
if (_tmpx < 0) _tmpdx = 1; if (_tmpx < 0) _tmpdx = 1;
if (_delay % 1 == 0) _tmpx += _tmpdx; if (_delay % 20 == 0) _tmpx += _tmpdx;
if (_tmpy > img->height-TEST_WIDTH) _tmpdy = -1; if (_tmpy > img->height-TEST_WIDTH) _tmpdy = -1;
if (_tmpy < 0) _tmpdy = 1; if (_tmpy < 0) _tmpdy = 1;
@ -96,7 +96,13 @@ void test_draw () {
Uint32 msdl_timercallback (Uint32 interval, void *param) { Uint32 msdl_timercallback (Uint32 interval, void *param) {
app_loop (); struct gps_data *gpspos;
if (gps_isrunning () > 0) {
if ((gpspos = gps_loop ())) {
drawgps_set_pos (gpspos);
}
}
d_printf ("timer %d", interval); d_printf ("timer %d", interval);
@ -105,19 +111,11 @@ Uint32 msdl_timercallback (Uint32 interval, void *param) {
int msdl_eventloop () { int msdl_eventloop () {
SDL_Event event, lastevent; SDL_Event event;
int gotevent = 0, keeppoll = 1; int eventstate;
GUIEvent gevent; GUIEvent gevent;
static int oldkey = 0;
if ((eventstate = SDL_PollEvent (&event)) != 0) {
/* only the last MOUSEMOTION event will handled */
while (keeppoll && SDL_PollEvent (&lastevent)) {
event = lastevent;
gotevent = 1;
keeppoll = 0;
if (event.type == SDL_MOUSEMOTION) keeppoll = 1;
}
if (gotevent) {
switch (event.type) { switch (event.type) {
case (SDL_QUIT): case (SDL_QUIT):
app.status = APPSTATUS_quit; app.status = APPSTATUS_quit;
@ -132,53 +130,26 @@ int msdl_eventloop () {
exit (2); exit (2);
} }
gfx_resize (event.resize.w, event.resize.h); gfx_resize (event.resize.w, event.resize.h);
draw (); // draw ();
test_draw ();
} }
break; break;
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
gevent.scr_mpos.x = event.motion.x; gevent.mousepos.x = event.motion.x;
gevent.scr_mpos.y = event.motion.y; gevent.mousepos.y = event.motion.y;
gevent.mousebtn = event.motion.state; gevent.mousebtn = 0;
gevent.event = EGUI_MOUSEMOVE; gevent.event = EGUI_MOUSEMOVE;
gui_event (gevent); // gui_event (gevent);
// draw_mousemove (event.motion.x, event.motion.y, -1);
test_draw();
break; break;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
gevent.scr_mpos.x = event.motion.x; case SDL_MOUSEBUTTONUP:
gevent.scr_mpos.y = event.motion.y;
gevent.mousebtn = 1;
gevent.event = EGUI_MOUSEPRESSED;
gui_event (gevent);
break; break;
case SDL_MOUSEBUTTONUP: case SDL_KEYDOWN:
gevent.scr_mpos.x = event.motion.x;
gevent.scr_mpos.y = event.motion.y;
gevent.mousebtn = 1;
gevent.event = EGUI_MOUSERELEASED;
gui_event (gevent);
break;
case SDL_KEYDOWN: {
int keyu = 0;
d_printf ("keydown. old_key:%d keysym:%d ukey:%d", oldkey, event.key.keysym.sym, event.key.keysym.unicode);
if (oldkey != event.key.keysym.sym) {
keyu = oldkey = event.key.keysym.unicode;
gevent.keychar = keyu;
if (event.key.keysym.sym == SDLK_UP) gevent.key = GUIKEY_UP;
else if (event.key.keysym.sym == SDLK_DOWN) gevent.key = GUIKEY_DOWN;
else if (event.key.keysym.sym == SDLK_LEFT) gevent.key = GUIKEY_LEFT;
else if (event.key.keysym.sym == SDLK_RIGHT) gevent.key = GUIKEY_RIGHT;
else gevent.key = event.key.keysym.sym;
gevent.event = EGUI_KEYCHAR;
gevent.scr_mpos.x = -1;
gevent.scr_mpos.y = -1;
if (gui_event (gevent) != 0) draw();
}
} break;
case SDL_KEYUP: case SDL_KEYUP:
d_printf ("keyup. old_key:%d keysym:%d ukey:%d", oldkey, event.key.keysym.sym, event.key.keysym.unicode);
oldkey = 0;
break; break;
default: default:
@ -190,75 +161,12 @@ int msdl_eventloop () {
}; };
/*
* some input handling code.. in sdl it seemed to work fine... used alot
* within the bomberclone code.
*
int key = 0, keyu = 0;
ki->changed = 0;
if (event->type == SDL_KEYDOWN && keybinput_oldkey != event->key.keysym.sym) {
key = keybinput_oldkey = event->key.keysym.sym;
keyu = event->key.keysym.unicode;
if (key == 8) { // BACKSPACE
if (ki->curpos > 0) {
ki->curpos--;
ki->text[ki->curpos] = 0;
ki->changed = 1;
}
}
else if (ki->type == KEYBI_text && ((keyu >= 32 && keyu <= 126) || (keyu >= 128 && keyu <= 255))) {
if (ki->curpos < ki->maxlen) {
ki->text[ki->curpos++] = event->key.keysym.unicode;
ki->text[ki->curpos] = 0;
ki->changed = 1;
}
}
else if (ki->type == KEYBI_int && (keyu == '-' || (keyu >= '0' && keyu <= '9'))) {
if (ki->curpos < 255) {
ki->text[ki->curpos] = event->key.keysym.unicode;
if (atoi(ki->text) <= ki->maxlen)
ki->curpos++;
ki->text[ki->curpos] = 0;
ki->changed = 1;
}
}
else if (ki->type == KEYBI_float && (keyu == '-' || keyu == '.' || (keyu >= '0' && keyu <= '9'))) {
if (ki->curpos < 255) {
ki->text[ki->curpos++] = event->key.keysym.unicode;
ki->text[ki->curpos] = 0;
ki->changed = 1;
}
}
ki->len = strlen (ki->text);
}
if (keybinput_oldkey == SDLK_RETURN && event->type == SDL_KEYUP)
keyu = 1;
else if (keybinput_oldkey == SDLK_ESCAPE && event->type == SDL_KEYUP)
keyu = -1;
else
keyu = 0;
if (event->type == SDL_KEYUP)
keybinput_oldkey = 0;
return keyu;
*/
int main (int argc, char **argv) { int main (int argc, char **argv) {
SDL_Surface *scr; SDL_Surface *scr;
static time_t to;
time_t t1;
/* Initialize SDL for video output */ /* Initialize SDL for video output */
if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) { if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) {
fprintf (stderr, "Unable to initialize SDL: %s\n", fprintf (stderr, "Unable to initialize SDL: %s\n",
SDL_GetError ()); SDL_GetError ());
exit (1); exit (1);
} }
@ -269,22 +177,16 @@ int main (int argc, char **argv) {
SDL_Quit(); SDL_Quit();
exit (2); exit (2);
} }
SDL_EnableUNICODE(1);
app_init (argc, argv); app_init (argc, argv);
gfx_init (RESOLUTION_X, RESOLUTION_Y); gfx_init (RESOLUTION_X, RESOLUTION_Y);
draw (); test_draw ();
// draw ();
while (app.status != APPSTATUS_quit) { while (app.status != APPSTATUS_quit) {
while (msdl_eventloop ()); msdl_eventloop ();
test_draw ();
t1 = time (NULL); // draw ();
if (to != t1) {
app_loop ();
to = t1;
}
draw ();
} }
SDL_Quit (); SDL_Quit ();
@ -294,9 +196,10 @@ int main (int argc, char **argv) {
} }
void main_wnd_loop (long long int cur, long long int max) {
}
void main_wnd_update () { void main_wnd_update () {
// d_printf ("main_wnd_update : %d", app.status);
app_loop();
while (msdl_eventloop ());
} }

@ -34,8 +34,6 @@
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
#include <SDL.h>
/***************************************************************************** /*****************************************************************************
* gfx stuff... * gfx stuff...

@ -157,7 +157,7 @@ void gfx_draw_line (struct image *dimg, int x1, int y1, int x2, int y2, struct l
/* /*
* draw polygon * 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) {
static POINT *polygon = NULL; static POINT *polygon = NULL;
static int polygon_cnt = 0; static int polygon_cnt = 0;
int i; int i;
@ -179,8 +179,8 @@ void gfx_draw_polygon (struct image *dimg, iPoint *p, int pcnt, struct line_styl
polygon[i].y = p[i].y; polygon[i].y = p[i].y;
} }
tmp_brush = SelectObject (dimg->hdc, c->brush); tmp_brush = SelectObject (dimg->hdc, c.brush);
tmp_pen = SelectObject (dimg->hdc, c->pen); tmp_pen = SelectObject (dimg->hdc, c.pen);
Polygon (dimg->hdc, polygon, pcnt); Polygon (dimg->hdc, polygon, pcnt);
SelectObject (dimg->hdc, tmp_brush); SelectObject (dimg->hdc, tmp_brush);
SelectObject (dimg->hdc, tmp_pen); SelectObject (dimg->hdc, tmp_pen);

@ -389,8 +389,8 @@ LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
case WM_LBUTTONUP: case WM_LBUTTONUP:
x = (lParam & 0xFFFF); x = (lParam & 0xFFFF);
y = (lParam >> 16); y = (lParam >> 16);
gevent.scr_mpos.x = x; gevent.mousepos.x = x;
gevent.scr_mpos.y = y; gevent.mousepos.y = y;
gevent.mousebtn = 1; gevent.mousebtn = 1;
gevent.event = EGUI_MOUSERELEASED; gevent.event = EGUI_MOUSERELEASED;
if (gui_event (gevent) == 0) draw_mousebtnup (x, y, 1); if (gui_event (gevent) == 0) draw_mousebtnup (x, y, 1);
@ -398,8 +398,8 @@ LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
x = (lParam & 0xFFFF); x = (lParam & 0xFFFF);
y = (lParam >> 16); y = (lParam >> 16);
gevent.scr_mpos.x = x; gevent.mousepos.x = x;
gevent.scr_mpos.y = y; gevent.mousepos.y = y;
gevent.mousebtn = 1; gevent.mousebtn = 1;
gevent.event = EGUI_MOUSEPRESSED; gevent.event = EGUI_MOUSEPRESSED;
if (gui_event (gevent) == 0) draw_mousebtndown (x, y, 1); if (gui_event (gevent) == 0) draw_mousebtndown (x, y, 1);
@ -407,18 +407,18 @@ LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
x = (lParam & 0xFFFF); x = (lParam & 0xFFFF);
y = (lParam >> 16); y = (lParam >> 16);
gevent.scr_mpos.x = x; gevent.mousepos.x = x;
gevent.scr_mpos.y = y; gevent.mousepos.y = y;
gevent.mousebtn = 0; gevent.mousebtn = 0;
gevent.event = EGUI_MOUSEMOVE; gevent.event = EGUI_MOUSEMOVE;
gui_event (gevent); gui_event (gevent);
draw_mousemove (x, y, -1); draw_mousemove (x, y, -1);
break; break;
case WM_CHAR: case WM_CHAR:
if (wParam < ' ') gevent.keychar = 0xff00 | wParam; if (wParam < ' ') gevent.keyval = 0xff00 | wParam;
else gevent.keychar = wParam; else gevent.keyval = wParam;
gevent.event = EGUI_KEYCHAR; gevent.event = EGUI_KEYRELEASED;
d_printf ("char wParam:%x keyval:%x", wParam, gevent.keychar); d_printf ("char wParam:%x keyval:%x", wParam, gevent.keyval);
if (gui_event (gevent) != 0) draw(); if (gui_event (gevent) != 0) draw();
break; break;
// case WM_KEYUP: // case WM_KEYUP:
@ -455,12 +455,12 @@ void DoMenuActions(HWND hWnd, INT id) {
{ {
char *fn; char *fn;
// wince_taskbar (hWnd, TRUE); // wince_taskbar (hWnd, TRUE);
fn = select_dir_dialog ("MapData", cfg.mappath); fn = select_dir_dialog ("MapData", cfg.datapath);
// wince_taskbar (hWnd, FALSE); // wince_taskbar (hWnd, FALSE);
if (fn) { if (fn) {
d_printf ("config: changed data path from '%s' to '%s'.", cfg.mappath, fn); d_printf ("config: changed data path from '%s' to '%s'.", cfg.datapath, fn);
map_clear(); map_clear();
strncpy (cfg.mappath, fn, LEN_FILENAME); strncpy (cfg.datapath, fn, LEN_FILENAME);
map_clear(); map_clear();
draw_redrawmap (); draw_redrawmap ();
} }
@ -488,7 +488,7 @@ void DoMenuActions(HWND hWnd, INT id) {
map_webload (rfn, lfn, NULL); map_webload (rfn, lfn, NULL);
map_search_sort (); map_search_sort ();
#endif #endif
app_status (-1, "", 0.0); app_status ("", -1);
} }
break; break;
case IDM_MENU_MAP_WEBLOAD: case IDM_MENU_MAP_WEBLOAD:
@ -568,3 +568,4 @@ void main_wnd_update () {
DispatchMessage(&message); DispatchMessage(&message);
} }
}; };

Loading…
Cancel
Save