cxx: Added examples and tutorial for C++ binding
[platform/upstream/elementary.git] / src / examples / thumb_cxx_example_01.cc
1 #include <Elementary.hh>
2
3 #include <iostream>
4 #include <sstream>
5
6 EAPI_MAIN int
7 elm_main(int argc, char *argv[])
8 {
9    elm_need_ethumb();
10
11    elm_app_info_set(reinterpret_cast<void*>(elm_main), "elementary", "images/plant_01.jpg");
12    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
13
14    ::elm::win_standard win;
15    win.title_set("Thumbnailer");
16    win.autohide_set(true);
17
18    ::elm::thumb thumb(efl::eo::parent = win);
19
20    auto generation_started = std::bind([] { std::cout << "thumbnail generation started." << std::endl; });
21
22    auto generation_finished = std::bind([] { std::cout << "thumbnail generation finished." << std::endl; });
23
24    auto generation_error = std::bind([] { std::cout << "thumbnail generation error." << std::endl; });
25
26    thumb.callback_generate_start_add( generation_started );
27    thumb.callback_generate_stop_add( generation_finished );
28    thumb.callback_generate_error_add( generation_error );
29
30    thumb.size_set(160, 160);
31    thumb.editable_set(false);
32    std::stringstream ss;
33    ss << elm_app_data_dir_get() << "/images/plant_01.jpg";
34    thumb.file_set(ss.str(), "image");
35    thumb.reload();
36
37    thumb.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
38    win.resize_object_add(thumb);
39    thumb.visible_set(true);
40
41    win.size_set(320, 320);
42    win.visible_set(true);
43
44    elm_run();
45    return 0;
46 }
47 ELM_MAIN()
48