Created
August 23, 2014 09:27
-
-
Save tai2/b621bb11bae9f317dac5 to your computer and use it in GitHub Desktop.
Tizen AppCore Hello World
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc -o helloworld helloworld.c `pkg-config --cflags --libs appcore-efl` | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <appcore-efl.h> | |
#include <Ecore.h> | |
#include <Ecore_Evas.h> | |
#define WIDTH 1920 | |
#define HEIGHT 1080 | |
static Ecore_Evas *ee; | |
static int app_create(void *data) { | |
Evas *canvas; | |
Evas_Object *bg, *text; | |
printf("app_create\n"); | |
ee = ecore_evas_wayland_egl_new (NULL, 0, 0, 0, WIDTH, HEIGHT, EINA_FALSE); | |
if (!ee) { | |
fprintf(stderr, "ecore_evas_new() failed\n"); | |
return -1; | |
} | |
ecore_evas_title_set(ee, "Hello World"); | |
ecore_evas_show(ee); | |
canvas = ecore_evas_get(ee); | |
// set background | |
bg = evas_object_rectangle_add(canvas); | |
if (!bg) { | |
fprintf(stderr, "ecore_object_rectangle_add() failed\n"); | |
return -1; | |
} | |
evas_object_color_set(bg, 0, 0, 255, 255); | |
evas_object_resize(bg, WIDTH, HEIGHT); | |
evas_object_move(bg, 0, 0); | |
evas_object_show(bg); | |
ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); | |
// show text | |
text = evas_object_text_add(canvas); | |
if (!text) { | |
fprintf(stderr, "ecore_object_text_add() failed\n"); | |
return -1; | |
} | |
evas_object_text_style_set(text, EVAS_TEXT_STYLE_PLAIN); | |
evas_object_color_set(text, 255, 255, 255, 255); | |
evas_object_text_font_set(text, "Courier", 50); | |
evas_object_text_text_set(text, "Hello, World!"); | |
evas_object_resize(text, 3 * WIDTH / 4, HEIGHT / 4); | |
evas_object_move(text, WIDTH / 8, 3 * HEIGHT / 8); | |
evas_object_show(text); | |
return 0; | |
} | |
static int app_terminate(void *data) { | |
printf("app_terminate\n"); | |
ecore_evas_free(ee); | |
return 0; | |
} | |
static int app_pause(void *data) { | |
printf("app_pause\n"); | |
return 0; | |
} | |
static int app_resume(void *data) { | |
printf("app_resume\n"); | |
return 0; | |
} | |
static int app_reset(bundle *b, void *data) { | |
printf("app_reset\n"); | |
return 0; | |
} | |
int main(int argc, char *argv[]) { | |
struct appcore_ops ops = { | |
.create = app_create, | |
.terminate = app_terminate, | |
.pause = app_pause, | |
.resume = app_resume, | |
.reset = app_reset, | |
.data = NULL, | |
}; | |
return appcore_efl_main("helloworld", &argc, &argv, &ops); // start mainloop | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment