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

Functions

static void gui_internal_scroll_buttons_init (struct gui_priv *this, struct widget *widget, struct scroll_buttons *sb)
 
void gui_internal_box_pack (struct gui_priv *this, struct widget *w)
 Computes the size and location for a box widget. More...
 
static void gui_internal_widget_transfer_content (struct gui_priv *this, struct widget *first, struct widget *second, int move_only)
 Transfer the content of one widget into another one (and optionally vice-versa) More...
 
void gui_internal_widget_swap (struct gui_priv *this, struct widget *first, struct widget *second)
 Swap two widgets. More...
 
void gui_internal_widget_move (struct gui_priv *this, struct widget *dst, struct widget *src)
 Move the content of one widget into another one (the src widget is then deallocated and should be be used anymore) More...
 
static void gui_internal_background_render (struct gui_priv *this, struct widget *w)
 
struct widgetgui_internal_label_font_new (struct gui_priv *this, const char *text, int font)
 
struct widgetgui_internal_label_new (struct gui_priv *this, const char *text)
 
struct widgetgui_internal_label_new_abbrev (struct gui_priv *this, const char *text, int maxwidth)
 
struct widgetgui_internal_image_new (struct gui_priv *this, struct graphics_image *image)
 
static void gui_internal_image_render (struct gui_priv *this, struct widget *w)
 Renders an image or icon, preparing it for drawing on the display. More...
 
static void gui_internal_label_render (struct gui_priv *this, struct widget *w)
 Renders a label, preparing it for drawing on the display. More...
 
struct widgetgui_internal_text_font_new (struct gui_priv *this, const char *text, int font, enum flags flags)
 Creates a text box. More...
 
struct widgetgui_internal_text_new (struct gui_priv *this, const char *text, enum flags flags)
 
struct widgetgui_internal_button_font_new_with_callback (struct gui_priv *this, const char *text, int font, struct graphics_image *image, enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data)
 
struct widgetgui_internal_button_new_with_callback (struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data)
 
struct widgetgui_internal_button_new (struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags)
 
struct widgetgui_internal_find_widget (struct widget *wi, struct point *p, int flags)
 
void gui_internal_highlight_do (struct gui_priv *this, struct widget *found)
 
void gui_internal_highlight (struct gui_priv *this)
 
struct widgetgui_internal_box_new_with_label (struct gui_priv *this, enum flags flags, const char *label)
 
struct widgetgui_internal_box_new (struct gui_priv *this, enum flags flags)
 
static void gui_internal_box_render (struct gui_priv *this, struct widget *w)
 Renders a box widget, preparing it for drawing on the display. More...
 
void gui_internal_box_resize (struct gui_priv *this, struct widget *w, void *data, int wnew, int hnew)
 Resize a box widget. More...
 
void gui_internal_widget_reset_pack (struct gui_priv *this, struct widget *w)
 
void gui_internal_widget_append (struct widget *parent, struct widget *child)
 Adds a child widget to a parent widget, making it the last child. More...
 
void gui_internal_widget_prepend (struct widget *parent, struct widget *child)
 Adds a child widget to a parent widget, making it the first child. More...
 
void gui_internal_widget_insert_sorted (struct widget *parent, struct widget *child, GCompareFunc func)
 Adds a child widget to a parent widget. More...
 
void gui_internal_widget_children_destroy (struct gui_priv *this, struct widget *w)
 Destroys all child widgets. More...
 
void gui_internal_widget_destroy (struct gui_priv *this, struct widget *w)
 Destroys a widget. More...
 
void gui_internal_widget_render (struct gui_priv *this, struct widget *w)
 Renders widgets, preparing it for drawing on the display. More...
 
void gui_internal_widget_pack (struct gui_priv *this, struct widget *w)
 
struct widgetgui_internal_button_label (struct gui_priv *this, const char *label, int mode)
 
struct widgetgui_internal_widget_table_new (struct gui_priv *this, enum flags flags, int buttons)
 Creates a new table widget. More...
 
void gui_internal_widget_table_clear (struct gui_priv *this, struct widget *table)
 Clears all the rows from the table. More...
 
GListgui_internal_widget_table_next_row (GList *row)
 Moves GList pointer to the next table row, skipping other table children (button box, for example). More...
 
GListgui_internal_widget_table_prev_row (GList *row)
 Moves GList pointer to the previous table row, skipping other table children (button box, for example). More...
 
