| 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 <atk/atk.h> |
| 24 |
#include <clutter/clutter.h> |
| 25 |
|
| 26 |
#include "cally-examples-util.h" |
| 27 |
|
| 28 |
#define WIDTH 800 |
| 29 |
#define HEIGHT 600 |
| 30 |
#define HEIGHT_STEP 100 |
| 31 |
#define NUM_ENTRIES 3 |
| 32 |
|
| 33 |
static void |
| 34 |
make_ui (ClutterActor *stage) |
| 35 |
{ |
| 36 |
ClutterActor *editable = NULL; |
| 37 |
ClutterActor *rectangle = NULL; |
| 38 |
ClutterActor *label = NULL; |
| 39 |
ClutterColor color_stage = { 0x00, 0x00, 0x00, 0xff }; |
| 40 |
ClutterColor color_text = { 0xff, 0x00, 0x00, 0xff }; |
| 41 |
ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 }; |
| 42 |
ClutterColor color_label = { 0x00, 0xff, 0x55, 0xff }; |
| 43 |
ClutterColor color_rect = { 0x00, 0xff, 0xff, 0x55 }; |
| 44 |
ClutterActor *full_entry = NULL; |
| 45 |
ClutterActor *cloned_entry = NULL; |
| 46 |
|
| 47 |
|
| 48 |
clutter_stage_set_color (CLUTTER_STAGE (stage), &color_stage); |
| 49 |
clutter_actor_set_size (stage, WIDTH, HEIGHT); |
| 50 |
|
| 51 |
label = clutter_text_new_full ("Sans Bold 32px", |
| 52 |
"Entry", |
| 53 |
&color_label); |
| 54 |
clutter_actor_set_position (label, 0, 50); |
| 55 |
|
| 56 |
/* editable */ |
| 57 |
editable = clutter_text_new_full ("Sans Bold 32px", |
| 58 |
"ddd", |
| 59 |
&color_text); |
| 60 |
clutter_actor_set_position (editable, 150, 50); |
| 61 |
clutter_text_set_editable (CLUTTER_TEXT (editable), TRUE); |
| 62 |
clutter_text_set_selectable (CLUTTER_TEXT (editable), TRUE); |
| 63 |
clutter_text_set_selection_color (CLUTTER_TEXT (editable), |
| 64 |
&color_sel); |
| 65 |
clutter_actor_grab_key_focus (editable); |
| 66 |
clutter_actor_set_reactive (editable, TRUE); |
| 67 |
|
| 68 |
/* rectangle: to create a entry "feeling" */ |
| 69 |
rectangle = clutter_rectangle_new_with_color (&color_rect); |
| 70 |
clutter_actor_set_position (rectangle, 150, 50); |
| 71 |
clutter_actor_add_constraint (rectangle, clutter_bind_constraint_new (editable, CLUTTER_BIND_SIZE, 0)); |
| 72 |
|
| 73 |
full_entry = clutter_group_new (); |
| 74 |
clutter_actor_set_position (full_entry, 0, 50); |
| 75 |
clutter_actor_set_size (full_entry, 100, 75); |
| 76 |
clutter_container_add_actor (CLUTTER_CONTAINER (full_entry), label); |
| 77 |
clutter_container_add_actor (CLUTTER_CONTAINER (full_entry), editable); |
| 78 |
clutter_container_add_actor (CLUTTER_CONTAINER (full_entry), rectangle); |
| 79 |
clutter_actor_show_all (full_entry); |
| 80 |
clutter_actor_set_scale (full_entry, 2, 1); |
| 81 |
clutter_container_add_actor (CLUTTER_CONTAINER (stage), full_entry); |
| 82 |
|
| 83 |
/* Cloning! */ |
| 84 |
cloned_entry = clutter_clone_new (full_entry); |
| 85 |
clutter_actor_set_position (cloned_entry, 50, 200); |
| 86 |
clutter_actor_set_scale (cloned_entry, 1, 2); |
| 87 |
clutter_actor_show_all (cloned_entry); |
| 88 |
clutter_actor_set_reactive (cloned_entry, TRUE); |
| 89 |
|
| 90 |
clutter_container_add_actor (CLUTTER_CONTAINER (stage), cloned_entry); |
| 91 |
} |
| 92 |
|
| 93 |
int |
| 94 |
main (int argc, char *argv[]) |
| 95 |
{ |
| 96 |
ClutterActor *stage; |
| 97 |
|
| 98 |
g_set_application_name ("Clone Example"); |
| 99 |
|
| 100 |
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) |
| 101 |
return 1; |
| 102 |
|
| 103 |
cally_util_a11y_init (&argc, &argv); |
| 104 |
|
| 105 |
stage = clutter_stage_new (); |
| 106 |
clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - Clone Test"); |
| 107 |
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); |
| 108 |
|
| 109 |
make_ui (stage); |
| 110 |
|
| 111 |
clutter_actor_show_all (stage); |
| 112 |
|
| 113 |
clutter_main (); |
| 114 |
|
| 115 |
return 0; |
| 116 |
} |