navit  0.5.3-trunk
gui_internal_keyboard.c File Reference
#include <glib.h>
#include <stdlib.h>
#include "color.h"
#include "coord.h"
#include "point.h"
#include "callback.h"
#include "graphics.h"
#include "debug.h"
#include "gui_internal.h"
#include "gui_internal_widget.h"
#include "gui_internal_priv.h"
#include "gui_internal_menu.h"
#include "gui_internal_keyboard.h"

Data Structures

struct  gui_internal_keyb_mode
 Describes a keyboard mode. More...
 

Functions

void gui_internal_keyboard_to_upper_case (struct gui_priv *this)
 Switch keyboard mode to uppercase if it's in lowercase mode and. More...
 
void gui_internal_keyboard_to_lower_case (struct gui_priv *this)
 Switch keyboard mode to lowercase if it's in uppercase mode and. More...
 
static void gui_internal_cmd_keypress (struct gui_priv *this, struct widget *wm, void *data)
 Processes a key press on the internal GUI keyboard. More...
 
static struct widgetgui_internal_keyboard_key_data (struct gui_priv *this, struct widget *wkbd, char *text, int font, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data, void(*data_free)(void *data), int w, int h)
 
static struct widgetgui_internal_keyboard_key (struct gui_priv *this, struct widget *wkbd, char *text, char *key, int w, int h)
 
static void gui_internal_keyboard_change (struct gui_priv *this, struct widget *key, void *data)
 
static void gui_internal_keyboard_topbox_resize (struct gui_priv *this, struct widget *w, void *data, int neww, int newh)
 
struct widgetgui_internal_keyboard_do (struct gui_priv *this, struct widget *wkbdb, int mode)
 Creates a new keyboard widget or switches the layout of an existing widget. More...
 
struct widgetgui_internal_keyboard (struct gui_priv *this, int mode)
 Creates a keyboard widget. More...
 
int gui_internal_keyboard_init_mode (char *lang)
 Returns the default keyboard mode for a country. More...
 
static void gui_internal_keyboard_hide_native (struct gui_priv *this_, struct widget *w)
 Hides the platform's native on-screen keyboard or other input method. More...
 
struct widgetgui_internal_keyboard_show_native (struct gui_priv *this, struct widget *w, int mode, char *lang)
 Shows the platform's native on-screen keyboard or other input method. More...
 

Variables

struct gui_internal_keyb_mode gui_internal_keyb_modes []
 A list of all available keyboard modes. More...
 

Function Documentation

◆ gui_internal_cmd_keypress()

static void gui_internal_cmd_keypress ( struct gui_priv this,
struct widget wm,
void *  data 
)
static

Processes a key press on the internal GUI keyboard.

If the keyboard is currently in uppercase mode and

VKBD_MODE_2

is set, it is tswitched to the corresponding lowercase mode in

void gui_internal_keypress_do(struct gui_priv *this, char *key)
Definition: gui_internal.c:1565

.

Parameters
thisThe internal GUI instance
wm
dataNot used

References widget::data, and gui_internal_keypress_do().

Referenced by gui_internal_keyboard_key().

◆ gui_internal_keyboard()

struct widget* gui_internal_keyboard ( struct gui_priv this,
int  mode 
)

Creates a keyboard widget.

This function creates a widget to display the internal GUI keyboard.

The

mode

argument specifies the type of keyboard which should initially be displayed. Refer to vkbd_mode for a list of possible modes and their meaning.

Parameters
thisThe internal GUI instance
modeThe mode for the keyboard
Returns
A new keyboard widget

References gui_internal_keyboard_do().

Referenced by gui_internal_cmd_add_bookmark2(), gui_internal_cmd_add_bookmark_folder2(), gui_internal_cmd_enter_coord(), gui_internal_cmd_log(), gui_internal_cmd_pois_filter(), gui_internal_cmd_rename_bookmark(), gui_internal_html_menu(), and gui_internal_search().

◆ gui_internal_keyboard_change()

static void gui_internal_keyboard_change ( struct gui_priv this,
struct widget key,
void *  data 
)
static

◆ gui_internal_keyboard_do()

struct widget* gui_internal_keyboard_do ( struct gui_priv this,
struct widget wkbdb,
int  mode 
)

Creates a new keyboard widget or switches the layout of an existing widget.

This is an internal helper function that is not normally called directly. To create a new keyboard widget, GUI widgets should call gui_internal_keyboard(struct gui_priv *, struct widget *, int).

Parameters
thisThe internal GUI instance
wkbdbThe existing keyboard widget whose layout is to be switched, or
NULL
to create a new keyboard widget
modeThe new keyboard mode, see gui_internal_keyboard(struct gui_priv *, struct widget *, int) for a description of possible values
Returns
wkbdb
if a non-NULL value was passed, else a new keyboard widget will be returned.

