From fe4682b41f55cf14e8d8089be05ac409234e8190 Mon Sep 17 00:00:00 2001 From: Denis Dolzhenko Date: Mon, 31 Oct 2016 14:52:50 +0200 Subject: [PATCH] TizenRefApp-7520 Wrap screen-reader accessibility API into new View methods Change-Id: I0a5d3eda5150c67e2944efa9d875b78570529fe7 Signed-off-by: Denis Dolzhenko --- .../View/inc/AtspiAccessibleInterface.h | 121 ++++++++++++++++++ src/Common/View/inc/View.h | 12 ++ 2 files changed, 133 insertions(+) create mode 100644 src/Common/View/inc/AtspiAccessibleInterface.h diff --git a/src/Common/View/inc/AtspiAccessibleInterface.h b/src/Common/View/inc/AtspiAccessibleInterface.h new file mode 100644 index 00000000..12dc35a2 --- /dev/null +++ b/src/Common/View/inc/AtspiAccessibleInterface.h @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef AtspiAccessibleInterface_h_ +#define AtspiAccessibleInterface_h_ + +#include "LangUtils.h" +#include "Config.h" +#include + +namespace Msg +{ + /** + * @brief Wrapper for Elm_Interface_Atspi_Accessible interface (Screen reader) + */ + class AtspiAccessibleInterface + { + public: + AtspiAccessibleInterface(Elm_Interface_Atspi_Accessible *obj); + void wrap(Elm_Interface_Atspi_Accessible *obj); + Elm_Interface_Atspi_Accessible *getEo() const; + operator Elm_Interface_Atspi_Accessible *() const; + + void setDescription(const char *text); + void setDescription(const std::string &text); + void setName(const char *text); + void setName(const std::string &text); + void setRole(Elm_Atspi_Role role); + void setReadingInfo(Elm_Accessible_Reading_Info_Type type); + void appendRelationship(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj); + void removeRelationship(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj); + void canHighlight(bool canHighlight); + + // TODO: impl. other methods if needed + + private: + Elm_Interface_Atspi_Accessible *m_pEo; + }; + + inline AtspiAccessibleInterface::AtspiAccessibleInterface(Elm_Interface_Atspi_Accessible *obj) + : m_pEo(obj) + { + } + + inline void AtspiAccessibleInterface::wrap(Elm_Interface_Atspi_Accessible *obj) + { + m_pEo = obj; + } + + inline Elm_Interface_Atspi_Accessible *AtspiAccessibleInterface::getEo() const + { + return m_pEo; + } + + inline AtspiAccessibleInterface::operator Elm_Interface_Atspi_Accessible *() const + { + return getEo(); + } + + inline void AtspiAccessibleInterface::setDescription(const char *text) + { + elm_atspi_accessible_description_set(m_pEo, text); + elm_atspi_accessible_translation_domain_set(m_pEo, PACKAGE_NAME); + } + + inline void AtspiAccessibleInterface::setDescription(const std::string &text) + { + setDescription(text.c_str()); + } + + inline void AtspiAccessibleInterface::setName(const char *text) + { + elm_atspi_accessible_name_set(m_pEo, (char*)text); + } + + inline void AtspiAccessibleInterface::setName(const std::string &text) + { + setName(text.c_str()); + } + + inline void AtspiAccessibleInterface::setRole(Elm_Atspi_Role role) + { + elm_atspi_accessible_role_set(m_pEo, role); + } + + inline void AtspiAccessibleInterface::setReadingInfo(Elm_Accessible_Reading_Info_Type type) + { + elm_atspi_accessible_reading_info_type_set(m_pEo, type); + } + + inline void AtspiAccessibleInterface::appendRelationship(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj) + { + elm_atspi_accessible_relationship_append(m_pEo, type, obj); + } + + inline void AtspiAccessibleInterface::removeRelationship(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj) + { + elm_atspi_accessible_relationship_remove(m_pEo, type, obj); + } + + inline void AtspiAccessibleInterface::canHighlight(bool canHighlight) + { + elm_atspi_accessible_can_highlight_set(m_pEo, canHighlight); + } +} + +#endif /* AtspiAccessibleInterface_h_ */ diff --git a/src/Common/View/inc/View.h b/src/Common/View/inc/View.h index 9238269f..e9762c90 100644 --- a/src/Common/View/inc/View.h +++ b/src/Common/View/inc/View.h @@ -21,6 +21,7 @@ #include "BaseView.h" #include "LangUtils.h" #include "CallbackAssist.h" +#include "AtspiAccessibleInterface.h" #include #include @@ -298,6 +299,12 @@ namespace Msg */ Evas_Object *getEdje() const; + /** + * @brief Gets AtspiAccessibleInterface wrapper + * @return wrapper to AtspiAccessibleInterface + */ + AtspiAccessibleInterface getAtspi() const; + static void setText(Evas_Object *obj, const TText &text, const char *part = nullptr); static Evas_Object *addLayout(Evas_Object *parent, const std::string &edjePath, const std::string &group); @@ -569,6 +576,11 @@ namespace Msg { setMirrored(getEo(), mirrored); } + + inline AtspiAccessibleInterface View::getAtspi() const + { + return AtspiAccessibleInterface(m_pEo); + } } #endif /* View_h_ */ -- 2.34.1