efl
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
25using efl::eo::instantiate;
26
27static void
28efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
29{
30elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
31
32efl::ui::Win win(instantiate);
33win.text_set("Button Example");
34win.autohide_set(true);
35
36efl::ui::Box box(instantiate, win);
37win.content_set(box);
38
39efl::ui::Button bt(instantiate, win);
40bt.text_set("Hello world!");
41box.pack(bt);
42
43auto wbt(bt._get_wref());
44auto cb(std::bind([wbt]() {
45std::cout << wbt->text_get() << std::endl;
46}));
47efl::eolian::event_add(efl::input::Clickable::clicked_event, bt, cb);
48
49efl::ui::Button bt2(instantiate, win);
50bt2.text_set("Click to quit");
51box.pack(bt2);
52
53auto wwin(win._get_wref());
54auto cb2(std::bind([wwin]() {
55::efl_del(wwin->_eo_ptr()); // FIXME: No proper C++ API to delete win
56}));
57efl::eolian::event_add(efl::input::Clickable::clicked_event, bt2, cb2);
58
59win.size_set({320,160});
60}
61EFL_MAIN()
62