You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
spOSMroute/gui/gui_softkeyboard.c

79 lines
2.5 KiB

/* $Id: gui_softkeyboard.c,v 1.1 2013/03/06 23:28:15 steffen Exp $ */
/***************************************************************************
* gui_softkeyboard.c
*
* Copyright (C) 2013 Steffen Pohle
* steffen@gulpe.de
***************************************************************************
* softkeyboard: self written softkeyboard.
***************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* main.c is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "osmroute.h"
#include "draw.h"
#include "gui.h"
#include "system.h"
GUISoftkeyboard *softkeyb = NULL;
void gui_softkeyb_show (int enable) {
/* keys which are displayed.. */
char line[GUI_SOFTKEYB_MODE_MAX][GUI_SOFTKEYB_X][GUI_SOFTKEYB_X] = {
{ "qwertzuiop?",
"asdfghjkl??",
"yxcvbnm,.-_" },
{ "QWERTZUIOP?",
"ASDFGHIKL??",
"YXCVBNM;:#+" },
{ "0123456789=",
" ",
" " }};
int i, j;
/* disable software keyboard */
if (cfg.softkeyboard == 0 || enable == 0) {
if (softkeyb) softkeyb->enabled = FALSE;
return;
}
/* check for allocation.. */
if (softkeyb == NULL) {
softkeyb = (GUISoftkeyboard*) ml_malloc (sizeof (GUISoftkeyboard));
memset (softkeyb, 0x0, sizeof (GUISoftkeyboard));
}
/* reset data */
for (i = 0; i < GUI_SOFTKEYB_MODE_MAX; i++) for (j = 0; j < 3; j++)
strncpy (softkeyb->keys[i][j], line[i][j], GUI_SOFTKEYB_X);
softkeyb->enabled = TRUE;
softkeyb->mode = GUI_SOFTKEYB_MODE_NORM;
};
/* only preparing the screen image... copying to the screen will be done later... */
void gui_softkeyb_draw () {
if (softkeyb == NULL || gfx_screensize.x < 0 || softkeyb->enabled == FALSE) return;
if (softkeyb->screen == NULL || softkeyb->screen->width != gfx_screensize.x) {
if (softkeyb->screen) gfx_img_free (softkeyb->screen);
softkeyb->screen = gfx_img_alloc (gfx_screensize.x, gfx_screensize.y * 0.8);
}
gfx_clear (softkeyb->screen, &color[COLOR_white][1]);
};