GListgui_internal_widget_table_first_row (GList *row)
 Moves GList pointer to the first table row, skipping other table children (button box, for example). More...
 
GListgui_internal_widget_table_top_row (struct gui_priv *this, struct widget *table)
 Gets GList pointer to the table row drawn on the top of the screen. More...
 
GListgui_internal_widget_table_set_top_row (struct gui_priv *this, struct widget *table, struct widget *row)
 Sets internal top row pointer of the table to point to a given row widget. More...
 
struct widgetgui_internal_widget_table_row_new (struct gui_priv *this, enum flags flags)
 Creates a new table_row widget. More...
 
static GListgui_internal_compute_table_dimensions (struct gui_priv *this, struct widget *w)
 Computes the column dimensions for the table. More...
 
static void g_free_helper (void *data, void *user_data)
 
void gui_internal_table_pack (struct gui_priv *this, struct widget *w)
 Computes the height and width for the table. More...
 
void gui_internal_table_hide_rows (struct table_data *table_data)
 Invalidates coordinates for previously rendered table widget rows. More...
 
void gui_internal_table_render (struct gui_priv *this, struct widget *w)
 Renders a table widget, preparing it for drawing on the display. More...
 
void gui_internal_table_button_next (struct gui_priv *this, struct widget *wm, void *data)
 Handles the 'next page' table event. More...
 
void gui_internal_table_button_prev (struct gui_priv *this, struct widget *wm, void *data)
 Handles the 'previous page' table event. More...
 
void gui_internal_table_data_free (void *p)
 Deallocates a table_data structure. More...
 

Function Documentation

◆ g_free_helper()

static void g_free_helper ( void *  data,
void *  user_data 
)
static

◆ gui_internal_background_render()

static void gui_internal_background_render ( struct gui_priv this,
struct widget w 
)
static

◆ gui_internal_box_new()

◆ gui_internal_box_new_with_label()

struct widget* gui_internal_box_new_with_label ( struct gui_priv this,
enum flags flags flags  ,
const char *  label 
)

◆ gui_internal_box_pack()

◆ gui_internal_box_render()

static void gui_internal_box_render ( struct gui_priv this,
struct widget w 
)
static

◆ gui_internal_box_resize()

void gui_internal_box_resize ( struct gui_priv this,
struct widget w,
void *  data,
int  wnew,
int  hnew 
)

Resize a box widget.

Parameters
thisThe internal GUI instance
wThe widget to resize
wnewThe new width of the widget
hnewTHe new height of the widget

References widget::data, gui_internal_widget_pack(), widget::h, widget::on_resize, orientation, orientation_horizontal, orientation_horizontal_vertical, orientation_vertical, and widget::w.

Referenced by gui_internal_box_new_with_label(), and gui_internal_menu_menu_resize().

◆ gui_internal_button_font_new_with_callback()

