access.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: access.h
  3. // Purpose: interface of wxAccessible
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. wxAccessible functions return a wxAccStatus error code,
  9. which may be one of this enum's values.
  10. */
  11. typedef enum
  12. {
  13. wxACC_FAIL, //!< The function failed.
  14. wxACC_FALSE, //!< The function returned false.
  15. wxACC_OK, //!< The function completed successfully.
  16. wxACC_NOT_IMPLEMENTED, //!< The function is not implemented.
  17. wxACC_NOT_SUPPORTED //!< The function is not supported.
  18. } wxAccStatus;
  19. /**
  20. Directions of navigation are represented by this enum.
  21. */
  22. typedef enum
  23. {
  24. wxNAVDIR_DOWN,
  25. wxNAVDIR_FIRSTCHILD,
  26. wxNAVDIR_LASTCHILD,
  27. wxNAVDIR_LEFT,
  28. wxNAVDIR_NEXT,
  29. wxNAVDIR_PREVIOUS,
  30. wxNAVDIR_RIGHT,
  31. wxNAVDIR_UP
  32. } wxNavDir;
  33. /**
  34. The role of a user interface element is represented by the values of this enum.
  35. */
  36. typedef enum {
  37. wxROLE_NONE,
  38. wxROLE_SYSTEM_ALERT,
  39. wxROLE_SYSTEM_ANIMATION,
  40. wxROLE_SYSTEM_APPLICATION,
  41. wxROLE_SYSTEM_BORDER,
  42. wxROLE_SYSTEM_BUTTONDROPDOWN,
  43. wxROLE_SYSTEM_BUTTONDROPDOWNGRID,
  44. wxROLE_SYSTEM_BUTTONMENU,
  45. wxROLE_SYSTEM_CARET,
  46. wxROLE_SYSTEM_CELL,
  47. wxROLE_SYSTEM_CHARACTER,
  48. wxROLE_SYSTEM_CHART,
  49. wxROLE_SYSTEM_CHECKBUTTON,
  50. wxROLE_SYSTEM_CLIENT,
  51. wxROLE_SYSTEM_CLOCK,
  52. wxROLE_SYSTEM_COLUMN,
  53. wxROLE_SYSTEM_COLUMNHEADER,
  54. wxROLE_SYSTEM_COMBOBOX,
  55. wxROLE_SYSTEM_CURSOR,
  56. wxROLE_SYSTEM_DIAGRAM,
  57. wxROLE_SYSTEM_DIAL,
  58. wxROLE_SYSTEM_DIALOG,
  59. wxROLE_SYSTEM_DOCUMENT,
  60. wxROLE_SYSTEM_DROPLIST,
  61. wxROLE_SYSTEM_EQUATION,
  62. wxROLE_SYSTEM_GRAPHIC,
  63. wxROLE_SYSTEM_GRIP,
  64. wxROLE_SYSTEM_GROUPING,
  65. wxROLE_SYSTEM_HELPBALLOON,
  66. wxROLE_SYSTEM_HOTKEYFIELD,
  67. wxROLE_SYSTEM_INDICATOR,
  68. wxROLE_SYSTEM_LINK,
  69. wxROLE_SYSTEM_LIST,
  70. wxROLE_SYSTEM_LISTITEM,
  71. wxROLE_SYSTEM_MENUBAR,
  72. wxROLE_SYSTEM_MENUITEM,
  73. wxROLE_SYSTEM_MENUPOPUP,
  74. wxROLE_SYSTEM_OUTLINE,
  75. wxROLE_SYSTEM_OUTLINEITEM,
  76. wxROLE_SYSTEM_PAGETAB,
  77. wxROLE_SYSTEM_PAGETABLIST,
  78. wxROLE_SYSTEM_PANE,
  79. wxROLE_SYSTEM_PROGRESSBAR,
  80. wxROLE_SYSTEM_PROPERTYPAGE,
  81. wxROLE_SYSTEM_PUSHBUTTON,
  82. wxROLE_SYSTEM_RADIOBUTTON,
  83. wxROLE_SYSTEM_ROW,
  84. wxROLE_SYSTEM_ROWHEADER,
  85. wxROLE_SYSTEM_SCROLLBAR,
  86. wxROLE_SYSTEM_SEPARATOR,
  87. wxROLE_SYSTEM_SLIDER,
  88. wxROLE_SYSTEM_SOUND,
  89. wxROLE_SYSTEM_SPINBUTTON,
  90. wxROLE_SYSTEM_STATICTEXT,
  91. wxROLE_SYSTEM_STATUSBAR,
  92. wxROLE_SYSTEM_TABLE,
  93. wxROLE_SYSTEM_TEXT,
  94. wxROLE_SYSTEM_TITLEBAR,
  95. wxROLE_SYSTEM_TOOLBAR,
  96. wxROLE_SYSTEM_TOOLTIP,
  97. wxROLE_SYSTEM_WHITESPACE,
  98. wxROLE_SYSTEM_WINDOW
  99. } wxAccRole;
  100. /**
  101. Objects are represented by a wxAccObject enum value.
  102. */
  103. typedef enum {
  104. wxOBJID_WINDOW = 0x00000000,
  105. wxOBJID_SYSMENU = 0xFFFFFFFF,
  106. wxOBJID_TITLEBAR = 0xFFFFFFFE,
  107. wxOBJID_MENU = 0xFFFFFFFD,
  108. wxOBJID_CLIENT = 0xFFFFFFFC,
  109. wxOBJID_VSCROLL = 0xFFFFFFFB,
  110. wxOBJID_HSCROLL = 0xFFFFFFFA,
  111. wxOBJID_SIZEGRIP = 0xFFFFFFF9,
  112. wxOBJID_CARET = 0xFFFFFFF8,
  113. wxOBJID_CURSOR = 0xFFFFFFF7,
  114. wxOBJID_ALERT = 0xFFFFFFF6,
  115. wxOBJID_SOUND = 0xFFFFFFF5
  116. } wxAccObject;
  117. /**
  118. Selection actions are identified by the wxAccSelectionFlags values.
  119. */
  120. typedef enum
  121. {
  122. wxACC_SEL_NONE = 0,
  123. wxACC_SEL_TAKEFOCUS = 1,
  124. wxACC_SEL_TAKESELECTION = 2,
  125. wxACC_SEL_EXTENDSELECTION = 4,
  126. wxACC_SEL_ADDSELECTION = 8,
  127. wxACC_SEL_REMOVESELECTION = 16
  128. } wxAccSelectionFlags;
  129. //@{
  130. /**
  131. Represents a status of the system.
  132. */
  133. #define wxACC_STATE_SYSTEM_ALERT_HIGH 0x00000001
  134. #define wxACC_STATE_SYSTEM_ALERT_MEDIUM 0x00000002
  135. #define wxACC_STATE_SYSTEM_ALERT_LOW 0x00000004
  136. #define wxACC_STATE_SYSTEM_ANIMATED 0x00000008
  137. #define wxACC_STATE_SYSTEM_BUSY 0x00000010
  138. #define wxACC_STATE_SYSTEM_CHECKED 0x00000020
  139. #define wxACC_STATE_SYSTEM_COLLAPSED 0x00000040
  140. #define wxACC_STATE_SYSTEM_DEFAULT 0x00000080
  141. #define wxACC_STATE_SYSTEM_EXPANDED 0x00000100
  142. #define wxACC_STATE_SYSTEM_EXTSELECTABLE 0x00000200
  143. #define wxACC_STATE_SYSTEM_FLOATING 0x00000400
  144. #define wxACC_STATE_SYSTEM_FOCUSABLE 0x00000800
  145. #define wxACC_STATE_SYSTEM_FOCUSED 0x00001000
  146. #define wxACC_STATE_SYSTEM_HOTTRACKED 0x00002000
  147. #define wxACC_STATE_SYSTEM_INVISIBLE 0x00004000
  148. #define wxACC_STATE_SYSTEM_MARQUEED 0x00008000
  149. #define wxACC_STATE_SYSTEM_MIXED 0x00010000
  150. #define wxACC_STATE_SYSTEM_MULTISELECTABLE 0x00020000
  151. #define wxACC_STATE_SYSTEM_OFFSCREEN 0x00040000
  152. #define wxACC_STATE_SYSTEM_PRESSED 0x00080000
  153. #define wxACC_STATE_SYSTEM_PROTECTED 0x00100000
  154. #define wxACC_STATE_SYSTEM_READONLY 0x00200000
  155. #define wxACC_STATE_SYSTEM_SELECTABLE 0x00400000
  156. #define wxACC_STATE_SYSTEM_SELECTED 0x00800000
  157. #define wxACC_STATE_SYSTEM_SELFVOICING 0x01000000
  158. #define wxACC_STATE_SYSTEM_UNAVAILABLE 0x02000000
  159. //@}
  160. //@{
  161. /**
  162. An event identifier that can be sent via wxAccessible::NotifyEvent.
  163. */
  164. #define wxACC_EVENT_SYSTEM_SOUND 0x0001
  165. #define wxACC_EVENT_SYSTEM_ALERT 0x0002
  166. #define wxACC_EVENT_SYSTEM_FOREGROUND 0x0003
  167. #define wxACC_EVENT_SYSTEM_MENUSTART 0x0004
  168. #define wxACC_EVENT_SYSTEM_MENUEND 0x0005
  169. #define wxACC_EVENT_SYSTEM_MENUPOPUPSTART 0x0006
  170. #define wxACC_EVENT_SYSTEM_MENUPOPUPEND 0x0007
  171. #define wxACC_EVENT_SYSTEM_CAPTURESTART 0x0008
  172. #define wxACC_EVENT_SYSTEM_CAPTUREEND 0x0009
  173. #define wxACC_EVENT_SYSTEM_MOVESIZESTART 0x000A
  174. #define wxACC_EVENT_SYSTEM_MOVESIZEEND 0x000B
  175. #define wxACC_EVENT_SYSTEM_CONTEXTHELPSTART 0x000C
  176. #define wxACC_EVENT_SYSTEM_CONTEXTHELPEND 0x000D
  177. #define wxACC_EVENT_SYSTEM_DRAGDROPSTART 0x000E
  178. #define wxACC_EVENT_SYSTEM_DRAGDROPEND 0x000F
  179. #define wxACC_EVENT_SYSTEM_DIALOGSTART 0x0010
  180. #define wxACC_EVENT_SYSTEM_DIALOGEND 0x0011
  181. #define wxACC_EVENT_SYSTEM_SCROLLINGSTART 0x0012
  182. #define wxACC_EVENT_SYSTEM_SCROLLINGEND 0x0013
  183. #define wxACC_EVENT_SYSTEM_SWITCHSTART 0x0014
  184. #define wxACC_EVENT_SYSTEM_SWITCHEND 0x0015
  185. #define wxACC_EVENT_SYSTEM_MINIMIZESTART 0x0016
  186. #define wxACC_EVENT_SYSTEM_MINIMIZEEND 0x0017
  187. #define wxACC_EVENT_OBJECT_CREATE 0x8000
  188. #define wxACC_EVENT_OBJECT_DESTROY 0x8001
  189. #define wxACC_EVENT_OBJECT_SHOW 0x8002
  190. #define wxACC_EVENT_OBJECT_HIDE 0x8003
  191. #define wxACC_EVENT_OBJECT_REORDER 0x8004
  192. #define wxACC_EVENT_OBJECT_FOCUS 0x8005
  193. #define wxACC_EVENT_OBJECT_SELECTION 0x8006
  194. #define wxACC_EVENT_OBJECT_SELECTIONADD 0x8007
  195. #define wxACC_EVENT_OBJECT_SELECTIONREMOVE 0x8008
  196. #define wxACC_EVENT_OBJECT_SELECTIONWITHIN 0x8009
  197. #define wxACC_EVENT_OBJECT_STATECHANGE 0x800A
  198. #define wxACC_EVENT_OBJECT_LOCATIONCHANGE 0x800B
  199. #define wxACC_EVENT_OBJECT_NAMECHANGE 0x800C
  200. #define wxACC_EVENT_OBJECT_DESCRIPTIONCHANGE 0x800D
  201. #define wxACC_EVENT_OBJECT_VALUECHANGE 0x800E
  202. #define wxACC_EVENT_OBJECT_PARENTCHANGE 0x800F
  203. #define wxACC_EVENT_OBJECT_HELPCHANGE 0x8010
  204. #define wxACC_EVENT_OBJECT_DEFACTIONCHANGE 0x8011
  205. #define wxACC_EVENT_OBJECT_ACCELERATORCHANGE 0x8012
  206. //@}
  207. /**
  208. @class wxAccessible
  209. The wxAccessible class allows wxWidgets applications, and wxWidgets itself,
  210. to return extended information about user interface elements to client
  211. applications such as screen readers. This is the main way in which wxWidgets
  212. implements accessibility features.
  213. At present, only Microsoft Active Accessibility is supported by this class.
  214. To use this class, derive from wxAccessible, implement appropriate
  215. functions, and associate an object of the class with a window using
  216. wxWindow::SetAccessible.
  217. All functions return an indication of success, failure, or not implemented
  218. using values of the wxAccStatus enum type.
  219. If you return @c wxACC_NOT_IMPLEMENTED from any function, the system will try
  220. to implement the appropriate functionality. However this will not work with
  221. all functions.
  222. Most functions work with an object @e id, which can be zero to refer to
  223. 'this' UI element, or greater than zero to refer to the nth child element.
  224. This allows you to specify elements that don't have a corresponding wxWindow or
  225. wxAccessible; for example, the sash of a splitter window.
  226. For details on the semantics of functions and types, please refer to the
  227. Microsoft Active Accessibility 1.2 documentation.
  228. This class is compiled into wxWidgets only if the wxUSE_ACCESSIBILITY setup
  229. symbol is set to 1.
  230. @onlyfor{wxmsw}
  231. @library{wxcore}
  232. @category{misc}
  233. @see @sample{access}
  234. */
  235. class wxAccessible : public wxObject
  236. {
  237. public:
  238. /**
  239. Constructor, taking an optional window. The object can be associated with
  240. a window later.
  241. */
  242. wxAccessible(wxWindow* win = NULL);
  243. /**
  244. Destructor.
  245. */
  246. ~wxAccessible();
  247. /**
  248. Performs the default action for the object.
  249. @a childId is 0 (the action for this object) or greater than 0 (the action
  250. for a child).
  251. @return wxACC_NOT_SUPPORTED if there is no default action for this
  252. window (e.g. an edit control).
  253. */
  254. virtual wxAccStatus DoDefaultAction(int childId);
  255. /**
  256. Gets the specified child (starting from 1). If @a child is @NULL and the return
  257. value is wxACC_OK, this means that the child is a simple element and not an
  258. accessible object.
  259. */
  260. virtual wxAccStatus GetChild(int childId, wxAccessible** child);
  261. /**
  262. Returns the number of children in @a childCount.
  263. */
  264. virtual wxAccStatus GetChildCount(int* childCount);
  265. /**
  266. Gets the default action for this object (0) or a child (greater than 0).
  267. Return wxACC_OK even if there is no action. @a actionName is the action, or the
  268. empty string if there is no action. The retrieved string describes the action that is
  269. performed on an object, not what the object does as a result. For example, a toolbar
  270. button that prints a document has a default action of "Press" rather than "Prints
  271. the current document."
  272. */
  273. virtual wxAccStatus GetDefaultAction(int childId,
  274. wxString* actionName);
  275. /**
  276. Returns the description for this object or a child.
  277. */
  278. virtual wxAccStatus GetDescription(int childId,
  279. wxString* description);
  280. /**
  281. Gets the window with the keyboard focus. If childId is 0 and child is @NULL, no
  282. object in this subhierarchy has the focus. If this object has the focus, child
  283. should be 'this'.
  284. */
  285. virtual wxAccStatus GetFocus(int* childId, wxAccessible** child);
  286. /**
  287. Returns help text for this object or a child, similar to tooltip text.
  288. */
  289. virtual wxAccStatus GetHelpText(int childId, wxString* helpText);
  290. /**
  291. Returns the keyboard shortcut for this object or child.
  292. Returns e.g. ALT+K.
  293. */
  294. virtual wxAccStatus GetKeyboardShortcut(int childId,
  295. wxString* shortcut);
  296. /**
  297. Returns the rectangle for this object (id is 0) or a child element (id is
  298. greater than 0).
  299. @a rect is in screen coordinates.
  300. */
  301. virtual wxAccStatus GetLocation(wxRect& rect, int elementId);
  302. /**
  303. Gets the name of the specified object.
  304. */
  305. virtual wxAccStatus GetName(int childId, wxString* name);
  306. /**
  307. Returns the parent of this object, or @NULL.
  308. */
  309. virtual wxAccStatus GetParent(wxAccessible** parent);
  310. /**
  311. Returns a role constant describing this object. See wxAccRole for a list
  312. of these roles.
  313. */
  314. virtual wxAccStatus GetRole(int childId, wxAccRole* role);
  315. /**
  316. Gets a variant representing the selected children of this object.
  317. Acceptable values are:
  318. @li a null variant (IsNull() returns @true)
  319. @li a list variant (GetType() == "list")
  320. @li an integer representing the selected child element,
  321. or 0 if this object is selected (GetType() == "long")
  322. @li a "void*" pointer to a wxAccessible child object
  323. */
  324. virtual wxAccStatus GetSelections(wxVariant* selections);
  325. /**
  326. Returns a state constant. See wxAccStatus for a list of these states.
  327. */
  328. virtual wxAccStatus GetState(int childId, long* state);
  329. /**
  330. Returns a localized string representing the value for the object
  331. or child.
  332. */
  333. virtual wxAccStatus GetValue(int childId, wxString* strValue);
  334. /**
  335. Returns the window associated with this object.
  336. */
  337. wxWindow* GetWindow();
  338. /**
  339. Returns a status value and object id to indicate whether the given point
  340. was on this or a child object. Can return either a child object, or an
  341. integer representing the child element, starting from 1.
  342. @a pt is in screen coordinates.
  343. */
  344. virtual wxAccStatus HitTest(const wxPoint& pt, int* childId,
  345. wxAccessible** childObject);
  346. /**
  347. Navigates from @a fromId to @a toId or to @a toObject.
  348. */
  349. virtual wxAccStatus Navigate(wxNavDir navDir, int fromId,
  350. int* toId,
  351. wxAccessible** toObject);
  352. /**
  353. Allows the application to send an event when something changes in
  354. an accessible object.
  355. */
  356. static void NotifyEvent(int eventType, wxWindow* window,
  357. wxAccObject objectType,
  358. int objectType);
  359. /**
  360. Selects the object or child. See wxAccSelectionFlags for a list
  361. of the selection actions.
  362. */
  363. virtual wxAccStatus Select(int childId,
  364. wxAccSelectionFlags selectFlags);
  365. /**
  366. Sets the window associated with this object.
  367. */
  368. void SetWindow(wxWindow* window);
  369. };