1 /*******************************************************************************
2 * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
3 * The contents of this file are made available under the terms
4 * of the GNU Lesser General Public License (LGPL) Version 2.1 that
5 * accompanies this distribution (lgpl-v21.txt). The LGPL is also
6 * available at http://www.gnu.org/licenses/lgpl.html. If the version
7 * of the LGPL at http://www.gnu.org is different to the version of
8 * the LGPL accompanying this distribution and there is any conflict
9 * between the two license versions, the terms of the LGPL accompanying
10 * this distribution shall govern.
11 *
12 * Contributors:
13 * IBM Corporation - initial API and implementation
14 * Port to the D programming language:
15 * Frank Benoit <benoit@tionex.de>
16 *******************************************************************************/
17 module org.eclipse.swt.internal.accessibility.gtk.ATK;
18
19 import java.lang.all;
20
21
22 import org.eclipse.swt.internal.Library;
23 import org.eclipse.swt.internal.gtk.OS;
24 import org.eclipse.swt.internal.c.atk;
25 import org.eclipse.swt.internal.c.gtk;
26
27 version(Tango){
28 import tango.core.Traits;
29 import tango.core.Tuple;
30 } else { // Phobos
31 import std.traits;
32 import std.typetuple;
33 }
34
35 alias org.eclipse.swt.internal.c.atk.AtkObjectFactory AtkObjectFactory;
36 alias org.eclipse.swt.internal.c.atk.AtkObjectClass AtkObjectClass;
37 alias org.eclipse.swt.internal.c.atk.AtkActionIface AtkActionIface;
38 alias org.eclipse.swt.internal.c.atk.AtkComponentIface AtkComponentIface;
39 alias org.eclipse.swt.internal.c.atk.AtkHypertextIface AtkHypertextIface;
40 alias org.eclipse.swt.internal.c.atk.AtkSelectionIface AtkSelectionIface;
41 alias org.eclipse.swt.internal.c.atk.AtkTextIface AtkTextIface;
42 alias org.eclipse.swt.internal.c.atk.AtkObject AtkObject;
43 alias org.eclipse.swt.internal.c.atk.AtkStateSet AtkStateSet;
44 alias org.eclipse.swt.internal.c.atk.AtkObjectFactoryClass AtkObjectFactoryClass;
45 alias org.eclipse.swt.internal.c.atk.AtkHyperlink AtkHyperlink;
46
47 alias org.eclipse.swt.internal.c.gtk.GtkAccessible GtkAccessible;
48
49 private AtkActionIface* ATK_ACTION_GET_IFACE( AtkObject* ){
50 return null;
51 }
52 private AtkComponentIface* ATK_COMPONENT_GET_IFACE( AtkObject* ){
53 return null;
54 }
55 private AtkObjectFactoryClass* ATK_OBJECT_FACTORY_CLASS( void* ){
56 return null;
57 }
58 private AtkSelectionIface* ATK_SELECTION_GET_IFACE( AtkObject* ){
59 return null;
60 }
61 private AtkTextIface* ATK_TEXT_GET_IFACE(AtkObject*){
62 return null;
63 }
64 private GtkAccessible* GTK_ACCESSIBLE(AtkObject*){
65 return null;
66 }
67
68
69 template NameOfFunc(alias f) {
70 // Note: highly dependent on the .stringof formatting
71 // the value begins with "& " which is why the first two chars are cut off
72 version( LDC ){
73 // stringof in LLVMDC is "&foobar"
74 const char[] NameOfFunc = (&f).stringof[1 .. $];
75 }
76 else{
77 // stringof in DMD is "& foobar"
78 const char[] NameOfFunc = (&f).stringof[2 .. $];
79 }
80 }
81
82 template ForwardGtkAtkCFunc( alias cFunc ) {
83 version(Tango){
84 alias ParameterTupleOf!(cFunc) P;
85 alias ReturnTypeOf!(cFunc) R;
86 mixin("public static R " ~ NameOfFunc!(cFunc) ~ "( P p ){
87 lock.lock();
88 scope(exit) lock.unlock();
89 return cFunc(p);
90 }");
91 } else { // Phobos
92 alias ParameterTypeTuple!(cFunc) P;
93 alias ReturnType!(cFunc) R;
94 mixin("public static R " ~ NameOfFunc!(cFunc) ~ "( P p ){
95 lock.lock();
96 scope(exit) lock.unlock();
97 return cFunc(p);
98 }");
99 }
100 }
101 /+
102 // alternative template implementation, might be more stable
103 template ForwardGtkOsCFunc(String name) {
104 alias typeof(mixin(name)) func;
105 alias ParameterTupleOf!(func) Params;
106 alias ReturnTypeOf!(func) Ret;
107 mixin("public static Ret "~name~"( Params p ) {
108 return ."~name~"(p);
109 }");
110 }
111 +/
112
113 public class ATK : OS {
114
115 /** Constants */
116 public static const int ATK_RELATION_LABELLED_BY = 4;
117 public static const int ATK_ROLE_CHECK_BOX = 7;
118 public static const int ATK_ROLE_COMBO_BOX = 11;
119 public static const int ATK_ROLE_DIALOG = 16;
120 public static const int ATK_ROLE_DRAWING_AREA = 18;
121 public static const int ATK_ROLE_WINDOW = 68;
122 public static const int ATK_ROLE_LABEL = 28;
123 public static const int ATK_ROLE_LIST = 30;
124 public static const int ATK_ROLE_LIST_ITEM = 31;
125 public static const int ATK_ROLE_MENU = 32;
126 public static const int ATK_ROLE_MENU_BAR = 33;
127 public static const int ATK_ROLE_MENU_ITEM = 34;
128 public static const int ATK_ROLE_PAGE_TAB = 36;
129 public static const int ATK_ROLE_PAGE_TAB_LIST = 37;
130 public static const int ATK_ROLE_PROGRESS_BAR = 41;
131 public static const int ATK_ROLE_PUSH_BUTTON = 42;
132 public static const int ATK_ROLE_RADIO_BUTTON = 43;
133 public static const int ATK_ROLE_SCROLL_BAR = 47;
134 public static const int ATK_ROLE_SEPARATOR = 49;
135 public static const int ATK_ROLE_SLIDER = 50;
136 public static const int ATK_ROLE_TABLE = 54;
137 public static const int ATK_ROLE_TABLE_CELL = 55;
138 public static const int ATK_ROLE_TABLE_COLUMN_HEADER = 56;
139 public static const int ATK_ROLE_TABLE_ROW_HEADER = 57;
140 public static const int ATK_ROLE_TEXT = 60;
141 public static const int ATK_ROLE_TOOL_BAR = 62;
142 public static const int ATK_ROLE_TOOL_TIP = 63;
143 public static const int ATK_ROLE_TREE = 64;
144 public static const int ATK_STATE_ARMED = 2;
145 public static const int ATK_STATE_BUSY = 3;
146 public static const int ATK_STATE_CHECKED = 4;
147 public static const int ATK_STATE_DEFUNCT = 5;
148 public static const int ATK_STATE_EDITABLE = 6;
149 public static const int ATK_STATE_ENABLED = 7;
150 public static const int ATK_STATE_EXPANDED = 9;
151 public static const int ATK_STATE_FOCUSABLE = 10;
152 public static const int ATK_STATE_FOCUSED = 11;
153 public static const int ATK_STATE_MULTISELECTABLE = 16;
154 public static const int ATK_STATE_PRESSED = 18;
155 public static const int ATK_STATE_RESIZABLE = 19;
156 public static const int ATK_STATE_SELECTABLE = 20;
157 public static const int ATK_STATE_SELECTED = 21;
158 public static const int ATK_STATE_SHOWING = 23;
159 public static const int ATK_STATE_TRANSIENT = 26;
160 public static const int ATK_STATE_VISIBLE = 28;
161 public static const int ATK_TEXT_BOUNDARY_CHAR = 0;
162 public static const int ATK_TEXT_BOUNDARY_WORD_START = 1;
163 public static const int ATK_TEXT_BOUNDARY_WORD_END = 2;
164 public static const int ATK_TEXT_BOUNDARY_SENTENCE_START = 3;
165 public static const int ATK_TEXT_BOUNDARY_SENTENCE_END = 4;
166 public static const int ATK_TEXT_BOUNDARY_LINE_START = 5;
167 public static const int ATK_TEXT_BOUNDARY_LINE_END = 6;
168 public static const int ATK_XY_WINDOW = 1;
169
170 /** Signals */
171 public static const String selection_changed = "selection_changed";
172 public static const String text_changed_insert = "text_changed::insert";
173 public static const String text_changed_delete = "text_changed::delete";
174 public static const String text_caret_moved = "text_caret_moved";
175 public static const String text_selection_changed = "text_selection_changed";
176
177 mixin ForwardGtkAtkCFunc!(.ATK_ACTION_GET_IFACE );
178 mixin ForwardGtkAtkCFunc!(.ATK_COMPONENT_GET_IFACE);
179 mixin ForwardGtkAtkCFunc!(.ATK_OBJECT_FACTORY_CLASS );
180 mixin ForwardGtkAtkCFunc!(.ATK_SELECTION_GET_IFACE );
181 mixin ForwardGtkAtkCFunc!(.ATK_TEXT_GET_IFACE );
182 mixin ForwardGtkAtkCFunc!(.GTK_ACCESSIBLE );
183 mixin ForwardGtkAtkCFunc!(.atk_focus_tracker_notify );
184 mixin ForwardGtkAtkCFunc!(.atk_get_default_registry );
185 mixin ForwardGtkAtkCFunc!(.atk_object_factory_create_accessible );
186 mixin ForwardGtkAtkCFunc!(.atk_object_factory_get_accessible_type );
187 mixin ForwardGtkAtkCFunc!(.atk_object_initialize );
188 mixin ForwardGtkAtkCFunc!(.atk_object_ref_relation_set );
189 mixin ForwardGtkAtkCFunc!(.atk_registry_get_factory );
190 mixin ForwardGtkAtkCFunc!(.atk_registry_set_factory_type );
191 mixin ForwardGtkAtkCFunc!(.atk_relation_set_get_n_relations );
192 mixin ForwardGtkAtkCFunc!(.atk_relation_set_get_relation );
193 mixin ForwardGtkAtkCFunc!(.atk_relation_set_remove );
194 mixin ForwardGtkAtkCFunc!(.atk_state_set_add_state );
195 mixin ForwardGtkAtkCFunc!(.atk_state_set_new );
196
197 }
198
199