References widget::background, widget::bb, widget::bl, widget::br, widget::bt, scroll_buttons::button_box_hide, widget::cols, widget::data, widget::datai, flags_fill, gui_internal_keyb_mode::font, widget::func, gravity_center, gui_internal_box_new(), gui_internal_highlight(), gui_internal_keyb_modes, gui_internal_keyboard_change(), gui_internal_keyboard_key(), gui_internal_keyboard_key_data(), gui_internal_keyboard_topbox_resize(), gui_internal_label_font_new(), gui_internal_label_new(), gui_internal_menu_data(), gui_internal_menu_render(), gui_internal_menu_reset_pack(), gui_internal_widget_append(), gui_internal_widget_children_destroy(), gui_internal_widget_pack(), gui_internal_widget_render(), gui_internal_widget_reset_pack(), widget::h, menu_data::keyboard, menu_data::keyboard_mode, widget::on_resize, orientation_horizontal, orientation_horizontal_vertical, widget::p, table_data::scroll_buttons, menu_data::search_list, widget::spx, widget::spy, widget::state, STATE_SENSITIVE, widget::text, gui_internal_keyb_mode::title, widget::type, VKBD_CYRILLIC_LOWER, VKBD_CYRILLIC_UPPER, VKBD_DEGREE, VKBD_FLAG_1024, VKBD_GREEK_LOWER, VKBD_GREEK_UPPER, VKBD_LATIN_LOWER, VKBD_LATIN_UPPER, VKBD_LAYOUT_MASK, VKBD_MASK_7, VKBD_NUMERIC, VKBD_UMLAUT_LOWER, VKBD_UMLAUT_UPPER, widget::w, widget_table, and point::y.

Referenced by gui_internal_keyboard(), gui_internal_keyboard_change(), gui_internal_keyboard_to_lower_case(), gui_internal_keyboard_to_upper_case(), and gui_internal_keyboard_topbox_resize().

◆ gui_internal_keyboard_hide_native()

static void gui_internal_keyboard_hide_native ( struct gui_priv this_,
struct widget w 
)
static

Hides the platform's native on-screen keyboard or other input method.

This function is called as the

wfree

method of the placeholder widget for the platform's native on-screen keyboard. It is a wrapper around the corresponding method of the graphics plugin, which takes care of all platform-specific actions to hide the on-screen input method it previously displayed.

A call to this function indicates that Navit no longer needs the input method and is about to destroy its placeholder widget. Navit will subsequently reclaim any screen real estate it may have previously reserved for the input method.

This function will free the

Definition: graphics.h:62

pointed to by

w->data
int w
Definition: graphics.h:63
Parameters
thisThe internal GUI instance
wThe placeholder widget

References dbg, gui_priv::gra, graphics_hide_native_keyboard(), graphics_keyboard::gui_priv, graphics_keyboard::lang, lvl_warning, and graphics_keyboard::w.

Referenced by gui_internal_keyboard_show_native().

◆ gui_internal_keyboard_init_mode()

int gui_internal_keyboard_init_mode ( char *  lang)

Returns the default keyboard mode for a country.

The return value can be passed to gui_internal_keyboard(struct gui_priv *, int) and related functions.

Parameters
langThe two-letter country code
Returns
@ VKBD_CYRILLIC_UPPER
Definition: gui_internal_keyboard.h:11
for countries using the Cyrillic alphabet,
@ VKBD_LATIN_UPPER
Definition: gui_internal_keyboard.h:6
otherwise

References VKBD_CYRILLIC_UPPER, VKBD_GREEK_UPPER, and VKBD_LATIN_UPPER.

Referenced by gui_internal_cmd_add_bookmark2(), gui_internal_cmd_add_bookmark_folder2(), gui_internal_cmd_log(), gui_internal_cmd_pois_filter(), gui_internal_cmd_rename_bookmark(), gui_internal_html_menu(), and gui_internal_search().

◆ gui_internal_keyboard_key()

static struct widget* gui_internal_keyboard_key ( struct gui_priv this,
struct widget wkbd,
char *  text,
char *  key,
int  w,
int  h 
)
static

◆ gui_internal_keyboard_key_data()

