comparison dwt/accessibility/Accessible.d @ 213:36f5cb12e1a2

Update to SWT 3.4M7
author Frank Benoit <benoit@tionex.de>
date Sat, 17 May 2008 17:34:28 +0200
parents ab60f3309436
children e2affbeb686d
comparison
equal deleted inserted replaced
212:ab60f3309436 213:36f5cb12e1a2
255 * application code. 255 * application code.
256 * </p> 256 * </p>
257 */ 257 */
258 public int /*long*/ internal_WM_GETOBJECT (int /*long*/ wParam, int /*long*/ lParam) { 258 public int /*long*/ internal_WM_GETOBJECT (int /*long*/ wParam, int /*long*/ lParam) {
259 if (objIAccessible is null) return 0; 259 if (objIAccessible is null) return 0;
260 if (cast(int)/*64*/lParam is COM.OBJID_CLIENT) { 260 if (lParam is COM.OBJID_CLIENT) {
261 /* LresultFromObject([in] riid, [in] wParam, [in] pAcc) 261 /* LresultFromObject([in] riid, [in] wParam, [in] pAcc)
262 * The argument pAcc is owned by the caller so reference count does not 262 * The argument pAcc is owned by the caller so reference count does not
263 * need to be incremented. 263 * need to be incremented.
264 */ 264 */
265 return COM.LresultFromObject(&COM.IIDIAccessible, wParam, cast(IAccessible)objIAccessible); 265 return COM.LresultFromObject(&COM.IIDIAccessible, wParam, cast(IAccessible)objIAccessible);
509 } 509 }
510 int childID = event.childID; 510 int childID = event.childID;
511 if (childID is ACC.CHILDID_NONE) { 511 if (childID is ACC.CHILDID_NONE) {
512 return iaccessible.accHitTest(xLeft, yTop, pvarChild); 512 return iaccessible.accHitTest(xLeft, yTop, pvarChild);
513 } 513 }
514 //TODO - use VARIANT structure
514 pvarChild.vt = COM.VT_I4; 515 pvarChild.vt = COM.VT_I4;
515 pvarChild.lVal = childIDToOs(childID); 516 pvarChild.lVal = childIDToOs(childID);
516 return COM.S_OK; 517 return COM.S_OK;
517 } 518 }
518 519
535 COM.MoveMemory(pHeight.ptr, pcyHeight, 4); 536 COM.MoveMemory(pHeight.ptr, pcyHeight, 4);
536 osLeft = pLeft[0]; osTop = pTop[0]; osWidth = pWidth[0]; osHeight = pHeight[0]; 537 osLeft = pLeft[0]; osTop = pTop[0]; osWidth = pWidth[0]; osHeight = pHeight[0];
537 } 538 }
538 539
539 AccessibleControlEvent event = new AccessibleControlEvent(this); 540 AccessibleControlEvent event = new AccessibleControlEvent(this);
540 event.childID = osToChildID(cast(int)/*64*/v.lVal); 541 event.childID = osToChildID(v.lVal);
541 event.x = osLeft; 542 event.x = osLeft;
542 event.y = osTop; 543 event.y = osTop;
543 event.width = osWidth; 544 event.width = osWidth;
544 event.height = osHeight; 545 event.height = osHeight;
545 for (int i = 0; i < accessibleControlListeners.length; i++) { 546 for (int i = 0; i < accessibleControlListeners.length; i++) {
583 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 584 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
584 return code; 585 return code;
585 } 586 }
586 587
587 AccessibleControlEvent event = new AccessibleControlEvent(this); 588 AccessibleControlEvent event = new AccessibleControlEvent(this);
588 event.childID = osToChildID(cast(int)/*64*/v.lVal); 589 event.childID = osToChildID(v.lVal);
589 for (int i = 0; i < accessibleControlListeners.length; i++) { 590 for (int i = 0; i < accessibleControlListeners.length; i++) {
590 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; 591 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i];
591 listener.getChild(event); 592 listener.getChild(event);
592 } 593 }
593 Accessible accessible = event.accessible; 594 Accessible accessible = event.accessible;
638 if (code is COM.S_OK) { 639 if (code is COM.S_OK) {
639 osDefaultAction = BSTRToStr( *pszDefaultAction, true ); 640 osDefaultAction = BSTRToStr( *pszDefaultAction, true );
640 } 641 }
641 642
642 AccessibleControlEvent event = new AccessibleControlEvent(this); 643 AccessibleControlEvent event = new AccessibleControlEvent(this);
643 event.childID = osToChildID(cast(int)/*64*/v.lVal); 644 event.childID = osToChildID(v.lVal);
644 event.result = osDefaultAction; 645 event.result = osDefaultAction;
645 for (int i = 0; i < accessibleControlListeners.length; i++) { 646 for (int i = 0; i < accessibleControlListeners.length; i++) {
646 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; 647 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i];
647 listener.getDefaultAction(event); 648 listener.getDefaultAction(event);
648 } 649 }
671 osDescription = WCHARzToStr(*pszDescription, size); 672 osDescription = WCHARzToStr(*pszDescription, size);
672 } 673 }
673 } 674 }
674 675
675 AccessibleEvent event = new AccessibleEvent(this); 676 AccessibleEvent event = new AccessibleEvent(this);
676 event.childID = osToChildID(cast(int)/*64*/v.lVal); 677 event.childID = osToChildID(v.lVal);
677 event.result = osDescription; 678 event.result = osDescription;
678 679
679 // TEMPORARY CODE 680 // TEMPORARY CODE
680 /* Currently our tree columns are emulated using custom draw, 681 /* Currently our tree columns are emulated using custom draw,
681 * so we need to create the description using the tree column 682 * so we need to create the description using the tree column
722 /* Get the default focus child from the OS. */ 723 /* Get the default focus child from the OS. */
723 int osChild = ACC.CHILDID_NONE; 724 int osChild = ACC.CHILDID_NONE;
724 int code = iaccessible.get_accFocus(pvarChild); 725 int code = iaccessible.get_accFocus(pvarChild);
725 if (accessibleControlListeners.length is 0) return code; 726 if (accessibleControlListeners.length is 0) return code;
726 if (code is COM.S_OK) { 727 if (code is COM.S_OK) {
728 //TODO - use VARIANT structure
727 short[1] pvt; 729 short[1] pvt;
728 COM.MoveMemory(pvt.ptr, pvarChild, 2); 730 COM.MoveMemory(pvt.ptr, pvarChild, 2);
729 if (pvt[0] is COM.VT_I4) { 731 if (pvt[0] is COM.VT_I4) {
730 int[1] pChild; 732 int[1] pChild;
731 COM.MoveMemory(pChild.ptr, pvarChild + 8, 4); 733 COM.MoveMemory(pChild.ptr, pvarChild + 8, 4);
777 // the original SysString is clearuped and bstr set to null 779 // the original SysString is clearuped and bstr set to null
778 osHelp = BSTRToStr(*pszHelp, true); 780 osHelp = BSTRToStr(*pszHelp, true);
779 } 781 }
780 782
781 AccessibleEvent event = new AccessibleEvent(this); 783 AccessibleEvent event = new AccessibleEvent(this);
782 event.childID = osToChildID(cast(int)/*64*/v.lVal); 784 event.childID = osToChildID(v.lVal);
783 event.result = osHelp; 785 event.result = osHelp;
784 for (int i = 0; i < accessibleListeners.length; i++) { 786 for (int i = 0; i < accessibleListeners.length; i++) {
785 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i]; 787 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i];
786 listener.getHelp(event); 788 listener.getHelp(event);
787 } 789 }
814 // the original SysString is clearuped and bstr set to null 816 // the original SysString is clearuped and bstr set to null
815 osKeyboardShortcut = BSTRToStr(*pszKeyboardShortcut, true); 817 osKeyboardShortcut = BSTRToStr(*pszKeyboardShortcut, true);
816 } 818 }
817 819
818 AccessibleEvent event = new AccessibleEvent(this); 820 AccessibleEvent event = new AccessibleEvent(this);
819 event.childID = osToChildID(cast(int)/*64*/v.lVal); 821 event.childID = osToChildID(v.lVal);
820 event.result = osKeyboardShortcut; 822 event.result = osKeyboardShortcut;
821 for (int i = 0; i < accessibleListeners.length; i++) { 823 for (int i = 0; i < accessibleListeners.length; i++) {
822 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i]; 824 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i];
823 listener.getKeyboardShortcut(event); 825 listener.getKeyboardShortcut(event);
824 } 826 }
843 // the original SysString is clearuped and bstr set to null 845 // the original SysString is clearuped and bstr set to null
844 osName = BSTRToStr(*pszName, true); 846 osName = BSTRToStr(*pszName, true);
845 } 847 }
846 848
847 AccessibleEvent event = new AccessibleEvent(this); 849 AccessibleEvent event = new AccessibleEvent(this);
848 event.childID = osToChildID(cast(int)/*64*/v.lVal); 850 event.childID = osToChildID(v.lVal);
849 event.result = osName; 851 event.result = osName;
850 for (int i = 0; i < accessibleListeners.length; i++) { 852 for (int i = 0; i < accessibleListeners.length; i++) {
851 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i]; 853 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i];
852 listener.getName(event); 854 listener.getName(event);
853 } 855 }
878 int code = iaccessible.get_accRole(variant, pvarRole); 880 int code = iaccessible.get_accRole(variant, pvarRole);
879 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 881 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
880 // TEMPORARY CODE - process tree and table even if there are no apps listening 882 // TEMPORARY CODE - process tree and table even if there are no apps listening
881 if (accessibleControlListeners.length is 0 && !( null !is cast(Tree)control || null !is cast(Table)control )) return code; 883 if (accessibleControlListeners.length is 0 && !( null !is cast(Tree)control || null !is cast(Table)control )) return code;
882 if (code is COM.S_OK) { 884 if (code is COM.S_OK) {
885 //TODO - use VARIANT structure
883 short[1] pvt; 886 short[1] pvt;
884 COM.MoveMemory(pvt.ptr, pvarRole, 2); 887 COM.MoveMemory(pvt.ptr, pvarRole, 2);
885 if (pvt[0] is COM.VT_I4) { 888 if (pvt[0] is COM.VT_I4) {
886 int[1] pRole; 889 int[1] pRole;
887 COM.MoveMemory(pRole.ptr, pvarRole + 8, 4); 890 COM.MoveMemory(pRole.ptr, pvarRole + 8, 4);
888 osRole = pRole[0]; 891 osRole = pRole[0];
889 } 892 }
890 } 893 }
891 894
892 AccessibleControlEvent event = new AccessibleControlEvent(this); 895 AccessibleControlEvent event = new AccessibleControlEvent(this);
893 event.childID = osToChildID(cast(int)/*64*/v.lVal); 896 event.childID = osToChildID(v.lVal);
894 event.detail = osToRole(osRole); 897 event.detail = osToRole(osRole);
895 // TEMPORARY CODE 898 // TEMPORARY CODE
896 /* Currently our checkbox table and tree are emulated using state mask 899 /* Currently our checkbox table and tree are emulated using state mask
897 * images, so we need to specify 'checkbox' role for the items. */ 900 * images, so we need to specify 'checkbox' role for the items. */
898 if (v.lVal !is COM.CHILDID_SELF) { 901 if (v.lVal !is COM.CHILDID_SELF) {
920 /* Get the default selection from the OS. */ 923 /* Get the default selection from the OS. */
921 int osChild = ACC.CHILDID_NONE; 924 int osChild = ACC.CHILDID_NONE;
922 int code = iaccessible.get_accSelection(pvarChildren); 925 int code = iaccessible.get_accSelection(pvarChildren);
923 if (accessibleControlListeners.length is 0) return code; 926 if (accessibleControlListeners.length is 0) return code;
924 if (code is COM.S_OK) { 927 if (code is COM.S_OK) {
928 //TODO - use VARIANT structure
925 short[1] pvt; 929 short[1] pvt;
926 COM.MoveMemory(pvt.ptr, pvarChildren, 2); 930 COM.MoveMemory(pvt.ptr, pvarChildren, 2);
927 if (pvt[0] is COM.VT_I4) { 931 if (pvt[0] is COM.VT_I4) {
928 int[1] pChild; 932 int[1] pChild;
929 COM.MoveMemory(pChild.ptr, pvarChildren + 8, 4); 933 COM.MoveMemory(pChild.ptr, pvarChildren + 8, 4);
980 int code = iaccessible.get_accState(variant, pvarState); 984 int code = iaccessible.get_accState(variant, pvarState);
981 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 985 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
982 // TEMPORARY CODE - process tree and table even if there are no apps listening 986 // TEMPORARY CODE - process tree and table even if there are no apps listening
983 if (accessibleControlListeners.length is 0 && !( null !is cast(Tree)control || null !is cast(Table)control )) return code; 987 if (accessibleControlListeners.length is 0 && !( null !is cast(Tree)control || null !is cast(Table)control )) return code;
984 if (code is COM.S_OK) { 988 if (code is COM.S_OK) {
989 //TODO - use VARIANT structure
985 short[1] pvt; 990 short[1] pvt;
986 COM.MoveMemory(pvt.ptr, pvarState, 2); 991 COM.MoveMemory(pvt.ptr, pvarState, 2);
987 if (pvt[0] is COM.VT_I4) { 992 if (pvt[0] is COM.VT_I4) {
988 int[1] pState; 993 int[1] pState;
989 COM.MoveMemory(pState.ptr, pvarState + 8, 4); 994 COM.MoveMemory(pState.ptr, pvarState + 8, 4);
990 osState = pState[0]; 995 osState = pState[0];
991 } 996 }
992 } 997 }
993 998 bool grayed = false;
994 AccessibleControlEvent event = new AccessibleControlEvent(this); 999 AccessibleControlEvent event = new AccessibleControlEvent(this);
995 event.childID = osToChildID(cast(int)/*64*/v.lVal); 1000 event.childID = osToChildID(v.lVal);
996 event.detail = osToState(osState); 1001 event.detail = osToState(osState);
997 // TEMPORARY CODE 1002 // TEMPORARY CODE
998 /* Currently our checkbox table and tree are emulated using state mask 1003 /* Currently our checkbox table and tree are emulated using state mask
999 * images, so we need to determine if the item state is 'checked'. */ 1004 * images, so we need to determine if the item state is 'checked'. */
1000 if (v.lVal !is COM.CHILDID_SELF) { 1005 if (v.lVal !is COM.CHILDID_SELF) {
1009 tvItem.hItem = cast(HANDLE) v.lVal; 1014 tvItem.hItem = cast(HANDLE) v.lVal;
1010 } 1015 }
1011 auto result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, &tvItem); 1016 auto result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, &tvItem);
1012 bool checked = (result !is 0) && (((tvItem.state >> 12) & 1) is 0); 1017 bool checked = (result !is 0) && (((tvItem.state >> 12) & 1) is 0);
1013 if (checked) event.detail |= ACC.STATE_CHECKED; 1018 if (checked) event.detail |= ACC.STATE_CHECKED;
1019 grayed = tvItem.state >> 12 > 2;
1014 } else if (null !is cast(Table)control && (control.getStyle() & DWT.CHECK) !is 0) { 1020 } else if (null !is cast(Table)control && (control.getStyle() & DWT.CHECK) !is 0) {
1015 Table table = cast(Table) control; 1021 Table table = cast(Table) control;
1016 TableItem item = table.getItem(event.childID); 1022 int index = event.childID;
1017 if (item !is null) { 1023 if (0 <= index && index < table.getItemCount()) {
1024 TableItem item = table.getItem(index);
1018 if (item.getChecked()) event.detail |= ACC.STATE_CHECKED; 1025 if (item.getChecked()) event.detail |= ACC.STATE_CHECKED;
1026 if (item.getGrayed()) grayed = true;
1019 } 1027 }
1020 } 1028 }
1021 } 1029 }
1022 for (int i = 0; i < accessibleControlListeners.length; i++) { 1030 for (int i = 0; i < accessibleControlListeners.length; i++) {
1023 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; 1031 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i];
1024 listener.getState(event); 1032 listener.getState(event);
1025 } 1033 }
1026 int state = stateToOs(event.detail); 1034 int state = stateToOs(event.detail);
1035 if ((state & ACC.STATE_CHECKED) !is 0 && grayed) {
1036 state &= ~ COM.STATE_SYSTEM_CHECKED;
1037 state |= COM.STATE_SYSTEM_MIXED;
1038 }
1027 pvarState.vt = COM.VT_I4; 1039 pvarState.vt = COM.VT_I4;
1028 pvarState.lVal = state; 1040 pvarState.lVal = state;
1029 return COM.S_OK; 1041 return COM.S_OK;
1030 } 1042 }
1031 1043
1046 osValue = WCHARsToStr((*pszValue)[ 0 .. size ]); 1058 osValue = WCHARsToStr((*pszValue)[ 0 .. size ]);
1047 } 1059 }
1048 } 1060 }
1049 1061
1050 AccessibleControlEvent event = new AccessibleControlEvent(this); 1062 AccessibleControlEvent event = new AccessibleControlEvent(this);
1051 event.childID = osToChildID(cast(int)/*64*/v.lVal); 1063 event.childID = osToChildID(v.lVal);
1052 event.result = osValue; 1064 event.result = osValue;
1053 for (int i = 0; i < accessibleControlListeners.length; i++) { 1065 for (int i = 0; i < accessibleControlListeners.length; i++) {
1054 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; 1066 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i];
1055 listener.getValue(event); 1067 listener.getValue(event);
1056 } 1068 }
1138 Object nextItem = nextItems[i]; 1150 Object nextItem = nextItems[i];
1139 if (auto val = cast(ValueWrapperInt)nextItem ) { 1151 if (auto val = cast(ValueWrapperInt)nextItem ) {
1140 int item = val.value; 1152 int item = val.value;
1141 rgvar[i].vt = COM.VT_I4; 1153 rgvar[i].vt = COM.VT_I4;
1142 rgvar[i].byRef = cast(void*)item; 1154 rgvar[i].byRef = cast(void*)item;
1155 COM.MoveMemory(rgvar + i * VARIANT.sizeof + 8, &item, 4);
1143 } else { 1156 } else {
1144 Accessible accessible = cast(Accessible) nextItem; 1157 Accessible accessible = cast(Accessible) nextItem;
1145 accessible.AddRef(); 1158 accessible.AddRef();
1146 rgvar[i].vt = COM.VT_DISPATCH; 1159 rgvar[i].vt = COM.VT_DISPATCH;
1147 rgvar[i].byRef = cast(void*)accessible.objIAccessible; 1160 rgvar[i].byRef = cast(void*)accessible.objIAccessible;
1187 /* If there are no listeners, query the proxy 1200 /* If there are no listeners, query the proxy
1188 * for its IEnumVariant, and tell it to Reset. 1201 * for its IEnumVariant, and tell it to Reset.
1189 */ 1202 */
1190 if (accessibleControlListeners.length is 0) { 1203 if (accessibleControlListeners.length is 0) {
1191 IEnumVARIANT ienumvariant; 1204 IEnumVARIANT ienumvariant;
1192 int code = cast(int)/*64*/iaccessible.QueryInterface(&COM.IIDIEnumVARIANT, cast(void**)&ienumvariant); 1205 int code = iaccessible.QueryInterface(&COM.IIDIEnumVARIANT, cast(void**)&ienumvariant);
1193 if (code !is COM.S_OK) return code; 1206 if (code !is COM.S_OK) return code;
1194 code = ienumvariant.Reset(); 1207 code = ienumvariant.Reset();
1195 ienumvariant.Release(); 1208 ienumvariant.Release();
1196 return code; 1209 return code;
1197 } 1210 }
1213 int code = iaccessible.QueryInterface(&COM.IIDIEnumVARIANT, cast(void**)&ienumvariant); 1226 int code = iaccessible.QueryInterface(&COM.IIDIEnumVARIANT, cast(void**)&ienumvariant);
1214 if (code !is COM.S_OK) return code; 1227 if (code !is COM.S_OK) return code;
1215 IEnumVARIANT[1] pEnum; 1228 IEnumVARIANT[1] pEnum;
1216 code = ienumvariant.Clone(pEnum.ptr); 1229 code = ienumvariant.Clone(pEnum.ptr);
1217 ienumvariant.Release(); 1230 ienumvariant.Release();
1218 COM.MoveMemory(ppEnum, pEnum.ptr, 4); 1231 COM.MoveMemory(ppEnum, pEnum.ptr, (void*).sizeof);
1219 return code; 1232 return code;
1220 } 1233 }
1221 1234
1222 if (ppEnum is null) return COM.E_INVALIDARG; 1235 if (ppEnum is null) return COM.E_INVALIDARG;
1223 *ppEnum = objIEnumVARIANT; 1236 *ppEnum = objIEnumVARIANT;
1234 * For backward compatibility, we still take a handle childID for tree 1247 * For backward compatibility, we still take a handle childID for tree
1235 * items on XP. All other childIDs are 1-based indices. 1248 * items on XP. All other childIDs are 1-based indices.
1236 */ 1249 */
1237 if (!(cast(Tree)control )) return childID + 1; 1250 if (!(cast(Tree)control )) return childID + 1;
1238 if (OS.COMCTL32_MAJOR < 6) return childID; 1251 if (OS.COMCTL32_MAJOR < 6) return childID;
1239 return cast(int)/*64*/OS.SendMessage (control.handle, OS.TVM_MAPHTREEITEMTOACCID, childID, 0); 1252 return OS.SendMessage (control.handle, OS.TVM_MAPHTREEITEMTOACCID, childID, 0);
1240 } 1253 }
1241 1254
1242 int osToChildID(int osChildID) { 1255 int osToChildID(int osChildID) {
1243 if (osChildID is COM.CHILDID_SELF) return ACC.CHILDID_SELF; 1256 if (osChildID is COM.CHILDID_SELF) return ACC.CHILDID_SELF;
1244 /* 1257 /*
1248 * For backward compatibility, we still take a handle childID for tree 1261 * For backward compatibility, we still take a handle childID for tree
1249 * items on XP. All other childIDs are 1-based indices. 1262 * items on XP. All other childIDs are 1-based indices.
1250 */ 1263 */
1251 if (!(cast(Tree)control )) return osChildID - 1; 1264 if (!(cast(Tree)control )) return osChildID - 1;
1252 if (OS.COMCTL32_MAJOR < 6) return osChildID; 1265 if (OS.COMCTL32_MAJOR < 6) return osChildID;
1253 return cast(int)/*64*/OS.SendMessage (control.handle, OS.TVM_MAPACCIDTOHTREEITEM, osChildID, 0); 1266 return OS.SendMessage (control.handle, OS.TVM_MAPACCIDTOHTREEITEM, osChildID, 0);
1254 } 1267 }
1255 1268
1256 int stateToOs(int state) { 1269 int stateToOs(int state) {
1257 int osState = 0; 1270 int osState = 0;
1258 if ((state & ACC.STATE_SELECTED) !is 0) osState |= COM.STATE_SYSTEM_SELECTED; 1271 if ((state & ACC.STATE_SELECTED) !is 0) osState |= COM.STATE_SYSTEM_SELECTED;