efl

Форк
0
/
button_cxx_example_00.cc 
61 строка · 1.9 Кб
1
/*
2
 * Copyright 2019 by its authors. See AUTHORS.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
// g++ -g `pkg-config --cflags --libs elementary-cxx efl-cxx eina-cxx eo-cxx ecore-cxx evas-cxx edje-cxx` button_cxx_example_00.cc -o button_cxx_example_00
17

18
#define EFL_CXXPERIMENTAL
19
#ifndef EFL_BETA_API_SUPPORT
20
#define EFL_BETA_API_SUPPORT
21
#endif
22
#include <Efl_Ui.hh>
23
#include <iostream>
24

25
using efl::eo::instantiate;
26

27
static void
28
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
29
{
30
   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
31

32
   efl::ui::Win win(instantiate);
33
   win.text_set("Button Example");
34
   win.autohide_set(true);
35

36
   efl::ui::Box box(instantiate, win);
37
   win.content_set(box);
38

39
   efl::ui::Button bt(instantiate, win);
40
   bt.text_set("Hello world!");
41
   box.pack(bt);
42

43
   auto wbt(bt._get_wref());
44
   auto cb(std::bind([wbt]() {
45
        std::cout << wbt->text_get() << std::endl;
46
     }));
47
   efl::eolian::event_add(efl::input::Clickable::clicked_event, bt, cb);
48

49
   efl::ui::Button bt2(instantiate, win);
50
   bt2.text_set("Click to quit");
51
   box.pack(bt2);
52

53
   auto wwin(win._get_wref());
54
   auto cb2(std::bind([wwin]() {
55
        ::efl_del(wwin->_eo_ptr()); // FIXME: No proper C++ API to delete win
56
     }));
57
   efl::eolian::event_add(efl::input::Clickable::clicked_event, bt2, cb2);
58

59
   win.size_set({320,160});
60
}
61
EFL_MAIN()
62

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.