static struct widget* gui_internal_keyboard_key_data ( struct gui_priv this,
struct widget wkbd,
char *  text,
int  font,
void(*)(struct gui_priv *priv, struct widget *widget, void *data func,
void *  data,
void(*)(void *data data_free,
int  w,
int  h 
)
static

◆ gui_internal_keyboard_show_native()

struct widget* gui_internal_keyboard_show_native ( struct gui_priv this,
struct widget w,
int  mode,
char *  lang 
)

Shows the platform's native on-screen keyboard or other input method.

This method is a wrapper around the corresponding method of the graphics plugin, which takes care of all platform-specific details. In particular, it is up to the graphics plugin to determine how to handle the request: it may show its on-screen keyboard or another input method (such as stroke recognition). It may choose to simply ignore the request, which will typically occur when a hardware keyboard (or other hardware input) is available.

The platform's native input method may obstruct parts of Navit's UI. To prevent parts of the UI from becoming unreachable, this method will insert an empty box widget in the appropriate size at the appropriate position, provided the graphics plugin reports the correct values. Otherwise a zero-size widget is inserted. If the graphics driver decides not to display an on-screen input method, no widget will be created and the return value will be

NULL

.

The widget's

wfree

function, to be called when the widget is destroyed, will be used to hide the platform keyboard when it is no longer needed.

Parameters
thisThe internal GUI instance
wThe parent of the widget requiring text input
modeThe requested keyboard mode
langThe language for text input, used to select a keyboard layout
Returns
The placeholder widget for the on-screen keyboard, may be
NULL

References widget::data, dbg, flags_fill, graphics_show_native_keyboard(), gravity_center, gui_internal_box_new(), gui_internal_keyboard_hide_native(), gui_internal_menu_data(), gui_internal_widget_append(), graphics_keyboard::h, widget::h, widget::hmin, menu_data::keyboard, menu_data::keyboard_mode, graphics_keyboard::lang, lvl_error, graphics_keyboard::mode, orientation_horizontal_vertical, graphics_keyboard::w, widget::w, widget::wfree, and widget::wmin.

Referenced by gui_internal_cmd_add_bookmark2(), gui_internal_cmd_add_bookmark_folder2(), gui_internal_cmd_enter_coord(), gui_internal_cmd_log(), gui_internal_cmd_pois_filter(), gui_internal_cmd_rename_bookmark(), gui_internal_html_menu(), and gui_internal_search().

◆ gui_internal_keyboard_to_lower_case()

void gui_internal_keyboard_to_lower_case ( struct gui_priv this)

Switch keyboard mode to lowercase if it's in uppercase mode and.

VKBD_MODE_2

is set.

Called on each alphanumeric input.

Parameters
thisThe internal GUI instance

References gui_internal_keyboard_do(), gui_internal_menu_data(), menu_data::keyboard, menu_data::keyboard_mode, VKBD_CYRILLIC_LOWER, VKBD_CYRILLIC_UPPER, VKBD_FLAG_2, VKBD_GREEK_LOWER, VKBD_GREEK_UPPER, VKBD_LATIN_LOWER, VKBD_LATIN_UPPER, VKBD_UMLAUT_LOWER, and VKBD_UMLAUT_UPPER.

Referenced by gui_internal_keypress_do().

◆ gui_internal_keyboard_to_upper_case()

void gui_internal_keyboard_to_upper_case ( struct gui_priv this)

Switch keyboard mode to uppercase if it's in lowercase mode and.

VKBD_MODE_2

is set.

Called when there's no input left in the input field.

Parameters
thisThe internal GUI instance

References gui_internal_keyboard_do(), gui_internal_menu_data(), menu_data::keyboard, menu_data::keyboard_mode, VKBD_CYRILLIC_LOWER, VKBD_CYRILLIC_UPPER, VKBD_FLAG_2, VKBD_GREEK_LOWER, VKBD_GREEK_UPPER, VKBD_LATIN_LOWER, VKBD_LATIN_UPPER, VKBD_UMLAUT_LOWER, and VKBD_UMLAUT_UPPER.

Referenced by gui_internal_keypress_do().

◆ gui_internal_keyboard_topbox_resize()

static void gui_internal_keyboard_topbox_resize ( struct gui_priv this,
struct widget w,
void *  data,
int  neww,
int  newh 
)
static

Variable Documentation

◆ gui_internal_keyb_modes

gui_internal_keyb_modes
Initial value:
= {
{"DEG", 2, VKBD_FLAG_2, VKBD_FLAG_2},
}
@ VKBD_FLAG_2
Definition: gui_internal_keyboard.h:18
@ VKBD_UMLAUT_LOWER
Definition: gui_internal_keyboard.h:10
@ VKBD_CYRILLIC_LOWER
Definition: gui_internal_keyboard.h:12
@ VKBD_LATIN_LOWER
Definition: gui_internal_keyboard.h:7
@ VKBD_GREEK_LOWER
Definition: gui_internal_keyboard.h:15
@ VKBD_UMLAUT_UPPER
Definition: gui_internal_keyboard.h:9
@ VKBD_GREEK_UPPER
Definition: gui_internal_keyboard.h:14

A list of all available keyboard modes.

Referenced by gui_internal_keyboard_do().