EAPI_MAIN int elm_main(int argc, char **argv) { Evas_Object *win, *bg, *icon, *icon2, *bt, *bt2, *layout; Evas_Object *clk; Evas_Object *item; char buf[PATH_MAX]; elm_app_info_set(elm_main, "elementary", "examples/layout_example.edj"); win = elm_win_add(NULL, "layout", ELM_WIN_BASIC); elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); elm_win_autodel_set(win, EINA_TRUE); bg = elm_bg_add(win); elm_bg_color_set(bg, 255,255 ,255); evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_win_resize_object_add(win, bg); evas_object_show(bg); // Adding layout and filling it with widgets layout = elm_layout_add(win); evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_win_resize_object_add(win, layout); snprintf(buf, sizeof(buf), "%s/examples/layout_example.edj", elm_app_data_dir_get()); elm_layout_file_set(layout, buf, "example/mylayout"); evas_object_show(layout); // Setting title const char *title = elm_layout_data_get(layout, "title"); if (title) { elm_win_title_set(win, title); elm_object_part_text_set(layout, TITLE, title); } // Add icon, clock and button to the table icon = elm_icon_add(win); elm_icon_standard_set(icon, "home"); evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_layout_table_pack(layout, TABLE, icon, 0, 0, 1, 1); evas_object_show(icon); icon2 = elm_icon_add(win); elm_icon_standard_set(icon2, "close"); evas_object_size_hint_weight_set(icon2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(icon2, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_layout_table_pack(layout, TABLE, icon2, 1, 0, 1, 1); evas_object_show(icon2); clk = elm_clock_add(win); evas_object_size_hint_weight_set(clk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(clk, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_layout_table_pack(layout, TABLE, clk, 2, 0, 1, 1); evas_object_show(clk); bt = elm_button_add(win); elm_object_text_set(bt, "Click me!"); evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_layout_table_pack(layout, TABLE, bt, 0, 1, 3, 1); evas_object_smart_callback_add(bt, "clicked", _tbl_btn_cb, layout); evas_object_show(bt); item = elm_button_add(win); elm_object_text_set(item, "Position 0"); evas_object_size_hint_weight_set(item, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(item, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_layout_box_insert_at(layout, BOX, item, 0); evas_object_smart_callback_add(item, "clicked", _box_btn_cb, layout); evas_object_show(item); item = elm_button_add(win); elm_object_text_set(item, "Prepended"); evas_object_size_hint_weight_set(item, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(item, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_layout_box_prepend(layout, BOX, item); evas_object_smart_callback_add(item, "clicked", _box_btn_cb, layout); evas_object_show(item); bt2 = elm_button_add(win); elm_object_text_set(bt2, "Delete All"); elm_object_part_content_set(layout, SWALLOW, bt2); evas_object_smart_callback_add(bt2, "clicked", _swallow_btn_cb, layout); evas_object_resize(win, 320, 320); evas_object_show(win); elm_run(); elm_shutdown(); return 0; }
void _show_highscores(void *data, Evas_Object *obj, void *event_info) { highscores_window = elm_win_add(NULL, "Highscores", ELM_WIN_BASIC); elm_win_autodel_set(highscores_window, EINA_TRUE); elm_win_alpha_set(highscores_window, EINA_TRUE); elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); highscores_layout = elm_layout_add(highscores_window); evas_object_size_hint_weight_set(highscores_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_win_resize_object_add(highscores_window, highscores_layout); elm_layout_file_set(highscores_layout, HIGHSCORES_LAYOUT, "highscore_layout"); /*highscores_toolbar = elm_toolbar_add(highscores_window); elm_toolbar_shrink_mode_set(highscores_toolbar, ELM_TOOLBAR_SHRINK_SCROLL); Elm_Object_Item *it = elm_toolbar_item_append(highscores_toolbar, NULL, "Classic - small grid", _show_hs, (int*)CLASSIC_GAME_SMALL_GRID); elm_toolbar_item_append(highscores_toolbar, NULL, "Classic - medium grid", _show_hs, (int*)CLASSIC_GAME_MEDIUM_GRID); elm_toolbar_item_append(highscores_toolbar, NULL, "Classic - big grid", _show_hs, (int*)CLASSIC_GAME_BIG_GRID); elm_toolbar_item_append(highscores_toolbar, NULL, "Arcade", _show_hs, (int*)ARCADE_GAME); elm_toolbar_select_mode_set(highscores_toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);*/ Evas_Object *btn = elm_button_add(highscores_window); evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_object_text_set(btn, "Small"); evas_object_smart_callback_add(btn, "clicked", _show_hs, (int*)CLASSIC_GAME_SMALL_GRID); elm_layout_table_pack(highscores_layout, "hs_toolbar", btn, 0, 0, 1, 1); evas_object_show(btn); btn = elm_button_add(highscores_window); evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_object_text_set(btn, "Normal"); evas_object_smart_callback_add(btn, "clicked", _show_hs, (int*)CLASSIC_GAME_MEDIUM_GRID); elm_layout_table_pack(highscores_layout, "hs_toolbar", btn, 1, 0, 1, 1); evas_object_show(btn); btn = elm_button_add(highscores_window); evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_object_text_set(btn, "Big"); evas_object_smart_callback_add(btn, "clicked", _show_hs, (int*)CLASSIC_GAME_BIG_GRID); elm_layout_table_pack(highscores_layout, "hs_toolbar", btn, 2, 0, 1, 1); evas_object_show(btn); btn = elm_button_add(highscores_window); evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_object_text_set(btn, "Arcade"); evas_object_smart_callback_add(btn, "clicked", _show_hs, (int*)ARCADE_GAME); elm_layout_table_pack(highscores_layout, "hs_toolbar", btn, 3, 0, 1, 1); evas_object_show(btn); highscores_genlist = elm_genlist_add(highscores_window); elm_object_part_content_set(highscores_layout, "list", highscores_genlist); Evas_Object *reset_btn = elm_button_add(highscores_window); elm_object_text_set(reset_btn, "Reset highscores"); elm_object_part_content_set(highscores_layout, "reset_button", reset_btn); evas_object_smart_callback_add(reset_btn, "clicked", _highscores_back_button_cb, NULL); evas_object_show(highscores_layout); evas_object_show(highscores_window); //elm_toolbar_item_selected_set(it, EINA_TRUE); ea_object_event_callback_add(highscores_window, EA_CALLBACK_BACK, _highscores_back_button_cb, NULL); //_show_hs((int*)CLASSIC_GAME_SMALL_GRID, highscores_toolbar, it); }