Compare commits
96 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
374c865c36 | 4 years ago |
|
|
64b2f34043 | 4 years ago |
|
|
b707c3fbd2 | 4 years ago |
|
|
632afcf333 | 4 years ago |
|
|
536a34160e | 11 years ago |
|
|
136a51f1f0 | 12 years ago |
|
|
09b8c79772 | 12 years ago |
|
|
867acfafcd | 12 years ago |
|
|
e018fef72b | 12 years ago |
|
|
e93500869a | 12 years ago |
|
|
3c01d729cd | 12 years ago |
|
|
465eb3647f | 12 years ago |
|
|
bb720fa2d8 | 12 years ago |
|
|
c7d32001a0 | 12 years ago |
|
|
3c54de751f | 12 years ago |
|
|
52088304b9 | 12 years ago |
|
|
87f0fac506 | 12 years ago |
|
|
fb279bdbb2 | 12 years ago |
|
|
dc3b085f0f | 12 years ago |
|
|
f844e7e712 | 12 years ago |
|
|
cc7d2dd753 | 12 years ago |
|
|
eb328d6c47 | 12 years ago |
|
|
30cbec28c6 | 12 years ago |
|
|
a96d5ccc04 | 13 years ago |
|
|
a6225615e6 | 13 years ago |
|
|
f6afe7f426 | 13 years ago |
|
|
5e5ef1b898 | 13 years ago |
|
|
d1afa786f9 | 13 years ago |
|
|
b2db01d39c | 13 years ago |
|
|
9ecdcbcd13 | 13 years ago |
|
|
b63076aa3f | 13 years ago |
|
|
01b9406ca3 | 13 years ago |
|
|
60d26e354a | 13 years ago |
|
|
4d21bcae1d | 13 years ago |
|
|
698cf67bd4 | 13 years ago |
|
|
a8bfba1032 | 13 years ago |
|
|
8cc646d18e | 13 years ago |
|
|
56379bb493 | 13 years ago |
|
|
bfbfe09312 | 13 years ago |
|
|
98347c53eb | 13 years ago |
|
|
33eb721c22 | 13 years ago |
|
|
98ad19dc03 | 13 years ago |
|
|
3bc2432a44 | 13 years ago |
|
|
5c0bfbe028 | 13 years ago |
|
|
08d75cf3b5 | 13 years ago |
|
|
48a81d7683 | 13 years ago |
|
|
5d5fefe138 | 13 years ago |
|
|
6eb422d368 | 13 years ago |
|
|
168d3b386d | 13 years ago |
|
|
6d74261ba5 | 13 years ago |
|
|
5832946569 | 13 years ago |
|
|
095f214710 | 13 years ago |
|
|
28f2b6b2ca | 13 years ago |
|
|
804e195cd4 | 13 years ago |
|
|
5bab311f8a | 13 years ago |
|
|
7ef7965350 | 13 years ago |
|
|
f6a5fb5a83 | 13 years ago |
|
|
ce4b8e828a | 13 years ago |
|
|
5ff050d5b1 | 13 years ago |
|
|
1cab6b20ac | 13 years ago |
|
|
a1fb6bc179 | 13 years ago |
|
|
ede8fc0768 | 13 years ago |
|
|
6527314883 | 13 years ago |
|
|
b1e2fca3f9 | 13 years ago |
|
|
5057228a2e | 13 years ago |
|
|
1a0e4a2af0 | 13 years ago |
|
|
a28bbd52a1 | 13 years ago |
|
|
1529314588 | 13 years ago |
|
|
b0143e2a8c | 13 years ago |
|
|
e752a97d6d | 13 years ago |
|
|
c8eb9d6e0c | 13 years ago |
|
|
afd9c27f83 | 13 years ago |
|
|
a5f20a0a64 | 13 years ago |
|
|
01f66ec740 | 13 years ago |
|
|
9aceb2934a | 13 years ago |
|
|
cff2c9a7cf | 13 years ago |
|
|
68803c1921 | 13 years ago |
|
|
1f2310937e | 13 years ago |
|
|
49eff650b6 | 13 years ago |
|
|
66d2be5f8a | 13 years ago |
|
|
0da7441a73 | 13 years ago |
|
|
87e6a631eb | 13 years ago |
|
|
beb62b5b03 | 13 years ago |
|
|
ec415d7a9f | 13 years ago |
|
|
e4f9249428 | 13 years ago |
|
|
36592a0d14 | 13 years ago |
|
|
4817c88996 | 13 years ago |
|
|
322630948e | 13 years ago |
|
|
aecda8e878 | 13 years ago |
|
|
d09e264688 | 13 years ago |
|
|
26cbac58f3 | 13 years ago |
|
|
475db83d4c | 13 years ago |
|
|
86ef5ffb33 | 13 years ago |
|
|
fecfe775c2 | 13 years ago |
|
|
bcac14b12f | 13 years ago |
|
|
4084e0475d | 13 years ago |
@ -0,0 +1,85 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,238 @@
|
||||
/* $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;
|
||||
}
|
||||
};
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
/* $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
|
||||
|
||||
Binary file not shown.
@ -0,0 +1,97 @@
|
||||
/* $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;
|
||||
};
|
||||
|
||||
@ -0,0 +1,95 @@
|
||||
/* $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;
|
||||
};
|
||||
|
||||
@ -0,0 +1,165 @@
|
||||
/* $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;
|
||||
};
|
||||
@ -0,0 +1,30 @@
|
||||
/* $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"
|
||||
@ -0,0 +1,62 @@
|
||||
/* $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;
|
||||
};
|
||||
|
||||
@ -0,0 +1,134 @@
|
||||
/* $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;
|
||||
};
|
||||
@ -0,0 +1,280 @@
|
||||
/* $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;
|
||||
};
|
||||
@ -0,0 +1,159 @@
|
||||
/* $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;
|
||||
};
|
||||
@ -0,0 +1,177 @@
|
||||
/* %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);
|
||||
}
|
||||
};
|
||||
|
||||
@ -0,0 +1,200 @@
|
||||
/* %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;
|
||||
}
|
||||
};
|
||||
|
||||
@ -0,0 +1,192 @@
|
||||
/* $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;
|
||||
}
|
||||
};
|
||||
|
||||
@ -0,0 +1,103 @@
|
||||
/* $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 ();
|
||||
};
|
||||
@ -0,0 +1,112 @@
|
||||
/* $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 ();
|
||||
};
|
||||
|
||||
Loading…
Reference in new issue