const void *ssd_widget_get_data (const SsdWidget widget, const char *name) { SsdWidget w = ssd_widget_get (widget, name); if (!w) return NULL; if (w->get_data) return w->get_data (w); else return NULL; }
static BOOL on_kb_closed( int exit_code, const char* value, void* context) { SsdWidget w = context; SsdEntryContext* ctx = ( SsdEntryContext* ) w->context; BOOL retVal = TRUE; if( dec_ok == exit_code) { w->set_value( w, value); if( value && value[0]) ssd_widget_hide( ssd_widget_get( w, "BgText")); else ssd_widget_show( ssd_widget_get( w, "BgText")); } if ( ctx->kb_post_done_cb ) { retVal = ctx->kb_post_done_cb( exit_code, value, context ); } return retVal; }
int ssd_widget_set_data (const SsdWidget widget, const char *name, const void *value) { SsdWidget w = ssd_widget_get (widget, name); if (!w || !w->set_data) return -1; return w->set_data(w, value); }
const char *ssd_widget_get_value (const SsdWidget widget, const char *name) { SsdWidget w = widget; if (name) w = ssd_widget_get (w, name); if (!w) return ""; if (w->get_value) return w->get_value (w); return w->value; }
static void ssd_widget_draw_one (SsdWidget w, int x, int y, int height) { RoadMapGuiRect rect; SsdSize size; ssd_widget_get_size (w, &size, NULL); if (w->flags & SSD_ALIGN_VCENTER) { y += (height - size.height) / 2; } w->position.x = x; w->position.y = y; if (size.width && size.height) { rect.minx = x; rect.miny = y; rect.maxx = x + size.width - 1; rect.maxy = y + size.height - 1; #if 0 if (!w->parent) printf("****** start draw ******\n"); printf("draw - %s:%s x=%d-%d y=%d-%d ofset_x=%d ofset_y=%d \n", w->_typeid, w->name, rect.minx, rect.maxx, rect.miny, rect.maxy, w->offset_x, w->offset_y); #endif if (!RecalculateWidgets && ssd_widget_rect_in_screen(&rect)) w->draw(w, &rect, 0); if (w->children) ssd_widget_draw (w->children, &rect, w->flags); } }
void ssd_widget_container_size (SsdWidget dialog, SsdSize *size) { SsdSize max_size; /* Calculate size recurisvely */ if (dialog->parent) { ssd_widget_container_size (dialog->parent, size); max_size.width = size->width; max_size.height = size->height; } else { max_size.width = roadmap_canvas_width (); #ifdef TOUCH_SCREEN max_size.height = roadmap_canvas_height (); #else max_size.height = roadmap_canvas_height () - roadmap_bar_bottom_height(); #endif } ssd_widget_get_size (dialog, size, &max_size); if (dialog->draw) { RoadMapGuiRect rect; rect.minx = 0; rect.miny = 0; rect.maxx = size->width - 1; rect.maxy = size->height - 1; dialog->draw (dialog, &rect, SSD_GET_SIZE|SSD_GET_CONTAINER_SIZE); size->width = rect.maxx - rect.minx + 1; size->height = rect.maxy - rect.miny + 1; } }
void ssd_generic_icon_list_dialog_show( const char* title, int count, const char** labels, const void** values, const char** icons, const int* flags, PFN_ON_ITEM_SELECTED on_item_selected, PFN_ON_ITEM_SELECTED on_item_deleted, void* context, const char* left_softkey_text, SsdSoftKeyCallback left_softkey_callback, int list_height, int dialog_flags, BOOL add_next_button) { static SsdListContext list_context; SsdWidget list; int list_flags = 0; #if defined (OPENGL) /* * Borders are fast in OPENGL */ list_flags |= SSD_ALIGN_CENTER|SSD_CONTAINER_BORDER|SSD_ROUNDED_CORNERS|SSD_ROUNDED_WHITE; #endif // OPENGL list_context.on_item_selected= on_item_selected; list_context.on_item_deleted = on_item_deleted; list_context.context = context; list_context.left_softkey_callback = left_softkey_callback; if ( !ssd_dialog_exists( SSD_GEN_LIST_DLG_NAME ) ) { GenericList = ssd_dialog_new ( SSD_GEN_LIST_DLG_NAME, "", on_dialog_closed, SSD_CONTAINER_TITLE|dialog_flags); list = ssd_list_new ("list", SSD_MAX_SIZE, SSD_MAX_SIZE, inputtype_none, 0, NULL); ssd_widget_add (GenericList, list); } else{ GenericList->flags &= ~SSD_HEADER_BLACK; GenericList->flags |= dialog_flags; } ssd_widget_set_offset(GenericList,0,0); list = ssd_widget_get (GenericList, "list"); GenericList->set_value (GenericList->parent, title); ssd_widget_set_context (GenericList, &list_context); ssd_widget_reset_cache (list->parent); ssd_widget_reset_position(GenericList); ssd_list_resize ( list, list_height ); ssd_list_populate (list, count, labels, values,icons,flags, list_callback, del_callback, add_next_button); ssd_widget_set_left_softkey_text(GenericList, left_softkey_text); if (left_softkey_callback != NULL) ssd_widget_set_left_softkey_callback(GenericList, list_left_softkey_callback); ssd_dialog_activate (SSD_GEN_LIST_DLG_NAME, NULL); ssd_dialog_draw(); }
void roadmap_messagebox (const char *title, const char *text) { SsdWidget dialog = ssd_dialog_activate ("message_box", NULL); title = roadmap_lang_get (title); text = roadmap_lang_get (text); if (!dialog) { create_messagebox (); dialog = ssd_dialog_activate ("message_box", NULL); } dialog->set_value (dialog, title); ssd_widget_set_value (dialog, "text", text); kill_messagebox_timer (); ssd_dialog_draw (); }
void ssd_confirm_dialog_custom (const char *title, const char *text, BOOL default_yes, ConfirmDialogCallback callback, void *context,const char *textYes, const char *textNo) { SsdWidget dialog; confirm_dialog_context *data = (confirm_dialog_context *)calloc (1, sizeof(*data)); data->default_yes = default_yes; dialog = ssd_dialog_activate ("confirm_dialog", NULL); title = roadmap_lang_get (title); text = roadmap_lang_get (text); if (!dialog) { create_confirm_dialog (default_yes,textYes,textNo); dialog = ssd_dialog_activate ("confirm_dialog", NULL); } else{ #ifdef TOUCH_SCREEN //set button text & softkeys SsdWidget buttonYes; SsdWidget buttonNo; buttonYes = ssd_widget_get(dialog, roadmap_lang_get ("Yes")); // change the buttons to custom text ssd_button_change_text(buttonYes, textYes); buttonNo = ssd_widget_get(dialog, roadmap_lang_get ("No")); ssd_button_change_text(buttonNo, textNo); #else //Non touch set_soft_keys(dialog, textYes, textNo); // change softkeys text to custom text ssd_dialog_refresh_current_softkeys(); #endif } if (title[0] == 0){ ssd_widget_hide(ssd_widget_get(dialog, "title_bar")); } else{ ssd_widget_show(ssd_widget_get(dialog, "title_bar")); } data->callback = callback; data->context = context; dialog->set_value (dialog, title); ssd_widget_set_value (dialog, "text", text); dialog->context = data; ssd_dialog_draw (); }
void ssd_generic_list_dialog_show(const char* title, int count, const char** labels, const void** values, PFN_ON_ITEM_SELECTED on_item_selected, PFN_ON_ITEM_SELECTED on_item_deleted, void* context, int list_height ) { static SsdListContext list_context; SsdWidget list; int flags = 0; #if defined (OPENGL) /* * Borders are fast in OPENGL */ flags |= SSD_ALIGN_CENTER|SSD_CONTAINER_BORDER|SSD_ROUNDED_CORNERS|SSD_ROUNDED_WHITE; #endif // OPENGL list_context.on_item_selected= on_item_selected; list_context.on_item_deleted = on_item_deleted; list_context.context = context; list_context.left_softkey_callback = NULL; if (!GenericList) { GenericList = ssd_dialog_new ( SSD_GEN_LIST_DLG_NAME, "", on_dialog_closed, SSD_CONTAINER_TITLE); ssd_dialog_add_vspace (GenericList, 5, 0); list = ssd_list_new ("list", ssd_container_get_width(), SSD_MAX_SIZE, inputtype_none, flags, NULL); ssd_widget_add (GenericList, list); } list = ssd_widget_get (GenericList, "list"); ssd_widget_set_offset(GenericList,0,0); ssd_widget_set_left_softkey_text(GenericList, roadmap_lang_get("Exit_key")); ssd_widget_set_left_softkey_callback(GenericList, NULL); GenericList->set_value (GenericList->parent, title); ssd_widget_set_context (GenericList, &list_context); ssd_widget_reset_cache (list->parent); ssd_widget_reset_position(GenericList); ssd_list_resize ( list, list_height ); ssd_list_populate (list, count, labels, values, NULL, NULL, list_callback, del_callback, FALSE); ssd_dialog_activate ( SSD_GEN_LIST_DLG_NAME, NULL ); ssd_dialog_draw(); }
static BOOL ssd_container_on_key_pressed( SsdWidget widget, const char* utf8char, uint32_t flags) { if( KEY_IS_ENTER && widget->callback) { widget->callback( widget, SSD_BUTTON_SHORT_CLICK); return TRUE; } return FALSE; }
/******************************************************* * Deallocates the widget node only */ static void ssd_widget_free_node( SsdWidget widget ) { /* * Release the widget itself */ if ( widget->release ) { widget->release( widget ); } free( (char*) widget->name ); free( widget ); }
static BOOL OnKeyPressed (SsdWidget widget, const char* utf8char, uint32_t flags){ BOOL key_handled = TRUE; if( KEY_IS_ENTER) { widget->callback(widget, SSD_BUTTON_SHORT_CLICK); return TRUE; } if( KEYBOARD_VIRTUAL_KEY & flags) { switch( *utf8char) { case VK_Arrow_up: move_up(); break; case VK_Arrow_down: move_down(); break; default: key_handled = FALSE; } } else { assert(utf8char); assert(*utf8char); // Other special keys: if( KEYBOARD_ASCII & flags) { switch(*utf8char) { case TAB_KEY: move_down(); break; default: key_handled = FALSE; } } } if( key_handled) roadmap_screen_redraw (); return key_handled; }
int ssd_widget_pointer_up_force_click (SsdWidget widget, const RoadMapGuiPoint *point) { int ret_val = 0; int movement = ABS_POINTS_DISTANCE( PressedPointerPoint, *point ); if ( widget->force_click && ssd_widget_contains_point( widget, point, TRUE ) && ( movement < FORCE_CLICK_MOVEMENT_THRESHOLD ) ) { if ( widget->long_click && roadmap_pointer_long_click_expired() ) { ret_val = widget->long_click( widget, point ); } else { if ( widget->short_click ) ret_val = widget->short_click( widget, point ); } widget->force_click = FALSE; } // TODO :: Check return value return 1; }
static BOOL ssd_button_on_key_pressed (SsdWidget button, const char* utf8char, uint32_t flags) { struct ssd_button_data *data = (struct ssd_button_data *) button->data; if (data->state == BUTTON_STATE_DISABLED) return FALSE; if( KEY_IS_ENTER ) { button->callback(button, SSD_BUTTON_SHORT_CLICK); return TRUE; } return FALSE; }
static void get_size(SsdWidget w, SsdSize * pack_size, RoadMapGuiRect * max_size){ if (!(w->flags & SSD_VAR_SIZE) && w->children) { RoadMapGuiRect container_rect = *max_size; int container_width; int container_height; w->draw (w, max_size, SSD_GET_SIZE); container_width = max_size->minx - container_rect.minx + container_rect.maxx - max_size->maxx; container_height = max_size->miny - container_rect.miny + container_rect.maxy - max_size->maxy; calc_pack_size (w->children, max_size, pack_size); pack_size->width += container_width; pack_size->height += container_height; } else { w->draw (w, max_size, SSD_GET_SIZE); pack_size->width = max_size->maxx - max_size->minx + 1; pack_size->height = max_size->maxy - max_size->miny + 1; } }
/******************************************************* * Deallocates the widget node only */ static void ssd_widget_free_node( SsdWidget widget ) { /* * Release the widget itself */ if ( widget->release ) { widget->release( widget ); } //int hash = roadmap_hash_string (widget->name); //int index = roadmap_hash_get_first (widget_cache, hash); //roadmap_hash_remove(widget_cache, hash, index); free( (char*) widget->name ); free( widget ); }
BOOL ssd_widget_on_key_pressed( SsdWidget w, const char* utf8char, uint32_t flags) { SsdWidget child; if(w->key_pressed && w->key_pressed( w, utf8char, flags)) return TRUE; child = w->children; while( child) { if( ssd_widget_on_key_pressed( child, utf8char, flags)) return TRUE; child = child->next; } return FALSE; }
static int edit_callback (SsdWidget widget, const char *new_value) { const char *value; SsdEntryContext* ctx; /* Get the entry widget */ widget = widget->parent; ctx = ( SsdEntryContext* ) widget->context; value = widget->get_value (widget); #if ((defined(__SYMBIAN32__) && !defined(TOUCH_SCREEN)) || defined(IPHONE) || defined( ANDROID )) { SsdWidget text = ssd_widget_get(widget->children, "Text"); if ( text && (text->flags & SSD_TEXT_PASSWORD) ) { if (!ctx->editbox_title) ShowEditbox( ctx->kb_title, value, on_kb_closed, widget, EEditBoxPassword ); else ShowEditbox( ctx->editbox_title, value, on_kb_closed, widget, EEditBoxPassword ); } else { if (!ctx->editbox_title) ShowEditbox( ctx->kb_title, value, on_kb_closed, widget, EEditBoxStandard ); else ShowEditbox( ctx->editbox_title, value, on_kb_closed, widget, EEditBoxStandard ); } } #else ssd_show_keyboard_dialog_ext( ctx->editbox_title ? ctx->editbox_title : ctx->kb_title, value, ctx->kb_label, ctx->kb_note, on_kb_closed, widget, ctx->kb_flags ); #endif return 1; }
static BOOL on_key( void* context, const char* utf8char, uint32_t flags) { SsdWidget editbox = ssd_widget_get( s_dialog, s_editbox_name); return editbox->key_pressed( editbox, utf8char, flags); }
static void draw_dialog (SsdDialog dialog) { if (!dialog) { return; } else { RoadMapGuiRect rect; rect.minx = 0; #ifndef TOUCH_SCREEN if (is_screen_wide()) rect.miny = 1; else rect.miny = roadmap_bar_top_height()+1; rect.maxx = roadmap_canvas_width() -1; #else rect.miny = 1; rect.maxx = roadmap_canvas_width() -1; #endif #ifdef TOUCH_SCREEN rect.maxy = roadmap_canvas_height() - 1; #else rect.maxy = roadmap_canvas_height() - 1 - roadmap_bar_bottom_height() ; #endif ssd_widget_reset_cache (dialog->container); ssd_widget_draw (dialog->container, &rect, 0); if ((dialog->container->flags & SSD_CONTAINER_TITLE) && (dialog->scroll_container != NULL) && (dialog->scroll_container->offset_y < 0)){ SsdWidget title; SsdSize size; title = ssd_widget_get (dialog->container, "title_bar"); ssd_widget_get_size(title, &size, NULL); #ifndef TOUCH_SCREEN if (!is_screen_wide()){ rect.miny = roadmap_bar_top_height(); } else{ rect.miny = 0; } #else rect.miny = 1; #endif rect.maxy = rect.miny + size.height-1 ; title->draw(title, &rect, 0); rect.miny +=1; ssd_widget_draw(title->children, &rect, 0); } #ifndef TOUCH_SCREEN roadmap_bar_draw_bottom_bar(TRUE); if ((dialog->container->flags & SSD_CONTAINER_TITLE) && (dialog->scroll_container != NULL) && (dialog->scroll_container->offset_y < 0)) if (!is_screen_wide()) roadmap_bar_draw_top_bar(TRUE); #endif ssd_dialog_sort_tab_order( dialog); ssd_dialog_sort_tab_order_by_gui_position(); } }
void ssd_widget_get_size (SsdWidget w, SsdSize *size, const SsdSize *max) { SsdSize pack_size = {0, 0}; RoadMapGuiRect max_size = {0, 0, 0, 0}; int total_height_below = 0; *size = w->size; if ((w->size.height >= 0) && (w->size.width >= 0)) { return; } if (!max && (w->cached_size.width < 0)) { static SsdSize canvas_size; canvas_size.width = roadmap_canvas_width(); #ifdef TOUCH_SCREEN canvas_size.height = roadmap_canvas_height() ; #else canvas_size.height = roadmap_canvas_height() - roadmap_bar_bottom_height(); #endif max = &canvas_size; } else{ if (!max) max = &w->cached_size; } if ((w->cached_size.width >= 0) && (w->cached_size.height >= 0)) { *size = w->cached_size; return; } /* Comment by AGA. THere is no assignment for this flag if (size->height == SSD_MAX_SIZE) { // Check if other siblings exists and should be placed below this one SsdWidget below_w = w->next; while (below_w) { if (below_w->flags & SSD_ORDER_LAST) { SsdSize s; ssd_widget_get_size (below_w, &s, max); total_height_below += s.height; } below_w = below_w->next; } } */ if ((w->flags & SSD_DIALOG_FLOAT) && !(w->flags & SSD_DIALOG_TRANSPARENT)){ if ((size->width == SSD_MAX_SIZE) && ((max->width >= roadmap_canvas_width()) || (max->width >= roadmap_canvas_height()))){ if (roadmap_canvas_width() > roadmap_canvas_height()) size->width = roadmap_canvas_height(); else size->width = roadmap_canvas_width()- ADJ_SCALE(20); #ifdef IPHONE size->width = ADJ_SCALE(320); #endif }else if (size->width == SSD_MAX_SIZE) size->width = max->width -ADJ_SCALE(20); if (size->height== SSD_MAX_SIZE) size->height= max->height - total_height_below; } else { if (size->width == SSD_MAX_SIZE) size->width = max->width; if (size->height== SSD_MAX_SIZE) size->height= max->height - total_height_below; } #ifdef IPHONE_NATIVE if (size->width > ADJ_SCALE(320)) size->width = ADJ_SCALE(320); #endif //IPHONE if ((size->height >= 0) && (size->width >= 0)) { w->cached_size = *size; return; } if (size->width >= 0) { max_size.maxx = size->width - 1; } else { if (!max){ static SsdSize canvas_size; canvas_size.width = roadmap_canvas_width(); #ifdef TOUCH_SCREEN canvas_size.height = roadmap_canvas_height(); #else canvas_size.height = roadmap_canvas_height() - roadmap_bar_bottom_height(); #endif max = &canvas_size; } max_size.maxx = max->width - 1; } if (size->height >= 0) { max_size.maxy = size->height - 1; } else { max_size.maxy = max->height - 1; } if (!(w->flags & SSD_VAR_SIZE) && w->children) { RoadMapGuiRect container_rect = max_size; int container_width; int container_height; w->draw (w, &max_size, SSD_GET_SIZE); container_width = max_size.minx - container_rect.minx + container_rect.maxx - max_size.maxx; container_height = max_size.miny - container_rect.miny + container_rect.maxy - max_size.maxy; calc_pack_size (w->children, &max_size, &pack_size); pack_size.width += container_width; pack_size.height += container_height; } else { w->draw (w, &max_size, SSD_GET_SIZE); pack_size.width = max_size.maxx - max_size.minx + 1; pack_size.height = max_size.maxy - max_size.miny + 1; } if (size->height< 0) size->height = pack_size.height; if (size->width < 0) size->width = pack_size.width; w->cached_size = *size; }
static BOOL OnKeyPressed( const char* utf8char, uint32_t flags) { BOOL key_handled = TRUE; SsdWidget in_focus = NULL; if( !RoadMapDialogCurrent) return FALSE; // Let the control handle the key: in_focus = RoadMapDialogCurrent->in_focus; if( in_focus && ssd_widget_on_key_pressed (in_focus, utf8char, flags)) { roadmap_screen_redraw(); return TRUE; } // The control did not handle the key... // Supply general handling for virtual keys: if( KEYBOARD_VIRTUAL_KEY & flags) { SsdWidget container = RoadMapDialogCurrent->container; switch( *utf8char) { case VK_Back: ssd_dialog_hide_current(dec_cancel); break; case VK_Arrow_left: if( SSD_TAB_CONTROL & RoadMapDialogCurrent->container->flags) if (RoadMapDialogCurrent->scroll_container) ssd_tabcontrol_move_tab_left( RoadMapDialogCurrent->scroll_container); else ssd_tabcontrol_move_tab_left( RoadMapDialogCurrent->container); else ssd_dialog_move_focus(FOCUS_LEFT); break; case VK_Arrow_up: ssd_dialog_move_focus(FOCUS_UP); break; case VK_Arrow_right: if( SSD_TAB_CONTROL & RoadMapDialogCurrent->container->flags) if (RoadMapDialogCurrent->scroll_container) ssd_tabcontrol_move_tab_right( RoadMapDialogCurrent->scroll_container); else ssd_tabcontrol_move_tab_right( RoadMapDialogCurrent->container); else ssd_dialog_move_focus( FOCUS_RIGHT); break; case VK_Arrow_down: ssd_dialog_move_focus(FOCUS_DOWN); break; case VK_Softkey_right: if (RoadMapDialogCurrent->scroll_container && (RoadMapDialogCurrent->scroll_container->right_softkey_callback != NULL)) RoadMapDialogCurrent->scroll_container->right_softkey_callback(RoadMapDialogCurrent->scroll_container, RoadMapDialogCurrent->scroll_container->name, RoadMapDialogCurrent->scroll_container->context); else if (container->right_softkey_callback != NULL) container->right_softkey_callback(container, container->name, container->context); else #ifdef TOUCH_SCREEN ssd_dialog_hide_current( dec_ok ); #else ssd_dialog_hide_current( dec_cancel ); #endif break; case VK_Softkey_left: if (RoadMapDialogCurrent->scroll_container && (RoadMapDialogCurrent->scroll_container->left_softkey_callback != NULL)) RoadMapDialogCurrent->scroll_container->left_softkey_callback(RoadMapDialogCurrent->scroll_container, RoadMapDialogCurrent->scroll_container->name, RoadMapDialogCurrent->scroll_container->context); else if (container->left_softkey_callback != NULL) container->left_softkey_callback(container, container->name, container->context); else ssd_dialog_hide_all(dec_cancel); break; default: key_handled = FALSE; } } else { assert(utf8char); assert(*utf8char); // Other special keys: if( KEYBOARD_ASCII & flags) { switch(*utf8char) { case ESCAPE_KEY: ssd_dialog_hide_current(dec_cancel); break; case TAB_KEY: ssd_dialog_move_focus(FOCUS_FORWARD); break; default: key_handled = FALSE; } } } if( key_handled) roadmap_screen_redraw (); return key_handled; }