[access] move mouse postion if an object has a highlight by highlight_cycle(); not...
[framework/uifw/elementary.git] / src / examples / efl_thread_win32_1.c
1 //Compile with:
2 //gcc -o efl_thread_1 efl_thread_win32_1.c -g `pkg-config --cflags --libs elementary`
3 #include <Elementary.h>
4 #define WIN32_LEAN_AND_MEAN
5 #include <windows.h>
6
7 static Evas_Object *win = NULL;
8 static Evas_Object *rect = NULL;
9
10 static HANDLE thread;
11
12 // BEGIN - code running in my custom win32 thread instance
13 //
14 static DWORD WINAPI
15 my_thread_run(LPVOID arg)
16 {
17    double t = 0.0;
18
19    for (;;)
20      {
21         ecore_thread_main_loop_begin(); // begin critical
22           { // indented for illustration of "critical" block
23              Evas_Coord x, y;
24
25              x = 200 + (200 * sin(t));
26              y = 200 + (200 * cos(t));
27              evas_object_move(rect, x - 50, y - 50);
28           }
29         ecore_thread_main_loop_end(); // end critical
30         usleep(1000);
31         t += 0.02;
32      }
33    return 0;
34 }
35 //
36 // END - code running in my custom win32 thread instance
37
38 static void
39 my_thread_new(void)
40 {
41   thread = CreateThread(NULL, 0, my_thread_run, NULL, 0, NULL);
42   if (!thread)
43     {
44        char *str = evil_last_error_get();
45        if (str)
46          {
47             fprintf("thread creation failed: %s\n", str);
48             free(str);
49          }
50     }
51 }
52
53 EAPI_MAIN int
54 elm_main(int argc, char **argv)
55 {
56    Evas_Object *o, *bg;
57
58    win = elm_win_add(NULL, "efl-thread-1", ELM_WIN_BASIC);
59    elm_win_title_set(win, "EFL Thread 1");
60    elm_win_autodel_set(win, EINA_TRUE);
61    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
62    evas_object_resize(win, 400, 400);
63    evas_object_show(win);
64
65    bg = elm_bg_add(win);
66    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
67    elm_win_resize_object_add(win, bg);
68    evas_object_show(bg);
69
70    o = evas_object_rectangle_add(evas_object_evas_get(win));
71    evas_object_color_set(o, 50, 80, 180, 255);
72    evas_object_resize(o, 100, 100);
73    evas_object_show(o);
74    rect = o;
75
76    // create custom thread to do some "work on the side"
77    my_thread_new();
78
79    elm_run();
80    elm_shutdown();
81
82    return 0;
83 }
84 ELM_MAIN()