TizenRefApp-7520 Wrap screen-reader accessibility API into new View methods 61/94561/2 submit/tizen/20161101.081820
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Mon, 31 Oct 2016 12:52:50 +0000 (14:52 +0200)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Mon, 31 Oct 2016 12:54:16 +0000 (14:54 +0200)
Change-Id: I0a5d3eda5150c67e2944efa9d875b78570529fe7
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
src/Common/View/inc/AtspiAccessibleInterface.h [new file with mode: 0644]
src/Common/View/inc/View.h

diff --git a/src/Common/View/inc/AtspiAccessibleInterface.h b/src/Common/View/inc/AtspiAccessibleInterface.h
new file mode 100644 (file)
index 0000000..12dc35a
--- /dev/null
@@ -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 <Elementary.h>
+
+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_ */
index 9238269fbe36f447fa7f6f2a078fa032a1abf7b3..e9762c90ae036dfe0c25727b2851f26dfaed9abc 100644 (file)
@@ -21,6 +21,7 @@
 #include "BaseView.h"
 #include "LangUtils.h"
 #include "CallbackAssist.h"
+#include "AtspiAccessibleInterface.h"
 
 #include <Evas.h>
 #include <Elementary.h>
@@ -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_ */