struct widget* gui_internal_button_font_new_with_callback ( struct gui_priv this,
const char *  text,
int  font,
struct graphics_image image,
enum flags flags flags  ,
void(*)(struct gui_priv *priv, struct widget *widget, void *data func,
void *  data 
)

◆ gui_internal_button_label()

◆ gui_internal_button_new()

struct widget* gui_internal_button_new ( struct gui_priv this,
const char *  text,
struct graphics_image image,
enum flags flags flags   
)

◆ gui_internal_button_new_with_callback()

◆ gui_internal_compute_table_dimensions()

static GList* gui_internal_compute_table_dimensions ( struct gui_priv this,
struct widget w 
)
static

Computes the column dimensions for the table.

Parameters
thisThe internal GUI instance
wThe table widget to compute dimensions for.

This function examines all of the rows and columns for the table w and returns a list (GList) of table_column_desc elements that describe each column of the table.

The caller is responsible for freeing the returned list.

References scroll_buttons::button_box, widget::children, widget::data, gui_internal_widget_pack(), widget::h, table_column_desc::height, height, table_data::scroll_buttons, widget::w, table_column_desc::width, and width.

Referenced by gui_internal_table_pack(), and gui_internal_table_render().

◆ gui_internal_find_widget()

struct widget* gui_internal_find_widget ( struct widget wi,
struct point p,
int  flags 
)

◆ gui_internal_highlight()

◆ gui_internal_highlight_do()

◆ gui_internal_image_new()

◆ gui_internal_image_render()

static void gui_internal_image_render ( struct gui_priv this,
struct widget w 
)
static

Renders an image or icon, preparing it for drawing on the display.

Parameters
thisThe internal GUI instance
wThe widget to render

References graphics_draw_image(), gui_internal_background_render(), widget::h, graphics_image::hot, widget::img, widget::p, widget::w, point::x, and point::y.

Referenced by gui_internal_widget_render().

◆ gui_internal_label_font_new()

◆ gui_internal_label_new()

◆ gui_internal_label_new_abbrev()

struct widget* gui_internal_label_new_abbrev ( struct gui_priv this,
const char *  text,
int  maxwidth 
)

◆ gui_internal_label_render()

static void gui_internal_label_render ( struct gui_priv this,
struct widget w 
)
static

◆ gui_internal_scroll_buttons_init()

◆ gui_internal_table_button_next()

void gui_internal_table_button_next ( struct gui_priv this,
struct widget wm,
void *  data 
)

Handles the 'next page' table event.

A callback function that is invoked when the 'next page' button is pressed to advance the contents of a table widget.

Parameters
thisThe graphics context.
wmThe button widget that was pressed.
data

References table_data::bottom_row, widget::data, data, gui_internal_menu_render(), gui_internal_table_hide_rows(), widget::state, STATE_HIGHLIGHTED, table_data::top_row, widget::type, and widget_table.

Referenced by gui_internal_cmd_pois(), gui_internal_gesture_do(), and gui_internal_scroll_buttons_init().

◆ gui_internal_table_button_prev()

void gui_internal_table_button_prev ( struct gui_priv this,
struct widget wm,
void *  data 
)

Handles the 'previous page' table event.

A callback function that is invoked when the 'previous page' button is pressed to go back in the contents of a table widget.

Parameters
thisThe graphics context.
wmThe button widget that was pressed.

References scroll_buttons::button_box, widget::data, data, gui_internal_menu_render(), gui_internal_table_hide_rows(), widget::h, widget::p, table_data::scroll_buttons, widget::state, STATE_HIGHLIGHTED, table_data::top_row, widget::type, widget::w, widget_table, and point::y.

Referenced by gui_internal_gesture_do(), and gui_internal_scroll_buttons_init().

◆ gui_internal_table_data_free()

void gui_internal_table_data_free ( void *  p)

Deallocates a table_data structure.

Note
button_box and its children (next_button,prev_button) have their memory managed by the table itself.
Parameters
pThe table_data structure

References p.

Referenced by gui_internal_widget_table_new().

◆ gui_internal_table_hide_rows()

void gui_internal_table_hide_rows ( struct table_data table_data)

Invalidates coordinates for previously rendered table widget rows.

Parameters
table_dataData from the table object.

References table_data::bottom_row, widget::data, widget::h, widget::p, table_data::top_row, widget::type, widget::w, widget_table_row, point::x, and point::y.

Referenced by gui_internal_motion_cb(), gui_internal_table_button_next(), gui_internal_table_button_prev(), and gui_internal_table_render().

◆ gui_internal_table_pack()

void gui_internal_table_pack ( struct gui_priv this,
struct widget w 
)

Computes the height and width for the table.

The height and width are computed to display all cells in the table at the requested height/width.

Parameters
thisThe graphics context
wThe widget to pack.

References scroll_buttons::button_box, widget::c, widget::children, widget::data, g_free_helper(), gui_internal_compute_table_dimensions(), gui_internal_widget_pack(), widget::h, table_column_desc::height, height, table_data::scroll_buttons, widget::w, table_column_desc::width, width, pcoord::x, and pcoord::y.

Referenced by gui_internal_widget_pack().

◆ gui_internal_table_render()

◆ gui_internal_text_font_new()

struct widget* gui_internal_text_font_new ( struct gui_priv this,
const char *  text,
int  font,
enum flags flags flags   
)

Creates a text box.

A text box is a widget that renders a text string containing newlines. The string will be broken up into label widgets at each newline with a vertical layout.

Parameters
thisThe internal GUI instance
textThe text to be displayed in the text box
fontThe font to use for the text
flags

References gui_internal_box_new(), gui_internal_label_font_new(), gui_internal_widget_append(), gui_internal_widget_pack(), and widget::text.

Referenced by gui_internal_button_font_new_with_callback(), gui_internal_html_text(), and gui_internal_text_new().

◆ gui_internal_text_new()

struct widget* gui_internal_text_new ( struct gui_priv this,
const char *  text,
enum flags flags flags   
)

◆ gui_internal_widget_append()

void gui_internal_widget_append ( struct widget parent,
struct widget child 
)

Adds a child widget to a parent widget, making it the last child.

Parameters
parentThe parent widget
childThe child widget

References widget::background, and widget::parent.

Referenced by gui_internal_add_vehicle_profile(), gui_internal_button_font_new_with_callback(), gui_internal_button_label(), gui_internal_cmd2_about(), gui_internal_cmd2_locale(), gui_internal_cmd2_network_info(), gui_internal_cmd2_route_description(), gui_internal_cmd2_route_height_profile(), gui_internal_cmd2_setting_layout(), gui_internal_cmd2_setting_maps(), gui_internal_cmd2_setting_rules(), gui_internal_cmd2_setting_vehicle(), gui_internal_cmd_add_bookmark2(), gui_internal_cmd_add_bookmark_folder2(), gui_internal_cmd_bookmarks(), gui_internal_cmd_enter_coord(), gui_internal_cmd_formerdests(), gui_internal_cmd_log(), gui_internal_cmd_map_download(), gui_internal_cmd_map_download_do(), gui_internal_cmd_pois(), gui_internal_cmd_pois_filter(), gui_internal_cmd_pois_selector(), gui_internal_cmd_position_do(), gui_internal_cmd_rename_bookmark(), gui_internal_cmd_show_nmea_data(), gui_internal_cmd_show_satellite_status(), gui_internal_cmd_view_attribute_details(), gui_internal_cmd_view_attributes(), gui_internal_cmd_view_on_map(), gui_internal_create_resultlist_entry(), gui_internal_html_end(), gui_internal_html_menu(), gui_internal_html_text(), gui_internal_keyboard_do(), gui_internal_keyboard_key_data(), gui_internal_keyboard_show_native(), gui_internal_menu(), gui_internal_menu_vehicle_settings(), gui_internal_populate_route_table(), gui_internal_scroll_buttons_init(), gui_internal_search(), gui_internal_search_idle(), gui_internal_select_waypoint(), gui_internal_text_font_new(), gui_internal_time_help(), gui_internal_top_bar(), and gui_internal_widget_table_new().

◆ gui_internal_widget_children_destroy()

void gui_internal_widget_children_destroy ( struct gui_priv this,
struct widget w 
)

Destroys all child widgets.

This function is recursive, destroying all widgets in the child hierarchy of

w

.

Parameters
thisThe internal GUI instance
wThe widget whose children are to be destroyed

References widget::data, gui_internal_widget_destroy(), and widget::w.

Referenced by gui_internal_keyboard_do(), and gui_internal_widget_destroy().

◆ gui_internal_widget_destroy()

void gui_internal_widget_destroy ( struct gui_priv this,
struct widget w 
)

Destroys a widget.

This function also takes care of recursively destroying the entire child widget hierarchy of

w

prior to destroying

w

itself.

Parameters
thisThe internal GUI instance
wThe widget to destroy

References graphics_image_free(), gui_internal_widget_children_destroy(), and widget::w.

Referenced by gui_internal_cmd_bookmarks(), gui_internal_cmd_view_on_map(), gui_internal_label_new_abbrev(), gui_internal_menu_destroy(), gui_internal_top_bar(), gui_internal_widget_children_destroy(), gui_internal_widget_table_clear(), and gui_internal_widget_transfer_content().

◆ gui_internal_widget_insert_sorted()

void gui_internal_widget_insert_sorted ( struct widget parent,
struct widget child,
GCompareFunc  func 
)

Adds a child widget to a parent widget.

Placement of the child widget among its siblings depends on the comparison function

func

.

Parameters
parentThe parent widget
childThe child widget
funcThe comparison function

References widget::background, widget::func, and widget::parent.

Referenced by gui_internal_search_idle().

◆ gui_internal_widget_move()

void gui_internal_widget_move ( struct gui_priv this,
struct widget dst,
struct widget src 
)

Move the content of one widget into another one (the src widget is then deallocated and should be be used anymore)

Parameters
thisThe internal GUI instance
[in,out]dstThe destination widget
[in,out]srcThe source widget

References gui_internal_widget_transfer_content().

Referenced by gui_internal_top_bar_resize().

◆ gui_internal_widget_pack()

◆ gui_internal_widget_prepend()

void gui_internal_widget_prepend ( struct widget parent,
struct widget child 
)

Adds a child widget to a parent widget, making it the first child.

Parameters
parentThe parent widget
childThe child widget

References widget::background, and widget::parent.

Referenced by gui_internal_button_label(), gui_internal_cmd_formerdests(), and gui_internal_cmd_pois().

◆ gui_internal_widget_render()

void gui_internal_widget_render ( struct gui_priv this,
struct widget w 
)

◆ gui_internal_widget_reset_pack()

void gui_internal_widget_reset_pack ( struct gui_priv this,
struct widget w 
)

◆ gui_internal_widget_swap()

void gui_internal_widget_swap ( struct gui_priv this,
struct widget first,
struct widget second 
)

Swap two widgets.

Parameters
thisThe internal GUI instance
[in,out]firstThe first widget
[in,out]secondThe second widget

References gui_internal_widget_transfer_content().

◆ gui_internal_widget_table_clear()

void gui_internal_widget_table_clear ( struct gui_priv this,
struct widget table 
)

Clears all the rows from the table.

This function removes all rows from a table. New rows can later be added to the table.

Parameters
thisThe internal GUI instance
tableThe table widget

References table_data::bottom_row, scroll_buttons::button_box, widget::children, widget::data, gui_internal_widget_destroy(), table_data::scroll_buttons, and table_data::top_row.

Referenced by gui_internal_populate_route_table(), and gui_internal_search_changed().

◆ gui_internal_widget_table_first_row()

GList* gui_internal_widget_table_first_row ( GList row)

Moves GList pointer to the first table row, skipping other table children (button box, for example).

Parameters
rowGList pointer into the children list
Returns
GList pointer to the first row in the children list, or NULL if table is empty.

References gui_internal_widget_table_next_row(), and widget_table_row.

Referenced by gui_internal_widget_table_set_top_row(), and gui_internal_widget_table_top_row().

◆ gui_internal_widget_table_new()

◆ gui_internal_widget_table_next_row()

GList* gui_internal_widget_table_next_row ( GList row)

Moves GList pointer to the next table row, skipping other table children (button box, for example).

Parameters
rowGList pointer into the children list
Returns
GList pointer to the next row in the children list, or NULL if there are no any rows left.

References widget_table_row.

Referenced by gui_internal_motion_cb(), and gui_internal_widget_table_first_row().

◆ gui_internal_widget_table_prev_row()

GList* gui_internal_widget_table_prev_row ( GList row)

Moves GList pointer to the previous table row, skipping other table children (button box, for example).

Parameters
rowGList pointer into the children list
Returns
GList pointer to the previous row in the children list, or NULL if there are no any rows left.

References widget_table_row.

Referenced by gui_internal_motion_cb().

◆ gui_internal_widget_table_row_new()

◆ gui_internal_widget_table_set_top_row()

GList* gui_internal_widget_table_set_top_row ( struct gui_priv this,
struct widget table,
struct widget row 
)

Sets internal top row pointer of the table to point to a given row widget.

Returns
GList pointer to the top row in the children list of the table.

References widget::children, widget::data, gui_internal_widget_table_first_row(), table_data::top_row, widget::type, and widget_table.

Referenced by gui_internal_populate_route_table().

◆ gui_internal_widget_table_top_row()

GList* gui_internal_widget_table_top_row ( struct gui_priv this,
struct widget table 
)

Gets GList pointer to the table row drawn on the top of the screen.

Returns
GList pointer to the top row in the children list, or NULL.

References widget::data, gui_internal_widget_table_first_row(), table_data::top_row, widget::type, and widget_table.

Referenced by gui_internal_keypress_do(), and gui_internal_populate_route_table().

◆ gui_internal_widget_transfer_content()

static void gui_internal_widget_transfer_content ( struct gui_priv this,
struct widget first,
struct widget second,
int  move_only 
)
static

Transfer the content of one widget into another one (and optionally vice-versa)

Parameters
thisThe internal GUI instance
[in,out]firstThe first widget
[in,out]secondThe second widget
move_onlyIf non nul, transfer only the second widget into the first widget. The second widget is then deallocated and should be be used anymore (this is a move operation)

References dbg, gui_internal_widget_destroy(), and lvl_error.

Referenced by gui_internal_widget_move(), and gui_internal_widget_swap().