navit  0.5.3-trunk
gui_internal_menu.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.h"
#include "navit_nls.h"
#include "xmlconfig.h"
#include "gui_internal.h"
#include "gui_internal_widget.h"
#include "gui_internal_priv.h"
#include "gui_internal_html.h"
#include "gui_internal_search.h"
#include "gui_internal_menu.h"

Functions

int gui_internal_menu_needs_resizing (struct gui_priv *this, struct widget *w, int wdisp, int hdisp)
 Utility function to check if a menu widget is adapted to the display size or needs resizing (if so, the widget dimensions will be set to match those of the display. More...
 
void gui_internal_menu_destroy (struct gui_priv *this, struct widget *w)
 destroy a menu widget and perform the associated cleanup in the menu & submenu list More...
 
static char * gui_internal_widget_get_href (struct widget *w)
 Retrieve then html anchor (href) from a menu widger. More...
 
int gui_internal_widget_reload_href (struct gui_priv *this, struct widget *w)
 Reload a menu from its anchor (href) More...
 
static void gui_internal_prune_menu_do (struct gui_priv *this, struct widget *w, int render)
 Destroy (discard) all menu screens that have been placed after widget w. More...
 
void gui_internal_prune_menu (struct gui_priv *this, struct widget *w)
 Destroy (discard) all menu screens that have been placed after widget w and redraw the display, showing widget @w. More...
 
void gui_internal_prune_menu_count (struct gui_priv *this, int count, int render)
 Destroy (discard) the last count menu screens. More...
 
void gui_internal_menu_menu_resize (struct gui_priv *this, struct widget *w, void *data, int neww, int newh)
 Resize the box widget (and its children) corresponding to a menu. More...
 
struct widgetgui_internal_menu (struct gui_priv *this, const char *label)
 Initializes a GUI menu screen. More...
 
struct menu_datagui_internal_menu_data (struct gui_priv *this)
 
void gui_internal_menu_reset_pack (struct gui_priv *this)
 
void gui_internal_menu_render (struct gui_priv *this)
 Renders a menu GUI on the display. More...
 
void gui_internal_menu_resize (struct gui_priv *this, int w, int h)
 Resize the currently displayed menu. More...
 
static void gui_internal_top_bar_resize (struct gui_priv *this, struct widget *w, void *data, int neww, int newh)
 Resize a top bar created using gui_internal_top_bar() More...
 
struct widgetgui_internal_top_bar (struct gui_priv *this)
 Create an GUI top bar (containing the history of GUI menus and submenus) More...
 

Function Documentation

◆ gui_internal_menu()

struct widget* gui_internal_menu ( struct gui_priv this,
const char *  label 
)

Initializes a GUI menu screen.

This method initializes the internal GUI's screen on which all other elements (such as HTML menus, dialogs or others) are displayed.

It sets up a view hierarchy, which includes a title bar and a client area to hold widgets defined by the caller.

Parameters
thisThe GUI instance
labelThe label to display in the top bar
Returns
The container for caller-defined widgets

References _, widget::background, widget::bb, widget::bl, widget::br, widget::bt, menu_data::button_bar, dbg, widget::flags, flags_expand, flags_fill, widget::func, gravity_center, gravity_left_center, gravity_right_center, gui_internal_apply_config(), gui_internal_back(), gui_internal_box_new(), gui_internal_box_new_with_label(), gui_internal_button_label(), gui_internal_menu_menu_resize(), gui_internal_search_idle_end(), gui_internal_time_help(), gui_internal_top_bar(), gui_internal_widget_append(), gui_internal_widget_pack(), gui_internal_widget_reset_pack(), widget::h, label, lvl_info, widget::menu_data, widget::on_resize, orientation_horizontal, orientation_horizontal_vertical, orientation_vertical, widget::spx, widget::state, STATE_SENSITIVE, and widget::w.

Referenced by 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_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_html_text(), gui_internal_menu_vehicle_settings(), gui_internal_search(), and gui_internal_select_waypoint().

◆ gui_internal_menu_data()

◆ gui_internal_menu_destroy()

void gui_internal_menu_destroy ( struct gui_priv this,
struct widget w 
)

destroy a menu widget and perform the associated cleanup in the menu & submenu list

Parameters
thisThe GUI instance
wThe menu widget to destroy

References attr::callback, callback_destroy(), gui_internal_widget_destroy(), menu_data::href, widget::menu_data, object_func_lookup(), menu_data::refresh_callback, object_func::remove_attr, and attr::u.

Referenced by gui_internal_prune_menu_do(), and gui_internal_widget_reload_href().

◆ gui_internal_menu_menu_resize()

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

Resize the box widget (and its children) corresponding to a menu.

Menus are stored in a main box (topbox) that spawn the entire screen, thus, once the topbox has been resized, it will in turn resize its children, effectively resizing the whole menu display size

Note: once this function has been run, widget w and its children have been resized, a call to gui_internal_box_render() needs to be done by the caller

Parameters
thisThe internal GUI instance
wA box widget corresponding to the menu widget
dataSome data to pass to the box resize handler
newwThe new width of the display
newhThe new height of the display

References padding::bottom, data, dbg, graphics_get_data(), gui_internal_box_resize(), widget::h, padding::left, lvl_warning, widget::p, padding::right, padding::top, widget::type, widget::w, widget_box, point::x, and point::y.

Referenced by gui_internal_menu().

◆ gui_internal_menu_needs_resizing()

int gui_internal_menu_needs_resizing ( struct gui_priv this,
struct widget w,
int  wdisp,
int  hdisp 
)

Utility function to check if a menu widget is adapted to the display size or needs resizing (if so, the widget dimensions will be set to match those of the display.

Parameters
thisThe GUI instance
wThe menu widget (top widget that should spawn over the entire display)
wdispThe width of the display to check the widget against
hdispThe width of the display to check the widget against
Returns
true if widget w has the same size as the provided display dimensions

References widget::h, and widget::w.

Referenced by gui_internal_resize().

◆ gui_internal_menu_render()

void gui_internal_menu_render ( struct gui_priv this)

Renders a menu GUI on the display.

Note
The whole sequence of menus is kept in this->root.children (when going back one page, we just move to the previous child in the list) Thus, only the last child of this->root.children is actually displayed
Parameters
thisThe internal GUI instance

References gui_internal_say(), gui_internal_widget_pack(), and gui_internal_widget_render().

Referenced by 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_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_html_menu(), gui_internal_html_submit(), gui_internal_keyboard_do(), gui_internal_menu_vehicle_settings(), gui_internal_prune_menu_do(), gui_internal_resize(), gui_internal_route_update(), gui_internal_search(), gui_internal_select_waypoint(), gui_internal_table_button_next(), and gui_internal_table_button_prev().

◆ gui_internal_menu_reset_pack()

void gui_internal_menu_reset_pack ( struct gui_priv this)

◆ gui_internal_menu_resize()

void gui_internal_menu_resize ( struct gui_priv this,
int  w,
int  h 
)

Resize the currently displayed menu.

Parameters
thisThe internal GUI instance
wThe new width of the display
hthe new height of the display

References widget::data, dbg, gui_internal_apply_config(), lvl_debug, widget::on_resize, and widget::w.

Referenced by gui_internal_prune_menu_do(), and gui_internal_resize().

◆ gui_internal_prune_menu()

◆ gui_internal_prune_menu_count()

void gui_internal_prune_menu_count ( struct gui_priv this,
int  count,
int  render 
)

Destroy (discard) the last count menu screens.

Parameters
thisThe internal GUI instance
countThe number of menus to destroy at the tail of the menu/submenu stack (if <=0, no menu will be destroyed)
renderwhether we should render the new last menu in the stack (render!=0) or not (render==0)

References gui_internal_prune_menu_do(), and widget::w.

Referenced by gui_internal_back(), gui_internal_cmd_bookmarks(), gui_internal_cmd_formerdests(), gui_internal_cmd_set_active_profile(), gui_internal_html_load_href(), and gui_internal_search_country().

◆ gui_internal_prune_menu_do()

static void gui_internal_prune_menu_do ( struct gui_priv this,
struct widget w,
int  render 
)
static

Destroy (discard) all menu screens that have been placed after widget w.

Parameters
thisThe internal GUI instance
wA widget corresponding to the last menu to keep (all subsequent menus in the list will be destroyed). NULL if all menus should be destroyed.
renderwhether we should render the menu indicated by widget w (render!=0) or not (render==0)

References widget::data, data, gui_internal_menu_destroy(), gui_internal_menu_render(), gui_internal_menu_resize(), gui_internal_say(), gui_internal_search_idle_end(), gui_internal_widget_reload_href(), and widget::w.

Referenced by gui_internal_prune_menu(), and gui_internal_prune_menu_count().

◆ gui_internal_top_bar()

◆ gui_internal_top_bar_resize()

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

Resize a top bar created using gui_internal_top_bar()

Parameters
thisThe internal GUI instance
dataSome data to pass to the box resize handler
newwThe new width of the display
newhThe new height of the display

References dbg, gui_internal_top_bar(), gui_internal_widget_move(), lvl_warning, widget::w, and widget_box.

Referenced by gui_internal_top_bar().

◆ gui_internal_widget_get_href()

static char* gui_internal_widget_get_href ( struct widget w)
static

Retrieve then html anchor (href) from a menu widger.

Parameters
wA widget corresponding to a menu (this widget should be an html menu)
Returns
the string for the href, or NULL if this menu has no href (or the widget is not a menu)

References menu_data::href, and widget::menu_data.

Referenced by gui_internal_widget_reload_href().

◆ gui_internal_widget_reload_href()

int gui_internal_widget_reload_href ( struct gui_priv this,
struct widget w 
)

Reload a menu from its anchor (href)

Parameters
thisThe internal GUI context
wA widget corresponding to the menu to redraw (this widget should be an html menu, thus it should have a href)
Returns
1 in case of success, 0 if no menu could be reloaded
Note
If the widget provided in w has no href, we will return 0

References gui_internal_html_load_href(), gui_internal_menu_destroy(), and gui_internal_widget_get_href().

Referenced by gui_internal_prune_menu_do(), and gui_internal_resize().