Debian Codegraph @

tests/accessibility/cally-atkcomponent-example.c

raw
1 /* CALLY - The Clutter Accessibility Implementation Library
2 *
3 * Copyright (C) 2009 Igalia, S.L.
4 *
5 * Author: Alejandro Piñeiro Iglesias <[email protected]>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 */
22
23 #include <clutter/clutter.h>
24
25 #include "cally-examples-util.h"
26
27 #define WIDTH 300
28 #define HEIGHT 300
29 #define SIZE 50
30 #define DEPTH -100
31
32 int
33 main (int argc, char *argv[])
34 {
35 ClutterActor *stage = NULL;
36 ClutterActor *button1 = NULL;
37 ClutterActor *button2 = NULL;
38 ClutterActor *button3 = NULL;
39 ClutterActor *button4 = NULL;
40 ClutterActor *group[4];
41 int i = 0;
42
43 if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
44 return 1;
45
46 cally_util_a11y_init (&argc, &argv);
47
48 stage = clutter_stage_new ();
49
50 clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - AtkComponent Test");
51 clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_White);
52 clutter_actor_set_size (stage, WIDTH, HEIGHT);
53
54 g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
55
56 button1 = clutter_rectangle_new_with_color (CLUTTER_COLOR_Yellow);
57 clutter_actor_set_size (button1, SIZE, SIZE);
58
59 button2 = clutter_rectangle_new_with_color (CLUTTER_COLOR_Green);
60 clutter_actor_set_position (button2, 2 * SIZE, 0);
61 clutter_actor_set_size (button2, SIZE, SIZE);
62
63 button3 = clutter_rectangle_new_with_color (CLUTTER_COLOR_Blue);
64 clutter_actor_set_position (button3, 0, 2 * SIZE);
65 clutter_actor_set_size (button3, SIZE, SIZE);
66 clutter_actor_set_depth( button3, DEPTH);
67
68 /* a nested hierarchy, to check that the relative positions are
69 computed properly */
70 button4 = clutter_rectangle_new_with_color (CLUTTER_COLOR_Magenta);
71 clutter_actor_set_position (button4, SIZE / 2, SIZE / 2);
72 clutter_actor_set_size (button4, SIZE, SIZE);
73
74 for (i = 0; i < 4; i++) {
75 group[i] = clutter_group_new ();
76 clutter_actor_set_position (group[i], SIZE / 2, SIZE / 2);
77 clutter_actor_set_size (group[i], SIZE, SIZE);
78
79 if (i > 0)
80 clutter_container_add_actor (CLUTTER_CONTAINER (group[i]), group [i - 1]);
81 }
82
83 clutter_container_add_actor (CLUTTER_CONTAINER (stage), button1);
84 clutter_container_add_actor (CLUTTER_CONTAINER (stage), button2);
85 clutter_container_add_actor (CLUTTER_CONTAINER (stage), button3);
86 clutter_container_add_actor (CLUTTER_CONTAINER (stage), group[3]);
87 clutter_container_add_actor (CLUTTER_CONTAINER (group[0]), button4);
88
89 clutter_actor_show (stage);
90
91 clutter_main ();
92
93 return 0;
94 }